@brightspace-hmc/siren-sdk
Advanced tools
Comparing version 2.38.0 to 2.39.0
{ | ||
"name": "@brightspace-hmc/siren-sdk", | ||
"version": "2.38.0", | ||
"version": "2.39.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -223,3 +223,36 @@ import { Actions, Classes, Rels } from '../../hypermedia-constants.js'; | ||
const fields = [{ name: 'ratingType', value: postRatingSelection }]; | ||
return { action, fields }; | ||
} | ||
/** | ||
* @returns {string} name of the parent forum associated with the discussion topic | ||
*/ | ||
forumName() { | ||
return this._entity && this._entity.properties && this._entity.properties.forumName; | ||
} | ||
/** | ||
* @returns {bool} Whether or not the create and associate with forum action is present on the discussion topic entity | ||
*/ | ||
canCreateAndAssociateWithForum() { | ||
return this._entity && this._entity.hasActionByName(Actions.discussions.topic.createAndAssociateWithForum); | ||
} | ||
/** | ||
* @summary Formats action and fields if topic name has changed and user has edit permission | ||
* @param {object} topic the topic that's being modified | ||
* @returns {object} the appropriate action/fields to update | ||
*/ | ||
_formatCreateAndAssociateWithForumAction(topic) { | ||
const { forumName } = topic || {}; | ||
if (!forumName) return; | ||
if (!this._hasFieldValueChanged(forumName, this.forumName())) return; | ||
if (!this.canCreateAndAssociateWithForum()) return; | ||
const action = this._entity.getActionByName(Actions.discussions.topic.createAndAssociateWithForum); | ||
const fields = [ | ||
{ name: 'forumName', value: forumName }, | ||
]; | ||
return { action, fields }; | ||
@@ -261,2 +294,3 @@ } | ||
const updateRatePostType = this._formatUpdateRatePostAction(topic); | ||
const createAndAssociateWithForumAction = this._formatCreateAndAssociateWithForumAction(topic); | ||
@@ -267,3 +301,4 @@ const sirenActions = [ | ||
syncDraftWithForum, | ||
updateRatePostType | ||
updateRatePostType, | ||
createAndAssociateWithForumAction, | ||
]; | ||
@@ -270,0 +305,0 @@ |
@@ -703,2 +703,3 @@ export const Rels = { | ||
updateRatingType: 'update-ratingtype', | ||
createAndAssociateWithForum: 'create-and-associate-with-forum', | ||
}, | ||
@@ -705,0 +706,0 @@ }, |
352295
9718