diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml index 1d9aa490e4309628677ce1e747c16821adcd0552..2570830748d2af7529d3fb8c9b1fd18c8925b0f2 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml @@ -140,6 +140,7 @@ group_list = form_definition.group_list,\n queue = new RSVP.Queue(),\n form_gadget = this,\n + suboption_dict = {},\n parent_element = document.createElement("div");\n \n delete options.erp5_document;\n @@ -147,6 +148,10 @@ \n // options = options.form_gadget || {};\n form_gadget.state_parameter_dict = options.form_gadget || {};\n + // XXX Hardcoded for searchfield - remove later!\n + if (form_definition.extended_search) {\n + suboption_dict.extended_search = form_definition.extended_search;\n + }\n \n form_gadget.props.gadget_list = [];\n form_gadget.props.id = erp5_document._id;\n @@ -203,7 +208,7 @@ })\n .push(function (field_gadget) {\n form_gadget.props.gadget_list.push(field_gadget);\n - var suboptions = options[renderered_field.key] || {};\n + var suboptions = options[renderered_field.key] || suboption_dict;\n suboptions.field_json = renderered_field;\n return field_gadget.render(suboptions);\n });\n diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml index 64f466a0dc5e1704f5c4532c62473ce19ad7b189..e85037cec8850c5e9e1be40cdd459ca8021d6844 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml @@ -138,6 +138,7 @@ \n gadget.props.field_json = field_json;\n gadget.props.begin_from = parseInt(options.begin_from, 10) || 0;\n + gadget.props.extended_search = options.extended_search;\n \n for (i = 0; i < field_json.column_list.length; i += 1) {\n th = document.createElement("th");\n @@ -152,22 +153,34 @@ //////////////////////////////////////////////\n .declareService(function () {\n var gadget = this,\n - field_json = gadget.props.field_json,\n - begin_from = gadget.props.begin_from,\n - table = gadget.props.element.querySelector(\'table\'),\n + props = gadget.props,\n + field_json = props.field_json,\n + begin_from = props.begin_from,\n + table = props.element.querySelector(\'table\'),\n tbody = document.createElement("tbody"),\n + url_query = props.extended_search,\n + query_string = "",\n lines = field_json.lines,\n select_list = [],\n dataset,\n counter,\n i;\n +\n + // function buildQueryString(previous, next) {\n + // return previous + next[0] + \':= "\' + url_query + \'" OR \';\n + // }\n +\n + if (url_query) {\n + //query_string = field_json.column_list.reduce(buildQueryString, \' AND (\').replace(new RegExp("OR " + \'$\'), \')\');\n + query_string = \' AND \' + url_query;\n + }\n \n for (i = 0; i < field_json.column_list.length; i += 1) {\n select_list.push(field_json.column_list[i][0]);\n }\n \n return gadget.jio_allDocs({\n - "query": new URI(field_json.query).query(true).query,\n + "query": new URI(field_json.query).query(true).query + query_string,\n "limit": [begin_from, begin_from + lines + 1],\n "select_list": select_list\n }).push(function (result) {\n @@ -239,7 +252,7 @@ paging_wrap = document.createElement("div"),\n len;\n \n - th.colspan = lines;\n + th.setAttribute("colspan", field_json.column_list.length);\n \n paging_menu.className = "ui-controlgroup ui-controlgroup-horizontal ui-corner-all";\n paging_wrap.className = "ui-controlgroup-controls";\n diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_html.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_html.xml index d347114e53e2a8846b1658f3617abde6755e7908..54890ed0259760fd90bfafb1748b55bb355a5fe0 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_html.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_html.xml @@ -118,10 +118,13 @@ \n </head>\n <body>\n -\n + <div data-gadget-url="gadget_erp5_searchfield.html"\n + data-gadget-scope="erp5_searchfield"\n + data-gadget-sandbox="public"></div>\n + \n <div data-gadget-url="gadget_erp5_form.html"\n data-gadget-scope="erp5_form"\n - data-gadget-sandbox="public">\n + data-gadget-sandbox="public"></div>\n \n </body>\n </html> diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml index 94a48aaad1b201acb828ccf6211328daae587dab..ebe0c45ce917d9f5a788bb8d25be5b1e3e09f645 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml @@ -97,7 +97,6 @@ <key> <string>text_content</string> </key> <value> <string>/*global rJS, RSVP, jQuery, Handlebars,\n promiseEventListener, console */\n -/*jslint nomen: true */\n /*global window, rJS, RSVP, StatelessJS, alert, FormData, document, console */\n /*jslint maxlen:200, nomen: true */\n (function (window, rJS, RSVP) {\n @@ -108,16 +107,31 @@ // declared methods\n /////////////////////////////////////////////////////////////////\n .declareMethod(\'render\', function (options) {\n -\n + var gadget = this;\n var form_options = options.erp5_form || {};\n + var search_options = {};\n \n form_options.erp5_document = options.erp5_document;\n form_options.form_definition = options.form_definition;\n + // XXX not generic, fix later\n + if (options.erp5_searchfield) {\n + form_options.form_definition.extended_search = options.erp5_searchfield.extended_search;\n + search_options.extended_search = options.erp5_searchfield.extended_search;\n + }\n form_options.view = options.view;\n \n - return this.getDeclaredGadget("erp5_form")\n - .push(function (erp5_form) {\n - return erp5_form.render(form_options);\n + return new RSVP.Queue()\n + .push(function () {\n + return RSVP.all([\n + gadget.getDeclaredGadget("erp5_searchfield"),\n + gadget.getDeclaredGadget("erp5_form")\n + ]);\n + })\n + .push(function (all_gadget) {\n + return RSVP.all([\n + all_gadget[0].render(search_options),\n + all_gadget[1].render(form_options)\n + ]);\n });\n \n });\n diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_html.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_html.xml new file mode 100644 index 0000000000000000000000000000000000000000..67bda4a860201b87e03d984e7f41eedf4d66588a --- /dev/null +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_html.xml @@ -0,0 +1,149 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Web Page" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_Access_contents_information_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Add_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Change_local_roles_Permission</string> </key> + <value> + <tuple> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Modify_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_View_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>content_md5</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>content_type</string> </key> + <value> <string>text/html</string> </value> + </item> + <item> + <key> <string>default_reference</string> </key> + <value> <string>gadget_erp5_searchfield.html</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>rjs_gadget_erp5_searchfield_html</string> </value> + </item> + <item> + <key> <string>language</string> </key> + <value> <string>en</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Web Page</string> </value> + </item> + <item> + <key> <string>short_title</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>text_content</string> </key> + <value> <string encoding="cdata"><![CDATA[ + +<!DOCTYPE html>\n +<html>\n + <head>\n + <meta charset="utf-8" />\n + <meta name="viewport" content="width=device-width, user-scalable=no" />\n + <title>ERP5 Search Field</title>\n +\n + <!-- renderjs -->\n + <script src="RSVP.js"></script>\n + <script src="renderjs.js"></script>\n + <!-- <script src="handlebars.js"></script> -->\n +\n + <!-- custom script -->\n + <script src="gadget_erp5_searchfield.js"></script>\n +\n + </head>\n + <body>\n +\n + <fieldset class="center">\n + <form class="search_form">\n + <div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">\n + <input type="text" data-enhanced="true" value="" name="search" />\n + <div class="ui-btn ui-input-clear ui-input-btn ui-corner-all ui-icon-search ui-btn-icon-notext">\n + Submit<input data-enhanced="true" type="submit" value="Submit">\n + </div>\n + </div>\n + </form>\n + </fieldset>\n +\n + </body>\n +</html> + +]]></string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Gadget ERP5 Search Field</string> </value> + </item> + <item> + <key> <string>version</string> </key> + <value> <string>001</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_js.xml new file mode 100644 index 0000000000000000000000000000000000000000..f22085094775da3a1720f15bac46a7308424c674 --- /dev/null +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_searchfield_js.xml @@ -0,0 +1,183 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Web Script" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_Access_contents_information_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Add_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Change_local_roles_Permission</string> </key> + <value> + <tuple> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Modify_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_View_Permission</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>content_md5</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>default_reference</string> </key> + <value> <string>gadget_erp5_searchfield.js</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>rjs_gadget_erp5_searchfield_js</string> </value> + </item> + <item> + <key> <string>language</string> </key> + <value> <string>en</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Web Script</string> </value> + </item> + <item> + <key> <string>short_title</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>text_content</string> </key> + <value> <string>/*global rJS, RSVP, jQuery, Handlebars,\n + promiseEventListener, console */\n +/*global window, rJS, RSVP, StatelessJS, alert, FormData, document, console */\n +/*jslint maxlen:200, nomen: true */\n +(function (window, rJS, RSVP, $) {\n + "use strict";\n +\n + rJS(window)\n + /////////////////////////////////////////////////////////////////\n + // ready\n + /////////////////////////////////////////////////////////////////\n + // Init local properties\n + .ready(function (g) {\n + g.props = {};\n + })\n +\n + // Assign the element to a variable\n + .ready(function (g) {\n + return g.getElement()\n + .push(function (element) {\n + g.props.element = element;\n + });\n + })\n +\n + .declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n + .declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")\n + /////////////////////////////////////////////////////////////////\n + // declared methods\n + /////////////////////////////////////////////////////////////////\n + .declareMethod(\'render\', function (options) {\n + this.props.element.querySelector("input").value = options.extended_search || "";\n + })\n +\n + .declareMethod(\'getContent\', function () {\n + var input = this.__element.querySelector(\'input\'),\n + result = {};\n +\n + result[input.getAttribute(\'name\')] = input.value;\n + return result;\n + })\n +\n + .declareService(function () {\n + var search_form = this;\n +\n + function formSubmit() {\n + var form_data;\n +\n + return new RSVP.Queue()\n + .push(function () {\n + return search_form.getContent();\n + })\n + .push(function (data) {\n + console.log(data);\n + return search_form.pleasePublishMyState({\n + "extended_search": data.search\n + });\n + })\n + .push(function (url) {\n + console.log(url);\n + return search_form.pleaseRedirectMyHash(url);\n + });\n + }\n +\n + // Listen to form submit\n + return loopEventListener(\n + search_form.props.element.querySelector(\'form\'),\n + \'submit\',\n + false,\n + formSubmit\n + );\n + });\n +\n +}(window, rJS, RSVP, jQuery));</string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Gadget ERP5 Search Field JS</string> </value> + </item> + <item> + <key> <string>version</string> </key> + <value> <string>001</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web_renderjs_ui/bt/revision b/bt5/erp5_web_renderjs_ui/bt/revision index 25bf17fc5aaabd17402e77a2b16f95fbea7310d2..dec2bf5d6199c7cd0d84f3dc1e76a73ccc336302 100644 --- a/bt5/erp5_web_renderjs_ui/bt/revision +++ b/bt5/erp5_web_renderjs_ui/bt/revision @@ -1 +1 @@ -18 \ No newline at end of file +19 \ No newline at end of file