Commit 62a81b13 authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: thread simplify conf from erp5form

parent 8b3c9c79
...@@ -141,72 +141,20 @@ ...@@ -141,72 +141,20 @@
// XXX implement pseudo getResultValue // XXX implement pseudo getResultValue
thread_info_dict = result_list.data.rows[0].value; thread_info_dict = result_list.data.rows[0].value;
var group_list = [], var group_list = [],
field_dict = {}, field_dict = {};
column_list = [
['asStrippedHTML', 'Content'],
['modification_date', 'Modification Date']
];
field_dict.nutnut = { field_dict.nutnut = {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1, "editable": 1,
"editable_column_list": [],
"key": THREAD_READER_FIELD_KEY, "key": THREAD_READER_FIELD_KEY,
"lines": DISPLAYED_POST_COUNT, "title": "Discussion Posts",
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=" + Query.objectToSearchText(
new ComplexQuery({
operator: "AND",
query_list: [
new SimpleQuery({
key: "portal_type",
operator: "=",
type: "simple",
value: "Discussion Post"
}),
new SimpleQuery({
key: "parent_uid",
operator: "=",
type: "simple",
// XXX Check usual states
value: thread_info_dict.uid
})
],
type: "complex"
})
),
"portal_type": ["Discussion Post"],
"search_column_list": [],
"sort_column_list": [],
"sort": [['modification_date', 'ASC']],
"title": "Discussion Posts XXXXXXX",
"type": "GadgetField", "type": "GadgetField",
"url": "gadget_thread_reader.html", "url": "gadget_thread_reader.html",
"sandbox": "", "sandbox": "",
"renderjs_extra": JSON.stringify({ "renderjs_extra": JSON.stringify({
query: "urn:jio:allDocs?query=" + Query.objectToSearchText( query_dict: {
new ComplexQuery({ portal_type: 'Discussion Post',
operator: "AND", parent_uid: thread_info_dict.uid
query_list: [ },
new SimpleQuery({
key: "portal_type",
operator: "=",
type: "simple",
value: "Discussion Post"
}),
new SimpleQuery({
key: "parent_uid",
operator: "=",
type: "simple",
// XXX Check usual states
value: thread_info_dict.uid
})
],
type: "complex"
})
),
sort: [['modification_date', 'ASC'], ['uid', 'ASC']], sort: [['modification_date', 'ASC'], ['uid', 'ASC']],
lines: DISPLAYED_POST_COUNT lines: DISPLAYED_POST_COUNT
}), }),
...@@ -215,8 +163,6 @@ ...@@ -215,8 +163,6 @@
group_list.push([ group_list.push([
"bottom", "bottom",
[["nutnut"]] [["nutnut"]]
], [
"hidden", ["listbox_modification_date"]
]); ]);
return form_gadget.render({ return form_gadget.render({
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.28652.26663.41830</string> </value> <value> <string>989.28731.10123.62685</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1611047820.37</float> <float>1611052523.08</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint indent: 2, maxerr: 3, nomen: true */ /*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, URI, RSVP, isEmpty, console, domsugar, Intl*/ /*global window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
(function () { ComplexQuery*/
(function (window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
ComplexQuery) {
"use strict"; "use strict";
function createMultipleSimpleOrQuery(key, value_list) {
var i,
query_list = [];
if (!Array.isArray(value_list)) {
value_list = [value_list];
}
for (i = 0; i < value_list.length; i += 1) {
query_list.push(new SimpleQuery({
key: key,
operator: "=",
type: "simple",
value: value_list[i]
}));
}
if (value_list.len === 1) {
return query_list[0];
}
return new ComplexQuery({
operator: "OR",
query_list: query_list,
type: "complex"
});
}
function getRelativeTimeString(language, current_date, date) { function getRelativeTimeString(language, current_date, date) {
var diff, var diff,
abs, abs,
...@@ -112,7 +138,16 @@ ...@@ -112,7 +138,16 @@
return gadget.changeState({ return gadget.changeState({
key: options.key, key: options.key,
language: result_dict.language, language: result_dict.language,
query_string: new URI(options.query).query(true).query || '', query_string: Query.objectToSearchText(
new ComplexQuery({
operator: "AND",
type: "complex",
query_list: Object.entries(options.query_dict)
.map(function (tuple) {
return createMultipleSimpleOrQuery(tuple[0], tuple[1]);
})
})
),
begin_from: parseInt(result_dict.begin_from || '0', 10) || 0, begin_from: parseInt(result_dict.begin_from || '0', 10) || 0,
lines: options.lines || 1, lines: options.lines || 1,
// Force line calculation in any case // Force line calculation in any case
...@@ -132,6 +167,10 @@ ...@@ -132,6 +167,10 @@
pagination_key; pagination_key;
console.log(gadget.state, modification_dict); console.log(gadget.state, modification_dict);
if (!gadget.state.query_string) {
throw new Error('No "query_dict" defined for ' + gadget.state.key);
}
if (modification_dict.hasOwnProperty('first_render')) { if (modification_dict.hasOwnProperty('first_render')) {
setPaginationElement(gadget, 0, []); setPaginationElement(gadget, 0, []);
} }
...@@ -275,4 +314,5 @@ ...@@ -275,4 +314,5 @@
return true; return true;
}); });
}()); }(window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
ComplexQuery));
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.27674.58520.17527</string> </value> <value> <string>989.28725.48684.35566</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1610989162.51</float> <float>1611052202.34</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