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

erp5_web_renderjs_ui: clean up

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