Commit df74a9f6 authored by Papa Tamsir Kane's avatar Papa Tamsir Kane Committed by Papa Tamsir Kane

erp5_office_js: Bookmark Manager, add migration code url_string -> coordinate_text

parent 5d9f2d19
...@@ -12,6 +12,48 @@ ...@@ -12,6 +12,48 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("jio_put", "jio_put")
// This is migration code from url_string to coordinate_text.
// Can be removed whenever deemed no longer necessary.
// May consider removing aquired method jio_put and setSetting above.
// Also remove [url_string, url_string] from column list below.
// begin migration code
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this, data, query_result;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
query_result = result;
return gadget.getSetting('migrated', false);
})
.push(function (migrated) {
if (!migrated) {
var i, len = query_result.data.total_rows, promises_list = [];
for (i = 0; i < len; i += 1) {
var row_value = query_result.data.rows[i].value;
if (row_value.hasOwnProperty("url_string")) {
if (!row_value.hasOwnProperty("coordinate_text")) {
row_value.coordinate_text = query_result.data.rows[i].value.url_string;
row_value.modification_date = (new Date()).toUTCString();
row_value.parent_relative_url = "url_module";
row_value.portal_type = "Url";
promises_list.push(gadget.jio_put(query_result.data.rows[i].id, row_value));
}
}
data = query_result;
promises_list.push(gadget.setSetting('migrated', true));
return RSVP.all(promises_list);
}
} else {
data = query_result;
}
})
.push(function () {
return data;
});
})
// end migration code
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -39,7 +81,8 @@ ...@@ -39,7 +81,8 @@
['reference', 'Reference'], ['reference', 'Reference'],
['title', 'Title'], ['title', 'Title'],
['coordinate_text', 'Url'], ['coordinate_text', 'Url'],
['description', 'Description'] ['description', 'Description'],
['url_string', 'url_string']
]; ];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.49415.17092.22306</string> </value> <value> <string>962.4164.48194.47035</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1504099713.54</float> <float>1505311051.82</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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