-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Showing
15 changed files
with
101 additions
and
115 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
/*! | ||
* vuex v4.0.2 | ||
* (c) 2021 Evan You | ||
* @license MIT | ||
*/ | ||
|
||
/** | ||
* @license | ||
* Lodash <https://lodash.com/> | ||
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"/js/field.js": "/js/field.js", | ||
"/css/field.css": "/css/field.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,40 @@ | ||
const mix = require('laravel-mix') | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
|
||
class NovaExtension { | ||
name() { | ||
return 'nova-extension' | ||
} | ||
|
||
register(name) { | ||
this.name = name | ||
} | ||
|
||
webpackPlugins() { | ||
return new webpack.ProvidePlugin({ | ||
_: 'lodash', | ||
Errors: 'form-backend-validation', | ||
}) | ||
} | ||
|
||
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()) |
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
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
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
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
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 |
---|---|---|
@@ -1,87 +1,11 @@ | ||
import {Errors} from "laravel-nova"; | ||
//import {Errors} from "laravel-nova"; | ||
|
||
Nova.booting((Vue, router, store) => { | ||
Vue.component('index-nova-tab-translatable', require('./components/IndexField')) | ||
Vue.component('detail-nova-tab-translatable', require('./components/DetailField')) | ||
Vue.component('form-nova-tab-translatable', require('./components/FormField')) | ||
import IndexField from './components/IndexField' | ||
import DetailField from './components/DetailField' | ||
import FormField from './components/FormField' | ||
|
||
const BaseFormFileField = Vue.options.components["form-file-field"]; | ||
const CustomFormFileField = BaseFormFileField.extend({ | ||
props: [ | ||
'resourceId', | ||
'relatedResourceName', | ||
'relatedResourceId', | ||
'viaRelationship', | ||
'dataDefault', | ||
], | ||
methods: { | ||
async removeFile() { | ||
this.uploadErrors = new Errors() | ||
|
||
const { | ||
resourceName, | ||
resourceId, | ||
relatedResourceName, | ||
relatedResourceId, | ||
viaRelationship, | ||
} = this | ||
const attribute = this.field.attribute | ||
|
||
var uri = | ||
this.viaRelationship && | ||
this.relatedResourceName && | ||
this.relatedResourceId | ||
? `/nova-api/kongulov/nova-tab-translatable/${resourceName}/${resourceId}/${relatedResourceName}/${relatedResourceId}/field/${attribute}?viaRelationship=${viaRelationship}` | ||
: `/nova-api/kongulov/nova-tab-translatable/${resourceName}/${resourceId}/field/${attribute}` | ||
|
||
if (!this.dataDefault){ | ||
uri = | ||
this.viaRelationship && | ||
this.relatedResourceName && | ||
this.relatedResourceId | ||
? `/nova-api/${resourceName}/${resourceId}/${relatedResourceName}/${relatedResourceId}/field/${attribute}?viaRelationship=${viaRelationship}` | ||
: `/nova-api/${resourceName}/${resourceId}/field/${attribute}` | ||
} | ||
|
||
try { | ||
await Nova.request().delete(uri) | ||
this.closeRemoveModal() | ||
this.deleted = true | ||
this.$emit('file-deleted') | ||
Nova.success(this.__('The file was deleted!')) | ||
} catch (error) { | ||
this.closeRemoveModal() | ||
|
||
if (error.response.status == 422) { | ||
this.uploadErrors = new Errors(error.response.data.errors) | ||
} | ||
} | ||
}, | ||
} | ||
}) | ||
Vue.component('form-file-field', CustomFormFileField) | ||
|
||
const BaseDetailFileField = Vue.options.components["detail-file-field"]; | ||
const CustomDetailFileField = BaseDetailFileField.extend({ | ||
props: ['resource', 'resourceName', 'resourceId', 'field', 'dataDefault'], | ||
methods: { | ||
download() { | ||
const { resourceName, resourceId } = this | ||
const attribute = this.field.attribute | ||
|
||
let link = document.createElement('a') | ||
|
||
link.href = `/nova-api/kongulov/nova-tab-translatable/${resourceName}/${resourceId}/download/${attribute}` | ||
if (!this.dataDefault) { | ||
link.href = `/nova-api/${resourceName}/${resourceId}/download/${attribute}` | ||
} | ||
|
||
link.download = 'download' | ||
document.body.appendChild(link) | ||
link.click() | ||
document.body.removeChild(link) | ||
}, | ||
} | ||
}) | ||
Vue.component('detail-file-field', CustomDetailFileField) | ||
Nova.booting((app, Vue, router, store) => { | ||
app.component('index-nova-tab-translatable', IndexField) | ||
app.component('detail-nova-tab-translatable', DetailField) | ||
app.component('form-nova-tab-translatable', FormField) | ||
}) |
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
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
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
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
let mix = require('laravel-mix') | ||
let path = require('path') | ||
|
||
require('./nova.mix') | ||
|
||
mix | ||
.setPublicPath('dist') | ||
.js('resources/js/field.js', 'js') | ||
.sass('resources/sass/field.scss', 'css') | ||
.setPublicPath('dist') | ||
.js('resources/js/field.js', 'js') | ||
.vue({ version: 3 }) | ||
.sass('resources/sass/field.scss', 'css') | ||
.nova('kongulov/nova-tab-translatable') |