Commit 97289223 authored by Vincent Bechu's avatar Vincent Bechu

[OfficeJS] Stop use memory to save change in document

Prevent issue when document is edited in multiple tab.
parent 1f475772
......@@ -15,7 +15,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("translateHtml", "translateHtml")
......@@ -40,17 +40,7 @@
return form_gadget.getContent();
})
.push(function (content) {
var doc;
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
content.text_content = gadget.state.doc.text_content;
} else {
doc = gadget.state.doc;
doc.text_content = content.text_content;
}
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37006.38613.44356</string> </value>
<value> <string>962.37366.56810.48998</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1507216731.96</float>
<float>1507217051.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,6 +9,7 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
......@@ -17,6 +18,19 @@
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.allowPublicAcquisition('updateDocument', function (content) {
var gadget = this;
return gadget.jio_get(gadget.state.jio_key)
.push(function (doc) {
var property;
for (property in content) {
if (content.hasOwnProperty(property)) {
doc[property] = content[property];
}
}
return gadget.jio_put(gadget.state.jio_key, doc);
});
})
.declareMethod('triggerSubmit', function () {
return this.getDeclaredGadget('fg')
.push(function (g) {
......
......@@ -213,7 +213,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>vincent</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.578.57241.54135</string> </value>
<value> <string>962.38368.35236.14643</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1501502753.18</float>
<float>1507276852.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
......@@ -38,20 +38,13 @@
return form_gadget.getContent();
})
.push(function (content) {
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
} else {
doc = gadget.state.doc;
if (gadget.state.editable) {
return jIO.util.dataURItoBlob(content)
.push(function (blob) {
return gadget.jio_putAttachment(gadget.state.doc.jio_key, "data", blob);
});
}
})
.push(function () {
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37007.2490.4437</string> </value>
<value> <string>962.37367.12390.34440</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1507216751.29</float>
<float>1507276424.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
......@@ -36,17 +36,7 @@
return form_gadget.getContent();
})
.push(function (content) {
var doc;
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
content.text_content = gadget.state.doc.text_content;
} else {
doc = gadget.state.doc;
doc.text_content = content.text_content;
}
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37007.62049.31914</string> </value>
<value> <string>962.38366.1240.39082</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1507216794.53</float>
<float>1507276696.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
......@@ -36,17 +36,7 @@
return form_gadget.getContent();
})
.push(function (content) {
var doc;
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
content.text_content = gadget.state.doc.text_content;
} else {
doc = gadget.state.doc;
doc.text_content = content.text_content;
}
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37008.9624.51234</string> </value>
<value> <string>962.37368.2625.44083</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1507216802.33</float>
<float>1507276723.18</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
......@@ -38,12 +38,7 @@
return form_gadget.getContent();
})
.push(function (content) {
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
} else {
doc = gadget.state.doc;
if (gadget.state.editable) {
return new RSVP.Queue()
.push(function () {
return jIO.util.dataURItoBlob(content.text_content);
......@@ -52,9 +47,7 @@
return gadget.jio_putAttachment(gadget.state.jio_key, "data", blob);
});
}
})
.push(function () {
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -235,7 +235,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37006.51899.60586</string> </value>
<value> <string>962.37374.62560.29798</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -253,7 +253,7 @@
</tuple>
<state>
<tuple>
<float>1507216742.11</float>
<float>1507276442.57</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
......@@ -36,17 +36,7 @@
return form_gadget.getContent();
})
.push(function (content) {
var doc;
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
content.text_content = gadget.state.doc.text_content;
} else {
doc = gadget.state.doc;
doc.text_content = content.text_content;
}
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37008.22150.56354</string> </value>
<value> <string>962.37368.12382.8550</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1507216811.32</float>
<float>1507276746.27</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
......@@ -39,22 +39,14 @@
return form_gadget.getContent();
})
.push(function (content) {
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
} else {
doc = gadget.state.doc;
doc.content_type = "application/x-asc-presentation";
if (gadget.state.editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
);
}
})
.push(function () {
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37007.20027.35498</string> </value>
<value> <string>962.38363.43436.63658</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1507216762.23</float>
<float>1507276582.46</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
......@@ -39,22 +39,14 @@
return form_gadget.getContent();
})
.push(function (content) {
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
} else {
doc = gadget.state.doc;
doc.content_type = "application/x-asc-spreadsheet";
if (gadget.state.editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
);
}
})
.push(function () {
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37007.35052.50005</string> </value>
<value> <string>962.37367.33580.22391</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1507216770.69</float>
<float>1507276608.1</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
......@@ -39,22 +39,14 @@
return form_gadget.getContent();
})
.push(function (content) {
if (!gadget.state.editable) {
doc = content;
content.portal_type = gadget.state.doc.portal_type;
content.parent_relative_url = gadget.state.doc.parent_relative_url;
} else {
doc = gadget.state.doc;
doc.content_type = "application/x-asc-text";
if (gadget.state.editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
);
}
})
.push(function () {
return gadget.jio_put(gadget.state.jio_key, doc);
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37007.50396.49885</string> </value>
<value> <string>962.37367.43380.13943</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1507216779.66</float>
<float>1507276655.94</float>
<string>UTC</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