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

DATETIMEFIELDUPDATE cleanup code

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