Mathijs den Burger pushed to branch feature/visual-editing-psp1 at 
cms-community / hippo-addon-channel-manager


Commits:
abcb8002 by Mark at 2016-09-19T11:13:12+02:00
CHANNELMGR-865 show edit content button if it is "locked" by you

- - - - -


2 changed files:

- frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
- frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js
@@ -209,12 +209,12 @@ export class HippoIframeCtrl {
     return !this.editMode ? this.PageStructureService.getContentLinks() : [];
   }
 
-  contentIsLocked(contentLink) {
-    return typeof contentLink.metaData.holderId !== 'undefined';
+  contentIsLockedByAnother(contentLink) {
+    return (typeof contentLink.metaData.holderId !== 'undefined') && 
contentLink.metaData.holderId !== this.ConfigService.cmsUser;
   }
 
   openContent(contentLink) {
-    if (this.contentIsLocked(contentLink) && contentLink.metaData.holderId !== 
this.ConfigService.cmsUser) {
+    if (this.contentIsLockedByAnother(contentLink)) {
       this.CmsService.publish('open-content', contentLink.getUuid());
     } else {
       this.ChannelSidePanelService.open('right');
@@ -223,7 +223,7 @@ export class HippoIframeCtrl {
 
   getContentLinkTooltip(contentLink) {
     let result;
-    if (this.contentIsLocked(contentLink)) {
+    if (this.contentIsLockedByAnother(contentLink)) {
       result = this.$translate.instant('LOCKED_BY', { user: 
contentLink.metaData.holderName });
     } else {
       result = this.$translate.instant('EDIT_CONTENT');
@@ -233,7 +233,7 @@ export class HippoIframeCtrl {
 
   getContentLinkIcon(contentLink) {
     let result;
-    if (this.contentIsLocked(contentLink)) {
+    if (this.contentIsLockedByAnother(contentLink)) {
       result = 'images/lock.svg';
     } else {
       result = 'images/edit-document.svg';


=====================================
frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
=====================================
--- 
a/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
+++ 
b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js
@@ -186,7 +186,7 @@ describe('hippoIframeCtrl', () => {
       uuid: '1234',
     });
 
-    const locked = hippoIframeCtrl.contentIsLocked(contentLink);
+    const locked = hippoIframeCtrl.contentIsLockedByAnother(contentLink);
 
     expect(locked).toBe(false);
   });
@@ -198,7 +198,7 @@ describe('hippoIframeCtrl', () => {
       holderId: 'test',
     });
 
-    const locked = hippoIframeCtrl.contentIsLocked(contentLink);
+    const locked = hippoIframeCtrl.contentIsLockedByAnother(contentLink);
 
     expect(locked).toBe(true);
   });
@@ -213,7 +213,7 @@ describe('hippoIframeCtrl', () => {
       cmsUser: 'test',
     };
     spyOn(CmsService, 'publish');
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(true);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(true);
 
     hippoIframeCtrl.openContent(contentLink);
 
@@ -226,7 +226,7 @@ describe('hippoIframeCtrl', () => {
       uuid: '1234',
     });
     spyOn(ChannelSidePanelService, 'open');
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(false);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(false);
 
     hippoIframeCtrl.openContent(contentLink);
 
@@ -234,7 +234,7 @@ describe('hippoIframeCtrl', () => {
   });
 
   it('gets the edit content tooltip for the content link', () => {
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(false);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(false);
 
     const tooltip = hippoIframeCtrl.getContentLinkTooltip({});
 
@@ -242,7 +242,7 @@ describe('hippoIframeCtrl', () => {
   });
 
   it('gets the locked by tooltip for the content link', () => {
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(true);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(true);
 
     const tooltip = hippoIframeCtrl.getContentLinkTooltip({
       metaData: {
@@ -254,7 +254,7 @@ describe('hippoIframeCtrl', () => {
   });
 
   it('gets the edit icon for the content link', () => {
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(false);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(false);
 
     const icon = hippoIframeCtrl.getContentLinkIcon({});
 
@@ -262,7 +262,7 @@ describe('hippoIframeCtrl', () => {
   });
 
   it('gets the locked icon for the content link', () => {
-    spyOn(hippoIframeCtrl, 'contentIsLocked').and.returnValue(true);
+    spyOn(hippoIframeCtrl, 'contentIsLockedByAnother').and.returnValue(true);
 
     const icon = hippoIframeCtrl.getContentLinkIcon({});
 



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/abcb800281a9f4bfeaa172a51ae8c27295890ce8
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to