diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index d2ccb4814..f3059179a 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -238,6 +238,23 @@ class App.TicketCreate extends App.Controller else @$('[data-name="body"]').find('[data-signature=true]').remove() + App.Ticket.configure_attributes.push { + name: 'cc' + display: 'Cc' + tag: 'input' + type: 'text' + maxlength: 1000 + null: true + screen: { + create_top: { + Agent: { + null: true + } + } + create_middle: {} + edit: {} + } + } new App.ControllerForm( el: @$('.ticket-form-top') form_id: @form_id @@ -290,6 +307,7 @@ class App.TicketCreate extends App.Controller filter: @formMeta.filter params: params ) + App.Ticket.configure_attributes.pop() # set type selector @setFormTypeInUi( params['formSenderType'] ) diff --git a/app/models/object_manager.rb b/app/models/object_manager.rb index b7c05090e..187f3f3e6 100644 --- a/app/models/object_manager.rb +++ b/app/models/object_manager.rb @@ -126,6 +126,41 @@ add a new attribute entry for an object =begin +remove attribute entry for an object + + ObjectManager::Attribute.remove( + object: 'Ticket', + name: 'group_id', + ) + +use "force: true" to delete also not editable fields + +=end + + def self.remove(data) + + # lookups + if data[:object] + data[:object_lookup_id] = ObjectLookup.by_name(data[:object]) + end + + # check newest entry - is needed + result = ObjectManager::Attribute.find_by( + object_lookup_id: data[:object_lookup_id], + name: data[:name], + ) + if !result + raise "ERROR: No such field #{data[:object]}.#{data[:name]}" + end + + if !data[:force] && !result.editable + raise "ERROR: #{data[:object]}.#{data[:name]} can't be removed!" + end + result.destroy + end + +=begin + get the attribute model based on object and name attribute = ObjectManager::Attribute.get( diff --git a/db/migrate/20160506000002_email_ticket_cc_remove.rb b/db/migrate/20160506000002_email_ticket_cc_remove.rb new file mode 100644 index 000000000..96c5e1dde --- /dev/null +++ b/db/migrate/20160506000002_email_ticket_cc_remove.rb @@ -0,0 +1,6 @@ + +class EmailTicketCcRemove < ActiveRecord::Migration + def up + ObjectManager::Attribute.remove(object: 'Ticket', name: 'cc', force: true) + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 96ab848f2..806c18abb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2533,30 +2533,6 @@ ObjectManager::Attribute.add( pending_migration: false, position: 10, ) -ObjectManager::Attribute.add( - object: 'Ticket', - name: 'cc', - display: 'Cc', - data_type: 'input', - data_option: { - type: 'text', - maxlength: 1000, - null: true, - }, - editable: false, - active: true, - screens: { - create_top: { - Agent: { - null: true, - }, - }, - create_middle: {}, - edit: {} - }, - pending_migration: false, - position: 11, -) ObjectManager::Attribute.add( object: 'Ticket', name: 'type',