Skip to content

Commit 64aed98

Browse files
Merge pull request #4690 from LianaHarris360/correct-topic-count
Correct topic count when node kind is not found in clipboardNodesMap
2 parents d078f45 + a3746ad commit 64aed98

File tree

1 file changed

+14
-5
lines changed
  • contentcuration/contentcuration/frontend/channelEdit/components/Clipboard

1 file changed

+14
-5
lines changed

contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/index.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
computed: {
203203
...mapGetters(['clipboardRootId']),
204204
...mapState('clipboard', ['initializing', 'clipboardNodesMap']),
205+
...mapState('contentNode', ['contentNodesMap']),
205206
...mapGetters('clipboard', [
206207
'channels',
207208
'selectedNodeIds',
@@ -248,14 +249,22 @@
248249
topicAndResourceCount() {
249250
let topicCount = 0;
250251
let resourceCount = 0;
252+
const contentNodesValues = Object.values(this.contentNodesMap);
251253
this.selectedNodeIds.forEach(id => {
252-
const kind = this.clipboardNodesMap[id]?.kind;
253-
if (kind === 'topic' || !kind) {
254-
// Increment topicCount if kind is "topic" or not set
254+
const node = this.clipboardNodesMap[id];
255+
let kind = node.kind;
256+
// Check contentNodesMap for node kind if missing in clipboardNodesMap
257+
if (!kind && node.source_node_id) {
258+
const contentNode = contentNodesValues.find(n => n.node_id === node.source_node_id);
259+
kind = contentNode.kind;
260+
}
261+
262+
if (kind === 'topic') {
255263
topicCount++;
256-
} else {
257-
// Increment resourceCount for any other kind
264+
} else if (kind) {
258265
resourceCount++;
266+
} else {
267+
console.error('`kind` missing from content.');
259268
}
260269
});
261270
return { topicCount: topicCount, resourceCount: resourceCount };

0 commit comments

Comments
 (0)