Commit d0b270a5 authored by Roque's avatar Roque

erp5_web_project_ui: use JIO objectToSearchText in queries

parent b0e2c308
/*global document, window, rJS */ /*global window, rJS, SimpleQuery, ComplexQuery, Query */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 90 */ /*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 90 */
(function (document, window, rJS) { (function (window, rJS, SimpleQuery, ComplexQuery, Query) {
"use strict"; "use strict";
function createMultipleSimpleOrQuery(key, value_list) {
var i,
search_query,
query_list = [];
for (i = 0; i < value_list.length; i += 1) {
query_list.push(new SimpleQuery({
key: key,
operator: "",
type: "simple",
value: value_list[i]
}));
}
search_query = new ComplexQuery({
operator: "OR",
query_list: query_list,
type: "complex"
});
return Query.objectToSearchText(search_query);
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -17,14 +37,25 @@ ...@@ -17,14 +37,25 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, id, var gadget = this,
types = '("Text", "File", "PDF", "Drawing", ' + type_list = ["Text", "File", "PDF", "Drawing",
'"Presentation", "Spreadsheet")', "Presentation", "Spreadsheet"],
states = '("shared", "published", "released", ' + state_list = ["shared", "published", "released", "shared_alive",
'"shared_alive", "published_alive", "released_alive")', "published_alive", "released_alive"],
query = 'portal_type:' + types + portal_type_query = createMultipleSimpleOrQuery('portal_type', type_list),
'AND reference:"' + options.reference + state_query = createMultipleSimpleOrQuery('validation_state', state_list),
'" AND validation_state:' + states; reference_query = new SimpleQuery({
key: "reference",
operator: "=",
type: "simple",
value: options.reference
}),
query = new ComplexQuery({
operator: "AND",
query_list: [portal_type_query, state_query, reference_query],
type: "complex"
});
query = Query.objectToSearchText(query);
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: query, query: query,
limit: 1 limit: 1
...@@ -38,10 +69,9 @@ ...@@ -38,10 +69,9 @@
'history': options.history 'history': options.history
} }
}); });
} else {
return gadget.redirect({command: 'history_previous', options: {}});
} }
return gadget.redirect({command: 'history_previous', options: {}});
}); });
}); });
}(document, window, rJS)); }(window, rJS, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file \ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>979.50783.7411.19677</string> </value> <value> <string>979.57611.25870.2542</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1573658874.74</float> <float>1574068976.28</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