define(['app', 'text!./room-row.html','text!../forms/edit/room-dialog.html',
  'ngDialog',
  '../forms/edit/room',
], function(app, template,roomDialog) {

  app.directive("roomRow", ['ngDialog',
    function(ngDialog) {
      return {
        restrict: 'E',
        template: template,
        replace: true,
        transclude: false,
        scope: {
          'room': '=',
          'index':'='
        },
        link: function($scope,$element) {

            //============================================================
            //
            //============================================================
            $scope.$watch('room.rowHeight',function(){
              if($scope.room.rowHeight)
                $element.css('height',$scope.room.rowHeight);
            });
            
            //============================================================
            //
            //============================================================
            $scope.$watch('index',function(){
              if($scope.index)
                $scope.room.sort=$scope.index;
            });

            //============================================================
            //
            //============================================================
            $scope.roomDialog = function(room) {
                $scope.editRoom = room;
                ngDialog.open({
                  template: roomDialog,
                  className: 'ngdialog-theme-default',
                  closeByDocument: true,
                  plain: true,
                  scope: $scope
                });
            };//$scope.roomDialog

          } //link
      }; //return
    }
  ]);
});
@@ -7,16 +7,25 @@
 (%5B'app',
+'lodash',
  'text!.
@@ -133,16 +133,18 @@
 ion(app,
+_,
  templat
@@ -203,30 +203,82 @@
 og',
-%0A    function(ngDialog
+'mongoStorage','$rootScope',%0A    function(ngDialog,mongoStorage,$rootScope
 ) %7B%0A
@@ -847,28 +847,16 @@
     %7D);%0A
-            
 %0A       
@@ -1423,16 +1423,29 @@
         
+ var dialog =
  ngDialo
@@ -1688,30 +1688,1237 @@
     
-%7D;//$scope.roomDialog%0A
+    dialog.closePromise.then(function(ret) %7B%0A                      if (ret.value === 'save')  save($scope.editRoom).then(close);%0A                %7D);%0A            %7D;//$scope.roomDialog%0A            //============================================================%0A            //%0A            //============================================================%0A            function save (obj)%7B%0A                return mongoStorage.save('venue-rooms', cleanDoc(obj),obj._id).then(function()%7B%0A                            $rootScope.$broadcast(%22showInfo%22,%22Room '%22+obj.title+%22' Successfully Updated.%22);%0A                %7D).catch(function(error)%7B%0A                    console.log(error);%0A                    $rootScope.$broadcast(%22showError%22,%22There was an error saving your Room details: '%22+obj.title+%22' to the server.%22);%0A                %7D);%0A            %7D//save%0A%0A            //============================================================%0A            //%0A            //============================================================%0A            function cleanDoc(obj) %7B%0A%0A              var objClone = _.clone(obj);%0A              delete(objClone.changed);%0A              delete(objClone.history);%0A              return objClone;%0A            %7D //triggerChanges
 %0A   

save room on schedule bug