{"version":3,"sources":["../js/Annotations/AnnotationStatus.js"],"names":["AnnotationStatus","this","id","g_iApprovalUserAnnotId","g_iAuthor","g_szAuthorEmail","g_szAuthorDisplayName","g_iAnnotationStatus","annotationStatusDateTime","prototype","annotationSaveStatus","annotation","oThisAnnotation","oThisAnnotationStatus","oAnnotationStatus","annotationId","approvalUserId","annotationStatus","annotationstatusId","oJSON","szSessionId","g_oAnnotations","c_szSessionId","iUserId","g_oUserDetails","UserId","$","ajax","type","url","data","JSON","stringify","contentType","dataType","success","response","g_oAnnotationViewer","redraw","remove","length","g_oActiveBubbles","i","g_oGreenlightMessages","closeBubble","updateAnnotationStatusId","g_bSVGTextAnnotation","g_oSVGText","applySVGStatusUpdate","displaySuccessBubble","c_szAnnotationStatusSavedSuccessfully","g_oAnnotationHub","server","send","g_iApprovalId","EmailAddress","failure","displayErrorBubble","c_szAnnotationFailedtoSave","error","deleteAnnotationStatus","statusId","artworkCanvas","annotationCanvas","rebuildAnnotationList","showSuccessBubble","updateSVGText","iArrayReplyPosition","g_oStatuses","sessionId","userId","annotationStatusId","annotationStatusCode","splice","find","parent","canAnnotationBeDeleted","insertDeleteButton","c_szAnnotationStatusDeletedSuccessfully","c_szAnnotationStatusDeletedFail","tempId","oReturnedStatus","parse","Contents","that","oMatchingAnnotation","grep","g_oAnnotationsMade","window"],"mappings":"CAkBC,WACA,aAKA,SAASA,mBACRC,KAAKC,IAAM,EACXD,KAAKE,uBAAyB,EAC9BF,KAAKG,UAAY,EACjBH,KAAKI,gBAAkB,GACvBJ,KAAKK,sBAAwB,GAC7BL,KAAKM,oBAAsB,EAC3BN,KAAKO,yBAA2B,KAWjCR,iBAAiBS,UAAUC,qBAAuB,SAAUC,YAG3D,IAAIC,gBAAkBD,WAClBE,sBAAwBZ,KAGxBa,kBAAoB,CACvBC,aAAcF,sBAAsBV,uBACpCa,eAAgBH,sBAAsBT,UACtCa,iBAAkBJ,sBAAsBN,oBACxCC,yBAA0B,GAC1BU,mBAAoBL,sBA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GAAGjB,YAAY1B,GAAGxC,GAAK+E,gBAAgB/D,mBAC3D,QAMHsE,OAAOxF,iBAAmBA,iBAlN3B","file":"AnnotationStatus-a2b4a9f6a3.js","sourcesContent":["/*\r\n * Copyright (c) 2018 SGS Europe. All rights reserved.\r\n *\r\n * This program is the CONFIDENTIAL and PROPRIETARY property of 2018 SGS Europe.\r\n * Any unauthorised use, reproduction, or transfer of this program is strictly\r\n * prohibited.\r\n *\r\n * File Name:\tAnnotationStatus.js\r\n *\r\n * Description:\tEncapsulates the Annotation Status JavaScript.\r\n *\r\n * History:\t\t12-FEB-18\tJ Fuller\t\tInitial implementation.\r\n *\t\t\t\t30-JUL-18\tP Dickson\t\tUpdated to pass through the session id.\r\n *\t\t\t\t08-OCT-18 R Pavolas Refactored bubble calls. (DR158989)\r\n *\t\t\t\t20-JAN-20\tS Norman\t\tAjax requests routing changed to use internal as part of UserStory 43113 - Upload Documents to Annotations.\r\n *\r\n */\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\t/**\r\n\t * Prototype for holding an annotation Status.\r\n\t */\r\n\tfunction AnnotationStatus() {\r\n\t\tthis.id = -1;\r\n\t\tthis.g_iApprovalUserAnnotId = 0;\r\n\t\tthis.g_iAuthor = 0;\r\n\t\tthis.g_szAuthorEmail = \"\";\r\n\t\tthis.g_szAuthorDisplayName = \"\";\r\n\t\tthis.g_iAnnotationStatus = 0;\r\n\t\tthis.annotationStatusDateTime = null;\r\n\t};\r\n\r\n\t/*\r\n\t * - - - P U B L I C M E T H O D S - - -\r\n\t */\r\n\r\n\t/**\r\n\t * Saves a new annotation save.\r\n\t * @param {type} callerType\r\n\t */\r\n\tAnnotationStatus.prototype.annotationSaveStatus = function (annotation) {\r\n\t\t\r\n\t\t// Copy the annotation and status.\r\n\t\tvar oThisAnnotation = annotation;\r\n\t\tvar oThisAnnotationStatus = this;\r\n\r\n\t\t// Create the annotation status object.\r\n\t\tvar oAnnotationStatus = {\r\n\t\t\tannotationId: oThisAnnotationStatus.g_iApprovalUserAnnotId,\r\n\t\t\tapprovalUserId: oThisAnnotationStatus.g_iAuthor,\r\n\t\t\tannotationStatus: oThisAnnotationStatus.g_iAnnotationStatus,\r\n\t\t\tannotationStatusDateTime: \"\",\r\n\t\t\tannotationstatusId: oThisAnnotationStatus.id\r\n\t\t};\r\n\r\n\t\t// Build up the JSON object.\r\n\t\tvar oJSON = {\r\n\t\t\tszSessionId: g_oAnnotations.c_szSessionId,\r\n\t\t\tiUserId: g_oUserDetails.UserId,\r\n\t\t\toAnnotationStatus: oAnnotationStatus\r\n\t\t};\r\n\r\n\t\t// Send the annotation to the server.\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"internal/GreenlightAnnotation/SaveAnnotationStatus\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\r\n\t\t\t\t// Redraw the annotations.\r\n\t\t\t\tg_oAnnotations.g_oAnnotationViewer.redraw(false);\r\n\r\n\t\t\t\t// Remove list delete icon.\r\n\t\t\t\t$(\"#li_\" + oThisAnnotationStatus.g_iApprovalUserAnnotId + \"_del\").remove();\r\n\r\n\t\t\t\t// Remove the delete icon from the bubble.\r\n\t\t\t\tif ($(\"#\" + oThisAnnotationStatus.g_iApprovalUserAnnotId + \"_del\").length > 0) {\r\n\t\t\t\t\t$(\"#\" + oThisAnnotationStatus.g_iApprovalUserAnnotId + \"_del\").remove();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Close any open delete confirmation bubbles.\r\n\t\t\t\tif (g_oActiveBubbles.length > 0) {\r\n\t\t\t\t\t// Find the confirm bubble.\r\n\t\t\t\t\tfor (var i = 0; i < g_oActiveBubbles.length; i++) {\r\n\t\t\t\t\t\tif (g_oActiveBubbles[i].type == \"Confirm\") {\r\n\t\t\t\t\t\t\tg_oGreenlightMessages.closeBubble(g_oActiveBubbles[i].id, true, true);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Update the id of the annotation status.\r\n\t\t\t\toThisAnnotationStatus.updateAnnotationStatusId(response, oThisAnnotationStatus.id);\r\n\r\n\t\t\t\t// If this is an svg text annotation.\r\n\t\t\t\tif (oThisAnnotation.g_bSVGTextAnnotation) {\r\n\r\n\t\t\t\t\t// Update the svg text based on the status.\r\n\t\t\t\t\tg_oSVGText.applySVGStatusUpdate(oThisAnnotation);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Display the success bubble.\r\n\t\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oAnnotations.c_szAnnotationStatusSavedSuccessfully);\r\n\r\n\t\t\t\t// Push this change to other users.\r\n\t\t\t\tg_oAnnotations.g_oAnnotationHub.server.send(g_oAnnotations.g_iApprovalId, g_oUserDetails.EmailAddress);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Removes an annotation status from an annotation.\r\n\t * @param {object} annotation - The annotation to have the status removed from.\r\n\t * @param {int} statusId - The id of the status to be deleted.\r\n\t * @param {object} artworkCanvas - The artwork canvas.\r\n\t * @param {object} annotationCanvas - The annotation canvas.\r\n\t * @param {bool} rebuildAnnotationList - If the annotation list should be rebuilt.\r\n\t * @param {bool} updateSVGText - If we should update any svg text.\r\n\t */\r\n\tAnnotationStatus.prototype.deleteAnnotationStatus = function (annotation, statusId, artworkCanvas, annotationCanvas, rebuildAnnotationList, showSuccessBubble, updateSVGText) {\r\n\r\n\t\t// Determine the position of the reply to be removed.\r\n\t\tvar iArrayReplyPosition = -1;\r\n\t\tfor (var i = 0; i < annotation.g_oStatuses.length; i++) {\r\n\t\t\tif (annotation.g_oStatuses[i].id == statusId) {\r\n\t\t\t\tiArrayReplyPosition = i;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If we have failed to get a valid position, return.\r\n\t\tif (iArrayReplyPosition == -1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Get the information for the annotation status to be deleted.\r\n\t\tvar oJSON = {\r\n\t\t\tsessionId: g_oAnnotations.c_szSessionId,\r\n\t\t\tannotationId: annotation.id,\r\n\t\t\tuserId: g_oUserDetails.UserId,\r\n\t\t\tannotationStatusId: annotation.g_oStatuses[iArrayReplyPosition].id,\r\n\t\t\tannotationStatusCode: annotation.g_oStatuses[iArrayReplyPosition].g_iAnnotationStatus\r\n\t\t};\r\n\r\n\t\t// Send to the server.\r\n\t\t$.ajax({\r\n\t\t\ttype: \"DELETE\",\r\n\t\t\turl: \"internal/GreenlightAnnotation/DeleteAnnotationStatus\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tsuccess: function () {\r\n\t\t\t\t\r\n\t\t\t\t// Remove the status from the JavaScript.\r\n\t\t\t\tannotation.g_oStatuses.splice(iArrayReplyPosition, 1);\r\n\r\n\t\t\t\t// Clean up the annotation popup if it exists.\r\n\t\t\t\tif ($(\"#sc_\" + annotation.id).length) {\r\n\r\n\t\t\t\t\t// Remove this annotation status from the bubble.\r\n\t\t\t\t\tif ($(\"#sc_\" + annotation.id).find(\".status[data-authorid='\" + g_oUserDetails.UserId + \"']\").length) {\r\n\t\t\t\t\t\t$(\"#sc_\" + annotation.id).find(\".status[data-authorid='\" + g_oUserDetails.UserId + \"']\").parent().remove();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Re-add the delete button if we can.\r\n\t\t\t\t\tif (g_oAnnotations.canAnnotationBeDeleted(annotation.id)) {\r\n\t\t\t\t\t\tg_oAnnotations.insertDeleteButton(annotation.id);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Re-build the annotation list if required.\r\n\t\t\t\tif (rebuildAnnotationList) {\r\n\t\t\t\t\tg_oAnnotations.rebuildAnnotationList(artworkCanvas, annotationCanvas);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If this is an svg text annotation.\r\n\t\t\t\tif (updateSVGText && annotation.g_bSVGTextAnnotation) {\r\n\r\n\t\t\t\t\t// Update the svg text based on the status.\r\n\t\t\t\t\tg_oSVGText.applySVGStatusUpdate(annotation);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Display the success message if required.\r\n\t\t\t\tif (showSuccessBubble) {\r\n\t\t\t\t\tg_oGreenlightMessages.displaySuccessBubble(g_oAnnotations.c_szAnnotationStatusDeletedSuccessfully);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Push this change to other users.\r\n\t\t\t\tg_oAnnotations.g_oAnnotationHub.server.send(g_oAnnotations.g_iApprovalId, g_oUserDetails.EmailAddress);\r\n\t\t\t},\r\n\t\t\tfailure: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationStatusDeletedFail);\r\n\t\t\t},\r\n\t\t\terror: function () {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationStatusDeletedFail);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n\t/**\r\n\t * Updates an annotation status Id after saving.\r\n\t * @param {object} response - The JSON content object.\r\n\t * @param {int} tempId - The (possibly) temporary Id given to the status.\r\n\t */\r\n\tAnnotationStatus.prototype.updateAnnotationStatusId = function (response, tempId) {\r\n\t\tvar oReturnedStatus = JSON.parse(response.Contents);\r\n\t\tvar that = this;\r\n\t\t// Find the annotation the status belongs to.\r\n\t\tvar oMatchingAnnotation = $.grep(g_oAnnotations.g_oAnnotationsMade, function (annotation) { return annotation.id == that.g_iApprovalUserAnnotId; });\r\n\r\n\t\tfor (var i = 0; i < oMatchingAnnotation[0].g_oStatuses.length; i++) {\r\n\t\t\tif (oMatchingAnnotation[0].g_oStatuses[i].id == tempId) {\r\n\t\t\t\toMatchingAnnotation[0].g_oStatuses[i].id = oReturnedStatus.annotationstatusId;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t// Add the Annotation UI object to the window.\r\n\twindow.AnnotationStatus = AnnotationStatus;\r\n\r\n}());"]}