Commit 87f5354c authored by Boris Kocherov's avatar Boris Kocherov

notifyChange emited on every input event, and then limit check validity on every 0.5 sec

parent 08481383
......@@ -420,7 +420,8 @@
})
.declareAcquiredMethod("downloadJSON", "downloadJSON")
.declareAcquiredMethod("notifyChange", "notifyChange")
.allowPublicAcquisition("notifyChange", function () {
.allowPublicAcquisition("rootNotifyChange", function () {
this.props.changed = true;
return this.notifyChange();
})
.declareAcquiredMethod("notifyValid", "notifyValid")
......@@ -643,6 +644,15 @@
// XXX Disable
return;
})
.onLoop(function () {
var gadget = this;
if (this.props.changed) {
return this.checkValidity()
.push(function () {
gadget.props.changed = false;
});
}
}, 500)
.declareMethod('getContent', function () {
var g = this;
......
......@@ -273,13 +273,6 @@
return ret_arr[0];
}
function checkValidityAndNotifyChange(g) {
return RSVP.all([
g.checkValidity(),
g.notifyChange()
]);
}
function render_schema_selector(gadget, title, schema_arr, event, rerender) {
return RSVP.Queue()
.push(function () {
......@@ -385,7 +378,7 @@
return event(schema_alternatives[value[scope]].value);
})
.push(function () {
return checkValidityAndNotifyChange(gadget);
return gadget.rootNotifyChange();
})
.push(function () {
if (rerender) {
......@@ -450,7 +443,7 @@
} else {
input.removeAttribute("style");
}
return checkValidityAndNotifyChange(gadget);
return gadget.rootNotifyChange();
});
},
rerender: function () {
......@@ -1298,7 +1291,7 @@
g.props = {};
g.options = {};
})
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("rootNotifyChange", "rootNotifyChange")
.declareAcquiredMethod("renameChildrenParent", "renameChildren")
.allowPublicAcquisition("renameChildren", function (opt_arr, scope) {
var property_name,
......@@ -1362,7 +1355,7 @@
for (i = 0; i < button_list.length; i = i + 1) {
tasks.push(button_list[i].rerender());
}
tasks.push(checkValidityAndNotifyChange(g));
tasks.push(g.rootNotifyChange());
return RSVP.Queue()
.push(function () {
return RSVP.all(tasks);
......@@ -1461,7 +1454,7 @@
if (event_object && opt.type === "change") {
return event_object.event();
}
return g.notifyChange();
return g.rootNotifyChange();
})
.declareMethod('renderForm', function (options) {
var g = this,
......@@ -1529,18 +1522,23 @@
}
})
.onEvent('change', function (evt) {
.onEvent('input', function (evt) {
if (evt.target === this.props.property_name_edit) {
return this.rename(this.props.property_name_edit.value, evt);
}
var field_list = this.props.inputs,
i;
var gadget = this,
field_list = this.props.inputs,
i,
changed = false;
// on form data field
for (i = 0; i < field_list.length; i = i + 1) {
if (evt.target === field_list[i]) {
return checkValidityAndNotifyChange(this);
changed = true;
}
}
if (changed) {
return gadget.rootNotifyChange();
}
})
......
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