Commit 1fcd0227 authored by Roque's avatar Roque Committed by Roque

erp5_web_project_ui: refactoring in queries and html document parsing

- test extended
parent b394f150
/*global document, window, rJS */ /*global window, rJS, SimpleQuery, ComplexQuery, Query */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 90 */ /*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 90 */
(function (document, window, rJS) { (function (window, rJS, SimpleQuery, ComplexQuery, Query) {
"use strict"; "use strict";
function createMultipleSimpleOrQuery(key, value_list) {
var i,
search_query,
query_list = [];
for (i = 0; i < value_list.length; i += 1) {
query_list.push(new SimpleQuery({
key: key,
operator: "",
type: "simple",
value: value_list[i]
}));
}
search_query = new ComplexQuery({
operator: "OR",
query_list: query_list,
type: "complex"
});
return Query.objectToSearchText(search_query);
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -17,14 +37,25 @@ ...@@ -17,14 +37,25 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, id, var gadget = this,
types = '("Text", "File", "PDF", "Drawing", ' + type_list = ["Text", "File", "PDF", "Drawing",
'"Presentation", "Spreadsheet")', "Presentation", "Spreadsheet"],
states = '("shared", "published", "released", ' + state_list = ["shared", "published", "released", "shared_alive",
'"shared_alive", "published_alive", "released_alive")', "published_alive", "released_alive"],
query = 'portal_type:' + types + portal_type_query = createMultipleSimpleOrQuery('portal_type', type_list),
'AND reference:"' + options.reference + state_query = createMultipleSimpleOrQuery('validation_state', state_list),
'" AND validation_state:' + states; reference_query = new SimpleQuery({
key: "reference",
operator: "=",
type: "simple",
value: options.reference
}),
query = new ComplexQuery({
operator: "AND",
query_list: [portal_type_query, state_query, reference_query],
type: "complex"
});
query = Query.objectToSearchText(query);
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: query, query: query,
limit: 1 limit: 1
...@@ -38,10 +69,9 @@ ...@@ -38,10 +69,9 @@
'history': options.history 'history': options.history
} }
}); });
} else {
return gadget.redirect({command: 'history_previous', options: {}});
} }
return gadget.redirect({command: 'history_previous', options: {}});
}); });
}); });
}(document, window, rJS)); }(window, rJS, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file \ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>979.50783.7411.19677</string> </value> <value> <string>979.57611.25870.2542</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1573658874.74</float> <float>1574068976.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -24,17 +24,25 @@ ...@@ -24,17 +24,25 @@
</tr> </tr>
<!-- Initialize --> <!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/portal_skins/erp5_web_project_test/ERP5Site_createTestStartedProject/</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Project Created</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/project_management/</td> <td>${base_url}/web_site_module/project_management/</td>
<td></td> <td></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr> <tr>
<td>assertElementPresent</td> <td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_erp5_field_listbox.html']</td> <td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_erp5_field_listbox.html']</td>
...@@ -45,6 +53,17 @@ ...@@ -45,6 +53,17 @@
<td>Projects</td> <td>Projects</td>
<td></td> <td></td>
</tr> </tr>
<!-- Check filter -->
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_erp5_searchfield.html']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_erp5_searchfield.html']//button[text()="started"]</td>
<td></td>
</tr>
<!-- Check sort --> <!-- Check sort -->
<tr> <tr>
<td>assertElementPresent</td> <td>assertElementPresent</td>
...@@ -87,7 +106,95 @@ ...@@ -87,7 +106,95 @@
<td>//div[@class='document_table']//th//a[text()="Location"]</td> <td>//div[@class='document_table']//th//a[text()="Location"]</td>
<td></td> <td></td>
</tr> </tr>
<!-- Check project present -->
<tr>
<td>assertElementPresent</td>
<td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@class='document_table']//table//tbody//tr//a[text()="test-project"]</td>
<td></td>
</tr>
<!-- check project quick view page elements -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[@id='milestone_link' and @class='first-line-buttons']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Milestones' and contains(@href, '#!push_history') and contains(@href, 'n.jio_key=milestone_module') and contains(@href, 'view%3Dmilestone')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Support requests']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Documents']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Opened Bugs']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Closed Bugs']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Confirmed Tasks']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Not Confirmed Tasks']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Opened Task Reports']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Closed Task Reports']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Last test result']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Test suite']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/project_management/gadget_project_info.html']//a[text()='Edit Project Page']</td>
<td></td>
</tr>
</tbody></table> </tbody></table>
</body> </body>
</html> </html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_web_project_test</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
module = portal.getDefaultModule('Project')
project = module.newContent(portal_type = 'Project',
reference = 'test-project')
project.validate()
print "Project Created"
return printed
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_createTestStartedProject</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
erp5_web_project_test
\ No newline at end of file
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