Commit 37afe87e authored by Romain Courteaud's avatar Romain Courteaud

[erp5_officejs] Add setSetting/getSetting methods.

This allow to configure local properties (like language) in the browser database through jIO.
parent cf123075
......@@ -155,6 +155,10 @@
<a href="#mypanel" class="ui-btn-left ui-btn ui-btn-inline ui-mini ui-corner-all"></a>\n
<div><h1 class="ui-title"></h1></div>\n
</div-->\n
\n
<div data-gadget-url="gadget_jio.html"\n
data-gadget-scope="setting_gadget"\n
data-gadget-sandbox="public"></div>\n
\n
<div data-gadget-url="${router_gadget}"\n
data-gadget-scope="router"\n
......@@ -322,7 +326,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.31049.20388.20360</string> </value>
<value> <string>945.38184.6119.32017</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -340,7 +344,7 @@
</tuple>
<state>
<tuple>
<float>1441200593.5</float>
<float>1441628774.12</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -314,7 +314,16 @@
}\n
}\n
})\n
\n
// Configure setting storage\n
.ready(function (g) {\n
return g.getDeclaredGadget("setting_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.createJio({\n
type: "indexeddb",\n
database: "setting"\n
});\n
});\n
})\n
// Configure jIO storage\n
.ready(function (g) {\n
return g.getDeclaredGadget("jio_gadget")\n
......@@ -341,6 +350,38 @@
//////////////////////////////////////////\n
// Allow Acquisition\n
//////////////////////////////////////////\n
.allowPublicAcquisition("getSetting", function (argument_list) {\n
return this.getDeclaredGadget("setting_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.get("setting");\n
})\n
.push(function (doc) {\n
return doc[argument_list[0]] || argument_list[1];\n
}, function (error) {\n
if (error.status_code === 404) {\n
return argument_list[1];\n
}\n
throw error;\n
});\n
})\n
.allowPublicAcquisition("setSetting", function (argument_list) {\n
var jio_gadget;\n
return this.getDeclaredGadget("setting_gadget")\n
.push(function (result) {\n
jio_gadget = result;\n
return jio_gadget.get("setting");\n
})\n
.push(undefined, function (error) {\n
if (error.status_code === 404) {\n
return {};\n
}\n
throw error;\n
})\n
.push(function (doc) {\n
doc[argument_list[0]] = argument_list[1];\n
return jio_gadget.put(\'setting\', doc);\n
});\n
})\n
.allowPublicAcquisition("translateHtml", function (argument_list) {\n
return this.getDeclaredGadget("translation_gadget")\n
.push(function (translation_gadget) {\n
......@@ -672,7 +713,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.33659.5064.30310</string> </value>
<value> <string>945.38261.35515.4386</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -690,7 +731,7 @@
</tuple>
<state>
<tuple>
<float>1441377487.05</float>
<float>1441634809.55</float>
<string>GMT</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