+
+
+
+
+
+
+
+
+ Отмена
+ OK
+
+
@@ -63,6 +90,7 @@ class StdDialog extends Vue {
message = '';
active = false;
type = '';
+ inputValue = '';
created() {
if (this.$root.addKeyHook) {
@@ -85,6 +113,12 @@ class StdDialog extends Vue {
}
}
+ onShow() {
+ if (this.type == 'prompt') {
+ this.$refs.input.focus();
+ }
+ }
+
okClick() {
this.ok = true;
}
@@ -123,6 +157,25 @@ class StdDialog extends Vue {
});
}
+ prompt(message, caption, opts) {
+ return new Promise((resolve) => {
+ this.init(message, caption);
+
+ this.hideTrigger = () => {
+ if (this.ok) {
+ resolve(true);
+ } else {
+ resolve(false);
+ }
+ };
+
+ this.type = 'prompt';
+ this.inputValue = opts.inputValue || '';
+ this.inputValidator = opts.inputValidator || null;
+ this.active = true;
+ });
+ }
+
keyHook(event) {
if (this.active && event.code == 'Enter') {
this.okClick();