Skip to content

Commit

Permalink
🔖 0.8.0
Browse files Browse the repository at this point in the history
update README and expamle
  • Loading branch information
yourtion committed May 18, 2018
1 parent a5c9b78 commit da48a03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions lib/json-editor.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ function initChild(data, ns) {
const n = ns[i];
const ret = getExtendibleLeaf(obj, n, true);
if (ret === undefined) {
throw new TypeError('fail to init because namespace ' + ns.join('.') + ' = ' + obj + '(' + (typeof obj) + ')');
throw new TypeError('fail to init because namespace ' + ns.join('.') + ' = ' + obj + '(' + typeof obj + ')');
}
parent = obj;
obj = ret;
Expand All @@ -961,7 +961,7 @@ function setVal(data, n, v) {
const ns = Array.isArray(n) ? n : n.split('.');
// eslint-disable-next-line
n = ns.pop();
const ret = (ns.length > 0 ? initChild(data, ns) : data);
const ret = ns.length > 0 ? initChild(data, ns) : data;
ret[n] = v;
return v;
}
Expand Down Expand Up @@ -1883,13 +1883,11 @@ exports.f = {}.propertyIsEnumerable;

const { initChild, getChild } = __webpack_require__(29);

const ARRAY_KEYWORDS = [ 'anyOf', 'oneOf', 'enum' ];
const ARRAY_KEYWORDS = ['anyOf', 'oneOf', 'enum'];

const setCommonFields = (schema, field, schemaName) => {
// eslint-disable-next-line no-nested-ternary
field.value = schema.hasOwnProperty('default')
? schema.default
: field.hasOwnProperty('value') ? field.value : '';
field.value = schema.hasOwnProperty('default') ? schema.default : field.hasOwnProperty('value') ? field.value : '';

field.component = schema.component;
field.schemaType = schema.type;
Expand All @@ -1905,12 +1903,11 @@ const setFormValue = (vm, field) => {
const vmValue = getChild(vm.value, ns);
if (vm.value && !vmValue) {
const n = ns.pop();
const ret = (ns.length > 0 ? initChild(vm.value, ns) : vm.value);
const ret = ns.length > 0 ? initChild(vm.value, ns) : vm.value;
vm.$set(ret, n, field.value);
}
};


const parseBoolean = (vm, schema, schemaName) => {
const field = schema.attrs || {};

Expand Down Expand Up @@ -1990,8 +1987,8 @@ const parseString = (vm, schema, schemaName) => {
/* unused harmony export parseString */


const parseItems = (items) => {
return items.map((item) => {
const parseItems = items => {
return items.map(item => {
if (typeof item !== 'object') {
return { value: item, label: item };
}
Expand Down Expand Up @@ -2032,11 +2029,10 @@ const parseArray = (vm, schema, schemaName) => {
field.value = field.value || [];
field.items = parseItems(schema[keyword]);
break;

}
}
}
if(!field.type) {
if (!field.type) {
field.type = schema.type;
field.value = field.value || [];
field.items = [];
Expand Down Expand Up @@ -2070,14 +2066,19 @@ const loadFields = (vm, schema, fields = vm.fields, sub) => {
}
}
}
if(schema.name && !fields[schemaName]) {
if (schema.name && !fields[schemaName]) {
fields[schemaName] = {
$sub: true,
$title: schema.title,
$description: schema.description,
};
}
loadFields(vm, schema.properties[key], schema.name ? fields[schemaName] : undefined, sub ? [ ...sub, key ] : [ key ]);
loadFields(
vm,
schema.properties[key],
schema.name ? fields[schemaName] : undefined,
sub ? [...sub, key] : [key]
);
}
break;

Expand Down Expand Up @@ -2107,7 +2108,6 @@ const loadFields = (vm, schema, fields = vm.fields, sub) => {
default:
fields[schemaName] = parseString(vm, schema, schemaName);
}

};
/* harmony export (immutable) */ __webpack_exports__["a"] = loadFields;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-json-ui-editor",
"version": "0.7.0",
"version": "0.8.0",
"description": "Edit JSON in UI form with JSON Schema and Vue.js",
"author": "YourtionGuo <yourtion@gmail.com>",
"scripts": {
Expand Down

0 comments on commit da48a03

Please sign in to comment.