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

rerender() return array changed paths

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