Merge conflict.

This commit is contained in:
mateuswetah 2018-09-04 19:37:18 -03:00
commit 56190103a6
57 changed files with 933 additions and 272 deletions

View File

@ -2,15 +2,16 @@
Notes for a future documentation Notes for a future documentation
Tainacan uses the ordinary WordPress template hierarchy for its templates. It adds only 3 additional templates in your hierarchy Tainacan uses the ordinary WordPress template hierarchy for its templates. It adds additional templates in the hierarchy
* `tainacan/single-items.php` - Used in the single template for any item of any collection * `tainacan/single-items.php` - Used in the single template for any item of any collection
* `tainacan/arhive-items.php` - Used in the list of items of any collection * `tainacan/arhive-items.php` - Used in the list of items of any collection (e.g. both archive-tnc_col_4_item.php and archive-tnc_col_5_item.php)
* `tainacan/archive-taxonomy.php` - Used as a template for all Tainacan Taxonomies (list items based on a term) * `tainacan/archive-taxonomy.php` - Used as a template for all Tainacan Taxonomies (list items based on a term)
* `tainacan/archive-repository.php` - Used in the `/items/` URL, which is added by the Tainacan plugin, and lists all items of all collections
Since each collection is a new custom post type, these templates are usefull to create a template that will be used by all collections. Since each collection is a new custom post type, these templates are usefull to create a template that will be used by all collections.
Nevertheless, you are still able to create more specific templates, using the standar WordPress hierarchy. Nevertheless, you are still able to create more specific templates, using the standard WordPress hierarchy.
Examples: Examples:

View File

@ -26,7 +26,7 @@ In WordPress language, each item is a post and its post type represents its coll
Document is the main information of the item. It is the object which all metadata refer to. Tainacan accepts 3 different document types: Document is the main information of the item. It is the object which all metadata refer to. Tainacan accepts 3 different document types:
* Attachment: A file attached to the item. An image, video, pdf, audio or other media file. * Attachment: A file attached to the item. An image, video, pdf, audio or other media file.
* URL: An URL pointing to an external website or file. It can be a general website, a specific file, or media services. In the case of media services, Tainacan recognizes addresses and displays the appropriate player, using [oEmbed](https://oembed.com/) * URL: An URL pointing to an external website or file. It can be a general website, a specific file, or media services. In the case of media services, Tainacan recognizes addresses and displays the appropriate player, using [oEmbed](https://oembed.com/). A list of services automatically conveted to embeds by WordPress can be found [here](https://codex.wordpress.org/Embeds).
* Text: A plain text, stored directly in the database, the user can type upon creating or editing an item * Text: A plain text, stored directly in the database, the user can type upon creating or editing an item
## Metadata ## Metadata

View File

@ -0,0 +1,9 @@
<?php
/**
* @see \Tainacan\Admin_Hooks->register()
*/
function register_admin_hook( $context, $callback, $position = 'end-left' ) {
$admin_hooks = \Tainacan\Admin_Hooks::get_instance();
return $admin_hooks->register( $context, $callback, $position );
}

View File

@ -0,0 +1,66 @@
<?php
namespace Tainacan;
class Admin_Hooks {
private $registered_hooks = [];
private static $instance = null;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action('init', [$this, 'init']);
}
function init() {
do_action('tainacan-register-admin-hooks');
}
public function get_available_positions() {
return apply_filters('tainacan-admin-hooks-positions', ['begin-left', 'begin-right', 'end-left', 'end-right']);
}
public function get_available_contexts() {
return apply_filters('tainacan-admin-hooks-contexts', ['collection', 'metadatum', 'item', 'taxonomy', 'term', 'filter']);
}
public function get_registered_hooks() {
return $this->registered_hooks;
}
/**
*
* @param string $context The context to add the hook to (collection, metadatum, item, taxonomy, term or filter)
* @param string $position The position inside the page to hook. (begin, end, begin-left, begin-right, end-left, end-right)
* @param callable $callback The callback that will output the form HTML
*/
public function register( $context, $callback, $position = 'end-left' ) {
$contexts = $this->get_available_contexts();
$positions = $this->get_available_positions();
if ( !in_array($context, $contexts) || !in_array($position, $positions) ) {
return false;
}
$result = call_user_func($callback);
if (is_string($result)){
$this->registered_hooks[$context][$position][] = $result;
return true;
}
return false;
}
}

View File

@ -203,7 +203,9 @@ class Admin {
foreach ( $metadata_types as $index => $metadata_type){ foreach ( $metadata_types as $index => $metadata_type){
$class = new $metadata_type; $class = new $metadata_type;
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels(); $settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
} }
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
return $settings; return $settings;

View File

@ -9,25 +9,29 @@
<hr> <hr>
</header> </header>
<div class="tainacan-form"> <div class="tainacan-form">
<div class="modal-card-body"> <div class="modal-card-body no-overflow-modal-card-body">
<div <div
v-for="criterion in editionCriteria" v-for="criterion in editionCriteria"
:key="criterion" :key="criterion"
class="tainacan-bulk-edition-inline-fields"> class="tainacan-bulk-edition-inline-fields">
<b-select <b-select
:loading="metadataIsLoading"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="!!bulkEditionProcedures[criterion].metadatumID" :disabled="!!bulkEditionProcedures[criterion].metadatumID"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
:placeholder="$i18n.get('instruction_select_a_metadatum')" :placeholder="$i18n.get('instruction_select_a_metadatum')"
@input="addToBulkEditionProcedures($event, 'metadatumID', criterion)"> @input="addToBulkEditionProcedures($event, 'metadatumID', criterion)">
<template v-for="(metadatum, index) in metadata"> <template
v-for="(metadatum, index) in metadata">
<option <option
:key="index"
v-if="metadatum.id" v-if="metadatum.id"
:value="metadatum.id"> :value="metadatum.id">
{{ metadatum.name }} {{ metadatum.name }}
</option> </option>
<option <option
:key="index"
v-if="index === Object.keys(metadata).length-1" v-if="index === Object.keys(metadata).length-1"
value="status"> value="status">
{{ $i18n.get('label_status') }} {{ $i18n.get('label_status') }}
@ -40,6 +44,7 @@
v-if="bulkEditionProcedures[criterion] && v-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID" bulkEditionProcedures[criterion].metadatumID"
:disabled="!!bulkEditionProcedures[criterion].action" :disabled="!!bulkEditionProcedures[criterion].action"
:value="bulkEditionProcedures[criterion].action ? bulkEditionProcedures[criterion].action : undefined"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
:placeholder="$i18n.get('instruction_select_a_action')" :placeholder="$i18n.get('instruction_select_a_action')"
@input="addToBulkEditionProcedures($event, 'action', criterion)"> @input="addToBulkEditionProcedures($event, 'action', criterion)">
@ -139,7 +144,7 @@
.metadata_type_options.allow_new_terms === 'yes'" .metadata_type_options.allow_new_terms === 'yes'"
:maxtags="1" :maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone" :disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
:id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component + :id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component +
'-' + getMetadataByID(bulkEditionProcedures[criterion].metadatumID).slug" '-' + getMetadataByID(bulkEditionProcedures[criterion].metadatumID).slug"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component" :is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
@ -172,7 +177,11 @@
class="is-pulled-right"> class="is-pulled-right">
<b-tooltip <b-tooltip
class="is-success" class="is-success"
:label="actionResult.constructor.name !== 'Object' && actionResult === 1 ? `${actionResult} ${$i18n.get('info_item_edited')}` : `${actionResult} ${$i18n.get('info_items_edited')}`"> size="is-small"
position="is-left"
animated
multilined
:label="actionResult.constructor.name !== 'Object' && actionResult === 1 ? `${actionResult} ${$i18n.get('info_item_affected')}` : `${actionResult} ${$i18n.get('info_items_affected')}`">
<b-icon <b-icon
type="is-success" type="is-success"
icon="check-circle"/> icon="check-circle"/>
@ -183,6 +192,10 @@
class="is-pulled-right"> class="is-pulled-right">
<b-tooltip <b-tooltip
class="is-danger" class="is-danger"
size="is-small"
position="is-left"
animated
multilined
:label="actionResult.constructor.name === 'Object' ? (actionResult.error_message ? actionResult.error_message : actionResult.message) : ''"> :label="actionResult.constructor.name === 'Object' ? (actionResult.error_message ? actionResult.error_message : actionResult.message) : ''">
<b-icon <b-icon
type="is-danger" type="is-danger"
@ -190,6 +203,7 @@
</b-tooltip> </b-tooltip>
</div> </div>
<button <button
:disabled="!groupID"
v-if="!bulkEditionProcedures[criterion].isDone && v-if="!bulkEditionProcedures[criterion].isDone &&
!bulkEditionProcedures[criterion].isExecuting && !bulkEditionProcedures[criterion].isExecuting &&
bulkEditionProcedures[criterion].metadatumID && bulkEditionProcedures[criterion].metadatumID &&
@ -229,13 +243,24 @@
</div> </div>
<!--<pre>{{ bulkEditionProcedures }}</pre>--> <!--<pre>{{ bulkEditionProcedures }}</pre>-->
<footer class="field form-submit"> <footer class="field is-grouped form-submit">
<div class="control is-pulled-right"> <div class="control">
<button
@click="$eventBusSearch.loadItems(); $parent.close()"
:disabled="(Object.keys(bulkEditionProcedures).length &&
bulkEditionProcedures[editionCriteria[editionCriteria.length-1]].isExecuting) || false"
type="button"
class="button is-outlined">
{{ $i18n.get('close') }}
</button>
</div>
<div class="control">
<button <button
:disabled="dones.every((item) => item === true) === false" :disabled="dones.every((item) => item === true) === false"
class="button is-success" class="button is-success"
type="button" type="button"
@click="$parent.close()">{{ $i18n.get('conclude') }} @click="$eventBusSearch.loadItems(); $parent.close();">
{{ $i18n.get('done') }}
</button> </button>
</div> </div>
</footer> </footer>
@ -252,18 +277,38 @@
modalTitle: String, modalTitle: String,
totalItems: Array, totalItems: Array,
objectType: String, objectType: String,
metadata: Array,
selectedForBulk: Object, selectedForBulk: Object,
collectionID: Number, collectionID: Number,
}, },
created(){ created(){
if(!this.collectionID){
// is repository level
} else {
this.metadataIsLoading = true;
this.fetchMetadata({
collectionId: this.collectionID,
isRepositoryLevel: false,
isContextEdit: true,
includeDisabled: true,
}).then(() => {
this.metadataIsLoading = false;
});
}
this.createEditGroup({ this.createEditGroup({
object: this.selectedForBulk, object: this.selectedForBulk,
collectionID: this.collectionID collectionID: this.collectionID ? this.collectionID : 'default'
}).then(() => { }).then(() => {
this.groupID = this.getGroupID(); this.groupID = this.getGroupID();
}); });
}, },
computed: {
metadata() {
return this.getMetadata();
}
},
data() { data() {
return { return {
statuses: { statuses: {
@ -273,13 +318,13 @@
}, },
editionCriteria: [1], editionCriteria: [1],
editionActionsForMultiple: { editionActionsForMultiple: {
add: this.$i18n.get('add'), add: this.$i18n.get('add_value'),
redefine: this.$i18n.get('redefine'), redefine: this.$i18n.get('set_new_value'),
remove: this.$i18n.get('remove'), remove: this.$i18n.get('remove_value'),
replace: this.$i18n.get('replace'), replace: this.$i18n.get('replace_value'),
}, },
editionActionsForNotMultiple: { editionActionsForNotMultiple: {
redefine: this.$i18n.get('redefine'), redefine: this.$i18n.get('set_new_value'),
}, },
bulkEditionProcedures: { bulkEditionProcedures: {
1: { 1: {
@ -292,6 +337,7 @@
dones: [false], dones: [false],
totalItemsEditedWithSuccess: 0, totalItemsEditedWithSuccess: 0,
actionResult: '', actionResult: '',
metadataIsLoading: false,
} }
}, },
methods: { methods: {
@ -308,6 +354,12 @@
'setStatusInBulk', 'setStatusInBulk',
'removeValueInBulk' 'removeValueInBulk'
]), ]),
...mapActions('metadata', [
'fetchMetadata'
]),
...mapGetters('metadata', [
'getMetadata'
]),
finalizeProcedure(criterion, withError){ finalizeProcedure(criterion, withError){
this.$set(this.bulkEditionProcedures[criterion], 'isDone', !withError); this.$set(this.bulkEditionProcedures[criterion], 'isDone', !withError);
this.$set(this.bulkEditionProcedures[criterion], 'isDoneWithError', withError); this.$set(this.bulkEditionProcedures[criterion], 'isDoneWithError', withError);
@ -483,11 +535,19 @@
return found ? found : {}; return found ? found : {};
}, },
addToBulkEditionProcedures(value, key, criterion){ addToBulkEditionProcedures(value, key, criterion){
if(Array.isArray(value)){ if(Array.isArray(value)){
value = value[0]; value = value[0];
} }
this.$set(this.bulkEditionProcedures[criterion], `${key}`, value); this.$set(this.bulkEditionProcedures[criterion], `${key}`, value);
if (key == 'metadatumID') {
if (this.getMetadataByID(this.bulkEditionProcedures[criterion].metadatumID).multiple != 'yes') {
let value = Object.values(this.editionActionsForNotMultiple)[0];
this.addToBulkEditionProcedures(value, 'action', criterion);
}
}
} }
}, },
} }
@ -497,11 +557,31 @@
@import '../../scss/_variables.scss'; @import '../../scss/_variables.scss';
.tainacan-modal-content { @media screen and (max-width: 768px) {
border-radius: 10px; .tainacan-bulk-edition-inline-fields {
flex-direction: column !important;
.tainacan-bulk-edition-field:not(:first-child) {
padding-left: 0 !important;
}
.buttons-r-bulk {
margin-left: 0 !important;
justify-content: center !important;
}
}
} }
.modal-card-body { .tainacan-modal-content {
border-radius: 10px;
min-height: 400px;
}
.tainacan-modal-content .form-submit {
padding: 120px 0 0.4em 0 !important;
}
.no-overflow-modal-card-body {
padding: 0 !important; padding: 0 !important;
overflow: unset !important; overflow: unset !important;
} }
@ -572,7 +652,7 @@
max-width: 100% !important; max-width: 100% !important;
} }
&:hover { &:hover, .tag {
background-color: white !important; background-color: white !important;
} }
} }

View File

@ -27,6 +27,15 @@
@blur="updateSlug" @blur="updateSlug"
@focus="clearErrors('name')"/> @focus="clearErrors('name')"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['collection'] != undefined &&
formHooks['collection']['begin-left'] != undefined">
<form
id="form-collection-begin-left"
v-html="this.formHooks['collection']['begin-left'].join('')"/>
</template>
<!-- Thumbnail -------------------------------- --> <!-- Thumbnail -------------------------------- -->
<b-field :addons="false"> <b-field :addons="false">
@ -216,11 +225,23 @@
size="is-small" size="is-small"
true-value="open" true-value="open"
false-value="closed" false-value="closed"
v-model="form.comment_status" /> v-model="form.allow_comments" />
<help-button <help-button
:title="$i18n.getHelperTitle('collections', 'comment_status')" :title="$i18n.getHelperTitle('collections', 'allow_comments')"
:message="$i18n.getHelperMessage('collections', 'comment_status')"/> :message="$i18n.getHelperMessage('collections', 'allow_comments')"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['collection'] != undefined &&
formHooks['collection']['end-left'] != undefined">
<form
ref="form-collection-end-left"
id="form-collection-end-left"
v-html="formHooks['collection']['end-left'].join('')"/>
</template>
</div> </div>
<div class="column is-1" /> <div class="column is-1" />
<div class="column"> <div class="column">
@ -284,7 +305,17 @@
</div> </div>
</div> </div>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['collection'] != undefined &&
formHooks['collection']['begin-right'] != undefined">
<form
id="form-collection-begin-right"
v-html="formHooks['collection']['begin-right'].join('')"/>
</template>
<!-- Description -------------------------------- --> <!-- Description -------------------------------- -->
<b-field <b-field
:addons="false" :addons="false"
@ -385,7 +416,18 @@
v-model="form.slug" v-model="form.slug"
@focus="clearErrors('slug')"/> @focus="clearErrors('slug')"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['collection'] != undefined &&
formHooks['collection']['end-right'] != undefined">
<form
id="form-collection-end-right"
v-html="formHooks['collection']['end-right'].join('')"/>
</template>
</div> </div>
</div> </div>
<!-- Form submit -------------------------------- --> <!-- Form submit -------------------------------- -->
@ -418,11 +460,11 @@ import { mapActions } from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames'; import wpMediaFrames from '../../js/wp-media-frames';
import FileItem from '../other/file-item.vue'; import FileItem from '../other/file-item.vue';
import EyeIcon from '../other/eye-icon.vue'; import EyeIcon from '../other/eye-icon.vue';
import { wpAjax } from '../../js/mixins'; import { wpAjax, formHooks } from '../../js/mixins';
export default { export default {
name: 'CollectionEditionForm', name: 'CollectionEditionForm',
mixins: [ wpAjax ], mixins: [ wpAjax, formHooks ],
data(){ data(){
return { return {
collectionId: Number, collectionId: Number,
@ -440,7 +482,7 @@ export default {
moderators_ids: [], moderators_ids: [],
enabled_view_modes: [], enabled_view_modes: [],
default_view_mode: [], default_view_mode: [],
comment_status: '' allow_comments: ''
}, },
thumbnail: {}, thumbnail: {},
cover: {}, cover: {},
@ -481,7 +523,7 @@ export default {
viewModesList: [], viewModesList: [],
fromImporter: '', fromImporter: '',
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page', newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
isUpdatingSlug: false, isUpdatingSlug: false
} }
}, },
components: { components: {
@ -526,8 +568,8 @@ export default {
}); });
}, 500), }, 500),
onSubmit() { onSubmit() {
this.isLoading = true; this.isLoading = true;
this.form.moderators_ids = []; this.form.moderators_ids = [];
for (let moderator of this.moderators) for (let moderator of this.moderators)
this.form.moderators_ids.push(moderator.id); this.form.moderators_ids.push(moderator.id);
@ -544,12 +586,18 @@ export default {
parent: this.form.parent, parent: this.form.parent,
enabled_view_modes: this.form.enabled_view_modes, enabled_view_modes: this.form.enabled_view_modes,
default_view_mode: this.form.default_view_mode, default_view_mode: this.form.default_view_mode,
comment_status: this.form.comment_status allow_comments: this.form.allow_comments
}; };
this.updateCollection(data).then(updatedCollection => { this.fillExtraFormData(data, 'collection');
this.updateCollection({collection_id: this.collectionId, collection: data })
.then(updatedCollection => {
this.collection = updatedCollection; this.collection = updatedCollection;
// Fills hook forms with it's real values
this.updateExtraFormData('collection', this.collection);
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.name = this.collection.name; this.form.name = this.collection.name;
this.form.slug = this.collection.slug; this.form.slug = this.collection.slug;
@ -559,7 +607,7 @@ export default {
this.form.enable_cover_page = this.collection.enable_cover_page; this.form.enable_cover_page = this.collection.enable_cover_page;
this.form.enabled_view_modes = this.collection.enabled_view_modes; this.form.enabled_view_modes = this.collection.enabled_view_modes;
this.form.default_view_mode = this.collection.default_view_mode; this.form.default_view_mode = this.collection.default_view_mode;
this.form.comment_status = this.collection.comment_status; this.form.allow_comments = this.collection.allow_comments;
this.isLoading = false; this.isLoading = false;
this.formErrorMessage = ''; this.formErrorMessage = '';
@ -586,6 +634,8 @@ export default {
// Creates draft Collection // Creates draft Collection
let data = { name: '', description: '', status: 'auto-draft', mapper: (this.isMapped && this.mapper != false ? this.mapper : false ) }; let data = { name: '', description: '', status: 'auto-draft', mapper: (this.isMapped && this.mapper != false ? this.mapper : false ) };
this.fillExtraFormData(data, 'collection');
this.sendCollection(data).then(res => { this.sendCollection(data).then(res => {
this.collectionId = res.id; this.collectionId = res.id;
@ -593,7 +643,7 @@ export default {
// Initializes Media Frames now that collectonId exists // Initializes Media Frames now that collectonId exists
this.initializeMediaFrames(); this.initializeMediaFrames();
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.name = this.collection.name; this.form.name = this.collection.name;
this.form.description = this.collection.description; this.form.description = this.collection.description;
@ -604,7 +654,7 @@ export default {
this.form.default_view_mode = this.collection.default_view_mode; this.form.default_view_mode = this.collection.default_view_mode;
this.form.enabled_view_modes = []; this.form.enabled_view_modes = [];
this.moderators = []; this.moderators = [];
this.form.comment_status = this.collection.comment_status; this.form.allow_comments = this.collection.allow_comments;
// Pre-fill status with publish to incentivate it // Pre-fill status with publish to incentivate it
this.form.status = 'publish'; this.form.status = 'publish';
@ -758,7 +808,7 @@ export default {
} }
} }
}, },
created(){ mounted(){
if (this.$route.query.fromImporter != undefined) if (this.$route.query.fromImporter != undefined)
this.fromImporter = this.$route.query.fromImporter; this.fromImporter = this.$route.query.fromImporter;
@ -779,7 +829,13 @@ export default {
// Initializes Media Frames now that collectonId exists // Initializes Media Frames now that collectonId exists
this.initializeMediaFrames(); this.initializeMediaFrames();
this.$nextTick()
.then(() => {
// Fills hook forms with it's real values
this.updateExtraFormData('collection', this.collection);
});
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.name = this.collection.name; this.form.name = this.collection.name;
this.form.description = this.collection.description; this.form.description = this.collection.description;
@ -791,7 +847,7 @@ export default {
this.form.default_view_mode = this.collection.default_view_mode; this.form.default_view_mode = this.collection.default_view_mode;
this.form.enabled_view_modes = JSON.parse(JSON.stringify(this.collection.enabled_view_modes)); this.form.enabled_view_modes = JSON.parse(JSON.stringify(this.collection.enabled_view_modes));
this.moderators = JSON.parse(JSON.stringify(this.collection.moderators)); this.moderators = JSON.parse(JSON.stringify(this.collection.moderators));
this.form.comment_status = this.collection.comment_status; this.form.allow_comments = this.collection.allow_comments;
// Generates CoverPage from current cover_page_id info // Generates CoverPage from current cover_page_id info
if (this.form.cover_page_id != undefined && this.form.cover_page_id != '') { if (this.form.cover_page_id != undefined && this.form.cover_page_id != '') {

View File

@ -2,7 +2,8 @@
<form <form
id="filterEditForm" id="filterEditForm"
class="tainacan-form" class="tainacan-form"
@submit.prevent="saveEdition(editForm)"> @submit.prevent="saveEdition(editForm)">
<b-field <b-field
:addons="false" :addons="false"
:type="formErrors['name'] != undefined ? 'is-danger' : ''" :type="formErrors['name'] != undefined ? 'is-danger' : ''"
@ -22,6 +23,16 @@
@focus="clearErrors('name')"/> @focus="clearErrors('name')"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['filter'] != undefined &&
formHooks['filter']['begin-left'] != undefined">
<form
id="form-filter-begin-left"
v-html="formHooks['filter']['begin-left'].join('')"/>
</template>
<b-field <b-field
:addons="false" :addons="false"
:type="formErrors['description'] != undefined ? 'is-danger' : ''" :type="formErrors['description'] != undefined ? 'is-danger' : ''"
@ -135,6 +146,16 @@
<div <div
v-html="editForm.edit_form" v-html="editForm.edit_form"
v-else/> v-else/>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['filter'] != undefined &&
formHooks['filter']['end-left'] != undefined">
<form
id="form-filter-end-left"
v-html="formHooks['filter']['end-left'].join('')"/>
</template>
<div class="field is-grouped form-submit"> <div class="field is-grouped form-submit">
<div class="control"> <div class="control">
@ -156,9 +177,11 @@
<script> <script>
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { formHooks } from "../../js/mixins";
export default { export default {
name: 'FilterEditionForm', name: 'FilterEditionForm',
mixins: [ formHooks ],
data(){ data(){
return { return {
editForm: {}, editForm: {},
@ -182,6 +205,13 @@ export default {
this.oldForm = JSON.parse(JSON.stringify(this.originalFilter)); this.oldForm = JSON.parse(JSON.stringify(this.originalFilter));
}, },
mounted() {
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData('filter', this.editForm);
});
},
beforeDestroy() { beforeDestroy() {
if (this.closedByForm) { if (this.closedByForm) {
this.editedFilter.saved = true; this.editedFilter.saved = true;
@ -201,6 +231,7 @@ export default {
if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') { if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') {
// this.fillExtraFormData(this.editForm, 'filter');
this.updateFilter({ filterId: filter.id, index: this.index, options: this.editForm}) this.updateFilter({ filterId: filter.id, index: this.index, options: this.editForm})
.then(() => { .then(() => {
this.editForm = {}; this.editForm = {};
@ -229,6 +260,7 @@ export default {
formObj[key] = value; formObj[key] = value;
} }
this.fillExtraFormData(formObj, 'filter');
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj}) this.updateFilter({ filterId: filter.id, index: this.index, options: formObj})
.then(() => { .then(() => {
this.editForm = {}; this.editForm = {};
@ -265,7 +297,7 @@ export default {
@import "../../scss/_variables.scss"; @import "../../scss/_variables.scss";
form { form#filterEditForm {
padding: 1.0em 2.0em; padding: 1.0em 2.0em;
border-top: 1px solid $gray2; border-top: 1px solid $gray2;
border-bottom: 1px solid $gray2; border-bottom: 1px solid $gray2;

View File

@ -16,6 +16,16 @@
<div class="columns"> <div class="columns">
<div class="column is-5-5"> <div class="column is-5-5">
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['item'] != undefined &&
formHooks['item']['begin-left'] != undefined">
<form
id="form-item-begin-left"
v-html="formHooks['item']['begin-left'].join('')"/>
</template>
<!-- Document -------------------------------- --> <!-- Document -------------------------------- -->
<div class="section-label"> <div class="section-label">
<label>{{ form.document != undefined && form.document != null && form.document != '' ? $i18n.get('label_document') : $i18n.get('label_document_empty') }}</label> <label>{{ form.document != undefined && form.document != null && form.document != '' ? $i18n.get('label_document') : $i18n.get('label_document_empty') }}</label>
@ -256,7 +266,7 @@
<b-field <b-field
:addons="false" :addons="false"
:label="$i18n.get('label_comment_status')" :label="$i18n.get('label_comment_status')"
v-if="collectionCommentStatus == 'open'"> v-if="collectionAllowComments == 'open'">
<b-switch <b-switch
id="tainacan-checkbox-comment-status" id="tainacan-checkbox-comment-status"
size="is-small" size="is-small"
@ -292,11 +302,31 @@
</div> </div>
</div> </div>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['item'] != undefined &&
formHooks['item']['end-left'] != undefined">
<form
id="form-item-end-left"
v-html="formHooks['item']['end-left'].join('')"/>
</template>
</div> </div>
<div <div
class="column is-4-5" class="column is-4-5"
v-show="!isMetadataColumnCompressed"> v-show="!isMetadataColumnCompressed">
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['item'] != undefined &&
formHooks['item']['begin-right'] != undefined">
<form
id="form-item-begin-right"
v-html="formHooks['item']['begin-right'].join('')"/>
</template>
<!-- Visibility (status public or private) -------------------------------- --> <!-- Visibility (status public or private) -------------------------------- -->
<div class="section-label"> <div class="section-label">
@ -341,16 +371,14 @@
<!-- Metadata from Collection-------------------------------- --> <!-- Metadata from Collection-------------------------------- -->
<span class="section-label"> <span class="section-label">
<label >{{ $i18n.get('metadata') }}</label> <label>{{ $i18n.get('metadata') }}</label>
</span> </span>
<br> <br>
<a <a
class="collapse-all" class="collapse-all"
@click="toggleCollapseAll()"> @click="toggleCollapseAll()">
{{ collapseAll ? $i18n.get('label_collapse_all') : $i18n.get('label_expand_all') }} {{ collapseAll ? $i18n.get('label_collapse_all') : $i18n.get('label_expand_all') }}
<b-icon <b-icon :icon=" collapseAll ? 'menu-down' : 'menu-right'" />
type="is-turoquoise5"
:icon=" collapseAll ? 'menu-down' : 'menu-right'" />
</a> </a>
<tainacan-form-item <tainacan-form-item
v-for="(metadatum, index) of metadatumList" v-for="(metadatum, index) of metadatumList"
@ -359,6 +387,15 @@
:is-collapsed="metadatumCollapses[index]" :is-collapsed="metadatumCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/> @changeCollapse="onChangeCollapse($event, index)"/>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['item'] != undefined &&
formHooks['item']['end-right'] != undefined">
<form
id="form-item-end-right"
v-html="formHooks['item']['end-right'].join('')"/>
</template>
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">
@ -443,9 +480,11 @@ import wpMediaFrames from '../../js/wp-media-frames';
import FileItem from '../other/file-item.vue'; import FileItem from '../other/file-item.vue';
import DocumentItem from '../other/document-item.vue'; import DocumentItem from '../other/document-item.vue';
import CustomDialog from '../other/custom-dialog.vue'; import CustomDialog from '../other/custom-dialog.vue';
import { formHooks } from '../../js/mixins';
export default { export default {
name: 'ItemEditionForm', name: 'ItemEditionForm',
mixins: [ formHooks ],
data(){ data(){
return { return {
pageTitle: '', pageTitle: '',
@ -490,7 +529,7 @@ export default {
textLink: '', textLink: '',
isUpdatingValues: false, isUpdatingValues: false,
collectionName: '', collectionName: '',
collectionCommentStatus: '' collectionAllowComments: ''
} }
}, },
computed: { computed: {
@ -530,7 +569,7 @@ export default {
]), ]),
...mapActions('collection', [ ...mapActions('collection', [
'fetchCollectionName', 'fetchCollectionName',
'fetchCollectionCommentStatus', 'fetchCollectionAllowComments',
'deleteItem', 'deleteItem',
]), ]),
onSubmit(status) { onSubmit(status) {
@ -540,12 +579,15 @@ export default {
let previousStatus = this.form.status; let previousStatus = this.form.status;
this.form.status = status; this.form.status = status;
let data = {item_id: this.itemId, status: this.form.status, comment_status: this.form.comment_status}; let data = {id: this.itemId, status: this.form.status, comment_status: this.form.comment_status};
this.fillExtraFormData(data, 'item');
this.updateItem(data).then(updatedItem => { this.updateItem(data).then(updatedItem => {
this.item = updatedItem; this.item = updatedItem;
// Fills hook forms with it's real values
this.updateExtraFormData('item', this.item);
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.status = this.item.status; this.form.status = this.item.status;
this.form.document = this.item.document; this.form.document = this.item.document;
@ -582,6 +624,7 @@ export default {
// Creates draft Item // Creates draft Item
let data = {collection_id: this.form.collectionId, status: 'auto-draft', comment_status: this.form.comment_status}; let data = {collection_id: this.form.collectionId, status: 'auto-draft', comment_status: this.form.comment_status};
this.fillExtraFormData(data, 'item');
this.sendItem(data).then(res => { this.sendItem(data).then(res => {
this.itemId = res.id; this.itemId = res.id;
@ -806,6 +849,12 @@ export default {
this.fetchItem(this.itemId).then(res => { this.fetchItem(this.itemId).then(res => {
this.item = res; this.item = res;
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData('item', this.item);
});
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.status = this.item.status; this.form.status = this.item.status;
this.form.document = this.item.document; this.form.document = this.item.document;
@ -833,9 +882,9 @@ export default {
this.collectionName = collectionName; this.collectionName = collectionName;
}); });
// Obtains collection name // Obtains if collection allow items comments
this.fetchCollectionCommentStatus(this.collectionId).then((collectionCommentStatus) => { this.fetchCollectionAllowComments(this.collectionId).then((collectionAllowComments) => {
this.collectionCommentStatus = collectionCommentStatus; this.collectionAllowComments = collectionAllowComments;
}); });
// Sets feedback variables // Sets feedback variables
@ -907,6 +956,10 @@ export default {
.page-container { .page-container {
padding: 25px 0px; padding: 25px 0px;
&>.tainacan-form {
margin-bottom: 110px;
}
.tainacan-page-title { .tainacan-page-title {
padding-left: $page-side-padding; padding-left: $page-side-padding;
padding-right: $page-side-padding; padding-right: $page-side-padding;
@ -945,7 +998,7 @@ export default {
label { label {
font-size: 16px !important; font-size: 16px !important;
font-weight: 500 !important; font-weight: 500 !important;
color: $blue5 !important; color: $gray5 !important;
line-height: 1.2em; line-height: 1.2em;
} }
} }

View File

@ -24,6 +24,16 @@
@focus="clearErrors('name')"/> @focus="clearErrors('name')"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['metadatum'] != undefined &&
formHooks['metadatum']['begin-left'] != undefined">
<form
id="form-metadatum-begin-left"
v-html="formHooks['metadatum']['begin-left'].join('')"/>
</template>
<b-field <b-field
:addons="false" :addons="false"
:type="formErrors['description'] != undefined ? 'is-danger' : ''" :type="formErrors['description'] != undefined ? 'is-danger' : ''"
@ -206,6 +216,16 @@
v-html="editForm.edit_form" v-html="editForm.edit_form"
v-else/> v-else/>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['metadatum'] != undefined &&
formHooks['metadatum']['end-left'] != undefined">
<form
id="form-metadatum-end-left"
v-html="formHooks['metadatum']['end-left'].join('')"/>
</template>
<div class="field is-grouped form-submit"> <div class="field is-grouped form-submit">
<div class="control"> <div class="control">
<button <button
@ -228,9 +248,11 @@
<script> <script>
import {mapActions} from 'vuex'; import {mapActions} from 'vuex';
import { formHooks } from "../../js/mixins";
export default { export default {
name: 'MetadatumEditionForm', name: 'MetadatumEditionForm',
mixins: [ formHooks ],
data() { data() {
return { return {
editForm: {}, editForm: {},
@ -257,6 +279,13 @@
this.oldForm = JSON.parse(JSON.stringify(this.originalMetadatum)); this.oldForm = JSON.parse(JSON.stringify(this.originalMetadatum));
}, },
mounted() {
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData('metadatum', this.editForm);
});
},
beforeDestroy() { beforeDestroy() {
if (this.closedByForm) { if (this.closedByForm) {
this.editedMetadatum.saved = true; this.editedMetadatum.saved = true;
@ -275,7 +304,8 @@
saveEdition(metadatum) { saveEdition(metadatum) {
if ((metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') { if ((metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') {
this.fillExtraFormData(this.editForm, 'metadatum');
this.updateMetadatum({ this.updateMetadatum({
collectionId: this.collectionId, collectionId: this.collectionId,
metadatumId: metadatum.id, metadatumId: metadatum.id,
@ -309,6 +339,7 @@
for (let [key, value] of formData.entries()) for (let [key, value] of formData.entries())
formObj[key] = value; formObj[key] = value;
this.fillExtraFormData(formObj, 'metadatum');
this.updateMetadatum({ this.updateMetadatum({
collectionId: this.collectionId, collectionId: this.collectionId,
metadatumId: metadatum.id, metadatumId: metadatum.id,

View File

@ -25,6 +25,16 @@
@blur="updateSlug()"/> @blur="updateSlug()"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['taxonomy'] != undefined &&
formHooks['taxonomy']['begin-left'] != undefined">
<form
id="form-taxonomy-begin-left"
v-html="formHooks['taxonomy']['begin-left'].join('')"/>
</template>
<!-- Description -------------------------------- --> <!-- Description -------------------------------- -->
<b-field <b-field
:addons="false" :addons="false"
@ -99,6 +109,16 @@
</div> </div>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['taxonomy'] != undefined &&
formHooks['taxonomy']['end-left'] != undefined">
<form
id="form-taxonomy-end-left"
v-html="formHooks['taxonomy']['end-left'].join('')"/>
</template>
<!-- Submit --> <!-- Submit -->
<div class="field is-grouped form-submit"> <div class="field is-grouped form-submit">
<div class="control"> <div class="control">
@ -133,14 +153,14 @@
</template> </template>
<script> <script>
import { wpAjax } from "../../js/mixins"; import { wpAjax, formHooks } from "../../js/mixins";
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import TermsList from '../lists/terms-list.vue'; import TermsList from '../lists/terms-list.vue';
import CustomDialog from '../other/custom-dialog.vue'; import CustomDialog from '../other/custom-dialog.vue';
export default { export default {
name: 'TaxonomyEditionForm', name: 'TaxonomyEditionForm',
mixins: [ wpAjax ], mixins: [ wpAjax, formHooks ],
data(){ data(){
return { return {
taxonomyId: String, taxonomyId: String,
@ -169,8 +189,7 @@
label: this.$i18n.get('trash') label: this.$i18n.get('trash')
}], }],
editFormErrors: {}, editFormErrors: {},
formErrorMessage: '', formErrorMessage: ''
// baseUrl: tainacan_plugin.base_url,
} }
}, },
components: { components: {
@ -225,16 +244,19 @@
taxonomyId: this.taxonomyId, taxonomyId: this.taxonomyId,
name: this.form.name, name: this.form.name,
description: this.form.description, description: this.form.description,
slug: this.form.slug, slug: this.form.slug ? this.form.slug : '',
status: this.form.status, status: this.form.status,
allowInsert: this.form.allowInsert allow_insert: this.form.allowInsert
}; };
this.fillExtraFormData(data, 'taxonomy');
this.updateTaxonomy(data) this.updateTaxonomy(data)
.then(updatedTaxonomy => { .then(updatedTaxonomy => {
this.taxonomy = updatedTaxonomy; this.taxonomy = updatedTaxonomy;
// Fills hook forms with it's real values
this.updateExtraFormData('taxonomy', this.taxonomy);
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.name = this.taxonomy.name; this.form.name = this.taxonomy.name;
this.form.slug = this.taxonomy.slug; this.form.slug = this.taxonomy.slug;
@ -291,9 +313,9 @@
description: '', description: '',
status: 'auto-draft', status: 'auto-draft',
slug: '', slug: '',
allowInsert: '', allow_insert: '',
}; };
this.fillExtraFormData(data, 'taxonomy');
this.createTaxonomy(data) this.createTaxonomy(data)
.then(res => { .then(res => {
@ -324,8 +346,8 @@
return ( this.form.allowInsert === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no'); return ( this.form.allowInsert === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no');
} }
}, },
created(){ mounted(){
if (this.$route.fullPath.split("/").pop() === "new") { if (this.$route.fullPath.split("/").pop() === "new") {
this.createNewTaxonomy(); this.createNewTaxonomy();
} else if (this.$route.fullPath.split("/").pop() === "edit" || this.$route.fullPath.split("/").pop() === "terms") { } else if (this.$route.fullPath.split("/").pop() === "edit" || this.$route.fullPath.split("/").pop() === "terms") {
@ -339,6 +361,12 @@
this.fetchTaxonomy(this.taxonomyId).then(res => { this.fetchTaxonomy(this.taxonomyId).then(res => {
this.taxonomy = res.taxonomy; this.taxonomy = res.taxonomy;
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData('taxonomy', this.taxonomy);
});
// Fill this.form data with current data. // Fill this.form data with current data.
this.form.name = this.taxonomy.name; this.form.name = this.taxonomy.name;
this.form.description = this.taxonomy.description; this.form.description = this.taxonomy.description;

View File

@ -63,6 +63,16 @@
@focus="clearErrors({ name: 'name', repeated: 'repeated' })"/> @focus="clearErrors({ name: 'name', repeated: 'repeated' })"/>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['term'] != undefined &&
formHooks['term']['begin-left'] != undefined">
<form
id="form-term-begin-left"
v-html="formHooks['term']['begin-left'].join('')"/>
</template>
<!-- Description -------------- --> <!-- Description -------------- -->
<b-field <b-field
:addons="false" :addons="false"
@ -122,6 +132,16 @@
</transition> </transition>
</b-field> </b-field>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['term'] != undefined &&
formHooks['term']['end-left'] != undefined">
<form
id="form-term-end-left"
v-html="formHooks['term']['end-left'].join('')"/>
</template>
<!-- Submit buttons -------------- --> <!-- Submit buttons -------------- -->
<div class="field is-grouped form-submit"> <div class="field is-grouped form-submit">
<div class="control"> <div class="control">
@ -154,11 +174,13 @@
</template> </template>
<script> <script>
import { formHooks } from "../../js/mixins";
import {mapActions, mapGetters} from 'vuex'; import {mapActions, mapGetters} from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames'; import wpMediaFrames from '../../js/wp-media-frames';
export default { export default {
name: 'TermEditionForm', name: 'TermEditionForm',
mixins: [ formHooks ],
data() { data() {
return { return {
formErrors: {}, formErrors: {},
@ -190,12 +212,16 @@
saveEdition(term) { saveEdition(term) {
if (term.id === 'new') { if (term.id === 'new') {
this.sendChildTerm({ let data = {
taxonomyId: this.taxonomyId,
name: this.editForm.name, name: this.editForm.name,
description: this.editForm.description, description: this.editForm.description,
parent: this.hasParent ? this.editForm.parent : 0, parent: this.hasParent ? this.editForm.parent : 0,
headerImageId: this.editForm.header_image_id, header_image_id: this.editForm.header_image_id,
};
this.fillExtraFormData(data, 'term');
this.sendChildTerm({
taxonomyId: this.taxonomyId,
term: data
}) })
.then((term) => { .then((term) => {
this.$emit('onEditionFinished', {term: term, hasChangedParent: this.hasChangedParent }); this.$emit('onEditionFinished', {term: term, hasChangedParent: this.hasChangedParent });
@ -213,13 +239,17 @@
} else { } else {
this.updateChildTerm({ let data = {
taxonomyId: this.taxonomyId, term_id: this.editForm.id,
termId: this.editForm.id,
name: this.editForm.name, name: this.editForm.name,
description: this.editForm.description, description: this.editForm.description,
parent: this.hasParent ? this.editForm.parent : 0, parent: this.hasParent ? this.editForm.parent : 0,
headerImageId: this.editForm.header_image_id, header_image_id: this.editForm.header_image_id,
}
this.fillExtraFormData(data, 'term');
this.updateChildTerm({
taxonomyId: this.taxonomyId,
term: data
}) })
.then((term) => { .then((term) => {
this.formErrors = {}; this.formErrors = {};
@ -312,6 +342,12 @@
}, },
mounted() { mounted() {
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData('term', this.editForm);
});
this.showCheckboxesWarning = false; this.showCheckboxesWarning = false;
this.hasParent = this.editForm.parent != undefined && this.editForm.parent > 0; this.hasParent = this.editForm.parent != undefined && this.editForm.parent > 0;
this.initialParentId = this.editForm.parent; this.initialParentId = this.editForm.parent;
@ -358,7 +394,7 @@
} }
} }
form { form#termEditForm {
padding: 1.7rem 0 1.5rem 1.5rem; padding: 1.7rem 0 1.5rem 1.5rem;
border-left: 1px solid $gray2; border-left: 1px solid $gray2;
margin-left: 0.75rem; margin-left: 0.75rem;

View File

@ -103,9 +103,7 @@
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <activities-icon />
icon="inbox"
size="is-large"/>
</p> </p>
<p>{{ $i18n.get('info_no_events') }}</p> <p>{{ $i18n.get('info_no_events') }}</p>
</div> </div>
@ -115,7 +113,7 @@
</template> </template>
<script> <script>
// import { mapActions } from 'vuex' import ActivitiesIcon from '../other/activities-icon.vue';
export default { export default {
name: 'EventsList', name: 'EventsList',
@ -124,6 +122,9 @@
selectedEvents: [] selectedEvents: []
} }
}, },
components: {
ActivitiesIcon
},
props: { props: {
isLoading: false, isLoading: false,
totalEvents: 0, totalEvents: 0,
@ -149,6 +150,9 @@
} }
</script> </script>
<style> <style scoped>
.activities-icon {
height: 24px;
width: 24px;
}
</style> </style>

View File

@ -583,12 +583,6 @@ export default {
} }
} }
form {
padding: 1.0em 2.0em;
border-top: 1px solid $gray2;
border-bottom: 1px solid $gray2;
margin-top: 1.0em;
}
&.not-sortable-item, &.not-sortable-item:hover { &.not-sortable-item, &.not-sortable-item:hover {
cursor: default; cursor: default;
background-color: white !important; background-color: white !important;

View File

@ -6,14 +6,19 @@
<span> <span>
<b-checkbox <b-checkbox
@click.native="selectAllItemsOnPage()" @click.native="selectAllItemsOnPage()"
:value="allItemsOnPageSelected">{{ $i18n.get('label_select_all_items_page') }}</b-checkbox> :value="allItemsOnPageSelected">
{{ $i18n.get('label_select_all_items_page') }}
</b-checkbox>
</span> </span>
<span v-if="allItemsOnPageSelected"> <span
style="margin-left: 10px"
v-if="allItemsOnPageSelected && items.length > 1">
<b-checkbox <b-checkbox
@click.native="selectAllItems()" @click.native="selectAllItems()"
v-model="isAllItemsSelected">{{ $i18n.get('label_select_all_items') }}</b-checkbox> v-model="isAllItemsSelected">
<small v-if="isAllItemsSelected">{{ `(${ totalItems } ${ $i18n.get('info_items_selected') })` }}</small> {{ `${$i18n.get('label_select_all')} ${totalItems} ${$i18n.get('items').toLowerCase()}` }}
</b-checkbox>
</span> </span>
</div> </div>
<div class="field is-pulled-right"> <div class="field is-pulled-right">
@ -28,17 +33,18 @@
slot="trigger"> slot="trigger">
<span>{{ $i18n.get('label_bulk_actions') }}</span> <span>{{ $i18n.get('label_bulk_actions') }}</span>
<b-icon icon="menu-down"/> <b-icon icon="menu-down"/>
</button> </button>
<b-dropdown-item
v-if="$route.params.collectionId && $userCaps.hasCapability('edit_others_posts')"
@click="openBulkEditionModal()">
{{ $i18n.get('label_edit_selected_items') }}
</b-dropdown-item>
<b-dropdown-item <b-dropdown-item
@click="deleteSelectedItems()" @click="deleteSelectedItems()"
id="item-delete-selected-items"> id="item-delete-selected-items">
{{ isOnTrash ? $i18n.get('label_delete_permanently') : $i18n.get('label_send_to_trash') }} {{ isOnTrash ? $i18n.get('label_delete_permanently') : $i18n.get('label_send_to_trash') }}
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item
@click="openBulkEditionModal()">
{{ $i18n.get('label_edit_selected_items') }}
</b-dropdown-item>
</b-dropdown> </b-dropdown>
</div> </div>
</div> </div>
@ -624,7 +630,6 @@ export default {
totalItems: Object.keys(this.queryAllItemsSelected).length ? this.totalItems : this.selectedItemsIDs.filter(item => item !== false).length, totalItems: Object.keys(this.queryAllItemsSelected).length ? this.totalItems : this.selectedItemsIDs.filter(item => item !== false).length,
selectedForBulk: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs.filter(item => item !== false), selectedForBulk: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs.filter(item => item !== false),
objectType: this.$i18n.get('items'), objectType: this.$i18n.get('items'),
metadata: this.tableMetadata,
collectionID: this.$route.params.collectionId, collectionID: this.$route.params.collectionId,
}, },
width: 'calc(100% - 8.333333333%)', width: 'calc(100% - 8.333333333%)',

View File

@ -79,7 +79,8 @@
<div <div
v-if="searchQuery == undefined || searchQuery == ''" v-if="searchQuery == undefined || searchQuery == ''"
v-for="(term, index) in localTerms" v-for="(term, index) in localTerms"
:key="term.id"> :key="term.id"
class="parent-term">
<recursive-term-item <recursive-term-item
:term="term" :term="term"
@ -112,9 +113,7 @@
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <taxonomies-icon class="taxonomies-term-icon"/>
icon="inbox"
size="is-large"/>
</p> </p>
<p>{{ $i18n.get('info_no_terms_created_on_taxonomy') }}</p> <p>{{ $i18n.get('info_no_terms_created_on_taxonomy') }}</p>
<button <button
@ -134,6 +133,7 @@ import { mapActions, mapGetters } from 'vuex';
import TermEditionForm from '../edition/term-edition-form.vue'; import TermEditionForm from '../edition/term-edition-form.vue';
import RecursiveTermItem from './recursive-term-item.vue' import RecursiveTermItem from './recursive-term-item.vue'
import BasicTermItem from './basic-term-item.vue' import BasicTermItem from './basic-term-item.vue'
import TaxonomiesIcon from '../other/taxonomies-icon.vue';
import t from 't'; import t from 't';
export default { export default {
@ -180,7 +180,8 @@ export default {
components: { components: {
RecursiveTermItem, RecursiveTermItem,
BasicTermItem, BasicTermItem,
TermEditionForm TermEditionForm,
TaxonomiesIcon
}, },
methods: { methods: {
...mapActions('taxonomy', [ ...mapActions('taxonomy', [
@ -346,6 +347,7 @@ export default {
this.deleteTerm({taxonomyId: this.taxonomyId, termId: term.id }) this.deleteTerm({taxonomyId: this.taxonomyId, termId: term.id })
.then(() => { .then(() => {
this.searchTerms(this.offset); this.searchTerms(this.offset);
this.totalTerms--;
}) })
.catch((error) => { .catch((error) => {
this.$console.log(error); this.$console.log(error);
@ -391,7 +393,10 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
.taxonomies-term-icon {
height: 24px;
width: 24px;
}
@import "../../scss/_variables.scss"; @import "../../scss/_variables.scss";
.columns { .columns {
@ -441,6 +446,17 @@ export default {
} }
} }
.parent-term>div>.term-item:first-child:hover {
background-color: $gray1 !important;
.controls {
visibility: visible;
opacity: 1.0;
}
&::before {
border-color: transparent transparent transparent $gray2 !important;
}
}
.view-more-terms-level-0 { .view-more-terms-level-0 {
font-size: 0.875rem; font-size: 0.875rem;
margin: 0; margin: 0;

View File

@ -211,7 +211,6 @@
.search-header { .search-header {
border: 1px solid $gray2 !important; border: 1px solid $gray2 !important;
height: 27px; height: 27px;
font-size: 11px;
transition: width linear 0.15s; transition: width linear 0.15s;
-webkit-transition: width linear 0.15s; -webkit-transition: width linear 0.15s;
width: 220px; width: 220px;

View File

@ -447,7 +447,6 @@
terms: this.selected terms: this.selected
}); });
for (let selected of this.selected) { for (let selected of this.selected) {
for(let i in this.finderColumns){ for(let i in this.finderColumns){

View File

@ -46,4 +46,80 @@ export const dateInter = {
return format.replace(/[\w]/g, '#'); return format.replace(/[\w]/g, '#');
} }
} }
};
// Used for filling extra form data on hooks
export const formHooks = {
data() {
return {
formHooks: JSON.parse(JSON.stringify(tainacan_plugin['form_hooks']))
}
},
methods: {
fillExtraFormData(data, entity) {
let positions = [
'begin-left',
'begin-right',
'end-left',
'end-right'
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks[entity] && this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
if (formElement) {
for (let element of formElement.elements) {
if (element.type == "checkbox" || (element.type == "select" && element.multiple != undefined && element.multiple == true)) {
if (element.checked && element.name != undefined && element.name != '') {
if (!Array.isArray(data[element.name]))
data[element.name] = [];
data[element.name].push(element.value);
}
} else if (element.type == "radio") {
if (element.checked && element.name != undefined && element.name != '')
data[element.name] = element.value;
} else {
data[element.name] = element.value;
}
}
}
}
}
},
updateExtraFormData(entity, entityObject) {
let positions = [
'begin-left',
'begin-right',
'end-left',
'end-right'
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks[entity] && this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
if (formElement) {
for (let element of formElement.elements) {
for (let key of Object.keys(entityObject)) {
if (element['name'] == key) {
if (Array.isArray(entityObject[key])) {
let obj = entityObject[key].find((value) => { return value == element['value'] });
element['checked'] = obj != undefined ? true : false;
} else {
if (entityObject[key] != null && entityObject[key] != undefined && entityObject[key] != ''){
if (element.type == "radio")
element['checked'] = entityObject[key] == element['value'] ? true : false;
else
element['value'] = entityObject[key];
}
}
}
}
}
}
}
}
}
}
}; };

View File

@ -110,7 +110,6 @@ export const ThemeItemsListing = new Vue({
}, },
render: h => h(ThemeItemsList), render: h => h(ThemeItemsList),
beforeMount () { beforeMount () {
if (this.$el.attributes['collection-id'] != undefined) if (this.$el.attributes['collection-id'] != undefined)
this.collectionId = this.$el.attributes['collection-id'].value; this.collectionId = this.$el.attributes['collection-id'].value;
if (this.$el.attributes['default-view-mode'] != undefined) if (this.$el.attributes['default-view-mode'] != undefined)

View File

@ -76,9 +76,7 @@
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <b-icon icon="folder-multiple"/>
icon="inbox"
size="is-large"/>
</p> </p>
<p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_collection_created') }}</p> <p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_collection_created') }}</p>
<p v-if="status == 'draft'">{{ $i18n.get('info_no_collection_draft') }}</p> <p v-if="status == 'draft'">{{ $i18n.get('info_no_collection_draft') }}</p>

View File

@ -45,9 +45,7 @@
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <activities-icon />
icon="inbox"
size="is-large"/>
</p> </p>
<p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_process') }}</p> <p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_process') }}</p>
</div> </div>
@ -137,6 +135,7 @@
<script> <script>
import EventsList from "../../components/lists/events-list.vue"; import EventsList from "../../components/lists/events-list.vue";
import ProcessesList from "../../components/lists/processes-list.vue"; import ProcessesList from "../../components/lists/processes-list.vue";
import ActivitiesIcon from '../../components/other/activities-icon.vue';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import moment from 'moment' import moment from 'moment'
@ -156,7 +155,8 @@
}, },
components: { components: {
EventsList, EventsList,
ProcessesList ProcessesList,
ActivitiesIcon
}, },
methods: { methods: {
...mapActions('event', [ ...mapActions('event', [
@ -314,6 +314,11 @@
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../scss/_variables.scss'; @import '../../scss/_variables.scss';
.activities-icon {
height: 24px;
width: 24px;
}
.sub-header { .sub-header {
max-height: $header-height; max-height: $header-height;
height: $header-height; height: $header-height;

View File

@ -152,12 +152,9 @@
<b-dropdown-item disabled> <b-dropdown-item disabled>
{{ $i18n.get('add_items_bulk') + ' (Not ready)' }} {{ $i18n.get('add_items_bulk') + ' (Not ready)' }}
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item disabled>
{{ $i18n.get('add_items_external_source') + ' (Not ready)' }}
</b-dropdown-item>
<b-dropdown-item> <b-dropdown-item>
<div <div
id="a-import-collection" id="a-import-items"
tag="div" tag="div"
@click="onOpenImportersModal"> @click="onOpenImportersModal">
{{ $i18n.get('label_import_items') }} {{ $i18n.get('label_import_items') }}
@ -566,9 +563,7 @@
class="section"> class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <b-icon icon="file-multiple"/>
icon="inbox"
size="is-large"/>
</p> </p>
<p v-if="status == undefined || status == ''">{{ hasFiltered ? $i18n.get('info_no_item_found_filter') : $i18n.get('info_no_item_created') }}</p> <p v-if="status == undefined || status == ''">{{ hasFiltered ? $i18n.get('info_no_item_found_filter') : $i18n.get('info_no_item_created') }}</p>
<p v-if="status == 'draft'">{{ $i18n.get('info_no_item_draft') }}</p> <p v-if="status == 'draft'">{{ $i18n.get('info_no_item_draft') }}</p>

View File

@ -48,9 +48,7 @@
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <taxonomies-icon class="taxonomies-term-icon"/>
icon="inbox"
size="is-large"/>
</p> </p>
<p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_taxonomy_created') }}</p> <p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_taxonomy_created') }}</p>
<p v-if="status == 'draft'">{{ $i18n.get('info_no_taxonomy_draft') }}</p> <p v-if="status == 'draft'">{{ $i18n.get('info_no_taxonomy_draft') }}</p>
@ -112,6 +110,7 @@
<script> <script>
import TaxonomiesList from "../../components/lists/taxonomies-list.vue"; import TaxonomiesList from "../../components/lists/taxonomies-list.vue";
import TaxonomiesIcon from '../../components/other/taxonomies-icon.vue';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
//import moment from 'moment' //import moment from 'moment'
@ -127,7 +126,8 @@
} }
}, },
components: { components: {
TaxonomiesList TaxonomiesList,
TaxonomiesIcon
}, },
methods: { methods: {
...mapActions('taxonomy', [ ...mapActions('taxonomy', [
@ -198,6 +198,10 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.taxonomies-icon {
height: 24px;
width: 24px;
}
@import '../../scss/_variables.scss'; @import '../../scss/_variables.scss';
.sub-header { .sub-header {

View File

@ -560,9 +560,7 @@
class="section"> class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
<b-icon <b-icon icon="file-multiple"/>
icon="inbox"
size="is-large"/>
</p> </p>
<p v-if="status == undefined || status == ''">{{ hasFiltered ? $i18n.get('info_no_item_found_filter') : $i18n.get('info_no_item_created') }}</p> <p v-if="status == undefined || status == ''">{{ hasFiltered ? $i18n.get('info_no_item_found_filter') : $i18n.get('info_no_item_created') }}</p>
<p v-if="status == 'draft'">{{ $i18n.get('info_no_item_draft') }}</p> <p v-if="status == 'draft'">{{ $i18n.get('info_no_item_draft') }}</p>

View File

@ -13,6 +13,16 @@
<div class="columns"> <div class="columns">
<div class="column is-5-5"> <div class="column is-5-5">
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['view-item'] != undefined &&
formHooks['view-item']['begin-left'] != undefined">
<div
id="view-item-begin-left"
v-html="formHooks['view-item']['begin-left'].join('')"/>
</template>
<!-- Document -------------------------------- --> <!-- Document -------------------------------- -->
<div class="section-label"> <div class="section-label">
<label>{{ item.document !== undefined && item.document !== null && item.document !== '' ? <label>{{ item.document !== undefined && item.document !== null && item.document !== '' ?
@ -88,7 +98,7 @@
<b-field <b-field
:addons="false" :addons="false"
:label="$i18n.get('label_comment_status')" :label="$i18n.get('label_comment_status')"
v-if="collectionCommentStatus == 'open'"> v-if="collectionAllowComments == 'open'">
<b-switch <b-switch
id="tainacan-checkbox-comment-status" id="tainacan-checkbox-comment-status"
size="is-small" size="is-small"
@ -156,11 +166,32 @@
</b-collapse> </b-collapse>
</div> </div>
</div> </div>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['view-item'] != undefined &&
formHooks['view-item']['end-left'] != undefined">
<div
id="view-item-end-left"
v-html="formHooks['view-item']['end-left'].join('')"/>
</template>
</div> </div>
<div <div
v-show="!isMetadataColumnCompressed" v-show="!isMetadataColumnCompressed"
class="column is-4-5"> class="column is-4-5">
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['view-item'] != undefined &&
formHooks['view-item']['begin-right'] != undefined">
<div
id="view-item-begin-right"
v-html="formHooks['view-item']['begin-right'].join('')"/>
</template>
<!-- Visibility (status public or private) -------------------------------- --> <!-- Visibility (status public or private) -------------------------------- -->
<div class="section-label"> <div class="section-label">
<label>{{ $i18n.get('label_visibility') }}</label> <label>{{ $i18n.get('label_visibility') }}</label>
@ -235,6 +266,16 @@
</b-collapse> </b-collapse>
</div> </div>
</div> </div>
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['view-item'] != undefined &&
formHooks['view-item']['end-right'] != undefined">
<div
id="view-item-end-right"
v-html="formHooks['view-item']['end-right'].join('')"/>
</template>
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">
@ -260,9 +301,11 @@
import {mapActions, mapGetters} from 'vuex' import {mapActions, mapGetters} from 'vuex'
import FileItem from '../../components/other/file-item.vue'; import FileItem from '../../components/other/file-item.vue';
import DocumentItem from '../../components/other/document-item.vue'; import DocumentItem from '../../components/other/document-item.vue';
import { formHooks } from '../../js/mixins';
export default { export default {
name: 'ItemPage', name: 'ItemPage',
mixins: [ formHooks ],
data() { data() {
return { return {
collectionId: Number, collectionId: Number,
@ -274,7 +317,7 @@
collectionName: '', collectionName: '',
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png', thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
urls_open: false, urls_open: false,
collectionCommentStatus: '' collectionAllowComments: ''
} }
}, },
components: { components: {
@ -289,7 +332,7 @@
]), ]),
...mapActions('collection', [ ...mapActions('collection', [
'fetchCollectionName', 'fetchCollectionName',
'fetchCollectionCommentStatus' 'fetchCollectionAllowComments'
]), ]),
...mapGetters('item', [ ...mapGetters('item', [
'getItem', 'getItem',
@ -329,6 +372,9 @@
}, },
computed: { computed: {
item() { item() {
// Fills hook forms with it's real values
this.updateExtraFormData('item', this.getItem());
return this.getItem(); return this.getItem();
}, },
metadatumList() { metadatumList() {
@ -374,8 +420,8 @@
this.fetchAttachments(this.itemId); this.fetchAttachments(this.itemId);
// Obtains collection Comment Status // Obtains collection Comment Status
this.fetchCollectionCommentStatus(this.collectionId).then((collectionCommentStatus) => { this.fetchCollectionAllowComments(this.collectionId).then((collectionAllowComments) => {
this.collectionCommentStatus = collectionCommentStatus; this.collectionAllowComments = collectionAllowComments;
}); });
} }
@ -411,6 +457,10 @@
.page-container { .page-container {
padding: 25px 0; padding: 25px 0;
&>.tainacan-form {
margin-bottom: 110px;
}
.tainacan-page-title { .tainacan-page-title {
padding-left: $page-side-padding; padding-left: $page-side-padding;
padding-right: $page-side-padding; padding-right: $page-side-padding;
@ -472,7 +522,7 @@
label { label {
font-size: 16px !important; font-size: 16px !important;
font-weight: 500 !important; font-weight: 500 !important;
color: $blue5 !important; color: $gray5 !important;
line-height: 1.2em; line-height: 1.2em;
} }
} }

View File

@ -37,7 +37,7 @@
} }
.tainacan-modal-content { .tainacan-modal-content {
background-color: white; background-color: white;
padding: 52px 8.3333333%; padding: 40px 50px;
position: relative; position: relative;
figure { figure {

View File

@ -33,14 +33,15 @@ return apply_filters( 'tainacan-admin-i18n', [
'processes' => __( 'Processes', 'tainacan' ), 'processes' => __( 'Processes', 'tainacan' ),
// Actions // Actions
'close' => __( 'Close', 'tainacan' ),
'edit' => __( 'Edit', 'tainacan' ), 'edit' => __( 'Edit', 'tainacan' ),
'settings' => __( 'Settings', 'tainacan' ), 'settings' => __( 'Settings', 'tainacan' ),
'new' => __( 'New', 'tainacan' ), 'new' => __( 'New', 'tainacan' ),
'add' => __( 'Add', 'tainacan' ), 'add_value' => __( 'Add value', 'tainacan' ),
'import' => __( 'Import', 'tainacan' ), 'import' => __( 'Import', 'tainacan' ),
'export' => __( 'Export', 'tainacan' ), 'export' => __( 'Export', 'tainacan' ),
'cancel' => __( 'Cancel', 'tainacan' ), 'cancel' => __( 'Cancel', 'tainacan' ),
'remove' => __( 'Remove', 'tainacan' ), 'remove_value' => __( 'Remove value', 'tainacan' ),
'save' => __( 'Save', 'tainacan' ), 'save' => __( 'Save', 'tainacan' ),
'next' => __( 'Next', 'tainacan' ), 'next' => __( 'Next', 'tainacan' ),
'back' => __( 'Back', 'tainacan' ), 'back' => __( 'Back', 'tainacan' ),
@ -66,9 +67,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'apply' => __( 'Apply', 'tainacan' ), 'apply' => __( 'Apply', 'tainacan' ),
'add_another_edition_criterion' => __( 'Add another edition criterion', 'tainacan' ), 'add_another_edition_criterion' => __( 'Add another edition criterion', 'tainacan' ),
'add_one_edition_criterion' => __( 'Add one edition criterion', 'tainacan' ), 'add_one_edition_criterion' => __( 'Add one edition criterion', 'tainacan' ),
'redefine' => __( 'Redefine', 'tainacan' ), 'set_new_value' => __( 'Set new value', 'tainacan' ),
'replace' => __( 'Replace', 'tainacan' ), 'replace_value' => __( 'Replace value', 'tainacan' ),
'conclude' => __( 'Conclude', 'tainacan' ), 'done' => __( 'Done', 'tainacan' ),
'select_to_create' => __( 'select to create', 'tainacan' ), 'select_to_create' => __( 'select to create', 'tainacan' ),
// Wordpress Status // Wordpress Status
@ -294,6 +295,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_hide_filters' => __( 'Hide filters menu', 'tainacan' ), 'label_hide_filters' => __( 'Hide filters menu', 'tainacan' ),
'label_show_filters' => __( 'Show filters menu', 'tainacan' ), 'label_show_filters' => __( 'Show filters menu', 'tainacan' ),
'label_select_all_items' => __( 'Select all items', 'tainacan' ), 'label_select_all_items' => __( 'Select all items', 'tainacan' ),
'label_select_all' => __( 'Select all', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders // Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -431,8 +433,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_editing_items_in_bulk' => __( 'Editing items in bulk', 'tainacan' ), 'info_editing_items_in_bulk' => __( 'Editing items in bulk', 'tainacan' ),
'info_by_inner' => __( 'by', 'tainacan' ), 'info_by_inner' => __( 'by', 'tainacan' ),
'info_items_selected' => __( 'items selected', 'tainacan' ), 'info_items_selected' => __( 'items selected', 'tainacan' ),
'info_items_edited' => __( 'items edited', 'tainacan' ), 'info_items_affected' => __( 'items affected', 'tainacan' ),
'info_item_edited' => __( 'item edited', 'tainacan'), 'info_item_affected' => __( 'item affected', 'tainacan'),
'info_no_parent_term_found' => __( 'No valid parent term was found with this name.', 'tainacan' ), 'info_no_parent_term_found' => __( 'No valid parent term was found with this name.', 'tainacan' ),
'info_warning_changing_parent_term' => __( 'Warning! Changing parent term will reload the terms list, thus uncheking any selection.', 'tainacan' ), 'info_warning_changing_parent_term' => __( 'Warning! Changing parent term will reload the terms list, thus uncheking any selection.', 'tainacan' ),

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<items-page <items-page
v-if="$root.collectionId != undefined && $root.collectionId != ''" v-if="$root.termId == undefined || $root.termId == ''"
class="theme-items-list" class="theme-items-list"
:enabled-view-modes="$root.enabledViewModes" :enabled-view-modes="$root.enabledViewModes"
:default-view-mode="$root.defaultViewMode" :default-view-mode="$root.defaultViewMode"

View File

@ -203,7 +203,20 @@ class REST_Collections_Controller extends REST_Controller {
$item_arr['total_items']['private'] = $total_items->private; $item_arr['total_items']['private'] = $total_items->private;
} }
return $item_arr; /**
* Use this filter to add additional post_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-collection-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_post_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr;
} }
return $item; return $item;

View File

@ -331,6 +331,19 @@ class REST_Filters_Controller extends REST_Controller {
$item_arr['filter_type_object'] = $item->get_filter_type_object() ? $item->get_filter_type_object()->_toArray() : $item->get_filter_type_object(); $item_arr['filter_type_object'] = $item->get_filter_type_object() ? $item->get_filter_type_object()->_toArray() : $item->get_filter_type_object();
/**
* Use this filter to add additional post_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-filter-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_post_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr; return $item_arr;
} }

View File

@ -183,6 +183,19 @@ class REST_Items_Controller extends REST_Controller {
$item_arr['url'] = get_permalink( $item_arr['id'] ); $item_arr['url'] = get_permalink( $item_arr['id'] );
$item_arr['exposer_urls'] = \Tainacan\Exposers\Exposers::get_exposer_urls(get_rest_url(null, "{$this->namespace}/{$this->rest_base}/{$item->get_id()}/")); $item_arr['exposer_urls'] = \Tainacan\Exposers\Exposers::get_exposer_urls(get_rest_url(null, "{$this->namespace}/{$this->rest_base}/{$item->get_id()}/"));
/**
* Use this filter to add additional post_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-item-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_post_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr; return $item_arr;
} }

View File

@ -321,6 +321,19 @@ class REST_Metadata_Controller extends REST_Controller {
$item_arr['enabled'] = $item->get_enabled_for_collection(); $item_arr['enabled'] = $item->get_enabled_for_collection();
} }
/**
* Use this filter to add additional post_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-metadatum-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_post_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr; return $item_arr;
} }

View File

@ -106,6 +106,19 @@ class REST_Taxonomies_Controller extends REST_Controller {
$item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter); $item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter);
} }
/**
* Use this filter to add additional post_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-taxonomy-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_post_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr; return $item_arr;
} }

View File

@ -277,6 +277,19 @@ class REST_Terms_Controller extends REST_Controller {
$item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter); $item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter);
} }
/**
* Use this filter to add additional term_meta to the api response
* Use the $request object to get the context of the request and other variables
* For example, id context is edit, you may want to add your meta or not.
*
* Also take care to do any permissions verification before exposing the data
*/
$extra_metadata = apply_filters('tainacan-api-response-term-meta', [], $request);
foreach ($extra_metadata as $extra_meta) {
$item_arr[$extra_meta] = get_term_meta($item_arr['id'], $extra_meta, true);
}
return $item_arr; return $item_arr;
} }

View File

@ -34,7 +34,8 @@ class Collection extends Entity {
$header_image_id, $header_image_id,
$header_image, $header_image,
$moderators_ids, $moderators_ids,
$comment_status; $comment_status,
$allow_comments;
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -501,6 +502,14 @@ class Collection extends Entity {
public function get_comment_status() { public function get_comment_status() {
return $this->get_mapped_property('comment_status'); return $this->get_mapped_property('comment_status');
} }
/**
* Checks if comments are allowed for the current Collection Items.
* @return bool
*/
public function get_allow_comments() {
return $this->get_mapped_property('allow_comments');
}
/** /**
* Set the collection name * Set the collection name
@ -702,6 +711,15 @@ class Collection extends Entity {
public function set_comment_status( $value ) { public function set_comment_status( $value ) {
$this->set_mapped_property('comment_status', $value); $this->set_mapped_property('comment_status', $value);
} }
/**
* Sets if comments are allowed for the current Collection Items.
*
* @param $value bool
*/
public function set_allow_comments( $value ) {
$this->set_mapped_property('allow_comments', $value );
}
// Moderators methods // Moderators methods

View File

@ -154,7 +154,7 @@ class Entity {
* @return mixed property value * @return mixed property value
*/ */
public function get_mapped_property($prop) { public function get_mapped_property($prop) {
if (isset($this->$prop) ){ if ( isset($this->$prop) ){
return $this->$prop; return $this->$prop;
} }

View File

@ -156,10 +156,10 @@
if(!isNaN(this.selected[0])){ if(!isNaN(this.selected[0])){
for (let option of this.options) { for (let option of this.options) {
let valueIndex = this.selected.findIndex(item => item == option.value); let value = this.selected.find(item => item == option.value);
if (valueIndex >= 0) { if (value != undefined) {
onlyLabels.push(this.options[valueIndex].label); onlyLabels.push(option.label);
} }
} }
} }

View File

@ -20,23 +20,20 @@
</div> </div>
<!-- Numeric --> <!-- Numeric -->
<div <div v-else>
class="columns"
v-else>
<b-input <b-input
size="is-small" size="is-small"
type="number" type="number"
step="any" step="any"
@input="validate_values()" @input="validate_values()"
class="column"
v-model="value_init"/> v-model="value_init"/>
<p class="is-size-7 has-text-centered is-marginless">{{ $i18n.get('label_until') }}</p>
<b-input <b-input
size="is-small" size="is-small"
type="number" type="number"
step="any" step="any"
@input="validate_values()" @input="validate_values()"
@focus="isTouched = true" @focus="isTouched = true"
class="column"
v-model="value_end"/> v-model="value_end"/>
</div> </div>
</div> </div>

View File

@ -145,7 +145,7 @@
padding: 0.2rem 0.1rem !important; padding: 0.2rem 0.1rem !important;
} }
} }
.select { .select {
select { select {
display: unset; display: unset;
@ -162,9 +162,6 @@
} }
} }
} }
.select:not(.is-loading)::after {
margin-top: -12px !important;
}
.collapse-trigger { .collapse-trigger {
margin-left: -5px; margin-left: -5px;

View File

@ -8,11 +8,10 @@
<b-checkbox <b-checkbox
v-model="selected" v-model="selected"
:native-value="option.id" :native-value="option.id"
v-if="!option.isChild"
>{{ option.name }}</b-checkbox> >{{ option.name }}</b-checkbox>
<div <div
class="see-more-container" class="see-more-container"
v-if="option.seeMoreLink" v-if="option.seeMoreLink && index == options.length-1"
@click="openCheckboxModal(option.parent)" @click="openCheckboxModal(option.parent)"
v-html="option.seeMoreLink"/> v-html="option.seeMoreLink"/>
</div> </div>
@ -35,7 +34,6 @@
let selectedOption = this.options.find(option => option.name == filterTag.singleValue); let selectedOption = this.options.find(option => option.name == filterTag.singleValue);
if(selectedOption) { if(selectedOption) {
let selectedIndex = this.selected.findIndex(option => option == selectedOption.id); let selectedIndex = this.selected.findIndex(option => option == selectedOption.id);
if (selectedIndex >= 0) { if (selectedIndex >= 0) {
@ -106,7 +104,6 @@
this.taxonomy = item.taxonomy; this.taxonomy = item.taxonomy;
this.options.push(item); this.options.push(item);
} }
}) })
.catch(error => { .catch(error => {
this.$console.log(error); this.$console.log(error);
@ -203,9 +200,9 @@
id: res.data.id id: res.data.id
}) })
}) })
.catch(error => { .catch(error => {
this.$console.log(error); this.$console.log(error);
}); });
} }
} }

View File

@ -199,9 +199,17 @@ class Collections extends Repository {
'map' => 'comment_status', 'map' => 'comment_status',
'title' => __( 'Comment Status', 'tainacan' ), 'title' => __( 'Comment Status', 'tainacan' ),
'type' => 'string', 'type' => 'string',
'description' => __( 'The status of collection comment, if is "open" the comments are allowed for collection items, or is "closed" for deny comments to items.', 'tainacan' ), 'description' => __( 'The status of collection comment, if is "open" the comments are allowed, or is "closed" for deny comments.', 'tainacan' ),
'default' => get_default_comment_status(Entities\Collection::get_post_type()), 'default' => get_default_comment_status(Entities\Collection::get_post_type()),
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )), 'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
],
'allow_comments' => [
'map' => 'meta',
'title' => __( 'Allow Items Comments', 'tainacan' ),
'type' => 'string',
'description' => __( 'Collection items comment is allowed, if is "open" the comments are allowed for collection items, or is "closed" for deny comments to items.', 'tainacan' ),
'default' => 'open',
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
] ]
] ); ] );

View File

@ -398,7 +398,7 @@ class Items extends Repository {
/** /**
* Get a default thumbnail ID from the item document. * Get a default thumbnail ID from the item document.
* *
* @param EntitiesItem $item The item * @param Entities\Item $item The item
* *
* @return int|null The thumbnail ID or null if it was not possible to find a thumbnail * @return int|null The thumbnail ID or null if it was not possible to find a thumbnail
*/ */
@ -491,7 +491,7 @@ class Items extends Repository {
if($item != false && $item instanceof Entities\Item) { if($item != false && $item instanceof Entities\Item) {
$collection = $item->get_collection(); $collection = $item->get_collection();
if($collection->get_comment_status() !== 'open' ) return false; if( $collection->get_allow_comments() !== 'open' ) return false;
} }
return $open_comment; return $open_comment;

View File

@ -1054,7 +1054,13 @@ class Metadata extends Repository {
} }
} }
return $this->unique_multidimensional_array( $results, 'mvalue' ); $spliced = $this->unique_multidimensional_array( $results, 'mvalue' );
if($number > 0 && count($spliced) > $number){
array_splice($spliced, (int) $number);
}
return $spliced;
} }
/** /**

View File

@ -131,6 +131,10 @@ $Tainacan_Embed = \Tainacan\Embed::get_instance();
require_once(__DIR__ . '/../admin/class-tainacan-admin.php'); require_once(__DIR__ . '/../admin/class-tainacan-admin.php');
$Tainacan_Admin = \Tainacan\Admin::get_instance(); $Tainacan_Admin = \Tainacan\Admin::get_instance();
require_once(__DIR__ . '/../admin/class-tainacan-admin-hooks.php');
require_once(__DIR__ . '/../admin/admin-hooks-functions.php');
$Tainacan_Admin_Hooks = \Tainacan\Admin_Hooks::get_instance();
require_once(__DIR__ . '/../theme-helper/class-tainacan-theme-helper.php'); require_once(__DIR__ . '/../theme-helper/class-tainacan-theme-helper.php');
require_once(__DIR__ . '/../theme-helper/template-tags.php'); require_once(__DIR__ . '/../theme-helper/template-tags.php');
$Tainacan_Theme_Helper = \Tainacan\Theme_Helper::get_instance(); $Tainacan_Theme_Helper = \Tainacan\Theme_Helper::get_instance();

View File

@ -297,7 +297,6 @@ export default {
this.$store.dispatch('search/set_postquery', this.$route.query); this.$store.dispatch('search/set_postquery', this.$route.query);
}, },
loadItems(to) { loadItems(to) {
this.$emit( 'isLoadingItems', true); this.$emit( 'isLoadingItems', true);
// Forces fetch_only to be filled before any search happens // Forces fetch_only to be filled before any search happens

View File

@ -3,7 +3,7 @@ import axios from '../../../axios/axios';
// Actions related to background processes // Actions related to background processes
export const fetchProcesses = ({ commit }, {page, processesPerPage}) => { export const fetchProcesses = ({ commit }, {page, processesPerPage}) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let endpoint = '/bg-processes?'; let endpoint = '/bg-processes?all_users=1';
if (page != undefined) if (page != undefined)
endpoint += 'paged=' + page; endpoint += 'paged=' + page;

View File

@ -174,6 +174,20 @@ export const fetchCollectionCommentStatus = ({ commit }, id) => {
}); });
}; };
export const fetchCollectionAllowComments = ({ commit }, id) => {
return new Promise((resolve, reject) =>{
axios.tainacan.get('/collections/' + id + '?fetch_only=allow_comments')
.then(res => {
let collectionAllowComments = res.data;
commit('setCollectionAllowComments', collectionAllowComments.allow_comments);
resolve( collectionAllowComments.allow_comments );
})
.catch(error => {
reject(error);
})
});
};
export const fetchCollectionNameAndURL = ({ commit }, id) => { export const fetchCollectionNameAndURL = ({ commit }, id) => {
//commit('cleanCollectionName'); //commit('cleanCollectionName');
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) =>{
@ -213,46 +227,11 @@ export const deleteCollection = ({ commit }, { collectionId, isPermanently }) =>
export const updateCollection = ({ commit }, { export const updateCollection = ({ commit }, {
collection_id, collection_id,
name, collection
description,
slug,
status,
enable_cover_page,
cover_page_id,
moderators_ids,
parent,
enabled_view_modes,
default_view_mode,
comment_status
}) => { }) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.patch('/collections/' + collection_id, { axios.tainacan.patch('/collections/' + collection_id, collection).then( res => {
name: name, commit('setCollection', collection);
description: description,
status: status,
slug: slug,
cover_page_id: "" + cover_page_id,
enable_cover_page: enable_cover_page,
moderators_ids: moderators_ids,
parent: parent,
enabled_view_modes: enabled_view_modes,
default_view_mode: default_view_mode,
comment_status: comment_status
}).then( res => {
commit('setCollection', {
id: collection_id,
name: name,
description: description,
slug: slug,
status: status,
enable_cover_page: enable_cover_page,
cover_page_id: cover_page_id,
moderators_ids: moderators_ids,
parent: parent,
enabled_view_modes: enabled_view_modes,
default_view_mode: default_view_mode,
comment_status: comment_status
});
commit('setCollectionName', res.data.name); commit('setCollectionName', res.data.name);
commit('setCollectionURL', res.data.url); commit('setCollectionURL', res.data.url);
resolve( res.data ); resolve( res.data );
@ -263,18 +242,16 @@ export const updateCollection = ({ commit }, {
}); });
}; };
export const sendCollection = ( { commit }, { name, description, status, mapper }) => { export const sendCollection = ( { commit }, collection) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
var param = { var param = collection;
name: name, param['mapper'] = null;
description: description, param[tainacan_plugin.exposer_mapper_param] = collection.mapper;
status: status,
};
param[tainacan_plugin.exposer_mapper_param] = mapper;
axios.tainacan.post('/collections/', param) axios.tainacan.post('/collections/', param)
.then( res => { .then( res => {
commit('setCollection', { name: name, description: description, status: status, mapper: mapper }); let collection = res.data;
resolve( res.data ); commit('setCollection', collection);
resolve( collection );
}) })
.catch(error => { .catch(error => {
reject( error.response ); reject( error.response );

View File

@ -28,4 +28,8 @@ export const getAttachments = state => {
export const getCollectionCommentStatus = state => { export const getCollectionCommentStatus = state => {
return state.collectionCommentStatus; return state.collectionCommentStatus;
}
export const getCollectionAllowComments = state => {
return state.collectionAllowComments;
} }

View File

@ -11,7 +11,8 @@ const state = {
collectionName: '', collectionName: '',
collectionURL: '', collectionURL: '',
attachments: [], attachments: [],
collectionCommentStatus: '' collectionCommentStatus: '',
collectionAllowComments: ''
}; };
export default { export default {

View File

@ -77,4 +77,12 @@ export const setCollectionCommentStatus = (state, collectionCommentStatus) => {
export const cleanCollectionCommentStatus = (state) => { export const cleanCollectionCommentStatus = (state) => {
state.collectionCommentStatus = ''; state.collectionCommentStatus = '';
}
export const setCollectionAllowComments = (state, collectionAllowComments) => {
state.collectionAllowComments = collectionAllowComments;
}
export const cleanCollectionAllowComments = (state) => {
state.collectionAllowComments = '';
} }

View File

@ -92,12 +92,9 @@ export const fetchItemTitle = ({ commit }, id) => {
}); });
} }
export const sendItem = ( { commit }, { collection_id, status, comment_status }) => { export const sendItem = ( { commit }, item) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.post('/collection/'+ collection_id + '/items/', { axios.tainacan.post('/collection/'+ item.collection_id + '/items/', item)
status: status,
comment_status: comment_status
})
.then( res => { .then( res => {
commit('setItem', res.data); commit('setItem', res.data);
commit('setLastUpdated'); commit('setLastUpdated');
@ -109,13 +106,10 @@ export const sendItem = ( { commit }, { collection_id, status, comment_status })
}); });
}; };
export const updateItem = ({ commit }, { item_id, status, comment_status }) => { export const updateItem = ({ commit }, item) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.patch('/items/' + item_id, { axios.tainacan.patch('/items/' + item.id, item).then( res => {
status: status,
comment_status: comment_status
}).then( res => {
commit('setItem', res.data); commit('setItem', res.data);
commit('setLastUpdated'); commit('setLastUpdated');
resolve( res.data ); resolve( res.data );

View File

@ -4,13 +4,7 @@ import qs from 'qs'
// TAXONOMIES // TAXONOMIES
export const createTaxonomy = ({commit}, taxonomy) => { export const createTaxonomy = ({commit}, taxonomy) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.post('/taxonomies', { axios.tainacan.post('/taxonomies', taxonomy)
name: taxonomy.name,
description: taxonomy.description,
status: taxonomy.status,
slug: taxonomy.slug,
allow_insert: taxonomy.allowInsert
})
.then( res => { .then( res => {
let taxonomy = res.data; let taxonomy = res.data;
commit('setTaxonomy', taxonomy); commit('setTaxonomy', taxonomy);
@ -39,18 +33,10 @@ export const deleteTaxonomy = ({ commit }, { taxonomyId, isPermanently }) => {
export const updateTaxonomy = ({ commit }, taxonomy) => { export const updateTaxonomy = ({ commit }, taxonomy) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.patch(`/taxonomies/${taxonomy.taxonomyId}`, { axios.tainacan.patch(`/taxonomies/${taxonomy.taxonomyId}`, taxonomy)
name: taxonomy.name,
description: taxonomy.description,
status: taxonomy.status,
slug: taxonomy.slug ? taxonomy.slug : '',
allow_insert: taxonomy.allowInsert
})
.then( res => { .then( res => {
let taxonomy = res.data; let taxonomy = res.data;
commit('setTaxonomy', taxonomy); commit('setTaxonomy', taxonomy);
resolve( taxonomy ); resolve( taxonomy );
}) })
.catch(error => { .catch(error => {
@ -239,18 +225,13 @@ export const fetchChildTerms = ({ commit }, { parentId, taxonomyId, fetchOnly, s
}); });
}; };
export const sendChildTerm = ({ commit }, { taxonomyId, name, description, parent, headerImageId }) => { export const sendChildTerm = ({ commit }, { taxonomyId, term }) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, { axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, term)
name: name,
description: description,
parent: parent,
header_image_id: headerImageId,
})
.then( res => { .then( res => {
let term = res.data; let newTerm = res.data;
commit('addChildTerm', {term: term, parent: parent }); commit('addChildTerm', {term: newTerm, parent: term.parent });
resolve( term ); resolve( newTerm );
}) })
.catch(error => { .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 });
@ -258,17 +239,12 @@ export const sendChildTerm = ({ commit }, { taxonomyId, name, description, paren
}); });
}; };
export const updateChildTerm = ({ commit }, { taxonomyId, termId, name, description, parent, headerImageId, oldParent }) => { export const updateChildTerm = ({ commit }, { taxonomyId, term }) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${termId}`, { axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${term.term_id}`, term)
name: name,
description: description,
parent: parent,
header_image_id: headerImageId,
})
.then( res => { .then( res => {
let term = res.data; let updatedTerm = res.data;
commit('updateChildTerm', { term: term, parent: parent, oldParent: oldParent }); commit('updateChildTerm', { term: updatedTerm, parent: updatedTerm.parent, oldParent: term.parent });
resolve( term ); resolve( term );
}) })
.catch(error => { .catch(error => {

View File

@ -279,6 +279,11 @@ class Migrations {
flush_rewrite_rules(false); flush_rewrite_rules(false);
} }
static function refresh_rewrite_rules_items() {
// needed after we added the /items rewrite rule
flush_rewrite_rules(false);
}
} }

View File

@ -49,6 +49,13 @@ class Theme_Helper {
add_filter('get_the_archive_title', array($this, 'filter_archive_title')); add_filter('get_the_archive_title', array($this, 'filter_archive_title'));
add_shortcode( 'tainacan-search', array($this, 'search_shortcode')); add_shortcode( 'tainacan-search', array($this, 'search_shortcode'));
add_action( 'generate_rewrite_rules', array( &$this, 'rewrite_rules' ), 10, 1 );
add_filter( 'query_vars', array( &$this, 'rewrite_rules_query_vars' ) );
add_filter( 'template_include', array( &$this, 'rewrite_rule_template_include' ) );
add_action( 'pre_get_posts', array($this, 'archive_repository_pre_get_posts'));
// TODO: fix the WP Title
// add_filter( 'wp_title', array($this, 'archive_repository_wp_title'), 10, 3);
$this->register_view_mode('table', [ $this->register_view_mode('table', [
'label' => __('Table', 'tainacan'), 'label' => __('Table', 'tainacan'),
@ -81,7 +88,7 @@ class Theme_Helper {
public function enqueue_scripts($force = false) { public function enqueue_scripts($force = false) {
global $TAINACAN_BASE_URL; global $TAINACAN_BASE_URL;
if ( $force || is_post_type_archive( \Tainacan\Repositories\Repository::get_collections_db_identifiers() ) || tainacan_get_term() ) { if ( $force || is_post_type_archive( \Tainacan\Repositories\Repository::get_collections_db_identifiers() ) || tainacan_get_term() || get_query_var('tainacan_repository_archive') == 1 ) {
//\Tainacan\Admin::get_instance()->add_admin_js(); //\Tainacan\Admin::get_instance()->add_admin_js();
wp_enqueue_script('tainacan-search', $TAINACAN_BASE_URL . '/assets/user_search-components.js' , [] , null, true); wp_enqueue_script('tainacan-search', $TAINACAN_BASE_URL . '/assets/user_search-components.js' , [] , null, true);
wp_localize_script('tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params()); wp_localize_script('tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params());
@ -112,7 +119,12 @@ class Theme_Helper {
if (in_array($current_post_type, $collections_post_types)) { if (in_array($current_post_type, $collections_post_types)) {
$title = sprintf( __( 'Collection: %s' ), post_type_archive_title( '', false ) ); $title = sprintf( __( 'Collection: %s' ), post_type_archive_title( '', false ) );
} }
} elseif (is_archive()) {
if (get_query_var('tainacan_repository_archive') == 1) {
$title = __( 'All items in repository', 'tainacan' );
}
} }
return $title; return $title;
} }
@ -323,6 +335,50 @@ class Theme_Helper {
return "<div id='tainacan-items-page' $params ></div>"; return "<div id='tainacan-items-page' $params ></div>";
}
function rewrite_rules( &$wp_rewrite ) {
/* Translators: The Items slug - will be the URL for the repository archive */
$items_base = sanitize_title(_x('items', 'Slug: the string that will be used to build the URL to list all items of the repository', 'tainacan'));
$new_rules = array(
$items_base . "/?$" => "index.php?tainacan_repository_archive=1",
$items_base . "/page/([0-9]+)/?$" => 'index.php?tainacan_repository_archive=1&paged=$matches[1]'
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
function rewrite_rules_query_vars( $public_query_vars ) {
$public_query_vars[] = "tainacan_repository_archive";
return $public_query_vars;
}
function rewrite_rule_template_include( $template ) {
global $wp_query;
if ( $wp_query->get( 'tainacan_repository_archive' ) == 1 ) {
$templates = apply_filters('tainacan_repository_archive_template_hierarchy', ['tainacan/archive-repository.php', 'index.php']);
return locate_template($templates, false);
}
return $template;
}
function archive_repository_pre_get_posts($wp_query) {
if (!$wp_query->is_main_query() || $wp_query->get( 'tainacan_repository_archive' ) != 1)
return;
$wp_query->set( 'is_archive', true );
$wp_query->set( 'is_post_type_archive', false );
$wp_query->set( 'is_home', false );
$wp_query->is_home = false;
$wp_query->is_post_type_archive = false;
$wp_query->is_archive = true;
$wp_query->set( 'post_type', \Tainacan\Repositories\Repository::get_collections_db_identifiers() );
} }
/** /**

View File

@ -1,3 +1,4 @@
<?php <?php
use \Tainacan\Entities; use \Tainacan\Entities;
@ -181,7 +182,6 @@ function tainacan_the_collection_description() {
function tainacan_the_faceted_search() { function tainacan_the_faceted_search() {
$props = ' '; $props = ' ';
$id = '';
// if in a collection page // if in a collection page
$collection_id = tainacan_get_collection_id(); $collection_id = tainacan_get_collection_id();
@ -190,7 +190,6 @@ function tainacan_the_faceted_search() {
$collection = new \Tainacan\Entities\Collection($collection_id); $collection = new \Tainacan\Entities\Collection($collection_id);
$props .= 'default-view-mode="' . $collection->get_default_view_mode() . '" '; $props .= 'default-view-mode="' . $collection->get_default_view_mode() . '" ';
$props .= 'enabled-view-modes="' . implode(',', $collection->get_enabled_view_modes()) . '" '; $props .= 'enabled-view-modes="' . implode(',', $collection->get_enabled_view_modes()) . '" ';
$id = 'tainacan-items-page';
} }
// if in a tainacan taxonomy // if in a tainacan taxonomy
@ -198,10 +197,9 @@ function tainacan_the_faceted_search() {
if ($term) { if ($term) {
$props .= 'term-id="' . $term->term_id . '" '; $props .= 'term-id="' . $term->term_id . '" ';
$props .= 'taxonomy="' . $term->taxonomy . '" '; $props .= 'taxonomy="' . $term->taxonomy . '" ';
$id = 'tainacan-items-page';
} }
echo "<div id='$id' $props ></div>"; echo "<div id='tainacan-items-page' $props ></div>";
} }

View File

@ -279,7 +279,7 @@ class Items extends TAINACAN_UnitTestCase {
'collection', 'collection',
array( array(
'name' => 'collectionComments', 'name' => 'collectionComments',
'comment_status' => 'closed' 'allow_comments' => 'closed'
), ),
true, true,
true true
@ -303,8 +303,8 @@ class Items extends TAINACAN_UnitTestCase {
$this->assertFalse(comments_open($item->get_id())); $this->assertFalse(comments_open($item->get_id()));
$collections = \Tainacan\Repositories\Collections::get_instance(); $collections = \Tainacan\Repositories\Collections::get_instance();
$collection->set('comment_status', 'open'); $collection->set('allow_comments', 'open');
$collection->validate(); $this->assertTrue($collection->validate());
$collections->update($collection); $collections->update($collection);
$this->assertTrue(comments_open($item->get_id())); $this->assertTrue(comments_open($item->get_id()));
@ -312,7 +312,7 @@ class Items extends TAINACAN_UnitTestCase {
$items = \Tainacan\Repositories\Items::get_instance(); $items = \Tainacan\Repositories\Items::get_instance();
$item->set('comment_status', 'closed'); $item->set('comment_status', 'closed');
$item->validate(); $this->assertTrue($item->validate());
$items->update($item); $items->update($item);
$this->assertFalse(comments_open($item->get_id())); $this->assertFalse(comments_open($item->get_id()));