Skip to content

Commit

Permalink
Merge pull request #1928 from christianmemije/deletechannels
Browse files Browse the repository at this point in the history
Delete actually selected channel
  • Loading branch information
rtibbles authored Jul 31, 2017
2 parents 2f5525d + 3719bd6 commit 0570b57
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</thead>

<tbody class="table-body">
<tr v-for="(channel, idx) in sortedChannels">
<tr v-for="channel in sortedChannels" :key="channel.id">
<td class="table-cell-title">
{{ channel.title }}
</td>
Expand Down Expand Up @@ -48,7 +48,7 @@
</td>
<td>
<button
@click="selectedChannelIdx=idx"
@click="selectedChannelId=channel.id"
class="delete-button"
>
{{ $tr('deleteButtonLabel') }}
Expand All @@ -63,7 +63,7 @@
v-if="channelIsSelected"
:channelTitle="selectedChannelTitle"
@confirm="handleDeleteChannel()"
@cancel="selectedChannelIdx=null"
@cancel="selectedChannelId=null"
/>
</div>

Expand All @@ -82,18 +82,15 @@
import elapsedTime from 'kolibri.coreVue.components.elapsedTime';
export default {
data: () => ({
selectedChannelIdx: null,
selectedChannelId: null,
notification: null,
}),
computed: {
channelIsSelected() {
return this.selectedChannelIdx !== null;
return this.selectedChannelId !== null;
},
selectedChannelTitle() {
if (this.channelIsSelected) {
return this.channelList[this.selectedChannelIdx].title;
}
return '';
return this.channelList.find(channel => channel.id === this.selectedChannelId).title;
},
sortedChannels() {
return orderBy(this.channelList, [channel => channel.title.toUpperCase()], ['asc']);
Expand All @@ -115,9 +112,9 @@
},
methods: {
handleDeleteChannel() {
if (this.selectedChannelIdx !== null) {
const channelId = this.channelList[this.selectedChannelIdx].id;
this.selectedChannelIdx = null;
if (this.selectedChannelId !== null) {
const channelId = this.selectedChannelId;
this.selectedChannelId = null;
this.deleteChannel(channelId)
.then(() => {
this.$emit('deletesuccess');
Expand Down

0 comments on commit 0570b57

Please sign in to comment.