← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21164: removed unused directive draggableModal

 

------------------------------------------------------------
revno: 21164
committer: Jiju K Jose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-23 10:07:59 +0100
message:
  removed unused directive draggableModal
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js	2015-11-21 09:55:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js	2015-11-23 09:07:59 +0000
@@ -155,17 +155,7 @@
         controller: function ($scope, Paginator) {
             $scope.paginator = Paginator;
         },
-        templateUrl: '../dhis-web-commons/angular-forms/serverside-pagination.html'
-    };
-})
-
-.directive('draggableModal', function () {
-
-    return {
-        restrict: 'EA',
-        link: function (scope, element) {
-            element.draggable();
-        }
+        templateUrl: '../../../dhis-web-commons/angular-forms/serverside-pagination.html'
     };
 })
 
@@ -183,7 +173,7 @@
     };
 })
 
-.directive('d2ContextMenu', function (ContextMenuSelectedItem) {
+.directive('d2ContextMenu', function () {
 
     return {
         restrict: 'A',

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js	2015-11-20 15:57:37 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js	2015-11-23 09:07:59 +0000
@@ -131,31 +131,7 @@
         });
     });
 
-    /*TODO: draggabkModal directive is not used and likely to be removed*/
-    xdescribe('Directive: draggableModal', () => {
-        let mock$scope;
-        let render;
-        let mySpy;
-        beforeEach(inject(($injector) => {
-            const $compile = $injector.get('$compile');
-            const $rootScope = $injector.get('$rootScope');
-            mock$scope = $rootScope.$new();
-            render = (elm) =>
-            {
-                elm.draggable = function() {};
-                mySpy = spy(elm, "draggable");
-                $compile(elm)(mock$scope);
-                mock$scope.$digest();
-            };
-        }));
-        /* TODO ../dhis-web-commons/angular-forms/serverside-pagination.html is not loaded. */
-        /* works if the path in specified as ../../../dhis-web-commons/angular-forms/serverside-pagination.html */
-        it('call the draggable function when loaded.', () => {
-            var elm = angular.element('<draggable-modal></draggable-modal>');
-            render(elm);
-            expect(mySpy).to.have.been.calledOnce;
-        });
-    });
+
 
     describe('Directive: d2CustomForm', () => {
         let mock$scope;
@@ -173,4 +149,38 @@
             expect(elm[0].innerHTML).to.equal('<div class="ng-scope">TestContentOne</div>');
         });
     });
+
+
+
+    describe('Directive: d2ContextMenu', () => {
+        let mock$scope;
+        let element;
+        let $timeout;
+        let render;
+
+        beforeEach(inject(($injector) => {
+            const $compile = $injector.get('$compile');
+            const $rootScope = $injector.get('$rootScope');
+            mock$scope = $rootScope.$new();
+            render = (elm) => {
+                $compile(elm)(mock$scope);
+                mock$scope.$digest();
+            };
+        }));
+
+        it('should call the resgistered function on key press event', () => {
+            var elm = angular.element('<div id="contextMenu"></div><div d2-context-menu></div>');
+            render(elm);
+            var contextMenu =  elm.find('#contextMenu');
+            contextMenu.show = spy();
+            console.log(elm[0].innerHTML);
+
+            var e = jQuery.Event("click");
+
+            elm .trigger(e);
+            console.log(elm[0].innerHTML);
+
+            expect(contextMenu.show).to.be.calledOnce;
+        });
+    });
 });
\ No newline at end of file