Commit 0f305253 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: clean up

parent cd369929
...@@ -539,8 +539,11 @@ ...@@ -539,8 +539,11 @@
} }
} }
} }
return gadget.getUrlParameter("graphic_type") return new RSVP.Queue(RSVP.all([
.push(function (graphic_type) { gadget.getUrlParameter("graphic_type"),
gadget.getUrlParameter("only_graphic")
]))
.push(function (parameter_list) {
return gadget.changeState({ return gadget.changeState({
jio_key: options.jio_key, jio_key: options.jio_key,
key: field_json.key, key: field_json.key,
...@@ -599,7 +602,8 @@ ...@@ -599,7 +602,8 @@
// graphic // graphic
enable_graphic: options.enable_graphic, enable_graphic: options.enable_graphic,
graphic_type: graphic_type || getDefaultGraphicType(option_list) graphic_type: parameter_list[0] || getDefaultGraphicType(option_list),
only_graphic: parameter_list[1]
}); });
}); });
}); });
...@@ -933,7 +937,7 @@ ...@@ -933,7 +937,7 @@
} }
domsugar(table_element.querySelector('tr'), th_element_list); domsugar(table_element.querySelector('tr'), th_element_list);
if (gadget.state.extended_search || !gadget.state.option_list.length) { if (gadget.state.extended_search && !gadget.state.only_graphic) {
domsugar(container, [ domsugar(container, [
domsugar('div', { domsugar('div', {
"class": 'ui-table-header ui-header' "class": 'ui-table-header ui-header'
...@@ -1201,8 +1205,11 @@ ...@@ -1201,8 +1205,11 @@
loading_element_classList.remove.apply(loading_element_classList, loading_class_list); loading_element_classList.remove.apply(loading_element_classList, loading_class_list);
loading_element.textContent = '(' + pagination_message + ')'; loading_element.textContent = '(' + pagination_message + ')';
} }
if (gadget.state.option_list.length > 0 && // XXX if is duplicated. Look at line 1222
gadget.state.enable_graphic) { if (gadget.state.enable_graphic && ((
gadget.state.graphic_type && !gadget.state.extended_search
) || (gadget.state.graphic_type && gadget.state.extended_search &&
gadget.state.only_graphic))) {
domsugar(gadget.element.querySelector(".graphic_section"), [ domsugar(gadget.element.querySelector(".graphic_section"), [
domsugar("div", {"class": "graphic_area"}) domsugar("div", {"class": "graphic_area"})
]); ]);
...@@ -1210,11 +1217,11 @@ ...@@ -1210,11 +1217,11 @@
}); });
}); });
if (gadget.state.enable_graphic && if (gadget.state.enable_graphic && ((
gadget.state.graphic_type && gadget.state.graphic_type && !gadget.state.extended_search
!gadget.state.extended_search && ) || (
gadget.state.option_list.length > 0 && gadget.state.graphic_type && gadget.state.extended_search && gadget.state.only_graphic
gadget.state.graphic_type !== "") { ))) {
result_queue result_queue
.push(function () { .push(function () {
return gadget.declareGadget('gadget_graphic.html', { return gadget.declareGadget('gadget_graphic.html', {
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>997.49726.7840.16145</string> </value> <value> <string>997.50830.31540.53299</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>1643213057.93</float> <float>1643230974.76</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,23 +9,6 @@ ...@@ -9,23 +9,6 @@
declareGadgetClassCanHandleListboxClipboardAction, RSVP) { declareGadgetClassCanHandleListboxClipboardAction, RSVP) {
"use strict"; "use strict";
function getDefaultGraphicType(option_list) {
var i,
default_option_list = [
"translated_simulation_state_title",
"translated_validation_state_title"
];
if (!option_list.length) {
return;
}
for (i = 0; i < option_list.length; i += 1) {
if (default_option_list.indexOf(option_list[i][0]) !== -1) {
return option_list[i][0];
}
}
return option_list[0][0];
}
function updateSearchQueryFromSelection(extended_search, checked_uid_list, function updateSearchQueryFromSelection(extended_search, checked_uid_list,
key, to_include) { key, to_include) {
var i, var i,
...@@ -162,7 +145,8 @@ ...@@ -162,7 +145,8 @@
form_options.enable_graphic = false; form_options.enable_graphic = false;
if (graphic_type || ( if (graphic_type || (
!form_gadget.state.extended_search && !graphic_type)) { !form_gadget.state.extended_search && !graphic_type
)) {
form_options.enable_graphic = true; form_options.enable_graphic = true;
} }
...@@ -170,7 +154,7 @@ ...@@ -170,7 +154,7 @@
}) })
// render the search field // render the search field
.push(function (result) { .push(function () {
return RSVP.all([ return RSVP.all([
form_gadget.getDeclaredGadget("erp5_searchfield"), form_gadget.getDeclaredGadget("erp5_searchfield"),
erp5_form.getGraphicType() erp5_form.getGraphicType()
...@@ -184,8 +168,9 @@ ...@@ -184,8 +168,9 @@
search_options.extended_search = form_gadget.state.extended_search; search_options.extended_search = form_gadget.state.extended_search;
} }
search_options.enable_graphic = false; search_options.enable_graphic = false;
if (graphic_type || ( if (graphic_type ||
!form_gadget.state.extended_search && !graphic_type)) { (!form_gadget.state.extended_search && !graphic_type)
) {
search_options.enable_graphic = true; search_options.enable_graphic = true;
} }
...@@ -309,7 +294,7 @@ ...@@ -309,7 +294,7 @@
return result_list; return result_list;
}); });
}) })
.allowPublicAcquisition("triggerListboxGraphicSelection", function triggerListboxGraphicSelection() { .allowPublicAcquisition("triggerListboxGraphicSelection", function triggerListboxGraphicSelection() {
var gadget = this; var gadget = this;
return this.getDeclaredGadget("erp5_form") return this.getDeclaredGadget("erp5_form")
.push(function (declared_gadget) { .push(function (declared_gadget) {
...@@ -319,14 +304,11 @@ ...@@ -319,14 +304,11 @@
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var result_dict = result_list[0], return gadget.renderEditorPanel("gadget_erp5_graphic_editor.html", {
graphic_type = result_list[1]; graphic_option_list: result_list[0].graphic_option_list,
return gadget.renderEditorPanel( jio_key: gadget.state.jio_key,
"gadget_erp5_graphic_editor.html", { graphic_type: result_list[1]
graphic_option_list: result_dict.graphic_option_list, });
jio_key: gadget.state.jio_key,
graphic_type: result_list[1]
});
}); });
}) })
.allowPublicAcquisition("triggerListboxSelectAction", function triggerListboxSelectAction(argument_list) { .allowPublicAcquisition("triggerListboxSelectAction", function triggerListboxSelectAction(argument_list) {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>997.50436.16456.55552</string> </value> <value> <string>997.50840.41905.62822</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>1643208720.28</float> <float>1643231574.6</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, document, Node, /*global window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar*/ QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar*/
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, document, Node, (function (window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar) { QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar) {
"use strict"; "use strict";
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
button_graphic = gadget.element.querySelector(".graphic-button"), button_graphic = gadget.element.querySelector(".graphic-button"),
change_button_graphic = gadget.element.querySelector(".change-graphic-button"), change_button_graphic = gadget.element.querySelector(".change-graphic-button"),
graphic_css_class = "ui-screen-hidden", graphic_css_class = "ui-screen-hidden",
button,
operator = 'AND', operator = 'AND',
jio_query_list = [], jio_query_list = [],
query_text_list = [], query_text_list = [],
...@@ -60,15 +59,8 @@ ...@@ -60,15 +59,8 @@
continue_full_text_query_search = true; continue_full_text_query_search = true;
if (gadget.state.extended_search) { if (gadget.state.extended_search) {
if (modification_dict.graphic_type) {
if (modification_dict.enable_graphic &&
modification_dict.extended_search &&
modification_dict.graphic_type) {
button_graphic.classList.remove(graphic_css_class);
change_button_graphic.classList.add(graphic_css_class);
} else {
button_graphic.classList.remove(graphic_css_class); button_graphic.classList.remove(graphic_css_class);
change_button_graphic.classList.add(graphic_css_class);
} }
// Parse the raw query // Parse the raw query
...@@ -128,13 +120,8 @@ ...@@ -128,13 +120,8 @@
} }
} }
} else if (modification_dict.enable_graphic && } else if (modification_dict.enable_graphic &&
button_graphic && !button_graphic.classList.contains( modification_dict.graphic_type &&
graphic_css_class)) { !modification_dict.extended_search) {
button_graphic.classList.add(graphic_css_class);
change_button_graphic.classList.remove(graphic_css_class);
} else if (change_button_graphic &&
modification_dict.enable_graphic &&
!modification_dict.extended_search ){
change_button_graphic.classList.remove(graphic_css_class); change_button_graphic.classList.remove(graphic_css_class);
} }
...@@ -261,19 +248,29 @@ ...@@ -261,19 +248,29 @@
// Open the filter panel if one 'search' button is clicked // Open the filter panel if one 'search' button is clicked
evt.preventDefault(); evt.preventDefault();
return this.triggerSubmit({focus_on: parseInt(evt.target.value, 10)}); return this.triggerSubmit({focus_on: parseInt(evt.target.value, 10)});
} else if (evt.target.classList.contains("graphic-button")) { }
if (evt.target.classList.contains("graphic-button")) {
evt.target.classList.add("ui-screen-hidden");
gadget.element.querySelector(
".change-graphic-button"
).classList.remove("ui-screen-hidden");
return gadget.redirect({ return gadget.redirect({
command: "display_with_history", command: "display_with_history",
options: { options: {
jio_key: gadget.state.jio_key, jio_key: gadget.state.jio_key,
graphic_type: gadget.state.graphic_type graphic_type: gadget.state.graphic_type,
extended_search: gadget.state.extended_search,
only_graphic: true
} }
}); });
} else if (evt.target.classList.contains("change-graphic-button")) { }
if (evt.target.classList.contains("change-graphic-button")) {
evt.target.classList.add("ui-screen-hidden");
return gadget.triggerListboxGraphicSelection(); return gadget.triggerListboxGraphicSelection();
} }
} }
}, false, false); }, false, false);
}(window, rJS, document, Node, }(window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar)); QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar));
\ 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>997.50526.4785.59750</string> </value> <value> <string>997.50833.30307.35925</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>1643213115.75</float> <float>1643231133.68</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