Skip to content

Commit 0570b57

Browse files
authored
Merge pull request #1928 from christianmemije/deletechannels
Delete actually selected channel
2 parents 2f5525d + 3719bd6 commit 0570b57

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

kolibri/plugins/management/assets/src/views/manage-content-page/channels-grid.vue

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</thead>
1919

2020
<tbody class="table-body">
21-
<tr v-for="(channel, idx) in sortedChannels">
21+
<tr v-for="channel in sortedChannels" :key="channel.id">
2222
<td class="table-cell-title">
2323
{{ channel.title }}
2424
</td>
@@ -48,7 +48,7 @@
4848
</td>
4949
<td>
5050
<button
51-
@click="selectedChannelIdx=idx"
51+
@click="selectedChannelId=channel.id"
5252
class="delete-button"
5353
>
5454
{{ $tr('deleteButtonLabel') }}
@@ -63,7 +63,7 @@
6363
v-if="channelIsSelected"
6464
:channelTitle="selectedChannelTitle"
6565
@confirm="handleDeleteChannel()"
66-
@cancel="selectedChannelIdx=null"
66+
@cancel="selectedChannelId=null"
6767
/>
6868
</div>
6969

@@ -82,18 +82,15 @@
8282
import elapsedTime from 'kolibri.coreVue.components.elapsedTime';
8383
export default {
8484
data: () => ({
85-
selectedChannelIdx: null,
85+
selectedChannelId: null,
8686
notification: null,
8787
}),
8888
computed: {
8989
channelIsSelected() {
90-
return this.selectedChannelIdx !== null;
90+
return this.selectedChannelId !== null;
9191
},
9292
selectedChannelTitle() {
93-
if (this.channelIsSelected) {
94-
return this.channelList[this.selectedChannelIdx].title;
95-
}
96-
return '';
93+
return this.channelList.find(channel => channel.id === this.selectedChannelId).title;
9794
},
9895
sortedChannels() {
9996
return orderBy(this.channelList, [channel => channel.title.toUpperCase()], ['asc']);
@@ -115,9 +112,9 @@
115112
},
116113
methods: {
117114
handleDeleteChannel() {
118-
if (this.selectedChannelIdx !== null) {
119-
const channelId = this.channelList[this.selectedChannelIdx].id;
120-
this.selectedChannelIdx = null;
115+
if (this.selectedChannelId !== null) {
116+
const channelId = this.selectedChannelId;
117+
this.selectedChannelId = null;
121118
this.deleteChannel(channelId)
122119
.then(() => {
123120
this.$emit('deletesuccess');

0 commit comments

Comments
 (0)