Skip to content

Commit

Permalink
Merge pull request #19 from the-alichemist/nova-4-upgrade
Browse files Browse the repository at this point in the history
Nova 4 upgrade
Very big thanks to @the-alichemist
  • Loading branch information
domthomas-dev authored Aug 24, 2022
2 parents c9f6ae6 + c77308b commit 40807d2
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 259 deletions.
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
}
],
"require": {
"php": ">=7.1.0"
"php": ">=7.1.0",
"laravel/nova":"^4.0"
},
"require-dev": {
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0"
"orchestra/testbench": "v7.4.0",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
Expand All @@ -39,6 +40,12 @@
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"config": {
"sort-packages": true
},
Expand Down
2 changes: 2 additions & 0 deletions dist/css/tool.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import url(https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css);

3 changes: 2 additions & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/js/tool.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*!
* vuex v4.0.2
* (c) 2021 Evan You
* @license MIT
*/
6 changes: 3 additions & 3 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/tool.js": "/js/tool.js?id=e49fc7b7e737d1ce30aa",
"/css/tool.css": "/css/tool.css?id=d41d8cd98f00b204e980"
}
"/js/tool.js": "/js/tool.js",
"/css/tool.css": "/css/tool.css"
}
33 changes: 33 additions & 0 deletions nova.mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const mix = require('laravel-mix')
const webpack = require('webpack')
const path = require('path')

class NovaExtension {
name() {
return 'nova-extension'
}

register(name) {
this.name = name
}

webpackConfig(webpackConfig) {
webpackConfig.externals = {
vue: 'Vue',
}

webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias || {}),
'laravel-nova': path.join(
__dirname,
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
),
}

webpackConfig.output = {
uniqueName: this.name,
}
}
}

mix.extend('nova', new NovaExtension())
25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"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",
"watch-poll": "npm run watch -- --watch-poll",
"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",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
"production": "mix --production"
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0"
"@vue/compiler-sfc": "^3.2.22",
"cross-env": "^5.2.1",
"laravel-mix": "^6.0.41",
"postcss": "^8.3.11",
"resolve-url-loader": "^2.3.2",
"sass": "^1.51.0",
"sass-loader": "^12.6.0",
"vue-loader": "^16.8.3"
},
"dependencies": {
"vue": "^2.5.0",
"laravel-nova": "^1.2.2"
"@inertiajs/inertia": "^0.11.0",
"vue": "^3.0",
"vuex": "^4.0.2"
}
}
245 changes: 124 additions & 121 deletions resources/js/components/DefaultField.vue
Original file line number Diff line number Diff line change
@@ -1,127 +1,130 @@
<template>
<div :class="elementSize">
<field-wrapper :stacked="field.stacked">
<div class="px-8" :class="field.stacked ? 'pt-6 w-full' : 'py-6 w-1/5'">
<slot>
<form-label
:label-for="field.attribute"
:class="{ 'mb-2': showHelpText && field.helpText }"
>
{{ fieldLabel }}

<span v-if="field.required" class="text-danger text-sm">{{
__('*')
}}</span>
</form-label>
</slot>
</div>
<div class="py-6 px-8" :class="fieldClasses">
<slot name="field"/>

<help-text
class="error-text mt-2 text-danger"
v-if="showErrors && hasError"
>
{{ firstError }}
</help-text>

<help-text class="help-text mt-2" v-if="showHelpText">
{{ field.helpText }}
</help-text>
</div>
</field-wrapper>
</div>
<div :class="elementSize">
<field-wrapper :stacked="field.stacked">
<div class="px-8" :class="field.stacked ? 'pt-6 w-full' : 'py-6 w-1/5'">
<slot>
<form-label
:label-for="field.attribute"
:class="{ 'mb-2': showHelpText && field.helpText }"
>
{{ fieldLabel }}

<span v-if="field.required" class="text-danger text-sm">{{
__("*")
}}</span>
</form-label>
</slot>
</div>
<div class="py-6 px-8" :class="fieldClasses">
<slot name="field" />

<help-text
class="error-text mt-2 text-danger"
v-if="showErrors && hasError"
>
{{ firstError }}
</help-text>

<help-text class="help-text mt-2" v-if="showHelpText">
{{ field.helpText }}
</help-text>
</div>
</field-wrapper>
</div>
</template>

<script>
import {HandlesValidationErrors, Errors} from 'laravel-nova'
export default {
mixins: [HandlesValidationErrors],
props: {
field: {type: Object, required: true},
fieldName: {type: String},
showHelpText: {type: Boolean, default: true},
showErrors: {type: Boolean, default: true},
fullWidthContent: {type: Boolean, default: false},
},
mounted() {
// If field has a size, this allows to use flex on card
if(this.hasSize) {
this.$parent.$parent.$el.classList.add('flex-dom')
this.$parent.$parent.$el.classList.add('flex-wrap')
this.$parent.$parent.$el.classList.add('flex')
// Use for eminiarts/nova-tabs package
if(document.getElementsByClassName('relationship-tabs-panel')){
var tabs = document.getElementsByClassName('relationship-tabs-panel')
for(var i = 0; i < tabs.length; i++) {
tabs.item(i).className += " w-full"
}
this.$parent.$el.parentElement.classList.add('flex')
this.$parent.$el.parentElement.classList.add('flex-wrap')
}
if(document.getElementsByClassName('action').length > 0){
document.getElementsByClassName('action').item(0).parentElement.classList.add('flex')
document.getElementsByClassName('action').item(0).parentElement.classList.add('flex-wrap')
}
}
if(this.getRemoveBottomBorder === true){
this.$el.children[0].classList.add('remove-bottom-border')
} else if(this.getRemoveBottomBorder === false){
this.$el.children[0].classList.remove('remove-bottom-border')
}
},
computed: {
/**
* Return the label that should be used for the field.
*/
fieldLabel() {
// If the field name is purposefully an empty string, then let's show it as such
if (this.fieldName === '') {
return ''
}
return this.fieldName || this.field.name || this.field.singularLabel
},
/**
* Return the classes that should be used for the field content.
*/
fieldClasses() {
return this.fullWidthContent
? this.field.stacked
? 'w-full'
: 'w-4/5'
: this.hasSize
? 'w-full'
: 'w-1/2'
},
/**
* Return the size that should be used for the field container.
*/
elementSize() {
return this.field.size || 'w-full'
},
/**
* Return if the field has a size
*/
hasSize() {
return this.field.size !== undefined;
},
/**
* Return if we must to remove or not the bottom border field
*/
getRemoveBottomBorder() {
return this.field.removeBottomBorder || null
}
},
import { HandlesValidationErrors, Errors } from "laravel-nova";
export default {
mixins: [HandlesValidationErrors],
props: {
field: { type: Object, required: true },
fieldName: { type: String },
showHelpText: { type: Boolean, default: true },
showErrors: { type: Boolean, default: true },
fullWidthContent: { type: Boolean, default: false },
},
mounted() {
if (!this.hasSize) {
this.$el.parentElement.classList.add("w-full");
}
// If field has a size, this allows to use flex on card
if (this.hasSize & this.$parent.$parent.$parent.selectedTab === undefined) {
this.$parent.$parent.$el.classList.add("flex-dom");
this.$parent.$parent.$el.classList.add("flex-wrap");
this.$parent.$parent.$el.classList.add("flex");
}
//Use for eminiarts/nova-tabs package
if (
this.hasSize &
(this.$parent.$parent.$parent.selectedTab !== undefined)
) {
this.$el.classList.add("inline-block");
}
if (this.getRemoveBottomBorder === true) {
this.$el.children[0].classList.add("remove-bottom-border");
} else if (this.getRemoveBottomBorder === false) {
this.$el.children[0].classList.remove("remove-bottom-border");
}
},
computed: {
/**
* Return the label that should be used for the field.
*/
fieldLabel() {
// If the field name is purposefully an empty string, then let's show it as such
if (this.fieldName === "") {
return "";
}
return this.fieldName || this.field.name || this.field.singularLabel;
},
/**
* Return the classes that should be used for the field content.
*/
fieldClasses() {
return this.fullWidthContent
? this.field.stacked
? "w-full"
: "w-4/5"
: this.hasSize
? "w-full"
: "w-1/2";
},
/**
* Return the size that should be used for the field container.
*/
elementSize() {
return this.field.size || "w-full";
},
/**
* Return if the field has a size
*/
hasSize() {
return this.field.size !== undefined;
},
/**
* Return if we must to remove or not the bottom border field
*/
getRemoveBottomBorder() {
return this.field.removeBottomBorder || null;
},
},
};
</script>
Loading

0 comments on commit 40807d2

Please sign in to comment.