-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jake Casto
committed
Mar 13, 2019
1 parent
41ce6de
commit 8414128
Showing
12 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.idea | ||
/vendor | ||
/node_modules | ||
package-lock.json | ||
composer.phar | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "lynndigital/custom-resource-toolbar", | ||
"description": "A Laravel Nova resource tool.", | ||
"keywords": [ | ||
"laravel", | ||
"nova" | ||
], | ||
"license": "MIT", | ||
"require": { | ||
"php": ">=7.1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Lynndigital\\CustomResourceToolbar\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Lynndigital\\CustomResourceToolbar\\ToolServiceProvider" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"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", | ||
"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" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^5.0.0", | ||
"laravel-mix": "^1.0" | ||
}, | ||
"dependencies": { | ||
"vue": "^2.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<div class="flex w-full justify-end items-center mx-3"> | ||
<component v-if="hasComponent" :is="component" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['resourceName', 'resourceId'], | ||
computed: { | ||
component(){ | ||
return this.resourceName + '-detail-toolbar'; | ||
}, | ||
hasComponent() | ||
{ | ||
return this.component in this.$options.components; | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div> | ||
<div class="flex w-full justify-end items-center"> | ||
<a | ||
class="btn btn-default btn-icon btn-white" | ||
:href="'/nova-vendor/custom-resource-toolbar/export-quote/' + this.$parent.resourceId" | ||
style="background-color: var(--primary); color: white;"> | ||
Export as PDF | ||
</a> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['resourceName', 'resourceId', 'field'], | ||
mounted() { | ||
var elements = document.getElementById('nova').querySelectorAll('h4'); | ||
[].forEach.call(elements, function(element) { | ||
if(element.innerHTML === 'Custom Detail Toolbar') { | ||
element.parentNode.remove(); | ||
} | ||
}); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<div> | ||
<div class="flex w-full justify-end items-center"> | ||
<a | ||
title="Back to Quote" | ||
class="btn btn-default btn-icon btn-white" | ||
:href="`/nova/resources/quotes/${this.parentResourceId}`"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path class="heroicon-ui" d="M5.41 11H21a1 1 0 0 1 0 2H5.41l5.3 5.3a1 1 0 0 1-1.42 1.4l-7-7a1 1 0 0 1 0-1.4l7-7a1 1 0 0 1 1.42 1.4L5.4 11z"/></svg> | ||
</a> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['resourceName', 'resourceId', 'field'], | ||
data() { | ||
return { | ||
parentResourceId: '' | ||
} | ||
}, | ||
created() { | ||
this.fetch() | ||
}, | ||
mounted() { | ||
var elements = document.getElementById('nova').querySelectorAll('h4'); | ||
[].forEach.call(elements, function(element) { | ||
if(element.innerHTML === 'Custom Detail Toolbar') { | ||
element.parentNode.remove(); | ||
} | ||
}); | ||
}, | ||
methods: { | ||
fetch() { | ||
Nova.request().get(`/nova-vendor/custom-resource-toolbar/parent/${this.$parent.resourceId}`) | ||
.then(response => { | ||
this.parentResourceId = response.data.id; | ||
}); | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Nova.booting((Vue, router) => { | ||
Vue.component('custom-detail-toolbar', require('./components/CustomDetailToolbar')); | ||
|
||
Vue.component('quote-items-detail-toolbar', require('./components/QuoteItemsDetailToolbar')); | ||
|
||
Vue.component('quotes-detail-toolbar', require('./components/QuoteDetailToolbar')); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Nova Tool CSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Tool API Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you may register API routes for your tool. These routes | ||
| are loaded by the ServiceProvider of your tool. You're free to add | ||
| as many additional routes to this file as your tool may require. | ||
| | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace Lynndigital\CustomResourceToolbar; | ||
|
||
use Laravel\Nova\ResourceTool; | ||
|
||
class CustomResourceToolbar extends ResourceTool | ||
{ | ||
/** | ||
* Get the displayable name of the resource tool. | ||
* | ||
* @return string | ||
*/ | ||
public function name() | ||
{ | ||
return 'Custom Detail Toolbar'; | ||
} | ||
|
||
/** | ||
* Get the component name for the resource tool. | ||
* | ||
* @return string | ||
*/ | ||
public function component() | ||
{ | ||
return 'custom-detail-toolbar'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Lynndigital\CustomResourceToolbar; | ||
|
||
use Laravel\Nova\Nova; | ||
use Laravel\Nova\Events\ServingNova; | ||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class ToolServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->app->booted(function () { | ||
$this->routes(); | ||
}); | ||
|
||
Nova::serving(function (ServingNova $event) { | ||
Nova::script('custom-resource-toolbar', __DIR__.'/../dist/js/tool.js'); | ||
Nova::style('custom-resource-toolbar', __DIR__.'/../dist/css/tool.css'); | ||
}); | ||
} | ||
|
||
/** | ||
* Register the tool's routes. | ||
* | ||
* @return void | ||
*/ | ||
protected function routes() | ||
{ | ||
if ($this->app->routesAreCached()) { | ||
return; | ||
} | ||
|
||
Route::middleware(['nova']) | ||
->prefix('nova-vendor/custom-resource-toolbar') | ||
->group(__DIR__.'/../routes/api.php'); | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let mix = require('laravel-mix') | ||
|
||
mix.setPublicPath('dist') | ||
.js('resources/js/tool.js', 'js') | ||
.sass('resources/sass/tool.scss', 'css') |