Skip to content

Commit 250cd70

Browse files
committed
5.2.4
1 parent e34b3aa commit 250cd70

File tree

14 files changed

+98
-39
lines changed

14 files changed

+98
-39
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@
162162
},
163163
"minimum-stability": "dev",
164164
"prefer-stable": true,
165-
"version": "5.2.3"
165+
"version": "5.2.4"
166166
}

public/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=daaffa78cdcf42b078c1a3167c9a19d1",
2+
"/app.js": "/app.js?id=b857d5654171bf2bc52af06dc8eb5772",
33
"/ui.js": "/ui.js?id=592866a715b1c20b43fff6ca7980b279",
44
"/manifest.js": "/manifest.js?id=3267e5c99fd7b729e2f38ec55b50397d",
55
"/app.css": "/app.css?id=e6e32c23966698900f862c22cfc1651d",

resources/js/fields/Form/SlugField.vue

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212
ref="theInput"
1313
:value="value"
1414
@blur="handleChangesOnBlurEvent"
15+
@keyup.enter="handleChangeOnPressingEnterEvent"
16+
@keydown.enter="handleChangeOnPressingEnterEvent"
1517
:id="field.uniqueKey"
16-
:disabled="isReadonly"
18+
:disabled="isImmutable"
19+
:readonly="isImmutable"
1720
class="w-full form-control form-input form-control-bordered"
1821
:dusk="field.attribute"
1922
autocomplete="off"
2023
spellcheck="false"
2124
/>
2225

2326
<button
24-
class="rounded inline-flex text-sm ml-3 link-default"
2527
v-if="field.showCustomizeButton"
2628
type="button"
2729
@click="toggleCustomizeClick"
30+
:dusk="`${field.attribute}-slug-field-edit-button`"
31+
class="rounded inline-flex text-sm ml-3 link-default"
2832
>
2933
{{ __('Customize') }}
3034
</button>
@@ -40,13 +44,15 @@ import {
4044
HandlesValidationErrors,
4145
} from '@/mixins'
4246
import debounce from 'lodash/debounce'
47+
import get from 'lodash/get'
4348
import isNil from 'lodash/isNil'
4449
4550
export default {
4651
mixins: [FormField, HandlesFieldPreviews, HandlesValidationErrors],
4752
4853
data: () => ({
4954
isListeningToChanges: false,
55+
isCustomisingValue: false,
5056
debouncedHandleChange: null,
5157
}),
5258
@@ -74,10 +80,24 @@ export default {
7480
}
7581
},
7682
77-
async handleChangesOnBlurEvent(event) {
78-
let value = event?.target?.value ?? event
83+
handleChangeOnPressingEnterEvent(event) {
84+
event.preventDefault()
85+
event.stopPropagation()
86+
87+
this.listenToValueChanges(event?.target?.value ?? event)
88+
},
89+
90+
handleChangesOnBlurEvent(event) {
91+
this.listenToValueChanges(event?.target?.value ?? event)
92+
},
7993
80-
if (this.isReadonly) {
94+
listenToValueChanges(value) {
95+
if (this.isImmutable === true) {
96+
return
97+
}
98+
99+
if (this.isCustomisingValue === true) {
100+
this.value = value
81101
return
82102
}
83103
@@ -91,18 +111,20 @@ export default {
91111
},
92112
93113
toggleCustomizeClick() {
94-
if (this.field.readonly) {
114+
if (this.field.extraAttributes.readonly === true) {
115+
this.isCustomisingValue = true
95116
this.removeChangeListener()
96117
this.isListeningToChanges = false
97-
this.field.readonly = false
118+
this.field.writable = true
98119
this.field.extraAttributes.readonly = false
99120
this.field.showCustomizeButton = false
100121
this.$refs.theInput.focus()
101122
return
102123
}
103124
125+
this.isCustomisingValue = false
104126
this.registerChangeListener()
105-
this.field.readonly = true
127+
this.field.writable = false
106128
this.field.extraAttributes.readonly = true
107129
},
108130
},
@@ -112,6 +134,14 @@ export default {
112134
return this.field.shouldListenToFromChanges
113135
},
114136
137+
isImmutable() {
138+
return Boolean(
139+
this.field.readonly === false &&
140+
this.field.writable === true &&
141+
get(this.field, 'extraAttributes.readonly') === true
142+
)
143+
},
144+
115145
eventName() {
116146
return this.getFieldAttributeChangeEventName(this.field.from)
117147
},

src/Fields/Repeater.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Laravel\Nova\Fields;
44

5+
use Illuminate\Support\Arr;
56
use Laravel\Nova\Exceptions\NovaException;
67
use Laravel\Nova\Fields\Repeater\Presets\HasMany;
78
use Laravel\Nova\Fields\Repeater\Presets\JSON;
@@ -288,8 +289,8 @@ protected function replaceRulesPlaceholder(array $rules, string $replaceWith = '
288289
return $rules;
289290
}
290291

291-
return collect($rules)->map(static function ($rules) use ($replacements) {
292-
return collect($rules)->map(static function ($rule) use ($replacements) {
292+
return collect($rules)->map(static function ($fieldRules) use ($replacements) {
293+
return collect(Arr::wrap($fieldRules))->map(static function ($rule) use ($replacements) {
293294
return is_string($rule)
294295
? str_replace(array_keys($replacements), array_values($replacements), $rule)
295296
: $rule;

src/Fields/Slug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function jsonSerialize(): array
101101
};
102102

103103
if (! is_null($from) && $request->isUpdateOrUpdateAttachedRequest()) {
104-
$this->readonly();
104+
$this->immutable();
105105
$this->showCustomizeButton = true;
106106
}
107107

src/Http/Requests/NovaRequest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Foundation\Http\FormRequest;
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Route;
8+
use Laravel\Nova\TrashedStatus;
89
use Mockery as m;
910
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
1011

@@ -150,6 +151,18 @@ public function isPresentationRequest(): bool
150151
|| $this->isLensRequest();
151152
}
152153

154+
/**
155+
* Get the trashed status of the request.
156+
*/
157+
public function trashed(): TrashedStatus
158+
{
159+
if (is_null($trashed = $this->trashed)) {
160+
return TrashedStatus::DEFAULT;
161+
}
162+
163+
return TrashedStatus::tryFrom((string) $trashed) ?? TrashedStatus::DEFAULT;
164+
}
165+
153166
/**
154167
* Create an Illuminate request from a Symfony instance.
155168
*/

src/Http/Requests/QueriesResources.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,5 @@ public function orderings(): array
7373
/**
7474
* Get the trashed status of the request.
7575
*/
76-
protected function trashed(): TrashedStatus
77-
{
78-
return TrashedStatus::tryFrom((string) $this->trashed) ?? TrashedStatus::DEFAULT;
79-
}
76+
abstract public function trashed(): TrashedStatus;
8077
}

src/Http/Requests/RestoreLensResourceRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function restorableModels(Collection $models): Collection
3434
/**
3535
* Get the trashed status of the request.
3636
*/
37-
protected function trashed(): TrashedStatus
37+
public function trashed(): TrashedStatus
3838
{
3939
return TrashedStatus::WITH;
4040
}

src/Http/Requests/RestoreResourceRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function restorableModels(Collection $models): Collection
3434
/**
3535
* Get the trashed status of the request.
3636
*/
37-
protected function trashed(): TrashedStatus
37+
public function trashed(): TrashedStatus
3838
{
3939
return TrashedStatus::WITH;
4040
}

0 commit comments

Comments
 (0)