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 @@
});
}
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)
// Add mutex protected defered gadget loader.
......@@ -423,26 +453,15 @@
});
})
.allowPublicAcquisition("setSetting", function setSetting(argument_list) {
var jio_gadget,
gadget = this,
key = argument_list[0],
value = argument_list[1];
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) {
doc[key] = value;
return jio_gadget.put(gadget.state.setting_id, doc);
});
})
var setting_dict = {};
setting_dict[argument_list[0]] = argument_list[1];
return setSettingDict(this, setting_dict);
})
.allowPublicAcquisition("setSettingList",
function setSettingList(argument_list) {
var setting_dict = argument_list[0];
return setSettingDict(this, setting_dict);
})
.allowPublicAcquisition("translateHtml", function translateHtml(
argument_list
) {
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.22303.65392.4215</string> </value>
<value> <string>978.22304.53878.1495</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1574872658.82</float>
<float>1577703410.93</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