Browse Source

Added debug info what on ticket has changed.

Martin Edenhofer 12 years ago
parent
commit
417657e9c8

+ 2 - 0
app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee

@@ -48,6 +48,8 @@ class Index extends App.Controller
       success: (data, status, xhr) =>
         if @dataLastCall
           return if _.isEqual( @dataLastCall.ticket, data.ticket)
+          diff = difference( @dataLastCall.ticket, data.ticket )
+          console.log('diff', diff)
           if $('[name="body"]').val()
             App.Event.trigger 'notify', {
               type: 'success'

+ 0 - 1
app/assets/javascripts/app/lib/base/jquery.sew.js

@@ -103,7 +103,6 @@
 		var separator2 = posfix.match(/^\s/) ? '' : ' ';
 
 		var finalFight = val + separator2 + posfix;
-		console.log('222', finalFight)
 		this.setText(finalFight);
 		this.$element.setCursorPosition(val.length + 1);
 	};

+ 17 - 0
app/assets/javascripts/application.js

@@ -46,4 +46,21 @@ function escapeRegExp(str) {
 Date.prototype.getWeek = function() {
   var onejan = new Date(this.getFullYear(),0,1);
   return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
+}
+
+function difference(object1, object2) {
+  var changes = {};
+  for ( var name in object1 ) {
+    if ( name in object2 ) {
+      if ( _.isObject( object2[name] ) && !_.isArray( object2[name] ) ) {
+        var diff = difference( object1[name], object2[name] );
+        if ( !_.isEmpty( diff ) ) {
+            changes[name] = diff;
+        }
+      } else if ( !_.isEqual( object1[name], object2[name] ) ) {
+        changes[name] = object2[name];
+      }
+    }
+  }
+  return changes;
 }