Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,38 @@
<KButton
v-if="page.count && !selecting"
:text="$tr('selectChannels')"
data-testid="select"
data-test="select"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to change testid. Perhaps just merge conflict?

appearance="basic-link"
@click="setSelection(true)"
/>
<Checkbox
<KCheckbox
v-else-if="selecting"
v-model="selectAll"
class="mb-4 mx-2"
:indeterminate="isIndeterminate"
:label="$tr('selectAll')"
:indeterminate="selected.length > 0 && selected.length < channels.length"
class="mb-4 mx-2"
/>
</VFlex>
<VFlex xs12>
<VLayout
v-for="item in channels"
:key="item.id"
align-center
<KCardGrid
layout="1-1-1"
:skeletonsConfig="[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not yet passing loading state to card grid, it will never show loading skeletons, and therefore skeletonsConfig is not needed.

We will probably use loading skeletons, but that'd be outside of scope of this task, so let's remove.

{
breakpoints: [0, 1, 2, 3, 4, 5, 6, 7],
orientation: 'vertical',
count: 3,
},
]"
>
<Checkbox
v-show="selecting"
v-model="selected"
class="mx-2"
:value="item.id"
<StudioChannelCard
v-for="channel in channels"
:key="channel.id"
:channel="channel"
:selectable="selecting"
:selected="isChannelSelected(channel.id)"
@toggle-selection="handleSelectionToggle"
/>
<ChannelItem
:channelId="item.id"
:detailsRouteName="detailsRouteName"
style="flex-grow: 1; width: 100%"
/>
</VLayout>
</KCardGrid>
</VFlex>
<VFlex
xs12
Expand Down Expand Up @@ -135,27 +137,25 @@
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
import { RouteNames } from '../../constants';
import CatalogFilters from './CatalogFilters';
import CatalogFilterBar from './CatalogFilterBar';
import ChannelItem from './ChannelItem';
import LoadingText from 'shared/views/LoadingText';
import Pagination from 'shared/views/Pagination';
import BottomBar from 'shared/views/BottomBar';
import Checkbox from 'shared/views/form/Checkbox';
import ToolBar from 'shared/views/ToolBar';
import OfflineText from 'shared/views/OfflineText';
import { constantsTranslationMixin } from 'shared/mixins';
import { channelExportMixin } from 'shared/views/channel/mixins';
import CatalogFilterBar from './CatalogFilterBar';
import StudioChannelCard from './components/StudioChannelCard';

export default {
name: 'CatalogList',
components: {
ChannelItem,
StudioChannelCard,
LoadingText,
CatalogFilters,
CatalogFilterBar,
Pagination,
BottomBar,
Checkbox,
ToolBar,
OfflineText,
},
Expand Down Expand Up @@ -216,9 +216,6 @@
debouncedSearch() {
return debounce(this.loadCatalog, 1000);
},
detailsRouteName() {
return RouteNames.CATALOG_DETAILS;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for removing this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was unused code that wasn't passed to StudioChannelCard.
The new component handles its own routing.
should it must be there??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends if the change affects user experience - you may want to check before/after. Is the route same as the one in StudioChannelCard?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any observations on the above?

},
channels() {
// Sort again by the same ordering used on the backend - name.
// Have to do this because of how we are getting the object data via getChannels.
Expand All @@ -227,6 +224,9 @@
selectedCount() {
return this.page.count - this.excluded.length;
},
isIndeterminate() {
return this.selected.length > 0 && this.selected.length < this.channels.length;
},
},
watch: {
$route(to) {
Expand All @@ -250,6 +250,17 @@
},
methods: {
...mapActions('channelList', ['searchCatalog']),
isChannelSelected(channelId) {
return this.selected.includes(channelId);
},
handleSelectionToggle(channelId) {
const currentlySelected = this.selected;
if (currentlySelected.includes(channelId)) {
this.selected = currentlySelected.filter(id => id !== channelId);
} else {
this.selected = [...currentlySelected, channelId];
}
},
loadCatalog() {
this.loading = true;
const params = {
Expand Down
Loading