Commit 347ede28 authored by Alain Takoudjou's avatar Alain Takoudjou

[slapos_jio] add menu to view all unread messages

List unread messages of user in a listbox, once user open the message it's marked as readed and will not be listed anymore.

Unread messages are show at home page, on top of Map gadget so the user will always see messages when he connect to the master.
parent c721d93e
<!DOCTYPE html>
<html>
<!--
data-i18n=Slapos
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Site List</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_slap_message_list.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_get", "jio_get")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, j, tmp, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("modification_date")) {
result.data.rows[i].value.modification_date = {
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": result.data.rows[i].value.modification_date,
key: "modification_date",
required: 0,
timezone_style: 0,
title: "Message Date",
type: "DateTimeField"
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
if (result.data.rows[i].value.hasOwnProperty("text_content")) {
if (result.data.rows[i].value.text_content &&
result.data.rows[i].value.text_content.length > 80) {
result.data.rows[i].value.text_content =
result.data.rows[i].value.text_content.slice(0, 80) + " ...";
}
}
}
return result;
});
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function (options) {
var gadget = this,
lines_limit;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting("listbox_lines_limit", 20),
gadget.getSetting("me")
]);
})
.push(function (setting) {
lines_limit = setting[0];
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.jio_get(setting[1])
]);
})
.push(function (result) {
var column_list = [
['title', 'Title'],
['modification_date', 'Date'],
['source_title', "From"],
['text_content', 'Message']
//['follow_up', 'Ticket']
];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_message_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%20%28%20" +
"%22" + "Web Message" + "%22%2C%20%22" + "Mail Message" +
"%22%29%20AND%20%28" + "default_destination_reference" +
"%3A" + result[1].reference + "%29%20AND%20%28" +
"simulation_state" + "%3A%20%28%22" + "started" +
"%22%2C%22" + "stopped" + "%22%29%29%20AND%20%28" +
"follow_up_portal_type" + "%3A%20%28%22" + "Support Request" +
"%22%2C%22" + "Upgrade Decision" + "%22%2C%22" +
"Regularisation Request" + "%22%29%29%20AND%20%28" +
"follow_up_simulation_state" + "%3A%20%28%22" +
"validated" + "%22%2C%22" + "suspended" + "%22%2C%22" +
"confirmed" + "%22%2C%22" + "started" + "%22%2C%22" +
"stopped" + "%22%2C%22" + "%22%29%29",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["modification_date", "Descending"]],
"title": "Messages",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_rss_ticket"}}),
gadget.getUrlFor({command: "change", options: {"page": "slapos"}}),
gadget.getUrlFor({command: "change", options: {"page": "slap_rss_critical_ticket"}})
]);
})
.push(function (result) {
return gadget.updateHeader({
page_title: "Messages",
filter_action: true,
selection_url: result[1],
rss_url: result[0],
critical_url: result[2]
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<!DOCTYPE html>
<html>
<!--
data-i18n=Slapos
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Message View</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_slap_message_view.js" type="text/javascript"></script>
</head>
<body>
<body>
</body>
</body>
</html>
/*global window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
// Open the ticket directly
return this.redirect({
"command": "change",
"options": {"jio_key": options.doc.follow_up}
});
});
}(window, rJS));
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.57488.48170.50312</string> </value>
<value> <string>972.8019.52352.28876</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1508424107.98</float>
<float>1544099821.24</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -49,9 +49,14 @@
.push(function (result) {
if (result.portal_type !== undefined) {
if (["Web Message", "Mail Message"]
.indexOf(result.portal_type) !== -1) {
child_gadget_url = 'gadget_erp5_page_slap_message_view.html';
} else {
child_gadget_url = 'gadget_erp5_page_slap_' +
result.portal_type.replace(/ /g, '_').toLowerCase() +
'_view.html';
}
} else {
throw new Error('Can not display document: ' + options.jio_key);
}
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.64854.62654.27545</string> </value>
<value> <string>972.24145.27625.63436</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1516644220.55</float>
<float>1545062511.01</float>
<string>UTC</string>
</tuple>
</state>
......
.box-gadget-left {
width: 49%;
float: left;
margin-bottom: 30px;
}
.box-gadget-right {
width: 49%;
float: right;
}
.box-gadget-bottom {
.box-gadget-top {
float: left;
width: 100%;
padding-top: 17px;
margin-bottom: 20px;
}
.ui-btn-white-front,
......
......@@ -74,6 +74,12 @@
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -245,7 +251,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.40300.60783.54357</string> </value>
<value> <string>972.24386.22001.41932</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -263,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1522775894.53</float>
<float>1545068727.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -20,7 +20,7 @@
<script id="ticket-link-control-template" type="text/x-handlebars-template">
<div class="slapos-control-front">
<center>
<a class="ui-btn ui-first-child ui-btn-white-front ui-btn-icon-left ui-icon-sort-alpha-asc" href={{ show_all_url }} data-i18n="Show All Tickets" > Show All Tickets</a>
<a class="ui-btn ui-first-child ui-btn-white-front ui-btn-icon-left ui-icon-sort-alpha-asc" href={{ show_all_url }} data-i18n="Show Tickets" > Show Tickets</a>
<a class="ui-btn ui-first-child ui-btn-white-front ui-btn-icon-left ui-icon-rss" href={{ rss_all_url }} data-i18n="RSS (all)" > RSS </a>
<a class="ui-btn ui-first-child ui-btn-white-front ui-btn-icon-left ui-icon-rss" href={{ rss_critical_url }} data-i18n="RSS Critical" > Critical </a>
</center>
......@@ -30,6 +30,10 @@
</head>
<body>
<form>
<div class="box-gadget-top">
<div data-gadget-url="gadget_erp5_pt_form_view.html"
data-gadget-scope="last"></div>
</div>
<div class="box-gadget-left">
<div class="map-gadget"></div>
</div>
......@@ -37,10 +41,6 @@
<div data-gadget-url="gadget_erp5_pt_form_view.html"
data-gadget-scope="right"></div>
</div>
<div class="box-gadget-bottom">
<div data-gadget-url="gadget_erp5_pt_form_view.html"
data-gadget-scope="last"></div>
</div>
</form>
</body>
</html>
\ No newline at end of file
......@@ -74,6 +74,12 @@
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -245,7 +251,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.40689.62566.35447</string> </value>
<value> <string>972.24383.44291.21572</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -263,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1522799337.96</float>
<float>1545068611.18</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -72,6 +72,13 @@
type: "DateTimeField"
};
}
if (result.data.rows[i].value.hasOwnProperty("text_content")) {
if (result.data.rows[i].value.text_content &&
result.data.rows[i].value.text_content.length > 80) {
result.data.rows[i].value.text_content =
result.data.rows[i].value.text_content.slice(0, 80) + " ...";
}
}
}
return result;
});
......@@ -169,8 +176,9 @@
var form_list = result[0],
column_list = [
['title', 'Title'],
['modification_date', 'Modification Date'],
['translated_simulation_state_title', 'State']
['modification_date', 'Date'],
['source_title', "From"],
['text_content', 'Message']
];
return form_list.render({
......@@ -200,13 +208,24 @@
"key": "slap_ticket_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%20%28%22Support%20Request%22%2C%20%22Upgrade%20Decision%22%2C%20%22Regularisation%20Request%22%29%20AND%20" +
"destination_decision_reference%3A" + gadget.me_dict.reference + "%20AND%20simulation_state%3A%20%28%22suspended%22%2C%20%22validated%22%2C%20%22confirmed%22%29",
"query": "urn:jio:allDocs?query=portal_type%3A%20%28%20" +
"%22" + "Web Message" + "%22%2C%20%22" + "Mail Message" +
"%22%29%20AND%20%28" + "default_destination_reference" +
"%3A" + gadget.me_dict.reference + "%29%20AND%20%28" +
"simulation_state" + "%3A%20%28%22" + "started" +
"%22%2C%22" + "stopped" + "%22%29%29%20AND%20%28" +
"follow_up_portal_type" + "%3A%20%28%22" + "Support Request" +
"%22%2C%22" + "Upgrade Decision" + "%22%2C%22" +
"Regularisation Request" + "%22%29%29%20AND%20%28" +
"follow_up_simulation_state" + "%3A%20%28%22" +
"validated" + "%22%2C%22" + "suspended" + "%22%2C%22" +
"confirmed" + "%22%2C%22" + "started" + "%22%2C%22" +
"stopped" + "%22%2C%22" + "%22%29%29",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["modification_date", "Descending"]],
"title": "Pending Tickets to Process",
"title": "Unread Messages",
"type": "ListBox"
}
}},
......
......@@ -74,6 +74,12 @@
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -241,7 +247,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.41526.6603.40089</string> </value>
<value> <string>972.24390.60760.64256</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +265,7 @@
</tuple>
<state>
<tuple>
<float>1522849395.6</float>
<float>1545068588.17</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n
# generated on Fri, 23 Nov 2018 12:00:00 GMT+0200\n
# generated on Fri, 17 Dec 2018 12:00:00 GMT+0200\n
CACHE:\n
favicon.ico\n
font-awesome/font-awesome-webfont.eot?v=4.6.3\n
......@@ -309,6 +309,10 @@ gadget_erp5_page_slap_invoice_list.html\n
gadget_erp5_page_slap_invoice_list.js\n
gadget_erp5_page_slap_load_schema.html\n
gadget_erp5_page_slap_load_schema.js\n
gadget_erp5_page_slap_message_list_html\n
gadget_erp5_page_slap_message_list_js\n
gadget_erp5_page_slap_message_view_html\n
gadget_erp5_page_slap_message_view_js\n
gadget_erp5_page_slap_network_list.html\n
gadget_erp5_page_slap_network_list.js\n
gadget_erp5_page_slap_organisation_view.html\n
......@@ -557,7 +561,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.7563.45762.64836</string> </value>
<value> <string>972.24295.54252.29815</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -575,7 +579,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1542984329.71</float>
<float>1545062887.64</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -29,6 +29,7 @@
<ul data-role="listview" class="ui-listview" data-enhanced="true">
<li class="ui-first-child"><a href="#?editable=true" class="ui-btn ui-btn-icon-left ui-icon-home" data-i18n="Home" accesskey="h">Home</a></li>
<li><a href="{{person_href}}" class="ui-btn ui-btn-icon-left ui-icon-user" data-i18n="Account" accesskey="p">Account</a></li>
<li><a href="{{message_href}}" class="ui-btn ui-btn-icon-left ui-icon-envelope" data-i18n="Unread Messages" accesskey="m">Unread Messages</a></li>
<li><a href="{{support_request_href}}" class="ui-btn ui-btn-icon-left ui-icon-comments" data-i18n="Tickets" accesskey="t">Tickets</a></li>
<li><a href="{{organisation_href}}" class="ui-btn ui-btn-icon-left ui-icon-map-marker" data-i18n="Sites" accesskey="k">Sites</a></li>
<li><a href="{{project_href}}" class="ui-btn ui-btn-icon-left ui-icon-cubes" data-i18n="Projects" accesskey="w">Projects</a></li>
......
......@@ -63,6 +63,12 @@
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -220,7 +226,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 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.45193.17797.6212</string> </value>
<value> <string>972.24319.2093.21845</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1519396467.53</float>
<float>1545068659.12</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -100,7 +100,8 @@
context.getUrlFor({command: 'display', options: {page: "slap_computer_list", editable: true}}),
context.getUrlFor({command: 'display', options: {page: "slap_network_list", editable: true}}),
context.getUrlFor({command: 'display', options: {page: "slap_project_list", editable: true}}),
context.getUrlFor({command: 'display', options: {page: "slap_person_view", editable: true}})
context.getUrlFor({command: 'display', options: {page: "slap_person_view", editable: true}}),
context.getUrlFor({command: 'display', options: {page: "slap_message_list", editable: true}})
]);
})
.push(function (result_list) {
......@@ -117,7 +118,8 @@
"computer_href": result_list[6],
"computer_network_href": result_list[7],
"project_href": result_list[8],
"person_href": result_list[9]
"person_href": result_list[9],
"message_href": result_list[10]
})
);
})
......
......@@ -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>969.30355.4749.17220</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1522944680.15</float>
<float>1544694357.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -101,6 +101,7 @@
<string>my_content_type</string>
<string>my_destination</string>
<string>my_start_date</string>
<string>deliver_message</string>
</list>
</value>
</item>
......
from DateTime import DateTime
if context.getSimulationState() in ("started", "stopped"):
context.deliver()
<?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>WebMessage_deliver</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
image_module/gadget_slapos_panel_png
web_page_module/gadget_erp5_page_slap_message_list_html
web_page_module/gadget_erp5_page_slap_message_list_js
web_page_module/gadget_erp5_page_slap_message_view_html
web_page_module/gadget_erp5_page_slap_message_view_js
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_page_map_css
......
image_module/gadget_slapos_panel_png
web_page_module/gadget_erp5_page_slap_message_list_html
web_page_module/gadget_erp5_page_slap_message_list_js
web_page_module/gadget_erp5_page_slap_message_view_html
web_page_module/gadget_erp5_page_slap_message_view_js
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_page_map_css
......
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