From a07a1c71f6b4026038f8e5628b2baf3b182e012e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 19 Nov 2013 14:32:32 +0100 Subject: [PATCH] Review of email settings. --- .../_application_controller_table.js.coffee | 6 +- .../app/controllers/_channel/email.js.coffee | 133 ++++++++---------- .../app/views/channel/email_outbound.jst.eco | 2 +- 3 files changed, 66 insertions(+), 75 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee index 7e247a58f..161533fa1 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee @@ -84,7 +84,8 @@ class App.ControllerTable extends App.Controller # collect data of col. types dataTypesForCols = [] for row in overview - if attributes + + if !_.isEmpty(attributes) for attribute in attributes found = false if row is attribute.name @@ -102,7 +103,8 @@ class App.ControllerTable extends App.Controller else dataTypesForCols.push { name: row - link: true + type: 'link' + dataType: 'edit' } # extended table format diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index e133981f8..75e94cf4c 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -51,26 +51,23 @@ class App.ChannelEmailFilter extends App.Controller constructor: -> super - App.PostmasterFilter.bind 'refresh change', @render - App.PostmasterFilter.fetch() + App.PostmasterFilter.subscribe( @render, initFetch: true ) render: => - data = App.PostmasterFilter.all() + data = App.PostmasterFilter.search( sortBy: 'name' ) - html = $('
') + template = $( '
' + App.i18n.translateContent('New') + '
' ) new App.ControllerTable( - el: html, + el: template.find('.overview'), model: App.PostmasterFilter, objects: data, ) - - html.append( '' + App.i18n.translateContent('New') + '' ) - @html html + @html template new: (e) => e.preventDefault() - new App.ChannelEmailFilterEdit() + new App.ChannelEmailFilterEdit( {} ) edit: (e) => e.preventDefault() @@ -143,26 +140,24 @@ class App.ChannelEmailAddress extends App.Controller constructor: -> super - App.EmailAddress.bind 'refresh change', @render - App.EmailAddress.fetch() + App.EmailAddress.subscribe( @render, initFetch: true ) render: => - data = App.EmailAddress.all() + data = App.EmailAddress.search( sortBy: 'realname' ) - html = $('
') + template = $( '
' + App.i18n.translateContent('New') + '
' ) new App.ControllerTable( - el: html, - model: App.EmailAddress, - objects: data, + el: template.find('.overview') + model: App.EmailAddress + objects: data ) - html.append( '' + App.i18n.translateContent('New') + '' ) - @html html + @html template new: (e) => e.preventDefault() - new App.ChannelEmailAddressEdit() + new App.ChannelEmailAddressEdit( {} ) edit: (e) => e.preventDefault() @@ -180,10 +175,10 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal head: 'Email-Address' ) @form = new App.ControllerForm( - el: @el.find('#object_edit'), - model: App.EmailAddress, - params: @object, - autofocus: true, + el: @el.find('#object_edit') + model: App.EmailAddress + params: @object + autofocus: true ) else @html App.view('generic/admin/new')( @@ -233,26 +228,23 @@ class App.ChannelEmailSignature extends App.Controller constructor: -> super - App.Signature.bind 'refresh change', @render - App.Signature.fetch() + App.Signature.subscribe( @render, initFetch: true ) render: => - data = App.Signature.all() - - html = $('
') + data = App.Signature.search( sortBy: 'name' ) + template = $( '
' + App.i18n.translateContent('New') + '
' ) new App.ControllerTable( - el: html, - model: App.Signature, - objects: data, + el: template.find('.overview') + model: App.Signature + objects: data ) - html.append( '' + App.i18n.translateContent('New') + '' ) - @html html + @html template new: (e) => e.preventDefault() - new App.ChannelEmailSignatureEdit() + new App.ChannelEmailSignatureEdit( {} ) edit: (e) => e.preventDefault() @@ -270,19 +262,19 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal head: 'Signature' ) @form = new App.ControllerForm( - el: @el.find('#object_edit'), - model: App.Signature, - params: @object, - autofocus: true, + el: @el.find('#object_edit') + model: App.Signature + params: @object + autofocus: true ) else @html App.view('generic/admin/new')( head: 'Signature' ) @form = new App.ControllerForm( - el: @el.find('#object_new'), - model: App.Signature, - autofocus: true, + el: @el.find('#object_new') + model: App.Signature + autofocus: true ) @modalShow() @@ -323,8 +315,7 @@ class App.ChannelEmailInbound extends App.Controller constructor: -> super - App.Channel.bind 'refresh change', @render - App.Channel.fetch() + App.Channel.subscribe( @render, initFetch: true ) render: => channels = App.Channel.all() @@ -336,21 +327,20 @@ class App.ChannelEmailInbound extends App.Controller channel.user = channel.options['user'] data.push channel - html = $('
') + template = $( '
' + App.i18n.translateContent('New') + '
' ) new App.ControllerTable( - el: html, header: ['Host', 'User', 'Adapter', 'Active'], + el: template.find('.overview'), + header: ['Host', 'User', 'Adapter', 'Active'], overview: ['host', 'user', 'adapter', 'active'], model: App.Channel, objects: data, ) - - html.append( '' + App.i18n.translateContent('New') + '' ) - @html html + @html template new: (e) => e.preventDefault() - new App.ChannelEmailInboundEdit() + new App.ChannelEmailInboundEdit( {} ) edit: (e) => e.preventDefault() @@ -385,18 +375,18 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal head: 'Email Channel' ) @form = new App.ControllerForm( - el: @el.find('#object_edit'), - model: { configure_attributes: configure_attributes, className: '' }, - autofocus: true, + el: @el.find('#object_edit') + model: { configure_attributes: configure_attributes, className: '' } + autofocus: true ) else @html App.view('generic/admin/new')( head: 'Email Channel' ) @form = new App.ControllerForm( - el: @el.find('#object_new'), - model: { configure_attributes: configure_attributes, className: '' }, - autofocus: true, + el: @el.find('#object_new') + model: { configure_attributes: configure_attributes, className: '' } + autofocus: true ) @modalShow() @@ -408,17 +398,17 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal object = @object || new App.Channel object.load( - area: 'Email::Inbound', - adapter: params['adapter'], - group_id: params['group_id'], + area: 'Email::Inbound' + adapter: params['adapter'] + group_id: params['group_id'] options: { - host: params['host'], - user: params['user'], - password: params['password'], - ssl: params['ssl'], - folder: params['folder'], + host: params['host'] + user: params['user'] + password: params['password'] + ssl: params['ssl'] + folder: params['folder'] }, - active: params['active'], + active: params['active'] ) # validate form @@ -449,8 +439,7 @@ class App.ChannelEmailOutbound extends App.Controller constructor: -> super - App.Channel.bind 'refresh change', @render - App.Channel.fetch() + App.Channel.subscribe( @render, initFetch: true ) render: => @@ -504,11 +493,13 @@ class App.ChannelEmailOutbound extends App.Controller # get params params = @formParam(e.target) - # set selected adapter - @adapter_used = params['adapter'] - # render page with new selected adapter - @render() + if @adapter_used isnt params['adapter'] + + # set selected adapter + @adapter_used = params['adapter'] + + @render() update: (e) => e.preventDefault() @@ -537,5 +528,3 @@ class App.ChannelEmailOutbound extends App.Controller if channel.area is 'Email::Outbound' && channel.adapter isnt params['adapter'] channel.updateAttributes( active: false ) - # rerender page - @render() diff --git a/app/assets/javascripts/app/views/channel/email_outbound.jst.eco b/app/assets/javascripts/app/views/channel/email_outbound.jst.eco index 828d26c59..974700215 100644 --- a/app/assets/javascripts/app/views/channel/email_outbound.jst.eco +++ b/app/assets/javascripts/app/views/channel/email_outbound.jst.eco @@ -1,4 +1,4 @@ -
+