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 );
|
||||
|
||||
}
|
||||
|
|
|
@ -71,41 +71,54 @@
|
|||
</div>
|
||||
</b-field>
|
||||
|
||||
<!-- 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>
|
||||
</b-radio>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'required')"
|
||||
:message="$i18n.getHelperMessage('fields', 'required')"/>
|
||||
: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
|
||||
:type="formErrors['display'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['display'] != undefined ? formErrors['display'] : ''">
|
||||
<b-radio
|
||||
size="is-small"
|
||||
@input="clearErrors('multiple')"
|
||||
v-model="editForm.multiple"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
name="multiple">
|
||||
v-model="editForm.display"
|
||||
@input="clearErrors('display')"
|
||||
native-value="never"
|
||||
name="display">
|
||||
{{ $i18n.get('label_display_never') }}
|
||||
</b-checkbox>
|
||||
</b-radio>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('fields', 'multiple')"
|
||||
:message="$i18n.getHelperMessage('fields', 'multiple')"/>
|
||||
:title="$i18n.getHelperTitle('fields', 'display')"
|
||||
:message="$i18n.getHelperMessage('fields', 'display')"/>
|
||||
</b-field>
|
||||
|
||||
</b-field>
|
||||
|
@ -180,12 +193,14 @@
|
|||
<button
|
||||
class="button is-outlined"
|
||||
@click.prevent="cancelEdition()"
|
||||
slot="trigger">{{ $i18n.get('cancel') }}</button>
|
||||
slot="trigger">{{ $i18n.get('cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button
|
||||
class="button is-success"
|
||||
type="submit">{{ $i18n.get('save') }}</button>
|
||||
type="submit">{{ $i18n.get('save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
|
@ -241,7 +256,13 @@ 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})
|
||||
this.updateField({
|
||||
collectionId: this.collectionId,
|
||||
fieldId: field.id,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
index: this.index,
|
||||
options: this.editForm
|
||||
})
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
|
@ -263,12 +284,18 @@ export default {
|
|||
} else {
|
||||
let formElement = document.getElementById('fieldEditForm');
|
||||
let formData = new FormData(formElement);
|
||||
let formObj = {}
|
||||
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})
|
||||
this.updateField({
|
||||
collectionId: this.collectionId,
|
||||
fieldId: field.id,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
index: this.index,
|
||||
options: formObj
|
||||
})
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
this.formErrors = {};
|
||||
|
|
|
@ -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 ">
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
class="control"
|
||||
custom>
|
||||
<b-checkbox
|
||||
v-model="column.visible"
|
||||
v-model="column.display"
|
||||
:native-value="column.field">
|
||||
{{ column.name }}
|
||||
</b-checkbox>
|
||||
|
@ -34,7 +34,8 @@
|
|||
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')"
|
||||
field.field_type_object.primitive_type != 'compound'
|
||||
)"
|
||||
:value="field"
|
||||
:key="field.id">
|
||||
{{ field.name }}
|
||||
|
|
|
@ -7,16 +7,32 @@
|
|||
:is-full-page="false"
|
||||
:active.sync="isLoadingFields"/>
|
||||
<div class="header-item">
|
||||
<router-link
|
||||
id="button-create-item"
|
||||
tag="button"
|
||||
|
||||
<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.getFrom('items', 'new_item') }}
|
||||
{{ `${$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)"
|
||||
v-if="fields.length > 0 && (items.length > 0 || isLoadingItems)"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:collection-id="collectionId"
|
||||
:table-fields="tableFields"
|
||||
|
@ -46,7 +62,8 @@
|
|||
:to="isRepositoryLevel ? $routerHelper.getNewFilterPath() : $routerHelper.getNewCollectionFilterPath(collectionId)"
|
||||
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>
|
||||
|
@ -70,7 +87,8 @@
|
|||
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"
|
||||
|
@ -159,22 +177,73 @@ export default {
|
|||
});
|
||||
|
||||
this.isLoadingFilters = true;
|
||||
this.fetchFilters( { collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: 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 });
|
||||
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) {
|
||||
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 }
|
||||
);
|
||||
if (field.display !== 'never') {
|
||||
// Will be pushed on array
|
||||
|
||||
let display = true;
|
||||
|
||||
if (field.display === 'no') {
|
||||
display = 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.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)
|
||||
|
@ -184,9 +253,11 @@ export default {
|
|||
// .catch((error) => {
|
||||
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, null);
|
||||
// });
|
||||
|
||||
this.isLoadingFields = false;
|
||||
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingFields = false;
|
||||
});
|
||||
},
|
||||
|
@ -269,7 +340,9 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.tainacan-dropdown-item:hover {
|
||||
background-color: rgba(192, 218, 223, 1) !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ return [
|
|||
'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' ),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,8 @@ class Fields extends Repository {
|
|||
'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
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ),
|
||||
// yes or no. It cant be multiple if its collection_key
|
||||
'default' => 'no'
|
||||
],
|
||||
'cardinality' => [
|
||||
|
@ -166,12 +167,21 @@ class Fields extends Repository {
|
|||
'exposer_mapping' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'exposer_mapping', 'tainacan' ),
|
||||
'type' => 'array',
|
||||
'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'
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ export const fetchFields = ({ commit }, {collectionId, isRepositoryLevel, isCont
|
|||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sendField = ({commit}, {collectionId, name, fieldType, status, isRepositoryLevel, newIndex}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -60,12 +60,15 @@ export const updateField = ( { commit }, { collectionId, fieldId, isRepositoryLe
|
|||
|
||||
axios.tainacan.put(endpoint + '?context=edit', options)
|
||||
.then(res => {
|
||||
let field = res.data
|
||||
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
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue