Commit 5c79470a authored by Tristan Cavelier's avatar Tristan Cavelier

DATETIMEFIELDUPDATE cleanup code

parent 7bd22168
...@@ -97,8 +97,10 @@ and handling data send&receive. ...@@ -97,8 +97,10 @@ and handling data send&receive.
content_key_list = Object.keys(current_content), content_key_list = Object.keys(current_content),
document_reference_dict = {}, document_reference_dict = {},
document_key_list = Object.keys(view), document_key_list = Object.keys(view),
i = 0, field = null, key = ""; i = 0,
for (; i < document_key_list.length; i += 1) { field = null,
key = "";
for (i = 0; i < document_key_list.length; i += 1) {
field = view[document_key_list[i]]; field = view[document_key_list[i]];
document_reference_dict[field.key] = field; document_reference_dict[field.key] = field;
} }
...@@ -310,7 +312,7 @@ and handling data send&receive. ...@@ -310,7 +312,7 @@ and handling data send&receive.
page_template_gadget = result; page_template_gadget = result;
var sub_options = options.fg || {}, var sub_options = options.fg || {},
queue = null; sub_queue = null;
loadFormContent(gadget, erp5_document._embedded._view); loadFormContent(gadget, erp5_document._embedded._view);
...@@ -322,7 +324,7 @@ and handling data send&receive. ...@@ -322,7 +324,7 @@ and handling data send&receive.
sub_options.editable = options.editable; // form decides on editability of its fields sub_options.editable = options.editable; // form decides on editability of its fields
if (gadget.state.changing && gadget.state.last_submitted_content) { if (gadget.state.changing && gadget.state.last_submitted_content) {
queue = page_template_gadget.getContent() sub_queue = page_template_gadget.getContent()
.push(function (content) { .push(function (content) {
updateErp5DocumentForAfterSave( updateErp5DocumentForAfterSave(
sub_options.erp5_document, sub_options.erp5_document,
...@@ -334,7 +336,7 @@ and handling data send&receive. ...@@ -334,7 +336,7 @@ and handling data send&receive.
}); });
} }
return (queue || new RSVP.Queue()) return (sub_queue || new RSVP.Queue())
.push(function () { .push(function () {
return page_template_gadget.render(sub_options); return page_template_gadget.render(sub_options);
}); });
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
rJS(window) rJS(window)
.declareMethod('render', function render(options) { .declareMethod('render', function render(options) {
//if (this.state && this.state.name === "field_my_short_title" || options && options.name === "field_my_short_title") console.log("input: render on call", options);
return this.changeState({ return this.changeState({
value: getFirstNonEmpty(options.value, ""), value: getFirstNonEmpty(options.value, ""),
checked: options.checked, checked: options.checked,
...@@ -42,32 +41,18 @@ ...@@ -42,32 +41,18 @@
}) })
.onStateChange(function onStateChange(modification_dict) { .onStateChange(function onStateChange(modification_dict) {
//if (this.state.name === "field_my_short_title") console.log("input: onStateChange on call", modification_dict);
var textarea = this.element.querySelector('input'), var textarea = this.element.querySelector('input'),
tmp; // general use short-scope variable tmp; // general use short-scope variable
/*if (modification_dict.hasOwnProperty("value")) { // TRISTAN
textarea.value = this.state.value;
textarea.setAttribute('value', this.state.value);
}
if (modification_dict.hasOwnProperty("checked")) { // TRISTAN
textarea.checked = this.state.checked;
if (this.state.checked) {
textarea.setAttribute('checked', 'checked');
} else {
textarea.removeAttribute('checked');
}
}/**/
if (this.state.type === 'checkbox') { if (this.state.type === 'checkbox') {
textarea.checked = this.state.checked; // TRISTAN textarea.checked = this.state.checked;
} else { } else {
textarea.setAttribute('value', this.state.value); // TRISTAN textarea.setAttribute('value', this.state.value);
textarea.value = this.state.value; // TRISTAN textarea.value = this.state.value;
} }
if (this.state.type === 'radio') { if (this.state.type === 'radio') {
textarea.checked = this.state.checked; // TRISTAN textarea.checked = this.state.checked;
}/**/ }
textarea.id = this.state.id || this.state.name; textarea.id = this.state.id || this.state.name;
textarea.setAttribute('name', this.state.name); textarea.setAttribute('name', this.state.name);
...@@ -221,15 +206,13 @@ ...@@ -221,15 +206,13 @@
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareAcquiredMethod("notifyChange", "notifyChange") .declareAcquiredMethod("notifyChange", "notifyChange")
//.onEvent('change', function change() { .onEvent('change', function change() {
.onEvent('change', function change(event) { var input = this.element.querySelector("input");
//if (this.state.name === "field_my_short_title") console.log("input: event change", event, event.target.value);
var input = this.element.querySelector("input"); // TRISTAN
if (input) { if (input) {
// force the state to have the current edited value // force the state to have the current edited value
this.state.checked = input.checked; this.state.checked = input.checked;
this.state.value = input.value; this.state.value = input.value;
}/**/ }
return RSVP.all([ return RSVP.all([
this.checkValidity(), this.checkValidity(),
this.notifyChange("change") this.notifyChange("change")
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.39254.10526.36096</string> </value> <value> <string>975.45053.32644.40618</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1557412896.19</float> <float>1557839422.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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