Commit 358c35c2 authored by Boris Kocherov's avatar Boris Kocherov

rerender() return array changed paths

parent d3801001
......@@ -981,7 +981,7 @@
return g.printErrors();
})
.push(function () {
if (g.props.form_gadget.props.changed) {
if (g.props.form_gadget.props.changed.length > 0) {
g.notifyChange();
}
})
......@@ -1028,10 +1028,13 @@
ignore_incorrect: opt.ignore_incorrect
})
.push(function () {
if (gadget.props.changed) {
if (gadget.props.changed.length > 0) {
value = undefined;
}
return gadget.reValidate(value, opt.schema);
})
.push(function () {
return gadget.props.changed;
});
});
})
......
......@@ -158,7 +158,7 @@
if (json_document !== undefined && !selected) {
if (g.props.ignore_incorrect) {
empty_option.selected = true;
g.props.changed = true;
g.props.changed.push(input);
} else {
// save original json_document even if it
// not support with schema
......@@ -216,7 +216,7 @@
if (json_document !== undefined && !selected) {
if (g.props.ignore_incorrect) {
empty_option.selected = true;
g.props.changed = true;
g.props.changed.push(input);
} else {
// save original json_document even if it
// not support with schema
......@@ -261,11 +261,8 @@
input.setAttribute('readonly', true);
if (json_document === undefined || g.props.ignore_incorrect ||
deepEqual(json_document, schema.const)) {
if (json_document === undefined) {
g.props.changed = true;
}
if (!deepEqual(json_document, schema.const)) {
g.props.changed = true;
if (json_document === undefined || !deepEqual(json_document, schema.const)) {
g.props.changed.push(input);
}
input.setAttribute('data-origin-value', ser_const);
if (schema.title) {
......@@ -362,8 +359,9 @@
}
})
.push(function () {
if (form_gadget.props.changed) {
g.props.changed = true;
if (form_gadget.props.changed.length > 0) {
// XXX not exactly path changed element
g.props.changed.push(parent_path);
}
return form_gadget.element;
});
......@@ -1005,7 +1003,7 @@
const: json_document
};
} else {
gadget.props.changed = true;
gadget.props.changed.push(first_path);
}
}
if (type === undefined && json_document !== undefined) {
......@@ -1587,15 +1585,15 @@
return queue;
})
.push(function () {
if (g.props.ignore_incorrect) {
g.props.changed = true;
return;
}
var key,
queue = RSVP.Queue();
for (key in json_document) {
if (json_document.hasOwnProperty(key)) {
if (!used_properties.hasOwnProperty(key)) {
if (g.props.ignore_incorrect) {
g.props.changed.push(path);
return;
}
queue
.push(
addSubForm.bind(g, {
......@@ -2110,7 +2108,7 @@
if (opt.ignore_incorrect !== undefined) {
g.props.ignore_incorrect = opt.ignore_incorrect;
}
g.props.changed = false;
g.props.changed = [];
g.props.inputs = [];
g.props.add_buttons = [];
g.props.add_custom_data = {};
......@@ -2136,9 +2134,15 @@
for (i = 0; i < for_delete.length; i += 1) {
root.removeChild(for_delete[i]);
}
if (g.props.changed) {
if (g.props.changed.length > 0) {
value = undefined;
}
g.props.changed = g.props.changed.map(function (el) {
if (el.name) {
return el.name;
}
return el;
});
return g.checkValidity(value);
})
.push(function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment