// Example 1
// Get the coding card object.
var codingCard = review.viewer.mainCollection.codingCards[0].instance;
//---------------
// Example 2
// Change the mode of the coding card.
// Change the mode from view -> edit.
await codingCard.editAsync();
// Change the mode from edit -> view.
await codingCard.cancelAsync();
// Change the reviewMode using the configuration service.
review.configuration.updateSetting("reviewMode", "Edit");
//---------------
// Example 3
// Save the coding card.
// Save
await codingCard.saveAsync();
// Save and Next
await codingCard.saveAndNextAsync();
// Save and Back
await codingCard.saveAndBackAsync();
//---------------
// Example 4
// Use the convenienceAPI object in the Relativity Forms API.
var convenienceAPI = codingCard.getConvenienceAPI();
var documentId = review.viewer.mainCollection.queuePointer.item.artifactId;
var workspaceId = review.configuration.workspaceId;
var formParams = {
workspaceId,
artifactTypeId: 10,
artifactId: documentId,
};
await convenienceAPI.navigation.navigateToForm("edit", formParams);
//---------------
// Example 5
// Add buttons to the toolbar and remove them.
var buttonToAdd = {
id: "_checkoutNextItemButton",
name: "Checkout Next Item",
slotPosition: "left",
visibleMode: [2],
isDisabled: false,
className: "",
order: 2,
onClick: async () => {
const currentIndex = review.viewer.mainCollection.queuePointer.index;
const queueLength = review.viewer.mainCollection.queuePointer.queue.length;
if (currentIndex + 1 === queueLength) {
// Add another item to the end of the queue.
}
await codingCard.saveAndNextAsync();
},
onBuild: () => {
const currentIndex = review.viewer.mainCollection.queuePointer.index;
const queueLength = review.viewer.mainCollection.queuePointer.queue.length;
// Return true, which displays the button, if you're the end of the queue.
return currentIndex === queueLength - 1;
},
};
// Get all the registered buttons.
var codingCardButtons = codingCard.buttons;
// Search for a button.
var saveAndBackButton = codingCardButtons.find((button) => {
return button.id === "_saveAndBackButton";
});
// Make sure the buttonToAdd displays in the same order as the button you removed.
buttonToAdd.order = saveAndBackButton.order;
// Remove the old button.
codingCard.removeButton(saveAndBackButton.id);
// Add a new button.
codingCard.addButton(buttonToAdd);