From 6f99e653619a6d6581ec791ba78eeed7a77250d0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 13 Jan 2017 19:55:12 +0100 Subject: [PATCH] Moved show additional ticket attributes to bottom to middle in create screens. --- .../object_manager_attribute.coffee | 4 +-- .../app/controllers/object_manager.coffee | 28 +++++++++++++------ ..._object_manager_attribute_create_middle.rb | 21 ++++++++++++++ db/seeds.rb | 5 ++-- 4 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20170113000001_object_manager_attribute_create_middle.rb diff --git a/app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee b/app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee index 3ad58c43b..41b280202 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee @@ -48,14 +48,14 @@ class App.UiElement.object_manager_attribute extends App.UiElement.ApplicationUi objects = Ticket: Customer: - create_bottom: + create_middle: shown: true required: false edit: shown: true required: false Agent: - create_bottom: + create_middle: shown: true required: false edit: diff --git a/app/assets/javascripts/app/controllers/object_manager.coffee b/app/assets/javascripts/app/controllers/object_manager.coffee index 09b7edd1a..5311380cf 100644 --- a/app/assets/javascripts/app/controllers/object_manager.coffee +++ b/app/assets/javascripts/app/controllers/object_manager.coffee @@ -83,7 +83,7 @@ class Items extends App.ControllerSubContent edit: (e) => e.preventDefault() - id = $( e.target ).closest('tr').data('id') + id = $(e.target).closest('tr').data('id') new Edit( pageData: head: @object @@ -135,15 +135,21 @@ class New extends App.ControllerGenericNew onSubmit: (e) => params = @formParam(e.target) + + # show attributes for create_middle in two column style + if params.screens && params.screens.create_middle + for role, value of params.screens.create_middle + value.item_class = 'column' + params.object = @pageData.head - object = new App[ @genericObject ] + object = new App[@genericObject] object.load(params) # validate errors = object.validate() if errors @log 'error', errors - @formValidate( form: e.target, errors: errors ) + @formValidate(form: e.target, errors: errors) return false # disable form @@ -154,7 +160,7 @@ class New extends App.ControllerGenericNew object.save( done: -> if ui.callback - item = App[ ui.genericObject ].fullLocal(@id) + item = App[ui.genericObject].fullLocal(@id) ui.callback(item) ui.close() @@ -167,11 +173,11 @@ class New extends App.ControllerGenericNew class Edit extends App.ControllerGenericEdit content: => - @item = App[ @genericObject ].find( @id ) + @item = App[@genericObject].find(@id) @head = @pageData.head || @pageData.object # set disabled attributes - configure_attributes = clone(App[ @genericObject ].configure_attributes) + configure_attributes = clone(App[@genericObject].configure_attributes) for attribute in configure_attributes if attribute.name is 'name' attribute.disabled = true @@ -189,6 +195,12 @@ class Edit extends App.ControllerGenericEdit onSubmit: (e) => params = @formParam(e.target) + + # show attributes for create_middle in two column style + if params.screens && params.screens.create_middle + for role, value of params.screens.create_middle + value.item_class = 'column' + params.object = @pageData.head @item.load(params) @@ -196,7 +208,7 @@ class Edit extends App.ControllerGenericEdit errors = @item.validate() if errors @log 'error', errors - @formValidate( form: e.target, errors: errors ) + @formValidate(form: e.target, errors: errors) return false # disable form @@ -207,7 +219,7 @@ class Edit extends App.ControllerGenericEdit @item.save( done: -> if ui.callback - item = App[ ui.genericObject ].fullLocal(@id) + item = App[ui.genericObject].fullLocal(@id) ui.callback(item) ui.close() diff --git a/db/migrate/20170113000001_object_manager_attribute_create_middle.rb b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb new file mode 100644 index 000000000..027d180db --- /dev/null +++ b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb @@ -0,0 +1,21 @@ +class UpdateObjectManagerAttributeCreateMiddle < ActiveRecord::Migration + def up + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + ObjectManager::Attribute.all.each { |attribute| + next if attribute.name == 'tags' + next if !attribute.screens + next if !attribute.screens['create_bottom'] + attribute.screens['create_middle'] = attribute.screens['create_bottom'] + attribute.screens.delete('create_bottom') + attribute.save! + } + + attribute = ObjectManager::Attribute.find_by(name: 'priority_id') + attribute.data_option['nulloption'] = false + attribute.save! + + Cache.clear + end +end diff --git a/db/seeds.rb b/db/seeds.rb index dd709e65c..9520d24fc 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3710,7 +3710,7 @@ ObjectManager::Attribute.add( data_type: 'select', data_option: { relation: 'TicketPriority', - nulloption: true, + nulloption: false, multiple: false, null: false, default: 2, @@ -3728,7 +3728,6 @@ ObjectManager::Attribute.add( edit: { Agent: { null: false, - nulloption: false, }, }, }, @@ -5296,7 +5295,7 @@ Trigger.create_or_update( 'notification.email' => { 'body' => '
Your request (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.

-
To provide additional information, please reply to this email or click on the following link: +
To provide additional information, please reply to this email or click on the following link (for initial login, please request a new password): #{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}