adapt-authoring-content 2.1.5 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ContentModule.js +12 -12
- package/package.json +1 -1
package/lib/ContentModule.js
CHANGED
|
@@ -115,8 +115,8 @@ class ContentModule extends AbstractApiModule {
|
|
|
115
115
|
return this.update({ _id: doc._id }, { _courseId: doc._id.toString() })
|
|
116
116
|
}
|
|
117
117
|
await Promise.all([
|
|
118
|
-
options.updateSortOrder !== false && this.updateSortOrder(doc, data),
|
|
119
|
-
options.updateEnabledPlugins !== false && this.updateEnabledPlugins(doc)
|
|
118
|
+
options.updateSortOrder !== false && this.updateSortOrder(doc, data, options, mongoOptions),
|
|
119
|
+
options.updateEnabledPlugins !== false && this.updateEnabledPlugins(doc, {}, options, mongoOptions)
|
|
120
120
|
])
|
|
121
121
|
return doc
|
|
122
122
|
}
|
|
@@ -133,8 +133,8 @@ class ContentModule extends AbstractApiModule {
|
|
|
133
133
|
throw e
|
|
134
134
|
}
|
|
135
135
|
await Promise.all([
|
|
136
|
-
this.updateSortOrder(doc, data),
|
|
137
|
-
this.updateEnabledPlugins(doc, data._enabledPlugins ? { forceUpdate: true } : {})
|
|
136
|
+
this.updateSortOrder(doc, data, options, mongoOptions),
|
|
137
|
+
this.updateEnabledPlugins(doc, data._enabledPlugins ? { forceUpdate: true } : {}, options, mongoOptions)
|
|
138
138
|
])
|
|
139
139
|
return doc
|
|
140
140
|
}
|
|
@@ -151,11 +151,11 @@ class ContentModule extends AbstractApiModule {
|
|
|
151
151
|
const descendants = await getDescendants(q => this.find(q), targetDoc)
|
|
152
152
|
|
|
153
153
|
await Promise.all([...descendants, targetDoc].map(d => {
|
|
154
|
-
return super.delete({ _id: d._id })
|
|
154
|
+
return super.delete({ _id: d._id }, options, mongoOptions)
|
|
155
155
|
}))
|
|
156
156
|
await Promise.all([
|
|
157
|
-
this.updateEnabledPlugins(targetDoc),
|
|
158
|
-
this.updateSortOrder(targetDoc)
|
|
157
|
+
this.updateEnabledPlugins(targetDoc, {}, options, mongoOptions),
|
|
158
|
+
this.updateSortOrder(targetDoc, undefined, options, mongoOptions)
|
|
159
159
|
])
|
|
160
160
|
return [targetDoc, ...descendants]
|
|
161
161
|
}
|
|
@@ -272,7 +272,7 @@ class ContentModule extends AbstractApiModule {
|
|
|
272
272
|
* @param {Object} updateData The update data
|
|
273
273
|
* @return {Promise}
|
|
274
274
|
*/
|
|
275
|
-
async updateSortOrder (item, updateData) {
|
|
275
|
+
async updateSortOrder (item, updateData, parentOptions, parentMongoOptions) {
|
|
276
276
|
// some exceptions which don't need a _sortOrder
|
|
277
277
|
if (item._type === 'config' || item._type === 'course' || !item._parentId) {
|
|
278
278
|
return
|
|
@@ -284,7 +284,7 @@ class ContentModule extends AbstractApiModule {
|
|
|
284
284
|
}
|
|
285
285
|
return Promise.all(siblings.map(async (s, i) => {
|
|
286
286
|
const _sortOrder = i + 1
|
|
287
|
-
if (s._sortOrder !== _sortOrder) return super.update({ _id: s._id }, { _sortOrder })
|
|
287
|
+
if (s._sortOrder !== _sortOrder) return super.update({ _id: s._id }, { _sortOrder }, parentOptions, parentMongoOptions)
|
|
288
288
|
}))
|
|
289
289
|
}
|
|
290
290
|
|
|
@@ -295,7 +295,7 @@ class ContentModule extends AbstractApiModule {
|
|
|
295
295
|
* @param {Boolean} options.forceUpdate Forces an update of defaults regardless of whether the _enabledPlugins list has changed
|
|
296
296
|
* @return {Promise}
|
|
297
297
|
*/
|
|
298
|
-
async updateEnabledPlugins ({ _courseId }, options = {}) {
|
|
298
|
+
async updateEnabledPlugins ({ _courseId }, options = {}, parentOptions, parentMongoOptions) {
|
|
299
299
|
const [contentplugin, jsonschema] = await this.app.waitForModule('contentplugin', 'jsonschema')
|
|
300
300
|
const contentItems = await this.find({ _courseId })
|
|
301
301
|
const config = contentItems.find(c => c._type === 'config')
|
|
@@ -330,12 +330,12 @@ class ContentModule extends AbstractApiModule {
|
|
|
330
330
|
}, types)
|
|
331
331
|
}, [])
|
|
332
332
|
// update config._enabledPlugins
|
|
333
|
-
await super.update({ _courseId, _type: 'config' }, { _enabledPlugins })
|
|
333
|
+
await super.update({ _courseId, _type: 'config' }, { _enabledPlugins }, parentOptions, parentMongoOptions)
|
|
334
334
|
// update other affected content objects to ensure new defaults are applied
|
|
335
335
|
// note: due to the complex data, each must be updated separately rather than using updateMany
|
|
336
336
|
if (types.length > 0) {
|
|
337
337
|
const toUpdate = await super.find({ _courseId, _type: { $in: types } }, {})
|
|
338
|
-
return Promise.all(toUpdate.map(c => super.update({ _id: c._id }, {})))
|
|
338
|
+
return Promise.all(toUpdate.map(c => super.update({ _id: c._id }, {}, parentOptions, parentMongoOptions)))
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
|