LINTER FOLKS. LINTER.

This commit is contained in:
mateuswetah 2018-03-23 10:20:37 -03:00
parent f98553f1f3
commit 0b5dfa8b30
37 changed files with 949 additions and 114 deletions

16
.eslintrc.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
extends: [
// add more generic rulesets here, such as:
'eslint:recommended',
'plugin:vue/essential'
],
rules: {
// override/add rules settings here, such as:
'vue/no-unused-vars': 'error',
"no-console": "warn",
"no-unused-vars": "warn",
"no-undef": "warn",
"vue/no-side-effects-in-computed-properties": "warn",
"vue/return-in-computed-property": "warn"
}
}

822
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,9 @@
"css-loader": "^0.25.0",
"cypress": "^2.1.0",
"element-theme-chalk": "^2.1.0",
"eslint": "^4.19.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-vue": "^4.4.0",
"file-loader": "^0.9.0",
"postcss-loader": "^2.1.0",
"sass-resources-loader": "^1.3.2",

View File

@ -118,7 +118,9 @@
<p class="help is-danger">{{formErrorMessage}}</p>
</form>
<b-loading :active.sync="isLoading" :canCancel="false"></b-loading>
<b-loading
:active.sync="isLoading"
:canCancel="false"></b-loading>
</div>
</div>
</template>
@ -224,7 +226,6 @@
status: 'private',
allowInsert: this.form.allowInsert
};
console.log(data);
this.updateCategory(data)

View File

@ -128,7 +128,7 @@
class="button is-success">{{ $i18n.get('save') }}</button>
</div>
</div>
<p class="help is-danger">{{formErrorMessage}}</p>
<p class="help is-danger">{{formErrorMessage}}</p>
</form>
<b-loading :active.sync="isLoading" :canCancel="false"></b-loading>
@ -280,7 +280,7 @@ export default {
deleteThumbnail() {
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: 0})
.then((res) => {
.then(() => {
this.collection.featured_image = false;
})
.catch((error) => {

View File

@ -188,7 +188,7 @@ export default {
if ((field.field_type_object && field.field_type_object.form_component) || field.edit_form == '') {
this.updateField({collectionId: this.collectionId, fieldId: field.id, isRepositoryLevel: this.isRepositoryLevel, index: this.index, options: this.editForm})
.then((field) => {
.then(() => {
this.editForm = {};
this.formErrors = {};
this.formErrorMessage = '';
@ -215,7 +215,7 @@ export default {
formObj[key] = value;
this.updateField({collectionId: this.collectionId, fieldId: field.id, isRepositoryLevel: this.isRepositoryLevel, index: this.index, options: formObj})
.then((field) => {
.then(() => {
this.editForm = {};
this.formErrors = {};
this.formErrorMessage = '';

View File

@ -130,7 +130,7 @@ export default {
if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') {
this.updateFilter({ filterId: filter.id, index: this.index, options: this.editForm})
.then((filter) => {
.then(() => {
this.editForm = {};
this.formErrors = {};
this.formErrorMessage = '';
@ -157,7 +157,7 @@ export default {
formObj[key] = value;
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj})
.then((filter) => {
.then(() => {
this.editForm = {};
this.formErrors = {};
this.formErrorMessage = '';

View File

@ -195,7 +195,7 @@ export default {
this.$router.push(this.$routerHelper.getItemPath(this.form.collectionId, this.itemId));
}).catch(error => {
console.log(error);
this.isLoading = false;
});
},
@ -234,7 +234,7 @@ export default {
},
loadMetadata() {
// Obtains Item Field
this.fetchFields(this.itemId).then(res => {
this.fetchFields(this.itemId).then(() => {
this.isLoading = false;
});
},
@ -245,7 +245,7 @@ export default {
for (let file of $event) {
this.sendAttachment({ item_id: this.itemId, file: file })
.then((res) => {
.then(() => {
})
.catch((error) => {
@ -273,7 +273,7 @@ export default {
},
deleteThumbnail() {
this.updateThumbnail({itemId: this.itemId, thumbnailId: 0})
.then((res) => {
.then(() => {
this.item.featured_image = false;
})
.catch((error) => {
@ -281,7 +281,7 @@ export default {
});
},
deleteFile(index) {
console.log("Delete:" + index);
}
},
computed: {

View File

@ -14,7 +14,6 @@
v-if="totalCategories > 0"
ref="categoryTable"
:data="categories"
@selection-change="handleSelectionChange"
:checked-rows.sync="selectedCategories"
checkable
:loading="isLoading"
@ -150,7 +149,7 @@
for (let category of this.selectedCategories) {
this.deleteCategory(category.id)
.then((res) => {
.then(() => {
this.loadCategories();
this.$toast.open({
duration: 3000,
@ -159,7 +158,7 @@
type: 'is-secondary',
queue: false
})
}).catch((err) => {
}).catch(() => {
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_error_deleting_category'),
@ -173,8 +172,6 @@
}
});
},
handleSelectionChange(value) {
},
goToCategoryPage(categoryId) {
this.$router.push(this.$routerHelper.getCategoryPath(categoryId));
},

View File

@ -6,7 +6,6 @@
<b-table
ref="collectionTable"
:data="collections"
@selection-change="handleSelectionChange"
:checked-rows.sync="selectedCollections"
checkable
:loading="isLoading"
@ -70,7 +69,7 @@
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import { mapActions } from 'vuex'
export default {
name: 'CollectionsList',
@ -126,7 +125,7 @@ export default {
for (let collection of this.selectedCollections) {
this.deleteCollection(collection.id)
.then((res) => {
.then(() => {
this.loadCollections();
this.$toast.open({
duration: 3000,
@ -135,7 +134,7 @@ export default {
type: 'is-secondary',
queue: false
})
}).catch((err) => {
}).catch(() => {
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_error_deleting_collection'),
@ -149,8 +148,6 @@ export default {
}
});
},
handleSelectionChange(value) {
},
goToCollectionPage(collectionId) {
this.$router.push(this.$routerHelper.getCollectionPath(collectionId));
},

View File

@ -220,7 +220,7 @@ export default {
if (!this.isRepositoryLevel)
this.updateFieldsOrder();
})
.catch((error) => {
.catch(() => {
});
},
editField(field) {
@ -270,10 +270,10 @@ export default {
this.isLoadingFields = true;
this.fetchFieldTypes()
.then((res) => {
.then(() => {
this.isLoadingFieldTypes = false;
})
.catch((error) => {
.catch(() => {
this.isLoadingFieldTypes = false;
});
@ -285,10 +285,10 @@ export default {
this.fetchFields({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
.then((res) => {
.then(() => {
this.isLoadingFields = false;
})
.catch((error) => {
.catch(() => {
this.isLoadingFields = false;
});
}

View File

@ -9,7 +9,6 @@
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import { eventFilterBus } from '../../../js/event-bus-filters'
export default {
data(){

View File

@ -280,17 +280,15 @@ export default {
this.activeFilterList.splice(index, 1);
this.isLoadingFieldTypes = true;
this.fetchFields({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
.then((res) => {
.then(() => {
this.isLoadingFieldTypes = false;
})
.catch((error) => {
.catch(() => {
this.isLoadingFieldTypes = false;
});
if (!this.isRepositoryLevel)
this.updateFiltersOrder();
})
.catch((error) => {
});
},
confirmSelectedFilterType() {
@ -379,26 +377,26 @@ export default {
this.isLoadingFilterTypes = true;
this.fetchFilterTypes()
.then((res) => {
.then(() => {
this.isLoadingFilterTypes = false;
})
.catch((error) => {
.catch(() => {
this.isLoadingFilterTypes = false;
});
this.fetchFilters({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
.then((res) => {
.then(() => {
this.isLoadingFilters = false;
// Needs to be done after activeFilterList exists to compare and remove chosen fields.
this.fetchFields({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
.then((res) => {
.then(() => {
this.isLoadingFieldTypes = false;
})
.catch((error) => {
.catch(() => {
this.isLoadingFieldTypes = false;
});
})
.catch((error) => {
.catch(() => {
this.isLoadingFilters = false;
});
}

View File

@ -65,7 +65,7 @@
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import { mapActions } from 'vuex';
export default {
name: 'ItemsList',
@ -92,7 +92,7 @@ export default {
this.$dialog.confirm({
message: this.$i18n.get('info_warning_item_delete'),
onConfirm: () => {
this.deleteItem(itemId).then((res) => {
this.deleteItem(itemId).then(() => {
this.loadItems();
this.$toast.open({
duration: 3000,
@ -105,7 +105,7 @@ export default {
if (this.selectedItems[i].id == this.itemId)
this.selectedItems.splice(i, 1);
}
}).catch(( error ) => {
}).catch(() => {
this.$toast.open({
duration: 3000,
@ -125,7 +125,7 @@ export default {
for (let item of this.selectedItems) {
this.deleteItem(item.id)
.then((res) => {
.then(() => {
this.loadItems();
this.$toast.open({
duration: 3000,
@ -135,7 +135,7 @@ export default {
queue: false
});
}).catch((err) => {
}).catch(() => {
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_error_deleting_item'),

View File

@ -58,7 +58,7 @@ export default {
}
},
watch: {
'$route' (to, from) {
'$route' (to) {
this.isCompressed = (to.params.collectionId != undefined);
this.activeRoute = to.name;
}

View File

@ -69,7 +69,7 @@ export default {
id: Number
},
watch: {
'$route' (to, from) {
'$route' (to) {
this.activeRoute = to.name;
}
},

View File

@ -93,7 +93,7 @@ export default {
}
},
watch: {
'$route' (to, from) {
'$route' (to) {
this.onSecondaryPage = (to.params.collectionId != undefined);
this.pageTitle = this.$route.meta.title;
this.currentIcon = this.$route.meta.icon;

View File

@ -56,7 +56,7 @@ export default {
border-radius: 10px;
margin: 0px 0px 0px -37px;
position: absolute;
z-index: 99999999999999;
z-index: 999999999999999;
bottom: 100%;
left: 0%;
min-width: 250px;

View File

@ -103,7 +103,7 @@
this.isLoading = false;
this.totalCategories = res.total;
})
.catch((error) => {
.catch(() => {
this.isLoading = false;
});
},
@ -126,7 +126,7 @@
.then((value) => {
this.categoriesPerPage = value;
})
.catch((error) => {
.catch(() => {
this.$userPrefs.set('categories_per_page', 12, null);
});
},

View File

@ -103,7 +103,7 @@ export default {
this.isLoading = false;
this.totalCollections = res.total;
})
.catch((error) => {
.catch(() => {
this.isLoading = false;
});
},
@ -126,7 +126,7 @@ export default {
.then((value) => {
this.collectionsPerPage = value;
})
.catch((error) => {
.catch(() => {
this.$userPrefs.set('collections_per_page', 12, null);
});
},

View File

@ -135,7 +135,7 @@ export default {
'search_by_collection'
]),
onChangeTableFields(field) {
let prevValue = this.prefTableFields;
// let prevValue = this.prefTableFields;
let index = this.prefTableFields.findIndex(alteredField => alteredField.slug === field.slug);
if (index >= 0) {
//prevValue[index].visible = this.prefTableFields[index].visible ? false : true;
@ -187,11 +187,10 @@ export default {
this.alterQueryString();
}
promisse.then((res) => {
promisse.then(() => {
this.isLoading = false;
})
.catch((error) => {
.catch(() => {
this.isLoading = false;
});
},
@ -233,7 +232,7 @@ export default {
.then((value) => {
this.itemsPerPage = value;
})
.catch((error) => {
.catch(() => {
this.$userPrefs.set('items_per_page', 12, null);
});
},
@ -307,11 +306,12 @@ export default {
background-color: $primary-lighter;
margin-left: -$page-small-side-padding;
padding: $page-small-side-padding;
.label {
font-size: 12px;
font-weight: normal;
font-size: 0.85em;
}
}
.table-container {

View File

@ -70,7 +70,7 @@ export default {
let loadingInstance = this;
// Obtains Item
this.fetchItem(this.itemId).then(res => {
this.fetchItem(this.itemId).then(() => {
loadingInstance.isLoading = false;
});
}

View File

@ -22,7 +22,7 @@
v-model="parent">
<option :value="0" selected> ---{{ $i18n.get('label_parent_term') }}--- </option>
<option
v-for="option,index in options"
v-for="(option,index) in options"
:key="index"
:value="option.term_id"
v-html="setSpaces( option.level ) + option.name"></option>
@ -97,7 +97,7 @@
if( !Array.isArray( val ) && this.field.field.multiple === 'no' ){
axios.patch(`/item/${this.item_id}/metadata/${this.field_id}`, {
values: term_id,
}).then( res => {
}).then(() => {
instance.$emit('newTerm', term_id);
})
} else {

View File

@ -1,6 +1,8 @@
<template>
<div>
<div v-for="option,index in options">
<div
v-for="(option, index) in options"
:key="index">
<b-checkbox
:id="id"
:style="{ paddingLeft: (option.level * 30) + 'px' }"

View File

@ -1,6 +1,8 @@
<template>
<div>
<div v-for="option,index in options">
<div
v-for="(option, index) in options"
:key="index">
<b-radio
:id="id"
:style="{ paddingLeft: (option.level * 30) + 'px' }"

View File

@ -7,7 +7,7 @@
@input="emitChange()"
:placeholder="$i18n.get('label_select_category')" expanded>
<option
v-for="option,index in options"
v-for="(option, index) in options"
:key="index"
:value="option.term_id"
v-html="setSpaces( option.level ) + option.name"></option>

View File

@ -45,7 +45,7 @@
@input="emitValues()"
v-model="input_type">
<option
v-for="option,index in single_types"
v-for="(option, index) in single_types"
:value="index"
:key="index">
{{ option }}
@ -60,7 +60,7 @@
v-else>
<option
v-for="option,index in multiple_types"
v-for="(option, index) in multiple_types"
:value="index"
:key="index">
{{ option }}
@ -102,7 +102,7 @@
errors: [ String, Object, Array ]
},
created(){
this.fetchTaxonomies().then( res => {
this.fetchTaxonomies().then(() => {
if ( this.value ) {
this.taxonomy_id = this.value.taxonomy_id;
}
@ -124,12 +124,12 @@
if( this.field && this.field.multiple === 'no' ){
let types = Object.keys( this.single_types );
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-radio';
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-radio';
return true;
} else {
let types = Object.keys( this.multiple_types );
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-checkbox';
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-checkbox';
return false;
}
},

View File

@ -45,7 +45,8 @@
</label>
<div class="block">
<div
v-for="option in fields"
v-for="(option, index) in fields"
:key="index"
class="field">
<b-checkbox
name="field_type_relationship[search][]"
@ -82,7 +83,6 @@
<script>
import { tainacan as axios } from '../../../js/axios/axios';
import Vue from 'vue';
export default {
props: {
@ -125,7 +125,7 @@
}
},
created(){
this.fetchCollections().then( data => {
this.fetchCollections().then(() => {
if( this.collection_id && this.collection_id !== '' ){
this.collection = this.collection_id;
} else if ( this.value ) {
@ -165,7 +165,6 @@
})
.catch(error => {
console.log(error);
reject(error);
});
},
fetchFieldsFromCollection( value ){
@ -198,7 +197,7 @@
})
}
})
.catch((error) => {
.catch(() => {
this.hasFields = false;
});

View File

@ -5,7 +5,7 @@
v-model="selected"
@input="onChecked()">
<option
v-for="option,index in getOptions"
v-for="(option, index) in getOptions"
:key="index"
:label="option"
:value="option"

View File

@ -1,29 +1,29 @@
<template>
<b-field
:addons="false"
:label="field.field.name"
:message="getErrorMessage"
:type="fieldTypeMessage">
<help-button
:title="field.field.name"
:message="field.field.description">
</help-button>
<div v-if="isTextInputComponent( field.field.field_type_object.component )">
<component :id="field.field.field_type_object.component + '-' + field.field.slug" :is="field.field.field_type_object.component" v-model="inputs[0]" :field="field" @blur="changeValue()"></component>
<div v-if="field.field.multiple == 'yes'">
<div v-if="index > 0" v-for="(input, index) in inputsList " v-bind:key="index" class="multiple-inputs">
<component :id="field.field.field_type_object.component + '-' + field.field.slug" :is="field.field.field_type_object.component" v-model="inputs[index]" :field="field" @blur="changeValue()"></component><a class="button" v-if="index > 0" @click="removeInput(index)">-</a>
</div>
<a class="button" @click="addInput">+</a>
<b-field
:addons="false"
:label="field.field.name"
:message="getErrorMessage"
:type="fieldTypeMessage">
<help-button
:title="field.field.name"
:message="field.field.description">
</help-button>
<div v-if="isTextInputComponent( field.field.field_type_object.component )">
<component :id="field.field.field_type_object.component + '-' + field.field.slug" :is="field.field.field_type_object.component" v-model="inputs[0]" :field="field" @blur="changeValue()"></component>
<div v-if="field.field.multiple == 'yes'">
<div v-if="index > 0" v-for="(input, index) in inputsList " v-bind:key="index" class="multiple-inputs">
<component :id="field.field.field_type_object.component + '-' + field.field.slug" :is="field.field.field_type_object.component" v-model="inputs[index]" :field="field" @blur="changeValue()"></component><a class="button" v-if="index > 0" @click="removeInput(index)">-</a>
</div>
<a class="button" @click="addInput">+</a>
</div>
<div v-else>
<component
:id="field.field.field_type_object.component + '-' + field.field.slug"
:is="field.field.field_type_object.component" v-model="inputs"
:field="field" @blur="changeValue()"></component>
</div>
</b-field>
</div>
<div v-else>
<component
:id="field.field.field_type_object.component + '-' + field.field.slug"
:is="field.field.field_type_object.component" v-model="inputs"
:field="field" @blur="changeValue()"></component>
</div>
</b-field>
</template>
<script>

View File

@ -33,9 +33,6 @@
this.inputValue = $event;
this.$emit('input', this.inputValue);
}
},
created(){
this.inputValue = this.value;
}
}
</script>

View File

@ -34,9 +34,6 @@
this.inputValue = $event;
this.$emit('input', this.inputValue);
}
},
created(){
this.inputValue = this.value;
}
}
</script>

View File

@ -1,7 +1,7 @@
<template>
<div class="block">
<div
v-for="option,index in options"
v-for="(option, index) in options"
:key="index"
class="field">
<b-checkbox
@ -53,11 +53,11 @@
}
},
methods: {
loadOptions(){
loadOptions(){deleteFile
let promise = null;
this.isLoading = true;
if ( this.type === 'Tainacan\Field_types\Relationship' ) {
if ( this.type === 'Tainacan\\Field_types\\Relationship' ) {
let collectionTarget = ( this.filter && this.filter.field.field_type_options.collection_id ) ?
this.filter.field.field_type_options.collection_id : this.collection_id;
@ -67,7 +67,7 @@
promise = this.getValuesPlainText( this.field );
}
promise.then( data => {
promise.then(() => {
this.isLoading = false;
this.selectedValues()
})

View File

@ -8,7 +8,7 @@
expanded>
<option value="">{{ $i18n.get('label_selectbox_init') }}...</option>
<option
v-for="option,index in options"
v-for="(option, index) in options"
:key="index"
:label="option.label"
:value="option.value"
@ -66,7 +66,7 @@
promise = this.getValuesPlainText( this.field );
}
promise.then( data => {
promise.then(() => {
this.isLoading = false;
instance.selectedValues();
})

View File

@ -81,7 +81,7 @@
promise = this.getValuesPlainText( this.field, query );
}
promise.then( data => {
promise.then(() => {
this.isLoading = false;
}).catch( error => {
console.log('error select', error );

View File

@ -15,7 +15,6 @@
<script>
import { eventFilterBus } from '../../js/event-bus-filters'
import qs from 'qs';
import { mapActions, mapGetters } from 'vuex';
import router from '../../admin/js/router'

View File

@ -14,6 +14,12 @@ module.exports = {
devtool: 'eval-source-map',
module: {
rules: [
{
enforce: "pre",
test: /\.vue$/,
exclude: /node_modules/,
loader: "eslint-loader"
},
{
test: /\.vue$/,
loader: 'vue-loader',