|
@@ -21,7 +21,7 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="buttons row justify-end q-pa-md">
|
|
<div class="buttons row justify-end q-pa-md">
|
|
- <q-btn class="q-px-md" dense no-caps @click="okClick" v-close-popup>OK</q-btn>
|
|
|
|
|
|
+ <q-btn class="q-px-md" dense no-caps @click="okClick">OK</q-btn>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -45,7 +45,7 @@
|
|
|
|
|
|
<div class="buttons row justify-end q-pa-md">
|
|
<div class="buttons row justify-end q-pa-md">
|
|
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
|
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
|
- <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick" v-close-popup>OK</q-btn>
|
|
|
|
|
|
+ <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">OK</q-btn>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -65,12 +65,13 @@
|
|
|
|
|
|
<div class="col q-mx-md">
|
|
<div class="col q-mx-md">
|
|
<div v-html="message"></div>
|
|
<div v-html="message"></div>
|
|
- <q-input ref="input" outlined dense v-model="inputValue"/>
|
|
|
|
|
|
+ <q-input ref="input" class="q-mt-xs" outlined dense v-model="inputValue"/>
|
|
|
|
+ <div class="error"><span v-show="error != ''">{{ error }}</span></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="buttons row justify-end q-pa-md">
|
|
<div class="buttons row justify-end q-pa-md">
|
|
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
|
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
|
- <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick" v-close-popup>OK</q-btn>
|
|
|
|
|
|
+ <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">OK</q-btn>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</q-dialog>
|
|
</q-dialog>
|
|
@@ -84,6 +85,11 @@ import Component from 'vue-class-component';
|
|
//import * as utils from '../../share/utils';
|
|
//import * as utils from '../../share/utils';
|
|
|
|
|
|
export default @Component({
|
|
export default @Component({
|
|
|
|
+ watch: {
|
|
|
|
+ inputValue: function(newValue) {
|
|
|
|
+ this.validate(newValue);
|
|
|
|
+ },
|
|
|
|
+ }
|
|
})
|
|
})
|
|
class StdDialog extends Vue {
|
|
class StdDialog extends Vue {
|
|
caption = '';
|
|
caption = '';
|
|
@@ -91,6 +97,7 @@ class StdDialog extends Vue {
|
|
active = false;
|
|
active = false;
|
|
type = '';
|
|
type = '';
|
|
inputValue = '';
|
|
inputValue = '';
|
|
|
|
+ error = '';
|
|
|
|
|
|
created() {
|
|
created() {
|
|
if (this.$root.addKeyHook) {
|
|
if (this.$root.addKeyHook) {
|
|
@@ -104,6 +111,9 @@ class StdDialog extends Vue {
|
|
|
|
|
|
this.ok = false;
|
|
this.ok = false;
|
|
this.type = '';
|
|
this.type = '';
|
|
|
|
+ this.inputValidator = null;
|
|
|
|
+ this.inputValue = '';
|
|
|
|
+ this.error = '';
|
|
}
|
|
}
|
|
|
|
|
|
onHide() {
|
|
onHide() {
|
|
@@ -115,12 +125,35 @@ class StdDialog extends Vue {
|
|
|
|
|
|
onShow() {
|
|
onShow() {
|
|
if (this.type == 'prompt') {
|
|
if (this.type == 'prompt') {
|
|
|
|
+ this.enableValidator = true;
|
|
|
|
+ if (this.inputValue)
|
|
|
|
+ this.validate(this.inputValue);
|
|
this.$refs.input.focus();
|
|
this.$refs.input.focus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ validate(value) {
|
|
|
|
+ if (!this.enableValidator)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (this.inputValidator) {
|
|
|
|
+ const result = this.inputValidator(value);
|
|
|
|
+ if (result !== true) {
|
|
|
|
+ this.error = result;
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.error = '';
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
okClick() {
|
|
okClick() {
|
|
|
|
+ if (this.type == 'prompt' && !this.validate(this.inputValue)) {
|
|
|
|
+ this.$refs.dialog.shake();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
this.ok = true;
|
|
this.ok = true;
|
|
|
|
+ this.$refs.dialog.hide();
|
|
}
|
|
}
|
|
|
|
|
|
alert(message, caption) {
|
|
alert(message, caption) {
|
|
@@ -159,6 +192,7 @@ class StdDialog extends Vue {
|
|
|
|
|
|
prompt(message, caption, opts) {
|
|
prompt(message, caption, opts) {
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
|
|
+ this.enableValidator = false;
|
|
this.init(message, caption);
|
|
this.init(message, caption);
|
|
|
|
|
|
this.hideTrigger = () => {
|
|
this.hideTrigger = () => {
|
|
@@ -170,8 +204,10 @@ class StdDialog extends Vue {
|
|
};
|
|
};
|
|
|
|
|
|
this.type = 'prompt';
|
|
this.type = 'prompt';
|
|
- this.inputValue = opts.inputValue || '';
|
|
|
|
- this.inputValidator = opts.inputValidator || null;
|
|
|
|
|
|
+ if (opts) {
|
|
|
|
+ this.inputValidator = opts.inputValidator || null;
|
|
|
|
+ this.inputValue = opts.inputValue || '';
|
|
|
|
+ }
|
|
this.active = true;
|
|
this.active = true;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -179,7 +215,6 @@ class StdDialog extends Vue {
|
|
keyHook(event) {
|
|
keyHook(event) {
|
|
if (this.active && event.code == 'Enter') {
|
|
if (this.active && event.code == 'Enter') {
|
|
this.okClick();
|
|
this.okClick();
|
|
- this.$refs.dialog.hide();
|
|
|
|
event.stopPropagation();
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
@@ -206,4 +241,9 @@ class StdDialog extends Vue {
|
|
height: 60px;
|
|
height: 60px;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+.error {
|
|
|
|
+ height: 20px;
|
|
|
|
+ font-size: 80%;
|
|
|
|
+ color: red;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|