-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
300bb18
commit 87b50f1
Showing
27 changed files
with
1,188 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
@xen-orchestra/web-core/lib/components/table/VtsDataTable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<div class="table-container"> | ||
<VtsLoadingHero :disabled="isReady" type="table"> | ||
<VtsTable class="table" vertical-border> | ||
<thead> | ||
<slot name="thead" /> | ||
</thead> | ||
<tbody> | ||
<slot name="tbody" /> | ||
</tbody> | ||
</VtsTable> | ||
</VtsLoadingHero> | ||
<VtsErrorNoDataHero v-if="hasError" type="table" /> | ||
<VtsStateHero v-if="noDataMessage" type="table" image="no-data"> | ||
{{ noDataMessage }} | ||
</VtsStateHero> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import VtsErrorNoDataHero from '@core/components/state-hero/VtsErrorNoDataHero.vue' | ||
import VtsLoadingHero from '@core/components/state-hero/VtsLoadingHero.vue' | ||
import VtsStateHero from '@core/components/state-hero/VtsStateHero.vue' | ||
import VtsTable from '@core/components/table/VtsTable.vue' | ||
defineProps<{ | ||
isReady?: boolean | ||
hasError?: boolean | ||
noDataMessage?: string | ||
}>() | ||
defineSlots<{ | ||
thead(): any | ||
tbody(): any | ||
}>() | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
@xen-orchestra/web-core/lib/composables/table/multi-select.composable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { computed, ref, unref, type MaybeRef, type Ref } from 'vue' | ||
|
||
export default function useMultiSelect<T>(usableIds: MaybeRef<T[]>, selectableIds?: MaybeRef<T[]>) { | ||
const $selected = ref(new Set()) as Ref<Set<T>> | ||
|
||
const selected = computed({ | ||
get() { | ||
return unref(usableIds).filter(usableId => $selected.value.has(usableId)) | ||
}, | ||
set(ids: T[]) { | ||
$selected.value = new Set(ids) | ||
}, | ||
}) | ||
|
||
const areAllSelected = computed({ | ||
get() { | ||
return (unref(selectableIds) ?? unref(usableIds)).every(id => $selected.value.has(id)) | ||
}, | ||
set(value: boolean) { | ||
if (value) { | ||
$selected.value = new Set(unref(selectableIds) ?? unref(usableIds)) | ||
} else { | ||
$selected.value = new Set() | ||
} | ||
}, | ||
}) | ||
|
||
return { | ||
selected, | ||
areAllSelected, | ||
} | ||
} |
Oops, something went wrong.