Commit 1b94a641 authored by Jérome Perrin's avatar Jérome Perrin

Support Request App: compatibility with new erp5_hal_json

Some things in support request app where working apparently a bit by chance and they no longer work with new erp5_hal_json (
09d00cae )

This aims at using erp5_hal_json as intended and simplifying the customisations by customising "only" the header gadget and not the page gadget.

/reviewed-on !787
parents 073444ac f82ce8c5
......@@ -112,7 +112,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# v1.0.4\n
# v1.0.5\n
CACHE:\n
font-awesome/font-awesome-webfont.woff2\n
echarts-all.js\n
......@@ -152,8 +152,8 @@ gadget_erp5_page_form.js\n
gadget_erp5_page_homepage.css\n
gadget_erp5_page_homepage.html\n
gadget_erp5_page_homepage.js\n
gadget_erp5_page_list.html\n
gadget_erp5_page_list.js\n
gadget_supportrequest_header.html\n
gadget_supportrequest_header.js\n
gadget_erp5_page_supportrequest_preference.html\n
gadget_erp5_page_supportrequest_preference.js\n
gadget_erp5_page_support_request_fast_view_dialog.html\n
......@@ -360,7 +360,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1536561148.11</float>
<float>1540870337.1</float>
<string>GMT+9</string>
</tuple>
</state>
......
......@@ -10,22 +10,9 @@
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("notifyChange", "notifyChange")
.allowPublicAcquisition("redirect", function (param_list) {
var gadget = this;
return gadget.redirect({command: 'change', options: {
view: gadget.hateoas_url +
"ERP5Document_getHateoas?mode=traverse&relative_url=" +
encodeURIComponent(param_list[0].options.jio_key) +
"&view=officejs_support_request_view",
page: 'list',
jio_key: param_list[0].options.jio_key
}
});
})
.allowPublicAcquisition("notifyChange", function (param_list) {
if (param_list[0]) {
return this.notifyChange("Please provide a description for this support request.");
......
......@@ -256,8 +256,8 @@
</tuple>
<state>
<tuple>
<float>1506672340.09</float>
<string>UTC</string>
<float>1540524000.73</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Support Request Header</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_supportrequest_header.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_header.html" data-gadget-scope="header" data-gadget-sandbox="public">
</body>
</html>
\ No newline at end of file
......@@ -16,7 +16,6 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -59,10 +58,15 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -75,7 +79,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_list.html</string> </value>
<value> <string>gadget_supportrequest_header.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +89,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_supportrequest_pt_listpage_html</string> </value>
<value> <string>gadget_supportrequest_header_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -103,7 +107,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget Support Request List HTML</string> </value>
<value> <string>Gadget Support Request Header HTML</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -167,7 +171,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -189,8 +193,8 @@
</tuple>
<state>
<tuple>
<float>1497910732.61</float>
<string>UTC</string>
<float>1540867849.08</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......@@ -220,7 +224,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.303.21710.19063</string> </value>
<value> <string>971.18479.8827.61354</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,8 +256,8 @@
</tuple>
<state>
<tuple>
<float>1504275408.49</float>
<string>UTC</string>
<float>1540870432.58</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......@@ -279,7 +283,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -309,8 +313,8 @@
</tuple>
<state>
<tuple>
<float>1497909778.2</float>
<string>UTC</string>
<float>1540867644.05</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......
/*global window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
'use strict';
/**
* A gadget which embeds default header, but remove add button, because in the
* case of support request app, adding is done through fast input.
*/
var gadgetKlass = rJS(window)
.declareMethod('render', function (options) {
delete options.add_url;
return this.getDeclaredGadget('header').push(function (headerGadget) {
return headerGadget.render(options);
});
});
/**
* Delegate a method to embedded header gadget
* @param {string}methodName method name
*/
function delegateMethod(methodName) {
gadgetKlass.declareMethod(methodName, function () {
var methodArguments = arguments;
return this.getDeclaredGadget('header').push(function (headerGadget) {
return headerGadget[methodName].apply(headerGadget, methodArguments);
});
});
}
delegateMethod('notifyLoaded');
delegateMethod('notifyLoading');
delegateMethod('notifySubmitted');
delegateMethod('notifySubmitting');
delegateMethod('notifyError');
delegateMethod('notifyChange');
delegateMethod('setButtonTitle');
}(window, rJS));
\ No newline at end of file
......@@ -16,7 +16,6 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -59,7 +58,6 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -75,7 +73,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_list.js</string> </value>
<value> <string>gadget_supportrequest_header.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +83,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_supportrequest_pt_listpage_js</string> </value>
<value> <string>gadget_supportrequest_header_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -103,7 +101,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget Support Request List JS</string> </value>
<value> <string>Gadget Support Request Header JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -167,7 +165,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -189,8 +187,8 @@
</tuple>
<state>
<tuple>
<float>1497910839.57</float>
<string>UTC</string>
<float>1540867895.46</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......@@ -220,7 +218,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.303.21710.19063</string> </value>
<value> <string>971.18510.51356.54101</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,8 +250,8 @@
</tuple>
<state>
<tuple>
<float>1504275382.57</float>
<string>UTC</string>
<float>1540870427.65</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......@@ -279,7 +277,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -309,8 +307,8 @@
</tuple>
<state>
<tuple>
<float>1497909777.39</float>
<string>UTC</string>
<float>1540867824.38</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......
......@@ -96,7 +96,7 @@
context.getUrlFor({command: 'display', options: {page: "supportrequest_preference"}}),
context.getUrlFor({command: 'display', options: {page: "logout"}}),
context.getUrlFor({command: 'display', options: {page: "search"}}),
context.getUrlFor({command: 'display', options: {jio_key: "support_request_module", page: "list"}})
context.getUrlFor({command: 'display', options: {jio_key: "support_request_module"}})
]);
})
.push(function (result_list) {
......
......@@ -252,8 +252,8 @@
</tuple>
<state>
<tuple>
<float>1523022102.41</float>
<string>GMT+2</string>
<float>1540790670.05</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......
<!DOCTYPE html>
<html>
<!--
data-i18n=User
data-i18n=Language
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Page Preferences</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_page_list.js" type="text/javascript"></script>
</head>
<body>
<form class="preference">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
\ No newline at end of file
/*global window, rJS, URI */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, URI) {
"use strict";
function loadFormContent(gadget, result) {
var key;
if (gadget.state.options.form_content) {
for (key in result) {
if (result.hasOwnProperty(key)) {
if (gadget.state.options.form_content[result[key].key]) {
result[key].default = gadget.state.options.form_content[result[key].key];
}
}
}
}
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("updateHeader", "updateHeader")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("updateHeader", function (param_list) {
var param = param_list[0];
delete param.add_url;
delete param.actions_url;
delete param.cut_url;
delete param.jump_url;
delete param.export_url;
return this.updateHeader(param);
})
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i;
if (result.data.rows.length) {
for (i = 0; i < result.data.rows.length; i += 1) {
loadFormContent(gadget, result.data.rows[i].value);
}
}
return result;
});
})
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.declareMethod('triggerSubmit', function () {
return this.getDeclaredGadget('fg')
.push(function (g) {
return g.triggerSubmit();
});
})
.declareMethod("render", function (options) {
var gadget = this,
view;
return gadget.getUrlParameter('view')
.push(function (result) {
view = result;
return gadget.jio_getAttachment(options.jio_key, view || "view")
})
.push(function (result) {
var uri;
if (!result._embedded) {
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result2) {
return gadget.redirect({command: 'change', options: {
view: result2._links.view[0].href,
page: "list"
}});
});
}
uri = new URI(result._embedded._view._links.form_definition.href);
return gadget.jio_getAttachment(uri.segment(2), "view")
.push(function (erp5_form) {
var url = "gadget_erp5_pt_" + erp5_form.pt;
// XXX Hardcoded specific behaviour for form_view
if ((options.editable !== undefined) && (erp5_form.pt === "form_view")) {
url += "_editable";
}
url += ".html";
return gadget.changeState({
jio_key: options.jio_key,
options: options,
view: options.view,
url: url,
erp5_document: JSON.stringify(result),
erp5_form: JSON.stringify(erp5_form)
});
});
});
})
.onStateChange(function (modification_dict) {
var queue,
gadget = this,
options = this.state.options,
page_template_gadget,
clean_dom = modification_dict.hasOwnProperty('url');
if (clean_dom) {
queue = gadget.declareGadget(gadget.state.url, {scope: "fg"});
} else {
queue = gadget.getDeclaredGadget("fg");
}
return queue
.push(function (result) {
page_template_gadget = result;
var sub_options = options.fg || {},
erp5_document = JSON.parse(gadget.state.erp5_document),
erp5_form = JSON.parse(gadget.state.erp5_form);
loadFormContent(gadget, erp5_document._embedded._view);
sub_options.erp5_document = erp5_document;
sub_options.form_definition = erp5_form;
sub_options.view = options.view;
sub_options.action_view = options.action_view;
sub_options.jio_key = options.jio_key;
sub_options.editable = options.editable;
return page_template_gadget.render(sub_options);
})
.push(function () {
if (clean_dom) {
return page_template_gadget.getElement()
.push(function (fragment) {
var element = gadget.element;
// Clear first to DOM, append after to reduce flickering/manip
while (element.firstChild) {
element.removeChild(element.firstChild);
}
element.appendChild(fragment);
});
}
})
.push(function () {
var jio_key = gadget.state.options.jio_key;
/*jslint regexp: true*/
if (/^[^\/]+_module\/.+$/.test(jio_key)) {
/*jslint regexp: false*/
return gadget.updatePanel({
erp5_document: JSON.parse(gadget.state.erp5_document),
editable: gadget.state.options.editable
});
}
});
})
.allowPublicAcquisition("displayFormulatorValidationError", function (param_list) {
var erp5_document = JSON.parse(this.state.erp5_document);
erp5_document._embedded._view = param_list[0];
// Force refresh
erp5_document._now = Date.now();
return this.changeState({erp5_document: JSON.stringify(erp5_document)});
});
}(window, rJS, URI));
\ No newline at end of file
......@@ -348,9 +348,7 @@
</item>
<item>
<key> <string>configuration_header_gadget_url</string> </key>
<value>
<none/>
</value>
<value> <string>gadget_supportrequest_header.html</string> </value>
</item>
<item>
<key> <string>configuration_jio_gadget_url</string> </key>
......@@ -625,8 +623,8 @@
</tuple>
<state>
<tuple>
<float>1506518906.34</float>
<string>UTC</string>
<float>1540870022.36</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
......
......@@ -19,34 +19,6 @@
<td>//input[@data-i18n='[value]Submit New Support Request']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//input[@data-i18n='[value]Submit New Support Request']</td>
<td></td>
</tr>
<tal:block tal:define="text_content string:Post test">
<tal:block metal:use-macro="container/Zuite_CommonTemplateForRenderjsUi/macros/type_ckeditor_text_content"/>
</tal:block>
<tr>
<td>type</td>
<td>//input[@name='field_your_title']</td>
<td>test</td>
</tr>
<tr>
<td>select</td>
<td>field_your_resource</td>
<td>FeatureRequire</td>
</tr>
<tr>
<td>click</td>
<td>//input[@data-i18n='[value]Proceed']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//input[@data-i18n='[value]Post Comment']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Support Requests']</td>
......@@ -62,6 +34,19 @@
<td>Title</td>
<td></td>
</tr>
<!-- The only way to add support requests is to use the "Submit new support request"
from the home page.
We intentionally disable the +Add button on the list view of support request module,
to prevent users from adding support requests this way, because we need to use the
fast input to set project, support request type and other required properties.
-->
<tr>
<td>assertElementNotPresent</td>
<td>//a[@data-i18n='Add']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ 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