mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
WIP of Notifications system:
- Add actions for notification messages - Fix on message click handler - Implement appointment request actions for calendar notifications
This commit is contained in:
parent
c945b55cce
commit
479a557381
@ -1045,8 +1045,33 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
// popup notifiactions: set subject, different message (without separator) and (always) links
|
||||
$notification->set_popupsubject($subject);
|
||||
$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
|
||||
$notification->set_popuplinks(array($details['link_arr']));
|
||||
|
||||
if ($method =='REQUEST')
|
||||
{
|
||||
// Add ACCEPT|REHECT|TENTATIVE actions
|
||||
$notification->set_popupactions(array(
|
||||
array(
|
||||
'id' => 'A',
|
||||
'caption' => lang('Accept'),
|
||||
'icon' => 'accepted',
|
||||
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",['.$event['id'].','.$userid.','.'"A"'.']).sendRequest(true);'
|
||||
),
|
||||
array(
|
||||
'id' => 'R',
|
||||
'caption' => lang('Reject'),
|
||||
'icon' => 'rejected',
|
||||
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",['.$event['id'].','.$userid.','.'"R"'.']).sendRequest(true);'
|
||||
),
|
||||
array(
|
||||
'id' => 'T',
|
||||
'caption' => lang('Tentative'),
|
||||
'icon' => 'tentative',
|
||||
'onExecute' => 'egw().json("calendar.calendar_uiforms.ajax_status",['.$event['id'].','.$userid.','.'"T"'.']).sendRequest(true);'
|
||||
)
|
||||
));
|
||||
}
|
||||
$notification->set_popupmessage($response."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n");
|
||||
$notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar')));
|
||||
|
||||
if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
|
||||
$notification->send();
|
||||
|
@ -154,6 +154,12 @@ final class notifications {
|
||||
*/
|
||||
private $popup_links = array();
|
||||
|
||||
/**
|
||||
* array with objects of actions
|
||||
* @var array
|
||||
*/
|
||||
private $popup_actions = array();
|
||||
|
||||
/**
|
||||
* array with objects of attachments
|
||||
* @var array
|
||||
@ -315,6 +321,7 @@ final class notifications {
|
||||
public function set_popupmessage($_message) {
|
||||
//popup requires html
|
||||
if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
|
||||
if ($this->popup_actions) $_message .= '<div data-actions='. json_encode($this->popup_actions).'></div>';
|
||||
$this->message_popup = $_message;
|
||||
return true;
|
||||
}
|
||||
@ -343,7 +350,7 @@ final class notifications {
|
||||
$this->popup_links = array(); // clear array if set
|
||||
foreach($_links as $link) {
|
||||
if(is_array($link)) {
|
||||
$this->add_popuplink($link['text'], $link['view'], $link['popup']);
|
||||
$this->add_popuplink($link['text'], $link['view'], $link['popup'], $link['app']);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -376,12 +383,15 @@ final class notifications {
|
||||
* @param string $_text a descriptive text for the link
|
||||
* @param array $_view all params needed to view the link (name => value pairs)
|
||||
* @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
|
||||
* @param string $_app application name
|
||||
*/
|
||||
public function add_popuplink($_text, $_view, $_popup = false) {
|
||||
public function add_popuplink($_text, $_view, $_popup = false, $_app = '') {
|
||||
if(!$_view || !$_text) { return false; }
|
||||
$this->popup_links[] = (object)array( 'text' => $_text,
|
||||
$this->popup_links[] = (object)array(
|
||||
'text' => $_text,
|
||||
'view' => $_view,
|
||||
'popup' => $_popup,
|
||||
'app' => $_app
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@ -767,4 +777,32 @@ final class notifications {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add action button to popup message
|
||||
* @param array $_action
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function add_popupaction($_action) {
|
||||
if(!is_array($_action)) { return false; }
|
||||
$this->popup_actions[] = (object)$_action;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set popup actions
|
||||
*
|
||||
* @param array $_actions
|
||||
* @return boolean
|
||||
*/
|
||||
public function set_popupactions($_actions) {
|
||||
$this->popup_actions = array();
|
||||
foreach($_actions as $action) {
|
||||
if(is_array($action)) {
|
||||
$this->add_popupaction($action);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,21 @@
|
||||
}
|
||||
}
|
||||
).addClass('et2_link');
|
||||
if (notifymessages[show]['data'] && notifymessages[show]['data']['actions'])
|
||||
{
|
||||
var $actions_container = jQuery(document.createElement('div')).addClass('egwpopup_actions_container');
|
||||
for(var action in notifymessages[show].data.actions)
|
||||
{
|
||||
var func = new Function(notifymessages[show].data.actions[action].onExecute);
|
||||
jQuery(document.createElement('button'))
|
||||
.addClass('et2_button')
|
||||
.css({'background-image':'url('+egw.image(notifymessages[show].data.actions[action].icon,notifymessages[show].data.app)+')'})
|
||||
.text(notifymessages[show].data.actions[action].caption)
|
||||
.click(jQuery.proxy(func,this))
|
||||
.prependTo($actions_container);
|
||||
}
|
||||
$actions_container.prependTo($message);
|
||||
}
|
||||
$egwpopup_list.append($message);
|
||||
// bind click handler after the message container is attached
|
||||
$message.click(jQuery.proxy(this.clickOnMessage, this,[$message]));
|
||||
@ -131,7 +146,7 @@
|
||||
notifications.prototype.clickOnMessage = function (_node, _event){
|
||||
_event.stopPropagation();
|
||||
this.message_seen(_node, _event);
|
||||
if (_event.target.classList.contains('link')) return;
|
||||
if (_node[0][0] !=_event.target) return;
|
||||
var egwpopup_message = _node[0];
|
||||
var id = egwpopup_message[0].id.replace(/egwpopup_message_/ig,'');
|
||||
if (notifymessages[id]['data'])
|
||||
@ -293,12 +308,14 @@
|
||||
notifications.prototype.getData = function (_message) {
|
||||
var dom = jQuery(document.createElement('div')).html(_message);;
|
||||
var link = dom.find('div[data-id],div[data-url]');
|
||||
var actions = dom.find('div[data-actions]');
|
||||
var data = {
|
||||
message: dom.text(),
|
||||
title: link.text(),
|
||||
icon: link.find('img').attr('src')
|
||||
};
|
||||
jQuery.extend(data,link.data());
|
||||
if (actions.data()) jQuery.extend(data,actions.data());
|
||||
return typeof data == 'object'? data: {};
|
||||
};
|
||||
|
||||
|
@ -3568,6 +3568,21 @@ td.lettersearch {
|
||||
#egwpopup #egwpopup_list .egwpopup_message:hover {
|
||||
background-color: rgba(103, 159, 210, 0.2);
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container {
|
||||
border-bottom: 1px solid silver;
|
||||
padding-bottom: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container > button {
|
||||
height: 24px;
|
||||
width: 90px;
|
||||
border: none;
|
||||
background: #e6e6e6;
|
||||
background-size: 16px;
|
||||
background-position: 12px center;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 26px;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message_seen .egwpopup_mark {
|
||||
cursor: auto;
|
||||
background: none;
|
||||
|
@ -3557,6 +3557,21 @@ td.lettersearch {
|
||||
#egwpopup #egwpopup_list .egwpopup_message:hover {
|
||||
background-color: rgba(103, 159, 210, 0.2);
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container {
|
||||
border-bottom: 1px solid silver;
|
||||
padding-bottom: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container > button {
|
||||
height: 24px;
|
||||
width: 90px;
|
||||
border: none;
|
||||
background: #e6e6e6;
|
||||
background-size: 16px;
|
||||
background-position: 12px center;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 26px;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message_seen .egwpopup_mark {
|
||||
cursor: auto;
|
||||
background: none;
|
||||
|
@ -86,6 +86,21 @@
|
||||
&:hover {
|
||||
background-color: rgba(103, 159, 210, 0.2);
|
||||
}
|
||||
.egwpopup_actions_container {
|
||||
border-bottom: 1px solid silver;
|
||||
padding-bottom: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.egwpopup_actions_container>button {
|
||||
height: 24px;
|
||||
width: 90px;
|
||||
border: none;
|
||||
background: #e6e6e6;
|
||||
background-size: 16px;
|
||||
background-position: 12px center;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 26px;
|
||||
}
|
||||
}
|
||||
.egwpopup_message_seen {
|
||||
.egwpopup_mark {cursor: auto;background:none;border-color: #666c6e;}
|
||||
|
@ -3579,6 +3579,21 @@ td.lettersearch {
|
||||
#egwpopup #egwpopup_list .egwpopup_message:hover {
|
||||
background-color: rgba(103, 159, 210, 0.2);
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container {
|
||||
border-bottom: 1px solid silver;
|
||||
padding-bottom: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message .egwpopup_actions_container > button {
|
||||
height: 24px;
|
||||
width: 90px;
|
||||
border: none;
|
||||
background: #e6e6e6;
|
||||
background-size: 16px;
|
||||
background-position: 12px center;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 26px;
|
||||
}
|
||||
#egwpopup #egwpopup_list .egwpopup_message_seen .egwpopup_mark {
|
||||
cursor: auto;
|
||||
background: none;
|
||||
|
Loading…
Reference in New Issue
Block a user