|
@@ -1,8 +1,3 @@
|
|
|
-$.fn.item = (genericObject) ->
|
|
|
- elementID = $(@).data('id')
|
|
|
- elementID or= $(@).parents('[data-id]').data('id')
|
|
|
- genericObject.find(elementID)
|
|
|
-
|
|
|
class App.ChannelEmail extends App.ControllerTabs
|
|
|
constructor: ->
|
|
|
super
|
|
@@ -46,7 +41,6 @@ class App.ChannelEmail extends App.ControllerTabs
|
|
|
class App.ChannelEmailFilter extends App.Controller
|
|
|
events:
|
|
|
'click [data-type=new]': 'new'
|
|
|
- 'click [data-type=edit]': 'edit'
|
|
|
|
|
|
constructor: ->
|
|
|
super
|
|
@@ -59,9 +53,12 @@ class App.ChannelEmailFilter extends App.Controller
|
|
|
template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
|
|
|
|
|
|
new App.ControllerTable(
|
|
|
- el: template.find('.overview'),
|
|
|
- model: App.PostmasterFilter,
|
|
|
- objects: data,
|
|
|
+ el: template.find('.overview')
|
|
|
+ model: App.PostmasterFilter
|
|
|
+ objects: data
|
|
|
+ bindRow:
|
|
|
+ events:
|
|
|
+ 'click': @edit
|
|
|
)
|
|
|
@html template
|
|
|
|
|
@@ -69,10 +66,9 @@ class App.ChannelEmailFilter extends App.Controller
|
|
|
e.preventDefault()
|
|
|
new App.ChannelEmailFilterEdit( {} )
|
|
|
|
|
|
- edit: (e) =>
|
|
|
+ edit: (id, e) =>
|
|
|
e.preventDefault()
|
|
|
- item = $(e.target).item( App.PostmasterFilter )
|
|
|
- new App.ChannelEmailFilterEdit( object: item )
|
|
|
+ new App.ChannelEmailFilterEdit( object: App.PostmasterFilter.find(id) )
|
|
|
|
|
|
class App.ChannelEmailFilterEdit extends App.ControllerModal
|
|
|
constructor: ->
|
|
@@ -135,7 +131,6 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
|
|
|
class App.ChannelEmailAddress extends App.Controller
|
|
|
events:
|
|
|
'click [data-type=new]': 'new'
|
|
|
- 'click [data-type=edit]': 'edit'
|
|
|
|
|
|
constructor: ->
|
|
|
super
|
|
@@ -151,6 +146,9 @@ class App.ChannelEmailAddress extends App.Controller
|
|
|
el: template.find('.overview')
|
|
|
model: App.EmailAddress
|
|
|
objects: data
|
|
|
+ bindRow:
|
|
|
+ events:
|
|
|
+ 'click': @edit
|
|
|
)
|
|
|
|
|
|
@html template
|
|
@@ -159,9 +157,9 @@ class App.ChannelEmailAddress extends App.Controller
|
|
|
e.preventDefault()
|
|
|
new App.ChannelEmailAddressEdit( {} )
|
|
|
|
|
|
- edit: (e) =>
|
|
|
+ edit: (id, e) =>
|
|
|
e.preventDefault()
|
|
|
- item = $(e.target).item( App.EmailAddress )
|
|
|
+ item = App.EmailAddress.find(id)
|
|
|
new App.ChannelEmailAddressEdit( object: item )
|
|
|
|
|
|
class App.ChannelEmailAddressEdit extends App.ControllerModal
|
|
@@ -223,7 +221,6 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal
|
|
|
class App.ChannelEmailSignature extends App.Controller
|
|
|
events:
|
|
|
'click [data-type=new]': 'new'
|
|
|
- 'click [data-type=edit]': 'edit'
|
|
|
|
|
|
constructor: ->
|
|
|
super
|
|
@@ -238,17 +235,19 @@ class App.ChannelEmailSignature extends App.Controller
|
|
|
el: template.find('.overview')
|
|
|
model: App.Signature
|
|
|
objects: data
|
|
|
+ bindRow:
|
|
|
+ events:
|
|
|
+ 'click': @edit
|
|
|
)
|
|
|
-
|
|
|
@html template
|
|
|
|
|
|
new: (e) =>
|
|
|
e.preventDefault()
|
|
|
new App.ChannelEmailSignatureEdit( {} )
|
|
|
|
|
|
- edit: (e) =>
|
|
|
+ edit: (id, e) =>
|
|
|
e.preventDefault()
|
|
|
- item = $(e.target).item( App.Signature )
|
|
|
+ item = App.Signature.find(id)
|
|
|
new App.ChannelEmailSignatureEdit( object: item )
|
|
|
|
|
|
class App.ChannelEmailSignatureEdit extends App.ControllerModal
|
|
@@ -310,31 +309,23 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
|
|
|
class App.ChannelEmailInbound extends App.Controller
|
|
|
events:
|
|
|
'click [data-type=new]': 'new'
|
|
|
- 'click [data-type=edit]': 'edit'
|
|
|
|
|
|
constructor: ->
|
|
|
super
|
|
|
-
|
|
|
App.Channel.subscribe( @render, initFetch: true )
|
|
|
|
|
|
render: =>
|
|
|
- channels = App.Channel.all()
|
|
|
-
|
|
|
- data = []
|
|
|
- for channel in channels
|
|
|
- if channel.area is 'Email::Inbound'
|
|
|
- channel.host = channel.options['host']
|
|
|
- channel.user = channel.options['user']
|
|
|
- data.push channel
|
|
|
+ channels = App.Channel.search( filter: { area: 'Email::Inbound' } )
|
|
|
|
|
|
template = $( '<div><div class="overview"></div><a data-type="new" class="btn btn-default">' + App.i18n.translateContent('New') + '</a></div>' )
|
|
|
|
|
|
new App.ControllerTable(
|
|
|
- el: template.find('.overview'),
|
|
|
- header: ['Host', 'User', 'Adapter', 'Active'],
|
|
|
- overview: ['host', 'user', 'adapter', 'active'],
|
|
|
- model: App.Channel,
|
|
|
- objects: data,
|
|
|
+ el: template.find('.overview')
|
|
|
+ model: App.Channel
|
|
|
+ objects: channels
|
|
|
+ bindRow:
|
|
|
+ events:
|
|
|
+ 'click': @edit
|
|
|
)
|
|
|
@html template
|
|
|
|
|
@@ -342,9 +333,9 @@ class App.ChannelEmailInbound extends App.Controller
|
|
|
e.preventDefault()
|
|
|
new App.ChannelEmailInboundEdit( {} )
|
|
|
|
|
|
- edit: (e) =>
|
|
|
+ edit: (id, e) =>
|
|
|
e.preventDefault()
|
|
|
- item = $(e.target).item( App.Channel )
|
|
|
+ item = App.Channel.find(id)
|
|
|
new App.ChannelEmailInboundEdit( object: item )
|
|
|
|
|
|
|
|
@@ -354,29 +345,13 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
|
|
@render(@object)
|
|
|
|
|
|
render: (data = {}) ->
|
|
|
-
|
|
|
- if !data['options']
|
|
|
- data['options'] = {}
|
|
|
- data['options']['ssl'] = true
|
|
|
- data['active'] = true
|
|
|
-
|
|
|
- configure_attributes = [
|
|
|
- { name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } , class: 'span4', default: data['adapter'] },
|
|
|
- { name: 'host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['host']) },
|
|
|
- { name: 'user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['user']) },
|
|
|
- { name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['password']) },
|
|
|
- { name: 'ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, class: 'span4', default: (data['options']&&data['options']['ssl']) },
|
|
|
- { name: 'folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, class: 'span4', autocapitalize: false, default: (data['options']&&data['options']['folder']) },
|
|
|
- { name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, filter: @edit_form, nulloption: false, relation: 'Group', class: 'span4', default: data['group_id'] },
|
|
|
- { name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , translate: true, class: 'span4', default: data['active'] },
|
|
|
- ]
|
|
|
if @object
|
|
|
@html App.view('generic/admin/edit')(
|
|
|
head: 'Email Channel'
|
|
|
)
|
|
|
@form = new App.ControllerForm(
|
|
|
el: @el.find('#object_edit')
|
|
|
- model: { configure_attributes: configure_attributes, className: '' }
|
|
|
+ model: App.Channel
|
|
|
autofocus: true
|
|
|
)
|
|
|
else
|
|
@@ -385,7 +360,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
|
|
)
|
|
|
@form = new App.ControllerForm(
|
|
|
el: @el.find('#object_new')
|
|
|
- model: { configure_attributes: configure_attributes, className: '' }
|
|
|
+ model: App.Channel
|
|
|
autofocus: true
|
|
|
)
|
|
|
@modalShow()
|
|
@@ -395,21 +370,10 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
|
|
|
|
|
# get params
|
|
|
params = @formParam(e.target)
|
|
|
+ params['area'] = 'Email::Inbound'
|
|
|
|
|
|
object = @object || new App.Channel
|
|
|
- object.load(
|
|
|
- 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']
|
|
|
- },
|
|
|
- active: params['active']
|
|
|
- )
|
|
|
+ object.load(params)
|
|
|
|
|
|
# validate form
|
|
|
errors = @form.validate( params )
|
|
@@ -463,7 +427,7 @@ class App.ChannelEmailOutbound extends App.Controller
|
|
|
channel_used = channel
|
|
|
|
|
|
configure_attributes = [
|
|
|
- { name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters , class: 'span4', default: adapter_used },
|
|
|
+ { name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters , default: adapter_used },
|
|
|
]
|
|
|
new App.ControllerForm(
|
|
|
el: @el.find('#form-email-adapter'),
|
|
@@ -476,10 +440,10 @@ class App.ChannelEmailOutbound extends App.Controller
|
|
|
|
|
|
if adapter_used is 'SMTP'
|
|
|
configure_attributes = [
|
|
|
- { name: 'host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, class: 'span4', autocapitalize: false, default: (channel_used['options']&&channel_used['options']['host']) },
|
|
|
- { name: 'user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, class: 'span4', autocapitalize: false, default: (channel_used['options']&&channel_used['options']['user']) },
|
|
|
- { name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, class: 'span4', autocapitalize: false, default: (channel_used['options']&&channel_used['options']['password']) },
|
|
|
- { name: 'ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , class: 'span4', translate: true, default: (channel_used['options']&&channel_used['options']['ssl']) },
|
|
|
+ { name: 'host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['host']) },
|
|
|
+ { name: 'user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['user']) },
|
|
|
+ { name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['password']) },
|
|
|
+ { name: 'ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , translate: true, default: (channel_used['options']&&channel_used['options']['ssl']) },
|
|
|
{ name: 'port', display: 'Port', tag: 'input', type: 'text', limit: 5, null: false, class: 'span1', autocapitalize: false, default: ((channel_used['options']&&channel_used['options']['port']) || 25) },
|
|
|
]
|
|
|
@form = new App.ControllerForm(
|