Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit f73fe3d

Browse files
committed
Initial commit
0 parents  commit f73fe3d

20 files changed

+494
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.idea
2+
/vendor
3+
/node_modules
4+
package-lock.json
5+
composer.phar
6+
composer.lock
7+
phpunit.xml
8+
.phpunit.result.cache
9+
.DS_Store
10+
Thumbs.db

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "codebykyle/calculated-field",
3+
"description": "A Laravel Nova field.",
4+
"keywords": [
5+
"laravel",
6+
"nova"
7+
],
8+
"license": "MIT",
9+
"require": {
10+
"php": ">=7.1.0"
11+
},
12+
"autoload": {
13+
"psr-4": {
14+
"Codebykyle\\CalculatedField\\": "src/"
15+
}
16+
},
17+
"extra": {
18+
"laravel": {
19+
"providers": [
20+
"Codebykyle\\CalculatedField\\FieldServiceProvider"
21+
]
22+
}
23+
},
24+
"config": {
25+
"sort-packages": true
26+
},
27+
"minimum-stability": "dev",
28+
"prefer-stable": true
29+
}

dist/css/field.css

Whitespace-only changes.

dist/js/field.js

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

dist/mix-manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"/js/field.js": "/js/field.js",
3+
"/css/field.css": "/css/field.css"
4+
}

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "npm run development",
5+
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6+
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7+
"watch-poll": "npm run watch -- --watch-poll",
8+
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9+
"prod": "npm run production",
10+
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11+
},
12+
"devDependencies": {
13+
"cross-env": "^5.0.0",
14+
"laravel-mix": "^1.0",
15+
"laravel-nova": "^1.0"
16+
},
17+
"dependencies": {
18+
"vue": "^2.5.0"
19+
}
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<panel-item :field="field" />
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: ['resource', 'resourceName', 'resourceId', 'field'],
8+
}
9+
</script>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<template>
2+
<default-field :field="field" :errors="errors">
3+
<template slot="field">
4+
<input
5+
:id="field.name"
6+
:type="this.field.type"
7+
class="w-full form-control form-input form-input-bordered"
8+
:class="errorClasses"
9+
:placeholder="field.name"
10+
:value="value"
11+
@input="setFieldAndMessage"
12+
/>
13+
</template>
14+
</default-field>
15+
</template>
16+
17+
<script>
18+
import { FormField, HandlesValidationErrors } from 'laravel-nova'
19+
20+
export default {
21+
mixins: [FormField, HandlesValidationErrors],
22+
23+
props: ['resourceName', 'resourceId', 'field'],
24+
25+
methods: {
26+
setFieldAndMessage(el) {
27+
const rawValue = el.target.value;
28+
let parsedValue = rawValue;
29+
30+
if (this.field.type === 'number') {
31+
parsedValue = Number(rawValue)
32+
}
33+
34+
Nova.$emit(this.field.broadcastTo, {
35+
'field_name': this.field.attribute,
36+
'value': parsedValue
37+
});
38+
39+
this.value = parsedValue;
40+
},
41+
42+
/*
43+
* Set the initial, internal value for the field.
44+
*/
45+
setInitialValue() {
46+
this.value = this.field.value || ''
47+
},
48+
49+
/**
50+
* Fill the given FormData object with the field's internal value.
51+
*/
52+
fill(formData) {
53+
formData.append(this.field.attribute, this.value || '')
54+
},
55+
56+
/**
57+
* Update the field's internal value.
58+
*/
59+
handleChange(value) {
60+
this.value = value
61+
},
62+
},
63+
}
64+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<span>{{ field.value }}</span>
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: ['resourceName', 'field'],
8+
}
9+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<panel-item :field="field" />
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: ['resource', 'resourceName', 'resourceId', 'field'],
8+
}
9+
</script>

0 commit comments

Comments
 (0)