-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bxc 4061 assigned thumbnail UI (#1616)
* BXC-4061 updating facet constants and adding handling for events * BXC-4061 adding help text * BXC-4061 fix backend of assigning thumbnail dropdown selection and clear thumbnail selection * BXC-4061 get js working * BXC-4061 making sure ajax waits to update row until item is updated in solr * BXC-4061 this isn't quite working right yet but close * Retrieve old thumbnail id before clearing the property, otherwise we generally won't get an id back. Adjust when refreshes happen * BXC-4061 make sure no assigned thumbnail tag is hidden in frontend * BXC-4061 fix codeclimate and update tests * BXC-4061 updating tests and adding handling for delete case without assigned thumbnail * BXC-4061 collapse nested if statement to make codeclimate happy --------- Co-authored-by: Sharon Luong <[email protected]> Co-authored-by: Ben Pennell <[email protected]>
- Loading branch information
1 parent
896fceb
commit 13949d4
Showing
13 changed files
with
333 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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(); | ||
}; | ||
|
||
AssignAsThumbnailAction.prototype.workDone = function(data) { | ||
this.completeTimestamp = data.timestamp; | ||
this.oldThumbnailId = data.oldThumbnailId; | ||
this.newThumbnailId = data.newThumbnailId; | ||
if (this.oldThumbnailId) { | ||
this.context.actionHandler.addEvent({ | ||
action : 'RefreshResult', | ||
target : this.context.resultTable.resultObjectList.getResultObject(this.oldThumbnailId), | ||
waitForUpdate : true | ||
}); | ||
} | ||
return true; | ||
}; | ||
|
||
AssignAsThumbnailAction.prototype.followup = function(data) { | ||
if (data) { | ||
return this.context.target.updateVersion(data); | ||
} | ||
return false; | ||
}; | ||
|
||
return AssignAsThumbnailAction; | ||
}); |
66 changes: 66 additions & 0 deletions
66
static/js/admin/src/action/ClearAssignedThumbnailAction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
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: "DELETE", | ||
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(); | ||
}; | ||
|
||
ClearAssignedThumbnailAction.prototype.workDone = function(data) { | ||
this.completeTimestamp = data.timestamp; | ||
this.oldThumbnailId = data.oldThumbnailId; | ||
if (this.context.target.metadata.type == "Work") { | ||
var oldThumbnail = this.context.resultTable.resultObjectList.getResultObject(this.oldThumbnailId); | ||
if (oldThumbnail != null) { | ||
this.context.actionHandler.addEvent({ | ||
action : 'RefreshResult', | ||
target : oldThumbnail, | ||
waitForUpdate : true | ||
}); | ||
} | ||
} | ||
return true; | ||
}; | ||
|
||
ClearAssignedThumbnailAction.prototype.followup = function(data) { | ||
if (data) { | ||
return this.context.target.updateVersion(data); | ||
} | ||
return false; | ||
}; | ||
|
||
return ClearAssignedThumbnailAction; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.