Possibility of hide or not a field by default
This commit is contained in:
parent
73b6b9493a
commit
6bbb596fc3
|
@ -57,37 +57,37 @@ class Admin {
|
|||
wp_enqueue_style( 'tainacan-admin-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-admin.css' );
|
||||
|
||||
$undesired_wp_styles = [
|
||||
//'admin-menu',
|
||||
//'admin-bar',
|
||||
//'code-editor',
|
||||
//'color-picker',
|
||||
//'customize-controls',
|
||||
//'customize-nav-menus',
|
||||
//'customize-widgets',
|
||||
//'dashboard',
|
||||
//'dashicons',
|
||||
//'deprecated-media',
|
||||
//'edit',
|
||||
//'wp-pointer',
|
||||
//'farbtastic',
|
||||
//'forms',
|
||||
//'common',
|
||||
//'install',
|
||||
//'wp-auth-check',
|
||||
//'site-icon',
|
||||
//'buttons',
|
||||
//'l10n',
|
||||
//'list-tables',
|
||||
//'login',
|
||||
//'media',
|
||||
//'nav-menus',
|
||||
//'revisions',
|
||||
//'themes',
|
||||
//'widgets',
|
||||
//'wp-admin'
|
||||
'admin-menu',
|
||||
'admin-bar',
|
||||
'code-editor',
|
||||
'color-picker',
|
||||
'customize-controls',
|
||||
'customize-nav-menus',
|
||||
'customize-widgets',
|
||||
'dashboard',
|
||||
'dashicons',
|
||||
'deprecated-media',
|
||||
'edit',
|
||||
'wp-pointer',
|
||||
'farbtastic',
|
||||
'forms',
|
||||
'common',
|
||||
'install',
|
||||
'wp-auth-check',
|
||||
'site-icon',
|
||||
'buttons',
|
||||
'l10n',
|
||||
'list-tables',
|
||||
'login',
|
||||
'media',
|
||||
'nav-menus',
|
||||
'revisions',
|
||||
'themes',
|
||||
'widgets',
|
||||
'wp-admin'
|
||||
];
|
||||
|
||||
//wp_dequeue_style( $undesired_wp_styles );
|
||||
wp_dequeue_style( $undesired_wp_styles );
|
||||
wp_deregister_style( $undesired_wp_styles );
|
||||
|
||||
}
|
||||
|
|
|
@ -1,167 +1,180 @@
|
|||
<template>
|
||||
<form
|
||||
id="fieldEditForm"
|
||||
class="tainacan-form"
|
||||
@submit.prevent="saveEdition(editForm)">
|
||||
|
||||
<b-field
|
||||
<form
|
||||
id="fieldEditForm"
|
||||
class="tainacan-form"
|
||||
@submit.prevent="saveEdition(editForm)">
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['name'] != undefined ? formErrors['name'] : ''">
|
||||
:type="formErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['name'] != undefined ? formErrors['name'] : ''">
|
||||
<label class="label">
|
||||
{{ $i18n.get('label_name') }}
|
||||
<span
|
||||
class="required-field-asterisk"
|
||||
:class="formErrors['name'] != undefined ? 'is-danger' : ''">*</span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'name')"
|
||||
{{ $i18n.get('label_name') }}
|
||||
<span
|
||||
class="required-field-asterisk"
|
||||
:class="formErrors['name'] != undefined ? 'is-danger' : ''">*</span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'name')"
|
||||
:message="$i18n.getHelperMessage('fields', 'name')"/>
|
||||
</label>
|
||||
<b-input
|
||||
v-model="editForm.name"
|
||||
name="name"
|
||||
<b-input
|
||||
v-model="editForm.name"
|
||||
name="name"
|
||||
@focus="clearErrors('name')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
|
||||
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['description'] != undefined ? formErrors['description'] : ''">
|
||||
<label class="label">
|
||||
{{ $i18n.get('label_description') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'description')"
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'description')"
|
||||
:message="$i18n.getHelperMessage('fields', 'description')"/>
|
||||
</label>
|
||||
<b-input
|
||||
type="textarea"
|
||||
name="description"
|
||||
v-model="editForm.description"
|
||||
@focus="clearErrors('description')" />
|
||||
<b-input
|
||||
type="textarea"
|
||||
name="description"
|
||||
v-model="editForm.description"
|
||||
@focus="clearErrors('description')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
:type="formErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['status'] != undefined ? formErrors['status'] : ''">
|
||||
<label class="label">
|
||||
{{ $i18n.get('label_status') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'status')"
|
||||
{{ $i18n.get('label_status') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'status')"
|
||||
:message="$i18n.getHelperMessage('fields', 'status')"/>
|
||||
</label>
|
||||
<div class="inline-block">
|
||||
<b-radio
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-publish"
|
||||
name="status"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="publish">
|
||||
{{ $i18n.get('publish_visibility') }}
|
||||
</b-radio>
|
||||
<br>
|
||||
<b-radio
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-private"
|
||||
name="status"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="private">
|
||||
{{ $i18n.get('private_visibility') }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_display')">
|
||||
|
||||
<!-- Display on listing -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_display')">
|
||||
<b-field
|
||||
:type="formErrors['required'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['required'] != undefined ? formErrors['required'] : ''">
|
||||
<b-checkbox
|
||||
:type="formErrors['display'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['display'] != undefined ? formErrors['display'] : ''">
|
||||
<b-radio
|
||||
size="is-small"
|
||||
@input="clearErrors('required')"
|
||||
v-model="editForm.required"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="required">
|
||||
@input="clearErrors('display')"
|
||||
v-model="editForm.display"
|
||||
native-value="yes"
|
||||
name="display">
|
||||
{{ $i18n.get('label_display_default') }}
|
||||
</b-checkbox>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'required')"
|
||||
:message="$i18n.getHelperMessage('fields', 'required')"/>
|
||||
</b-radio>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'display')"
|
||||
:message="$i18n.getHelperMessage('fields', 'display')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<b-radio
|
||||
size="is-small"
|
||||
@input="clearErrors('display')"
|
||||
v-model="editForm.display"
|
||||
native-value="no"
|
||||
name="display">
|
||||
{{ $i18n.get('label_not_display') }}
|
||||
</b-radio>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'display')"
|
||||
:message="$i18n.getHelperMessage('fields', 'display')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
|
||||
<b-checkbox
|
||||
size="is-small"
|
||||
@input="clearErrors('multiple')"
|
||||
v-model="editForm.multiple"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="multiple">
|
||||
:type="formErrors['display'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['display'] != undefined ? formErrors['display'] : ''">
|
||||
<b-radio
|
||||
size="is-small"
|
||||
v-model="editForm.display"
|
||||
@input="clearErrors('display')"
|
||||
native-value="never"
|
||||
name="display">
|
||||
{{ $i18n.get('label_display_never') }}
|
||||
</b-checkbox>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'multiple')"
|
||||
:message="$i18n.getHelperMessage('fields', 'multiple')"/>
|
||||
</b-radio>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'display')"
|
||||
:message="$i18n.getHelperMessage('fields', 'display')"/>
|
||||
</b-field>
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_options')">
|
||||
<b-field
|
||||
:type="formErrors['required'] != undefined ? 'is-danger' : ''"
|
||||
:type="formErrors['required'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['required'] != undefined ? formErrors['required'] : ''">
|
||||
<b-checkbox
|
||||
size="is-small"
|
||||
@input="clearErrors('required')"
|
||||
v-model="editForm.required"
|
||||
true-value="yes"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="required">
|
||||
{{ $i18n.get('label_required') }}
|
||||
</b-checkbox>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'required')"
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'required')"
|
||||
:message="$i18n.getHelperMessage('fields', 'required')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
|
||||
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
|
||||
<b-checkbox
|
||||
<b-checkbox
|
||||
size="is-small"
|
||||
@input="clearErrors('multiple')"
|
||||
v-model="editForm.multiple"
|
||||
true-value="yes"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="multiple">
|
||||
{{ $i18n.get('label_allow_multiple') }}
|
||||
</b-checkbox>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'multiple')"
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'multiple')"
|
||||
:message="$i18n.getHelperMessage('fields', 'multiple')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:type="formErrors['unique'] != undefined ? 'is-danger' : ''"
|
||||
<b-field
|
||||
:type="formErrors['unique'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['unique'] != undefined ? formErrors['unique'] : ''">
|
||||
<b-checkbox
|
||||
size="is-small"
|
||||
size="is-small"
|
||||
@input="clearErrors('unique')"
|
||||
v-model="editForm.unique"
|
||||
true-value="yes"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="collecion_key">
|
||||
{{ $i18n.get('label_unique_value') }}
|
||||
</b-checkbox>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'unique')"
|
||||
:message="$i18n.getHelperMessage('fields', 'unique')"/>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'unique')"
|
||||
:message="$i18n.getHelperMessage('fields', 'unique')"/>
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
|
@ -171,21 +184,23 @@
|
|||
:is="editForm.field_type_object.form_component"
|
||||
:field="editForm"
|
||||
v-model="editForm.field_type_options"/>
|
||||
<div
|
||||
v-html="editForm.edit_form"
|
||||
<div
|
||||
v-html="editForm.edit_form"
|
||||
v-else/>
|
||||
|
||||
<div class="field is-grouped form-submit">
|
||||
<div class="field is-grouped form-submit">
|
||||
<div class="control">
|
||||
<button
|
||||
class="button is-outlined"
|
||||
@click.prevent="cancelEdition()"
|
||||
slot="trigger">{{ $i18n.get('cancel') }}</button>
|
||||
<button
|
||||
class="button is-outlined"
|
||||
@click.prevent="cancelEdition()"
|
||||
slot="trigger">{{ $i18n.get('cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button
|
||||
class="button is-success"
|
||||
type="submit">{{ $i18n.get('save') }}</button>
|
||||
<button
|
||||
class="button is-success"
|
||||
type="submit">{{ $i18n.get('save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
|
@ -193,117 +208,129 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import {mapActions} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'FieldEditionForm',
|
||||
data(){
|
||||
return {
|
||||
editForm: {},
|
||||
oldForm: {},
|
||||
formErrors: {},
|
||||
formErrorMessage: '',
|
||||
closedByForm: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
index: '',
|
||||
editedField: Object,
|
||||
originalField: Object,
|
||||
isRepositoryLevel: false,
|
||||
collectionId: ''
|
||||
},
|
||||
created() {
|
||||
|
||||
this.editForm = this.editedField;
|
||||
this.formErrors = this.editForm.formErrors != undefined ? this.editForm.formErrors : {};
|
||||
this.formErrorMessage = this.editForm.formErrors != undefined ? this.editForm.formErrorMessage : '';
|
||||
|
||||
this.oldForm = JSON.parse(JSON.stringify(this.originalField));
|
||||
export default {
|
||||
name: 'FieldEditionForm',
|
||||
data() {
|
||||
return {
|
||||
editForm: {},
|
||||
oldForm: {},
|
||||
formErrors: {},
|
||||
formErrorMessage: '',
|
||||
closedByForm: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
index: '',
|
||||
editedField: Object,
|
||||
originalField: Object,
|
||||
isRepositoryLevel: false,
|
||||
collectionId: ''
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.closedByForm) {
|
||||
this.editedField.saved = true;
|
||||
} else {
|
||||
this.oldForm.saved = this.editForm.saved;
|
||||
if (JSON.stringify(this.editForm) != JSON.stringify(this.oldForm))
|
||||
this.editedField.saved = false;
|
||||
else
|
||||
this.editForm = this.editedField;
|
||||
this.formErrors = this.editForm.formErrors != undefined ? this.editForm.formErrors : {};
|
||||
this.formErrorMessage = this.editForm.formErrors != undefined ? this.editForm.formErrorMessage : '';
|
||||
|
||||
this.oldForm = JSON.parse(JSON.stringify(this.originalField));
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.closedByForm) {
|
||||
this.editedField.saved = true;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('fields', [
|
||||
'updateField'
|
||||
]),
|
||||
saveEdition(field) {
|
||||
|
||||
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(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
this.formErrorMessage = '';
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.formErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$emit('onErrorFound');
|
||||
|
||||
this.editForm.formErrors = this.formErrors;
|
||||
this.editForm.formErrorMessage = this.formErrorMessage;
|
||||
});
|
||||
} else {
|
||||
let formElement = document.getElementById('fieldEditForm');
|
||||
let formData = new FormData(formElement);
|
||||
let formObj = {}
|
||||
this.oldForm.saved = this.editForm.saved;
|
||||
if (JSON.stringify(this.editForm) != JSON.stringify(this.oldForm))
|
||||
this.editedField.saved = false;
|
||||
else
|
||||
this.editedField.saved = true;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('fields', [
|
||||
'updateField'
|
||||
]),
|
||||
saveEdition(field) {
|
||||
|
||||
for (let [key, value] of formData.entries())
|
||||
formObj[key] = value;
|
||||
|
||||
this.updateField({collectionId: this.collectionId, fieldId: field.id, isRepositoryLevel: this.isRepositoryLevel, index: this.index, options: formObj})
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
this.formErrorMessage = '';
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionFinished');
|
||||
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
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.formErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$emit('onErrorFound');
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
this.formErrorMessage = '';
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.formErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$emit('onErrorFound');
|
||||
|
||||
this.editForm.formErrors = this.formErrors;
|
||||
this.editForm.formErrorMessage = this.formErrorMessage;
|
||||
});
|
||||
}
|
||||
},
|
||||
clearErrors(attribute) {
|
||||
this.formErrors[attribute] = undefined;
|
||||
},
|
||||
cancelEdition() {
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionCanceled');
|
||||
},
|
||||
this.editForm.formErrors = this.formErrors;
|
||||
this.editForm.formErrorMessage = this.formErrorMessage;
|
||||
});
|
||||
} else {
|
||||
let formElement = document.getElementById('fieldEditForm');
|
||||
let formData = new FormData(formElement);
|
||||
let formObj = {};
|
||||
|
||||
for (let [key, value] of formData.entries())
|
||||
formObj[key] = value;
|
||||
|
||||
this.updateField({
|
||||
collectionId: this.collectionId,
|
||||
fieldId: field.id,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
index: this.index,
|
||||
options: formObj
|
||||
})
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
this.formErrorMessage = '';
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.formErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$emit('onErrorFound');
|
||||
|
||||
this.editForm.formErrors = this.formErrors;
|
||||
this.editForm.formErrorMessage = this.formErrorMessage;
|
||||
});
|
||||
}
|
||||
},
|
||||
clearErrors(attribute) {
|
||||
this.formErrors[attribute] = undefined;
|
||||
},
|
||||
cancelEdition() {
|
||||
this.closedByForm = true;
|
||||
this.$emit('onEditionCanceled');
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@import "../../scss/_variables.scss";
|
||||
|
||||
|
||||
form {
|
||||
padding: 1.0em 2.0em;
|
||||
border-top: 1px solid $draggable-border-color;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
:key="index"
|
||||
:custom-key="column.slug"
|
||||
:label="column.name"
|
||||
:visible="column.visible"
|
||||
:visible="column.display"
|
||||
:class="column.field == 'row_creation' ? 'row-creation' : ''"
|
||||
:width="column.field == 'row_actions' ? 78 : column.field == 'row_thumbnail' ? 55 : undefined ">
|
||||
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
<span>
|
||||
<div class="header-item">
|
||||
<b-dropdown>
|
||||
<button
|
||||
class="button"
|
||||
<button
|
||||
class="button"
|
||||
slot="trigger">
|
||||
<span>{{ $i18n.get('label_table_fields') }}</span>
|
||||
<b-icon icon="menu-down"/>
|
||||
</button>
|
||||
<b-dropdown-item
|
||||
v-for="(column, index) in tableFields"
|
||||
<b-dropdown-item
|
||||
v-for="(column, index) in tableFields"
|
||||
:key="index"
|
||||
class="control"
|
||||
class="control"
|
||||
custom>
|
||||
<b-checkbox
|
||||
v-model="column.visible"
|
||||
v-model="column.display"
|
||||
:native-value="column.field">
|
||||
{{ column.name }}
|
||||
</b-checkbox>
|
||||
|
@ -24,23 +24,24 @@
|
|||
<div class="header-item">
|
||||
<b-field>
|
||||
<b-select
|
||||
@input="onChangeOrderBy($event)"
|
||||
@input="onChangeOrderBy($event)"
|
||||
:placeholder="$i18n.get('label_sorting')">
|
||||
<option
|
||||
v-for="field in tableFields"
|
||||
v-if="
|
||||
v-for="field in tableFields"
|
||||
v-if="
|
||||
field.id == 'date' || (
|
||||
field.id != undefined &&
|
||||
field.field_type_object.related_mapped_prop != 'description' &&
|
||||
field.field_type_object.primitive_type != 'term' &&
|
||||
field.field_type_object.primitive_type != 'item' &&
|
||||
field.field_type_object.primitive_type != 'compound')"
|
||||
:value="field"
|
||||
:key="field.id">
|
||||
field.id != undefined &&
|
||||
field.field_type_object.related_mapped_prop != 'description' &&
|
||||
field.field_type_object.primitive_type != 'term' &&
|
||||
field.field_type_object.primitive_type != 'item' &&
|
||||
field.field_type_object.primitive_type != 'compound'
|
||||
)"
|
||||
:value="field"
|
||||
:key="field.id">
|
||||
{{ field.name }}
|
||||
</option>
|
||||
</b-select>
|
||||
<button
|
||||
<button
|
||||
class="button is-small"
|
||||
@click="onChangeOrder()">
|
||||
<b-icon :icon="order == 'ASC' ? 'sort-ascending' : 'sort-descending'"/>
|
||||
|
@ -51,41 +52,41 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import {mapGetters} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'SearchControl',
|
||||
data() {
|
||||
return {
|
||||
prefTableFields: []
|
||||
}
|
||||
},
|
||||
props: {
|
||||
collectionId: Number,
|
||||
isRepositoryLevel: false,
|
||||
tableFields: Array
|
||||
},
|
||||
computed: {
|
||||
orderBy() {
|
||||
return this.getOrderBy();
|
||||
export default {
|
||||
name: 'SearchControl',
|
||||
data() {
|
||||
return {
|
||||
prefTableFields: []
|
||||
}
|
||||
},
|
||||
order() {
|
||||
return this.getOrder();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('search', [
|
||||
'getOrderBy',
|
||||
'getOrder'
|
||||
]),
|
||||
onChangeOrderBy(field) {
|
||||
this.$eventBusSearch.setOrderBy(field);
|
||||
props: {
|
||||
collectionId: Number,
|
||||
isRepositoryLevel: false,
|
||||
tableFields: Array
|
||||
},
|
||||
onChangeOrder() {
|
||||
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
||||
computed: {
|
||||
orderBy() {
|
||||
return this.getOrderBy();
|
||||
},
|
||||
order() {
|
||||
return this.getOrder();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('search', [
|
||||
'getOrderBy',
|
||||
'getOrder'
|
||||
]),
|
||||
onChangeOrderBy(field) {
|
||||
this.$eventBusSearch.setOrderBy(field);
|
||||
},
|
||||
onChangeOrder() {
|
||||
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -1,37 +1,53 @@
|
|||
<template>
|
||||
<div
|
||||
class="page-container-small"
|
||||
<template>
|
||||
<div
|
||||
class="page-container-small"
|
||||
:class="{'primary-page': isRepositoryLevel}">
|
||||
<div class="sub-header">
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="isLoadingFields"/>
|
||||
<div class="header-item">
|
||||
<router-link
|
||||
id="button-create-item"
|
||||
tag="button"
|
||||
class="button is-secondary"
|
||||
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
||||
{{ $i18n.getFrom('items', 'new_item') }}
|
||||
</router-link>
|
||||
|
||||
<b-dropdown>
|
||||
<button
|
||||
class="button is-secondary"
|
||||
slot="trigger">
|
||||
<span>{{ `${$i18n.get('add')} ${$i18n.get('item')}` }}</span>
|
||||
<b-icon icon="menu-down"/>
|
||||
</button>
|
||||
|
||||
<b-dropdown-item class="tainacan-dropdown-item">
|
||||
<router-link
|
||||
id="a-create-item"
|
||||
tag="div"
|
||||
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
||||
{{ `${$i18n.get('add_one_item')}` }}
|
||||
</router-link>
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item>Adicionar itens em massa <br>
|
||||
<small class="is-small">Eu quero café</small>
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item>Adicionar item de fonte externa</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
|
||||
</div>
|
||||
<search-control
|
||||
v-if="fields.length > 0 && (items.length != 0 || isLoadingItems)"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
v-if="fields.length > 0 && (items.length > 0 || isLoadingItems)"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:collection-id="collectionId"
|
||||
:table-fields="tableFields"
|
||||
:pref-table-fields="prefTableFields"/>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<aside class="column filters-menu">
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="isLoadingFilters"/>
|
||||
<h3>{{ $i18n.get('filters') }}</h3>
|
||||
<filters-items-list
|
||||
v-if="!isLoadingFilters && filters.length > 0"
|
||||
<filters-items-list
|
||||
v-if="!isLoadingFilters && filters.length > 0"
|
||||
:filters="filters"/>
|
||||
<section
|
||||
<section
|
||||
v-else
|
||||
class="is-grouped-centered section">
|
||||
<div class="content has-text-gray has-text-centered">
|
||||
|
@ -40,29 +56,30 @@
|
|||
icon="filter-outline"
|
||||
size="is-large"/>
|
||||
</p>
|
||||
<p>{{ $i18n.get('info_there_is_no_filter' ) }}</p>
|
||||
<p>{{ $i18n.get('info_there_is_no_filter' ) }}</p>
|
||||
<router-link
|
||||
id="button-create-filter"
|
||||
:to="isRepositoryLevel ? $routerHelper.getNewFilterPath() : $routerHelper.getNewCollectionFilterPath(collectionId)"
|
||||
tag="button"
|
||||
tag="button"
|
||||
class="button is-secondary is-centered">
|
||||
{{ $i18n.getFrom('filters', 'new_item') }}</router-link>
|
||||
{{ $i18n.getFrom('filters', 'new_item') }}
|
||||
</router-link>
|
||||
</div>
|
||||
</section>
|
||||
</aside>
|
||||
<div class="column">
|
||||
<div class="table-container above-subheader">
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="isLoadingItems"/>
|
||||
<items-list
|
||||
v-if="!isLoadingItems && items.length > 0"
|
||||
:collection-id="collectionId"
|
||||
:table-fields="tableFields"
|
||||
:items="items"
|
||||
:items="items"
|
||||
:is-loading="isLoading"/>
|
||||
<section
|
||||
v-if="!isLoadingItems && items.length <= 0"
|
||||
<section
|
||||
v-if="!isLoadingItems && items.length <= 0"
|
||||
class="section">
|
||||
<div class="content has-text-grey has-text-centered">
|
||||
<p>
|
||||
|
@ -70,11 +87,12 @@
|
|||
icon="inbox"
|
||||
size="is-large"/>
|
||||
</p>
|
||||
<p>{{ hasFiltered ? $i18n.get('info_no_item_found') : $i18n.get('info_no_item_created') }}</p>
|
||||
<p>{{ hasFiltered ? $i18n.get('info_no_item_found') : $i18n.get('info_no_item_created')
|
||||
}}</p>
|
||||
<router-link
|
||||
v-if="!hasFiltered"
|
||||
id="button-create-item"
|
||||
tag="button"
|
||||
id="button-create-item"
|
||||
tag="button"
|
||||
class="button is-primary"
|
||||
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
||||
{{ $i18n.getFrom('items', 'new_item') }}
|
||||
|
@ -85,127 +103,180 @@
|
|||
<pagination v-if="items.length > 0"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SearchControl from '../../components/search/search-control.vue'
|
||||
import ItemsList from '../../components/lists/items-list.vue';
|
||||
import FiltersItemsList from '../../components/search/filters-items-list.vue';
|
||||
import Pagination from '../../components/search/pagination.vue'
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import SearchControl from '../../components/search/search-control.vue'
|
||||
import ItemsList from '../../components/lists/items-list.vue';
|
||||
import FiltersItemsList from '../../components/search/filters-items-list.vue';
|
||||
import Pagination from '../../components/search/pagination.vue'
|
||||
import {mapActions, mapGetters} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'ItemsPage',
|
||||
data(){
|
||||
return {
|
||||
isRepositoryLevel: false,
|
||||
tableFields: [],
|
||||
prefTableFields: [],
|
||||
isLoadingItems: false,
|
||||
isLoadingFilters: false,
|
||||
isLoadingFields: false,
|
||||
hasFiltered: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
collectionId: Number
|
||||
},
|
||||
components: {
|
||||
SearchControl,
|
||||
ItemsList,
|
||||
FiltersItemsList,
|
||||
Pagination
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('collection', [
|
||||
'getItems'
|
||||
]),
|
||||
...mapActions('fields', [
|
||||
'fetchFields'
|
||||
]),
|
||||
...mapGetters('fields', [
|
||||
'getFields'
|
||||
]),
|
||||
...mapActions('filter',[
|
||||
'fetchFilters'
|
||||
]),
|
||||
...mapGetters('filter', [
|
||||
'getFilters'
|
||||
])
|
||||
},
|
||||
computed: {
|
||||
items(){
|
||||
return this.getItems();
|
||||
},
|
||||
filters(){
|
||||
return this.getFilters();
|
||||
},
|
||||
fields() {
|
||||
return this.getFields();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
this.isRepositoryLevel = (this.collectionId == undefined);
|
||||
|
||||
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {
|
||||
this.isLoadingItems = isLoadingItems;
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasFiltered', hasFiltered => {
|
||||
this.hasFiltered = hasFiltered;
|
||||
});
|
||||
|
||||
this.isLoadingFilters = true;
|
||||
this.fetchFilters( { collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: true })
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
this.isLoadingFields = true;
|
||||
this.fetchFields({ collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: false }).then(() => {
|
||||
|
||||
this.tableFields.push({ name: this.$i18n.get('label_thumbnail'), field: 'row_thumbnail', field_type: undefined, slug: 'featured_image', id: undefined, visible: true });
|
||||
for (let field of this.fields) {
|
||||
this.tableFields.push(
|
||||
{name: field.name, field: field.description, slug: field.slug, field_type: field.field_type, field_type_object: field.field_type_object, id: field.id, visible: true }
|
||||
);
|
||||
export default {
|
||||
name: 'ItemsPage',
|
||||
data() {
|
||||
return {
|
||||
isRepositoryLevel: false,
|
||||
tableFields: [],
|
||||
prefTableFields: [],
|
||||
isLoadingItems: false,
|
||||
isLoadingFilters: false,
|
||||
isLoadingFields: false,
|
||||
hasFiltered: false
|
||||
}
|
||||
|
||||
this.tableFields.push({ name: this.$i18n.get('label_creation'), field: 'row_creation', field_type: undefined, slug: 'creation', id: 'date', visible: true});
|
||||
this.tableFields.push({ name: this.$i18n.get('label_actions'), field: 'row_actions', field_type: undefined, slug: 'actions', id: undefined, visible: true });
|
||||
|
||||
//this.prefTableFields = this.tableFields;
|
||||
// this.$userPrefs.get('table_columns_' + this.collectionId)
|
||||
// .then((value) => {
|
||||
// this.prefTableFields = value;
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, null);
|
||||
// });
|
||||
this.isLoadingFields = false;
|
||||
},
|
||||
props: {
|
||||
collectionId: Number
|
||||
},
|
||||
components: {
|
||||
SearchControl,
|
||||
ItemsList,
|
||||
FiltersItemsList,
|
||||
Pagination
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('collection', [
|
||||
'getItems'
|
||||
]),
|
||||
...mapActions('fields', [
|
||||
'fetchFields'
|
||||
]),
|
||||
...mapGetters('fields', [
|
||||
'getFields'
|
||||
]),
|
||||
...mapActions('filter', [
|
||||
'fetchFilters'
|
||||
]),
|
||||
...mapGetters('filter', [
|
||||
'getFilters'
|
||||
])
|
||||
},
|
||||
computed: {
|
||||
items() {
|
||||
return this.getItems();
|
||||
},
|
||||
filters() {
|
||||
return this.getFilters();
|
||||
},
|
||||
fields() {
|
||||
return this.getFields();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
this.isRepositoryLevel = (this.collectionId == undefined);
|
||||
|
||||
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {
|
||||
this.isLoadingItems = isLoadingItems;
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasFiltered', hasFiltered => {
|
||||
this.hasFiltered = hasFiltered;
|
||||
});
|
||||
|
||||
this.isLoadingFilters = true;
|
||||
this.fetchFilters({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: true
|
||||
})
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
this.isLoadingFields = true;
|
||||
|
||||
this.fetchFields({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
this.tableFields.push({
|
||||
name: this.$i18n.get('label_thumbnail'),
|
||||
field: 'row_thumbnail',
|
||||
field_type: undefined,
|
||||
slug: 'featured_image',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
|
||||
for (let field of this.fields) {
|
||||
if (field.display !== 'never') {
|
||||
// Will be pushed on array
|
||||
|
||||
let display = true;
|
||||
|
||||
if (field.display === 'no') {
|
||||
display = false;
|
||||
}
|
||||
|
||||
this.tableFields.push(
|
||||
{
|
||||
name: field.name,
|
||||
field: field.description,
|
||||
slug: field.slug,
|
||||
field_type: field.field_type,
|
||||
field_type_object: field.field_type_object,
|
||||
id: field.id,
|
||||
display: display
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.tableFields.push({
|
||||
name: this.$i18n.get('label_creation'),
|
||||
field: 'row_creation',
|
||||
field_type: undefined,
|
||||
slug: 'creation',
|
||||
id: 'date',
|
||||
display: true
|
||||
});
|
||||
|
||||
this.tableFields.push({
|
||||
name: this.$i18n.get('label_actions'),
|
||||
field: 'row_actions',
|
||||
field_type: undefined,
|
||||
slug: 'actions',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
|
||||
// this.prefTableFields = this.tableFields;
|
||||
// this.$userPrefs.get('table_columns_' + this.collectionId)
|
||||
// .then((value) => {
|
||||
// this.prefTableFields = value;
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, null);
|
||||
// });
|
||||
|
||||
this.isLoadingFields = false;
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingFields = false;
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
this.$eventBusSearch.setCollectionId(this.collectionId);
|
||||
this.$eventBusSearch.updateStoreFromURL();
|
||||
this.$eventBusSearch.loadItems();
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
this.isLoadingFields = false;
|
||||
});
|
||||
},
|
||||
mounted(){
|
||||
this.$eventBusSearch.setCollectionId(this.collectionId);
|
||||
this.$eventBusSearch.updateStoreFromURL();
|
||||
this.$eventBusSearch.loadItems();
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@import '../../scss/_variables.scss';
|
||||
|
||||
.page-container-small>.columns {
|
||||
.page-container-small > .columns {
|
||||
margin-top: 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.sub-header {
|
||||
|
@ -219,7 +290,7 @@ export default {
|
|||
padding-right: $page-small-side-padding;
|
||||
border-bottom: 0.5px solid #ddd;
|
||||
position: relative;
|
||||
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
height: 60px;
|
||||
margin-top: -0.5em;
|
||||
|
@ -235,7 +306,7 @@ export default {
|
|||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.filters-menu {
|
||||
|
@ -245,12 +316,12 @@ export default {
|
|||
background-color: $tainacan-input-color;
|
||||
margin-left: -$page-small-side-padding;
|
||||
padding: $page-small-side-padding;
|
||||
|
||||
|
||||
.label {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.table-container {
|
||||
|
@ -260,7 +331,7 @@ export default {
|
|||
}
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
.filters-menu {
|
||||
.filters-menu {
|
||||
display: none;
|
||||
}
|
||||
.table-container {
|
||||
|
@ -269,7 +340,9 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.tainacan-dropdown-item:hover {
|
||||
background-color: rgba(192, 218, 223, 1) !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ return [
|
|||
'title_item_page' => __( 'Item Page', 'tainacan' ),
|
||||
'title_field_page' => __( 'Field Page', 'tainacan' ),
|
||||
|
||||
/* translators: alkdjklasdj laksjd klsadj */
|
||||
'title_collection_page' => __( 'Collection Page', 'tainacan' ),
|
||||
/* translators: alkdjklasdj laksjd klsadj */
|
||||
'title_collection_page' => __( 'Collection Page', 'tainacan' ),
|
||||
'title_filter_page' => __( 'Filter Page', 'tainacan' ),
|
||||
'title_category_page' => __( 'Category Page', 'tainacan' ),
|
||||
'title_term_page' => __( 'Term Page', 'tainacan' ),
|
||||
|
@ -73,10 +73,10 @@ return [
|
|||
'title_collection_fields_edition' => __( 'Collection Fields Edition Page', 'tainacan' ),
|
||||
|
||||
// Labels (used mainly on Aria Labels and Inputs)
|
||||
'label_clean' => __( 'Clear', 'tainacan' ),
|
||||
'label_selected' => __( 'Selected', 'tainacan' ),
|
||||
'label_relationship_new_search' => __( 'New Search', 'tainacan' ),
|
||||
'label_relationship_items_found' => __( 'Items found', 'tainacan' ),
|
||||
'label_clean' => __( 'Clear', 'tainacan' ),
|
||||
'label_selected' => __( 'Selected', 'tainacan' ),
|
||||
'label_relationship_new_search' => __( 'New Search', 'tainacan' ),
|
||||
'label_relationship_items_found' => __( 'Items found', 'tainacan' ),
|
||||
'label_menu' => __( 'Menu', 'tainacan' ),
|
||||
'label_main_menu' => __( 'Main Menu', 'tainacan' ),
|
||||
'label_collection_menu' => __( 'Collection Menu', 'tainacan' ),
|
||||
|
@ -94,7 +94,7 @@ return [
|
|||
'label_button_delete' => __( 'Button Delete', 'tainacan' ),
|
||||
'label_button_edit_thumb' => __( 'Button Edit Thumbnail', 'tainacan' ),
|
||||
'label_button_edit_header_image' => __( 'Button Edit Header Image', 'tainacan' ),
|
||||
'label_choose_thumb' => __( 'Choose Thumbnail', 'tainacan' ),
|
||||
'label_choose_thumb' => __( 'Choose Thumbnail', 'tainacan' ),
|
||||
'label_button_delete_thumb' => __( 'Button Delete Thumbnail', 'tainacan' ),
|
||||
'label_collections_per_page' => __( 'Collections per Page:', 'tainacan' ),
|
||||
'label_categories_per_page' => __( 'Categories per Page:', 'tainacan' ),
|
||||
|
@ -131,23 +131,24 @@ return [
|
|||
'label_collection_fields' => __( 'Collection Fields', 'tainacan' ),
|
||||
'label_collection_filters' => __( 'Collection Filters', 'tainacan' ),
|
||||
'label_parent_term' => __( 'Parent Term', 'tainacan' ),
|
||||
'label_new_term' => __( 'New Term', 'tainacan' ),
|
||||
'label_new_term' => __( 'New Term', 'tainacan' ),
|
||||
'label_new_child' => __( 'New Child', 'tainacan' ),
|
||||
'label_category_terms' => __( 'Category Terms', 'tainacan' ),
|
||||
'label_no_parent_term' => __( 'No parent term', 'tainacan' ),
|
||||
'label_term_without_name' => __( 'Term without name', 'tainacan' ),
|
||||
'label_inherited' => __( 'Inherited', 'tainacan' ),
|
||||
'label_sorting' => __( 'Sorting', 'tainacan' ),
|
||||
'label_inherited' => __( 'Inherited', 'tainacan' ),
|
||||
'label_sorting' => __( 'Sorting', 'tainacan' ),
|
||||
'label_who_when' => __( 'Who and when', 'tainacan' ),
|
||||
'label_event_title' => __( 'Event', 'tainacan' ),
|
||||
'label_header_image' => __( 'Header Image', 'tainacan' ),
|
||||
'label_empty_header_image' => __( 'Empty Header Image', 'tainacan' ),
|
||||
'label_enable_cover_page' => __( 'Enable Cover Page', 'tainacan' ),
|
||||
'label_cover_page' => __( 'Cover Page', 'tainacan' ),
|
||||
'label_default_displayed_fields' => __( 'Default Displayed Fields', 'tainacan' ),
|
||||
'label_display' => __( 'Display on Listing', 'tainacan' ),
|
||||
'label_display_default' => __( 'Display by default', 'tainacan' ),
|
||||
'label_display_never' => __( 'Never displayed', 'tainacan' ),
|
||||
'label_cover_page' => __( 'Cover Page', 'tainacan' ),
|
||||
'label_default_displayed_fields' => __( 'Default Displayed Fields', 'tainacan' ),
|
||||
'label_display' => __( 'Display on Listing', 'tainacan' ),
|
||||
'label_display_default' => __( 'Display by default', 'tainacan' ),
|
||||
'label_display_never' => __( 'Never displayed', 'tainacan' ),
|
||||
'label_not_display' => __( 'Not display by default', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_dragndrop_fields_collection' => __( 'Drag and drop Fields here to Collection.', 'tainacan' ),
|
||||
|
@ -190,18 +191,18 @@ return [
|
|||
'info_by' => __( 'By: ', 'tainacan' ),
|
||||
'info_date' => __( 'Date: ', 'tainacan' ),
|
||||
'info_not_saved' => __( 'Not saved ', 'tainacan' ),
|
||||
'info_warning_fields_not_saved' => __('Are you sure? There are fields not saved, changes will be lost.', 'tainacan'),
|
||||
'info_warning_filters_not_saved' => __('Are you sure? There are filters not saved, changes will be lost.', 'tainacan'),
|
||||
'info_no_description_provided' => __('No description provided.', 'tainacan'),
|
||||
'info_warning_category_not_saved' => __('Are you sure? The category is not saved, changes will be lost.', 'tainacan'),
|
||||
'info_warning_terms_not_saved' => __('Are you sure? There are terms not saved, changes will be lost.', 'tainacan'),
|
||||
'info_warning_orphan_terms' => __('Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan'),
|
||||
'info_there_is_no_field' => __('There is no field here.', 'tainacan' ),
|
||||
'info_warning_fields_not_saved' => __( 'Are you sure? There are fields not saved, changes will be lost.', 'tainacan' ),
|
||||
'info_warning_filters_not_saved' => __( 'Are you sure? There are filters not saved, changes will be lost.', 'tainacan' ),
|
||||
'info_no_description_provided' => __( 'No description provided.', 'tainacan' ),
|
||||
'info_warning_category_not_saved' => __( 'Are you sure? The category is not saved, changes will be lost.', 'tainacan' ),
|
||||
'info_warning_terms_not_saved' => __( 'Are you sure? There are terms not saved, changes will be lost.', 'tainacan' ),
|
||||
'info_warning_orphan_terms' => __( 'Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan' ),
|
||||
'info_there_is_no_field' => __( 'There is no field here.', 'tainacan' ),
|
||||
'info_no_events' => __( 'No events', 'tainacan' ),
|
||||
'info_logs_before' => __( 'Before updating', 'tainacan' ),
|
||||
'info_logs_after' => __( 'What was updated', 'tainacan' ),
|
||||
'info_there_is_no_field' => __('There is no field here yet.', 'tainacan' ),
|
||||
'info_there_is_no_filter' => __('There is no filter here yet.', 'tainacan' ),
|
||||
'info_there_is_no_field' => __( 'There is no field here yet.', 'tainacan' ),
|
||||
'info_there_is_no_filter' => __( 'There is no filter here yet.', 'tainacan' ),
|
||||
'info_changes' => __( 'Changes', 'tainacan' ),
|
||||
|
||||
// Tainacan Field Types
|
||||
|
|
|
@ -16,6 +16,7 @@ class Field extends Entity {
|
|||
$description,
|
||||
$required,
|
||||
$multiple,
|
||||
$display,
|
||||
$cardinality,
|
||||
$collection_key,
|
||||
$mask,
|
||||
|
@ -40,6 +41,21 @@ class Field extends Entity {
|
|||
return 'Hello, my name is '. $this->get_name();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $display
|
||||
*/
|
||||
function set_display( $display ){
|
||||
$this->set_mapped_property('display', $display);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
function get_display(){
|
||||
return $this->get_mapped_property('display');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the field name
|
||||
*
|
||||
|
@ -315,7 +331,7 @@ class Field extends Entity {
|
|||
* @param bool $value
|
||||
*/
|
||||
function set_accept_suggestion( $value ) {
|
||||
return $this->set_mapped_property('accept_suggestion', $value);
|
||||
$this->set_mapped_property('accept_suggestion', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,138 +41,148 @@ class Fields extends Repository {
|
|||
|
||||
public function get_map() {
|
||||
return apply_filters('tainacan-get-map-'.$this->get_name(), [
|
||||
'name' => [
|
||||
'map' => 'post_title',
|
||||
'title' => __('Name', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Name of the field', 'tainacan'),
|
||||
'on_error' => __('The name should be a text value and not empty', 'tainacan'),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'slug' => [
|
||||
'map' => 'post_name',
|
||||
'title' => __('Slug', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('A unique and santized string representation of the field', 'tainacan'),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
'order' => [
|
||||
'map' => 'menu_order',
|
||||
'title' => __('Order', 'tainacan'),
|
||||
'type' => 'string/integer',
|
||||
'description'=> __('Field order. Field used if collections are manually ordered', 'tainacan'),
|
||||
'on_error' => __('The menu order should be a numeric value', 'tainacan'),
|
||||
//'validation' => v::numeric(),
|
||||
],
|
||||
'parent' => [
|
||||
'map' => 'post_parent',
|
||||
'title' => __('Parent', 'tainacan'),
|
||||
'type' => 'integer',
|
||||
'description'=> __('Parent field', 'tainacan'),
|
||||
'default' => 0
|
||||
//'on_error' => __('The Parent should be numeric value', 'tainacan'),
|
||||
//'validation' => v::numeric(),
|
||||
],
|
||||
'description' => [
|
||||
'map' => 'post_content',
|
||||
'title' => __('Description', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The field description', 'tainacan'),
|
||||
'default' => '',
|
||||
//'on_error' => __('The description should be a text value', 'tainacan'),
|
||||
//'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'field_type' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Type', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The field type', 'tainacan'),
|
||||
'on_error' => __('Field type is empty', 'tainacan'),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'required' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Required', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The field is required', 'tainacan'),
|
||||
'on_error' => __('Field required field is invalid', 'tainacan'),
|
||||
'validation' => v::stringType()->in(['yes', 'no']), // yes or no
|
||||
'default' => 'no'
|
||||
],
|
||||
'collection_key' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Collection key', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Field value should not be repeated', 'tainacan'),
|
||||
'on_error' => __('Collection key is invalid', 'tainacan'),
|
||||
'validation' => v::stringType()->in(['yes', 'no']), // yes or no
|
||||
'default' => 'no'
|
||||
],
|
||||
'multiple' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Multiple', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Allow multiple fields for the field', 'tainacan'),
|
||||
'on_error' => __('Multiple fields is invalid', 'tainacan'),
|
||||
'validation' => v::stringType()->in(['yes', 'no']), // yes or no. It cant be multiple if its collection_key
|
||||
'default' => 'no'
|
||||
],
|
||||
'cardinality' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Cardinality', 'tainacan'),
|
||||
'type' => 'string/number',
|
||||
'description'=> __('Number of multiples possible fields', 'tainacan'),
|
||||
'on_error' => __('The number of fields not allowed', 'tainacan'),
|
||||
'validation' => v::numeric()->positive(),
|
||||
'default' => 1
|
||||
],
|
||||
'mask' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Mask', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The mask to be used in the field', 'tainacan'),
|
||||
//'on_error' => __('Mask is invalid', 'tainacan'),
|
||||
//'validation' => ''
|
||||
],
|
||||
'default_value' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Default value', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The value default fot the field', 'tainacan'),
|
||||
],
|
||||
'field_type_options' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __('Field Type options', 'tainacan'),
|
||||
'type' => 'array/object/string',
|
||||
'items' => ['type' => 'array/string/integer/object'],
|
||||
'description'=> __('Options specific for field type', 'tainacan'),
|
||||
// 'validation' => ''
|
||||
],
|
||||
'collection_id' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __('Collection', 'tainacan'),
|
||||
'type' => 'integer/string',
|
||||
'description'=> __('The collection ID', 'tainacan'),
|
||||
//'validation' => ''
|
||||
],
|
||||
'accept_suggestion' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Field Value Accepts Suggestions', 'tainacan'),
|
||||
'type' => 'bool',
|
||||
'description'=> __('Allow the community suggest a different values for that field', 'tainacan'),
|
||||
'default' => false,
|
||||
'validation' => v::boolType()
|
||||
],
|
||||
'exposer_mapping' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('exposer_mapping', 'tainacan'),
|
||||
'type' => 'array',
|
||||
'description'=> __('The field mapping options', 'tainacan'),
|
||||
'on_error' => __('Invalid Field Mapping', 'tainacan'),
|
||||
//'validation' => v::arrayType(),
|
||||
'default' => []
|
||||
],
|
||||
]);
|
||||
'name' => [
|
||||
'map' => 'post_title',
|
||||
'title' => __( 'Name', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name of the field', 'tainacan' ),
|
||||
'on_error' => __( 'The name should be a text value and not empty', 'tainacan' ),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'slug' => [
|
||||
'map' => 'post_name',
|
||||
'title' => __( 'Slug', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'A unique and santized string representation of the field', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
'order' => [
|
||||
'map' => 'menu_order',
|
||||
'title' => __( 'Order', 'tainacan' ),
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'Field order. Field used if collections are manually ordered', 'tainacan' ),
|
||||
'on_error' => __( 'The menu order should be a numeric value', 'tainacan' ),
|
||||
//'validation' => v::numeric(),
|
||||
],
|
||||
'parent' => [
|
||||
'map' => 'post_parent',
|
||||
'title' => __( 'Parent', 'tainacan' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Parent field', 'tainacan' ),
|
||||
'default' => 0
|
||||
//'on_error' => __('The Parent should be numeric value', 'tainacan'),
|
||||
//'validation' => v::numeric(),
|
||||
],
|
||||
'description' => [
|
||||
'map' => 'post_content',
|
||||
'title' => __( 'Description', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The field description', 'tainacan' ),
|
||||
'default' => '',
|
||||
//'on_error' => __('The description should be a text value', 'tainacan'),
|
||||
//'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'field_type' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Type', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The field type', 'tainacan' ),
|
||||
'on_error' => __( 'Field type is empty', 'tainacan' ),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'required' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Required', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The field is required', 'tainacan' ),
|
||||
'on_error' => __( 'Field required field is invalid', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
'default' => 'no'
|
||||
],
|
||||
'collection_key' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Collection key', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Field value should not be repeated', 'tainacan' ),
|
||||
'on_error' => __( 'Collection key is invalid', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
'default' => 'no'
|
||||
],
|
||||
'multiple' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Multiple', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Allow multiple fields for the field', 'tainacan' ),
|
||||
'on_error' => __( 'Multiple fields is invalid', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ),
|
||||
// yes or no. It cant be multiple if its collection_key
|
||||
'default' => 'no'
|
||||
],
|
||||
'cardinality' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Cardinality', 'tainacan' ),
|
||||
'type' => 'string/number',
|
||||
'description' => __( 'Number of multiples possible fields', 'tainacan' ),
|
||||
'on_error' => __( 'The number of fields not allowed', 'tainacan' ),
|
||||
'validation' => v::numeric()->positive(),
|
||||
'default' => 1
|
||||
],
|
||||
'mask' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Mask', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The mask to be used in the field', 'tainacan' ),
|
||||
//'on_error' => __('Mask is invalid', 'tainacan'),
|
||||
//'validation' => ''
|
||||
],
|
||||
'default_value' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Default value', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The value default fot the field', 'tainacan' ),
|
||||
],
|
||||
'field_type_options' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Field Type options', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'description' => __( 'Options specific for field type', 'tainacan' ),
|
||||
// 'validation' => ''
|
||||
],
|
||||
'collection_id' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Collection', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'description' => __( 'The collection ID', 'tainacan' ),
|
||||
//'validation' => ''
|
||||
],
|
||||
'accept_suggestion' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Field Value Accepts Suggestions', 'tainacan' ),
|
||||
'type' => 'bool',
|
||||
'description' => __( 'Allow the community suggest a different values for that field', 'tainacan' ),
|
||||
'default' => false,
|
||||
'validation' => v::boolType()
|
||||
],
|
||||
'exposer_mapping' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'exposer_mapping', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'description' => __( 'The field mapping options', 'tainacan' ),
|
||||
'on_error' => __( 'Invalid Field Mapping', 'tainacan' ),
|
||||
//'validation' => v::arrayType(),
|
||||
'default' => []
|
||||
],
|
||||
'display' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Display', 'tainacan' ),
|
||||
'type' => __( 'string' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no', 'never' ] ),
|
||||
'description' => __( 'Display by default on listing or not display or never display. yes = display, no = not diplay, never = never display', 'tainacan' ),
|
||||
'default' => 'yes'
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import axios from '../../../axios/axios';
|
||||
import qs from 'qs';
|
||||
|
||||
export const fetchFields = ({ commit }, {collectionId, isRepositoryLevel, isContextEdit }) => {
|
||||
export const fetchFields = ({commit}, {collectionId, isRepositoryLevel, isContextEdit}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
else
|
||||
endpoint = '/fields/';
|
||||
|
||||
|
@ -14,116 +14,119 @@ export const fetchFields = ({ commit }, {collectionId, isRepositoryLevel, isCont
|
|||
endpoint += '&context=edit';
|
||||
|
||||
axios.tainacan.get(endpoint)
|
||||
.then((res) => {
|
||||
let fields= res.data;
|
||||
commit('setFields', fields);
|
||||
resolve (fields);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
.then((res) => {
|
||||
let fields = res.data;
|
||||
commit('setFields', fields);
|
||||
resolve(fields);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sendField = ( { commit }, { collectionId, name, fieldType, status, isRepositoryLevel, newIndex }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
export const sendField = ({commit}, {collectionId, name, fieldType, status, isRepositoryLevel, newIndex}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
else
|
||||
endpoint = '/fields/';
|
||||
axios.tainacan.post(endpoint + '?context=edit', {
|
||||
name: name,
|
||||
field_type: fieldType,
|
||||
field_type: fieldType,
|
||||
status: status
|
||||
})
|
||||
.then( res => {
|
||||
.then(res => {
|
||||
let field = res.data;
|
||||
commit('setSingleField', { field: field, index: newIndex});
|
||||
resolve( res.data );
|
||||
commit('setSingleField', {field: field, index: newIndex});
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error.response );
|
||||
reject(error.response);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const updateField = ( { commit }, { collectionId, fieldId, isRepositoryLevel, index, options }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
export const updateField = ({commit}, {collectionId, fieldId, isRepositoryLevel, index, options}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
else
|
||||
endpoint = '/fields/' + fieldId;
|
||||
|
||||
axios.tainacan.put(endpoint + '?context=edit', options)
|
||||
.then( res => {
|
||||
let field = res.data
|
||||
commit('setSingleField', { field: field, index: index });
|
||||
resolve( field );
|
||||
.then(res => {
|
||||
let field = res.data;
|
||||
commit('setSingleField', {field: field, index: index});
|
||||
resolve(field);
|
||||
})
|
||||
.catch(error => {
|
||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||
reject({
|
||||
error_message: error['response']['data'].error_message,
|
||||
errors: error['response']['data'].errors
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const updateFields = ( { commit }, fields) => {
|
||||
export const updateFields = ({commit}, fields) => {
|
||||
commit('setFields', fields);
|
||||
};
|
||||
|
||||
export const deleteField = ({ commit }, { collectionId, fieldId, isRepositoryLevel }) => {
|
||||
export const deleteField = ({commit}, {collectionId, fieldId, isRepositoryLevel}) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
else
|
||||
endpoint = '/fields/' + fieldId;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.delete(endpoint)
|
||||
.then( res => {
|
||||
commit('deleteField', res.data );
|
||||
resolve( res.data );
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
reject( error );
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCollectionFieldsOrder = ({ commit, dispatch }, { collectionId, fieldsOrder }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.patch('/collections/' + collectionId, {
|
||||
fields_order: fieldsOrder
|
||||
}).then( res => {
|
||||
// dispatch('collection/setCollection', res.data, {root: true});
|
||||
resolve( res.data );
|
||||
}).catch( error => {
|
||||
reject( error.response );
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
export const fetchFieldTypes = ({ commit} ) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get('/field-types')
|
||||
.then((res) => {
|
||||
let fieldTypes = res.data;
|
||||
commit('setFieldTypes', fieldTypes);
|
||||
resolve (fieldTypes);
|
||||
})
|
||||
.catch((error) => {
|
||||
.then(res => {
|
||||
commit('deleteField', res.data);
|
||||
resolve(res.data);
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCollectionFieldsOrder = ({commit, dispatch}, {collectionId, fieldsOrder}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.patch('/collections/' + collectionId, {
|
||||
fields_order: fieldsOrder
|
||||
}).then(res => {
|
||||
// dispatch('collection/setCollection', res.data, {root: true});
|
||||
resolve(res.data);
|
||||
}).catch(error => {
|
||||
reject(error.response);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
export const fetchFieldTypes = ({commit}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get('/field-types')
|
||||
.then((res) => {
|
||||
let fieldTypes = res.data;
|
||||
commit('setFieldTypes', fieldTypes);
|
||||
resolve(fieldTypes);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export const updateFieldTypes = ( { commit }, fieldTypes) => {
|
||||
export const updateFieldTypes = ({commit}, fieldTypes) => {
|
||||
commit('setFieldTypes', fieldTypes);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue