Commit 748c295d authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Update jIO

Modify jIO API to keep user data not modified.
jIO.get({"_id": "foo"} -> jIO.get("foo")
jIO.remove({"_id": "foo"} -> jIO.remove("foo")
jIO.post({"title": "bar"}) -> jIO.post({"title": "bar"})
jIO.put({"_id": "foo", "title": "bar"}) -> jIO.put("foo", {"title": "bar"})
jIO.getAttachment({"_id": "foo", "_attachment": "enclosure"} -> jIO.getAttachment("foo", "enclosure")
jIO.removeAttachment({"_id": "foo", "_attachment": "enclosure"} -> jIO.removeAttachment("foo", "enclosure")
jIO.putAttachment({"_id": "foo", "_attachment": "enclosure", "_blob": blob} -> jIO.putAttachment("foo", "enclosure", blob)

Add jIO.allAttachments method.

jIO.get does not return an _id and _attachments attributes anymore.
jIO.get now really returns the document as saved by jIO.put/post.
parent 1a585aa7
......@@ -320,17 +320,17 @@
.allowPublicAcquisition("aq_putAttachment", function (param_list) {\n
return this.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.putAttachment({\n
"_id": param_list[0]._id,\n
"_attachment": param_list[0]._attachment,\n
"_data": JSON.stringify(param_list[0]._data)\n
});\n
return jio_gadget.putAttachment(\n
param_list[0]._id,\n
param_list[0]._attachment,\n
JSON.stringify(param_list[0]._data)\n
);\n
});\n
})\n
.allowPublicAcquisition("jio_get", function (param_list) {\n
return this.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.get.apply(jio_gadget, param_list);\n
return jio_gadget.get(param_list[0]._id);\n
})\n
.push(function (result) {\n
return {data: result};\n
......@@ -339,10 +339,13 @@
.allowPublicAcquisition("jio_getAttachment", function (param_list) {\n
return this.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.getAttachment.apply(jio_gadget, param_list);\n
return jio_gadget.getAttachment(\n
param_list[0]._id,\n
param_list[0]._attachment\n
);\n
})\n
.push(function (response) {\n
return jIO.util.readBlobAsText(response.data);\n
return jIO.util.readBlobAsText(response);\n
})\n
.push(function (event) {\n
return {data: JSON.parse(event.target.result)};\n
......@@ -732,7 +735,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>sven</string> </value>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -746,7 +749,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>942.12884.35349.45585</string> </value>
<value> <string>942.15701.13180.42427</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -764,7 +767,7 @@
</tuple>
<state>
<tuple>
<float>1428487042.05</float>
<float>1428656180.86</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -118,6 +118,10 @@
var storage = this.state_parameter_dict.jio_storage;\n
return storage.allDocs.apply(storage, arguments);\n
})\n
.declareMethod(\'allAttachments\', function () {\n
var storage = this.state_parameter_dict.jio_storage;\n
return storage.allAttachments.apply(storage, arguments);\n
})\n
.declareMethod(\'get\', function () {\n
var storage = this.state_parameter_dict.jio_storage;\n
return storage.get.apply(storage, arguments);\n
......@@ -268,7 +272,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -282,7 +286,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.52129.46198.31044</string> </value>
<value> <string>941.55610.36294.45499</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -300,7 +304,7 @@
</tuple>
<state>
<tuple>
<float>1425049350.7</float>
<float>1428655701.93</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