Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into Kreyu#88
Browse files Browse the repository at this point in the history
# Conflicts:
#	assets/package.json
  • Loading branch information
alexandre-castelain committed Jan 7, 2025
2 parents 3c90c86 + 8ac58f3 commit 80b6d34
Show file tree
Hide file tree
Showing 127 changed files with 7,053 additions and 1,091 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Code Quality

on:
- push
- pull_request
- workflow_dispatch
push:
pull_request:
workflow_dispatch:
paths:
- '**.php'

jobs:
php-cs-fixer:
Expand All @@ -22,7 +24,12 @@ jobs:
uses: ramsey/composer-install@v2

- name: Run php-cs-fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
run: ./vendor/bin/php-cs-fixer fix --diff

- name: Commit php-cs-fixer changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes

phpstan:
runs-on: ubuntu-latest
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Testing

on:
- push
- pull_request
- workflow_dispatch
push:
pull_request:
workflow_dispatch:
paths:
- '**.php'

jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.1', '8.2', '8.3', '8.4']
dependency-version: ['lowest', 'highest']
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<img align="right" width="200px" src="./docs/src/public/logo.png"/>

[![Latest Stable Version](http://poser.pugx.org/kreyu/data-table-bundle/v)](https://packagist.org/packages/kreyu/data-table-bundle)
![Packagist Version](https://img.shields.io/packagist/v/kreyu/data-table-bundle?label=version&color=%237986CB&link=https%3A%2F%2Fpackagist.org%2Fpackages%2Fkreyu%2Fdata-table-bundle)

Streamlines the creation process of the data tables in Symfony applications.

> [!WARNING]
> This bundle is still in early stages of development and is likely to **change**, or even **change drastically**.
> This bundle is still in development and is likely to **change**, or even **change drastically**.
> It is **NOT** production ready, and backwards compatibility is **NOT** guaranteed until the first stable release.
## Documentation
Expand Down
9 changes: 7 additions & 2 deletions assets/controllers/batch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Controller} from '@hotwired/stimulus'

/* stimulusFetch: 'lazy' */
export default class extends Controller {
static targets = [
'selectAllCheckbox',
Expand Down Expand Up @@ -41,8 +42,12 @@ export default class extends Controller {
#updateBatchActionBar() {
const uniqueSelectedCount = this.#getUniqueSelectedCount();

this.selectedCounterTarget.innerHTML = uniqueSelectedCount;
this.batchActionBarTarget.hidden = uniqueSelectedCount === 0;
if (this.hasSelectedCounterTarget) {
this.selectedCounterTarget.innerHTML = uniqueSelectedCount;
}
if (this.hasBatchActionBarTarget) {
this.batchActionBarTarget.hidden = uniqueSelectedCount === 0;
}
}

#updateIndeterminateStates() {
Expand Down
1 change: 1 addition & 0 deletions assets/controllers/personalization.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Controller } from '@hotwired/stimulus'
import Sortable from 'sortablejs'

/* stimulusFetch: 'lazy' */
export default class extends Controller {
static targets = [ 'visibleColumns', 'hiddenColumns' ]

Expand Down
45 changes: 45 additions & 0 deletions assets/controllers/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Controller } from '@hotwired/stimulus'

/* stimulusFetch: 'lazy' */
export default class extends Controller {
static values = {
urlQueryParameters: Object,
}

connect() {
this.#appendUrlQueryParameters();
}

#appendUrlQueryParameters() {
const url = new URL(window.location.href);

const parameters = this.#flattenParameters(this.urlQueryParametersValue);

for (const [key, value] of Object.entries(parameters)) {
if (!url.searchParams.has(key)) {
url.searchParams.set(key, String(value));
}
}

if (url.toString() !== window.location.href) {
window.history.replaceState(null, null, url);
Turbo.navigator.history.push(url);
}
}

#flattenParameters(input, keyName) {
let result = {};

for (const key in input) {
const newKey = keyName ? `${keyName}[${key}]` : key;

if (typeof input[key] === "object" && !Array.isArray(input[key])) {
result = { ...result, ...this.#flattenParameters(input[key], newKey) }
} else {
result[newKey] = input[key];
}
}

return result;
}
}
9 changes: 7 additions & 2 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
"fetch": "eager",
"enabled": true
},
"dropdown": {
"main": "controllers/dropdown.js",
"state": {
"main": "controllers/state.js",
"fetch": "eager",
"enabled": true
},
"dropdown": {
"main": "controllers/dropdown.js",
"fetch": "eager",
"enabled": true
}
},
"importmap": {
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default defineConfig({
{ text: 'Persistence', link: '/docs/features/persistence' },
{ text: 'Theming', link: '/docs/features/theming' },
{ text: 'Asynchronicity', link: '/docs/features/asynchronicity' },
{ text: 'Profiler', link: '/docs/features/profiler' },
{ text: 'Extensibility', link: '/docs/features/extensibility' },
]
},
Expand Down
Loading

0 comments on commit 80b6d34

Please sign in to comment.