From be3ee48a3cac27d55c9893645a3242f05ff14e02 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 17 Nov 2016 11:21:47 +0100 Subject: [PATCH] Added missing migration file for issue#427 - Improved ticket number generator settings (just show necessary settings based on generator selection). --- ...00002_ticket_number_generator_issue_427.rb | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 db/migrate/20161117000002_ticket_number_generator_issue_427.rb diff --git a/db/migrate/20161117000002_ticket_number_generator_issue_427.rb b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb new file mode 100644 index 000000000..a0617ce04 --- /dev/null +++ b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb @@ -0,0 +1,55 @@ +class TicketNumberGeneratorIssue427 < ActiveRecord::Migration + def up + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + setting = Setting.find_by(name: 'ticket_number') + setting.preferences = { + settings_included: %w(ticket_number_increment ticket_number_date), + controller: 'SettingsAreaTicketNumber', + permission: ['admin.ticket'], + } + setting.save! + setting = Setting.find_by(name: 'ticket_number_increment') + setting.preferences = { + permission: ['admin.ticket'], + hidden: true, + } + setting.save! + setting = Setting.find_by(name: 'ticket_number_date') + setting.preferences = { + permission: ['admin.ticket'], + hidden: true, + } + + # just to make sure that value is saved correctly - https://github.com/zammad/zammad/issues/413 + if setting.state_current['value'] == true || setting.state_current['value'] == false + setting.state_current['value'] = { 'checksum' => setting.state_current['value'] } + end + setting.save! + + setting = Setting.find_by(name: 'ticket_hook_position') + setting.preferences = { + controller: 'SettingsAreaTicketHookPosition', + permission: ['admin.ticket'], + } + setting.options = { + form: [ + { + display: '', + null: true, + name: 'ticket_hook_position', + tag: 'select', + translate: true, + options: { + 'left' => 'left', + 'right' => 'right', + 'none' => 'none', + }, + }, + ], + } + setting.save! + + end +end