Commit 095256fd authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Add Attention Point Gadget

parent e59b06d5
.attention-point {
border: 1px solid #FF0004;
border-radius: 5%;
color: #FF0004;
padding: 5px;
margin: 5px;
}
.no-alert {
border: 1px solid #228B22;
border-radius: 5%;
color: #228B22;
padding: 5px;
margin: 5px;
}
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Style" 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>
</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>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_attention_point.css</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_attention_point_css</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 Style</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Attention Point CSS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<!--
data-i18n=Warnings
data-i18n=No Alert!
-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Information</title>
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<!-- custom script -->
<script src="gadget_erp5_attention_point.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="gadget_erp5_attention_point.css">
<script id="attention_point-item-template" type="text/x-handlebars-template">
{{#each option}}
<div class={{css_class}}>{{text}}</div>
{{/each}}
</script>
<script id="attention_point-template" type="text/x-handlebars-template">
<div class="ui-panel-inner">
<div data-role="header" role="banner" class="ui-header ui-bar-inherit">
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">
<div class="ui-controlgroup-controls">
<button data-rel="save" data-i18n="Submit" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left"></button>
</div>
</div>
<h1 class="ui-title" role="heading" data-i18n="Warnings" aria-level="1">Warnings</h1>
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">
<div class="ui-controlgroup-controls">
<button data-i18n="Close" data-rel="close" type="submit" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>
</div>
</div>
</div>
<section class="ui-body-c ui-content-section">
<div class="attention_point_item_container ui-controlgroup ui-corner_all"></div>
</section>
</div>
</script>
</head>
<body>
<form class="attention_point_editor">
<div class="container"></div>
</form>
</body>
</html>
\ No newline at end of file
<?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>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</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>
</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_attention_point.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_attention_point_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>title</string> </key>
<value> <string>Gadget Attention Point</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, RSVP, Handlebars*/
(function (window, document, rJS, RSVP, Handlebars) {
"use strict";
var gadget_klass = rJS(window),
template_element = gadget_klass.__template_element,
attention_point_item_template = Handlebars.compile(template_element
.getElementById("attention_point-item-template")
.innerHTML),
attention_point_template = Handlebars.compile(template_element
.getElementById("attention_point-template")
.innerHTML);
Handlebars.registerHelper('equal', function (left_value, right_value, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (left_value !== right_value) {
return options.inverse(this);
}
return options.fn(this);
});
function createAttentionPointTemplate(gadget, attention_point) {
return gadget.translateHtml(attention_point_item_template({
option: [{
text: attention_point[0],
css_class: attention_point[1]
}]
}));
}
gadget_klass
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("trigger", "trigger")
.onStateChange(function onStateChange() {
var gadget = this,
div = document.createElement("div"),
container = gadget.element.querySelector(".container");
return gadget.translateHtml(attention_point_template())
.push(function (translated_html) {
div.innerHTML = translated_html;
return RSVP.all(gadget.state.attention_point_list
.map(function (attention_point) {
return createAttentionPointTemplate(gadget, attention_point);
})
);
})
.push(function (result_list) {
var i,
subdiv,
attention_point_item_container = div.querySelector('.attention_point_item_container');
for (i = 0; i < result_list.length; i += 1) {
subdiv = document.createElement("div");
subdiv.innerHTML = result_list[i];
attention_point_item_container.appendChild(subdiv);
}
while (container.firstChild) {
container.removeChild(container.firstChild);
}
container.appendChild(div);
});
})
.declareMethod('render', function render(options) {
return this.changeState({
attention_point_list: options.attention_point_list || [],
key: options.key
});
})
.onEvent('click', function click(evt) {
if (evt.target.classList.contains('close')) {
evt.preventDefault();
return this.trigger();
}
}, false, false)
.onEvent('submit', function submit() {
var gadget = this,
sort_list = gadget.element.querySelectorAll(".attention_point_item_container"),
sort_query = [],
select_list,
sort_item,
options = {},
i;
for (i = 0; i < sort_list.length; i += 1) {
sort_item = sort_list[i];
select_list = sort_item.querySelectorAll("select");
sort_query[i] = [select_list[0][select_list[0].selectedIndex].value,
select_list[1][select_list[1].selectedIndex].value];
}
if (i === 0) {
options[gadget.state.key] = undefined;
} else {
options[gadget.state.key] = sort_query;
}
return gadget.redirect({
command: 'store_and_change',
options: options
});
});
}(window, document, rJS, RSVP, Handlebars));
\ 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>
</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>
</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_attention_point.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_attention_point_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 Attention Point JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -117,6 +118,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_computer"}}),
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.38797.10404.27528</string> </value>
<value> <string>974.61498.11899.44253</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1545935797.99</float>
<float>1554901061.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,6 +10,7 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
......@@ -82,6 +83,9 @@
doc: gadget.state.doc,
editable: gadget.state.editable
});
})
.push(function () {
return gadget.updatePanel({jio_key: gadget.state.jio_key});
});
});
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.64854.62654.27545</string> </value>
<value> <string>972.32024.53732.34406</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1516644220.55</float>
<float>1554855524.15</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -148,6 +149,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "accounting_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slapos"}})
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.32024.53732.34406</string> </value>
<value> <string>974.61498.36227.27835</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1552960106.68</float>
<float>1554901051.44</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -110,6 +111,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_network_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_network"}}),
......
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.38848.17221.24388</string> </value>
<value> <string>974.61513.15083.40157</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1545936199.72</float>
<float>1554901041.21</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -121,6 +122,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "project_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_project"}}),
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.29228.49487.5973</string> </value>
<value> <string>974.61500.28585.34065</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1554315644.91</float>
<float>1554901016.21</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -111,6 +112,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "hosting_subscription_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_select_software_product"}}),
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superrafael</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.50694.51828.32204</string> </value>
<value> <string>974.61501.898.16708</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1554254296.08</float>
<float>1554900916.8</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -120,6 +121,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "organisation_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_organisation"}}),
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superrafael</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.29228.49487.5973</string> </value>
<value> <string>974.61497.27931.35481</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1554317319.46</float>
<float>1554900905.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -84,6 +85,11 @@
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "support_request_module"
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_ticket"}}),
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.32073.19438.59528</string> </value>
<value> <string>974.61510.55768.19899</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1522772191.41</float>
<float>1554901834.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,6 +21,7 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("updateHeader", "updateHeader")
......@@ -229,6 +230,11 @@
});
});
})
.push(function () {
return gadget.updatePanel({
jio_key: false
});
})
.push(function () {
return gadget.updateHeader({
page_title: 'Dashboard'
......
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superrafael</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.51826.62399.12902</string> </value>
<value> <string>974.61525.54996.33297</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1554320110.18</float>
<float>1554901947.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -379,6 +379,9 @@ gadget_erp5_panel_shortcut.html\n
gadget_erp5_panel_shortcut.js\n
gadget_erp5_pt_form_slapos_index.html\n
gadget_erp5_pt_form_slapos_index.js\n
gadget_erp5_attention_point.html\n
gadget_erp5_attention_point.css\n
gadget_erp5_attention_point.js\n
gadget_slapos_computer_map.html\n
gadget_slapos_computer_map.js\n
gadget_slapos_computer_status.css\n
......@@ -555,7 +558,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.38681.356.33024</string> </value>
<value> <string>974.29171.1584.24746</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -573,7 +576,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1552960501.44</float>
<float>1554923957.36</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -24,6 +24,9 @@
</div>
</script>
<script id="panel-template-warning-link" type="text/x-handlebars-template">
<li><a href="#" id="attention-point-link" class="ui-btn-icon-notext ui-icon-warning attention-point-link">Warnings ({{amount}})</a></li>
</script>
<script id="panel-template-body" type="text/x-handlebars-template">
<div class="ui-content">
<ul data-role="listview" class="ui-listview" data-enhanced="true">
......@@ -47,6 +50,10 @@
<div data-gadget-url="gadget_erp5_panel_shortcut.html"
data-gadget-scope="erp5_panel_shortcut"
data-gadget-sandbox="public"></div>
<dl></dl>
<ul data-role="listview" class="ui-listview ul-attention-point" data-enhanced="true">
<li></li>
</ul>
</div>
</script>
<!-- custom script -->
......
......@@ -220,7 +220,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.45193.17797.6212</string> </value>
<value> <string>974.61786.203.13243</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1519396467.53</float>
<float>1554918794.64</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -14,6 +14,9 @@
.innerHTML),
panel_template_body = Handlebars.compile(template_element
.getElementById("panel-template-body")
.innerHTML),
panel_template_warning_link = Handlebars.compile(template_element
.getElementById("panel-template-warning-link")
.innerHTML);
gadget_klass
......@@ -25,7 +28,10 @@
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("renderEditorPanel", "renderEditorPanel")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
......@@ -44,28 +50,10 @@
})
.declareMethod('render', function (options) {
var erp5_document = options.erp5_document,
workflow_list,
view_list;
if (erp5_document !== undefined) {
workflow_list = erp5_document._links.action_workflow || [];
view_list = erp5_document._links.action_object_view || [];
if (workflow_list.constructor !== Array) {
workflow_list = [workflow_list];
}
if (view_list.constructor !== Array) {
view_list = [view_list];
}
// Prevent has much as possible to modify the DOM panel
// stateChange prefer to compare strings
workflow_list = JSON.stringify(workflow_list);
view_list = JSON.stringify(view_list);
}
return this.changeState({
workflow_list: workflow_list,
view_list: view_list,
global: true,
editable: options.editable
editable: true,
jio_key: options.jio_key
});
})
......@@ -73,6 +61,7 @@
var context = this,
gadget = this,
queue = new RSVP.Queue(),
jio_key = modification_dict.jio_key,
tmp_element;
if (modification_dict.hasOwnProperty("visible")) {
......@@ -139,70 +128,12 @@
return context.listenResize();
});
}
if ((this.state.global === true) &&
(modification_dict.hasOwnProperty("desktop") ||
modification_dict.hasOwnProperty("editable") ||
modification_dict.hasOwnProperty("workflow_list") ||
modification_dict.hasOwnProperty("view_list"))) {
if (!(this.state.desktop && (this.state.view_list !== undefined))) {
// Check for Alerts to pop
if (!(jio_key === undefined || jio_key === null)) {
queue
.push(function () {
gadget.element.querySelector("dl").textContent = '';
return context.calculateMyAttentionPointList(jio_key, false);
});
} else {
queue
.push(function () {
var i = 0,
promise_list = [],
workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list);
for (i = 0; i < workflow_list.length; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: workflow_list[i].href,
page: undefined
}
})
);
}
for (i = 0; i < view_list.length; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: view_list[i].href,
page: undefined
}
})
);
}
return RSVP.all(promise_list);
})
.push(function (result_list) {
var i,
result_workflow_list = [],
result_view_list = [],
workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list);
for (i = 0; i < workflow_list.length; i += 1) {
result_workflow_list.push({
title: workflow_list[i].title,
href: result_list[i]
});
}
for (i = 0; i < view_list.length; i += 1) {
result_view_list.push({
title: view_list[i].title,
href: result_list[i + workflow_list.length]
});
}
});
}
}
return queue;
......@@ -216,6 +147,10 @@
(evt.target.tagName === 'BUTTON')) {
return this.toggle();
}
if (this.element.querySelector('a[id="attention-point-link"]') === evt.target) {
evt.preventDefault();
return this.calculateMyAttentionPointList(this.state.jio_key, true);
}
}, false, false)
.declareJob('listenResize', function () {
......@@ -246,34 +181,52 @@
// Typing a search query should not modify the header status
return;
})
.onEvent('submit', function () {
var gadget = this;
return gadget.getDeclaredGadget("erp5_searchfield")
.push(function (search_gadget) {
return search_gadget.getContent();
.declareJob("calculateMyAttentionPointList", function (jio_key, force_open) {
var context = this,
queue = new RSVP.Queue(),
attention_point_ul = document.querySelector('ul.ul-attention-point'),
seen_attention_point_dict = JSON.parse(window.sessionStorage.getItem('seen_attention_point_dict') || "{}");
return queue
.push(function () {
return context.getSetting('hateoas_url');
})
.push(function (data) {
var options = {
page: "search"
};
if (data.search) {
options.extended_search = data.search;
.push(function (hateoas_url) {
if (jio_key === false || jio_key === undefined || jio_key === null) {
return [[], 'No Alert'];
}
// Remove focus from the search field
document.activeElement.blur();
return gadget.redirect({command: 'display', options: options});
return RSVP.all([context.jio_getAttachment(
jio_key,
hateoas_url + jio_key + '/Base_getAttentionPointList'
),
context.translate('No Alert!')
]);
})
.push(function (result_list) {
var attention_point_list = result_list[0],
no_alert_caption = result_list[1];
if (attention_point_list.length > 0) {
if (!Boolean(document.querySelector('#attention-point-link'))) {
attention_point_ul.innerHTML = panel_template_warning_link({
amount: attention_point_list.length
});
}, false, true)
.onEvent('blur', function (evt) {
// XXX Horrible hack to clear the search when focus is lost
// This does not follow renderJS design, as a gadget should not touch
// another gadget content
if (evt.target.type === 'search') {
evt.target.value = "";
}
}, true, false);
if (force_open || (JSON.stringify(seen_attention_point_dict[jio_key]) != JSON.stringify(attention_point_list))) {
seen_attention_point_dict[jio_key] = attention_point_list;
window.sessionStorage.setItem('seen_attention_point_dict', JSON.stringify(seen_attention_point_dict));
return context.renderEditorPanel("gadget_erp5_attention_point.html", {
attention_point_list: attention_point_list
});
}
} else {
attention_point_ul.innerHTML = "<li></li>";
if (force_open) {
return context.renderEditorPanel("gadget_erp5_attention_point.html", {
attention_point_list: [[no_alert_caption, 'no-alert']]
});
}
}
});
});
}(window, document, rJS, Handlebars, RSVP, Node, loopEventListener));
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.41526.6603.40089</string> </value>
<value> <string>974.61794.16321.5393</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1522944680.15</float>
<float>1554920653.43</float>
<string>UTC</string>
</tuple>
</state>
......
<?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>Base_getAttentionPointList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
image_module/gadget_slapos_panel_png
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_html
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_js
web_page_module/rjs_gadget_erp5_attention_point_css
web_page_module/rjs_gadget_erp5_attention_point_html
web_page_module/rjs_gadget_erp5_attention_point_js
web_page_module/rjs_gadget_erp5_page_map_css
web_page_module/rjs_gadget_erp5_page_map_html
web_page_module/rjs_gadget_erp5_page_map_js
......
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