Commit 4e083e84 authored by Tristan Cavelier's avatar Tristan Cavelier

Revert "DATETIMEFIELDUPDATE cleanup code"

This reverts commit 5c79470a.
parent eabe52e1
......@@ -97,10 +97,8 @@ 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 = 0; i < document_key_list.length; i += 1) {
i = 0, field = null, key = "";
for (; i < document_key_list.length; i += 1) {
field = view[document_key_list[i]];
document_reference_dict[field.key] = field;
}
......@@ -312,7 +310,7 @@ and handling data send&receive.
page_template_gadget = result;
var sub_options = options.fg || {},
sub_queue = null;
queue = null;
loadFormContent(gadget, erp5_document._embedded._view);
......@@ -324,7 +322,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) {
sub_queue = page_template_gadget.getContent()
queue = page_template_gadget.getContent()
.push(function (content) {
updateErp5DocumentForAfterSave(
sub_options.erp5_document,
......@@ -336,7 +334,7 @@ and handling data send&receive.
});
}
return (sub_queue || new RSVP.Queue())
return (queue || new RSVP.Queue())
.push(function () {
return page_template_gadget.render(sub_options);
});
......
......@@ -19,6 +19,7 @@
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,
......@@ -41,18 +42,32 @@
})
.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 (this.state.type === 'checkbox') {
textarea.checked = this.state.checked;
} else {
textarea.setAttribute('value', this.state.value);
/*if (modification_dict.hasOwnProperty("value")) { // TRISTAN
textarea.value = this.state.value;
textarea.setAttribute('value', this.state.value);
}
if (this.state.type === 'radio') {
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
} else {
textarea.setAttribute('value', this.state.value); // TRISTAN
textarea.value = this.state.value; // TRISTAN
}
if (this.state.type === 'radio') {
textarea.checked = this.state.checked; // TRISTAN
}/**/
textarea.id = this.state.id || this.state.name;
textarea.setAttribute('name', this.state.name);
......@@ -206,13 +221,15 @@
}, {mutex: 'changestate'})
.declareAcquiredMethod("notifyChange", "notifyChange")
.onEvent('change', function change() {
var input = this.element.querySelector("input");
//.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
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.45053.32644.40618</string> </value>
<value> <string>975.39254.10526.36096</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1557839422.8</float>
<float>1557412896.19</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