From c73c5b0ca1ded7a02a87eb26d820d3d72bd34ba8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 21 Mar 2013 10:40:49 +0100 Subject: [PATCH 1/2] Fixed not working SLA creation. --- app/models/application_model.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index a3806a03b..e72b4c882 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -10,9 +10,11 @@ class ApplicationModel < ActiveRecord::Base after_update :cache_delete after_destroy :cache_delete + @@import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::Priority', 'Group', 'User' ] + # for import other objects, remove 'id' def self.attributes_protected_by_default - if Setting.get('import_mode') + if Setting.get('import_mode') && @@import_class_list.include?( self.name.to_s ) ['type'] else ['id','type'] From 288c9c0f12f3b2e697ebccdec680df4fd7a1c102 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 21 Mar 2013 11:26:36 +0100 Subject: [PATCH 2/2] Destroy objects also in local storage. --- .../javascripts/app/models/application_model.js.coffee | 10 ++++++++++ app/assets/javascripts/app/models/sla.js.coffee | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/models/application_model.js.coffee b/app/assets/javascripts/app/models/application_model.js.coffee index 6b764a589..d86ace5e4 100644 --- a/app/assets/javascripts/app/models/application_model.js.coffee +++ b/app/assets/javascripts/app/models/application_model.js.coffee @@ -1,4 +1,13 @@ class App.Model extends Spine.Model + constructor: -> + super + + # delete object from local storage on destroy + @bind( 'destroy', (e) -> + className = Object.getPrototypeOf(e).constructor.className + key = "collection::#{className}::#{e.id}" + App.Store.delete(key) + ) displayName: -> return @name if @name @@ -69,3 +78,4 @@ class App.Model extends Spine.Model model: @constructor, params: @, ) + diff --git a/app/assets/javascripts/app/models/sla.js.coffee b/app/assets/javascripts/app/models/sla.js.coffee index 81a51135c..7f50cf6fb 100644 --- a/app/assets/javascripts/app/models/sla.js.coffee +++ b/app/assets/javascripts/app/models/sla.js.coffee @@ -1,4 +1,4 @@ -class App.Sla extends Spine.Model +class App.Sla extends App.Model @configure 'Sla', 'name', 'first_response_time', 'update_time', 'close_time', 'condition', 'data', 'active' @extend Spine.Model.Ajax @url: 'api/slas'