Commit ce4f5956 authored by Roque's avatar Roque Committed by Roque

erp5_officejs: panel lists views and actions

- tests updated
parent 1fcd0227
......@@ -14,6 +14,7 @@
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("updatePanel", "updatePanel")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -26,6 +27,7 @@
jio_document,
portal_type,
parent_portal_type,
form_definition,
current_version,
index;
current_version = window.location.href.replace(window.location.hash, "");
......@@ -79,9 +81,11 @@
return gadget_util.getFormDefinition(portal_type, app_view);
})
.push(function (result) {
return result;
form_definition = result;
return gadget_util.getViewAndActionDict(portal_type,
options.jio_key);
})
.push(function (form_definition) {
.push(function (view_action_dict) {
return gadget.changeState({
jio_key: options.jio_key,
doc: jio_document,
......@@ -89,7 +93,8 @@
child_gadget_url: form_definition.child_gadget_url,
form_definition: form_definition,
form_type: form_definition.form_type,
view: options.view || app_view
view: options.view || app_view,
view_action_dict: view_action_dict
});
}, function (error) {
// jio not found error
......@@ -128,6 +133,11 @@
message: "Error rendering view",
status: "error"
});
})
.push(function () {
return gadget.updatePanel({
view_action_dict: gadget.state.view_action_dict
});
});
})
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.7618.39284.59767</string> </value>
<value> <string>979.53364.49548.7526</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1571070879.6</float>
<float>1573813846.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -22,6 +22,56 @@
.getElementById("panel-template-body-desktop")
.innerHTML);
function getElementList(gadget, element_list) {
var i = 0,
element_info_list = [],
url_for_parameter_list = [],
element_info,
key;
for (key in element_list) {
if (element_list.hasOwnProperty(key)) {
element_info = element_list[key];
url_for_parameter_list.push({ command: 'change',
options: element_info });
element_info_list[i] = { reference: element_info.reference,
title: element_info.title};
i += 1;
}
}
return gadget.getUrlForList(url_for_parameter_list)
.push(function (url_list) {
var action_list = [], j, element;
for (j = 0; j < url_list.length; j += 1) {
element = { href: url_list[j],
icon: null,
name: element_info_list[j].reference,
title: element_info_list[j].title };
action_list.push(element);
}
return action_list;
});
}
function appendDt(fragment, dt_title, dt_icon, action_list) {
var dt_element = document.createElement('dt'),
dd_element,
a_element,
i;
dt_element.textContent = dt_title;
dt_element.setAttribute('class', 'ui-btn-icon-left ui-icon-' + dt_icon);
fragment.appendChild(dt_element);
for (i = 0; i < action_list.length; i += 1) {
dd_element = document.createElement('dd');
dd_element.setAttribute('class', 'document-listview');
a_element = document.createElement('a');
a_element.setAttribute('class', action_list[i].class_name);
a_element.href = action_list[i].href;
a_element.textContent = action_list[i].title;
dd_element.appendChild(a_element);
fragment.appendChild(dd_element);
}
}
gadget_klass
.setState({
visible: false,
......@@ -35,6 +85,7 @@
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -75,6 +126,7 @@
workflow_list: workflow_list,
view_list: view_list,
global: true,
view_action_dict: options.view_action_dict || false,
editable: options.editable || editable || false
});
});
......@@ -124,7 +176,9 @@
.push(function () {
context.element.querySelector("div").appendChild(tmp_element);
return context.listenResize();
if (!modification_dict.view_action_dict) {
return context.listenResize();
}
});
}
......@@ -222,6 +276,34 @@
}
}
if (modification_dict.view_action_dict) {
queue
.push(function () {
return RSVP.all([
getElementList(gadget, modification_dict.view_action_dict.view_list),
getElementList(gadget, modification_dict.view_action_dict.action_list)
]);
})
.push(function (view_action_list) {
var dl_element,
dl_fragment = document.createDocumentFragment();
dl_element = gadget.element.querySelector("dl");
while (dl_element.firstChild) {
dl_element.removeChild(dl_element.firstChild);
}
if (view_action_list[0].length > 0) {
appendDt(dl_fragment, "VIEWS", 'eye',
view_action_list[0]);
dl_element.appendChild(dl_fragment);
}
if (view_action_list[1].length > 0) {
appendDt(dl_fragment, "ACTIONS", 'cogs',
view_action_list[1]);
dl_element.appendChild(dl_fragment);
}
});
}
return queue;
})
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.37259.50413.8226</string> </value>
<value> <string>979.60628.36308.55278</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>1538643425.79</float>
<float>1574249684.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -215,7 +215,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>vincent</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -229,7 +229,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.45561.47559.9591</string> </value>
<value> <string>979.53350.54566.5802</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -247,7 +247,7 @@
</tuple>
<state>
<tuple>
<float>1515509919.32</float>
<float>1573813812.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -127,6 +127,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Upload' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......@@ -189,6 +200,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Download' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......
......@@ -127,6 +127,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Upload' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......@@ -189,6 +200,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Download' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......
......@@ -127,6 +127,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Upload' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......@@ -189,6 +200,17 @@
<td>//a[@data-i18n='Actions']</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Download' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[@data-i18n='Actions']</td>
......
......@@ -196,6 +196,17 @@
<td>identifier=cke_1_contents</td>
<td></td>
</tr>
<!-- check panel actions -->
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dt[text()='ACTIONS']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_ojs_panel.html')]//dd//a[text()='Clone' and contains(@href, '#!change') and contains(@href, 'n.page=handle_action')]</td>
<td></td>
</tr>
<!-- Clone action -->
<tr>
<td>waitForElementPresent</td>
......
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