diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 257aa6716..1c7916319 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -78,7 +78,7 @@ class App.Controller extends Spine.Controller table: (data) -> overview = data.overview || data.model.configure_overview || [] - attributes = data.attributes || data.model.configure_attributes + attributes = data.attributes || data.model.configure_attributes || {} header = data.header # define normal header @@ -123,42 +123,18 @@ class App.Controller extends Spine.Controller # check if info for each col. is already there for row in dataTypesForCols - # check if info is a object - if typeof object[row.name] is 'object' - if !object[row.name] - object[row.name] = { - name: '-', - } - - # if no content exists, try firstname/lastname - if !object[row.name]['name'] - if object[row.name]['realname'] - object[row.name]['name'] = object[row.name]['realname'] - - # if info isnt a object, create one - else if typeof object[row.name] isnt 'object' - object[row.name] = { - name: object[row.name], - } - - # fallback if it's something else - else - object[row.name] = { - name: '????', - } - # execute callback on content if row.callback - object[row.name]['name'] = row.callback( object[row.name]['name'] ) + object[row.name] = row.callback( object[row.name] ) # lookup relation - if !object[row.name]['name'] + if !object[row.name] rowWithoutId = row.name + '_id' for attribute in attributes if rowWithoutId is attribute.name if attribute.relation && App[attribute.relation] record = App.Collection.find( attribute.relation, object[rowWithoutId] ) - object[row.name]['name'] = record.name + object[row.name] = record.name @log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', objects table = App.view('generic/table')( diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index 8bda184ad..d0def8ed8 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -126,6 +126,9 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false + # disable form + @formDisable(e) + # save object object.save( success: => @@ -215,6 +218,9 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false + # disable form + @formDisable(e) + # save object object.save( success: => @@ -304,6 +310,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false + # disable form + @formDisable(e) + # save object object.save( success: => @@ -326,7 +335,7 @@ class App.ChannelEmailInbound extends App.Controller render: => channels = App.Channel.all() - + @log 'llllll', channels html = $('
') data = [] for channel in channels @@ -334,6 +343,7 @@ class App.ChannelEmailInbound extends App.Controller channel.host = channel.options['host'] channel.user = channel.options['user'] data.push channel + @log 'llllll222', data table = @table( header: ['Host', 'User', 'Adapter', 'Active'], @@ -374,7 +384,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal ] if @object @html App.view('generic/admin/edit')( - head: 'Channel' + head: 'Email Channel' ) @form = new App.ControllerForm( el: @el.find('#object_edit'), @@ -383,7 +393,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal ) else @html App.view('generic/admin/new')( - head: 'Channel' + head: 'Email Channel' ) @form = new App.ControllerForm( el: @el.find('#object_new'), @@ -409,6 +419,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal password: params['password'], ssl: params['ssl'], }, + active: params['active'], ) # validate form @@ -420,6 +431,9 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false + # disable form + @formDisable(e) + # save object object.save( success: => diff --git a/app/assets/javascripts/app/models/application_model.js.coffee b/app/assets/javascripts/app/models/application_model.js.coffee index c2db5ccb6..94aa6b0a5 100644 --- a/app/assets/javascripts/app/models/application_model.js.coffee +++ b/app/assets/javascripts/app/models/application_model.js.coffee @@ -13,16 +13,35 @@ class App.Model extends Spine.Model return name return '???' + displayNameLong: -> + return @name if @name + if @firstname + name = @firstname + if @lastname + if name + name = name + ' ' + name = name + @lastname + if @note + name = "#{name} (#{@note})" + return name + return '???' + @validate: ( data = {} ) -> return if !data['model'].configure_attributes + # check attributes/each attribute of object errors = {} for attribute in data['model'].configure_attributes - if !attribute.readonly - - # check required - if 'null' of attribute && !attribute[null] && !data['params'][attribute.name] - errors[attribute.name] = 'is required' + + # only if attribute is not read only + if !attribute.readonly + + # check required // if null is defined && null is false + if 'null' of attribute && !attribute[null] + + # key exists not in hash || value is '' || value is undefined + if !( attribute.name of data['params'] ) || data['params'][attribute.name] is '' || data['params'][attribute.name] is undefined + errors[attribute.name] = 'is required' # check confirm password if attribute.type is 'password' && data['params'][attribute.name] && "#{attribute.name}_confirm" of data['params'] diff --git a/app/assets/javascripts/app/models/group.js.coffee b/app/assets/javascripts/app/models/group.js.coffee index 9161cd447..305c4e091 100644 --- a/app/assets/javascripts/app/models/group.js.coffee +++ b/app/assets/javascripts/app/models/group.js.coffee @@ -16,4 +16,5 @@ class App.Group extends App.Model ] @configure_overview = [ 'name', + 'active' ] diff --git a/app/assets/javascripts/app/models/organization.js.coffee b/app/assets/javascripts/app/models/organization.js.coffee index 44d8f7673..426a8f82d 100644 --- a/app/assets/javascripts/app/models/organization.js.coffee +++ b/app/assets/javascripts/app/models/organization.js.coffee @@ -10,5 +10,7 @@ class App.Organization extends App.Model { name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' }, ] @configure_overview = [ - 'name', 'shared', + 'name', + 'shared', + 'active', ] diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 8f4dbca9f..d5d49744c 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -26,5 +26,5 @@ class App.User extends App.Model ] @configure_overview = [ # 'login', 'firstname', 'lastname', 'email', 'updated_at', - 'login', 'firstname', 'lastname' + 'login', 'firstname', 'lastname', 'active', ] diff --git a/app/assets/javascripts/app/views/generic/table.jst.eco b/app/assets/javascripts/app/views/generic/table.jst.eco index c50f3aa29..895b2f63c 100644 --- a/app/assets/javascripts/app/views/generic/table.jst.eco +++ b/app/assets/javascripts/app/views/generic/table.jst.eco @@ -16,18 +16,24 @@ <% position = 0 %> <% for object in @objects: %> <% position++ %> -