Improved table view and added check of name presence of objects.
This commit is contained in:
parent
cf6340a212
commit
d0a0ebdbc5
21 changed files with 94 additions and 48 deletions
|
@ -78,7 +78,7 @@ class App.Controller extends Spine.Controller
|
||||||
|
|
||||||
table: (data) ->
|
table: (data) ->
|
||||||
overview = data.overview || data.model.configure_overview || []
|
overview = data.overview || data.model.configure_overview || []
|
||||||
attributes = data.attributes || data.model.configure_attributes
|
attributes = data.attributes || data.model.configure_attributes || {}
|
||||||
header = data.header
|
header = data.header
|
||||||
|
|
||||||
# define normal header
|
# define normal header
|
||||||
|
@ -123,42 +123,18 @@ class App.Controller extends Spine.Controller
|
||||||
# check if info for each col. is already there
|
# check if info for each col. is already there
|
||||||
for row in dataTypesForCols
|
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
|
# execute callback on content
|
||||||
if row.callback
|
if row.callback
|
||||||
object[row.name]['name'] = row.callback( object[row.name]['name'] )
|
object[row.name] = row.callback( object[row.name] )
|
||||||
|
|
||||||
# lookup relation
|
# lookup relation
|
||||||
if !object[row.name]['name']
|
if !object[row.name]
|
||||||
rowWithoutId = row.name + '_id'
|
rowWithoutId = row.name + '_id'
|
||||||
for attribute in attributes
|
for attribute in attributes
|
||||||
if rowWithoutId is attribute.name
|
if rowWithoutId is attribute.name
|
||||||
if attribute.relation && App[attribute.relation]
|
if attribute.relation && App[attribute.relation]
|
||||||
record = App.Collection.find( attribute.relation, object[rowWithoutId] )
|
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
|
@log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', objects
|
||||||
table = App.view('generic/table')(
|
table = App.view('generic/table')(
|
||||||
|
|
|
@ -126,6 +126,9 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
|
||||||
@formValidate( form: e.target, errors: errors )
|
@formValidate( form: e.target, errors: errors )
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
# disable form
|
||||||
|
@formDisable(e)
|
||||||
|
|
||||||
# save object
|
# save object
|
||||||
object.save(
|
object.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
@ -215,6 +218,9 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal
|
||||||
@formValidate( form: e.target, errors: errors )
|
@formValidate( form: e.target, errors: errors )
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
# disable form
|
||||||
|
@formDisable(e)
|
||||||
|
|
||||||
# save object
|
# save object
|
||||||
object.save(
|
object.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
@ -304,6 +310,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
|
||||||
@formValidate( form: e.target, errors: errors )
|
@formValidate( form: e.target, errors: errors )
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
# disable form
|
||||||
|
@formDisable(e)
|
||||||
|
|
||||||
# save object
|
# save object
|
||||||
object.save(
|
object.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
@ -326,7 +335,7 @@ class App.ChannelEmailInbound extends App.Controller
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
channels = App.Channel.all()
|
channels = App.Channel.all()
|
||||||
|
@log 'llllll', channels
|
||||||
html = $('<div></div>')
|
html = $('<div></div>')
|
||||||
data = []
|
data = []
|
||||||
for channel in channels
|
for channel in channels
|
||||||
|
@ -334,6 +343,7 @@ class App.ChannelEmailInbound extends App.Controller
|
||||||
channel.host = channel.options['host']
|
channel.host = channel.options['host']
|
||||||
channel.user = channel.options['user']
|
channel.user = channel.options['user']
|
||||||
data.push channel
|
data.push channel
|
||||||
|
@log 'llllll222', data
|
||||||
|
|
||||||
table = @table(
|
table = @table(
|
||||||
header: ['Host', 'User', 'Adapter', 'Active'],
|
header: ['Host', 'User', 'Adapter', 'Active'],
|
||||||
|
@ -374,7 +384,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
||||||
]
|
]
|
||||||
if @object
|
if @object
|
||||||
@html App.view('generic/admin/edit')(
|
@html App.view('generic/admin/edit')(
|
||||||
head: 'Channel'
|
head: 'Email Channel'
|
||||||
)
|
)
|
||||||
@form = new App.ControllerForm(
|
@form = new App.ControllerForm(
|
||||||
el: @el.find('#object_edit'),
|
el: @el.find('#object_edit'),
|
||||||
|
@ -383,7 +393,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@html App.view('generic/admin/new')(
|
@html App.view('generic/admin/new')(
|
||||||
head: 'Channel'
|
head: 'Email Channel'
|
||||||
)
|
)
|
||||||
@form = new App.ControllerForm(
|
@form = new App.ControllerForm(
|
||||||
el: @el.find('#object_new'),
|
el: @el.find('#object_new'),
|
||||||
|
@ -409,6 +419,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
||||||
password: params['password'],
|
password: params['password'],
|
||||||
ssl: params['ssl'],
|
ssl: params['ssl'],
|
||||||
},
|
},
|
||||||
|
active: params['active'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# validate form
|
# validate form
|
||||||
|
@ -420,6 +431,9 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
|
||||||
@formValidate( form: e.target, errors: errors )
|
@formValidate( form: e.target, errors: errors )
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
# disable form
|
||||||
|
@formDisable(e)
|
||||||
|
|
||||||
# save object
|
# save object
|
||||||
object.save(
|
object.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
|
|
@ -13,16 +13,35 @@ class App.Model extends Spine.Model
|
||||||
return name
|
return name
|
||||||
return '???'
|
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 = {} ) ->
|
@validate: ( data = {} ) ->
|
||||||
return if !data['model'].configure_attributes
|
return if !data['model'].configure_attributes
|
||||||
|
|
||||||
|
# check attributes/each attribute of object
|
||||||
errors = {}
|
errors = {}
|
||||||
for attribute in data['model'].configure_attributes
|
for attribute in data['model'].configure_attributes
|
||||||
if !attribute.readonly
|
|
||||||
|
# only if attribute is not read only
|
||||||
# check required
|
if !attribute.readonly
|
||||||
if 'null' of attribute && !attribute[null] && !data['params'][attribute.name]
|
|
||||||
errors[attribute.name] = 'is required'
|
# 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
|
# check confirm password
|
||||||
if attribute.type is 'password' && data['params'][attribute.name] && "#{attribute.name}_confirm" of data['params']
|
if attribute.type is 'password' && data['params'][attribute.name] && "#{attribute.name}_confirm" of data['params']
|
||||||
|
|
|
@ -16,4 +16,5 @@ class App.Group extends App.Model
|
||||||
]
|
]
|
||||||
@configure_overview = [
|
@configure_overview = [
|
||||||
'name',
|
'name',
|
||||||
|
'active'
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,5 +10,7 @@ class App.Organization extends App.Model
|
||||||
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
|
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
|
||||||
]
|
]
|
||||||
@configure_overview = [
|
@configure_overview = [
|
||||||
'name', 'shared',
|
'name',
|
||||||
|
'shared',
|
||||||
|
'active',
|
||||||
]
|
]
|
||||||
|
|
|
@ -26,5 +26,5 @@ class App.User extends App.Model
|
||||||
]
|
]
|
||||||
@configure_overview = [
|
@configure_overview = [
|
||||||
# 'login', 'firstname', 'lastname', 'email', 'updated_at',
|
# 'login', 'firstname', 'lastname', 'email', 'updated_at',
|
||||||
'login', 'firstname', 'lastname'
|
'login', 'firstname', 'lastname', 'active',
|
||||||
]
|
]
|
||||||
|
|
|
@ -16,18 +16,24 @@
|
||||||
<% position = 0 %>
|
<% position = 0 %>
|
||||||
<% for object in @objects: %>
|
<% for object in @objects: %>
|
||||||
<% position++ %>
|
<% position++ %>
|
||||||
<tr class="item" data-id="<%= object.id %>" data-position="<%= position %>" >
|
<tr class="item <% if object.active is false: %>not-active<% end %>" data-id="<%= object.id %>" data-position="<%= position %>" >
|
||||||
<% if @checkbox: %>
|
<% if @checkbox: %>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" value="<%= object.id %>" name="bulk"/>
|
<input type="checkbox" value="<%= object.id %>" name="bulk"/>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% for row in @overview: %>
|
<% for row in @overview: %>
|
||||||
|
<% displayName = '' %>
|
||||||
|
<% if typeof object[row.name] is 'object': %>
|
||||||
|
<% displayName = object[row.name].displayNameLong() %>
|
||||||
|
<% else: %>
|
||||||
|
<% displayName = object[row.name] %>
|
||||||
|
<% end %>
|
||||||
<td>
|
<td>
|
||||||
<% if row.link: %>
|
<% if row.link: %>
|
||||||
<a href="#" data-type="edit"><%= object[row.name]['name'] %></a>
|
<a href="#" data-type="edit"><%= displayName %></a>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<span <% if row.class: %>class="<%= row.class %>"<% end %> <% if row.data && row.data.id: %>data-id="<%= object[row.name]['id'] %>"<% end %>><% if row.translate: %><%- T(object[row.name]['name']) %><% else if row.callback: %><%- object[row.name]['name'] %><% else: %><%= object[row.name]['name'] %><% end %></span>
|
<span <% if row.class: %>class="<%= row.class %>"<% end %> <% if row.data && row.data.id: %>data-id="<%= object[row.name].id %>"<% end %>><% if row.translate: %><%- T(displayName) %><% else if row.callback: %><%- displayName %><% else: %><%= displayName %><% end %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -239,6 +239,14 @@ footer {
|
||||||
text-decoration: line-through;
|
text-decoration: line-through;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.not-active {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
.not-active a {
|
||||||
|
color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.customer-info {
|
.customer-info {
|
||||||
width:86%;
|
width:86%;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
|
|
|
@ -251,7 +251,7 @@ class Channel::Twitter2
|
||||||
)
|
)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(attr, notification = false)
|
def send(attr, notification = false)
|
||||||
# logger.debug('tweeeeettttt!!!!!!')
|
# logger.debug('tweeeeettttt!!!!!!')
|
||||||
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
|
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
|
||||||
|
@ -272,7 +272,7 @@ class Channel::Twitter2
|
||||||
# puts dm.inspect
|
# puts dm.inspect
|
||||||
return dm
|
return dm
|
||||||
end
|
end
|
||||||
|
|
||||||
if atts[:type] == 'twitter status'
|
if atts[:type] == 'twitter status'
|
||||||
message = client.update(
|
message = client.update(
|
||||||
atts[:body].to_s,
|
atts[:body].to_s,
|
||||||
|
|
|
@ -3,4 +3,6 @@ class EmailAddress < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :realname, :presence => true
|
||||||
|
validates :email, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,4 +5,5 @@ class Group < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -173,7 +173,9 @@ class Link < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class Link::Type < ActiveRecord::Base
|
class Link::Type < ActiveRecord::Base
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class Link::Object < ActiveRecord::Base
|
class Link::Object < ActiveRecord::Base
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
class Organization < ApplicationModel
|
class Organization < ApplicationModel
|
||||||
has_and_belongs_to_many :users
|
has_and_belongs_to_many :users
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,5 @@ class Overview < ApplicationModel
|
||||||
store :order
|
store :order
|
||||||
store :meta
|
store :meta
|
||||||
store :view
|
store :view
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
|
@ -1,4 +1,5 @@
|
||||||
class PostmasterFilter < ApplicationModel
|
class PostmasterFilter < ApplicationModel
|
||||||
store :perform
|
store :perform
|
||||||
store :match
|
store :match
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,5 @@ class Role < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,5 @@ class Signature < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
|
||||||
class Store < ActiveRecord::Base
|
class Store < ActiveRecord::Base
|
||||||
store :preferences
|
store :preferences
|
||||||
belongs_to :store_object, :class_name => 'Store::Object'
|
belongs_to :store_object, :class_name => 'Store::Object'
|
||||||
belongs_to :store_file, :class_name => 'Store::File'
|
belongs_to :store_file, :class_name => 'Store::File'
|
||||||
|
validates :filename, :presence => true
|
||||||
|
|
||||||
def self.add(data)
|
def self.add(data)
|
||||||
data = data.stringify_keys
|
data = data.stringify_keys
|
||||||
|
|
||||||
|
@ -71,10 +72,12 @@ class Store < ActiveRecord::Base
|
||||||
|
|
||||||
|
|
||||||
class Object < ActiveRecord::Base
|
class Object < ActiveRecord::Base
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class File < ActiveRecord::Base
|
class File < ActiveRecord::Base
|
||||||
before_validation :add_md5
|
before_validation :add_md5
|
||||||
|
validates :name, :presence => true
|
||||||
|
|
||||||
private
|
private
|
||||||
def add_md5
|
def add_md5
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class Template < ApplicationModel
|
class Template < ApplicationModel
|
||||||
store :options
|
store :options
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
|
@ -403,12 +403,14 @@ class Ticket < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class StateType < ApplicationModel
|
class StateType < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class State < ApplicationModel
|
class State < ApplicationModel
|
||||||
|
@ -416,5 +418,6 @@ class Ticket < ApplicationModel
|
||||||
after_create :cache_delete
|
after_create :cache_delete
|
||||||
after_update :cache_delete
|
after_update :cache_delete
|
||||||
after_destroy :cache_delete
|
after_destroy :cache_delete
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -173,8 +173,11 @@ class Ticket::Article < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
class Sender < ApplicationModel
|
class Sender < ApplicationModel
|
||||||
|
validates :name, :presence => true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Type < ApplicationModel
|
class Type < ApplicationModel
|
||||||
|
validates :name, :presence => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue