Browse Source

Moved to ajax searchable select for organization selection.

Martin Edenhofer 9 years ago
parent
commit
a6b5b43994

+ 5 - 10
app/controllers/sessions/collection_base.rb

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

+ 1 - 0
db/migrate/20140831000001_create_object_manager.rb

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

+ 1 - 1
db/migrate/20141217000001_update_object_manager2.rb

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

+ 71 - 0
db/migrate/20150977000001_update_object_manager3.rb

@@ -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