From 405be366479881864db17dbe6c87ed7a422ca709 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 8 Feb 2016 06:57:54 +0100 Subject: [PATCH] Improved shown information. --- .../controllers/_profile/notification.coffee | 74 +++++++------------ .../app/views/profile/notification.jst.eco | 2 +- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_profile/notification.coffee b/app/assets/javascripts/app/controllers/_profile/notification.coffee index 51588ee29..4169e3f7e 100644 --- a/app/assets/javascripts/app/controllers/_profile/notification.coffee +++ b/app/assets/javascripts/app/controllers/_profile/notification.coffee @@ -11,56 +11,37 @@ class Index extends App.Controller render: => # matrix - config = {} - config['matrix'] = {} - config['matrix']['create'] = {} - config['matrix']['create']['name'] = 'new Ticket' - config['matrix']['create']['criteria'] = {} - config['matrix']['create']['criteria']['owned_by_me'] = true - config['matrix']['create']['criteria']['owned_by_nobody'] = true - config['matrix']['create']['criteria']['no'] = false - config['matrix']['create']['channel'] = {} - config['matrix']['create']['channel']['email'] = true - config['matrix']['create']['channel']['online'] = false - config['matrix']['update'] = {} - config['matrix']['update']['name'] = 'Ticket update' - config['matrix']['update']['criteria'] = {} - config['matrix']['update']['criteria']['owned_by_me'] = true - config['matrix']['update']['criteria']['owned_by_nobody'] = false - config['matrix']['update']['criteria']['no'] = false - config['matrix']['update']['channel'] = {} - config['matrix']['update']['channel']['email'] = true - config['matrix']['update']['channel']['online'] = false - config['matrix']['move_into'] = {} - config['matrix']['move_into']['name'] = 'Ticket moved into my group' - config['matrix']['move_into']['criteria'] = {} - config['matrix']['move_into']['criteria']['owned_by_me'] = true - config['matrix']['move_into']['criteria']['owned_by_nobody'] = true - config['matrix']['move_into']['criteria']['no'] = false - config['matrix']['move_into']['channel'] = {} - config['matrix']['move_into']['channel']['email'] = true - config['matrix']['move_into']['channel']['online'] = false - config['matrix']['escalation'] = {} - config['matrix']['escalation']['name'] = 'Ticket escalation' - config['matrix']['escalation']['criteria'] = {} - config['matrix']['escalation']['criteria']['owned_by_me'] = true - config['matrix']['escalation']['criteria']['owned_by_nobody'] = true - config['matrix']['escalation']['criteria']['no'] = false - config['matrix']['escalation']['channel'] = {} - config['matrix']['escalation']['channel']['email'] = true - config['matrix']['escalation']['channel']['online'] = false + config = + group_ids: [] + matrix: + create: + name: 'new Ticket' + update: + name: 'Ticket update' + reminder_reached: + name: 'Ticket reminder reached' + escalation: + name: 'Ticket escalation' user_config = @Session.get('preferences').notification_config if user_config config = $.extend(true, {}, config, user_config) - console.log('oo', config) + # groups + user_group_config = true + if !user_config || !user_config['group_ids'] || _.isEmpty(user_config['group_ids']) || user_config['group_ids'][0] is '-' + user_group_config = false + groups = [] group_ids = @Session.get('group_ids') if group_ids for group_id in group_ids group = App.Group.find(group_id) groups.push group + if !user_group_config + if !config['group_ids'] + config['group_ids'] = [] + config['group_ids'].push group_id.toString() @html App.view('profile/notification')( groups: groups, config: config ) @@ -72,7 +53,6 @@ class Index extends App.Controller params.notification_config = {} form_params = @formParam(e.target) - console.log('P',form_params) for key, value of form_params if key is 'group_ids' if typeof value isnt 'object' @@ -110,8 +90,8 @@ class Index extends App.Controller email: true online: false } - console.log('P2',params) - + if !params.notification_config.group_ids || _.isEmpty(params.notification_config.group_ids) + params.notification_config.group_ids = ['-'] @formDisable(e) # get data @@ -127,12 +107,12 @@ class Index extends App.Controller success: (data, status, xhr) => App.User.full( - App.Session.get( 'id' ), + App.Session.get('id'), => - App.Event.trigger( 'ui:rerender' ) + App.Event.trigger('ui:rerender') @notify( type: 'success' - msg: App.i18n.translateContent( 'Successfully!' ) + msg: App.i18n.translateContent('Successfully!') ) , true @@ -140,10 +120,10 @@ class Index extends App.Controller error: (xhr, status, error) => @render() - data = JSON.parse( xhr.responseText ) + data = JSON.parse(xhr.responseText) @notify( type: 'error' - msg: App.i18n.translateContent( data.message ) + msg: App.i18n.translateContent(data.message) ) App.Config.set( 'Notifications', { prio: 2600, name: 'Notifications', parent: '#profile', target: '#profile/notifications', role: ['Agent'], controller: Index }, 'NavBarProfile' ) diff --git a/app/assets/javascripts/app/views/profile/notification.jst.eco b/app/assets/javascripts/app/views/profile/notification.jst.eco index d2db68717..158d6db69 100644 --- a/app/assets/javascripts/app/views/profile/notification.jst.eco +++ b/app/assets/javascripts/app/views/profile/notification.jst.eco @@ -31,7 +31,7 @@

<%- @T( 'Groups' ) %>

- + <%- @T('For "owned by nobody" and "no criteria" only notify about tickets in theres groups.') %>
<% if @groups: %>