Removes remaining Core Author stuff and creates FormUser.
This commit is contained in:
parent
53322b6a86
commit
01d448251a
|
@ -68,7 +68,7 @@
|
|||
getInputPlaceholder() {
|
||||
if (this.metadatumType == 'Tainacan\\Metadata_Types\\Relationship')
|
||||
return this.$i18n.get('info_type_to_add_items');
|
||||
else if (this.metadatumType == 'Tainacan\\Metadata_Types\\Core_Author')
|
||||
else if (this.metadatumType == 'Tainacan\\Metadata_Types\\User')
|
||||
return this.$i18n.get('info_type_to_add_users');
|
||||
else
|
||||
return this.$i18n.get('info_type_to_add_metadata');
|
||||
|
@ -125,7 +125,7 @@
|
|||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' || this.metadatumType === 'Tainacan\\Metadata_Types\\Core_Author' )
|
||||
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' || this.metadatumType === 'Tainacan\\Metadata_Types\\User' )
|
||||
promise = this.getValuesRelationship( this.searchQuery, this.isRepositoryLevel, valuesToIgnore, this.searchOffset, this.searchNumber );
|
||||
else
|
||||
promise = this.getValuesPlainText( this.metadatumId, this.searchQuery, this.isRepositoryLevel, valuesToIgnore, this.searchOffset, this.searchNumber );
|
||||
|
@ -189,7 +189,7 @@
|
|||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
} else if (this.metadatumType === 'Tainacan\\Metadata_Types\\Core_Author') {
|
||||
} else if (this.metadatumType === 'Tainacan\\Metadata_Types\\User') {
|
||||
let query = qs.stringify({ include: metadata.value });
|
||||
let endpoint = '/users/';
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
lang="en"
|
||||
:step="getStep"/>
|
||||
</template>
|
||||
itemMetadatum
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<template>
|
||||
<section>
|
||||
<b-field :addons="false">
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-user', 'default_author') }}<span> * </span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('tainacan-user', 'default_author')"
|
||||
:message="$i18n.getHelperMessage('tainacan-user', 'default_author')"/>
|
||||
</label>
|
||||
<b-checkbox
|
||||
v-model="defaultAuthor"
|
||||
@input="onUpdateDefaultAuthor"
|
||||
true-value="yes"
|
||||
false-value="no">
|
||||
{{ $i18n.get('label_default_author_user') }}
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: [ String, Object, Array ]
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
defaultAuthor: String
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.defaultAuthor = this.value && this.value.default_author ? this.value.default_author : 'no';
|
||||
},
|
||||
methods: {
|
||||
onUpdateDefaultAuthor(value) {
|
||||
this.$emit('input', { default_author: value });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -17,8 +17,9 @@ class User extends Metadata_Type {
|
|||
parent::__construct();
|
||||
$this->set_primitive_type('user');
|
||||
$this->set_component('tainacan-user');
|
||||
$this->set_form_component('tainacan-form-user');
|
||||
$this->set_name( __('User', 'tainacan') );
|
||||
$this->set_description( __('A registered user on wordpress', 'tainacan') );
|
||||
$this->set_description( __('A registered user on WordPress', 'tainacan') );
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div class="control is-clearfix">
|
||||
|
@ -28,13 +29,6 @@ class User extends Metadata_Type {
|
|||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the metadata for this metadatum type
|
||||
*/
|
||||
public function form() {
|
||||
|
||||
}
|
||||
|
||||
function user_exists($user) {
|
||||
// if( !is_int($user) )
|
||||
// return username_exists($user) !== false;
|
||||
|
@ -73,6 +67,18 @@ class User extends Metadata_Type {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_form_labels(){
|
||||
return [
|
||||
'default_author' => [
|
||||
'title' => __( 'Defaults to author user', 'tainacan' ),
|
||||
'description' => __( 'This sets the default value of this metadata as the current item author.', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function validate_options( Metadatum $metadatum ) {
|
||||
if ( !in_array($metadatum->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) ) {
|
||||
return true;
|
||||
|
|
|
@ -537,12 +537,7 @@
|
|||
let validEditionActions = {};
|
||||
|
||||
for (let [actionKey, action] of Object.entries(isMultiple ? this.editionActionsForMultiple : this.editionActionsForNotMultiple)) {
|
||||
if ( (metadatumID != 'status' &&
|
||||
metadatumID != 'comments' &&
|
||||
(this.getMetadataByID(metadatumID) && this.getMetadataByID(metadatumID).metadata_type_object && this.getMetadataByID(metadatumID).metadata_type_object.component !== 'tainacan-author')
|
||||
) ||
|
||||
actionKey != 'clear'
|
||||
)
|
||||
if ((metadatumID != 'status' && metadatumID != 'comments') || actionKey != 'clear')
|
||||
validEditionActions[actionKey] = action;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import FormRelationship from '../components/metadata-types/relationship/FormRela
|
|||
import FormTaxonomy from '../components/metadata-types/taxonomy/FormTaxonomy.vue';
|
||||
import FormSelectbox from '../components/metadata-types/selectbox/FormSelectbox.vue';
|
||||
import FormNumeric from '../components/metadata-types/numeric/FormNumeric.vue';
|
||||
import FormUser from '../components/metadata-types/user/FormUser.vue';
|
||||
|
||||
import FilterNumeric from '../components/filter-types/numeric/Numeric.vue';
|
||||
import FilterDate from '../components/filter-types/date/Date.vue';
|
||||
|
@ -102,6 +103,7 @@ Vue.component('tainacan-form-relationship', FormRelationship);
|
|||
Vue.component('tainacan-form-taxonomy', FormTaxonomy);
|
||||
Vue.component('tainacan-form-selectbox', FormSelectbox);
|
||||
Vue.component('tainacan-form-numeric', FormNumeric);
|
||||
Vue.component('tainacan-form-user', FormUser);
|
||||
|
||||
/* Filters */
|
||||
Vue.component('tainacan-filter-numeric', FilterNumeric);
|
||||
|
|
|
@ -107,7 +107,7 @@ export const setOrderBy = ({ state, commit }, orderBy ) => {
|
|||
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
|
||||
commit('setPostQueryAttribute', { attr: 'metatype', value: 'DATETIME' } );
|
||||
} else if (orderBy.metadata_type_object.core) {
|
||||
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : orderBy.metadata_type_object.related_mapped_prop } );
|
||||
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop } );
|
||||
commit('removePostQueryAttribute', 'metakey');
|
||||
commit('removePostQueryAttribute', 'metatype');
|
||||
} else {
|
||||
|
|
|
@ -704,7 +704,7 @@
|
|||
|
||||
if (
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug == 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == 'date') ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == (metadatum.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : metadatum.metadata_type_object.related_mapped_prop)) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == metadatum.metadata_type_object.related_mapped_prop) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
|
||||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
|
||||
)
|
||||
|
@ -1002,15 +1002,6 @@
|
|||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_author'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'author_id'},
|
||||
metadata_type: undefined,
|
||||
slug: 'author',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
|
|
@ -96,24 +96,10 @@
|
|||
</span>
|
||||
<span
|
||||
v-if="metadatum.id != undefined && metadatum.metadata_type_object"
|
||||
class="label-details">
|
||||
class="label-details"
|
||||
:class="{ 'has-text-weight-bold': metadatum.metadata_type_object.core }">
|
||||
({{ metadatum.metadata_type_object.name }})
|
||||
<em v-if="metadatum.collection_id != collectionId">{{ $i18n.get('label_inherited') }}</em>
|
||||
<em
|
||||
v-if="metadatum.metadata_type_object.core &&
|
||||
metadatum.metadata_type_object.related_mapped_prop == 'title'">
|
||||
{{ $i18n.get('label_core_title') }}
|
||||
</em>
|
||||
<em
|
||||
v-if="metadatum.metadata_type_object.core &&
|
||||
metadatum.metadata_type_object.related_mapped_prop == 'description'">
|
||||
{{ $i18n.get('label_core_description') }}
|
||||
</em>
|
||||
<em
|
||||
v-if="metadatum.metadata_type_object.core &&
|
||||
metadatum.metadata_type_object.related_mapped_prop == 'author_id'">
|
||||
{{ $i18n.get('label_core_author') }}
|
||||
</em>
|
||||
<span
|
||||
class="not-saved"
|
||||
v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'">
|
||||
|
|
|
@ -231,7 +231,6 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_inherited' => __( 'Inherited', 'tainacan' ),
|
||||
'label_core_title' => __( 'Core Title', 'tainacan' ),
|
||||
'label_core_description' => __( 'Core Description', 'tainacan' ),
|
||||
'label_core_author' => __( 'Core Author', 'tainacan' ),
|
||||
'label_sorting' => __( 'Sorting', 'tainacan' ),
|
||||
'label_sorting_direction' => __( 'Sorting direction', 'tainacan' ),
|
||||
'label_sort' => __( 'Sort', 'tainacan' ),
|
||||
|
@ -460,6 +459,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_associated_roles' => __( 'Associated roles', 'tainacan' ),
|
||||
'label_inherited_roles' => __( 'Inherited roles', 'tainacan' ),
|
||||
'label_editing_capabilitiy' => __( 'Editing capabilitiy', 'tainacan' ),
|
||||
'label_default_author_user' => __( 'Set the item author as default value', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
|
|
@ -629,7 +629,7 @@
|
|||
for (let metadatum of this.sortingMetadata) {
|
||||
if (
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug == 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == 'date') ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == (metadatum.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : metadatum.metadata_type_object.related_mapped_prop)) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == metadatum.metadata_type_object.related_mapped_prop) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
|
||||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
|
||||
)
|
||||
|
@ -903,15 +903,6 @@
|
|||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_author'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'author_id'},
|
||||
metadata_type: undefined,
|
||||
slug: 'author',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
|
Loading…
Reference in New Issue