Review of email settings.

This commit is contained in:
Martin Edenhofer 2013-11-19 14:32:32 +01:00
parent 71c26e16ec
commit a07a1c71f6
3 changed files with 66 additions and 75 deletions

View file

@ -84,7 +84,8 @@ class App.ControllerTable extends App.Controller
# collect data of col. types # collect data of col. types
dataTypesForCols = [] dataTypesForCols = []
for row in overview for row in overview
if attributes
if !_.isEmpty(attributes)
for attribute in attributes for attribute in attributes
found = false found = false
if row is attribute.name if row is attribute.name
@ -102,7 +103,8 @@ class App.ControllerTable extends App.Controller
else else
dataTypesForCols.push { dataTypesForCols.push {
name: row name: row
link: true type: 'link'
dataType: 'edit'
} }
# extended table format # extended table format

View file

@ -51,26 +51,23 @@ class App.ChannelEmailFilter extends App.Controller
constructor: -> constructor: ->
super super
App.PostmasterFilter.bind 'refresh change', @render App.PostmasterFilter.subscribe( @render, initFetch: true )
App.PostmasterFilter.fetch()
render: => render: =>
data = App.PostmasterFilter.all() data = App.PostmasterFilter.search( sortBy: 'name' )
html = $('<div></div>') template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
new App.ControllerTable( new App.ControllerTable(
el: html, el: template.find('.overview'),
model: App.PostmasterFilter, model: App.PostmasterFilter,
objects: data, objects: data,
) )
@html template
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
@html html
new: (e) => new: (e) =>
e.preventDefault() e.preventDefault()
new App.ChannelEmailFilterEdit() new App.ChannelEmailFilterEdit( {} )
edit: (e) => edit: (e) =>
e.preventDefault() e.preventDefault()
@ -143,26 +140,24 @@ class App.ChannelEmailAddress extends App.Controller
constructor: -> constructor: ->
super super
App.EmailAddress.bind 'refresh change', @render App.EmailAddress.subscribe( @render, initFetch: true )
App.EmailAddress.fetch()
render: => render: =>
data = App.EmailAddress.all() data = App.EmailAddress.search( sortBy: 'realname' )
html = $('<div></div>') template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
new App.ControllerTable( new App.ControllerTable(
el: html, el: template.find('.overview')
model: App.EmailAddress, model: App.EmailAddress
objects: data, objects: data
) )
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' ) @html template
@html html
new: (e) => new: (e) =>
e.preventDefault() e.preventDefault()
new App.ChannelEmailAddressEdit() new App.ChannelEmailAddressEdit( {} )
edit: (e) => edit: (e) =>
e.preventDefault() e.preventDefault()
@ -180,10 +175,10 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal
head: 'Email-Address' head: 'Email-Address'
) )
@form = new App.ControllerForm( @form = new App.ControllerForm(
el: @el.find('#object_edit'), el: @el.find('#object_edit')
model: App.EmailAddress, model: App.EmailAddress
params: @object, params: @object
autofocus: true, autofocus: true
) )
else else
@html App.view('generic/admin/new')( @html App.view('generic/admin/new')(
@ -233,26 +228,23 @@ class App.ChannelEmailSignature extends App.Controller
constructor: -> constructor: ->
super super
App.Signature.bind 'refresh change', @render App.Signature.subscribe( @render, initFetch: true )
App.Signature.fetch()
render: => render: =>
data = App.Signature.all() data = App.Signature.search( sortBy: 'name' )
html = $('<div></div>')
template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
new App.ControllerTable( new App.ControllerTable(
el: html, el: template.find('.overview')
model: App.Signature, model: App.Signature
objects: data, objects: data
) )
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' ) @html template
@html html
new: (e) => new: (e) =>
e.preventDefault() e.preventDefault()
new App.ChannelEmailSignatureEdit() new App.ChannelEmailSignatureEdit( {} )
edit: (e) => edit: (e) =>
e.preventDefault() e.preventDefault()
@ -270,19 +262,19 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
head: 'Signature' head: 'Signature'
) )
@form = new App.ControllerForm( @form = new App.ControllerForm(
el: @el.find('#object_edit'), el: @el.find('#object_edit')
model: App.Signature, model: App.Signature
params: @object, params: @object
autofocus: true, autofocus: true
) )
else else
@html App.view('generic/admin/new')( @html App.view('generic/admin/new')(
head: 'Signature' head: 'Signature'
) )
@form = new App.ControllerForm( @form = new App.ControllerForm(
el: @el.find('#object_new'), el: @el.find('#object_new')
model: App.Signature, model: App.Signature
autofocus: true, autofocus: true
) )
@modalShow() @modalShow()
@ -323,8 +315,7 @@ class App.ChannelEmailInbound extends App.Controller
constructor: -> constructor: ->
super super
App.Channel.bind 'refresh change', @render App.Channel.subscribe( @render, initFetch: true )
App.Channel.fetch()
render: => render: =>
channels = App.Channel.all() channels = App.Channel.all()
@ -336,21 +327,20 @@ class App.ChannelEmailInbound extends App.Controller
channel.user = channel.options['user'] channel.user = channel.options['user']
data.push channel data.push channel
html = $('<div></div>') template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
new App.ControllerTable( new App.ControllerTable(
el: html, header: ['Host', 'User', 'Adapter', 'Active'], el: template.find('.overview'),
header: ['Host', 'User', 'Adapter', 'Active'],
overview: ['host', 'user', 'adapter', 'active'], overview: ['host', 'user', 'adapter', 'active'],
model: App.Channel, model: App.Channel,
objects: data, objects: data,
) )
@html template
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
@html html
new: (e) => new: (e) =>
e.preventDefault() e.preventDefault()
new App.ChannelEmailInboundEdit() new App.ChannelEmailInboundEdit( {} )
edit: (e) => edit: (e) =>
e.preventDefault() e.preventDefault()
@ -385,18 +375,18 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
head: 'Email Channel' head: 'Email Channel'
) )
@form = new App.ControllerForm( @form = new App.ControllerForm(
el: @el.find('#object_edit'), el: @el.find('#object_edit')
model: { configure_attributes: configure_attributes, className: '' }, model: { configure_attributes: configure_attributes, className: '' }
autofocus: true, autofocus: true
) )
else else
@html App.view('generic/admin/new')( @html App.view('generic/admin/new')(
head: 'Email Channel' head: 'Email Channel'
) )
@form = new App.ControllerForm( @form = new App.ControllerForm(
el: @el.find('#object_new'), el: @el.find('#object_new')
model: { configure_attributes: configure_attributes, className: '' }, model: { configure_attributes: configure_attributes, className: '' }
autofocus: true, autofocus: true
) )
@modalShow() @modalShow()
@ -408,17 +398,17 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
object = @object || new App.Channel object = @object || new App.Channel
object.load( object.load(
area: 'Email::Inbound', area: 'Email::Inbound'
adapter: params['adapter'], adapter: params['adapter']
group_id: params['group_id'], group_id: params['group_id']
options: { options: {
host: params['host'], host: params['host']
user: params['user'], user: params['user']
password: params['password'], password: params['password']
ssl: params['ssl'], ssl: params['ssl']
folder: params['folder'], folder: params['folder']
}, },
active: params['active'], active: params['active']
) )
# validate form # validate form
@ -449,8 +439,7 @@ class App.ChannelEmailOutbound extends App.Controller
constructor: -> constructor: ->
super super
App.Channel.bind 'refresh change', @render App.Channel.subscribe( @render, initFetch: true )
App.Channel.fetch()
render: => render: =>
@ -504,11 +493,13 @@ class App.ChannelEmailOutbound extends App.Controller
# get params # get params
params = @formParam(e.target) params = @formParam(e.target)
# set selected adapter
@adapter_used = params['adapter']
# render page with new selected adapter # render page with new selected adapter
@render() if @adapter_used isnt params['adapter']
# set selected adapter
@adapter_used = params['adapter']
@render()
update: (e) => update: (e) =>
e.preventDefault() e.preventDefault()
@ -537,5 +528,3 @@ class App.ChannelEmailOutbound extends App.Controller
if channel.area is 'Email::Outbound' && channel.adapter isnt params['adapter'] if channel.area is 'Email::Outbound' && channel.adapter isnt params['adapter']
channel.updateAttributes( active: false ) channel.updateAttributes( active: false )
# rerender page
@render()

View file

@ -1,4 +1,4 @@
<form class="form-horizontal" id="mail_adapter"> <form class="form-horizontal form-normal" id="mail_adapter">
<div id="form-email-adapter"></div> <div id="form-email-adapter"></div>
<div id="form-email-adapter-settings"></div> <div id="form-email-adapter-settings"></div>
<button data-type="" type="submit" class="btn"><%- @T( 'Submit' ) %></botton> <button data-type="" type="submit" class="btn"><%- @T( 'Submit' ) %></botton>