Commit bb0a0be4 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_officejs] Backport some functionnalities from the erp5 launcher.

+ store all ERP5 configuration parameters in the local setting DB.
parent 7827de4a
...@@ -329,7 +329,16 @@ ...@@ -329,7 +329,16 @@
g.props.content_element = element.querySelector(\'.gadget-content\');\n g.props.content_element = element.querySelector(\'.gadget-content\');\n
});\n });\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
.ready(function (g) {\n .ready(function (g) {\n
// Extract configuration parameters stored in HTML\n // Extract configuration parameters stored in HTML\n
// XXX Will work only if top gadget...\n // XXX Will work only if top gadget...\n
...@@ -338,32 +347,31 @@ ...@@ -338,32 +347,31 @@
len = element_list.length,\n len = element_list.length,\n
key,\n key,\n
value,\n value,\n
i;\n i,\n
queue = new RSVP.Queue();\n
\n
function push(a, b) {\n
queue.push(function () {\n
return setSetting(g, a, b);\n
});\n
}\n
\n \n
for (i = 0; i < len; i += 1) {\n for (i = 0; i < len; i += 1) {\n
key = element_list[i].getAttribute(\'data-renderjs-configuration\');\n key = element_list[i].getAttribute(\'data-renderjs-configuration\');\n
value = element_list[i].textContent;\n value = element_list[i].textContent;\n
if (value !== "") {\n if (value !== "") {\n
g.props[key] = value;\n g.props[key] = value;\n
push(key, value);\n
}\n }\n
}\n }\n
})\n return queue;\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 })\n
.ready(function (g) {\n .ready(function (g) {\n
return setSetting(g, \'hateoas_url\',\n return setSetting(g, \'hateoas_url\',\n
(new URI(g.props.hateoas_url))\n (new URI(g.props.hateoas_url))\n
.absoluteTo(location.href)\n .absoluteTo(location.href)\n
.toString()\n .toString()\n
);\n );\n
})\n })\n
// Configure jIO storage\n // Configure jIO storage\n
.ready(function (g) {\n .ready(function (g) {\n
...@@ -419,17 +427,7 @@ ...@@ -419,17 +427,7 @@
return location.reload();\n return location.reload();\n
})\n })\n
.allowPublicAcquisition("getUrlFor", function (param_list) {\n .allowPublicAcquisition("getUrlFor", function (param_list) {\n
var options = param_list[0],\n return this.aq_pleasePublishMyState(param_list[0]);\n
key;\n
for (key in options) {\n
if (options.hasOwnProperty(key)) {\n
if (options[key] === undefined) {\n
throw new Error("Can not generate URL for: " +\n
JSON.stringify(options));\n
}\n
}\n
}\n
return this.aq_pleasePublishMyState(options);\n
})\n })\n
\n \n
.allowPublicAcquisition("updateHeader", function (param_list) {\n .allowPublicAcquisition("updateHeader", function (param_list) {\n
...@@ -460,6 +458,22 @@ ...@@ -460,6 +458,22 @@
if (result_list.length === 2) {\n if (result_list.length === 2) {\n
gadget.props.header_argument_list.right_title = result_list[1];\n gadget.props.header_argument_list.right_title = result_list[1];\n
}\n }\n
\n
// XXX Sven hack: number of _url determine padding for\n
// subheader on ui-content\n
var key,\n
count = 0;\n
for (key in gadget.props.header_argument_list) {\n
if (gadget.props.header_argument_list.hasOwnProperty(key)) {\n
if (key.indexOf(\'_url\') > -1) {\n
count += 1;\n
}\n
}\n
}\n
if (count > 2) {\n
console.log(\'Has subheader\');\n
gadget.props.sub_header_class = "ui-has-subheader";\n
}\n
});\n });\n
})\n })\n
\n \n
...@@ -479,6 +493,12 @@ ...@@ -479,6 +493,12 @@
.allowPublicAcquisition("jio_get", function (param_list) {\n .allowPublicAcquisition("jio_get", function (param_list) {\n
return callJioGadget(this, "get", param_list);\n return callJioGadget(this, "get", param_list);\n
})\n })\n
.allowPublicAcquisition("jio_getAttachment", function (param_list) {\n
return callJioGadget(this, "getAttachment", param_list);\n
})\n
.allowPublicAcquisition("jio_putAttachment", function (param_list) {\n
return callJioGadget(this, "putAttachment", param_list);\n
})\n
.allowPublicAcquisition("jio_repair", function (param_list) {\n .allowPublicAcquisition("jio_repair", function (param_list) {\n
return callJioGadget(this, "repair", param_list);\n return callJioGadget(this, "repair", param_list);\n
})\n })\n
...@@ -724,7 +744,7 @@ ...@@ -724,7 +744,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value> <value> <string>romain</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -738,7 +758,7 @@ ...@@ -738,7 +758,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.39852.16132.21538</string> </value> <value> <string>945.51276.58336.63624</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -756,8 +776,8 @@ ...@@ -756,8 +776,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441729471.18</float> <float>1442414233.9</float>
<string>UTC</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
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