Commit 54ca1675 authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_UI: allow users to delete and minor refactoring

parent 1f6c1731
...@@ -95,12 +95,12 @@ ...@@ -95,12 +95,12 @@
]); ]);
}) })
.push(function (setting_list) { .push(function (setting_list) {
/*return gadget.state_parameter_dict.jio_storage.createJio({ return gadget.state_parameter_dict.jio_storage.createJio({
type: "erp5", type: "erp5",
url: setting_list[0], url: setting_list[0],
default_view_reference: setting_list[1] default_view_reference: setting_list[1]
});*/ });
return gadget.state_parameter_dict.jio_storage.createJio({ /*return gadget.state_parameter_dict.jio_storage.createJio({
type: "replicate", type: "replicate",
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
...@@ -115,23 +115,24 @@ ...@@ -115,23 +115,24 @@
default_view_reference: setting_list[1] default_view_reference: setting_list[1]
}, },
query: { query: {
query: 'portal_type:"Data Array" OR portal_type:"Data Descriptor" OR portal_type:"Data Set"', //query: 'portal_type:"Data Array" OR portal_type:"Data Descriptor" OR portal_type:"Data Set"', // and validation_state = 'validated'
query: 'validation_state:"validated" AND portal_type:"Data Array" OR portal_type:"Data Descriptor" OR portal_type:"Data Set"',
limit: [0, 20000] limit: [0, 20000]
}, },
check_local_modification: false, //check_local_modification: false,
check_local_creation: false, check_local_creation: false,
//check_local_deletion: false, //check_local_deletion: false,
check_local_attachment_modification: false, //check_local_attachment_modification: false,
check_local_attachment_creation: false, check_local_attachment_creation: false,
//check_local_attachment_deletion: false, //check_local_attachment_deletion: false,
check_remote_modification: false, //check_remote_modification: false,
check_remote_attachment_modification: false //check_remote_attachment_modification: false
}); });*/
}) })
.push(function () { /*.push(function () {
if (navigator.onLine) if (navigator.onLine)
return wrapJioCall(gadget, "repair", []); return wrapJioCall(gadget, "repair", []);
}); })*/;
}) })
.declareMethod('allDocs', function (option_dict) { .declareMethod('allDocs', function (option_dict) {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.14289.42730.50432</string> </value> <value> <string>962.62889.55640.44134</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1498141059.77</float> <float>1508748123.09</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -26,15 +26,9 @@ ...@@ -26,15 +26,9 @@
html = "push <i>my-data-set</i>"; html = "push <i>my-data-set</i>";
return this.changeState({"dataset_reference" : html}); return this.changeState({"dataset_reference" : html});
}) })
/*.onStateChange(function (modification_dict) {
console.log("STATUS CHANGED !!");
})*/
.declareService(function () { .declareService(function () {
document.getElementById("dataset_reference").innerHTML = this.state.dataset_reference; document.getElementById("dataset_reference").innerHTML = this.state.dataset_reference;
}) })
/*.ready(function () {
console.log("DOM LOADED!");
})*/
.onEvent('submit', function (evt) { .onEvent('submit', function (evt) {
if (evt.target.name === 'download') { if (evt.target.name === 'download') {
return this.download(evt); return this.download(evt);
......
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1498723115.95</float> <float>1508757685.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -70,12 +70,12 @@ ...@@ -70,12 +70,12 @@
<div class="ui-controlgroup-controls"> <div class="ui-controlgroup-controls">
</div> </div>
</div> </div>
<!-- <!-- ROQUESUBHEADER -->
<div class="ui-navbar ui-subheader ui-grid-container ui-body-a" role="navigation"> <div class="ui-navbar ui-subheader ui-grid-container ui-body-a" role="navigation">
<ul class="ui-grid-d"> <ul class="ui-grid-d">
</ul> </ul>
</div> </div>
--> <!-- ROQUESUBHEADER -->
</div> </div>
</body> </body>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.7946.30674.29798</string> </value> <value> <string>959.7948.48395.27716</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>1493827836.9</float> <float>1508506834.12</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
header_title_link_template = Handlebars.compile(template_element header_title_link_template = Handlebars.compile(template_element
.getElementById("header-title-link-template") .getElementById("header-title-link-template")
.innerHTML), .innerHTML),
/*sub_header_template = Handlebars.compile(template_element sub_header_template = Handlebars.compile(template_element
.getElementById("sub-header-template") .getElementById("sub-header-template")
.innerHTML),*/ .innerHTML),
header_button_template = Handlebars.compile(template_element header_button_template = Handlebars.compile(template_element
.getElementById("header-button-template") .getElementById("header-button-template")
.innerHTML), .innerHTML),
...@@ -78,8 +78,8 @@ ...@@ -78,8 +78,8 @@
element_list: [ element_list: [
this.element.querySelector("h1"), this.element.querySelector("h1"),
this.element.querySelector(".ui-btn-left > div"), this.element.querySelector(".ui-btn-left > div"),
this.element.querySelector(".ui-btn-right > div") this.element.querySelector(".ui-btn-right > div"),
//this.element.querySelector(".ui-subheader").querySelector("ul") this.element.querySelector(".ui-subheader").querySelector("ul")
] ]
}; };
}) })
...@@ -128,11 +128,11 @@ ...@@ -128,11 +128,11 @@
modified: true modified: true
}); });
}) })
/* /*
.declareMethod('notifyUpdate', function () { .declareMethod('notifyUpdate', function () {
return this.render(this.stats.options); return this.render(this.stats.options);
}) })
*/ */
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var state = { var state = {
error: false, error: false,
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
} }
// Sub header // Sub header
/*for (i = 0; i < possible_sub_header_list.length; i += 1) { for (i = 0; i < possible_sub_header_list.length; i += 1) {
if (options.hasOwnProperty(possible_sub_header_list[i][0])) { if (options.hasOwnProperty(possible_sub_header_list[i][0])) {
klass = ""; klass = "";
if (!options[possible_sub_header_list[i][0]]) { if (!options[possible_sub_header_list[i][0]]) {
...@@ -211,7 +211,6 @@ ...@@ -211,7 +211,6 @@
} }
} }
state.sub_header_list = sub_header_list; state.sub_header_list = sub_header_list;
*/
return this.changeState(state); return this.changeState(state);
}) })
...@@ -326,13 +325,13 @@ ...@@ -326,13 +325,13 @@
} }
// Handle sub header // Handle sub header
/*if (modification_dict.hasOwnProperty('sub_header_list')) { if (modification_dict.hasOwnProperty('sub_header_list')) {
promise_list.push(gadget.translateHtml(sub_header_template({ promise_list.push(gadget.translateHtml(sub_header_template({
sub_header_list: gadget.state.sub_header_list sub_header_list: gadget.state.sub_header_list
}))); })));
} else { } else {
promise_list.push(null); promise_list.push(null);
}*/ }
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.7953.26200.31897</string> </value> <value> <string>962.58905.50664.31180</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1493828249.21</float> <float>1509016469.74</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,16 +9,26 @@ ...@@ -9,16 +9,26 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'change') {
if (argument_list[0].options.page == "action") {
return this.getUrlFor({command: 'change', options: {page: "fif_action"}});
}
}
return this.getUrlFor.apply(this, argument_list);
})
.allowPublicAcquisition('updateHeader', function (argument_list) { .allowPublicAcquisition('updateHeader', function (argument_list) {
var header_dict = { var header_dict = {
page_title: "Data Set : " + this.state.document_title, page_title: "Data Set : " + this.state.document_title,
selection_url: argument_list[0].selection_url, selection_url: argument_list[0].selection_url,
next_url: argument_list[0].next_url, //next_url: argument_list[0].next_url,
previous_url: argument_list[0].previous_url //previous_url: argument_list[0].previous_url,
actions_url: argument_list[0].actions_url
}; };
return this.updateHeader(header_dict); return this.updateHeader(header_dict);
}) })
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.59500.56545.51490</string> </value> <value> <string>963.611.21138.12390</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1496921234.29</float> <float>1508943588.17</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -11,16 +11,26 @@ ...@@ -11,16 +11,26 @@
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'change') {
if (argument_list[0].options.page == "action") {
return this.getUrlFor({command: 'change', options: {page: "fif_action"}});
}
}
return this.getUrlFor.apply(this, argument_list);
})
.allowPublicAcquisition('updateHeader', function (argument_list) { .allowPublicAcquisition('updateHeader', function (argument_list) {
var header_dict = { var header_dict = {
page_title: "File : " + this.state.document_title, page_title: "File : " + this.state.document_title,
selection_url: argument_list[0].selection_url, selection_url: argument_list[0].selection_url,
next_url: argument_list[0].next_url, //next_url: argument_list[0].next_url,
previous_url: argument_list[0].previous_url //previous_url: argument_list[0].previous_url,
actions_url: argument_list[0].actions_url
}; };
return this.updateHeader(header_dict); return this.updateHeader(header_dict);
}) })
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.7937.48489.29388</string> </value> <value> <string>963.1824.9931.36795</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1493828434.2</float> <float>1509016348.15</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.6219.39657.8379</string> </value> <value> <string>962.62894.19831.57719</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>1493736238.56</float> <float>1508748673.85</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.44968.37293.31692</string> </value> <value> <string>962.62918.5842.5666</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1496049170.98</float> <float>1508749838.17</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="ui-content"> <div class="ui-content">
<ul data-role="listview" class="ui-listview" data-enhanced="true"> <ul data-role="listview" class="ui-listview" data-enhanced="true">
<li class="ui-first-child"><a href="#" class="ui-btn ui-btn-icon-left ui-icon-home" data-i18n="Home">Home</a></li> <li class="ui-first-child"><a href="#" class="ui-btn ui-btn-icon-left ui-icon-home" data-i18n="Home">Home</a></li>
<li class="ui-last-child"><a href="{{logout_href}}" class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Logout" accesskey="o">Logout</a></li> <li class="ui-last-child"><a href="{{logout_href}}" class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Logout">Logout</a></li>
</ul> </ul>
</div> </div>
</script> </script>
......
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1493713251.03</float> <float>1509011775.07</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Workflow-Transitions
data-i18n=Actions
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 FIF Page Action</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_fif_action.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c" data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-custom ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul data-role="listview" data-theme="c" data-inset="true" class="document-listview">
{{#each documentlist}}
<li><a data-i18n="{{title}}" class="ui-body-inherit" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
<div>MY ACTION GADGET!</div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, Handlebars, calculatePageTitle */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, calculatePageTitle) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this,
erp5_document,
result_list,
view_list,
action_list,
// XXX harcoded...
return_page = "data_set";
if (options.jio_key.indexOf("data_array") !== -1) {
return_page = "file_fif";
}
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) {
var i, i_len,
promise_list = [
gadget.getUrlFor({command: 'change', options: {page: return_page}})
];
erp5_document = result;
view_list = erp5_document._links.action_workflow || [];
action_list = []; // erp5_document._links.action_object_action
if (view_list.constructor !== Array) {
view_list = [view_list];
}
if (action_list.constructor !== Array) {
view_list = [view_list];
}
for (i = 0; i < view_list.length; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: view_list[i].href,
page: undefined
}
})
);
}
if (erp5_document._links.action_object_clone_action) {
action_list.push(erp5_document._links.action_object_clone_action);
}
for (i = 0, i_len = action_list.length; i < i_len; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: action_list[i].href,
page: undefined,
editable: true
}
})
);
}
return RSVP.all(promise_list);
})
.push(function (all_result) {
var i,
tab_list = [],
action_tab_list = [];
result_list = all_result;
for (i = 0; i < view_list.length; i += 1) {
// XXX harcoded...
if (view_list[i].title === "Invalidate") {
view_list[i].title = "Delete";
}
tab_list.push({
title: view_list[i].title,
link: all_result[i + 1],
i18n: view_list[i].title
});
}
for (i = 0; i < action_list.length; i += 1) {
action_tab_list.push({
title: action_list[i].title,
link: all_result[i + 1 + view_list.length],
i18n: action_list[i].title
});
}
var title = "Actions";
if (tab_list.length === 0) {
title = "No actions available";
}
return RSVP.all([
gadget.translateHtml(
table_template({
definition_title: title,
definition_icon: "random",
documentlist: tab_list,
definition_i18n: title
})
),
calculatePageTitle(gadget, erp5_document)
]);
})
.push(function (last_result_list) {
gadget.element.innerHTML = last_result_list[0];
return gadget.updateHeader({
back_url: result_list[0],
page_title: last_result_list[1]
});
});
});
}(window, rJS, RSVP, Handlebars, calculatePageTitle));
\ No newline at end of file
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") //.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.allowPublicAcquisition('updateHeader', function () { /*.allowPublicAcquisition('updateHeader', function () {
return; return;
}) })*/
.allowPublicAcquisition('getUrlFor', function (argument_list) { .allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'index') { if (argument_list[0].command === 'index') {
return this.getUrlFor({command: 'index', options: {jio_key: argument_list[0].options.jio_key, page: "data_set"}}); return this.getUrlFor({command: 'index', options: {jio_key: argument_list[0].options.jio_key, page: "data_set"}});
...@@ -31,16 +31,8 @@ ...@@ -31,16 +31,8 @@
}); });
}) })
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this, var gadget = this;
header_dict = { return gadget.getDeclaredGadget('form_list')
page_title: 'Modules',
filter_action: true
};
return gadget.updateHeader(header_dict)
.push(function () {
return gadget.getDeclaredGadget('form_list');
})
.push(function (form_gadget) { .push(function (form_gadget) {
var column_list = [ var column_list = [
['title', 'Title'], ['title', 'Title'],
...@@ -59,7 +51,7 @@ ...@@ -59,7 +51,7 @@
"key": "field_listbox", "key": "field_listbox",
"lines": 15, "lines": 15,
"list_method": "portal_catalog", "list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22Data+Set%22", "query": "urn:jio:allDocs?query=portal_type%3A%22Data+Set%22+AND+validation_state%3A%22validated%22",
"portal_type": [], "portal_type": [],
"search_column_list": column_list, "search_column_list": column_list,
"sort_column_list": column_list, "sort_column_list": column_list,
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.23980.29750.19575</string> </value> <value> <string>963.610.2969.24712</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1498722032.07</float> <float>1508943533.69</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
var column_list = [ var column_list = [
['title', 'Title'], ['title', 'Title'],
['reference', 'Reference'], ['reference', 'Reference'],
['version', 'version'] //['version', 'version'],
['validation_state', 'State']
]; ];
return form_gadget.render({ return form_gadget.render({
erp5_document: {"_embedded": {"_view": { erp5_document: {"_embedded": {"_view": {
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
"key": "field_listbox", "key": "field_listbox",
"lines": 15, "lines": 15,
"list_method": "portal_catalog", "list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22Data+Descriptor%22+AND+reference%3A%22%25" + dataset + "%25%22", "query": "urn:jio:allDocs?query=portal_type%3A%22Data+Array%22+AND+validation_state%3A%22validated%22+AND+reference%3A%22%25" + dataset + "%25%22",
"portal_type": [], "portal_type": [],
"search_column_list": column_list, "search_column_list": column_list,
"sort_column_list": column_list, "sort_column_list": column_list,
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.6439.28996.48401</string> </value> <value> <string>963.502.41707.13465</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1493827273.32</float> <float>1508943600.56</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, RSVP, URI, calculatePageTitle */
(function (window, rJS, RSVP, URI, calculatePageTitle) {
"use strict";
rJS(window)
.setState({
title: ""
})
/////////////////////////////////////////////////////////////////
// acquisition
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("displayFormulatorValidationError",
"displayFormulatorValidationError")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('triggerSubmit', function () {
this.element.querySelector('button').click();
})
.declareMethod('render', function (options) {
var isFifDataSite = options.erp5_document._links.self.href.indexOf("fif_data_runner") !== -1,
return_page;
// XXX hardcoded...
if (isFifDataSite) {
if (options.jio_key.indexOf("data_array") !== -1) {
return_page = "file_fif";
} else { return_page = "data_set"; }
}
if (options.form_definition.title === "Validate Workflow Action") {
options.form_definition.title = "Validate deletion";
}
var state_dict = {
id: options.jio_key,
view: options.view,
editable: options.editable,
erp5_document: options.erp5_document,
form_definition: options.form_definition,
erp5_form: options.erp5_form || {},
isFifDataSite: isFifDataSite,
return_page: return_page
};
return this.changeState(state_dict);
})
.onStateChange(function () {
var form_gadget = this,
icon,
selector = form_gadget.element.querySelector("h3"),
title,
i,
return_page = this.state.return_page,
view_list = this.state.erp5_document._links.action_workflow || [];
title = this.state.form_definition.title;
for (i = 0; i < view_list.length; i += 1) {
if (view_list[i].name === this.state.view) {
title = view_list[i].title;
}
}
// XXX hardcoded...
switch (form_gadget.state.title) {
case "Create User":
icon = " ui-icon-user";
break;
case "Create Document":
icon = " ui-icon-file-o";
break;
case "Change State":
icon = " ui-icon-share-alt";
break;
case "Submit":
icon = " ui-icon-check";
break;
default:
icon = " ui-icon-random";
break;
}
// Calculate the h3 properties
return form_gadget.translate(title)
.push(function (translated_title) {
selector.textContent = "\u00A0" + translated_title;
selector.className = "ui-content-title ui-body-c ui-icon ui-icon-custom" + icon;
// Render the erp5_from
return form_gadget.getDeclaredGadget("erp5_form");
})
.push(function (erp5_form) {
var form_options = form_gadget.state.erp5_form;
// <span class="ui-icon ui-icon-custom ui-icon-random">&nbsp;</span>
form_options.erp5_document = form_gadget.state.erp5_document;
form_options.form_definition = form_gadget.state.form_definition;
form_options.view = form_gadget.state.view;
return erp5_form.render(form_options);
})
.push(function () {
// Render the headers
return RSVP.all([
form_gadget.getUrlFor({command: 'change', options: {page: return_page, view: undefined}}),
calculatePageTitle(form_gadget, form_gadget.state.erp5_document)
]);
})
.push(function (all_result) {
return form_gadget.updateHeader({
cancel_url: all_result[0],
page_title: all_result[1],
submit_action: true
});
});
})
.onEvent('submit', function () {
var form_gadget = this,
action = this.state.erp5_document._embedded._view._actions.put,
form_id = this.state.erp5_document._embedded._view.form_id,
isFifDataSite = this.state.isFifDataSite,
redirect_to_parent;
return form_gadget.notifySubmitting()
.push(function () {
return form_gadget.getDeclaredGadget("erp5_form");
})
.push(function (erp5_form) {
return erp5_form.getContent();
})
.push(function (content_dict) {
var data = {},
key;
data[form_id.key] = form_id['default'];
// XXX Hardcoded
data.dialog_id = form_id['default'];
data.dialog_method = action.action;
//XXX hack for redirect, difined in form
redirect_to_parent = content_dict.field_your_redirect_to_parent;
for (key in content_dict) {
if (content_dict.hasOwnProperty(key)) {
data[key] = content_dict[key];
}
}
return form_gadget.jio_putAttachment(
form_gadget.state.id,
action.href,
data
);
})
.push(function (evt) {
var location = evt.target.getResponseHeader("X-Location"),
jio_key,
list = [],
message;
try {
message = JSON.parse(evt.target.response).portal_status_message;
} catch (ignore) {
}
list.push(form_gadget.notifySubmitted(message));
if (isFifDataSite) {
list.push(form_gadget.redirect({command: 'change', options: {page: "fifdata"}}));
}
else {
if (redirect_to_parent) {
list.push(form_gadget.redirect({command: 'history_previous'}));
} else {
if (location === undefined || location === null) {
// No redirection, stay on the same document
list.push(form_gadget.redirect({command: 'change', options: {view: "view", page: undefined, editable: form_gadget.state.editable}}));
} else {
jio_key = new URI(location).segment(2);
if (form_gadget.state.id === jio_key) {
// Do not update navigation history if dialog redirect to the same document
list.push(form_gadget.redirect({command: 'change', options: {jio_key: jio_key, view: "view", page: undefined, editable: form_gadget.state.editable}}));
} else {
list.push(form_gadget.redirect({command: 'push_history', options: {jio_key: jio_key, editable: form_gadget.state.editable}}));
}
}
}
}
return RSVP.all(list);
})
.push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 400)) {
return form_gadget.notifySubmitted()
.push(function () {
return form_gadget.translate('Input data has errors');
})
.push(function (message) {
return form_gadget.notifyChange(message + '.');
})
.push(function () {
return form_gadget.displayFormulatorValidationError(JSON.parse(error.target.responseText));
});
}
throw error;
});
}, false, true);
}(window, rJS, RSVP, URI, calculatePageTitle));
\ No newline at end of file
<?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>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</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>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</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_pt_form_dialog.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_pt_form_dialog_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>title</string> </key>
<value> <string>Gadget ERP5 Form Dialog JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1509008879.94</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.1736.17088.5205</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1509011695.92</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
...@@ -343,7 +343,9 @@ ...@@ -343,7 +343,9 @@
</item> </item>
<item> <item>
<key> <string>configuration_header_gadget_url</string> </key> <key> <string>configuration_header_gadget_url</string> </key>
<value> <string>fif_gadget_erp5_header.html</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>configuration_jio_gadget_url</string> </key> <key> <string>configuration_jio_gadget_url</string> </key>
...@@ -618,7 +620,7 @@ ...@@ -618,7 +620,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1496154474.05</float> <float>1508749049.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,4 +5,5 @@ web_site_module/fif_data_runner/** ...@@ -5,4 +5,5 @@ web_site_module/fif_data_runner/**
web_page_module/fif_* web_page_module/fif_*
web_page_module/gadget_fif_* web_page_module/gadget_fif_*
data_set_module/fake_dataset_for_UI_test data_set_module/fake_dataset_for_UI_test
data_descriptor_module/fake_descriptor_for_UI_test data_descriptor_module/fake_descriptor_for_UI_test
\ No newline at end of file web_page_module/rjs_gadget_erp5_pt_form_dialog_js
\ No newline at end of file
...@@ -5,4 +5,5 @@ web_site_module/fif_data_runner/** ...@@ -5,4 +5,5 @@ web_site_module/fif_data_runner/**
web_page_module/fif_* web_page_module/fif_*
web_page_module/gadget_fif_* web_page_module/gadget_fif_*
data_set_module/fake_dataset_for_UI_test data_set_module/fake_dataset_for_UI_test
data_descriptor_module/fake_descriptor_for_UI_test data_descriptor_module/fake_descriptor_for_UI_test
\ No newline at end of file web_page_module/rjs_gadget_erp5_pt_form_dialog_js
\ No newline at end of file
...@@ -6,5 +6,6 @@ portal_tests/telecom_renderjs_ui_zuite/* ...@@ -6,5 +6,6 @@ portal_tests/telecom_renderjs_ui_zuite/*
web_page_module/*fif_* web_page_module/*fif_*
web_page_module/fif_* web_page_module/fif_*
web_page_module/gadget_fif_* web_page_module/gadget_fif_*
web_page_module/rjs_gadget_erp5_pt_form_dialog_js
web_site_module/fif_data_runner web_site_module/fif_data_runner
web_site_module/fif_data_runner/** web_site_module/fif_data_runner/**
\ 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