@brightspace-hmc/siren-sdk
Advanced tools
Comparing version 2.40.0 to 2.41.0
{ | ||
"name": "@brightspace-hmc/siren-sdk", | ||
"version": "2.40.0", | ||
"version": "2.41.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -125,2 +125,15 @@ import { Actions, Classes } from '../hypermedia-constants.js'; | ||
_generateDeletePreviousAndAssociateWithNewCategory(category, shouldDeletePreviousCategory) { | ||
const categoryEntity = this._getCategoryById(category.categoryId); | ||
if (!categoryEntity) return; | ||
const action = shouldDeletePreviousCategory && categoryEntity.getActionByName(Actions.activities.categories.deletePreviousAndAssociateWithNewCategory); | ||
if (!action) return; | ||
const fields = [ | ||
{ name: 'deletePreviousCategory', value: shouldDeletePreviousCategory } | ||
]; | ||
return { action, fields }; | ||
} | ||
_hasCategoryIdChanged(categoryId) { | ||
@@ -133,7 +146,9 @@ const selectedCategory = this.getSelectedCategory(); | ||
async save(category) { | ||
async save(category, shouldDeletePreviousCategory = false) { | ||
const hasCategoryIdChanged = category.categoryId && this._hasCategoryIdChanged(category.categoryId); | ||
if (hasCategoryIdChanged && category.categoryId !== UNSET_CATEGORY_ID) { | ||
const { action, fields } = this._generateSelectCategoryAction(category) || {}; | ||
const { action, fields } = shouldDeletePreviousCategory | ||
? this._generateDeletePreviousAndAssociateWithNewCategory(category, shouldDeletePreviousCategory) || {} | ||
: this._generateSelectCategoryAction(category) || {}; | ||
@@ -140,0 +155,0 @@ return action && await performSirenAction(this._token, action, fields); |
@@ -583,3 +583,4 @@ export const Rels = { | ||
deselect: 'deselect', | ||
add: 'add' | ||
add: 'add', | ||
deletePreviousAndAssociateWithNewCategory: 'delete-previous-and-associate-with-new-category', | ||
}, | ||
@@ -586,0 +587,0 @@ create: 'create', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
353077
9724