Moved to own active element in forms.

This commit is contained in:
Martin Edenhofer 2015-02-08 09:49:05 +01:00
parent 13685030d1
commit e66ef04332
21 changed files with 163 additions and 41 deletions

View file

@ -175,7 +175,7 @@ class App.ControllerForm extends App.Controller
###
formGenItem: (attribute_config, classname, form, attribute_count ) ->
attribute = clone( attribute_config )
attribute = clone( attribute_config, true )
# create item id
attribute.id = classname + '_' + attribute.name
@ -260,8 +260,8 @@ class App.ControllerForm extends App.Controller
# build options list
if _.isEmpty(attribute.options)
attribute.options = [
{ name: 'active', value: true }
{ name: 'inactive', value: false }
{ name: 'yes', value: true }
{ name: 'no', value: false }
]
# set data type
@ -276,6 +276,29 @@ class App.ControllerForm extends App.Controller
# return item
item = $( App.view('generic/select')( attribute: attribute ) )
else if attribute.tag is 'active'
# active attribute is always required
attribute.null = false
# build options list
attribute.options = [
{ name: 'active', value: true }
{ name: 'inactive', value: false }
]
# set data type
if attribute.name
attribute.name = '{boolean}' + attribute.name
# finde selected item of list
for record in attribute.options
if record.value is attribute.value
record.selected = 'selected'
# return item
item = $( App.view('generic/select')( attribute: attribute ) )
# select
else if attribute.tag is 'select'
item = $( App.view('generic/select')( attribute: attribute ) )

View file

@ -250,7 +250,7 @@ class Edit extends App.ControllerModal
configureAttributesBottom = [
{ name: 'active', display: 'Active', tag: 'boolean', 'default': true, 'null': false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]
controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesBottom, className: '' },

View file

@ -8,7 +8,7 @@ class App.EmailAddress extends App.Model
{ name: 'email', display: 'Email', tag: 'input', type: 'text', limit: 250, null: false },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]
@configure_overview = [
'realname', 'email'

View file

@ -12,7 +12,7 @@ class App.Group extends App.Model
{ name: 'signature_id', display: 'Signature', tag: 'select', multiple: false, null: true, relation: 'Signature', nulloption: true },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]
@configure_overview = [
'name',

View file

@ -8,7 +8,7 @@ class App.Job extends App.Model
{ name: 'condition', display: 'Conditions for matching objects.', tag: 'ticket_attribute_selection', null: true },
{ name: 'execute', display: 'Execute changes on objects.', tag: 'ticket_attribute_set', null: true },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'matching', display: 'Matching', readonly: 1 },
{ name: 'processed', display: 'Processed', readonly: 1 },
{ name: 'last_run_at', display: 'Last run', tag: 'datetime', readonly: 1 },

View file

@ -5,5 +5,5 @@ class App.Network extends App.Model
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'note', display: 'Note', note: 'Notes are visible to agents only, never to customers.', tag: 'textarea', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]

View file

@ -3,13 +3,13 @@ class App.ObjectManagerAttribute extends App.Model
@extend Spine.Model.Ajax
@url: @apiPath + '/object_manager_attributes'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'display', display: 'Anzeige', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'object', display: 'Object', tag: 'input', readonly: 1 },
{ name: 'position', display: 'Position', tag: 'input', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', default: true, null: false },
{ name: 'data_type', display: 'Format', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'display', display: 'Anzeige', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'object', display: 'Object', tag: 'input', readonly: 1 },
{ name: 'position', display: 'Position', tag: 'input', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'data_type', display: 'Format', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
]
@configure_overview = [
#'name',

View file

@ -7,7 +7,7 @@ class App.Organization extends App.Model
{ name: 'shared', display: 'Shared organization', tag: 'boolean', note: 'Customers in the organization can view each other items.', type: 'boolean', default: true, null: false, info: false },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true, info: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1, info: false },
{ name: 'active', display: 'Active', tag: 'boolean', default: true, null: false, info: false },
{ name: 'active', display: 'Active', tag: 'active', default: true, info: false },
]
@configure_overview = [
'name',

View file

@ -131,7 +131,7 @@ class App.Overview extends App.Model
owner: 'Owner'
class: 'span4'
},
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -10,7 +10,7 @@ class App.PostmasterFilter extends App.Model
{ name: 'perform', display: 'Perform action of the following', tag: 'postmaster_set' },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -5,7 +5,7 @@ class App.Role extends App.Model
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', 'default': true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -7,7 +7,7 @@ class App.Signature extends App.Model
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false },
{ name: 'body', display: 'Text', tag: 'textarea', limit: 250, 'null': true, rows: 10 },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, 'null': true },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', 'default': true, 'null': false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -31,7 +31,7 @@ class App.Sla extends App.Model
group: 'Group'
owner: 'Owner'
},
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -3,11 +3,11 @@ class App.TextModule extends App.Model
@extend Spine.Model.Ajax
@url: @apiPath + '/text_modules'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
{ name: 'keywords', display: 'Keywords', tag: 'input', type: 'text', limit: 100, 'null': true, 'class': 'span4' },
{ name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false, 'class': 'span4' },
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'keywords', display: 'Keywords', tag: 'input', type: 'text', limit: 100, null: true },
{ name: 'content', display: 'Content', tag: 'textarea', limit: 250, null: false },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]
@configure_delete = true
@configure_overview = [

View file

@ -4,7 +4,7 @@ class App.TicketPriority extends App.Model
@url: @apiPath + '/ticket_priorities'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false, translate: true },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
]

View file

@ -4,7 +4,7 @@ class App.TicketState extends App.Model
@url: @apiPath + '/ticket_states'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false, translate: true },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', default: true, null: false },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
]

View file

@ -22,7 +22,7 @@ class App.User extends App.Model
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true, info: true },
{ name: 'role_ids', display: 'Roles', tag: 'checkbox', multiple: true, null: false, relation: 'Role' },
{ name: 'group_ids', display: 'Groups', tag: 'checkbox', multiple: true, null: true, relation: 'Group', invite_agent: true },
{ name: 'active', display: 'Active', tag: 'boolean', default: true, null: true },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
]
@configure_overview = [

View file

@ -463,7 +463,7 @@ class UpdateObjectManager2 < ActiveRecord::Migration
:maxlength => 100,
:null => true,
:autocomplete => 'off',
:item_class => 'formGroup--halfSize',
:item_class => 'formGroup--halfSize',
},
:editable => false,
:active => true,
@ -493,10 +493,11 @@ class UpdateObjectManager2 < ActiveRecord::Migration
:display => 'Note',
:data_type => 'richtext',
:data_option => {
:type => 'text',
:maxlength => 250,
:null => true,
:note => 'Notes are visible to agents only, never to customers.',
:type => 'text',
:maxlength => 250,
:null => true,
:note => 'Notes are visible to agents only, never to customers.',
# :item_class => 'formGroup--halfSize',
},
:editable => false,
:active => true,
@ -592,7 +593,7 @@ class UpdateObjectManager2 < ActiveRecord::Migration
:object => 'User',
:name => 'active',
:display => 'Active',
:data_type => 'boolean',
:data_type => 'active',
:data_option => {
:null => true,
:default => true,
@ -722,10 +723,8 @@ class UpdateObjectManager2 < ActiveRecord::Migration
:object => 'Organization',
:name => 'active',
:display => 'Active',
:data_type => 'boolean',
:data_type => 'active',
:data_option => {
:maxlength => 250,
:null => true,
:default => true,
},
:editable => false,

View file

@ -0,0 +1,100 @@
class UpdateObjectManager3 < ActiveRecord::Migration
def up
ObjectManager::Attribute.add(
:object => 'User',
:name => 'active',
:display => 'Active',
:data_type => 'active',
:data_option => {
:default => true,
},
:editable => false,
:active => true,
:screens => {
:signup => {},
:invite_agent => {},
:edit => {
:Admin => {
:null => false,
},
},
:view => {
'-all-' => {
:shown => false,
},
},
},
:pending_migration => false,
:position => 1800,
:created_by_id => 1,
:updated_by_id => 1,
)
ObjectManager::Attribute.add(
:object => 'Organization',
:name => 'active',
:display => 'Active',
:data_type => 'active',
:data_option => {
:default => true,
},
:editable => false,
:active => true,
:screens => {
:edit => {
:Admin => {
:null => false,
},
},
:view => {
'-all-' => {
:shown => false,
},
},
},
:pending_migration => false,
:position => 1800,
:created_by_id => 1,
:updated_by_id => 1,
)
ObjectManager::Attribute.add(
:object => 'User',
:name => 'password',
:display => 'Password',
:data_type => 'input',
:data_option => {
:type => 'password',
:maxlength => 100,
:null => true,
:autocomplete => 'off',
:item_class => 'formGroup--halfSize',
},
:editable => false,
:active => true,
:screens => {
:signup => {
'-all-' => {
:null => false,
},
},
:invite_agent => {},
:edit => {
:Admin => {
:null => true,
},
},
:view => {}
},
:pending_migration => false,
:position => 1400,
:created_by_id => 1,
:updated_by_id => 1,
)
end
def down
end
end

View file

@ -17,7 +17,7 @@ test( "form validation check", function() {
{ name: 'richtext1', display: 'Richtext1', tag: 'richtext', maxlength: 100, null: false, type: 'richtext', multiline: true, upload: true, default: defaults['richtext1'] },
{ name: 'datetime1', display: 'Datetime1', tag: 'datetime', null: false, default: defaults['datetime1'] },
{ name: 'date1', display: 'Date1', tag: 'date', null: false, default: defaults['date1'] },
{ name: 'active1', display: 'Active1', tag: 'boolean', type: 'boolean', default: defaults['active1'], null: false },
{ name: 'active1', display: 'Active1', tag: 'active', default: defaults['active1'] },
],
},
params: defaults,

View file

@ -159,8 +159,8 @@ test( "form params check", function() {
{ name: 'date2', display: 'Date2', tag: 'date', null: true, default: defaults['date2'] },
{ name: 'date3', display: 'Date3', tag: 'date', null: false, default: defaults['date3'] },
{ name: 'date4', display: 'Date4', tag: 'date', null: false, default: defaults['date4'] },
{ name: 'active1', display: 'Active1', tag: 'boolean', type: 'boolean', default: defaults['active1'], null: false },
{ name: 'active2', display: 'Active2', tag: 'boolean', type: 'boolean', default: defaults['active2'], null: false },
{ name: 'active1', display: 'Active1', tag: 'active', default: defaults['active1'] },
{ name: 'active2', display: 'Active2', tag: 'active', default: defaults['active2'] },
],
},
params: defaults,
@ -795,7 +795,7 @@ test( "form required_if + shown_if", function() {
{ name: 'input2', display: 'Input2', tag: 'input', type: 'text', limit: 100, null: true, default: 'some used default', required_if: { active: true }, shown_if: { active: true } },
{ name: 'input3', display: 'Input3', tag: 'input', type: 'text', limit: 100, null: true, default: 'some used default', required_if: { active: [true,false] }, shown_if: { active: [true,false] } },
{ name: 'input4', display: 'Input4', tag: 'input', type: 'text', limit: 100, null: true, default: 'some used default', required_if: { active: [55,66] }, shown_if: { active: [55,66] } },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', 'default': true, null: false },
{ name: 'active', display: 'Active', tag: 'active', 'default': true },
],
},
params: defaults,