|
18 | 18 | </thead> |
19 | 19 |
|
20 | 20 | <tbody class="table-body"> |
21 | | - <tr v-for="(channel, idx) in sortedChannels"> |
| 21 | + <tr v-for="channel in sortedChannels" :key="channel.id"> |
22 | 22 | <td class="table-cell-title"> |
23 | 23 | {{ channel.title }} |
24 | 24 | </td> |
|
48 | 48 | </td> |
49 | 49 | <td> |
50 | 50 | <button |
51 | | - @click="selectedChannelIdx=idx" |
| 51 | + @click="selectedChannelId=channel.id" |
52 | 52 | class="delete-button" |
53 | 53 | > |
54 | 54 | {{ $tr('deleteButtonLabel') }} |
|
63 | 63 | v-if="channelIsSelected" |
64 | 64 | :channelTitle="selectedChannelTitle" |
65 | 65 | @confirm="handleDeleteChannel()" |
66 | | - @cancel="selectedChannelIdx=null" |
| 66 | + @cancel="selectedChannelId=null" |
67 | 67 | /> |
68 | 68 | </div> |
69 | 69 |
|
|
82 | 82 | import elapsedTime from 'kolibri.coreVue.components.elapsedTime'; |
83 | 83 | export default { |
84 | 84 | data: () => ({ |
85 | | - selectedChannelIdx: null, |
| 85 | + selectedChannelId: null, |
86 | 86 | notification: null, |
87 | 87 | }), |
88 | 88 | computed: { |
89 | 89 | channelIsSelected() { |
90 | | - return this.selectedChannelIdx !== null; |
| 90 | + return this.selectedChannelId !== null; |
91 | 91 | }, |
92 | 92 | 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; |
97 | 94 | }, |
98 | 95 | sortedChannels() { |
99 | 96 | return orderBy(this.channelList, [channel => channel.title.toUpperCase()], ['asc']); |
|
115 | 112 | }, |
116 | 113 | methods: { |
117 | 114 | 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; |
121 | 118 | this.deleteChannel(channelId) |
122 | 119 | .then(() => { |
123 | 120 | this.$emit('deletesuccess'); |
|
0 commit comments