Commit 20793c52 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Drop getTextContent method

This was only used by listbox.
As most fields now render themself as 'p' tag in non editable mode, they are compatible with non editable listboxes to be rendered inside an 'a' tag.
parent 3f1a84f1
......@@ -61,13 +61,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375799.46</float>
<float>1482843222.46</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -224,14 +224,17 @@
} else {
queue
.push(function (gadget_list) {
return RSVP.all([
gadget_list[0],
gadget.getTextContent()
]);
})
.push(function (result_list) {
p_state.text_content = result_list[1];
return result_list[0].render(p_state);
var text_content = "",
state_date;
if (gadget.state.value) {
state_date = new Date(gadget.state.value);
text_content = state_date.toLocaleDateString();
if (!gadget.state.date_only) {
text_content += " " + state_date.toLocaleTimeString();
}
}
p_state.text_content = text_content;
return gadget_list[0].render(p_state);
});
}
return queue;
......@@ -346,19 +349,6 @@
return result;
})
.declareMethod('getTextContent', function () {
var result = "",
date;
if (this.state.value) {
date = new Date(this.state.value);
result = date.toLocaleDateString();
if (!this.state.date_only) {
result += " " + date.toLocaleTimeString();
}
}
return result;
})
.declareMethod('checkValidity', function () {
var gadget = this;
if (gadget.state.editable) {
......
......@@ -224,7 +224,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.33816.11447.60450</string> </value>
<value> <string>956.15728.7577.42257</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -242,7 +242,7 @@
</tuple>
<state>
<tuple>
<float>1480083572.88</float>
<float>1482843916.5</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -62,13 +62,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375741.07</float>
<float>1482843519.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -60,10 +60,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return "";
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.47131.47054.46694</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375829.11</float>
<float>1482843418.41</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -70,13 +70,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.15606.9114.8567</string> </value>
<value> <string>956.15709.17217.39492</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1482842715.75</float>
<float>1482842913.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -64,13 +64,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.15546.61555.10547</string> </value>
<value> <string>956.15712.57649.37376</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1482836410.69</float>
<float>1482843064.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -60,45 +60,15 @@
gadget.props.listbox_uid_dict = {};
gadget.props.cell_gadget_list = [];
function renderSubCell(element, sub_field_json) {
var options = {},
queue;
sub_field_json.editable = sub_field_json.editable && gadget.state.editable; // XXX
queue = gadget.getFieldTypeGadgetUrl(sub_field_json.type);
queue
return gadget.getFieldTypeGadgetUrl(sub_field_json.type)
.push(function (gadget_url) {
if (sub_field_json.editable) {
options = {
element: element
};
}
return gadget.declareGadget(gadget_url, options);
return gadget.declareGadget(gadget_url, {element: element});
})
.push(function (cell_gadget) {
if (sub_field_json.editable) {
gadget.props.cell_gadget_list.push(cell_gadget);
} else {
if (cell_gadget.getTextContent) {
queue
.push(function () {
return cell_gadget.getTextContent();
})
.push(function (text_content) {
var text = document.createTextNode(text_content);
element.appendChild(text);
});
} else {
queue
.push(function () {
return cell_gadget.getElement();
})
.push(function (cell_element) {
element.appendChild(cell_element);
});
}
}
gadget.props.cell_gadget_list.push(cell_gadget);
return cell_gadget.render({field_json: sub_field_json});
});
return queue;
}
for (i = 0; i < element_list.length; i += 1) {
column = element_list[i].getAttribute("column");
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.20595.9130.22579</string> </value>
<value> <string>956.15532.4001.22118</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1479307118.44</float>
<float>1482835694.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -89,13 +89,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.47274.43639.56354</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375598.52</float>
<float>1482843508.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -119,14 +119,6 @@
return final_result;
})
/*
.declareMethod('getTextContent', function () {
// I don't know if a multilistfield was ever used in a listbox
// Skip for now
throw new Error('not implemented');
})
*/
.allowPublicAcquisition('notifyValid', function () {
return;
})
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375515.85</float>
<float>1482843497.05</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -71,13 +71,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479375816.46</float>
<float>1482843530.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -62,13 +62,6 @@
return {};
})
.declareMethod('getTextContent', function () {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getTextContent();
});
})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.51162.4768.35123</string> </value>
<value> <string>955.60919.29957.58146</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1481623167.42</float>
<float>1482843372.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -39,10 +39,6 @@
element.removeChild(element.firstChild);
}
element.appendChild(new_element);
})
.declareMethod('getTextContent', function (options) {
return this.state.text_content;
});
}(window, document, rJS));
\ No newline at end of file
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.2251.20190.28416</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1478189649.02</float>
<float>1482843300.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -117,24 +117,6 @@
return result;
})
.declareMethod('getTextContent', function () {
var result = '',
input = this.element.querySelector('input');
if (this.state.type === 'checkbox') {
result = (input.checked ? '' : '');
} else if (this.state.type === 'radio') {
if (input.checked) {
result = input.value;
}
} else {
result = input.value;
if (this.state.trim) {
result = result.trim();
}
}
return result;
})
.declareAcquiredMethod("notifyValid", "notifyValid")
.declareMethod('checkValidity', function () {
var result = this.element.querySelector('input').checkValidity(),
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.51162.4768.35123</string> </value>
<value> <string>955.60922.14888.40516</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1481623333.62</float>
<float>1482843242.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -109,11 +109,6 @@
return result;
})
.declareMethod('getTextContent', function () {
var select = this.element.querySelector('select');
return select.options[select.selectedIndex].text;
})
.declareAcquiredMethod("notifyValid", "notifyValid")
.declareMethod('checkValidity', function () {
var result = this.element.querySelector('select').checkValidity();
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value>
<value> <string>955.51162.4768.35123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1479374875.05</float>
<float>1482843283.34</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