Commit d1006d7b authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Set setting_id parameter on the gadget state

parent bda7f4cb
...@@ -200,18 +200,19 @@ ...@@ -200,18 +200,19 @@
// Page rendering // Page rendering
////////////////////////////////////////// //////////////////////////////////////////
rJS(window) rJS(window)
.setState({
setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]'
).textContent
})
.ready(function () { .ready(function () {
var gadget = this, var gadget = this,
setting_gadget, setting_gadget,
setting; setting;
this.props = { this.props = {
loading_counter: 0, loading_counter: 0,
content_element: this.element.querySelector('.gadget-content'), content_element: this.element.querySelector('.gadget-content')
setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]'
).textContent
}; };
// Configure setting storage // Configure setting storage
return gadget.getDeclaredGadget("setting_gadget") return gadget.getDeclaredGadget("setting_gadget")
.push(function (result) { .push(function (result) {
...@@ -223,7 +224,7 @@ ...@@ -223,7 +224,7 @@
}) })
.push(function () { .push(function () {
return setting_gadget.get(gadget.props.setting_id) return setting_gadget.get(gadget.state.setting_id)
.push(undefined, function (error) { .push(undefined, function (error) {
if (error.status_code === 404) { if (error.status_code === 404) {
return {}; return {};
...@@ -266,7 +267,7 @@ ...@@ -266,7 +267,7 @@
} }
} }
return setting_gadget.put(gadget.props.setting_id, setting); return setting_gadget.put(gadget.state.setting_id, setting);
}) })
.push(function () { .push(function () {
// Configure jIO storage // Configure jIO storage
...@@ -296,7 +297,7 @@ ...@@ -296,7 +297,7 @@
.allowPublicAcquisition("getSettingList", .allowPublicAcquisition("getSettingList",
function getSettingList(argument_list) { function getSettingList(argument_list) {
var key_list = argument_list[0]; var key_list = argument_list[0];
return route(this, 'setting_gadget', 'get', [this.props.setting_id]) return route(this, 'setting_gadget', 'get', [this.state.setting_id])
.push(function (doc) { .push(function (doc) {
var i, var i,
result_list = []; result_list = [];
...@@ -315,7 +316,7 @@ ...@@ -315,7 +316,7 @@
var gadget = this, var gadget = this,
key = argument_list[0], key = argument_list[0],
default_value = argument_list[1]; default_value = argument_list[1];
return route(gadget, 'setting_gadget', 'get', [gadget.props.setting_id]) return route(gadget, 'setting_gadget', 'get', [gadget.state.setting_id])
.push(function (doc) { .push(function (doc) {
return doc[key] || default_value; return doc[key] || default_value;
}, function (error) { }, function (error) {
...@@ -333,7 +334,7 @@ ...@@ -333,7 +334,7 @@
return gadget.getDeclaredGadget("setting_gadget") return gadget.getDeclaredGadget("setting_gadget")
.push(function (result) { .push(function (result) {
jio_gadget = result; jio_gadget = result;
return jio_gadget.get(gadget.props.setting_id); return jio_gadget.get(gadget.state.setting_id);
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
if (error.status_code === 404) { if (error.status_code === 404) {
...@@ -343,7 +344,7 @@ ...@@ -343,7 +344,7 @@
}) })
.push(function (doc) { .push(function (doc) {
doc[key] = value; doc[key] = value;
return jio_gadget.put(gadget.props.setting_id, doc); return jio_gadget.put(gadget.state.setting_id, doc);
}); });
}) })
.allowPublicAcquisition("translateHtml", function translateHtml( .allowPublicAcquisition("translateHtml", function translateHtml(
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.11649.40314.9062</string> </value> <value> <string>971.11671.54203.21998</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1540458410.99</float> <float>1540459696.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