Added time zone support for slas.
This commit is contained in:
parent
b47ad57129
commit
7b15323315
4 changed files with 57 additions and 10 deletions
|
@ -221,6 +221,27 @@ class App.ControllerForm extends App.Controller
|
||||||
else if attribute.tag is 'select'
|
else if attribute.tag is 'select'
|
||||||
item = $( App.view('generic/select')( attribute: attribute ) )
|
item = $( App.view('generic/select')( attribute: attribute ) )
|
||||||
|
|
||||||
|
# timezone
|
||||||
|
else if attribute.tag is 'timezone'
|
||||||
|
attribute.options = []
|
||||||
|
timezones = App.Config.get('timezones')
|
||||||
|
|
||||||
|
# build list based on config
|
||||||
|
for timezone_value, timezone_diff of timezones
|
||||||
|
if timezone_diff > 0
|
||||||
|
timezone_diff = '+' + timezone_diff
|
||||||
|
item =
|
||||||
|
name: "#{timezone_value} (GMT#{timezone_diff})"
|
||||||
|
value: timezone_value
|
||||||
|
attribute.options.push item
|
||||||
|
|
||||||
|
# finde selected item of list
|
||||||
|
for record in attribute.options
|
||||||
|
if record.value is attribute.value
|
||||||
|
record.selected = 'selected'
|
||||||
|
|
||||||
|
item = $( App.view('generic/select')( attribute: attribute ) )
|
||||||
|
|
||||||
# select
|
# select
|
||||||
else if attribute.tag is 'input_select'
|
else if attribute.tag is 'input_select'
|
||||||
item = $('<div class="input_select"></div>')
|
item = $('<div class="input_select"></div>')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class App.Sla extends App.Model
|
class App.Sla extends App.Model
|
||||||
@configure 'Sla', 'name', 'first_response_time', 'update_time', 'close_time', 'condition', 'data', 'active'
|
@configure 'Sla', 'name', 'first_response_time', 'update_time', 'close_time', 'condition', 'timezone', 'data', 'active'
|
||||||
@extend Spine.Model.Ajax
|
@extend Spine.Model.Ajax
|
||||||
@url: 'api/slas'
|
@url: 'api/slas'
|
||||||
@configure_attributes = [
|
@configure_attributes = [
|
||||||
|
@ -8,6 +8,7 @@ class App.Sla extends App.Model
|
||||||
{ name: 'update_time', display: 'Update Time', tag: 'input', type: 'text', limit: 100, null: true, 'class': 'span4', note: 'In minutes, only business times are counted.' },
|
{ name: 'update_time', display: 'Update Time', tag: 'input', type: 'text', limit: 100, null: true, 'class': 'span4', note: 'In minutes, only business times are counted.' },
|
||||||
{ name: 'close_time', display: 'Solution Time', tag: 'input', type: 'text', limit: 100, null: true, 'class': 'span4', note: 'In minutes, only business times are counted.' },
|
{ name: 'close_time', display: 'Solution Time', tag: 'input', type: 'text', limit: 100, null: true, 'class': 'span4', note: 'In minutes, only business times are counted.' },
|
||||||
{ name: 'condition', display: 'Conditions where SLA is used', tag: 'ticket_attribute_selection', null: true, class: 'span4' },
|
{ name: 'condition', display: 'Conditions where SLA is used', tag: 'ticket_attribute_selection', null: true, class: 'span4' },
|
||||||
|
{ name: 'timezone', display: 'Timezone', tag: 'timezone', null: true, class: 'span4' },
|
||||||
{
|
{
|
||||||
name: 'data'
|
name: 'data'
|
||||||
display: 'Business Times'
|
display: 'Business Times'
|
||||||
|
|
|
@ -202,6 +202,22 @@ class ApplicationController < ActionController::Base
|
||||||
Setting.select('name').where( :frontend => true ).each { |setting|
|
Setting.select('name').where( :frontend => true ).each { |setting|
|
||||||
config[setting.name] = Setting.get(setting.name)
|
config[setting.name] = Setting.get(setting.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get all time zones
|
||||||
|
config['timezones'] = {}
|
||||||
|
TZInfo::Timezone.all.each { |t|
|
||||||
|
|
||||||
|
# ignore the following time zones
|
||||||
|
next if t.name =~ /^GMT/
|
||||||
|
next if t.name =~ /^Etc/
|
||||||
|
next if t.name =~ /^MET/
|
||||||
|
next if t.name =~ /^MST/
|
||||||
|
next if t.name =~ /^ROC/
|
||||||
|
next if t.name =~ /^ROK/
|
||||||
|
diff = t.current_period.utc_total_offset / 60 /60
|
||||||
|
config['timezones'][ t.name ] = diff
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
9
db/migrate/20130606070432_sla_timezone.rb
Normal file
9
db/migrate/20130606070432_sla_timezone.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class SlaTimezone < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
add_column :slas, :timezone, :string, :limit => 50, :null => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :slas, :timezone
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue