Moved to ajax searchable select for organization selection.

This commit is contained in:
Martin Edenhofer 2015-09-23 17:22:31 +02:00
parent 2311d1c393
commit a6b5b43994
4 changed files with 78 additions and 11 deletions

View file

@ -26,19 +26,14 @@ module ExtraCollection
Group.all.each {|item| Group.all.each {|item|
assets = item.assets(assets) assets = item.assets(assets)
} }
if !user.role?(Z_ROLENAME_CUSTOMER)
collections[ Organization.to_app_model ] = [] collections[ Organization.to_app_model ] = []
Organization.all.each {|item|
assets = item.assets(assets)
}
else
if user.organization_id if user.organization_id
collections[ Organization.to_app_model ] = []
Organization.where( id: user.organization_id ).each {|item| Organization.where( id: user.organization_id ).each {|item|
assets = item.assets(assets) assets = item.assets(assets)
} }
end end
end
[collections, assets] [collections, assets]
end end
module_function :session module_function :session

View file

@ -30,6 +30,7 @@ class CreateObjectManager < ActiveRecord::Migration
display: 'Customer', display: 'Customer',
data_type: 'user_autocompletion', data_type: 'user_autocompletion',
data_option: { data_option: {
relation: 'User',
autocapitalize: false, autocapitalize: false,
multiple: false, multiple: false,
null: false, null: false,

View file

@ -292,7 +292,7 @@ class UpdateObjectManager2 < ActiveRecord::Migration
object: 'User', object: 'User',
name: 'organization_id', name: 'organization_id',
display: 'Organization', display: 'Organization',
data_type: 'select', data_type: 'autocompletion_ajax',
data_option: { data_option: {
multiple: false, multiple: false,
nulloption: true, nulloption: true,

View file

@ -0,0 +1,71 @@
class UpdateObjectManager3 < ActiveRecord::Migration
def up
ObjectManager::Attribute.add(
object: 'User',
name: 'organization_id',
display: 'Organization',
data_type: 'autocompletion_ajax',
data_option: {
multiple: false,
nulloption: true,
null: true,
relation: 'Organization',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
pending_migration: false,
position: 900,
created_by_id: 1,
updated_by_id: 1,
)
ObjectManager::Attribute.add(
object: 'Ticket',
name: 'customer_id',
display: 'Customer',
data_type: 'user_autocompletion',
data_option: {
relation: 'User',
autocapitalize: false,
multiple: false,
null: false,
limit: 200,
placeholder: 'Enter Person or Organization/Company',
minLengt: 2,
translate: false,
},
editable: false,
active: true,
screens: {
create_top: {
Agent: {
null: false,
},
},
edit: {},
},
pending_migration: false,
position: 10,
created_by_id: 1,
updated_by_id: 1,
)
end
end