learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
809 stars 682 forks source link

Replace `CoreTable` with `KTable` in UserPage.vue #12705

Open BabyElias opened 1 month ago

BabyElias commented 1 month ago

🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.

Motivation

We are replacing the usage of CoreTable with our newly introduced KTable component to address accessibility needs and provide an enhanced sorting experience. This is one of the key use cases where the sorting features of KTable will bring significant improvements, particularly for administrators.

In the future, we plan to introduce columns such as “Date created” and “Date added” to the table. These additional columns, combined with KTable's sorting capabilities, will allow administrators to quickly locate newly added users.

Guidance

The replacement will take place in UserPage.vue, specifically the following code:

<PaginatedListContainerWithBackend
    v-model="currentPage"
    :items="facilityUsers"
    ...
  >
    <template #otherFilter>
      <KSelect
        v-model="roleFilter"
        :label="coreString('userTypeLabel')"
        ...
      />
    </template>

    <template #filter>
      <FilterTextbox v-model="search" :placeholder="$tr('searchText')" />
    </template>

    <template>
      <UserTable
        class="move-down user-roster"
        :users="facilityUsers"
        ...
      >

        ...

      </UserTable>
    </template>
  </PaginatedListContainerWithBackend>

This block will be replaced with:

<PaginatedListContainerWithBackend
    v-model="currentPage"
    :items="facilityUsers"
    ...
  >
    <template #otherFilter>
      <KSelect
        v-model="roleFilter"
        :label="coreString('userTypeLabel')"
        ...
      />
    </template>

    <template #filter>
      <FilterTextbox v-model="search" :placeholder="$tr('searchText')" />
    </template>

    <template>
      <KTable ...
        sortable
        disableDefaultSorting
       @changeSort="changeSortHandler">

        ...

      </KTable>
    </template>
  </PaginatedListContainerWithBackend>
<script>
export default {
  data() {
    return {
      isLoading: false,
      sortKey: null, // Store the current column being sorted
      sortOrder: null, // Store the current sort order (asc/desc/unsorted)
    };
  },
  methods: {
    async changeSortHandler(index, currentSortOrder) {
      // Cycle through the sorting states: ascending > descending > unsorted
      // Update the current sort key and order
      // Emit the new sort state (asc/desc/unsorted)
      // Set loading state, loading state messages, error management and handle UI focus for accessibility
};
</script>

This refactor involves removing the UserTable component and replacing it with KTable. Refactoring UserTable.vue itself is not recommended as it could affect multiple other areas in the codebase. Instead, we'll integrate KTable where necessary.


Key Implementation Notes


Resources for Implementation


Acceptance Criteria


This update is a step forward in enhancing both the user experience and accessibility in the table component. It is essential to preserve existing pagination logic while introducing improved sorting and accessibility features.

MisRob commented 1 month ago

Reserved for @BabyElias

BabyElias commented 1 month ago

Started working on this. @MisRob Can you please assign this to me? Thanks!

AlexVelezLl commented 1 month ago

Assigned @BabyElias!

MisRob commented 1 month ago

Yey :) Thank you