Commit 9bc57d75 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_officejs] Use a jio_storage_description setting as createJio parameter

This allows to store any arbitrary value as jio configuration.
parent 361e9787
......@@ -275,6 +275,40 @@
});\n
});\n
}\n
\n
function getSetting(gadget, key, default_value) {\n
return gadget.getDeclaredGadget("setting_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.get("setting");\n
})\n
.push(function (doc) {\n
return doc[key] || default_value;\n
}, function (error) {\n
if (error.status_code === 404) {\n
return default_value;\n
}\n
throw error;\n
});\n
}\n
\n
function setSetting(gadget, key, value) {\n
var jio_gadget;\n
return gadget.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[key] = value;\n
return jio_gadget.put(\'setting\', doc);\n
});\n
}\n
\n
//////////////////////////////////////////\n
// Page rendering\n
......@@ -324,15 +358,23 @@
});\n
});\n
})\n
.ready(function (g) {\n
return setSetting(g, \'hateoas_url\',\n
(new URI(g.props.hateoas_url))\n
.absoluteTo(location.href)\n
.toString()\n
);\n
})\n
// Configure jIO storage\n
.ready(function (g) {\n
var jio_gadget;\n
return g.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.createJio({\n
hateoas_url: (new URI(g.props.hateoas_url))\n
.absoluteTo(location.href)\n
.toString()\n
});\n
.push(function (result) {\n
jio_gadget = result;\n
return getSetting(g, \'jio_storage_description\');\n
})\n
.push(function (result) {\n
return jio_gadget.createJio(result);\n
});\n
})\n
.ready(function (g) {\n
......@@ -351,36 +393,10 @@
// 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
return getSetting(this, argument_list[0], argument_list[1]);\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
return setSetting(this, argument_list[0], argument_list[1]);\n
})\n
.allowPublicAcquisition("translateHtml", function (argument_list) {\n
return this.getDeclaredGadget("translation_gadget")\n
......@@ -716,7 +732,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.38286.54145.32000</string> </value>
<value> <string>945.39476.14059.34508</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -734,7 +750,7 @@
</tuple>
<state>
<tuple>
<float>1441635494.88</float>
<float>1441706203.86</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