Skip to content

Commit

Permalink
select visible
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Nov 28, 2023
1 parent 80c3949 commit 463bc92
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions frontend/src/components/demo/DemoDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,39 @@ type DemoObject = {
};
// State
const initialDatatableValues: Ref<DemoObject[]> = ref([
const tableData: Ref<DemoObject[]> = ref([
{ id: 0, name: 'Item 1', value: 'a', toggle: false },
{ id: 1, name: 'Item 2', value: 'b', toggle: false },
{ id: 2, name: 'Item 3', value: 'c', toggle: true },
{ id: 3, name: 'Item 4', value: 'd', toggle: true }
]);
const selectVisible = ref(false);
const selectedObjects = ref();
let rows = ref(3);
let first = 0;
// capture current page details
const onPageEmit = (event: any) => {
rows.value = event.rows;
first = event.first;
// uncheck if switching pages or changing row count
selectVisible.value = false;
selectedObjects.value = [];
};
// when select all is checked
const onSelectVisibleChange = (event: any) => {
selectVisible.value = event.checked;
if (selectVisible.value) {
// get visible table data
selectedObjects.value = tableData.value.slice(first, first + rows.value);
} else {
selectVisible.value = false;
selectedObjects.value = [];
}
};
const panelObject: Ref<DemoObject | undefined> = ref(undefined);
const selectedDatatableObjects: Ref<Array<DemoObject>> = ref([]);
const showSidePanel: Ref<boolean> = ref(false);
// Datatable filter(s)
Expand All @@ -36,15 +61,18 @@ const filters = ref({
<div class="flex">
<div class="flex-grow-1">
<DataTable
v-model:selection="selectedDatatableObjects"
v-model:selection="selectedObjects"
v-model:filters="filters"
@select-all-change="onSelectVisibleChange"
@page="onPageEmit"
:selectAll="selectVisible"

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ":selectAll" should go before "@page"

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ':selectAll' must be hyphenated

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ":selectAll" should go before "@page"

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ':selectAll' must be hyphenated

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ":selectAll" should go before "@page"

Check warning on line 68 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ':selectAll' must be hyphenated
:loading="false"

Check warning on line 69 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ":loading" should go before "@page"

Check warning on line 69 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ":loading" should go before "@page"

Check warning on line 69 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ":loading" should go before "@page"
:value="initialDatatableValues"
:value="tableData"

Check warning on line 70 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ":value" should go before "@page"

Check warning on line 70 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ":value" should go before "@page"

Check warning on line 70 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ":value" should go before "@page"
data-key="id"

Check warning on line 71 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute "data-key" should go before "@page"

Check warning on line 71 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "data-key" should go before "@page"

Check warning on line 71 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "data-key" should go before "@page"
class="p-datatable-sm"

Check warning on line 72 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute "class" should go before "@page"

Check warning on line 72 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "class" should go before "@page"

Check warning on line 72 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "class" should go before "@page"
responsive-layout="scroll"

Check warning on line 73 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute "responsive-layout" should go before "@page"

Check warning on line 73 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "responsive-layout" should go before "@page"

Check warning on line 73 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "responsive-layout" should go before "@page"
:paginator="true"

Check warning on line 74 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ":paginator" should go before "@page"

Check warning on line 74 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ":paginator" should go before "@page"

Check warning on line 74 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ":paginator" should go before "@page"
:rows="10"
:rows="rows"

Check warning on line 75 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Attribute ":rows" should go before "@page"

Check warning on line 75 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute ":rows" should go before "@page"

Check warning on line 75 in frontend/src/components/demo/DemoDataTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute ":rows" should go before "@page"
paginator-template="RowsPerPageDropdown CurrentPageReport PrevPageLink NextPageLink "
current-page-report-template="{first}-{last} of {totalRecords}"
:rows-per-page-options="[10, 20, 50]"
Expand Down Expand Up @@ -83,27 +111,6 @@ const filters = ref({
header="Value"
:sortable="true"
/>
<Column header="Toggle">
<template #body="{ data }">
<InputSwitch v-model="data.toggle" />
</template>
</Column>
<Column header="Actions">
<template #body="{ data }">
<Button
class="p-button-lg p-button-rounded p-button-text p-0"
aria-label="help text"
@click="
() => {
showSidePanel = true;
panelObject = data;
}
"
>
<font-awesome-icon icon="fa-solid fa-circle-info" />
</Button>
</template>
</Column>
</DataTable>
</div>
<Divider
Expand Down

0 comments on commit 463bc92

Please sign in to comment.