Skip to content

Commit 8806b5d

Browse files
committed
[modal] added allow-multiple + autofocus options
1 parent c9fa8c8 commit 8806b5d

File tree

8 files changed

+105
-4
lines changed

8 files changed

+105
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div>
2+
<ui-modal id="first-modal" attach-show=".show-modal" :allow-multiple="true">
3+
FIRST MODAL
4+
<span slot="actions">
5+
<ui-button v-on:click="showSecondModal">Show Second Modal</ui-button>
6+
<div class="ui negative button">Close</div>
7+
</span>
8+
</ui-modal>
9+
10+
<ui-modal id="second-modal" :allow-multiple="true">
11+
SECOND MODAL
12+
<span slot="actions">
13+
<div class="ui positive button">OK</div>
14+
</span>
15+
</ui-modal>
16+
17+
<ui-button class="show-modal">Show Modal</ui-button>
18+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component } from 'vue-typed';
2+
import { Base } from '../../base'
3+
import * as Vue from 'vue'
4+
5+
@Component({
6+
template: require('./index.html')
7+
})
8+
export class ModalMultiple extends Base {
9+
showSecondModal() {
10+
this.$ui.modal('#second-modal').show()
11+
}
12+
}

demo/src/demo/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { DateDemo } from './date';
2020
import { Time } from './time';
2121
import { DateTime } from './datetime';
2222
import { Modal } from './modal';
23+
import { ModalMultiple } from './modal/multiple';
2324
import { Tree } from './tree';
2425
import { MenuDropdown } from './menu/dropdown';
2526
import { MenuVertical } from './menu/vertical';
@@ -56,6 +57,7 @@ const m = [
5657
{ group: 'component/checkbox', text: 'Checkbox', path: 'checkbox', component: Checkbox },
5758
{ group: 'component/dropdown', text: 'Dropdown', path: 'dropdown', component: Dropdown },
5859
{ group: 'component/modal', text: 'Modal', path: 'modal', component: Modal },
60+
{ group: 'component/modal', text: 'Multiple Modal', path: 'modal/multiple', component: ModalMultiple },
5961
{ group: 'component/tree', text: 'Tree', path: 'tree', component: Tree },
6062
{ group: 'component/menu-dropdown', text: 'Menu Dropdown', path: 'menu/dropdown', component: MenuDropdown },
6163
{ group: 'component/menu-horizontal', text: 'Menu Horizontal', path: 'menu/horizontal', component: MenuHorizontal },

dist/vue-typed-ui.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,24 @@ var _ModalBase = function (_Vue) {
26752675

26762676
function _ModalBase() {
26772677
classCallCheck(this, _ModalBase);
2678-
return possibleConstructorReturn(this, (_ModalBase.__proto__ || Object.getPrototypeOf(_ModalBase)).apply(this, arguments));
2678+
2679+
/**
2680+
* Allow second modal to be opened on top of the first modal.
2681+
*
2682+
* @default false
2683+
* @type {boolean}
2684+
*/
2685+
var _this = possibleConstructorReturn(this, (_ModalBase.__proto__ || Object.getPrototypeOf(_ModalBase)).apply(this, arguments));
2686+
2687+
_this.allowMultiple = false;
2688+
/**
2689+
* First input in modal will receive focus when shown.
2690+
*
2691+
* @default false
2692+
* @type {boolean}
2693+
*/
2694+
_this.autofocus = false;
2695+
return _this;
26792696
}
26802697

26812698
return _ModalBase;
@@ -2697,6 +2714,12 @@ __decorate([vueTyped.Prop({
26972714
type: Boolean
26982715
})], _ModalBase.prototype, "closable", void 0);
26992716
__decorate([vueTyped.Prop()], _ModalBase.prototype, "transition", void 0);
2717+
__decorate([vueTyped.Prop({
2718+
type: Boolean
2719+
})], _ModalBase.prototype, "allowMultiple", void 0);
2720+
__decorate([vueTyped.Prop({
2721+
type: Boolean
2722+
})], _ModalBase.prototype, "autofocus", void 0);
27002723

27012724
var Modal = function (_ModalBase2) {
27022725
inherits(Modal, _ModalBase2);
@@ -2725,7 +2748,9 @@ var Modal = function (_ModalBase2) {
27252748
onHidden: emit('hidden'),
27262749
onVisible: emit('visible'),
27272750
closable: this.closable,
2728-
transition: this.transition
2751+
transition: this.transition,
2752+
allowMultiple: this.allowMultiple,
2753+
autofocus: this.autofocus
27292754
});
27302755
if (this.attachShow) $(this.$el).modal('attach events', this.attachShow, 'show');
27312756
if (this.attachHide) $(this.$el).modal('attach events', this.attachHide, 'hide');

doc/api.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@
809809
}
810810
},
811811
"props": {
812+
"allow-multiple": {
813+
"description": "Allow second modal to be opened on top of the first modal.",
814+
"type": "boolean",
815+
"default": "false"
816+
},
812817
"attach-hide": {
813818
"description": "Attach hide event to another element",
814819
"type": "string",
@@ -849,6 +854,11 @@
849854
}
850855
}
851856
},
857+
"autofocus": {
858+
"description": "First input in modal will receive focus when shown.",
859+
"type": "boolean",
860+
"default": "false"
861+
},
852862
"closable": {
853863
"description": "Setting to false will not allow you to close the modal by clicking on the dimmer.",
854864
"type": "boolean"

src/components/modal/_base.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,26 @@ export abstract class _ModalBase extends Vue {
7070
@Prop()
7171
transition: SemanticUI.AnimationNames
7272

73+
/**
74+
* Allow second modal to be opened on top of the first modal.
75+
*
76+
* @default false
77+
* @type {boolean}
78+
*/
79+
@Prop({
80+
type: Boolean
81+
})
82+
allowMultiple: boolean = false
83+
84+
/**
85+
* First input in modal will receive focus when shown.
86+
*
87+
* @default false
88+
* @type {boolean}
89+
*/
90+
@Prop({
91+
type: Boolean
92+
})
93+
autofocus: boolean = false
94+
7395
}

src/components/modal/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Modal extends _ModalBase implements SemanticUI.Modal.Settings {
3838
self.$emit(fn, e)
3939
return e.result;
4040
}
41-
} as Function
41+
} as Function
4242

4343
$(this.$el).modal({
4444
onDeny: emit('deny'),
@@ -48,7 +48,9 @@ export class Modal extends _ModalBase implements SemanticUI.Modal.Settings {
4848
onHidden: emit('hidden'),
4949
onVisible: emit('visible'),
5050
closable: this.closable,
51-
transition: this.transition
51+
transition: this.transition,
52+
allowMultiple: this.allowMultiple,
53+
autofocus: this.autofocus
5254
})
5355

5456
if (this.attachShow) $(this.$el).modal('attach events', this.attachShow, 'show')

src/components/modal/schema/props.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
"transition": {
5151
"description": "Named transition to use when animating menu in and out, full list can be found in ui transitions docs.",
5252
"type": "SemanticUI.AnimationNames"
53+
},
54+
"allow-multiple": {
55+
"description": "Allow second modal to be opened on top of the first modal.",
56+
"type": "boolean",
57+
"default": "false"
58+
},
59+
"autofocus": {
60+
"description": "First input in modal will receive focus when shown.",
61+
"type": "boolean",
62+
"default": "false"
5363
}
5464
}
5565
}

0 commit comments

Comments
 (0)