|
188 | 188 | scope.hasVisibletasks = false; |
189 | 189 | scope.doiServers = []; |
190 | 190 | scope.status = undefined; |
| 191 | + scope.anonymousAccessExists = false; |
191 | 192 |
|
192 | 193 | scope.statusEffects = { |
193 | 194 | editor: [ |
|
288 | 289 | ); |
289 | 290 | }; |
290 | 291 |
|
| 292 | + /** |
| 293 | + * Display the anonymous access option. |
| 294 | + * |
| 295 | + * Checks: |
| 296 | + * - The user is logged in. |
| 297 | + * - The user is administrator or more. |
| 298 | + * - The metadata record is not null. |
| 299 | + * - The metadata is not published. |
| 300 | + * |
| 301 | + * @param {Object} md - The metadata record to check. |
| 302 | + * @param {Object} user - The user for whom the check is being performed. |
| 303 | + * @param {Object} pubOption - The publication option to check against. |
| 304 | + * @returns {boolean} - True if the anonymous access option should be displayed, false otherwise. |
| 305 | + */ |
| 306 | + scope.displayAnonymousAccessOption = function (md, user, pubOption) { |
| 307 | + return ( |
| 308 | + user.id && user.isAdministratorOrMore() && md && !md.isPublished(pubOption) |
| 309 | + ); |
| 310 | + }; |
| 311 | + |
291 | 312 | scope.displayWorkflowStepOption = function (step, user) { |
292 | 313 | return ( |
293 | 314 | user.id && |
|
363 | 384 | scope.md = md; |
364 | 385 | scope.doiServers = []; |
365 | 386 | scope.ownerGroupName = undefined; |
| 387 | + scope.anonymousAccessExists = false; |
366 | 388 |
|
367 | 389 | if (md) { |
368 | 390 | $http.get("../api/doiservers/metadata/" + md.id).then(function (response) { |
369 | 391 | scope.doiServers = response.data; |
370 | 392 | }); |
371 | 393 |
|
| 394 | + $http |
| 395 | + .get("../api/anonymousAccessLink/" + md.uuid) |
| 396 | + .then(function (response) { |
| 397 | + scope.anonymousAccessExists = response.data; |
| 398 | + }); |
| 399 | + |
372 | 400 | if (md.groupOwner) { |
373 | 401 | gnMetadataActions.getGroupName(md.groupOwner).then(function (name) { |
374 | 402 | scope.ownerGroupName = name; |
|
389 | 417 | loadTasks(); |
390 | 418 | loadWorkflowStatus(); |
391 | 419 |
|
| 420 | + scope.$on("AnonymousAccessCreated", function () { |
| 421 | + scope.anonymousAccessExists = true; |
| 422 | + }); |
| 423 | + |
| 424 | + scope.$on("AnonymousAccessDeleted", function () { |
| 425 | + scope.anonymousAccessExists = false; |
| 426 | + }); |
| 427 | + |
392 | 428 | watchRecord( |
393 | 429 | scope, |
394 | 430 | attrs.gnManageRecordMenu || "mdView.current.record", |
|
0 commit comments