Commit 7e2fac60 authored by Roque's avatar Roque Committed by Roque

[erp5_web_renderjs_ui] Launcher: add setSettingList method

parent 08a65f23
...@@ -274,6 +274,36 @@ ...@@ -274,6 +274,36 @@
}); });
} }
function setSettingDict(gadget, setting_dict) {
var jio_gadget,
update_setting;
return gadget.getDeclaredGadget("setting_gadget")
.push(function (result) {
jio_gadget = result;
return jio_gadget.get(gadget.state.setting_id);
})
.push(undefined, function (error) {
if (error.status_code === 404) {
return {};
}
throw error;
})
.push(function (doc) {
for (var key in setting_dict) {
if (setting_dict.hasOwnProperty(key)) {
if (!doc.hasOwnProperty(key) ||
doc[key] !== setting_dict[key]) {
doc[key] = setting_dict[key];
update_setting = true;
}
}
}
if (update_setting) {
return jio_gadget.put(gadget.state.setting_id, doc);
}
});
}
rJS(window) rJS(window)
// Add mutex protected defered gadget loader. // Add mutex protected defered gadget loader.
...@@ -423,26 +453,15 @@ ...@@ -423,26 +453,15 @@
}); });
}) })
.allowPublicAcquisition("setSetting", function setSetting(argument_list) { .allowPublicAcquisition("setSetting", function setSetting(argument_list) {
var jio_gadget, var setting_dict = {};
gadget = this, setting_dict[argument_list[0]] = argument_list[1];
key = argument_list[0], return setSettingDict(this, setting_dict);
value = argument_list[1]; })
return gadget.getDeclaredGadget("setting_gadget") .allowPublicAcquisition("setSettingList",
.push(function (result) { function setSettingList(argument_list) {
jio_gadget = result; var setting_dict = argument_list[0];
return jio_gadget.get(gadget.state.setting_id); return setSettingDict(this, setting_dict);
}) })
.push(undefined, function (error) {
if (error.status_code === 404) {
return {};
}
throw error;
})
.push(function (doc) {
doc[key] = value;
return jio_gadget.put(gadget.state.setting_id, doc);
});
})
.allowPublicAcquisition("translateHtml", function translateHtml( .allowPublicAcquisition("translateHtml", function translateHtml(
argument_list argument_list
) { ) {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>978.22303.65392.4215</string> </value> <value> <string>978.22304.53878.1495</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1574872658.82</float> <float>1577703410.93</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