Fixes #3575 - Display minutes for session timeouts instead of seconds.

This commit is contained in:
Rolf Schmidt 2021-05-28 11:28:06 +00:00 committed by Thorsten Eckel
parent dc0813ba28
commit 01b414f9fc
3 changed files with 82 additions and 17 deletions

View file

@ -424,7 +424,7 @@ class CreateBase < ActiveRecord::Migration[4.2]
t.string :name, limit: 200, null: false
t.string :area, limit: 100, null: false
t.string :description, limit: 2000, null: false
t.string :options, limit: 2000, null: true
t.text :options, null: true
t.text :state_current, limit: 200.kilobytes + 1, null: true
t.string :state_initial, limit: 2000, null: true
t.boolean :frontend, null: false

View file

@ -0,0 +1,55 @@
class UpdateSessionTimeoutDropdown < ActiveRecord::Migration[5.2]
def change
return if !Setting.exists?(name: 'system_init_done')
change_column :settings, :options, :text, null: true
Setting.reset_column_information
update_setting
end
def options
[ { value: '0', name: 'disabled' }, { value: 1.hour.seconds, name: '1 hour' }, { value: 2.hours.seconds, name: '2 hours' }, { value: 1.day.seconds, name: '1 day' }, { value: 7.days.seconds, name: '1 week' }, { value: 14.days.seconds, name: '2 weeks' }, { value: 21.days.seconds, name: '3 weeks' }, { value: 28.days.seconds, name: '4 weeks' } ]
end
def update_setting
setting = Setting.find_by(name: 'session_timeout')
setting.options = {
form: [
{
display: 'Default',
null: false,
name: 'default',
tag: 'select',
options: options,
translate: true,
},
{
display: 'admin',
null: false,
name: 'admin',
tag: 'select',
options: options,
translate: true,
},
{
display: 'ticket.agent',
null: false,
name: 'ticket.agent',
tag: 'select',
options: options,
translate: true,
},
{
display: 'ticket.customer',
null: false,
name: 'ticket.customer',
tag: 'select',
options: options,
translate: true,
},
]
}
setting.save!
end
end

View file

@ -1041,6 +1041,8 @@ Setting.create_if_not_exists(
},
frontend: true
)
options = [ { value: '0', name: 'disabled' }, { value: 1.hour.seconds, name: '1 hour' }, { value: 2.hours.seconds, name: '2 hours' }, { value: 1.day.seconds, name: '1 day' }, { value: 7.days.seconds, name: '1 week' }, { value: 14.days.seconds, name: '2 weeks' }, { value: 21.days.seconds, name: '3 weeks' }, { value: 28.days.seconds, name: '4 weeks' } ]
Setting.create_if_not_exists(
title: 'Session Timeout',
name: 'session_timeout',
@ -1052,25 +1054,33 @@ Setting.create_if_not_exists(
display: 'Default',
null: false,
name: 'default',
tag: 'input',
tag: 'select',
options: options,
translate: true,
},
{
display: 'admin',
null: false,
name: 'admin',
tag: 'input',
tag: 'select',
options: options,
translate: true,
},
{
display: 'ticket.agent',
null: false,
name: 'ticket.agent',
tag: 'input',
tag: 'select',
options: options,
translate: true,
},
{
display: 'ticket.customer',
null: false,
name: 'ticket.customer',
tag: 'input',
tag: 'select',
options: options,
translate: true,
},
],
},