Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
476
vendor/filament/tables/resources/js/components/table.js
vendored
Normal file
476
vendor/filament/tables/resources/js/components/table.js
vendored
Normal file
|
|
@ -0,0 +1,476 @@
|
|||
import { autoUpdate, computePosition, offset, shift } from '@floating-ui/dom'
|
||||
|
||||
export default ({
|
||||
areGroupsCollapsedByDefault,
|
||||
canTrackDeselectedRecords,
|
||||
currentSelectionLivewireProperty,
|
||||
maxSelectableRecords,
|
||||
selectsCurrentPageOnly,
|
||||
$wire,
|
||||
}) => ({
|
||||
areFiltersOpen: false,
|
||||
|
||||
checkboxClickController: null,
|
||||
|
||||
groupVisibility: [],
|
||||
|
||||
isLoading: false,
|
||||
|
||||
selectedRecords: new Set(),
|
||||
|
||||
deselectedRecords: new Set(),
|
||||
|
||||
isTrackingDeselectedRecords: false,
|
||||
|
||||
shouldCheckUniqueSelection: true,
|
||||
|
||||
lastCheckedRecord: null,
|
||||
|
||||
livewireId: null,
|
||||
|
||||
entangledSelectedRecords: currentSelectionLivewireProperty
|
||||
? $wire.$entangle(currentSelectionLivewireProperty)
|
||||
: null,
|
||||
|
||||
cleanUpFiltersDropdown: null,
|
||||
|
||||
livewireEventListenersController: null,
|
||||
|
||||
unsubscribeLivewireHook: null,
|
||||
|
||||
init() {
|
||||
this.livewireId =
|
||||
this.$root.closest('[wire\\:id]')?.attributes['wire:id'].value
|
||||
|
||||
this.livewireEventListenersController = new AbortController()
|
||||
|
||||
const { signal } = this.livewireEventListenersController
|
||||
|
||||
$wire.$el.addEventListener(
|
||||
'deselectAllTableRecords',
|
||||
() => this.deselectAllRecords(),
|
||||
{ signal },
|
||||
)
|
||||
$wire.$el.addEventListener(
|
||||
'scrollToTopOfTable',
|
||||
() =>
|
||||
this.$root.scrollIntoView({
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
}),
|
||||
{ signal },
|
||||
)
|
||||
|
||||
if (currentSelectionLivewireProperty) {
|
||||
if (maxSelectableRecords !== 1) {
|
||||
this.selectedRecords = new Set(this.entangledSelectedRecords)
|
||||
} else {
|
||||
this.selectedRecords = new Set(
|
||||
this.entangledSelectedRecords
|
||||
? [this.entangledSelectedRecords]
|
||||
: [],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
this.$nextTick(() => this.watchForCheckboxClicks())
|
||||
|
||||
this.unsubscribeLivewireHook = Livewire.hook(
|
||||
'element.init',
|
||||
({ component }) => {
|
||||
if (component.id === this.livewireId) {
|
||||
this.watchForCheckboxClicks()
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
|
||||
mountAction(...args) {
|
||||
$wire.set(
|
||||
'isTrackingDeselectedTableRecords',
|
||||
this.isTrackingDeselectedRecords,
|
||||
false,
|
||||
)
|
||||
$wire.set('selectedTableRecords', [...this.selectedRecords], false)
|
||||
$wire.set('deselectedTableRecords', [...this.deselectedRecords], false)
|
||||
|
||||
$wire.mountAction(...args)
|
||||
},
|
||||
|
||||
toggleSelectRecordsOnPage() {
|
||||
const keys = this.getRecordsOnPage()
|
||||
|
||||
if (this.areRecordsSelected(keys)) {
|
||||
this.deselectRecords(keys)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.selectRecords(keys)
|
||||
},
|
||||
|
||||
toggleSelectRecords(keys) {
|
||||
if (this.areRecordsSelected(keys)) {
|
||||
this.deselectRecords(keys)
|
||||
} else {
|
||||
this.selectRecords(keys)
|
||||
}
|
||||
},
|
||||
|
||||
getSelectedRecordsCount() {
|
||||
if (this.isTrackingDeselectedRecords) {
|
||||
return (
|
||||
(this.$refs.allSelectableRecordsCount?.value ??
|
||||
this.deselectedRecords.size) - this.deselectedRecords.size
|
||||
)
|
||||
}
|
||||
|
||||
return this.selectedRecords.size
|
||||
},
|
||||
|
||||
getRecordsOnPage() {
|
||||
const keys = []
|
||||
|
||||
for (let checkbox of this.$root?.getElementsByClassName(
|
||||
'fi-ta-record-checkbox',
|
||||
) ?? []) {
|
||||
keys.push(checkbox.value)
|
||||
}
|
||||
|
||||
return keys
|
||||
},
|
||||
|
||||
selectRecords(keys) {
|
||||
if (maxSelectableRecords === 1) {
|
||||
this.deselectAllRecords()
|
||||
|
||||
keys = keys.slice(0, 1)
|
||||
}
|
||||
|
||||
for (let key of keys) {
|
||||
if (this.isRecordSelected(key)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (this.isTrackingDeselectedRecords) {
|
||||
this.deselectedRecords.delete(key)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
this.selectedRecords.add(key)
|
||||
}
|
||||
|
||||
this.updatedSelectedRecords()
|
||||
},
|
||||
|
||||
deselectRecords(keys) {
|
||||
for (let key of keys) {
|
||||
if (this.isTrackingDeselectedRecords) {
|
||||
this.deselectedRecords.add(key)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
this.selectedRecords.delete(key)
|
||||
}
|
||||
|
||||
this.updatedSelectedRecords()
|
||||
},
|
||||
|
||||
updatedSelectedRecords() {
|
||||
if (maxSelectableRecords !== 1) {
|
||||
this.entangledSelectedRecords = [...this.selectedRecords]
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.entangledSelectedRecords = [...this.selectedRecords][0] ?? null
|
||||
},
|
||||
|
||||
toggleSelectedRecord(key) {
|
||||
if (this.isRecordSelected(key)) {
|
||||
this.deselectRecords([key])
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.selectRecords([key])
|
||||
},
|
||||
|
||||
async selectAllRecords() {
|
||||
if (!canTrackDeselectedRecords || selectsCurrentPageOnly) {
|
||||
this.isLoading = true
|
||||
|
||||
this.selectedRecords = new Set(
|
||||
await $wire.getAllSelectableTableRecordKeys(),
|
||||
)
|
||||
|
||||
this.updatedSelectedRecords()
|
||||
|
||||
this.isLoading = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.isTrackingDeselectedRecords = true
|
||||
this.selectedRecords = new Set()
|
||||
this.deselectedRecords = new Set()
|
||||
|
||||
this.updatedSelectedRecords()
|
||||
},
|
||||
|
||||
canSelectAllRecords() {
|
||||
if (selectsCurrentPageOnly) {
|
||||
const recordsOnPage = this.getRecordsOnPage()
|
||||
|
||||
return (
|
||||
!this.areRecordsSelected(recordsOnPage) &&
|
||||
this.areRecordsToggleable(recordsOnPage)
|
||||
)
|
||||
}
|
||||
|
||||
const allSelectableRecordsCount = parseInt(
|
||||
this.$refs.allSelectableRecordsCount?.value,
|
||||
)
|
||||
|
||||
if (!allSelectableRecordsCount) {
|
||||
return false
|
||||
}
|
||||
|
||||
const selectedRecordsCount = this.getSelectedRecordsCount()
|
||||
|
||||
if (allSelectableRecordsCount === selectedRecordsCount) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
maxSelectableRecords === null ||
|
||||
allSelectableRecordsCount <= maxSelectableRecords
|
||||
)
|
||||
},
|
||||
|
||||
deselectAllRecords() {
|
||||
this.isTrackingDeselectedRecords = false
|
||||
this.selectedRecords = new Set()
|
||||
this.deselectedRecords = new Set()
|
||||
|
||||
this.updatedSelectedRecords()
|
||||
},
|
||||
|
||||
isRecordSelected(key) {
|
||||
if (this.isTrackingDeselectedRecords) {
|
||||
return !this.deselectedRecords.has(key)
|
||||
}
|
||||
|
||||
return this.selectedRecords.has(key)
|
||||
},
|
||||
|
||||
areRecordsSelected(keys) {
|
||||
return keys.every((key) => this.isRecordSelected(key))
|
||||
},
|
||||
|
||||
areRecordsPartiallySelected(keys) {
|
||||
if (keys.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
const selectedCount = keys.filter((key) =>
|
||||
this.isRecordSelected(key),
|
||||
).length
|
||||
|
||||
return selectedCount > 0 && selectedCount < keys.length
|
||||
},
|
||||
|
||||
areRecordsToggleable(keys) {
|
||||
if (maxSelectableRecords === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (maxSelectableRecords === 1) {
|
||||
return true
|
||||
}
|
||||
|
||||
const selectedRecords = keys.filter((key) => this.isRecordSelected(key))
|
||||
|
||||
if (selectedRecords.length === keys.length) {
|
||||
return true
|
||||
}
|
||||
|
||||
return (
|
||||
this.getSelectedRecordsCount() +
|
||||
(keys.length - selectedRecords.length) <=
|
||||
maxSelectableRecords
|
||||
)
|
||||
},
|
||||
|
||||
toggleCollapseGroup(group) {
|
||||
if (this.isGroupCollapsed(group)) {
|
||||
if (areGroupsCollapsedByDefault) {
|
||||
this.groupVisibility.push(group)
|
||||
} else {
|
||||
this.groupVisibility.splice(
|
||||
this.groupVisibility.indexOf(group),
|
||||
1,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (areGroupsCollapsedByDefault) {
|
||||
this.groupVisibility.splice(
|
||||
this.groupVisibility.indexOf(group),
|
||||
1,
|
||||
)
|
||||
} else {
|
||||
this.groupVisibility.push(group)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isGroupCollapsed(group) {
|
||||
if (areGroupsCollapsedByDefault) {
|
||||
return !this.groupVisibility.includes(group)
|
||||
}
|
||||
|
||||
return this.groupVisibility.includes(group)
|
||||
},
|
||||
|
||||
resetCollapsedGroups() {
|
||||
this.groupVisibility = []
|
||||
},
|
||||
|
||||
watchForCheckboxClicks() {
|
||||
if (this.checkboxClickController) {
|
||||
this.checkboxClickController.abort()
|
||||
}
|
||||
|
||||
this.checkboxClickController = new AbortController()
|
||||
|
||||
const { signal } = this.checkboxClickController
|
||||
|
||||
this.$root?.addEventListener(
|
||||
'click',
|
||||
(event) =>
|
||||
event.target?.matches('.fi-ta-record-checkbox') &&
|
||||
this.handleCheckboxClick(event, event.target),
|
||||
{ signal },
|
||||
)
|
||||
},
|
||||
|
||||
handleCheckboxClick(event, checkbox) {
|
||||
if (!this.lastChecked) {
|
||||
this.lastChecked = checkbox
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey) {
|
||||
let checkboxes = Array.from(
|
||||
this.$root?.getElementsByClassName('fi-ta-record-checkbox') ??
|
||||
[],
|
||||
)
|
||||
|
||||
if (!checkboxes.includes(this.lastChecked)) {
|
||||
this.lastChecked = checkbox
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let start = checkboxes.indexOf(this.lastChecked)
|
||||
let end = checkboxes.indexOf(checkbox)
|
||||
|
||||
let range = [start, end].sort((a, b) => a - b)
|
||||
let values = []
|
||||
|
||||
for (let i = range[0]; i <= range[1]; i++) {
|
||||
values.push(checkboxes[i].value)
|
||||
}
|
||||
|
||||
if (checkbox.checked) {
|
||||
if (!this.areRecordsToggleable(values)) {
|
||||
checkbox.checked = false
|
||||
this.deselectRecords([checkbox.value])
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.selectRecords(values)
|
||||
} else {
|
||||
this.deselectRecords(values)
|
||||
}
|
||||
}
|
||||
|
||||
this.lastChecked = checkbox
|
||||
},
|
||||
|
||||
toggleFiltersDropdown() {
|
||||
this.areFiltersOpen = !this.areFiltersOpen
|
||||
|
||||
if (this.areFiltersOpen) {
|
||||
const trigger = this.$refs.filtersTriggerActionContainer
|
||||
const filters = this.$refs.filtersContentContainer
|
||||
let isPositioningActive = true
|
||||
|
||||
const cleanUpAutoUpdate = autoUpdate(trigger, filters, async () => {
|
||||
const { x, y } = await computePosition(trigger, filters, {
|
||||
placement: 'bottom-end',
|
||||
middleware: [offset(8), shift({ padding: 8 })],
|
||||
})
|
||||
|
||||
if (!isPositioningActive) {
|
||||
return
|
||||
}
|
||||
|
||||
Object.assign(filters.style, {
|
||||
left: `${x}px`,
|
||||
top: `${y}px`,
|
||||
})
|
||||
})
|
||||
|
||||
const onClickAway = (event) => {
|
||||
if (
|
||||
(filters && filters.contains(event.target)) ||
|
||||
(trigger && trigger.contains(event.target))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.areFiltersOpen = false
|
||||
|
||||
if (this.cleanUpFiltersDropdown) {
|
||||
this.cleanUpFiltersDropdown()
|
||||
this.cleanUpFiltersDropdown = null
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('mousedown', onClickAway)
|
||||
document.addEventListener('touchstart', onClickAway, {
|
||||
passive: true,
|
||||
})
|
||||
const onKeydown = (event) => {
|
||||
if (event.key === 'Escape') {
|
||||
onClickAway(event)
|
||||
}
|
||||
}
|
||||
document.addEventListener('keydown', onKeydown)
|
||||
|
||||
this.cleanUpFiltersDropdown = () => {
|
||||
isPositioningActive = false
|
||||
cleanUpAutoUpdate()
|
||||
document.removeEventListener('mousedown', onClickAway)
|
||||
document.removeEventListener('touchstart', onClickAway, {
|
||||
passive: true,
|
||||
})
|
||||
document.removeEventListener('keydown', onKeydown)
|
||||
}
|
||||
} else if (this.cleanUpFiltersDropdown) {
|
||||
this.cleanUpFiltersDropdown()
|
||||
this.cleanUpFiltersDropdown = null
|
||||
}
|
||||
},
|
||||
|
||||
destroy() {
|
||||
this.cleanUpFiltersDropdown?.()
|
||||
this.livewireEventListenersController?.abort()
|
||||
this.unsubscribeLivewireHook?.()
|
||||
},
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue