Commit 13818129 authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: thread simplify conf from erp5form

parent 9b851c37
......@@ -141,72 +141,20 @@
// XXX implement pseudo getResultValue
thread_info_dict = result_list.data.rows[0].value;
var group_list = [],
field_dict = {},
column_list = [
['asStrippedHTML', 'Content'],
['modification_date', 'Modification Date']
];
field_dict = {};
field_dict.nutnut = {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": THREAD_READER_FIELD_KEY,
"lines": DISPLAYED_POST_COUNT,
"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",
"title": "Discussion Posts",
"type": "GadgetField",
"url": "gadget_thread_reader.html",
"sandbox": "",
"renderjs_extra": JSON.stringify({
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"
})
),
query_dict: {
portal_type: 'Discussion Post',
parent_uid: thread_info_dict.uid
},
sort: [['modification_date', 'ASC'], ['uid', 'ASC']],
lines: DISPLAYED_POST_COUNT
}),
......@@ -215,8 +163,6 @@
group_list.push([
"bottom",
[["nutnut"]]
], [
"hidden", ["listbox_modification_date"]
]);
return form_gadget.render({
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.28652.26663.41830</string> </value>
<value> <string>989.28731.10123.62685</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1611047820.37</float>
<float>1611052523.08</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, URI, RSVP, isEmpty, console, domsugar, Intl*/
(function () {
/*global window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
ComplexQuery*/
(function (window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
ComplexQuery) {
"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) {
var diff,
abs,
......@@ -112,7 +138,16 @@
return gadget.changeState({
key: options.key,
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,
lines: options.lines || 1,
// Force line calculation in any case
......@@ -132,6 +167,10 @@
pagination_key;
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')) {
setPaginationElement(gadget, 0, []);
}
......@@ -275,4 +314,5 @@
return true;
});
}());
}(window, rJS, RSVP, console, domsugar, Intl, Query, SimpleQuery,
ComplexQuery));
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27674.58520.17527</string> </value>
<value> <string>989.28725.48684.35566</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1610989162.51</float>
<float>1611052202.34</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