Skip to content

Commit 647d8c9

Browse files
authored
Merge pull request #58 from MaidenVoyageSoftware/master
Nova v5 Support
2 parents 6c5d33d + dcb5c29 commit 647d8c9

10 files changed

Lines changed: 65 additions & 18524 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"php": "^8.0"
2525
},
2626
"require-dev": {
27-
"laravel/nova": "^4.2",
28-
"orchestra/testbench": "^7.4",
27+
"laravel/nova": "^5.0",
2928
"phpunit/phpunit": "^9.5.10"
3029
},
3130
"autoload": {

dist/css/field.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/* Nova Field CSS */
21

dist/js/field.js

Lines changed: 2 additions & 18497 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/field.js.LICENSE.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*!
2+
* vuex v4.1.0
3+
* (c) 2022 Evan You
4+
* @license MIT
5+
*/
6+
7+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */

mix.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class NovaExtension {
1414
webpackPlugins() {
1515
return new webpack.ProvidePlugin({
1616
_: 'lodash',
17-
Errors: 'form-backend-validation',
1817
});
1918
}
2019

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
"@inertiajs/inertia": "^0.11.0",
1414
"@vue/babel-plugin-jsx": "^1.1.0",
1515
"@vue/compiler-sfc": "^3.2.22",
16-
"form-backend-validation": "^2.3.3",
1716
"inflector-js": "^1.0.1",
1817
"laravel-mix": "^6.0.41",
1918
"lodash": "^4.17.21",
2019
"postcss": "^8.3.11",
20+
"tailwindcss": "^3.4.19",
21+
"uid": "^2.0.2",
2122
"vue-loader": "^16.8.3",
22-
"vuex": "^4.0.2"
23-
},
24-
"dependencies": {}
23+
"vuex": "^4.0.2",
24+
"webpack": "5.89.0"
25+
}
2526
}

readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Laravel Nova v5
2+
This package has been forked from kirschbaum-development/nova-inline-select and updated to support Laravel Nova v5.
3+
14
![Nova Inline Select banner](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-select/master/screenshots/banner.jpg)
25

36
# An inline select field for Nova apps
@@ -24,6 +27,19 @@ This Nova field requires Nova 1.0 or higher.
2427

2528
You can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
2629

30+
First, add this to the repositories section of your composer.json file:
31+
32+
```text
33+
"repositories": [
34+
{
35+
"type": "git",
36+
"url": "https://github.com/MaidenVoyageSoftware/nova-inline-select.git"
37+
},
38+
]
39+
```
40+
41+
Then, install the package as usual
42+
2743
```bash
2844
composer require kirschbaum-development/nova-inline-select
2945
```

resources/js/components/DetailField.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<SelectControl
77
:id="field.uniqueKey"
88
:dusk="field.attribute"
9-
v-model:selected="value"
10-
@change="attemptUpdate"
9+
v-model="value"
10+
@selected="attemptUpdate"
1111
@click.stop
1212
class="w-full md:w-3/5"
13-
:select-classes="{ 'form-input-border-error': hasError }"
13+
:has-error="hasError"
1414
:options="field.options"
1515
:disabled="isReadonly"
1616
>
@@ -19,14 +19,17 @@
1919
</option>
2020
</SelectControl>
2121

22-
<BasicButton
23-
class="shadow relative ml-2 bg-primary-500 hover:bg-primary-400 active:bg-primary-600 text-white dark:text-gray-900"
22+
<button
23+
type="button"
2424
v-if="showUpdateButton"
2525
:title="__('Update')"
2626
@click.stop="submit"
27+
class="shadow relative ml-2 flex h-9 items-center justify-center rounded-lg px-2 bg-primary-500 hover:bg-primary-400 active:bg-primary-600 text-white dark:text-gray-900"
2728
>
28-
<Icon type="play" solid />
29-
</BasicButton>
29+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="h-4 w-4">
30+
<path d="M6.3 2.84A1.5 1.5 0 0 0 4 4.11v11.78a1.5 1.5 0 0 0 2.3 1.27l9.34-5.89a1.5 1.5 0 0 0 0-2.54L6.3 2.84Z" />
31+
</svg>
32+
</button>
3033
</template>
3134

3235
<template v-else>

resources/js/components/IndexField.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<SelectControl
55
:id="field.uniqueKey"
66
:dusk="field.attribute"
7-
v-model:selected="value"
8-
@change="attemptUpdate"
7+
v-model="value"
8+
@selected="attemptUpdate"
99
@click.stop
1010
class="w-full"
11-
:select-classes="{ 'form-input-border-error': hasError }"
11+
:has-error="hasError"
1212
:options="field.options"
1313
:disabled="isReadonly"
1414
>
@@ -17,14 +17,17 @@
1717
</option>
1818
</SelectControl>
1919

20-
<BasicButton
21-
class="shadow relative ml-2 bg-primary-500 hover:bg-primary-400 active:bg-primary-600 text-white dark:text-gray-900"
20+
<button
21+
type="button"
2222
v-if="showUpdateButton"
2323
:title="__('Update')"
2424
@click.stop="submit"
25+
class="shadow relative ml-2 flex h-9 items-center justify-center rounded-lg px-2 bg-primary-500 hover:bg-primary-400 active:bg-primary-600 text-white dark:text-gray-900"
2526
>
26-
<Icon type="play" solid />
27-
</BasicButton>
27+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="h-4 w-4">
28+
<path d="M6.3 2.84A1.5 1.5 0 0 0 4 4.11v11.78a1.5 1.5 0 0 0 2.3 1.27l9.34-5.89a1.5 1.5 0 0 0 0-2.54L6.3 2.84Z" />
29+
</svg>
30+
</button>
2831
</template>
2932

3033
<template v-else>

resources/js/components/mixins/inline.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ export default {
2727
async submit() {
2828
let formData = new FormData();
2929

30-
formData.append(this.field.attribute, this.value);
30+
formData.append(this.field.attribute, this.value ?? '');
3131
formData.append('_method', 'PUT');
3232

3333
return Nova.request().post(`/nova-api/${this.resourceName}/${this.resourceId}`, formData)
3434
.then(() => {
35-
let label = find(this.field.options, option => option.value === this.value).label;
35+
let option = find(this.field.options, option => option.value == this.value);
36+
let label = option ? option.label : this.value;
3637

3738
Nova.success(`${this.field.name} updated to "${label}"`);
3839
}, (response) => {
@@ -43,10 +44,18 @@ export default {
4344
});
4445
},
4546

46-
attemptUpdate(value) {
47-
this.value = value;
47+
attemptUpdate(optionOrEvent) {
48+
/*
49+
* Nova v5's SelectControl emits `@selected` with the selected option object.
50+
* Fall back to reading a native event target (older behaviour) just in case.
51+
*/
52+
if (optionOrEvent?.target) {
53+
this.value = optionOrEvent.target.value;
54+
} else if (optionOrEvent != null && optionOrEvent.value !== undefined) {
55+
this.value = optionOrEvent.value;
56+
}
4857

49-
if (this.field.indexTwoStepDisabled ?? false) {
58+
if (this.twoStepDisabled) {
5059
return this.submit();
5160
}
5261

0 commit comments

Comments
 (0)