Commit 41f8646e authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs, erp5_web_renderjs_ui: add setVolatileSetting

parent 167c9f03
......@@ -220,6 +220,7 @@
})
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setVolatileSetting', 'setVolatileSetting')
.declareAcquiredMethod('setSetting', 'setSetting')
.declareMethod("getCommandUrlFor", function (options) {
var prefix = '',
......@@ -308,7 +309,7 @@
if (a == "portal_type") {
NAME = b.toLowerCase();
}
return gadget.setSetting(a, b);
return gadget.setVolatileSetting(a, b);
});
}
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.30941.12978.18978</string> </value>
<value> <string>953.32243.18684.49254</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1472135853.24</float>
<float>1472224693.07</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -8,6 +8,7 @@
.ready(function (gadget) {
// Initialize the gadget local parameters
gadget.state_parameter_dict = {};
gadget.state_parameter_dict.volatile_settings = {};
gadget.state_parameter_dict.jio_storage = jIO.createJIO({
type: "indexeddb",
database: "global-setting"
......@@ -16,7 +17,8 @@
.declareMethod('getSetting', function (key, default_value) {
var gadget = this;
return gadget.state_parameter_dict.jio_storage.get("setting")
return gadget.state_parameter_dict.volatile_settings[key] ||
gadget.state_parameter_dict.jio_storage.get("setting")
.push(function (doc) {
return doc[key] || default_value;
}, function (error) {
......@@ -39,5 +41,10 @@
doc[key] = value;
return gadget.state_parameter_dict.jio_storage.put('setting', doc);
});
})
.declareMethod('setVolatileSetting', function (key, value) {
var gadget = this;
gadget.state_parameter_dict.volatile_settings[key] = value;
return {};
});
}(window, rJS, jIO));
\ No newline at end of file
......@@ -251,7 +251,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -265,7 +265,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.59871.63141.64426</string> </value>
<value> <string>953.32236.42703.4147</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -283,7 +283,7 @@
</tuple>
<state>
<tuple>
<float>1466091728.66</float>
<float>1472228963.67</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -177,7 +177,8 @@
}
function getSetting(gadget, key, default_value) {
return gadget.getDeclaredGadget("setting_gadget")
return gadget.props.volatile_settings[key] ||
gadget.getDeclaredGadget("setting_gadget")
.push(function (jio_gadget) {
return jio_gadget.get("setting");
})
......@@ -191,6 +192,11 @@
});
}
function setVolatileSetting(gadget, key, value) {
gadget.props.volatile_settings[key] = value;
return {};
}
function setSetting(gadget, key, value) {
var jio_gadget;
return gadget.getDeclaredGadget("setting_gadget")
......@@ -216,6 +222,7 @@
rJS(window)
.ready(function (g) {
g.props = {};
g.props.volatile_settings = {};
return g.getElement()
.push(function (element) {
$(element).trigger("create");
......@@ -297,6 +304,9 @@
.allowPublicAcquisition("getSetting", function (argument_list) {
return getSetting(this, argument_list[0], argument_list[1]);
})
.allowPublicAcquisition("setVolatileSetting", function (argument_list) {
return setVolatileSetting(this, argument_list[0], argument_list[1]);
})
.allowPublicAcquisition("setSetting", function (argument_list) {
return setSetting(this, argument_list[0], argument_list[1]);
})
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.1266.16388.62907</string> </value>
<value> <string>953.32473.8185.46148</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1458731136.97</float>
<float>1472225816.15</float>
<string>UTC</string>
</tuple>
</state>
......
  • I do not understand advantage of using in this context. Especially when there are two layers (one part stored in erp5_launcher and the other part in setting gadget)

  • @cedric.leninivin , please correct me if i'm wrong. There are 2 way to store gadget persistent settings:

    • erp5_launher
    • setting gadget.

    In my case on d1 server for default is 1-st way is used. For each way of store the Volatile Settings saving/getting should be realized. Otherwise the portal type (as example) will be the same for all gadgets.

    You can change the code as you think it's correct.

  • Maybe I was unclear. To store settings, erp5_launcher use the gadget_setting which also implement the setVolatileSetting. For consistency setVolatileSetting of erp5_launcher should also use setVolatileSetting from gadget_setting.

  • I've deleted this commit. i made it as i thought the global setting gadget had been not working, but i just hadn't understood correctly how it had to work. For my testing purposes i have made subdomains for each application, so now i have the similar environment as Nexedi's production, and as a result i don't need this patch too.

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