From 06f82774dea47afb4bb5e2f3ade85f488add2c44 Mon Sep 17 00:00:00 2001 From: Pradeep Kumar <56213738+pradeep-017@users.noreply.github.com> Date: Wed, 19 Jan 2022 08:22:24 -0700 Subject: [PATCH] [VSPC-199] Fixed the link issue with null targetSpace (#272) * [VSPC-199] Fixed the link issue with null targetSpace * [VSPC-199] Making changes more DRY * [VSPC-199] reverse OR arguments * [VSPC-199] Added title for inactive links Co-authored-by: Julia Damerow --- .../WEB-INF/views/staff/spaces/space.html | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html b/vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html index cbe09501f..acf6fd02c 100644 --- a/vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html +++ b/vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html @@ -62,18 +62,31 @@ modalLink.css('font-size', "12px"); var positionX = isModal ? posXModal : posX; var positionY = isModal ? posYModal : posY; - if(isSpaceLink && link.link.targetSpace.spaceStatus=="UNPUBLISHED"){ - var unpublishedSpaceElement = $('') - unpublishedSpaceElement.css('position', 'absolute'); - unpublishedSpaceElement.css('left', link.positionX + positionX + displaceUnpublishedOnX); - unpublishedSpaceElement.css('top', link.positionY + positionY - displaceUnpublishedOnY); - unpublishedSpaceElement.css('transform', 'rotate('+link.rotation+'deg)'); - unpublishedSpaceElement.css('font-size', "24px"); - if(isModal){ - $("#space").append(unpublishedSpaceElement); - }else{ - $("#main-space").append(unpublishedSpaceElement); - } + if(isSpaceLink && (link.link.targetSpace==null || link.link.targetSpace.spaceStatus=="UNPUBLISHED")){ + var inactiveLinkId; + var inactiveLinkClasses; + var inactiveLinkTitle; + if(link.link.targetSpace==null) { + inactiveLinkId = "deletedSpace-"; + inactiveLinkClasses = "deletedSpaceClass deletedClass-"; + inactiveLinkTitle = "The target space for this link has been deleted. This link won't be shown on the public site." + } else { + inactiveLinkId = "unpublished-"; + inactiveLinkClasses = "unpublishedSpaceClass unpublishedClass-"; + inactiveLinkTitle = "The target space for this link is unpublished. This link won't be shown on the public site." + } + var inactiveSpaceElement = $('') + inactiveSpaceElement.css('position', 'absolute'); + inactiveSpaceElement.css('left', link.positionX + positionX + displaceUnpublishedOnX); + inactiveSpaceElement.css('top', link.positionY + positionY - displaceUnpublishedOnY); + inactiveSpaceElement.css('transform', 'rotate('+link.rotation+'deg)'); + inactiveSpaceElement.css('font-size', "24px"); + inactiveSpaceElement.attr('title', inactiveLinkTitle); + if(isModal){ + $("#space").append(inactiveSpaceElement); + } else{ + $("#main-space").append(inactiveSpaceElement); + } } var linkId = isExternalLink ? link.externalLink.id : link.link.id; setLabelPosition(link,linkId,positionX,positionY); @@ -90,14 +103,14 @@ if(link != null){ var spaceLink; if(link.type == "ALERT"){ - spaceLink = $('

'+link.link.name+'

'); + spaceLink = $('

'+link.link.name+'

'); } else if(link.type == "IMAGE" && link.image != null){ var spaceImageURL = [[@{/api/image/}]]+link.image.id; - spaceLink = $(''); + spaceLink = $(''); } else{ - spaceLink = $('

'+link.link.name+'

'); + spaceLink = $('

'+link.link.name+'

'); } setLinkPosition(spaceLink,link,true,isModal,false, posX, posY, posXModal, posYModal); $(divId).append(spaceLink); @@ -164,6 +177,7 @@ $(".alertLink").remove(); $(".ellipse_class").remove(); $(".unpublishedSpaceClass").remove(); + $(".deletedSpaceClass").remove(); $.ajax({ type: "GET", @@ -1963,4 +1977,4 @@