Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f5607a

Browse files
Enhance prompt
1 parent b5eecf8 commit 9f5607a

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

extensions/web-base/www/app/app.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,28 +552,43 @@ var promptDialog = new Vue({
552552
data: {
553553
message: 'Nothing here',
554554
schema: false,
555-
value: null
555+
value: ''
556556
},
557557
methods: {
558558
ask: function(schema, message) {
559+
if (typeof schema === 'string') {
560+
message = schema;
561+
schema = undefined;
562+
}
559563
if (!isObject(schema)) {
560-
return Promise.reject('invalid schema');
564+
schema = {
565+
title: 'Value',
566+
type: 'string'
567+
};
561568
}
562-
this.schema = schema;
569+
var wrapped = false;
563570
if (schema.type === 'object') {
571+
this.schema = schema;
564572
this.value = {};
565573
} else if (schema.type === 'array') {
574+
this.schema = schema;
566575
this.value = [];
567576
} else {
568-
this.value = '';
577+
this.schema = {
578+
type: 'array',
579+
prefixItems: [schema],
580+
minItems: 1
581+
}
582+
this.value = [];
583+
wrapped = true;
569584
}
570585
this.message = message || 'Value?';
571586
app.openDialog('prompt');
572587
var self = this;
573588
return new Promise(function(resolve, reject) {
574589
self.apply = function(confirm) {
575590
if (confirm) {
576-
resolve(self.value);
591+
resolve(wrapped ? self.value[0] : self.value);
577592
} else {
578593
reject('canceled');
579594
}

extensions/web-base/www/app/json.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,15 @@ Vue.component('json-item', {
426426
v = parseJsonItemValue(this.schema.type, val);
427427
}
428428
}
429-
var k = this.$vnode.key;
430-
if (v === undefined) {
431-
delete this.pobj[k];
432-
} else {
433-
this.pobj[k] = v;
429+
if (this.pobj && isObject(this.pobj)) {
430+
var k = this.$vnode.key;
431+
if (v === undefined) {
432+
delete this.pobj[k];
433+
} else {
434+
this.pobj[k] = v;
435+
}
436+
} else if (v !== undefined) {
437+
this.obj = v;
434438
}
435439
}
436440
},

0 commit comments

Comments
 (0)