Skip to content

Commit

Permalink
BXC-4061 updating facet constants and adding handling for events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharon Luong committed Oct 12, 2023
1 parent 0216755 commit 08060d3
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private List<String> determineContentStatus(DocumentIndexingPackage dip)
status.add(FacetConstants.IS_PRIMARY_OBJECT);
}
if (parentResc.hasProperty(Cdr.useAsThumbnail, resc)) {
status.add(FacetConstants.IS_ASSIGNED_THUMBNAIL);
status.add(FacetConstants.ASSIGNED_AS_THUMBNAIL);
}
}

Expand All @@ -75,7 +75,7 @@ private void addWorkObjectStatuses(List<String> status, Resource resource) {
}

if (resource.hasProperty(Cdr.useAsThumbnail)) {
status.add(FacetConstants.THUMBNAIL_ASSIGNED);
status.add(FacetConstants.HAS_THUMBNAIL_ASSIGNED);
} else {
status.add(FacetConstants.NO_THUMBNAIL_ASSIGNED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void testWorkWithAssignedThumbnail() throws Exception {
filter.filter(dip);

verify(idb).setContentStatus(listCaptor.capture());
assertTrue(listCaptor.getValue().contains(FacetConstants.THUMBNAIL_ASSIGNED));
assertTrue(listCaptor.getValue().contains(FacetConstants.HAS_THUMBNAIL_ASSIGNED));
assertFalse(listCaptor.getValue().contains(FacetConstants.NO_THUMBNAIL_ASSIGNED));
}

Expand All @@ -216,6 +216,6 @@ public void testIsAssignedThumbnail() throws Exception {
filter.filter(dip);

verify(idb).setContentStatus(listCaptor.capture());
assertTrue(listCaptor.getValue().contains(FacetConstants.IS_ASSIGNED_THUMBNAIL));
assertTrue(listCaptor.getValue().contains(FacetConstants.ASSIGNED_AS_THUMBNAIL));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public abstract class FacetConstants {
public static final String STAFF_ONLY_ACCESS = "Staff-Only Access";
public static final String MEMBERS_ARE_ORDERED = "Members Are Ordered";
public static final String MEMBERS_ARE_UNORDERED = "Members Are Unordered";
public static final String THUMBNAIL_ASSIGNED = "Has Assigned Thumbnail";
public static final String HAS_THUMBNAIL_ASSIGNED = "Has Assigned Thumbnail";
public static final String NO_THUMBNAIL_ASSIGNED = "No Assigned Thumbnail";
public static final String IS_ASSIGNED_THUMBNAIL = "Is Assigned Thumbnail";
public static final String ASSIGNED_AS_THUMBNAIL = "Assigned As Thumbnail";

}
19 changes: 19 additions & 0 deletions static/js/admin/src/ResultObjectActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ define('ResultObjectActionMenu', [ 'jquery', 'jquery-ui', 'StringUtilities', 'A
} else {
items['setAsPrimaryObject'] = { name : 'Set as Primary Object' };
}
if ($.inArray('Assigned As Thumbnail', metadata.contentStatus) != -1) {
items['clearAssignedThumbnail'] = { name : 'Clear Assigned Thumbnail' };
} else {
items['assignAsThumbnail'] = { name : 'Assign as Thumbnail' };
}
} else if (metadata.type == 'Work') {
if ($.inArray('Has Primary Object', metadata.contentStatus) != -1) {
items['clearPrimaryObject'] = { name : 'Clear Primary Object' };
Expand Down Expand Up @@ -363,6 +368,20 @@ define('ResultObjectActionMenu', [ 'jquery', 'jquery-ui', 'StringUtilities', 'A
confirm : false
});
break;
case "clearAssignedThumbnail" :
self.actionHandler.addEvent({
action : 'ClearAssignedThumbnail',
target : resultObject,
confirm : false
});
break;
case "assignAsThumbnail" :
self.actionHandler.addEvent({
action : 'AssignAsThumbnail',
target : resultObject,
confirm : false
});
break;
case "destroy" :
self.actionHandler.addEvent({
action : 'DestroyResult',
Expand Down
43 changes: 43 additions & 0 deletions static/js/admin/src/action/AssignAsThumbnailAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
define('AssignAsThumbnailAction', [ 'jquery', 'AjaxCallbackAction'], function($, AjaxCallbackAction) {

function AssignAsThumbnailAction(context) {
this._create(context);
};

AssignAsThumbnailAction.prototype.constructor = AssignAsThumbnailAction;
AssignAsThumbnailAction.prototype = Object.create( AjaxCallbackAction.prototype );

AssignAsThumbnailAction.prototype._create = function(context) {
this.context = context;

var options = {
workMethod: "PUT",
workPath: "/services/api/edit/assignThumbnail/{idPath}",
workLabel: "Setting as assigned thumbnail...",
followupLabel: "Setting as assigned thumbnail...",
followupPath: "/services/api/status/item/{idPath}/solrRecord/version"
}

if ('confirm' in this.context && !this.context.confirm) {
options.confirm = false;
} else {
options.confirm = {
promptText : "Use this as the assigned thumbnail for its parent?",
confirmAnchor : this.context.confirmAnchor
};
}

AjaxCallbackAction.prototype._create.call(this, options);
};

AssignAsThumbnailAction.prototype.completeState = function() {
this.context.actionHandler.addEvent({
action : 'RefreshResult',
target : this.context.target
});
this.alertHandler.alertHandler("success", "Assignment of object \"" + this.context.target.metadata.title + "\" as the assigned thumbnail has completed.");
this.context.target.enable();
};

return AssignAsThumbnailAction;
});
43 changes: 43 additions & 0 deletions static/js/admin/src/action/ClearAssignedThumbnailAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
define('ClearAssignedThumbnailAction', [ 'jquery', 'AjaxCallbackAction'], function($, AjaxCallbackAction) {

function ClearAssignedThumbnailAction(context) {
this._create(context);
};

ClearAssignedThumbnailAction.prototype.constructor = ClearAssignedThumbnailAction;
ClearAssignedThumbnailAction.prototype = Object.create( AjaxCallbackAction.prototype );

ClearAssignedThumbnailAction.prototype._create = function(context) {
this.context = context;

var options = {
workMethod: "PUT",
workPath: "/services/api/edit/deleteThumbnail/{idPath}",
workLabel: "Clearing assigned thumbnail...",
followupLabel: "Clearing assigned thumbnail...",
followupPath: "/services/api/status/item/{idPath}/solrRecord/version"
}

if ('confirm' in this.context && !this.context.confirm) {
options.confirm = false;
} else {
options.confirm = {
promptText : "Clear the assigned thumbnail?",
confirmAnchor : this.context.confirmAnchor
};
}

AjaxCallbackAction.prototype._create.call(this, options);
};

ClearAssignedThumbnailAction.prototype.completeState = function() {
this.context.actionHandler.addEvent({
action : 'RefreshResult',
target : this.context.target
});
this.alertHandler.alertHandler("success", "Cleared the assigned thumbnail.");
this.context.target.enable();
};

return ClearAssignedThumbnailAction;
});

0 comments on commit 08060d3

Please sign in to comment.