Commit a31c8432 authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: forum jslint

parent 67902a43
/*global window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query, /*global window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query,
console */ console */
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80, continue:true */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80, continue:true */
(function (window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query) { (function (window, rJS, domsugar, SimpleQuery, ComplexQuery, Query) {
"use strict"; "use strict";
// XXX history_previous: prevent getting to erp5 ui by checking the // XXX history_previous: prevent getting to erp5 ui by checking the
// historing or forcing the page value // historing or forcing the page value
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
var DISPLAY_READER = 'display_reader', var DISPLAY_READER = 'display_reader',
DISPLAY_THREAD = 'display_thread', DISPLAY_THREAD = 'display_thread',
DISPLAY_POST = 'display_post', // DISPLAY_POST = 'display_post',
MAIN_SCOPE = 'child_scope', MAIN_SCOPE = 'child_scope',
DISPLAYED_POST_COUNT = 15, DISPLAYED_POST_COUNT = 15,
THREAD_READER_FIELD_KEY = 'field_listbox'; THREAD_READER_FIELD_KEY = 'field_listbox';
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
}) })
), ),
sort: [['modification_date', 'ASC'], ['uid', 'ASC']], sort: [['modification_date', 'ASC'], ['uid', 'ASC']],
lines: DISPLAYED_POST_COUNT, lines: DISPLAYED_POST_COUNT
}), }),
"hidden": 0 "hidden": 0
}; };
...@@ -349,147 +349,6 @@ ...@@ -349,147 +349,6 @@
return; return;
}) })
.declareMethod('render2', function renderHeader() {
var gadget = this;
return gadget.jio_allDocs({
select_list: ['uid', 'follow_up_title', 'title',
'modification_date', 'countFolder'],
sort_on: [['modification_date', 'DESC']],
query: Query.objectToSearchText(
new ComplexQuery({
operator: "AND",
query_list: [
new SimpleQuery({
key: "portal_type",
operator: "=",
type: "simple",
value: "Discussion Thread"
}),
new SimpleQuery({
key: "validation_state",
operator: "=",
type: "simple",
// XXX Check usual states
value: "shared"
})
],
type: "complex"
})
),
limit: 15
})
.push(function (result) {
var uid_list = [];
if (result.data.total_rows.length === 0) {
uid_list.push(-1);
} else {
uid_list = result.data.rows.map(function (x) {
return x.value.uid;
});
}
// Search amount of documentation web pages related to those products
return gadget.jio_allDocs({
select_list: ['parent_uid', 'count(*)'],
query: Query.objectToSearchText(
new ComplexQuery({
operator: "AND",
query_list: [
new SimpleQuery({
key: "portal_type",
operator: "=",
type: "simple",
value: "Discussion Post"
}),
new ComplexQuery({
operator: "OR",
type: "complex",
query_list: uid_list.map(function (parent_uid) {
return new SimpleQuery({
key: "parent_uid",
operator: "=",
type: "simple",
value: parent_uid
});
})
})
],
type: "complex"
})
),
group_by: ['parent_uid'],
limit: 10000
})
.push(function () {
return result;
});
})
.push(function (result) {
console.log(result);
var element_list = [],
i;
console.log(result);
for (i = 0; i < result.data.total_rows; i += 1) {
element_list.push(
domsugar('br'),
domsugar('div', [
domsugar('p', {text: result.data.rows[i].value.title}),
domsugar('p', {text: result.data.rows[i].value.modification_date}),
domsugar('p', {text: result.data.rows[i].value.follow_up_title}),
domsugar('p', {text: result.data.rows[i].value.countFolder}),
])
);
}
// XXX group by discussion post by parent_uid
console.log(element_list);
return domsugar(gadget.element, element_list);
});
var gadget = this,
product_uid_dict = {},
meta_product_uid_list = [],
product_list = [];
// First, get the list of products
return searchAllProject(gadget, product_uid_dict,
meta_product_uid_list, product_list)
.push(function () {
return RSVP.hash({
status_dom: buildSoftwareStatusDom(gadget, product_list,
product_uid_dict),
documentation_dom: buildDocumentationDom(gadget,
meta_product_uid_list)
});
})
.push(function (result_dict) {
domsugar(gadget.element, [
domsugar('img', {src: 'NXD-Official.Logo.svg?format=',
alt: 'Nexedi Logo'}),
domsugar('section', {class: 'ui-content-header-plain'}, [
domsugar('h3', [
domsugar('span', {class: 'ui-icon ui-icon-exchange',
text: ' '}),
'Documentation'
])
]),
result_dict.documentation_dom,
domsugar('section', {class: 'ui-content-header-plain'}, [
domsugar('h3', [
domsugar('span', {class: 'ui-icon ui-icon-exchange',
text: ' '}),
'Software Status'
])
]),
result_dict.status_dom
]);
return gadget.updateHeader({
page_title: 'Nexedi Project Quality',
page_icon: 'puzzle-piece'
});
});
})
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Go // Go
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
...@@ -513,7 +372,8 @@ ...@@ -513,7 +372,8 @@
len = result.data.total_rows, len = result.data.total_rows,
key, key,
url_value, url_value,
last_url_value; last_url_value,
count;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
url_value = { url_value = {
command: 'index', command: 'index',
...@@ -526,55 +386,65 @@ ...@@ -526,55 +386,65 @@
command: 'index', command: 'index',
options: { options: {
jio_key: result.data.rows[i].id, jio_key: result.data.rows[i].id,
page: gadget.state.page, page: gadget.state.page
} }
}; };
count = result.data.rows[i].value
.DiscussionThread_getDiscussionPostCount;
last_url_value.options[THREAD_READER_FIELD_KEY + '_begin_from'] = last_url_value.options[THREAD_READER_FIELD_KEY + '_begin_from'] =
result.data.rows[i].value.DiscussionThread_getDiscussionPostCount - count - (count % DISPLAYED_POST_COUNT);
(result.data.rows[i].value.DiscussionThread_getDiscussionPostCount % DISPLAYED_POST_COUNT);
for (key in result.data.rows[i].value) { for (key in result.data.rows[i].value) {
if (result.data.rows[i].value.hasOwnProperty(key)) { if (result.data.rows[i].value.hasOwnProperty(key)) {
result.data.rows[i].value[key] = { result.data.rows[i].value[key] = {
url_value: url_value, url_value: url_value,
default: result.data.rows[i].value[key] default: result.data.rows[i].value[key]
} };
} }
} }
if (result.data.rows[i].value.hasOwnProperty("modification_date")) { if (result.data.rows[i].value.hasOwnProperty("modification_date")) {
date = new Date(result.data.rows[i].value.modification_date.default); date = new Date(
console.log(last_url_value); result.data.rows[i].value.modification_date.default
result.data.rows[i].value.modification_date.url_value = last_url_value; );
result.data.rows[i].value.modification_date.field_gadget_param = { result.data.rows[i].value.modification_date.url_value =
allow_empty_time: 0, last_url_value;
ampm_time_style: 0, result.data.rows[i].value.modification_date
css_class: "date_field", .field_gadget_param = {
date_only: false, allow_empty_time: 0,
description: "The Date", ampm_time_style: 0,
editable: 1, css_class: "date_field",
hidden: 0, date_only: false,
hidden_day_is_last_day: 0, description: "The Date",
"default": date.toUTCString(), editable: 1,
key: "modification_date", hidden: 0,
required: 0, hidden_day_is_last_day: 0,
timezone_style: 0, "default": date.toUTCString(),
title: "Modification Date", key: "modification_date",
type: "DateTimeField" required: 0,
}; timezone_style: 0,
title: "Modification Date",
type: "DateTimeField"
};
} }
if (result.data.rows[i].value.hasOwnProperty("DiscussionThread_getDiscussionPostCount")) { if (result.data.rows[i].value.hasOwnProperty(
result.data.rows[i].value.DiscussionThread_getDiscussionPostCount.field_gadget_param = { "DiscussionThread_getDiscussionPostCount"
description: "Count", )) {
editable: 0, result.data.rows[i].value
hidden: 0, .DiscussionThread_getDiscussionPostCount
"default": result.data.rows[i].value.DiscussionThread_getDiscussionPostCount.default, .field_gadget_param = {
key: "count", description: "Count",
required: 0, editable: 0,
title: "Responses", hidden: 0,
type: "IntegerField" "default": result.data.rows[i].value
}; .DiscussionThread_getDiscussionPostCount
.default,
key: "count",
required: 0,
title: "Responses",
type: "IntegerField"
};
} }
/* /*
if (result.data.rows[i].value.hasOwnProperty("asStrippedHTML")) { if (result.data.rows[i].value.hasOwnProperty("asStrippedHTML")) {
...@@ -667,7 +537,8 @@ ...@@ -667,7 +537,8 @@
/* /*
return renderDiscussionPost( return renderDiscussionPost(
gadget, gadget,
modification_dict.hasOwnProperty('display_step') || modification_dict.first_render, modification_dict.hasOwnProperty('display_step') ||
modification_dict.first_render,
gadget.state.jio_key gadget.state.jio_key
); );
} }
...@@ -675,4 +546,4 @@ ...@@ -675,4 +546,4 @@
throw new Error('Unhandled display step: ' + gadget.state.display_step); throw new Error('Unhandled display step: ' + gadget.state.display_step);
}); });
}(window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query)); }(window, rJS, domsugar, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file \ No newline at end of file
...@@ -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.23331.40399.10871</string> </value> <value> <string>989.27664.22728.10274</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>1610728771.86</float> <float>1610988520.24</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*/ /*global window, document, rJS, URI, RSVP, isEmpty, console, domsugar, Intl*/
(function () { (function () {
"use strict"; "use strict";
var variable = {},
loading_class_list = ['ui-icon-spinner', 'ui-btn-icon-left'],
disabled_class = 'ui-disabled';
function getRelativeTimeString(language, current_date, date) { function getRelativeTimeString(language, current_date, date) {
var diff, var diff,
abs, abs,
...@@ -28,36 +24,14 @@ ...@@ -28,36 +24,14 @@
console.log(current_date, date, abs, week, day); console.log(current_date, date, abs, week, day);
if (abs > (week * 2)) { if (abs > (week * 2)) {
return time_format.format(Math.floor(diff / week), 'week'); return time_format.format(Math.floor(diff / week), 'week');
} else if (abs > (day * 2)) { }
if (abs > (day * 2)) {
return time_format.format(Math.floor(diff / day), 'day'); return time_format.format(Math.floor(diff / day), 'day');
} else if (abs > (hour * 2)) {
return time_format.format(Math.floor(diff / hour), 'hour');
} else {
return time_format.format(Math.floor(diff / minute), 'minute');
} }
return date; if (abs > (hour * 2)) {
} return time_format.format(Math.floor(diff / hour), 'hour');
function buildFieldGadgetParam(value) {
var field_gadget_param;
if ((value !== undefined) && (value !== null) && (value.constructor === Object)) {
if (value.field_gadget_param) {
field_gadget_param = value.field_gadget_param;
} else {
field_gadget_param = {
'editable': 0,
'default': value.default
};
}
} else {
field_gadget_param = {
'editable': 0,
'default': value
};
} }
return time_format.format(Math.floor(diff / minute), 'minute');
return field_gadget_param;
} }
function setPaginationElement(gadget, count, url_list) { function setPaginationElement(gadget, count, url_list) {
...@@ -166,7 +140,7 @@ ...@@ -166,7 +140,7 @@
domsugar(gadget.element.querySelector(':scope > nav > span'), { domsugar(gadget.element.querySelector(':scope > nav > span'), {
class: "ui-icon-spinner ui-btn-icon-left", class: "ui-icon-spinner ui-btn-icon-left",
text: '' text: ''
}) });
return gadget.fetchLineContent(false); return gadget.fetchLineContent(false);
} }
...@@ -221,7 +195,7 @@ ...@@ -221,7 +195,7 @@
text: source_short_title text: source_short_title
}), }),
domsugar('div', { domsugar('div', {
class: 'post_content', class: 'post_content'
}, [ }, [
domsugar('strong', {text: source_title}), domsugar('strong', {text: source_title}),
" ", " ",
...@@ -229,18 +203,20 @@ ...@@ -229,18 +203,20 @@
datetime: entry.value.modification_date, datetime: entry.value.modification_date,
title: entry.value.modification_date, title: entry.value.modification_date,
text: getRelativeTimeString( text: getRelativeTimeString(
gadget.state.language, now, new Date(entry.value.modification_date) gadget.state.language,
now,
new Date(entry.value.modification_date)
) )
}), }),
domsugar('br'), domsugar('br'),
result_dict.viewer_list[i].element, result_dict.viewer_list[i].element
// domsugar('hr') // domsugar('hr')
]) ])
]); ]);
})); }));
setPaginationElement(gadget, allDocs_result.data.total_rows, result_dict.url_list); setPaginationElement(gadget, allDocs_result.data.total_rows,
result_dict.url_list);
}); });
return;
} }
}) })
...@@ -251,7 +227,9 @@ ...@@ -251,7 +227,9 @@
this.element.querySelectorAll("div.post_content > time").forEach( this.element.querySelectorAll("div.post_content > time").forEach(
function (element) { function (element) {
element.textContent = getRelativeTimeString( element.textContent = getRelativeTimeString(
gadget.state.language, now, new Date(element.getAttribute('datetime')) gadget.state.language,
now,
new Date(element.getAttribute('datetime'))
); );
} }
); );
...@@ -267,8 +245,7 @@ ...@@ -267,8 +245,7 @@
} }
var gadget = this, var gadget = this,
limit_options = [], limit_options = [];
i;
if (gadget.state.lines === 0) { if (gadget.state.lines === 0) {
limit_options = undefined; limit_options = undefined;
......
...@@ -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.23313.49582.17834</string> </value> <value> <string>989.27674.58520.17527</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>1610727867.53</float> <float>1610989162.51</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