Commit 01176737 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: use url_string instead of grouping_reference property

parent f03ea07e
......@@ -65,8 +65,7 @@
local_sub_storage: {
type: "attachasproperty",
map: {
text_content: "text_content",
data: "data"
text_content: "text_content"
},
sub_storage: {
type: "query",
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.7575.54412.14336</string> </value>
<value> <string>952.14930.43095.30429</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1466890658.78</float>
<float>1467326624.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -82,7 +82,7 @@
select: 'reference',
title: 'File Name'
}, {
select: 'grouping_reference',
select: 'url_string',
title: 'Full Path'
}, {
select: 'description',
......@@ -96,12 +96,11 @@
}],
query: {
query: 'portal_type:("Web Style", "Web Script", "Web Page")',
select_list: ['title', 'reference', 'grouping_reference',
select_list: ['title', 'reference', 'url_string',
'language','description', 'version',
'modification_date'],
//limit: [0, 30],
sort_on: [["grouping_reference", "ascending"]]
// sort_on: [["grouping_reference", "descending"]]
sort_on: [["url_string", "ascending"]]
}
});
});
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.6151.10846.11349</string> </value>
<value> <string>952.17750.64891.24132</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1466802974.52</float>
<float>1467409438.82</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -220,7 +220,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.34038.48545.63795</string> </value>
<value> <string>950.30159.50183.6604</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1443093586.17</float>
<float>1460462781.7</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -99,6 +99,9 @@ var global = self,
self.jio_erp5_cache_storage = jIO.createJIO(self.jio_erp5_cache_storage);
}
// 3. save static list urls
// site root files
// external urls
// binary files (images, fonts)
self.jio_cache_storage = jIO.createJIO({
type: "query",
sub_storage: {
......@@ -135,24 +138,6 @@ var global = self,
}
return 'text_content';
},
get_from_cache_storage = function (url, storage) {
var jio_key = get_relative_url(url);
if (!storage) {
storage = self.jio_cache_storage;
}
return new Promise(function (resolve, reject) {
storage.get(jio_key)
.push(function (metadata) {
return storage.getAttachment(jio_key, 'body')
.push(function (body) {
resolve(new Response(body, {'headers': metadata.headers}));
});
})
.push(undefined, function (error) {
reject(error);
});
});
},
get_relative_url = function (url) {
var prefix,
relative_url,
......@@ -175,6 +160,24 @@ var global = self,
}
return url;
},
get_from_cache_storage = function (url, storage) {
var jio_key = get_relative_url(url);
if (!storage) {
storage = self.jio_cache_storage;
}
return new Promise(function (resolve, reject) {
storage.get(jio_key)
.push(function (metadata) {
return storage.getAttachment(jio_key, 'body')
.push(function (body) {
resolve(new Response(body, {'headers': metadata.headers}));
});
})
.push(undefined, function (error) {
reject(error);
});
});
},
get_specific_url = function (url) {
var prefix,
prefix_id,
......@@ -209,7 +212,7 @@ var global = self,
});
},
get_from_storage = function (url, storage) {
var grouping_reference = get_specific_url(url),
var url_string = get_specific_url(url),
url_object = new URI(url),
reference = url_object.filename();
if (!storage) {
......@@ -217,24 +220,30 @@ var global = self,
}
return new Promise(function (resolve, reject) {
var find_queue;
if (grouping_reference !== undefined) {
if (url_string !== undefined) {
find_queue = find_and_get({
query: query_portal_types + ' AND (grouping_reference: "' + grouping_reference + '")'
query: query_portal_types + ' AND (url_string: ="' + url_string + '")'
}, storage);
/*.push(undefined, function (error) {
if (!self.jio_cache.development_mode) {
find_queue = find_queue
.push(undefined, function (error) {
if (error.status_code === 404) {
return self.jio_dev_storage.find_and_get(query + ' AND (reference: "' + reference + '")');
return find_and_get({
query: query_portal_types + ' AND (reference: ="' + reference + '")',
sort_on: [["url_string", "ascending"]]
}, storage);
} else {
throw error;
}
});*/
});
}
//} else if (reference !== "") {
} else if (reference === get_relative_url(url)) {
// i use sort_on for emulate query:
// '(grouping_reference: "" ) AND (reference: "' + reference + '")'
// '(url_string: "" ) AND (reference: "' + reference + '")'
find_queue = find_and_get({
query: query_portal_types + ' AND (reference: "' + reference + '")',
sort_on: [["grouping_reference", "ascending"]]
query: query_portal_types + ' AND (reference: ="' + reference + '")',
sort_on: [["url_string", "ascending"]]
}, storage);
} else {
reject({status_code: 404});
......@@ -275,7 +284,7 @@ var global = self,
// save in developer storage
//if (url)
var jio_key,
grouping_reference,
url_string,
reference,
prefix,
prefix_id,
......@@ -291,10 +300,10 @@ var global = self,
}
}
if (prefix_id !== "") {
grouping_reference = url.replace(prefix, prefix_id + '/');
erp5_id = grouping_reference.replace(/\//g, '_').replace(/\./g, '_');
url_string = url.replace(prefix, prefix_id + '/');
erp5_id = url_string.replace(/\//g, '_').replace(/\./g, '_');
} else {
grouping_reference = "";
url_string = "";
erp5_id = reference.replace(/\./g, '_');
}
if (erp5_id) {
......@@ -317,7 +326,7 @@ var global = self,
'id': erp5_id,
'portal_type': portal_type,
'reference': reference,
'grouping_reference': grouping_reference,
'url_string': url_string,
'parent_relative_url': 'web_page_module'
};
/*if (!portal_type) {
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.13474.34766.7185</string> </value>
<value> <string>952.17603.54912.57941</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1467293350.41</float>
<float>1467533213.19</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,16 +3,34 @@
(function (window, rJS) {
"use strict";
var gadget_klass = rJS(window),
NAME = "spreadsheet",
MAIN_PAGE_PREFIX = "gadget_officejs_",
DEFAULT_PAGE = NAME + "_list",
REDIRECT_TIMEOUT = 5000;
(function () {
var erp5_query,
jio_erp5_cache_storage;
if ('serviceWorker' in navigator) {
erp5_query = '(' +
'grouping_reference: "ooffice/apps/common/%"' +
' OR grouping_reference: "ooffice/sdk/Common/%"' +
' OR grouping_reference: "ooffice/apps/spreadsheeteditor/main/%"' +
' OR grouping_reference: "ooffice/sdk/Excel/%"' +
')';
erp5_query = [
"ooffice/gadget_ooffice.js",
"ooffice/gadget_ooffice.html",
"ooffice/apps/require.js",
"ooffice/apps/css.js",
"ooffice/apps/underscore.js",
"ooffice/apps/backbone.js",
"ooffice/apps/bootstrap.js",
"ooffice/apps/text.js",
"ooffice/apps/xregexp-all-min.js",
"ooffice/apps/jquery.mousewheel.js",
"ooffice/apps/common/%",
"ooffice/apps/spreadsheeteditor/main/%",
"ooffice/sdk/Common/%",
"ooffice/sdk/Excel/%"
].map(function (currentValue) {
return 'url_string: "' + currentValue + '"';
}).join(' OR ');
erp5_query = '(' + erp5_query + ' OR ' + [
"gadget_officejs_spreadsheet_router.html",
"gadget_officejs_spreadsheet_router.js",
......@@ -78,7 +96,7 @@
type: "uuid",
sub_storage: {
type: "indexeddb",
database: 'officejs_spreadsheet' + '_cache_erp5'
database: 'officejs_' + NAME + '_cache_erp5'
}
}
};
......@@ -108,7 +126,7 @@
},
remote_sub_storage: {
type: "erp5",
url: (new URI("hateoas"))
url: (new URI("hateoasnoauth"))
.absoluteTo(location.href)
.toString(),
default_view_reference: "jio_view"
......@@ -116,7 +134,7 @@
});
jio_erp5_cache_storage.repair().push(function () {
navigator.serviceWorker.register('gadget_officejs_spreadsheet_serviceworker.js')
navigator.serviceWorker.register('gadget_officejs_' + NAME + '_serviceworker.js')
.then(function (reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
......@@ -130,11 +148,6 @@
}
}());
var gadget_klass = rJS(window),
MAIN_PAGE_PREFIX = "gadget_officejs_",
DEFAULT_PAGE = "spreadsheet_list",
REDIRECT_TIMEOUT = 5000;
function listenHashChange(gadget) {
function extractHashAndDispatch(evt) {
var hash = (evt.newURL || window.location.toString()).split('#')[1],
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.14611.52315.62993</string> </value>
<value> <string>952.17638.13871.38877</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1467307441.12</float>
<float>1467536010.46</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,14 +5,6 @@
self.jio_cache = {
development_mode: false,
name: 'officejs_spreadsheet_cache',
/*
erp5_query: '"(' +
'grouping_reference: "ooffice/apps/common/%"' +
'OR grouping_reference: "ooffice/sdk/Common/%"' +
'OR grouping_reference: "ooffice/apps/spreadsheeteditor/main/%"' +
'OR grouping_reference: "ooffice/sdk/Excel/%"' +
'")',
*/
cached_urls: [
"./",
"handlebars.js",
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.13402.58271.46762</string> </value>
<value> <string>952.18597.7272.54272</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1467237351.07</float>
<float>1467460249.11</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS */
/*global window, rJS, jIO, URI, location, console, document, RSVP, loopEventListener, navigator */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS) {
"use strict";
var gadget_klass = rJS(window),
NAME = "text",
MAIN_PAGE_PREFIX = "gadget_officejs_",
DEFAULT_PAGE = NAME + "_list",
REDIRECT_TIMEOUT = 5000;
(function () {
var erp5_query,
jio_erp5_cache_storage;
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('gadget_officejs_text_serviceworker.js')
erp5_query = [
"ooffice/gadget_ooffice.js",
"ooffice/gadget_ooffice.html",
"ooffice/apps/require.js",
"ooffice/apps/css.js",
"ooffice/apps/underscore.js",
"ooffice/apps/backbone.js",
"ooffice/apps/bootstrap.js",
"ooffice/apps/text.js",
"ooffice/apps/xregexp-all-min.js",
"ooffice/apps/jquery.mousewheel.js",
"ooffice/apps/common/%",
"ooffice/apps/documenteditor/main/%",
"ooffice/sdk/Common/%",
"ooffice/sdk/Word/%"
].map(function (currentValue) {
return 'url_string: "' + currentValue + '"';
}).join(' OR ');
erp5_query = '(' + erp5_query + ' OR ' + [
"gadget_officejs_text_router.html",
"gadget_officejs_text_router.js",
"gadget_officejs_text_application_panel.html",
"gadget_officejs_page_text_list.html",
"gadget_officejs_page_text_list.js",
"gadget_officejs_jio_text_view.html",
"gadget_officejs_jio_spreadsheet_view.js",
"gadget_officejs_page_add_text.html",
"gadget_officejs_page_add_text.js",
"gadget_erp5_editor_panel.html",
"gadget_erp5_editor_panel.js",
"URI.js",
"dygraph.js",
"gadget_erp5.css",
"gadget_global.js",
"gadget_jio.html",
"gadget_jio.js",
"gadget_translate.html",
"gadget_translate.js",
"i18next.js",
"jiodev.js",
"jquery.js",
"jquerymobile.css",
"jquerymobile.js",
"renderjs.js",
"rsvp.js",
"gadget_officejs_header.html",
"gadget_officejs_jio.html",
"gadget_officejs_page_add_text_document.html",
"gadget_officejs_page_jio_configurator.html",
"gadget_officejs_page_jio_dav_configurator.html",
"gadget_officejs_page_login.html",
"gadget_officejs_page_logout.html",
"gadget_officejs_page_share_webrtc_jio.html",
"gadget_officejs_page_sync.html",
"gadget_translation.html",
"gadget_officejs_webrtc_jio.html",
"gadget_officejs_widget_listbox.html",
"gadget_officejs_header.js",
"gadget_officejs_jio.js",
"gadget_officejs_page_add_text_document.js",
"gadget_officejs_page_jio_configurator.js",
"gadget_officejs_page_jio_dav_configurator.js",
"gadget_officejs_page_login.js",
"gadget_officejs_page_logout.js",
"gadget_officejs_page_share_webrtc_jio.js",
"gadget_officejs_page_sync.js",
"gadget_officejs_text_editor_application_panel.js",
"gadget_translation.js",
"gadget_translation_data.js",
"gadget_officejs_webrtc_jio.js",
"gadget_officejs_widget_listbox.js",
"erp5_launcher.js",
"erp5_launcher.html"
].map(function (currentValue) {
return '(reference: ="' + currentValue + '")';
}).join(' OR ') + ')';
jio_erp5_cache_storage = {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: 'officejs_' + NAME + '_cache_erp5'
}
}
};
jio_erp5_cache_storage = jIO.createJIO({
type: "replicate",
query: {
query: '(portal_type: ("Web Style", "Web Page", "Web Script")) AND ' +
erp5_query,
limit: [0, 1234567890]
},
use_remote_post: true,
conflict_handling: 2,
check_local_modification: false,
check_local_creation: false,
check_local_deletion: false,
check_remote_modification: true,
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "attachasproperty",
map: {
text_content: "text_content",
data: "data"
},
sub_storage: jio_erp5_cache_storage
},
remote_sub_storage: {
type: "erp5",
url: (new URI("hateoasnoauth"))
.absoluteTo(location.href)
.toString(),
default_view_reference: "jio_view"
}
});
jio_erp5_cache_storage.repair().push(function () {
navigator.serviceWorker.register('gadget_officejs_' + NAME + '_serviceworker.js')
.then(function (reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
......@@ -13,12 +143,10 @@
// registration failed
console.log('Registration failed with ' + error);
});
}
}, console.log);
var gadget_klass = rJS(window),
MAIN_PAGE_PREFIX = "gadget_officejs_",
DEFAULT_PAGE = "text_list",
REDIRECT_TIMEOUT = 5000;
}
}());
function listenHashChange(gadget) {
function extractHashAndDispatch(evt) {
......@@ -66,7 +194,7 @@
};
})
.declareMethod("getCommandUrlFor", function(options) {
.declareMethod("getCommandUrlFor", function (options) {
var prefix = '',
result,
key;
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.50294.65237.43212</string> </value>
<value> <string>952.19926.3121.29149</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1463147142.93</float>
<float>1467539971.86</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.11121.2531.21930</string> </value>
<value> <string>952.17059.29170.50995</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1467235894.43</float>
<float>1467458879.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -743,7 +743,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.63944.36324.63914</string> </value>
<value> <string>952.14901.60787.3464</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -761,7 +761,7 @@
</tuple>
<state>
<tuple>
<float>1466340151.15</float>
<float>1467456965.65</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -434,7 +434,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.63106.5592.44526</string> </value>
<value> <string>952.14901.60787.3464</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -452,7 +452,7 @@
</tuple>
<state>
<tuple>
<float>1466284982.77</float>
<float>1467456965.64</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -329,7 +329,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.63106.5592.44526</string> </value>
<value> <string>952.14901.60787.3464</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -347,7 +347,7 @@
</tuple>
<state>
<tuple>
<float>1466284982.81</float>
<float>1467456965.64</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -407,6 +407,7 @@
<value>
<tuple>
<string>aggregate/web_page_module/rjs_gadget_erp5_html</string>
<string>caching_policy/must-revalidate</string>
</tuple>
</value>
</item>
......@@ -755,7 +756,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.12290.58270.10427</string> </value>
<value> <string>951.20706.65396.43656</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -773,7 +774,7 @@
</tuple>
<state>
<tuple>
<float>1463236183.32</float>
<float>1463744174.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,6 +108,12 @@
</dictionary>
</value>
</item>
<item>
<key> <string>__translation_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
......@@ -383,7 +389,7 @@
</tuple>
<state>
<tuple>
<float>1443914195.08</float>
<float>1467540283.74</float>
<string>UTC</string>
</tuple>
</state>
......@@ -428,7 +434,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.12180.38409.20770</string> </value>
<value> <string>952.19934.1513.34508</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -446,7 +452,7 @@
</tuple>
<state>
<tuple>
<float>1444083543.91</float>
<float>1467540363.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,6 +108,12 @@
</dictionary>
</value>
</item>
<item>
<key> <string>__translation_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
......@@ -120,6 +126,14 @@
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>caching_policy/must-revalidate</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......@@ -315,7 +329,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.12180.38409.20770</string> </value>
<value> <string>951.20740.48139.14762</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -333,7 +347,7 @@
</tuple>
<state>
<tuple>
<float>1444083543.91</float>
<float>1463744194.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -81,7 +81,7 @@
<string>my_version</string>
<string>my_portal_type</string>
<string>your_modification_date</string>
<string>my_grouping_reference</string>
<string>my_url_string</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_grouping_reference</string> </value>
<value> <string>my_url_string</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>My Reference</string> </value>
<value> <string>Path</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
......
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