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 ...@@ -103,9 +103,8 @@ def getAllSubCategoriesAsMap(root):\n
sub_categories_list = root.objectValues()\n sub_categories_list = root.objectValues()\n
if len(sub_categories_list) != 0:\n if len(sub_categories_list) != 0:\n
for grain in sub_categories_list:\n for grain in sub_categories_list:\n
result[grain.getId()] = {"sub_categories": getAllSubCategoriesAsMap(grain),\n result[grain.getUid()] = {"sub_categories": getAllSubCategoriesAsMap(grain),\n
"title": grain.getTitle(),\n "title": grain.getTitle()}\n
"uid": grain.getUid()}\n
\n \n
return result\n return result\n
\n \n
...@@ -392,9 +391,10 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -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 domain_tree = field.get_value("domain_root_list")\n
for tree in domain_tree:\n for tree in domain_tree:\n
if hasattr(portal_categories, tree[0]):\n if hasattr(portal_categories, tree[0]):\n
domain_tree_map[tree[0]] = {"sub_categories":getAllSubCategoriesAsMap(portal_categories[tree[0]]),\n domain_tree_map[portal_categories[tree[0]].getUid()] = {\n
"title": tree[1],\n "sub_categories":getAllSubCategoriesAsMap(portal_categories[tree[0]]),\n
"uid": portal_categories[tree[0]].getUid()}\n "title": tree[1]\n
}\n
\n \n
result = {\n result = {\n
"type": meta_type,\n "type": meta_type,\n
......
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="submit">\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 </form>\n
</div>\n </div>\n
</div>\n </div>\n
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.37783.58290.59204</string> </value> <value> <string>945.58401.24333.56064</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442309257.72</float> <float>1442993681.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -213,8 +213,7 @@ ...@@ -213,8 +213,7 @@
parent_element = document.createElement("div");\n parent_element = document.createElement("div");\n
suboption_dict.jio_key = options.jio_key;\n suboption_dict.jio_key = options.jio_key;\n
suboption_dict.view = options.view;\n suboption_dict.view = options.view;\n
delete options.erp5_document;\n \n
delete options.form_definition;\n
\n \n
// options = options.form_gadget || {};\n // options = options.form_gadget || {};\n
form_gadget.state_parameter_dict = options.form_gadget || {};\n form_gadget.state_parameter_dict = options.form_gadget || {};\n
...@@ -228,6 +227,10 @@ ...@@ -228,6 +227,10 @@
if (form_definition.hide_item) {\n if (form_definition.hide_item) {\n
suboption_dict.hide_item = form_definition.hide_item;\n suboption_dict.hide_item = form_definition.hide_item;\n
}\n }\n
\n
if (form_definition.domain_tree) {\n
suboption_dict.domain_tree = form_definition.domain_tree;\n
}\n
\n \n
form_gadget.props.gadget_list = [];\n form_gadget.props.gadget_list = [];\n
form_gadget.props.id = erp5_document._id;\n form_gadget.props.id = erp5_document._id;\n
...@@ -521,7 +524,7 @@ ...@@ -521,7 +524,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.59569.17291.44356</string> </value> <value> <string>945.61212.37056.32187</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -539,7 +542,7 @@ ...@@ -539,7 +542,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442911758.8</float> <float>1443019673.69</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2, maxerr: 3, nomen: true */\n /*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 (function (window, document, rJS, URI, RSVP, UriTemplate) {\n
"use strict";\n "use strict";\n
\n \n
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
.declareAcquiredMethod("redirect", "redirect")\n .declareAcquiredMethod("redirect", "redirect")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n .declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
.declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")\n .declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")\n
.declareAcquiredMethod("triggleSortEditor", "triggleSortEditor")\n .declareAcquiredMethod("triggerSortEditor", "triggerSortEditor")\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
// initialize the gadget content\n // initialize the gadget content\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
\n \n
gadget.props.field_json = field_json;\n gadget.props.field_json = field_json;\n
gadget.props.extended_search = options.extended_search;\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.jio_key = options.jio_key;\n
gadget.props.view = options.view;\n gadget.props.view = options.view;\n
if (options.sort_list) {\n if (options.sort_list) {\n
...@@ -209,22 +210,20 @@ ...@@ -209,22 +210,20 @@
begin_from = props.begin_from,\n begin_from = props.begin_from,\n
table = props.element.querySelector(\'table\'),\n table = props.element.querySelector(\'table\'),\n
original_tfoot = props.element.querySelector(\'tfoot\'),\n original_tfoot = props.element.querySelector(\'tfoot\'),\n
original_tbody = props.element.querySelector(\'tbody\'),\n
tbody = document.createElement("tbody"),\n tbody = document.createElement("tbody"),\n
url_query = props.extended_search,\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 query_string = "",\n
lines = field_json.lines,\n lines = field_json.lines,\n
select_list = [],\n select_list = [],\n
dataset,\n dataset,\n
last_uid,\n
counter,\n counter,\n
tmp_query,\n
domain_query,\n
domain_tree_map,\n
hide_item = gadget.props.hide_item || [],\n hide_item = gadget.props.hide_item || [],\n
tmp_hide_item,\n tmp_hide_item,\n
sort_list = gadget.props.sort_list || [],\n sort_list = gadget.props.sort_list || [],\n
operator,\n
i,\n i,\n
j,\n j,\n
list_method_promise = function () {\n list_method_promise = function () {\n
...@@ -239,41 +238,6 @@ ...@@ -239,41 +238,6 @@
// }\n // }\n
//rebuild query\n //rebuild query\n
if (url_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 //query_string = field_json.column_list.reduce(buildQueryString, \' AND (\').replace(new RegExp("OR " + \'$\'), \')\');\n
if (field_json.list_method_template === undefined) {\n if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + url_query;\n query_string = \' AND \' + url_query;\n
...@@ -281,7 +245,25 @@ ...@@ -281,7 +245,25 @@
query_string = url_query;\n query_string = url_query;\n
}\n }\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 if (hide_item.length > 0) {\n
tmp_hide_item = "catalog.uid: (";\n tmp_hide_item = "catalog.uid: (";\n
for (i = 0; i < hide_item.length; i += 1) {\n for (i = 0; i < hide_item.length; i += 1) {\n
...@@ -292,8 +274,8 @@ ...@@ -292,8 +274,8 @@
tmp_hide_item += ")";\n tmp_hide_item += ")";\n
}\n }\n
}\n }\n
\n \n
if (query_string !== "" ) {\n if (query_string !== "") {\n
query_string += \' AND \' + tmp_hide_item;\n query_string += \' AND \' + tmp_hide_item;\n
} else if (field_json.list_method_template === undefined) {\n } else if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + tmp_hide_item;\n query_string = \' AND \' + tmp_hide_item;\n
...@@ -520,7 +502,7 @@ ...@@ -520,7 +502,7 @@
"submit",\n "submit",\n
false,\n false,\n
function () {\n function () {\n
gadget.triggleSortEditor();\n gadget.triggerSortEditor();\n
}\n }\n
);\n );\n
})\n })\n
...@@ -539,7 +521,6 @@ ...@@ -539,7 +521,6 @@
i,\n i,\n
th,\n th,\n
hide_form_elements,\n hide_form_elements,\n
hide_form_element_head,\n
checkbox;\n checkbox;\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n
if (hide_form_elements.length > 0) {\n if (hide_form_elements.length > 0) {\n
...@@ -552,7 +533,9 @@ ...@@ -552,7 +533,9 @@
}\n }\n
\n \n
return gadget.redirect({jio_key: gadget.props.jio_key, view: gadget.props.view,\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 "hide_item": selected_uid_list});\n
}\n }\n
th = document.createElement("th");\n th = document.createElement("th");\n
...@@ -747,7 +730,7 @@ ...@@ -747,7 +730,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.59934.39249.4522</string> </value> <value> <string>945.61307.7519.27835</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -765,7 +748,7 @@ ...@@ -765,7 +748,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442934055.69</float> <float>1443018723.19</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -175,6 +175,7 @@ ...@@ -175,6 +175,7 @@
sub_options.extended_search = options.extended_search;\n sub_options.extended_search = options.extended_search;\n
sub_options.sort_list = options.sort_list;\n sub_options.sort_list = options.sort_list;\n
sub_options.hide_item = options.hide_item;\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.erp5_document = erp5_document;\n
sub_options.form_definition = erp5_form;\n sub_options.form_definition = erp5_form;\n
sub_options.view = options.view;\n sub_options.view = options.view;\n
...@@ -334,7 +335,7 @@ ...@@ -334,7 +335,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.58540.1924.39543</string> </value> <value> <string>945.59567.60083.25890</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -352,7 +353,7 @@ ...@@ -352,7 +353,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442911674.99</float> <float>1443010200.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="submit">\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 </form>\n
</div>\n </div>\n
</div>\n </div>\n
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>test</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.49372.46702.47957</string> </value> <value> <string>945.58401.24333.56064</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -319,7 +319,7 @@ ...@@ -319,7 +319,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442299971.28</float> <float>1442993692.55</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2, maxerr: 3, nomen: true */\n /*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 (function (window, document, rJS, RSVP) {\n
"use strict";\n "use strict";\n
var gadget_klass = rJS(window),\n var gadget_klass = rJS(window),\n
...@@ -237,18 +237,7 @@ ...@@ -237,18 +237,7 @@
.declareAcquiredMethod("translateHtml", "translateHtml")\n .declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("redirect", "redirect")\n .declareAcquiredMethod("redirect", "redirect")\n
.declareMethod(\'toggle\', function () {\n .declareMethod(\'toggle\', function () {\n
var gadget = this,\n
options = gadget.props.options;\n
this.props.jelement.panel("toggle");\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
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
// initialize the gadget content\n // initialize the gadget content\n
...@@ -264,25 +253,23 @@ ...@@ -264,25 +253,23 @@
}\n }\n
options.view = options.view || "view";\n options.view = options.view || "view";\n
gadget.props.options = options;\n gadget.props.options = options;\n
\n \n
gadget.props.column_list = "";\n gadget.props.column_list = "";\n
if (options.sort_list) {\n return new RSVP.Queue()\n
return new RSVP.Queue()\n .push(function () {\n
.push(function () {\n return gadget.jio_getAttachment(options.jio_key, options.view);\n
return gadget.jio_getAttachment(options.jio_key, options.view);\n })\n
})\n .push(function (result) {\n
.push(function (result) {\n var key;\n
var key;\n gadget.props.column_list = result._embedded._view.listbox.column_list;\n
gadget.props.column_list = result._embedded._view.listbox.column_list;\n for (key in options.form_definition.sort_list) {\n
for (key in options.sort_list) {\n if (options.form_definition.sort_list.hasOwnProperty(key)) {\n
if (options.sort_list.hasOwnProperty(key)) {\n if (options.form_definition.sort_list[key] !== "") {\n
if (options.sort_list[key] !== "") {\n container.insertBefore(createSortItem(gadget, options.form_definition.sort_list[key]), container.lastChild);\n
container.insertBefore(createSortItem(gadget, options.sort_list[key]), container.lastChild);\n
}\n
}\n }\n
}\n }\n
});\n }\n
}\n });\n
})\n })\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
.declareService(function () {\n .declareService(function () {\n
...@@ -327,10 +314,13 @@ ...@@ -327,10 +314,13 @@
.push(function () {\n .push(function () {\n
gadget.props.jelement.panel("toggle");\n gadget.props.jelement.panel("toggle");\n
return gadget.redirect({jio_key: gadget.props.options.jio_key, view: gadget.props.options.view,\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 "extended_search": gadget.props.options.form_definition.extended_search || "",\n
"hide_item": gadget.props.options.hide_item || ""});\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
});\n });\n
\n \n
}(window, document, rJS, RSVP)); }(window, document, rJS, RSVP));
...@@ -470,7 +460,7 @@ ...@@ -470,7 +460,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.59595.22725.716</string> </value> <value> <string>945.61360.46259.34611</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -488,7 +478,7 @@ ...@@ -488,7 +478,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442913587.3</float> <float>1443019877.26</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