Commit 06f4a2d4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Implement Contextual Help on the left panel

parent 241cacfd
...@@ -40,6 +40,16 @@ ...@@ -40,6 +40,16 @@
<script id="panel-template-warning-link" type="text/x-handlebars-template"> <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> <li><a href="#" id="attention-point-link" class="ui-btn-icon-notext ui-icon-warning attention-point-link">Warnings ({{amount}})</a></li>
</script> </script>
<script id="panel-template-contextual-help" type="text/x-handlebars-template">
<dt class="ui-btn-icon-left ui-icon-question" data-i18n="Help">Help</dt>
{{#each contextual_help_list}}
<dd class="document-listview">
<a class="help" target="_blank" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
</script>
<script id="panel-template-body" type="text/x-handlebars-template"> <script id="panel-template-body" type="text/x-handlebars-template">
<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">
...@@ -67,6 +77,8 @@ ...@@ -67,6 +77,8 @@
<ul data-role="listview" class="ui-listview ul-attention-point" data-enhanced="true"> <ul data-role="listview" class="ui-listview ul-attention-point" data-enhanced="true">
<li></li> <li></li>
</ul> </ul>
<dl class="dl-contextual-help">
</dl>
</div> </div>
</script> </script>
<!-- custom script --> <!-- custom script -->
......
...@@ -154,11 +154,13 @@ ...@@ -154,11 +154,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -202,17 +204,20 @@ ...@@ -202,17 +204,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -235,7 +240,7 @@ ...@@ -235,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.53553.60693.32631</string> </value> <value> <string>984.41750.3569.51541</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -253,7 +258,7 @@ ...@@ -253,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1581609475.31</float> <float>1592432119.42</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -262,17 +267,20 @@ ...@@ -262,17 +267,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -320,8 +328,9 @@ ...@@ -320,8 +328,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
.innerHTML), .innerHTML),
panel_template_warning_link = Handlebars.compile(template_element panel_template_warning_link = Handlebars.compile(template_element
.getElementById("panel-template-warning-link") .getElementById("panel-template-warning-link")
.innerHTML),
panel_template_contextual_help = Handlebars.compile(template_element
.getElementById("panel-template-contextual-help")
.innerHTML); .innerHTML);
gadget_klass gadget_klass
...@@ -38,18 +41,18 @@ ...@@ -38,18 +41,18 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod('toggle', function () { .declareMethod('toggle', function toggle() {
return this.changeState({ return this.changeState({
visible: !this.state.visible visible: !this.state.visible
}); });
}) })
.declareMethod('close', function () { .declareMethod('close', function close() {
return this.changeState({ return this.changeState({
visible: false visible: false
}); });
}) })
.declareMethod('render', function (options) { .declareMethod('render', function render(options) {
return this.changeState({ return this.changeState({
global: true, global: true,
editable: true, editable: true,
...@@ -131,6 +134,9 @@ ...@@ -131,6 +134,9 @@
// Check for Alerts to pop // Check for Alerts to pop
if (!(jio_key === undefined || jio_key === null)) { if (!(jio_key === undefined || jio_key === null)) {
queue queue
.push(function () {
return context.calculateContextualHelpList(jio_key);
})
.push(function () { .push(function () {
return context.calculateMyAttentionPointList(jio_key, false); return context.calculateMyAttentionPointList(jio_key, false);
}); });
...@@ -142,7 +148,7 @@ ...@@ -142,7 +148,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared services // declared services
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.onEvent('click', function (evt) { .onEvent('click', function click(evt) {
if ((evt.target.nodeType === Node.ELEMENT_NODE) && if ((evt.target.nodeType === Node.ELEMENT_NODE) &&
(evt.target.tagName === 'BUTTON')) { (evt.target.tagName === 'BUTTON')) {
return this.toggle(); return this.toggle();
...@@ -182,6 +188,33 @@ ...@@ -182,6 +188,33 @@
return; return;
}) })
.declareJob("calculateContextualHelpList", function (jio_key) {
var context = this,
queue = new RSVP.Queue(),
contextual_help_dl = document.querySelector('dl.dl-contextual-help');
return queue
.push(function () {
return context.getSetting('hateoas_url');
})
.push(function (hateoas_url) {
if (jio_key === false || jio_key === undefined || jio_key === null) {
return [];
}
return context.jio_getAttachment(
jio_key,
hateoas_url + jio_key + '/Base_getContextualHelpList'
);
})
.push(function (contextual_help_list) {
if (contextual_help_list.length > 0) {
if (!Boolean(document.querySelector('#contextual-help-link'))) {
contextual_help_dl.innerHTML = panel_template_contextual_help({
contextual_help_list: contextual_help_list
})
}
}
});
})
.declareJob("calculateMyAttentionPointList", function (jio_key, force_open) { .declareJob("calculateMyAttentionPointList", function (jio_key, force_open) {
var context = this, var context = this,
queue = new RSVP.Queue(), queue = new RSVP.Queue(),
......
...@@ -161,11 +161,13 @@ ...@@ -161,11 +161,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -209,17 +211,20 @@ ...@@ -209,17 +211,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -242,7 +247,7 @@ ...@@ -242,7 +247,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.61794.16321.5393</string> </value> <value> <string>984.41613.62401.26214</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +265,7 @@ ...@@ -260,7 +265,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1554920653.43</float> <float>1592426598.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -269,17 +274,20 @@ ...@@ -269,17 +274,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -327,8 +335,9 @@ ...@@ -327,8 +335,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
import json
contextual_help_list = []
#contextual_help_list.append(
# {"title": "XX", "href": "LLLL"}
#)
return json.dumps(contextual_help_list)
<?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_getContextualHelpList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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