Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Commit

Permalink
add prettier to format js style
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparclex committed Nov 1, 2018
1 parent 5e0d2c2 commit 4510b31
Show file tree
Hide file tree
Showing 5 changed files with 7,870 additions and 61 deletions.
2 changes: 1 addition & 1 deletion dist/js/card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
"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"
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"check-format": "prettier --list-different 'resources/**/*.{css,js,vue}'",
"format": "prettier --write 'resources/**/*.{css,js,vue}'",
"lint": "eslint resources/js --fix --ext js,vue"
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0"
"laravel-mix": "^1.0",
"prettier": "^1.14.2",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-vue": "^4.4.0"
},
"dependencies": {
"vue": "^2.5.0"
Expand Down
4 changes: 2 additions & 2 deletions resources/js/card.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Nova.booting((Vue, router) => {
Nova.booting(Vue => {
Vue.component('nova-import-card', require('./components/Card'));
})
});
114 changes: 58 additions & 56 deletions resources/js/components/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<div class="py-4">
<span class="form-file mr-4">
<input
ref="fileField"
class="form-file-input"
type="file"
id="import-file"
name="name"
@change="fileChange"
ref="fileField"
class="form-file-input"
type="file"
id="import-file"
name="name"
@change="fileChange"
/>
<label for="import-file" class="form-file-btn btn btn-default btn-primary">
{{__('Choose File')}}
Expand All @@ -28,9 +28,9 @@
<p class="text-danger">{{firstError}}</p>
</div>
<button
:disabled="working"
type="submit"
class="btn btn-default btn-primary ml-auto"
:disabled="working"
type="submit"
class="btn btn-default btn-primary ml-auto"
>
<loader v-if="working" width="30"></loader>
<span v-else>{{__('Import')}}</span>
Expand All @@ -42,58 +42,60 @@
</template>

<script>
export default {
props: ['card'],
export default {
props: ['card'],
data() {
return {
fileName: '',
file: null,
label: 'no file selected',
working: false,
errors: null,
};
},
data() {
return {
fileName: '',
file: null,
label: 'no file selected',
working: false,
errors: null
mounted() {
//
},
}
methods: {
fileChange(event) {
let path = event.target.value;
let fileName = path.match(/[^\\/]*$/)[0];
this.fileName = fileName;
this.file = this.$refs.fileField.files[0];
},
mounted() {
//
processImport() {
this.working = true;
let formData = new FormData();
formData.append('file', this.file);
Nova.request()
.post(
'/nova-vendor/sparclex/nova-import-card/endpoint/' + this.card.resource,
formData
)
.then(({ data }) => {
this.$toasted.success(data.message);
this.$parent.$parent.$parent.$parent.getResources();
})
.catch(({ response }) => {
this.errors = response.data.errors;
})
.finally(() => (this.working = false));
},
methods: {
fileChange(event) {
let path = event.target.value
let fileName = path.match(/[^\\/]*$/)[0]
this.fileName = fileName
this.file = this.$refs.fileField.files[0]
},
processImport() {
this.working = true;
let formData = new FormData();
formData.append('file', this.file);
Nova.request().post('/nova-vendor/sparclex/nova-import-card/endpoint/' + this.card.resource, formData)
.then(({data}) => {
this.$toasted.success(data.message);
this.$parent.$parent.$parent.$parent.getResources();
})
.catch(({response}) => {
this.errors = response.data.errors;
})
.finally(() => this.working = false);
}
},
computed: {
/**
* The current label of the file field
*/
currentLabel() {
return this.fileName || this.label;
},
computed: {
/**
* The current label of the file field
*/
currentLabel() {
return this.fileName || this.label
},
firstError() {
return this.errors ? this.errors[Object.keys(this.errors)[0]][0] : null;
}
}
}
firstError() {
return this.errors ? this.errors[Object.keys(this.errors)[0]][0] : null;
},
},
};
</script>
Loading

0 comments on commit 4510b31

Please sign in to comment.