Commit 9929bc4f authored by Tristan Cavelier's avatar Tristan Cavelier

DATETIMEFIELDUPDATE +1 (remove TRISTAN, console.log, ERP5TypeTestCase)

                                     version   | generique       | render               | onchange            | onmodification      | ideale
have A and B with empty reference,               keep typed        field reset to empty   keep typed            ?                     field reset empty
goto A, click next to acces B,
type in reference while B form is loading,
B is loaded

same with B reference = 1                        field set to 1    field set to 1         field set to 1        ?                     field set to 1

have A with empty reference,                     keep typed        field reset to empty   field reset to empty  ?                     field reset to empty
type in reference (hello),                       (hello)           ()                     ()                    (?)                   ()
click View on confirm popup,
A is reloaded

have A with empty reference,                     keep typed        field reset to empty   field reset to empty  ?                     field reset to empty
click View to reload the form,                   (hello2)          ()                     ()                    (?)                   ()
type in reference (hello2),
A is reloaded

have A with empty reference,                     keep typed        field reset            field reset           ?                     keep typed (the form decides
to update the field but should not ? no)
type in reference (hello), save,                 (hello2)          (hello)                (hello) (why??)       (?)                   (hello2)
type in reference (hello2),
focus something else,
A form is reloaded

have A with empty reference,                     field reset       field reset            field reset           ?                     field reset (user should see
the modification done server side)
type in reference (hello), click save,           (world)           (world)                (world)               (?)                   (world)
type in reference (hello2),
focus something else,
interaction add modifications to the reference
(world),
A form is reloaded

------------------------------------
So !

input.value MUST be updated on onStateChange if modification_dict.hasOwnProperty("value")
this.state.value MUST be updated on getContent
this.state.value MUST be updated on onEvent change

------------------------------------
UNRELATED NOTES

input.value reflects the typed value of the element
gadget_input.getContent reflects the typed value of the element too

input.value = "hello" replaces the current value to "hello", no matter the state of the input
gadget_input.render({value: "hello"}) does not... because gadget.state.value does not really reflects the dom value.
  if gadget.state.value was reflecting the value, then
gadget_input.render({value: "hello"}) reflects the current value to "hello", no matter the state of the input

so the form could act : while saving, listen for changes/inputs, (now saved) get the new form but ignore it, put save to orange if changes/inputs were done
parent 002b97ee
...@@ -19,12 +19,7 @@ ...@@ -19,12 +19,7 @@
rJS(window) rJS(window)
.declareMethod('render', function render(options) { .declareMethod('render', function render(options) {
var input = this.element.querySelector("input"); if (this.state && this.state.name === "field_my_title" || options && options.name === "field_my_title") console.log("input: render on call", options);
if (input) {
// force the state to have the current edited value
this.state.checked = input.checked;
this.state.value = input.value;
}
return this.changeState({ return this.changeState({
value: getFirstNonEmpty(options.value, ""), value: getFirstNonEmpty(options.value, ""),
checked: options.checked, checked: options.checked,
...@@ -47,17 +42,31 @@ ...@@ -47,17 +42,31 @@
}) })
.onStateChange(function onStateChange(modification_dict) { .onStateChange(function onStateChange(modification_dict) {
if (this.state.name === "field_my_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 (this.state.type === 'checkbox') { 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; 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 { } else {
textarea.setAttribute('value', this.state.value); // textarea.setAttribute('value', this.state.value); // TRISTAN
textarea.value = this.state.value; // textarea.value = this.state.value; // TRISTAN
} }
if (this.state.type === 'radio') { if (this.state.type === 'radio') {
textarea.checked = this.state.checked; // textarea.checked = this.state.checked; // TRISTAN
} }
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);
...@@ -212,7 +221,15 @@ ...@@ -212,7 +221,15 @@
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareAcquiredMethod("notifyChange", "notifyChange") .declareAcquiredMethod("notifyChange", "notifyChange")
.onEvent('change', function change() { //.onEvent('change', function change() {
.onEvent('change', function change(event) {
if (this.state.name === "field_my_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([ return RSVP.all([
this.checkValidity(), this.checkValidity(),
this.notifyChange("change") this.notifyChange("change")
......
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>ERP5TypeTestCase</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -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.16158.58810.54749</string> </value> <value> <string>975.39254.10526.36096</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>1556111993.61</float> <float>1557412896.19</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