Skip to content

Commit 33b1680

Browse files
Manav AggarwalManav Aggarwal
Manav Aggarwal
authored and
Manav Aggarwal
committed
- Enhance IMS Content Package Import UI
1 parent ba1e0d4 commit 33b1680

File tree

7 files changed

+654
-558
lines changed

7 files changed

+654
-558
lines changed

contentcuration/contentcuration/frontend/channelEdit/components/edit/EditList.vue

+44-9
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
class="mb-2 ml-1 mt-0 px-3 py-2"
88
:label="$tr('selectAllLabel')"
99
/>
10-
<EditListItem
11-
v-for="nodeId in nodeIds"
12-
:key="nodeId"
10+
<EditListItems
1311
v-model="selected"
14-
:nodeId="nodeId"
12+
:nodeId="parentId"
13+
:nodes="nodes"
14+
:nodeIds="nodeIds"
1515
@input="trackSelect"
1616
@removed="handleRemoved"
1717
/>
@@ -22,13 +22,14 @@
2222

2323
<script>
2424
25-
import EditListItem from './EditListItem';
25+
import { mapGetters } from 'vuex';
26+
import EditListItems from './EditListItems';
2627
import Checkbox from 'shared/views/form/Checkbox';
2728
2829
export default {
2930
name: 'EditList',
3031
components: {
31-
EditListItem,
32+
EditListItems,
3233
Checkbox,
3334
},
3435
props: {
@@ -40,14 +41,25 @@
4041
type: Array,
4142
default: () => [],
4243
},
44+
parentId: {
45+
type: String,
46+
require: true,
47+
default: null,
48+
},
4349
},
4450
computed: {
51+
...mapGetters('contentNode', ['getContentNode']),
4552
selected: {
4653
get() {
4754
return this.value;
4855
},
4956
set(items) {
50-
this.$emit('input', items);
57+
if (this.selected.includes(items[0])) {
58+
this.selected = [];
59+
} else {
60+
this.getChildren(items[0]).forEach(item => items.push(item));
61+
this.$emit('input', items);
62+
}
5163
},
5264
},
5365
selectAll: {
@@ -63,11 +75,34 @@
6375
}
6476
},
6577
},
78+
nodes() {
79+
const nodes = {};
80+
this.nodeIds.forEach(nodeId => {
81+
const parentId = this.getContentNode(nodeId).parent;
82+
nodes[`${nodeId}`] = this.nodeIds.includes(parentId) ? parentId : null;
83+
});
84+
return nodes;
85+
},
6686
},
6787
methods: {
88+
...mapGetters('contentNode', ['deleteContentNode']),
89+
getChildren(parent) {
90+
const childrens = [];
91+
Object.keys(this.nodes).forEach(nodeId => {
92+
if (this.nodes[nodeId] === parent) {
93+
childrens.push(...this.getChildren(nodeId));
94+
childrens.push(nodeId);
95+
}
96+
});
97+
return childrens;
98+
},
6899
handleRemoved(nodeId) {
69-
const nodeIds = this.$route.params.detailNodeIds.split(',').filter(id => id !== nodeId);
70-
100+
const removedNodes = this.getChildren(nodeId);
101+
removedNodes.push(nodeId);
102+
removedNodes.forEach(nodeId => this.deleteContentNode(nodeId));
103+
const nodeIds = this.$route.params.detailNodeIds
104+
.split(',')
105+
.filter(id => !removedNodes.includes(id));
71106
this.$router.push({
72107
name: this.$route.name,
73108
params: {

contentcuration/contentcuration/frontend/channelEdit/components/edit/EditListItem.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
<script>
7373
74-
import { mapActions, mapGetters } from 'vuex';
74+
import { mapGetters } from 'vuex';
7575
import { RouteNames } from '../../constants';
7676
import { fileSizeMixin, fileStatusMixin } from 'shared/mixins';
7777
import ContentNodeIcon from 'shared/views/ContentNodeIcon';
@@ -166,11 +166,8 @@
166166
},
167167
},
168168
methods: {
169-
...mapActions('contentNode', ['deleteContentNode']),
170169
removeNode() {
171-
this.deleteContentNode(this.nodeId).then(() => {
172-
this.$emit('removed', this.nodeId);
173-
});
170+
this.$emit('removed', this.nodeId);
174171
},
175172
},
176173
$trs: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<template>
2+
3+
<VList two-line class="pl-3">
4+
<EditListItem
5+
:key="nodeId"
6+
v-model="selected"
7+
:nodeId="nodeId"
8+
@input="trackSelect"
9+
@removed="handleRemoved"
10+
/>
11+
<div v-if="getChildren !== undefined">
12+
<EditListItems
13+
v-for="childId in getChildren"
14+
:key="childId"
15+
v-model="selected"
16+
:nodeId="childId"
17+
:nodes="nodes"
18+
:nodeIds="nodeIds"
19+
@input="trackSelect"
20+
@removed="handleRemoved"
21+
/>
22+
</div>
23+
</VList>
24+
25+
</template>
26+
27+
<script>
28+
29+
import EditListItem from './EditListItem';
30+
31+
export default {
32+
name: 'EditListItems',
33+
components: {
34+
EditListItem,
35+
},
36+
props: {
37+
value: {
38+
type: Array,
39+
default: () => [],
40+
},
41+
nodeIds: {
42+
type: Array,
43+
default: () => [],
44+
},
45+
nodeId: {
46+
type: String,
47+
require: true,
48+
default: null,
49+
},
50+
nodes: {
51+
type: Object,
52+
default: () => {},
53+
},
54+
},
55+
computed: {
56+
selected: {
57+
get() {
58+
return this.value;
59+
},
60+
set(items) {
61+
this.$emit('input', items);
62+
},
63+
},
64+
getChildren() {
65+
const childrens = [];
66+
Object.keys(this.nodes).forEach(nodeId => {
67+
if (this.nodes[nodeId] === this.nodeId) {
68+
childrens.push(nodeId);
69+
}
70+
});
71+
return childrens;
72+
},
73+
},
74+
methods: {
75+
handleRemoved(nodeId) {
76+
this.$emit('removed', nodeId);
77+
},
78+
trackSelect(value) {
79+
this.$emit('input', value);
80+
},
81+
},
82+
};
83+
84+
</script>
85+
86+
<style lang="less" scoped>
87+
88+
.v-divider {
89+
margin-top: 0;
90+
}
91+
92+
</style>

0 commit comments

Comments
 (0)