Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace CoreTable with KTable in UserPage.vue #12705

Open
4 tasks
BabyElias opened this issue Oct 7, 2024 · 5 comments
Open
4 tasks

Replace CoreTable with KTable in UserPage.vue #12705

BabyElias opened this issue Oct 7, 2024 · 5 comments
Assignees

Comments

@BabyElias
Copy link
Contributor

BabyElias commented Oct 7, 2024

🌱 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

  • KTable will receive pre-sorted data from the backend instead of handling the sorting itself. The backend will be responsible for fetching and managing the sorted data. The backend sorting function can be viewed here
  • Use the KTable’s sortable feature with disableDefaultSorting to ensure the table displays backend-sorted data without applying additional local sorting logic.
  • Ensure that the table remains integrated with PaginatedListContainerWithBackend, as the latter is responsible for managing pagination.
  • Implement integration with useKliveregion to announce loading states for accessibility purposes. The following messages should be announced
    • When a header is clicked and sorting begins - “Data sorting in progress”
    • When sorted data is finally loaded - “Data sorting completed”
  • Handle error states with snackbars to notify users of any issues encountered during data fetching or sorting operations.
    • In case data fetching fails due to any reason : “Data sorting failed. Please try again.”

Resources for Implementation


Acceptance Criteria

  • Replace CoreTable with KTable in UserPage.vue.
  • The sorting functionality should work seamlessly with data provided by the backend, using disableDefaultSorting.
  • Accessibility features such as loading announcements using useKLiveRegion and error state snackbars should be properly integrated.
  • The table should continue to work correctly with PaginatedListContainerWithBackend for pagination.

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
Copy link
Member

MisRob commented Oct 8, 2024

Reserved for @BabyElias

@BabyElias
Copy link
Contributor Author

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

@AlexVelezLl
Copy link
Member

Assigned @BabyElias!

@MisRob
Copy link
Member

MisRob commented Oct 14, 2024

Yey :) Thank you

@MisRob
Copy link
Member

MisRob commented Dec 17, 2024

Hi @BabyElias, I wanted to mention that Learning Equality will be closed from December 23 to January 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants