Merge branch '3.x' into 4.x

This commit is contained in:
Dan Harrin
2024-05-15 11:37:41 +01:00
21 changed files with 289 additions and 215 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+48 -48
View File
@@ -8,7 +8,7 @@
"devDependencies": {
"@awcodes/alpine-floating-ui": "^3.4.0",
"@babel/runtime": "^7.15.3",
"@danharrin/alpine-mousetrap": "^0.1.0",
"@danharrin/alpine-mousetrap": "^0.1.6",
"@ryangjchandler/alpine-tooltip": "^2.0",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.9",
@@ -1924,9 +1924,9 @@
}
},
"node_modules/@danharrin/alpine-mousetrap": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/@danharrin/alpine-mousetrap/-/alpine-mousetrap-0.1.5.tgz",
"integrity": "sha512-7Cm7ZdIEhjfjzgA9FJihkLrd3OvsS6eEwYwXawh9BpjUrpRkq1A5Ah3PvyDkJcVMciGRW6zLUcPVjhZNVyJc9g==",
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@danharrin/alpine-mousetrap/-/alpine-mousetrap-0.1.6.tgz",
"integrity": "sha512-NKdnTtakvaA6eqXhItXgpIsa/tmY+22SBNje6IahkVhjY9ULACDURMlZDfJ5i8i5ilI7gR6PcZZHURWrEITUYA==",
"dev": true
},
"node_modules/@discoveryjs/json-ext": {
@@ -2805,9 +2805,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "20.12.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz",
"integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==",
"version": "20.12.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
"integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@@ -3891,9 +3891,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001617",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz",
"integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==",
"version": "1.0.30001618",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz",
"integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==",
"dev": true,
"funding": [
{
@@ -4018,9 +4018,9 @@
}
},
"node_modules/cli-table3": {
"version": "0.6.4",
"resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.4.tgz",
"integrity": "sha512-Lm3L0p+/npIQWNIiyF/nAn7T5dnOwR3xNTHXYEBFBFVPXzCVNZ5lqEC/1eo/EVfpDsQ1I+TX4ORPQgp+UI0CRw==",
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz",
"integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==",
"dev": true,
"dependencies": {
"string-width": "^4.2.0"
@@ -4274,9 +4274,9 @@
"dev": true
},
"node_modules/core-js-compat": {
"version": "3.37.0",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.0.tgz",
"integrity": "sha512-vYq4L+T8aS5UuFg4UwDhc7YNRWVeVZwltad9C/jV3R2LgVOpS9BDr7l/WL6BN0dbV3k1XejPTHqqEzJgsa0frA==",
"version": "3.37.1",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.1.tgz",
"integrity": "sha512-9TNiImhKvQqSUkOvk/mMRZzOANTiEVC7WaBNhHcKM7x+/5E1l5NvsysR19zuDQScE8k+kfQXWRN3AtS/eOSHpg==",
"dev": true,
"dependencies": {
"browserslist": "^4.23.0"
@@ -4999,9 +4999,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.4.761",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.761.tgz",
"integrity": "sha512-PIbxpiJGx6Bb8dQaonNc6CGTRlVntdLg/2nMa1YhnrwYOORY9a3ZgGN0UQYE6lAcj/lkyduJN7BPt/JiY+jAQQ==",
"version": "1.4.769",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.769.tgz",
"integrity": "sha512-bZu7p623NEA2rHTc9K1vykl57ektSPQYFFqQir8BOYf6EKOB+yIsbFB9Kpm7Cgt6tsLr9sRkqfqSZUw7LP1XxQ==",
"dev": true
},
"node_modules/elliptic": {
@@ -7809,9 +7809,9 @@
}
},
"node_modules/minipass": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.0.tgz",
"integrity": "sha512-oGZRv2OT1lO2UF1zUcwdTb3wqUwI0kBGTgt/T7OdSj6M6N5m3o5uPf0AIW6lVxGGoiWUR7e2AwTE+xiwK8WQig==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz",
"integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==",
"dev": true,
"engines": {
"node": ">=16 || 14 >=14.17"
@@ -8453,16 +8453,16 @@
"dev": true
},
"node_modules/path-scurry": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz",
"integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
"dev": true,
"dependencies": {
"lru-cache": "^10.2.0",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@@ -8509,9 +8509,9 @@
}
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
"dev": true
},
"node_modules/picomatch": {
@@ -8977,9 +8977,9 @@
}
},
"node_modules/postcss-nesting": {
"version": "12.1.2",
"resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.2.tgz",
"integrity": "sha512-FUmTHGDNundodutB4PUBxt/EPuhgtpk8FJGRsBhOuy+6FnkR2A8RZWIsyyy6XmhvX2DZQQWIkvu+HB4IbJm+Ew==",
"version": "12.1.4",
"resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.4.tgz",
"integrity": "sha512-CcHOq94K137E+U4Ommu7pexcpp0Tjm24zl4UcqWs1oSLAr5cLI+jLrqQ5h/bdjhMX6cMbzunyustVNnvrzF8Zg==",
"dev": true,
"funding": [
{
@@ -8993,7 +8993,7 @@
],
"dependencies": {
"@csstools/selector-resolve-nested": "^1.1.0",
"@csstools/selector-specificity": "^3.0.3",
"@csstools/selector-specificity": "^3.1.1",
"postcss-selector-parser": "^6.0.13"
},
"engines": {
@@ -9026,9 +9026,9 @@
}
},
"node_modules/postcss-nesting/node_modules/@csstools/selector-specificity": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-3.0.3.tgz",
"integrity": "sha512-KEPNw4+WW5AVEIyzC80rTbWEUatTW2lXpN8+8ILC8PiPeWPjwUzrPZDIOZ2wwqDmeqOYTdSGyL3+vE5GC3FB3Q==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-3.1.1.tgz",
"integrity": "sha512-a7cxGcJ2wIlMFLlh8z2ONm+715QkPHiyJcxwQlKOz/03GPw1COpfhcmC9wm4xlZfp//jWHNNMwzjtqHXVWU9KA==",
"dev": true,
"funding": [
{
@@ -10034,9 +10034,9 @@
}
},
"node_modules/semver": {
"version": "7.6.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.1.tgz",
"integrity": "sha512-f/vbBsu+fOiYt+lmwZV0rVwJScl46HppnOA1ZvIuBWKOTlllpyJ3bfVax76/OrhCH38dyxoDIA8K7uB963IYgA==",
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz",
"integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==",
"dev": true,
"bin": {
"semver": "bin/semver.js"
@@ -10745,22 +10745,22 @@
}
},
"node_modules/sucrase/node_modules/glob": {
"version": "10.3.12",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz",
"integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==",
"version": "10.3.15",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz",
"integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==",
"dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^2.3.6",
"minimatch": "^9.0.1",
"minipass": "^7.0.4",
"path-scurry": "^1.10.2"
"path-scurry": "^1.11.0"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@@ -11318,9 +11318,9 @@
}
},
"node_modules/update-browserslist-db": {
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz",
"integrity": "sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==",
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz",
"integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==",
"dev": true,
"funding": [
{
@@ -11338,7 +11338,7 @@
],
"dependencies": {
"escalade": "^3.1.2",
"picocolors": "^1.0.0"
"picocolors": "^1.0.1"
},
"bin": {
"update-browserslist-db": "cli.js"
+1 -1
View File
@@ -18,7 +18,7 @@
"devDependencies": {
"@awcodes/alpine-floating-ui": "^3.4.0",
"@babel/runtime": "^7.15.3",
"@danharrin/alpine-mousetrap": "^0.1.0",
"@danharrin/alpine-mousetrap": "^0.1.6",
"@ryangjchandler/alpine-tooltip": "^2.0",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.9",
@@ -67,7 +67,7 @@ return [
'started' => [
'title' => 'Vienti aloitettu',
'body' => 'Vienti on aloitettu ja 1 rivi käsitellään taustalla.|Vienti on aloitettu ja :count riviä käsitellään taustalla.',
'body' => 'Vienti on aloitettu ja 1 rivi käsitellään taustalla. Saat ilmoituksen latauslinkillä kun se on valmis.|Vienti on aloitettu ja :count riviä käsitellään taustalla. Saat ilmoituksen latauslinkillä kun se on valmis.',
],
],
File diff suppressed because one or more lines are too long
@@ -54,13 +54,15 @@ export default function richEditorFormComponent({ state }) {
init: function () {
this.$refs.trixValue.value = this.state
this.$refs.trix.editor?.loadHTML(this.state)
this.$watch('state', () => {
if (document.activeElement === this.$refs.trix) {
return
}
this.$refs.trix.editor.loadHTML(this.state)
this.$refs.trixValue.value = this.state
this.$refs.trix.editor?.loadHTML(this.state)
})
},
}
+37 -8
View File
@@ -168,34 +168,63 @@ class CheckboxList extends Field implements Contracts\CanDisableOptions, Contrac
->toArray();
});
$this->loadStateFromRelationshipsUsing(static function (CheckboxList $component, ?array $state): void {
$this->loadStateFromRelationshipsUsing(static function (CheckboxList $component, ?array $state) use ($modifyQueryUsing): void {
$relationship = $component->getRelationship();
/** @var Collection $relatedModels */
$relatedModels = $relationship->getResults();
if ($modifyQueryUsing) {
$component->evaluate($modifyQueryUsing, [
'query' => $relationship->getQuery(),
]);
}
/** @var Collection $relatedRecords */
$relatedRecords = $relationship->getResults();
$component->state(
// Cast the related keys to a string, otherwise Livewire does not
// know how to handle deselection.
//
// https://github.com/filamentphp/filament/issues/1111
$relatedModels
$relatedRecords
->pluck($relationship->getRelatedKeyName())
->map(static fn ($key): string => strval($key))
->toArray(),
->all(),
);
});
$this->saveRelationshipsUsing(static function (CheckboxList $component, ?array $state) {
$this->saveRelationshipsUsing(static function (CheckboxList $component, ?array $state) use ($modifyQueryUsing) {
$relationship = $component->getRelationship();
if ($modifyQueryUsing) {
$component->evaluate($modifyQueryUsing, [
'query' => $relationship->getQuery(),
]);
}
/** @var Collection $relatedRecords */
$relatedRecords = $relationship->getResults();
$recordsToDetach = array_diff(
$relatedRecords
->pluck($relationship->getRelatedKeyName())
->map(static fn ($key): string => strval($key))
->all(),
$state ?? [],
);
if (count($recordsToDetach) > 0) {
$relationship->detach($recordsToDetach);
}
$pivotData = $component->getPivotData();
if ($pivotData === []) {
$component->getRelationship()->sync($state ?? []);
$relationship->sync($state ?? [], detaching: false);
return;
}
$component->getRelationship()->syncWithPivotValues($state ?? [], $pivotData);
$relationship->syncWithPivotValues($state ?? [], $pivotData, detaching: false);
});
$this->dehydrated(false);
+35 -8
View File
@@ -813,7 +813,7 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
->toArray();
});
$this->loadStateFromRelationshipsUsing(static function (Select $component, $state): void {
$this->loadStateFromRelationshipsUsing(static function (Select $component, $state) use ($modifyQueryUsing): void {
if (filled($state)) {
return;
}
@@ -824,18 +824,24 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
($relationship instanceof BelongsToMany) ||
($relationship instanceof HasManyThrough)
) {
/** @var Collection $relatedModels */
$relatedModels = $relationship->getResults();
if ($modifyQueryUsing) {
$component->evaluate($modifyQueryUsing, [
'query' => $relationship->getQuery(),
]);
}
/** @var Collection $relatedRecords */
$relatedRecords = $relationship->getResults();
$component->state(
// Cast the related keys to a string, otherwise JavaScript does not
// know how to handle deselection.
//
// https://github.com/filamentphp/filament/issues/1111
$relatedModels
$relatedRecords
->pluck(($relationship instanceof BelongsToMany) ? $relationship->getRelatedKeyName() : $relationship->getRelated()->getKeyName())
->map(static fn ($key): string => strval($key))
->toArray(),
->all(),
);
return;
@@ -959,7 +965,7 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
},
);
$this->saveRelationshipsUsing(static function (Select $component, Model $record, $state) {
$this->saveRelationshipsUsing(static function (Select $component, Model $record, $state) use ($modifyQueryUsing) {
$relationship = $component->getRelationship();
if (
@@ -987,15 +993,36 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
return;
}
if ($modifyQueryUsing) {
$component->evaluate($modifyQueryUsing, [
'query' => $relationship->getQuery(),
]);
}
/** @var Collection $relatedRecords */
$relatedRecords = $relationship->getResults();
$recordsToDetach = array_diff(
$relatedRecords
->pluck($relationship->getRelatedKeyName())
->map(static fn ($key): string => strval($key))
->all(),
$state ?? [],
);
if (count($recordsToDetach) > 0) {
$relationship->detach($recordsToDetach);
}
$pivotData = $component->getPivotData();
if ($pivotData === []) {
$relationship->sync($state ?? []);
$relationship->sync($state ?? [], detaching: false);
return;
}
$relationship->syncWithPivotValues($state ?? [], $pivotData);
$relationship->syncWithPivotValues($state ?? [], $pivotData, detaching: false);
});
$this->createOptionUsing(static function (Select $component, array $data, Schema $form) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -37,7 +37,7 @@ Since all pages are Livewire components, you can [add actions](../actions/adding
### Header actions
You can also easily add actions to the header of any page, including [resource pages](resources/getting-started). You don't need to worry about adding anything to the Blade, we handle that for you. Just return your actions from the `getHeaderActions()` method of the page class:
You can also easily add actions to the header of any page, including [resource pages](resources/getting-started). You don't need to worry about adding anything to the Blade template, we handle that for you. Just return your actions from the `getHeaderActions()` method of the page class:
```php
use Filament\Actions\Action;
@@ -52,4 +52,12 @@ return [
],
'avatar' => [
'alt' => ':name avatar',
],
'logo' => [
'alt' => ':name logo',
],
];
@@ -0,0 +1,7 @@
<?php
return [
'body' => 'Sinulla on tallentamattomia muutoksia. Oletko varma että haluat poistua?',
];
@@ -112,7 +112,7 @@ class EditRecord extends Page
/**
* @param array<string> $attributes
*/
protected function refreshFormData(array $attributes): void
public function refreshFormData(array $attributes): void
{
$this->data = [
...$this->data,
@@ -102,7 +102,7 @@ class ViewRecord extends Page
/**
* @param array<string> $attributes
*/
protected function refreshFormData(array $attributes): void
public function refreshFormData(array $attributes): void
{
$this->data = [
...$this->data,