Added time zone support for slas.
This commit is contained in:
parent
b47ad57129
commit
7b15323315
4 changed files with 57 additions and 10 deletions
|
@ -157,7 +157,7 @@ class App.ControllerForm extends App.Controller
|
|||
|
||||
# set value
|
||||
if @params
|
||||
|
||||
|
||||
# check if we have a references
|
||||
parts = attribute.name.split '::'
|
||||
if parts[0] && parts[1]
|
||||
|
@ -201,8 +201,8 @@ class App.ControllerForm extends App.Controller
|
|||
# build options list
|
||||
if _.isEmpty(attribute.options)
|
||||
attribute.options = [
|
||||
{ name: 'active', value: true }
|
||||
{ name: 'inactive', value: false }
|
||||
{ name: 'active', value: true }
|
||||
{ name: 'inactive', value: false }
|
||||
]
|
||||
|
||||
# update boolean types
|
||||
|
@ -221,6 +221,27 @@ class App.ControllerForm extends App.Controller
|
|||
else if attribute.tag is 'select'
|
||||
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
|
||||
else if attribute.tag is 'input_select'
|
||||
item = $('<div class="input_select"></div>')
|
||||
|
@ -374,7 +395,7 @@ class App.ControllerForm extends App.Controller
|
|||
onRemoveTag: onRemoveTag
|
||||
)
|
||||
siteUpdate(true)
|
||||
|
||||
|
||||
# update box size
|
||||
App.Event.bind 'ui:rerender:content', =>
|
||||
siteUpdate(true)
|
||||
|
@ -493,7 +514,7 @@ class App.ControllerForm extends App.Controller
|
|||
name = 'owner_id'
|
||||
if key is 'customer_id'
|
||||
display = 'Customer'
|
||||
name = 'customer_id'
|
||||
name = 'customer_id'
|
||||
attribute_config = {
|
||||
name: attribute.name + '::tickets.' + name
|
||||
display: display
|
||||
|
@ -674,7 +695,7 @@ class App.ControllerForm extends App.Controller
|
|||
)
|
||||
# itemSub.append('<a href=\"#\" class=\"icon-minus\"></a>')
|
||||
item.find('.ticket_attribute_item').append( itemSub )
|
||||
|
||||
|
||||
|
||||
# list of shown attributes
|
||||
show = []
|
||||
|
@ -793,7 +814,7 @@ class App.ControllerForm extends App.Controller
|
|||
selected: true
|
||||
disable: false
|
||||
},
|
||||
|
||||
|
||||
# {
|
||||
# value: 'tag'
|
||||
# name: 'Tag'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
@url: 'api/slas'
|
||||
@configure_attributes = [
|
||||
|
@ -8,7 +8,8 @@ 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: '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: 'timezone', display: 'Timezone', tag: 'timezone', null: true, class: 'span4' },
|
||||
{
|
||||
name: 'data'
|
||||
display: 'Business Times'
|
||||
tag: 'working_hour'
|
||||
|
|
|
@ -196,12 +196,28 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def config_frontend
|
||||
|
||||
|
||||
# config
|
||||
config = {}
|
||||
Setting.select('name').where( :frontend => true ).each { |setting|
|
||||
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
|
||||
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