Commit 62418cb3 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: don't show domain tree infos in search text

parent 2f9dd8da
......@@ -103,9 +103,8 @@ def getAllSubCategoriesAsMap(root):\n
sub_categories_list = root.objectValues()\n
if len(sub_categories_list) != 0:\n
for grain in sub_categories_list:\n
result[grain.getId()] = {"sub_categories": getAllSubCategoriesAsMap(grain),\n
"title": grain.getTitle(),\n
"uid": grain.getUid()}\n
result[grain.getUid()] = {"sub_categories": getAllSubCategoriesAsMap(grain),\n
"title": grain.getTitle()}\n
\n
return result\n
\n
......@@ -392,9 +391,10 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
domain_tree = field.get_value("domain_root_list")\n
for tree in domain_tree:\n
if hasattr(portal_categories, tree[0]):\n
domain_tree_map[tree[0]] = {"sub_categories":getAllSubCategoriesAsMap(portal_categories[tree[0]]),\n
"title": tree[1],\n
"uid": portal_categories[tree[0]].getUid()}\n
domain_tree_map[portal_categories[tree[0]].getUid()] = {\n
"sub_categories":getAllSubCategoriesAsMap(portal_categories[tree[0]]),\n
"title": tree[1]\n
}\n
\n
result = {\n
"type": meta_type,\n
......
......@@ -157,7 +157,7 @@
<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-left ui-icon-check">Save</button>\n
<button data-rel="save" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n
</form>\n
</div>\n
</div>\n
......@@ -349,7 +349,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.37783.58290.59204</string> </value>
<value> <string>945.58401.24333.56064</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -367,7 +367,7 @@
</tuple>
<state>
<tuple>
<float>1442309257.72</float>
<float>1442993681.59</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -131,12 +131,14 @@
function submitFilterQuery(gadget) {\n
var i,\n
operator,\n
query,\n
query = "",\n
value,\n
key,\n
simple_query_list = [],\n
complex_query,\n
select,\n
domain_tree_query = "",\n
domain_tree_query_list = [],\n
options = gadget.props.render_options,\n
filterforms = gadget.props.element.querySelectorAll(".filterForm"),\n
and = gadget.props.element.querySelector(".and");\n
......@@ -154,41 +156,64 @@
} else {\n
key = filterforms[i][0][filterforms[i][0].selectedIndex].value;\n
}\n
simple_query_list.push(new SimpleQuery({\n
simple_query_list.push(new SimpleQuery(\n
{\n
key: key,\n
type: "simple",\n
value: value}));\n
value: value\n
}\n
));\n
}\n
}\n
\n
if (gadget.props.tree_path[0] !== "--") {\n
value = "";\n
for (i = 0; i < gadget.props.tree_path.length; i += 1) {\n
if (gadget.props.tree_path[i] !== "--") {\n
if (i !== 0) {\n
value += "/";\n
if (i === 0) {\n
domain_tree_query_list.push(new SimpleQuery(\n
{\n
key: "category.base_category_uid",\n
type: "simple",\n
value: gadget.props.tree_path[i]\n
}\n
));\n
} else {\n
domain_tree_query_list.push(new SimpleQuery(\n
{\n
key: "category.category_uid",\n
type: "simple",\n
value: gadget.props.tree_path[i]\n
}\n
value += gadget.props.tree_path[i];\n
));\n
}\n
}\n
simple_query_list.push(new SimpleQuery({key: "Domain",\n
type: "simple",\n
value: value}));\n
}\n
}\n
if (simple_query_list.length > 0 || domain_tree_query_list.length > 0) {\n
if (simple_query_list.length > 0) {\n
complex_query = new ComplexQuery({\n
operator: operator,\n
query_list: simple_query_list,\n
type: "complex"\n
});\n
\n
query = Query.objectToSearchText(complex_query);\n
}\n
\n
if (domain_tree_query_list.length > 0) {\n
domain_tree_query = new ComplexQuery({\n
operator: "AND",\n
query_list: domain_tree_query_list,\n
type: "complex"\n
});\n
domain_tree_query = Query.objectToSearchText(domain_tree_query);\n
}\n
\n
gadget.props.jelement.panel("toggle");\n
\n
return gadget.redirect({jio_key: options.jio_key, view: options.view,\n
"extended_search": query, "sort_list": options.sort_list || "",\n
"hide_item": options.hide_item || ""});\n
"extended_search": query, "domain_tree": domain_tree_query,\n
"sort_list": options.form_definition.sort_list || "",\n
"hide_item": options.form_definition.hide_item || ""});\n
}\n
}\n
\n
......@@ -444,24 +469,7 @@
// declared methods\n
/////////////////////////////////////////////////////////////////\n
.declareMethod(\'toggle\', function () {\n
var gadget = this,\n
options = gadget.props.options;\n
gadget.props.jelement.panel("toggle");\n
if (gadget.props.element.querySelector(".filterForm") === null || gadget.props.change) {\n
gadget.props.tree_path = [];\n
gadget.props.change = false;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.jio_getAttachment(options.jio_key, options.view);\n
})\n
.push(function (result) {\n
var container = gadget.props.element.querySelector(".filter_item_container");\n
gadget.props.options = result._embedded._view.listbox.column_list;\n
gadget.props.domain_tree_map = result._embedded._view.listbox.domain_tree_map;\n
container.insertBefore(createFilterItem(gadget), container.lastChild);\n
createDomainTree(gadget);\n
});\n
}\n
this.props.jelement.panel("toggle");\n
})\n
\n
.declareMethod(\'render\', function (options) {\n
......@@ -469,6 +477,7 @@
domain_tree_container = this.props.element.querySelector(".domain_tree_container"),\n
i,\n
gadget = this,\n
domain_tree,\n
item,\n
and = gadget.props.element.querySelector(".and"),\n
or = gadget.props.element.querySelector(".or"),\n
......@@ -479,27 +488,23 @@
while (domain_tree_container.firstChild) {\n
domain_tree_container.removeChild(domain_tree_container.firstChild);\n
}\n
options.view = options.view || \'view\';\n
this.props.render_options = options;\n
this.props.options = options;\n
if (options.extended_search || options.sortEditor) {\n
gadget.props.tree_path = [];\n
query = options.extended_search;\n
if (query === undefined) {\n
query = "";\n
}\n
query = options.form_definition.extended_search || "";\n
domain_tree = options.form_definition.domain_tree || "";\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.jio_getAttachment(options.jio_key, options.view);\n
})\n
.push(function (result) {\n
var query_list = QueryFactory.create(query),\n
j = 0,\n
key,\n
var query_list,\n
domain_tree_map = result._embedded._view.listbox.domain_tree_map,\n
domain_tree_list;\n
domain_tree_query_list;\n
gadget.props.options = result._embedded._view.listbox.column_list;\n
gadget.props.domain_tree_map = result._embedded._view.listbox.domain_tree_map;\n
if (query !== "") {\n
query_list = QueryFactory.create(query);\n
if (query_list.operator === "OR") {\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
......@@ -509,29 +514,29 @@
}\n
query_list = query_list.query_list || [query_list];\n
for (i = 0; i < query_list.length; i += 1) {\n
key = query_list[i].key;\n
if (key !== "Domain") {\n
item = createFilterItem(gadget, query_list[i]);\n
container.insertBefore(item, container.lastChild);\n
} else {\n
domain_tree_list = query_list[i].value.split("/");\n
createDomainTree(gadget, domain_tree_map, domain_tree_list[0]);\n
for (j = 0; j < domain_tree_list.length; j += 1) {\n
domain_tree_map = domain_tree_map[domain_tree_list[j]].sub_categories;\n
if (Object.keys(domain_tree_map).length !== 0) {\n
createDomainTree(gadget, domain_tree_map, domain_tree_list[j + 1]);\n
}\n
} else {\n
container.insertBefore(createFilterItem(gadget), container.lastChild);\n
}\n
\n
if (domain_tree !== "") {\n
domain_tree_query_list = QueryFactory.create(domain_tree);\n
domain_tree_query_list = domain_tree_query_list.query_list || [domain_tree_query_list];\n
for (i = 0; i < domain_tree_query_list.length; i += 1) {\n
if (Object.keys(domain_tree_map).length !== 0) {\n
createDomainTree(gadget, domain_tree_map, domain_tree_query_list[i].value);\n
}\n
domain_tree_map = domain_tree_map[domain_tree_query_list[i].value].sub_categories;\n
}\n
if (gadget.props.element.querySelector(".filterForm") === null) {\n
container.insertBefore(createFilterItem(gadget), container.lastChild);\n
if (Object.keys(domain_tree_map).length !== 0) {\n
createDomainTree(gadget, domain_tree_map, "--");\n
}\n
if (gadget.props.element.querySelector(".domain_tree") === null) {\n
} else {\n
createDomainTree(gadget);\n
}\n
});\n
}\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
......@@ -708,7 +713,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.60010.1085.56388</string> </value>
<value> <string>945.61379.4089.58965</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -726,7 +731,7 @@
</tuple>
<state>
<tuple>
<float>1442938284.06</float>
<float>1443020437.71</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -213,8 +213,7 @@
parent_element = document.createElement("div");\n
suboption_dict.jio_key = options.jio_key;\n
suboption_dict.view = options.view;\n
delete options.erp5_document;\n
delete options.form_definition;\n
\n
\n
// options = options.form_gadget || {};\n
form_gadget.state_parameter_dict = options.form_gadget || {};\n
......@@ -228,6 +227,10 @@
if (form_definition.hide_item) {\n
suboption_dict.hide_item = form_definition.hide_item;\n
}\n
\n
if (form_definition.domain_tree) {\n
suboption_dict.domain_tree = form_definition.domain_tree;\n
}\n
\n
form_gadget.props.gadget_list = [];\n
form_gadget.props.id = erp5_document._id;\n
......@@ -521,7 +524,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.59569.17291.44356</string> </value>
<value> <string>945.61212.37056.32187</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -539,7 +542,7 @@
</tuple>
<state>
<tuple>
<float>1442911758.8</float>
<float>1443019673.69</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2, maxerr: 3, nomen: true */\n
/*global window, document, rJS, URI, RSVP, UriTemplate, QueryFactory, loopEventListener */\n
/*global window, document, rJS, URI, RSVP, UriTemplate, QueryFactory, loopEventListener, Query */\n
(function (window, document, rJS, URI, RSVP, UriTemplate) {\n
"use strict";\n
\n
......@@ -145,7 +145,7 @@
.declareAcquiredMethod("redirect", "redirect")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
.declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")\n
.declareAcquiredMethod("triggleSortEditor", "triggleSortEditor")\n
.declareAcquiredMethod("triggerSortEditor", "triggerSortEditor")\n
//////////////////////////////////////////////\n
// initialize the gadget content\n
//////////////////////////////////////////////\n
......@@ -161,6 +161,7 @@
\n
gadget.props.field_json = field_json;\n
gadget.props.extended_search = options.extended_search;\n
gadget.props.domain_tree = options.domain_tree;\n
gadget.props.jio_key = options.jio_key;\n
gadget.props.view = options.view;\n
if (options.sort_list) {\n
......@@ -209,22 +210,20 @@
begin_from = props.begin_from,\n
table = props.element.querySelector(\'table\'),\n
original_tfoot = props.element.querySelector(\'tfoot\'),\n
original_tbody = props.element.querySelector(\'tbody\'),\n
tbody = document.createElement("tbody"),\n
url_query = props.extended_search,\n
domain_tree = props.domain_tree,\n
domain_tree_query,\n
domain_tree_string,\n
domain_tree_query_list,\n
query_string = "",\n
lines = field_json.lines,\n
select_list = [],\n
dataset,\n
last_uid,\n
counter,\n
tmp_query,\n
domain_query,\n
domain_tree_map,\n
hide_item = gadget.props.hide_item || [],\n
tmp_hide_item,\n
sort_list = gadget.props.sort_list || [],\n
operator,\n
i,\n
j,\n
list_method_promise = function () {\n
......@@ -239,41 +238,6 @@
// }\n
//rebuild query\n
if (url_query) {\n
domain_tree_map = props.field_json.domain_tree_map;\n
tmp_query = QueryFactory.create(url_query);\n
operator = tmp_query.operator ? " " + tmp_query.operator + " " : " AND ";\n
tmp_query = tmp_query.query_list || [tmp_query];\n
\n
url_query = "";\n
for (i = 0; i < tmp_query.length; i += 1) {\n
if (i !== 0) {\n
url_query += operator;\n
}\n
if (tmp_query[i].key === "Domain") {\n
domain_query = tmp_query[i].value.split("/");\n
if (domain_query[0] !== "--") {\n
url_query += "category.base_category_uid: " + domain_tree_map[domain_query[0]].uid;\n
domain_tree_map = domain_tree_map[domain_query[0]].sub_categories;\n
for (j = 1; j < domain_query.length - 1; j += 1) {\n
last_uid = domain_tree_map[domain_query[j]].uid;\n
domain_tree_map = domain_tree_map[domain_query[j]].sub_categories;\n
}\n
if (j < domain_query.length && domain_query[j] !== "--") {\n
url_query += operator;\n
url_query += "category.category_uid: " + domain_tree_map[domain_query[j]].uid;\n
} else if (j !== 1) {\n
url_query += operator;\n
url_query += "category.category_uid: " + last_uid;\n
}\n
}\n
} else {\n
if (tmp_query[i].operator) {\n
url_query += tmp_query[i].key + ":" + tmp_query[i].operator + tmp_query[i].value;\n
} else {\n
url_query += tmp_query[i].key + ":" + tmp_query[i].value;\n
}\n
}\n
}\n
//query_string = field_json.column_list.reduce(buildQueryString, \' AND (\').replace(new RegExp("OR " + \'$\'), \')\');\n
if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + url_query;\n
......@@ -281,7 +245,25 @@
query_string = url_query;\n
}\n
}\n
\n
\n
if (domain_tree) {\n
domain_tree_query = QueryFactory.create(domain_tree);\n
if (domain_tree_query.query_list) {\n
domain_tree_query_list = [domain_tree_query.query_list[0], domain_tree_query.query_list[domain_tree_query.query_list.length - 1]];\n
domain_tree_query.query_list = domain_tree_query_list;\n
}\n
domain_tree_string = Query.objectToSearchText(domain_tree_query);\n
if (query_string !== "") {\n
query_string += \' AND \' + domain_tree_string;\n
} else if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + domain_tree_string;\n
} else {\n
query_string = domain_tree_string;\n
}\n
}\n
\n
\n
\n
if (hide_item.length > 0) {\n
tmp_hide_item = "catalog.uid: (";\n
for (i = 0; i < hide_item.length; i += 1) {\n
......@@ -292,8 +274,8 @@
tmp_hide_item += ")";\n
}\n
}\n
\n
if (query_string !== "" ) {\n
\n
if (query_string !== "") {\n
query_string += \' AND \' + tmp_hide_item;\n
} else if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + tmp_hide_item;\n
......@@ -520,7 +502,7 @@
"submit",\n
false,\n
function () {\n
gadget.triggleSortEditor();\n
gadget.triggerSortEditor();\n
}\n
);\n
})\n
......@@ -539,7 +521,6 @@
i,\n
th,\n
hide_form_elements,\n
hide_form_element_head,\n
checkbox;\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n
if (hide_form_elements.length > 0) {\n
......@@ -552,7 +533,9 @@
}\n
\n
return gadget.redirect({jio_key: gadget.props.jio_key, view: gadget.props.view,\n
"extended_search": gadget.props.extended_search || "", "sort_list": gadget.props.sort_list || "",\n
"extended_search": gadget.props.extended_search || "",\n
"domain_tree": gadget.props.domain_tree || "",\n
"sort_list": gadget.props.sort_list || "",\n
"hide_item": selected_uid_list});\n
}\n
th = document.createElement("th");\n
......@@ -747,7 +730,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.59934.39249.4522</string> </value>
<value> <string>945.61307.7519.27835</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -765,7 +748,7 @@
</tuple>
<state>
<tuple>
<float>1442934055.69</float>
<float>1443018723.19</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -175,6 +175,7 @@
sub_options.extended_search = options.extended_search;\n
sub_options.sort_list = options.sort_list;\n
sub_options.hide_item = options.hide_item;\n
sub_options.domain_tree = options.domain_tree;\n
sub_options.erp5_document = erp5_document;\n
sub_options.form_definition = erp5_form;\n
sub_options.view = options.view;\n
......@@ -334,7 +335,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58540.1924.39543</string> </value>
<value> <string>945.59567.60083.25890</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -352,7 +353,7 @@
</tuple>
<state>
<tuple>
<float>1442911674.99</float>
<float>1443010200.33</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -145,7 +145,7 @@
<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-left ui-icon-check">Save</button>\n
<button data-rel="save" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n
</form>\n
</div>\n
</div>\n
......@@ -287,7 +287,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>test</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -301,7 +301,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.49372.46702.47957</string> </value>
<value> <string>945.58401.24333.56064</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -319,7 +319,7 @@
</tuple>
<state>
<tuple>
<float>1442299971.28</float>
<float>1442993692.55</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -102,7 +102,7 @@
<value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2, maxerr: 3, nomen: true */\n
/*global window, document, rJS, URI, RSVP, UriTemplate, Handlebars, $, loopEventListener */\n
/*global window, document, rJS, URI, RSVP, UriTemplate, Handlebars, $, loopEventListener*/\n
(function (window, document, rJS, RSVP) {\n
"use strict";\n
var gadget_klass = rJS(window),\n
......@@ -237,18 +237,7 @@
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("redirect", "redirect")\n
.declareMethod(\'toggle\', function () {\n
var gadget = this,\n
options = gadget.props.options;\n
this.props.jelement.panel("toggle");\n
if (gadget.props.column_list === "") {\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.jio_getAttachment(options.jio_key, options.view);\n
})\n
.push(function (result) {\n
gadget.props.column_list = result._embedded._view.listbox.column_list;\n
});\n
}\n
})\n
//////////////////////////////////////////////\n
// initialize the gadget content\n
......@@ -264,9 +253,8 @@
}\n
options.view = options.view || "view";\n
gadget.props.options = options;\n
\n
\n
gadget.props.column_list = "";\n
if (options.sort_list) {\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.jio_getAttachment(options.jio_key, options.view);\n
......@@ -274,15 +262,14 @@
.push(function (result) {\n
var key;\n
gadget.props.column_list = result._embedded._view.listbox.column_list;\n
for (key in options.sort_list) {\n
if (options.sort_list.hasOwnProperty(key)) {\n
if (options.sort_list[key] !== "") {\n
container.insertBefore(createSortItem(gadget, options.sort_list[key]), container.lastChild);\n
for (key in options.form_definition.sort_list) {\n
if (options.form_definition.sort_list.hasOwnProperty(key)) {\n
if (options.form_definition.sort_list[key] !== "") {\n
container.insertBefore(createSortItem(gadget, options.form_definition.sort_list[key]), container.lastChild);\n
}\n
}\n
}\n
});\n
}\n
})\n
//////////////////////////////////////////////\n
.declareService(function () {\n
......@@ -327,10 +314,13 @@
.push(function () {\n
gadget.props.jelement.panel("toggle");\n
return gadget.redirect({jio_key: gadget.props.options.jio_key, view: gadget.props.options.view,\n
"extended_search": gadget.props.options.extended_search || "", "sort_list": sort_query,\n
"hide_item": gadget.props.options.hide_item || ""});\n
});\n
"extended_search": gadget.props.options.form_definition.extended_search || "",\n
"domain_tree": gadget.props.options.form_definition.domain_tree || "",\n
"sort_list": sort_query,\n
"hide_item": gadget.props.options.form_definition.hide_item || ""});\n
});\n
}\n
);\n
});\n
\n
}(window, document, rJS, RSVP));
......@@ -470,7 +460,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.59595.22725.716</string> </value>
<value> <string>945.61360.46259.34611</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -488,7 +478,7 @@
</tuple>
<state>
<tuple>
<float>1442913587.3</float>
<float>1443019877.26</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