Commit 48269f33 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: change filter editor's layout

parent 04df0c44
...@@ -138,37 +138,70 @@ ...@@ -138,37 +138,70 @@
</script>\n </script>\n
\n \n
<script id="filter-template" type="text/x-handlebars-template">\n <script id="filter-template" type="text/x-handlebars-template">\n
<div class="header">\n <div class="ui-panel-inner">\n
<form class="delete">\n \n
<button type="submit" class="close ui-btn-c ui-override-theme ui-btn ui-icon-delete ui-btn-icon-notext"></button>\n <div data-role="header" role="banner" class="ui-header ui-bar-inherit">\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n
<div class="ui-controlgroup-controls">\n
<form class="delete">\n
<button data-rel="close" type="submit" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>\n
</form>\n
</div>\n
</div>\n
\n
<h1 class="ui-title" role="heading" aria-level="1">Filter Editor</h1>\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n
<form class="submit">\n
<button data-rel="save" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-right ui-icon-check">Save</button>\n
</form>\n </form>\n
<h1 data-i18n="Filter Editor">Filter Editor</h1>\n </div>\n
</div>\n
</div>\n
\n
\n
<section class="ui-content-header-plain">\n
<h3 class="ui-content-title ui-body-c">\n
<span class="ui-icon ui-icon-custom">&nbsp;</span>\n
Custom Filter\n
</h3>\n
</section>\n
<section class="ui-body-c ui-content-section">\n
<fieldset data-role="controlgroup" class="ui-controlgroup ui-corner-all">\n
\n \n
<form class="submit">\n <div class="ui-radio">\n
<button type="submit" class="submit ui-btn-c ui-override-theme ui-btn ui-icon-reorder ui-btn-icon-notext"></button>\n <label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-on">All criterions(AND)</label>\n
<input type="radio" value="Off" name="heard_about" id="heard_about_a" class="and checkboxradio" data-cacheval="true" data-enhanced="true">\n
</div>\n
\n
<div class="ui-radio">\n
<label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off">At lease one(OR)</label>\n
<input type="radio" value="Off" name="heard_about" id="heard_about_b" class="or checkboxradio" data-cacheval="false" data-enhanced="true">\n
</div>\n
\n
</fieldset>\n
\n
\n
<div class="filter_item_container">\n
</div>\n
<form class="plus">\n
<button type="submit" class="plus ui-btn-c ui-override-theme ui-btn ui-icon-plus ui-btn-icon-notext"></button>\n
</form>\n </form>\n
</div>\n </section>\n
\n \n
<div class="container">\n
<h1 data-i18n="Custom Filter">Custom Filter</h1>\n
\n
<fieldset data-role="ui_controlgroup">\n
<label for="radio-a">All criterions(AND)</label>\n
<input type="radio" name="radio_filter" id="radio_a" class="and" checked></input>\n
<label for="radio-b">At least one(OR)</label>\n
<input type="radio" name="radio_filter" id="radio_b" class="or"></input>\n
</fieldset>\n
<div class="filter_item_container">\n
<form class="plus">\n
<button type="submit" class="plus ui-btn-c ui-override-theme ui-btn ui-icon-plus ui-btn-icon-notext"></button>\n
</div>\n
</form>\n
</div>\n
\n \n
<div class="predefined_filter">\n \n
<h1 data-i18n="Predefined Filter">Predefined Filter</h1>\n <section class="ui-content-header-plain">\n
</div>\n <h3 class="ui-content-title ui-body-c">\n
\n <span class="ui-icon ui-icon-custom">&nbsp;</span>\n
Predefined Filter\n
</h3>\n
</section>\n
<section class="ui-body-c ui-content-section">\n
<div class="predefined_filter">\n
</div>\n
</section>\n
</div>\n
</script>\n </script>\n
\n \n
</head>\n </head>\n
...@@ -312,7 +345,7 @@ ...@@ -312,7 +345,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.13851.42970.21913</string> </value> <value> <string>945.19755.27628.12919</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -330,7 +363,7 @@ ...@@ -330,7 +363,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1440425765.38</float> <float>1440523041.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -138,21 +138,21 @@ ...@@ -138,21 +138,21 @@
and = gadget.props.element.querySelector(".and");\n and = gadget.props.element.querySelector(".and");\n
operator = and.checked ? " AND " : " OR ";\n operator = and.checked ? " AND " : " OR ";\n
for (i = 0; i < filterforms.length; i += 1) {\n for (i = 0; i < filterforms.length; i += 1) {\n
if (filterforms[i][3].value !== "") {\n if (filterforms[i][2].value !== "") {\n
if (i !== 0) {\n if (i !== 0) {\n
query += operator;\n query += operator;\n
}\n }\n
value = filterforms[i][3].value;\n value = filterforms[i][2].value;\n
select = filterforms[i][2][filterforms[i][2].selectedIndex].value;\n select = filterforms[i][1][filterforms[i][1].selectedIndex].value;\n
if (select === "keyword" && filterforms[i][1][filterforms[i][1].selectedIndex].value !== "Searchable Text") {\n if (select === "keyword" && filterforms[i][0][filterforms[i][0].selectedIndex].value !== "Searchable Text") {\n
value = "%" + value + "%";\n value = "%" + value + "%";\n
} else {\n } else {\n
value = select + value;\n value = select + " " + value;\n
}\n }\n
if (filterforms[i][1][filterforms[i][1].selectedIndex].value === "Searchable Text") {\n if (filterforms[i][0][filterforms[i][0].selectedIndex].value === "Searchable Text") {\n
query += value;\n query += value;\n
} else {\n } else {\n
query += filterforms[i][1][filterforms[i][1].selectedIndex].value + ":" + value;\n query += filterforms[i][0][filterforms[i][0].selectedIndex].value + ":" + value;\n
}\n }\n
}\n }\n
}\n }\n
...@@ -173,7 +173,8 @@ ...@@ -173,7 +173,8 @@
\n \n
\n \n
function createFilterItem(gadget, select, input_value) {\n function createFilterItem(gadget, select, input_value) {\n
var container = document.createElement("form"),\n var div = document.createElement("div"),\n
container = document.createElement("form"),\n
minus_button = document.createElement("input"),\n minus_button = document.createElement("input"),\n
select_reference = document.createElement("select"),\n select_reference = document.createElement("select"),\n
i,\n i,\n
...@@ -181,6 +182,7 @@ ...@@ -181,6 +182,7 @@
default_select = "Searchable Text",\n default_select = "Searchable Text",\n
select_options,\n select_options,\n
select_options_value,\n select_options_value,\n
value_list = [" ", " "],\n
options_map = {\n options_map = {\n
"date_float": ["Equals To", "Greater Than", "Less Than", "Not Greater Than", "Not Less Than"],\n "date_float": ["Equals To", "Greater Than", "Less Than", "Not Greater Than", "Not Less Than"],\n
"date_float_value": ["", ">", "<", "<=", ">="],\n "date_float_value": ["", ">", "<", "<=", ">="],\n
...@@ -192,23 +194,26 @@ ...@@ -192,23 +194,26 @@
\n \n
text = document.createElement("input"),\n text = document.createElement("input"),\n
select_operator = document.createElement("select");\n select_operator = document.createElement("select");\n
minus_button.setAttribute("type", "button");\n
\n \n
container.appendChild(minus_button);\n
container.appendChild(select_reference);\n container.appendChild(select_reference);\n
container.appendChild(select_operator);\n container.appendChild(select_operator);\n
text.setAttribute("type", "text");\n
text.setAttribute("value", input_value || "");\n
minus_button.setAttribute("class", "minus_button");\n
minus_button.setAttribute("type", "button");\n
container.appendChild(text);\n container.appendChild(text);\n
container.appendChild(minus_button);\n
container.setAttribute("class", "filterForm");\n container.setAttribute("class", "filterForm");\n
\n div.appendChild(container);\n
\n
\n
\n
function createSelectOperator(event) {\n function createSelectOperator(event) {\n
var html = "",\n var html = "",\n
j;\n j;\n
if (input_value !== undefined) {\n
value_list = input_value.split(" ");\n
}\n
if (event.target.value.indexOf(\'date\') !== -1) {\n
text.setAttribute("type", "date");\n
} else {\n
text.setAttribute("type", "text");\n
}\n
text.setAttribute("value", value_list[value_list.length - 1] || "");\n
if (event.target.value.indexOf(\'date\') !== -1 ||\n if (event.target.value.indexOf(\'date\') !== -1 ||\n
event.target.value.indexOf(\'quantity\') !== -1 ||\n event.target.value.indexOf(\'quantity\') !== -1 ||\n
event.target.value.indexOf(\'price\') !== -1) {\n event.target.value.indexOf(\'price\') !== -1) {\n
...@@ -223,12 +228,21 @@ ...@@ -223,12 +228,21 @@
}\n }\n
\n \n
for (j = 0; j < select_options.length; j += 1) {\n for (j = 0; j < select_options.length; j += 1) {\n
html += option_template({\n if (value_list[0] === select_options_value[j]) {\n
value: select_options_value[j],\n html += selected_option_template({\n
text: select_options[j]\n value: select_options_value[j],\n
});\n text: select_options[j]\n
});\n
} else {\n
html += option_template({\n
value: select_options_value[j],\n
text: select_options[j]\n
});\n
}\n
}\n }\n
select_operator.innerHTML = html;\n select_operator.innerHTML = html;\n
$(select_operator).selectmenu();\n
$(select_operator).selectmenu(\'refresh\');\n
}\n }\n
\n \n
\n \n
...@@ -239,7 +253,7 @@ ...@@ -239,7 +253,7 @@
});\n });\n
for (i = 0; i < gadget.props.options.length; i += 1) {\n for (i = 0; i < gadget.props.options.length; i += 1) {\n
if (select === gadget.props.options[i][0]) {\n if (select === gadget.props.options[i][0]) {\n
default_select = gadget.props.options[i][1];\n default_select = gadget.props.options[i][0];\n
tmp += selected_option_template({\n tmp += selected_option_template({\n
value: gadget.props.options[i][0],\n value: gadget.props.options[i][0],\n
text: gadget.props.options[i][1]\n text: gadget.props.options[i][1]\n
...@@ -253,8 +267,9 @@ ...@@ -253,8 +267,9 @@
}\n }\n
\n \n
select_reference.innerHTML = tmp;\n select_reference.innerHTML = tmp;\n
\n
createSelectOperator({"target": {"value": default_select}});\n createSelectOperator({"target": {"value": default_select}});\n
\n
$(select_reference).selectmenu();\n
loopEventListener(\n loopEventListener(\n
minus_button,\n minus_button,\n
"click",\n "click",\n
...@@ -277,7 +292,7 @@ ...@@ -277,7 +292,7 @@
return submitFilterQuery(gadget);\n return submitFilterQuery(gadget);\n
}\n }\n
);\n );\n
return container;\n return div;\n
}\n }\n
\n \n
\n \n
...@@ -342,12 +357,9 @@ ...@@ -342,12 +357,9 @@
return gadget.jio_getAttachment({"_id": options.jio_key, "_attachment": options.view});\n return gadget.jio_getAttachment({"_id": options.jio_key, "_attachment": options.view});\n
})\n })\n
.push(function (result) {\n .push(function (result) {\n
gadget.props.options = result.data._embedded._view.listbox.column_list;\n
return createFilterItem(gadget);\n
})\n
.push(function (item) {\n
var container = gadget.props.element.querySelector(".filter_item_container");\n var container = gadget.props.element.querySelector(".filter_item_container");\n
container.insertBefore(item, container.lastChild);\n gadget.props.options = result.data._embedded._view.listbox.column_list;\n
container.insertBefore(createFilterItem(gadget), container.lastChild);\n
});\n });\n
}\n }\n
})\n })\n
...@@ -357,6 +369,8 @@ ...@@ -357,6 +369,8 @@
i,\n i,\n
gadget = this,\n gadget = this,\n
item,\n item,\n
and = gadget.props.element.querySelector(".and"),\n
or = gadget.props.element.querySelector(".or"),\n
select_list,\n select_list,\n
query;\n query;\n
while (container.firstChild !== container.lastChild) {\n while (container.firstChild !== container.lastChild) {\n
...@@ -372,7 +386,15 @@ ...@@ -372,7 +386,15 @@
})\n })\n
.push(function (result) {\n .push(function (result) {\n
gadget.props.options = result.data._embedded._view.listbox.column_list;\n gadget.props.options = result.data._embedded._view.listbox.column_list;\n
var query_list = query.split(" AND ");\n var query_list = query.split(" OR ");\n
if (query_list.length === 1) {\n
query_list = query.split(" AND ");\n
and.checked = true;\n
and.parentElement.children[0].setAttribute("class", "ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-on");\n
} else {\n
or.checked = true;\n
or.parentElement.children[0].setAttribute("class", "ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-on");\n
}\n
\n \n
for (i = 0; i < query_list.length; i += 1) {\n for (i = 0; i < query_list.length; i += 1) {\n
select_list = query_list[i].split(":");\n select_list = query_list[i].split(":");\n
...@@ -566,7 +588,7 @@ ...@@ -566,7 +588,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.18296.32311.54766</string> </value> <value> <string>945.19828.51016.30276</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -584,7 +606,7 @@ ...@@ -584,7 +606,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1440435953.88</float> <float>1440527609.31</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