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
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/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-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.
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:

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:
* 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
## 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

@ -205,6 +205,8 @@ class Admin {
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
}
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
return $settings;
}

View File

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

View File

@ -27,6 +27,15 @@
@blur="updateSlug"
@focus="clearErrors('name')"/>
</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 -------------------------------- -->
<b-field :addons="false">
@ -216,11 +225,23 @@
size="is-small"
true-value="open"
false-value="closed"
v-model="form.comment_status" />
v-model="form.allow_comments" />
<help-button
:title="$i18n.getHelperTitle('collections', 'comment_status')"
:message="$i18n.getHelperMessage('collections', 'comment_status')"/>
:title="$i18n.getHelperTitle('collections', 'allow_comments')"
:message="$i18n.getHelperMessage('collections', 'allow_comments')"/>
</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 class="column is-1" />
<div class="column">
@ -285,6 +306,16 @@
</div>
</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 -------------------------------- -->
<b-field
:addons="false"
@ -385,7 +416,18 @@
v-model="form.slug"
@focus="clearErrors('slug')"/>
</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>
<!-- Form submit -------------------------------- -->
@ -418,11 +460,11 @@ import { mapActions } from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames';
import FileItem from '../other/file-item.vue';
import EyeIcon from '../other/eye-icon.vue';
import { wpAjax } from '../../js/mixins';
import { wpAjax, formHooks } from '../../js/mixins';
export default {
name: 'CollectionEditionForm',
mixins: [ wpAjax ],
mixins: [ wpAjax, formHooks ],
data(){
return {
collectionId: Number,
@ -440,7 +482,7 @@ export default {
moderators_ids: [],
enabled_view_modes: [],
default_view_mode: [],
comment_status: ''
allow_comments: ''
},
thumbnail: {},
cover: {},
@ -481,7 +523,7 @@ export default {
viewModesList: [],
fromImporter: '',
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
isUpdatingSlug: false,
isUpdatingSlug: false
}
},
components: {
@ -526,8 +568,8 @@ export default {
});
}, 500),
onSubmit() {
this.isLoading = true;
this.isLoading = true;
this.form.moderators_ids = [];
for (let moderator of this.moderators)
this.form.moderators_ids.push(moderator.id);
@ -544,12 +586,18 @@ export default {
parent: this.form.parent,
enabled_view_modes: this.form.enabled_view_modes,
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;
// Fills hook forms with it's real values
this.updateExtraFormData('collection', this.collection);
// Fill this.form data with current data.
this.form.name = this.collection.name;
this.form.slug = this.collection.slug;
@ -559,7 +607,7 @@ export default {
this.form.enable_cover_page = this.collection.enable_cover_page;
this.form.enabled_view_modes = this.collection.enabled_view_modes;
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.formErrorMessage = '';
@ -586,6 +634,8 @@ export default {
// Creates draft Collection
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.collectionId = res.id;
@ -604,7 +654,7 @@ export default {
this.form.default_view_mode = this.collection.default_view_mode;
this.form.enabled_view_modes = [];
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
this.form.status = 'publish';
@ -758,7 +808,7 @@ export default {
}
}
},
created(){
mounted(){
if (this.$route.query.fromImporter != undefined)
this.fromImporter = this.$route.query.fromImporter;
@ -779,6 +829,12 @@ export default {
// Initializes Media Frames now that collectonId exists
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.
this.form.name = this.collection.name;
@ -791,7 +847,7 @@ export default {
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.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
if (this.form.cover_page_id != undefined && this.form.cover_page_id != '') {

View File

@ -3,6 +3,7 @@
id="filterEditForm"
class="tainacan-form"
@submit.prevent="saveEdition(editForm)">
<b-field
:addons="false"
:type="formErrors['name'] != undefined ? 'is-danger' : ''"
@ -22,6 +23,16 @@
@focus="clearErrors('name')"/>
</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
:addons="false"
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
@ -136,6 +147,16 @@
v-html="editForm.edit_form"
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="control">
<button
@ -156,9 +177,11 @@
<script>
import { mapActions } from 'vuex';
import { formHooks } from "../../js/mixins";
export default {
name: 'FilterEditionForm',
mixins: [ formHooks ],
data(){
return {
editForm: {},
@ -182,6 +205,13 @@ export default {
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() {
if (this.closedByForm) {
this.editedFilter.saved = true;
@ -201,6 +231,7 @@ export default {
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})
.then(() => {
this.editForm = {};
@ -229,6 +260,7 @@ export default {
formObj[key] = value;
}
this.fillExtraFormData(formObj, 'filter');
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj})
.then(() => {
this.editForm = {};
@ -265,7 +297,7 @@ export default {
@import "../../scss/_variables.scss";
form {
form#filterEditForm {
padding: 1.0em 2.0em;
border-top: 1px solid $gray2;
border-bottom: 1px solid $gray2;

View File

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

View File

@ -24,6 +24,16 @@
@focus="clearErrors('name')"/>
</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
:addons="false"
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
@ -206,6 +216,16 @@
v-html="editForm.edit_form"
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="control">
<button
@ -228,9 +248,11 @@
<script>
import {mapActions} from 'vuex';
import { formHooks } from "../../js/mixins";
export default {
name: 'MetadatumEditionForm',
mixins: [ formHooks ],
data() {
return {
editForm: {},
@ -257,6 +279,13 @@
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() {
if (this.closedByForm) {
this.editedMetadatum.saved = true;
@ -276,6 +305,7 @@
if ((metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') {
this.fillExtraFormData(this.editForm, 'metadatum');
this.updateMetadatum({
collectionId: this.collectionId,
metadatumId: metadatum.id,
@ -309,6 +339,7 @@
for (let [key, value] of formData.entries())
formObj[key] = value;
this.fillExtraFormData(formObj, 'metadatum');
this.updateMetadatum({
collectionId: this.collectionId,
metadatumId: metadatum.id,

View File

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

View File

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

View File

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

View File

@ -6,14 +6,19 @@
<span>
<b-checkbox
@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 v-if="allItemsOnPageSelected">
<span
style="margin-left: 10px"
v-if="allItemsOnPageSelected && items.length > 1">
<b-checkbox
@click.native="selectAllItems()"
v-model="isAllItemsSelected">{{ $i18n.get('label_select_all_items') }}</b-checkbox>
<small v-if="isAllItemsSelected">{{ `(${ totalItems } ${ $i18n.get('info_items_selected') })` }}</small>
v-model="isAllItemsSelected">
{{ `${$i18n.get('label_select_all')} ${totalItems} ${$i18n.get('items').toLowerCase()}` }}
</b-checkbox>
</span>
</div>
<div class="field is-pulled-right">
@ -30,15 +35,16 @@
<b-icon icon="menu-down"/>
</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
@click="deleteSelectedItems()"
id="item-delete-selected-items">
{{ isOnTrash ? $i18n.get('label_delete_permanently') : $i18n.get('label_send_to_trash') }}
</b-dropdown-item>
<b-dropdown-item
@click="openBulkEditionModal()">
{{ $i18n.get('label_edit_selected_items') }}
</b-dropdown-item>
</b-dropdown>
</div>
</div>
@ -624,7 +630,6 @@ export default {
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),
objectType: this.$i18n.get('items'),
metadata: this.tableMetadata,
collectionID: this.$route.params.collectionId,
},
width: 'calc(100% - 8.333333333%)',

View File

@ -79,7 +79,8 @@
<div
v-if="searchQuery == undefined || searchQuery == ''"
v-for="(term, index) in localTerms"
:key="term.id">
:key="term.id"
class="parent-term">
<recursive-term-item
:term="term"
@ -112,9 +113,7 @@
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
<taxonomies-icon class="taxonomies-term-icon"/>
</p>
<p>{{ $i18n.get('info_no_terms_created_on_taxonomy') }}</p>
<button
@ -134,6 +133,7 @@ import { mapActions, mapGetters } from 'vuex';
import TermEditionForm from '../edition/term-edition-form.vue';
import RecursiveTermItem from './recursive-term-item.vue'
import BasicTermItem from './basic-term-item.vue'
import TaxonomiesIcon from '../other/taxonomies-icon.vue';
import t from 't';
export default {
@ -180,7 +180,8 @@ export default {
components: {
RecursiveTermItem,
BasicTermItem,
TermEditionForm
TermEditionForm,
TaxonomiesIcon
},
methods: {
...mapActions('taxonomy', [
@ -346,6 +347,7 @@ export default {
this.deleteTerm({taxonomyId: this.taxonomyId, termId: term.id })
.then(() => {
this.searchTerms(this.offset);
this.totalTerms--;
})
.catch((error) => {
this.$console.log(error);
@ -391,7 +393,10 @@ export default {
</script>
<style lang="scss">
.taxonomies-term-icon {
height: 24px;
width: 24px;
}
@import "../../scss/_variables.scss";
.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 {
font-size: 0.875rem;
margin: 0;

View File

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

View File

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

View File

@ -47,3 +47,79 @@ export const dateInter = {
}
}
};
// 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),
beforeMount () {
if (this.$el.attributes['collection-id'] != undefined)
this.collectionId = this.$el.attributes['collection-id'].value;
if (this.$el.attributes['default-view-mode'] != undefined)

View File

@ -76,9 +76,7 @@
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
<b-icon icon="folder-multiple"/>
</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>

View File

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

View File

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

View File

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

View File

@ -560,9 +560,7 @@
class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
<b-icon icon="file-multiple"/>
</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>

View File

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

View File

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

View File

@ -33,14 +33,15 @@ return apply_filters( 'tainacan-admin-i18n', [
'processes' => __( 'Processes', 'tainacan' ),
// Actions
'close' => __( 'Close', 'tainacan' ),
'edit' => __( 'Edit', 'tainacan' ),
'settings' => __( 'Settings', 'tainacan' ),
'new' => __( 'New', 'tainacan' ),
'add' => __( 'Add', 'tainacan' ),
'add_value' => __( 'Add value', 'tainacan' ),
'import' => __( 'Import', 'tainacan' ),
'export' => __( 'Export', 'tainacan' ),
'cancel' => __( 'Cancel', 'tainacan' ),
'remove' => __( 'Remove', 'tainacan' ),
'remove_value' => __( 'Remove value', 'tainacan' ),
'save' => __( 'Save', 'tainacan' ),
'next' => __( 'Next', 'tainacan' ),
'back' => __( 'Back', 'tainacan' ),
@ -66,9 +67,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'apply' => __( 'Apply', 'tainacan' ),
'add_another_edition_criterion' => __( 'Add another edition criterion', 'tainacan' ),
'add_one_edition_criterion' => __( 'Add one edition criterion', 'tainacan' ),
'redefine' => __( 'Redefine', 'tainacan' ),
'replace' => __( 'Replace', 'tainacan' ),
'conclude' => __( 'Conclude', 'tainacan' ),
'set_new_value' => __( 'Set new value', 'tainacan' ),
'replace_value' => __( 'Replace value', 'tainacan' ),
'done' => __( 'Done', 'tainacan' ),
'select_to_create' => __( 'select to create', 'tainacan' ),
// Wordpress Status
@ -294,6 +295,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_hide_filters' => __( 'Hide filters menu', 'tainacan' ),
'label_show_filters' => __( 'Show filters menu', 'tainacan' ),
'label_select_all_items' => __( 'Select all items', 'tainacan' ),
'label_select_all' => __( 'Select all', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'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_by_inner' => __( 'by', 'tainacan' ),
'info_items_selected' => __( 'items selected', 'tainacan' ),
'info_items_edited' => __( 'items edited', 'tainacan' ),
'info_item_edited' => __( 'item edited', 'tainacan'),
'info_items_affected' => __( 'items affected', 'tainacan' ),
'info_item_affected' => __( 'item affected', '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' ),

View File

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

View File

@ -203,6 +203,19 @@ class REST_Collections_Controller extends REST_Controller {
$item_arr['total_items']['private'] = $total_items->private;
}
/**
* 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;
}

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();
/**
* 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;
}

View File

@ -183,6 +183,19 @@ class REST_Items_Controller extends REST_Controller {
$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()}/"));
/**
* 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;
}

View File

@ -321,6 +321,19 @@ class REST_Metadata_Controller extends REST_Controller {
$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;
}

View File

@ -106,6 +106,19 @@ class REST_Taxonomies_Controller extends REST_Controller {
$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;
}

View File

@ -277,6 +277,19 @@ class REST_Terms_Controller extends REST_Controller {
$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;
}

View File

@ -34,7 +34,8 @@ class Collection extends Entity {
$header_image_id,
$header_image,
$moderators_ids,
$comment_status;
$comment_status,
$allow_comments;
/**
* {@inheritDoc}
@ -502,6 +503,14 @@ class Collection extends Entity {
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
*
@ -703,6 +712,15 @@ class Collection extends Entity {
$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
/**

View File

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

View File

@ -156,10 +156,10 @@
if(!isNaN(this.selected[0])){
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) {
onlyLabels.push(this.options[valueIndex].label);
if (value != undefined) {
onlyLabels.push(option.label);
}
}
}

View File

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

View File

@ -162,9 +162,6 @@
}
}
}
.select:not(.is-loading)::after {
margin-top: -12px !important;
}
.collapse-trigger {
margin-left: -5px;

View File

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

View File

@ -199,9 +199,17 @@ class Collections extends Repository {
'map' => 'comment_status',
'title' => __( 'Comment Status', 'tainacan' ),
'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()),
'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.
*
* @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
*/
@ -491,7 +491,7 @@ class Items extends Repository {
if($item != false && $item instanceof Entities\Item) {
$collection = $item->get_collection();
if($collection->get_comment_status() !== 'open' ) return false;
if( $collection->get_allow_comments() !== 'open' ) return false;
}
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');
$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/template-tags.php');
$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);
},
loadItems(to) {
this.$emit( 'isLoadingItems', true);
// 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
export const fetchProcesses = ({ commit }, {page, processesPerPage}) => {
return new Promise((resolve, reject) => {
let endpoint = '/bg-processes?';
let endpoint = '/bg-processes?all_users=1';
if (page != undefined)
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) => {
//commit('cleanCollectionName');
return new Promise((resolve, reject) =>{
@ -213,46 +227,11 @@ export const deleteCollection = ({ commit }, { collectionId, isPermanently }) =>
export const updateCollection = ({ commit }, {
collection_id,
name,
description,
slug,
status,
enable_cover_page,
cover_page_id,
moderators_ids,
parent,
enabled_view_modes,
default_view_mode,
comment_status
collection
}) => {
return new Promise((resolve, reject) => {
axios.tainacan.patch('/collections/' + collection_id, {
name: name,
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
});
axios.tainacan.patch('/collections/' + collection_id, collection).then( res => {
commit('setCollection', collection);
commit('setCollectionName', res.data.name);
commit('setCollectionURL', res.data.url);
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 ) => {
var param = {
name: name,
description: description,
status: status,
};
param[tainacan_plugin.exposer_mapper_param] = mapper;
var param = collection;
param['mapper'] = null;
param[tainacan_plugin.exposer_mapper_param] = collection.mapper;
axios.tainacan.post('/collections/', param)
.then( res => {
commit('setCollection', { name: name, description: description, status: status, mapper: mapper });
resolve( res.data );
let collection = res.data;
commit('setCollection', collection);
resolve( collection );
})
.catch(error => {
reject( error.response );

View File

@ -29,3 +29,7 @@ export const getAttachments = state => {
export const getCollectionCommentStatus = state => {
return state.collectionCommentStatus;
}
export const getCollectionAllowComments = state => {
return state.collectionAllowComments;
}

View File

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

View File

@ -78,3 +78,11 @@ export const setCollectionCommentStatus = (state, collectionCommentStatus) => {
export const cleanCollectionCommentStatus = (state) => {
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 ) => {
axios.tainacan.post('/collection/'+ collection_id + '/items/', {
status: status,
comment_status: comment_status
})
axios.tainacan.post('/collection/'+ item.collection_id + '/items/', item)
.then( res => {
commit('setItem', res.data);
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) => {
axios.tainacan.patch('/items/' + item_id, {
status: status,
comment_status: comment_status
}).then( res => {
axios.tainacan.patch('/items/' + item.id, item).then( res => {
commit('setItem', res.data);
commit('setLastUpdated');
resolve( res.data );

View File

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

View File

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

View File

@ -50,6 +50,13 @@ class Theme_Helper {
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', [
'label' => __('Table', 'tainacan'),
'dynamic_metadata' => true,
@ -81,7 +88,7 @@ class Theme_Helper {
public function enqueue_scripts($force = false) {
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();
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());
@ -112,7 +119,12 @@ class Theme_Helper {
if (in_array($current_post_type, $collections_post_types)) {
$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;
}
@ -325,6 +337,50 @@ class Theme_Helper {
}
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() );
}
/**
* Register a new View Mode
*

View File

@ -1,3 +1,4 @@
<?php
use \Tainacan\Entities;
@ -181,7 +182,6 @@ function tainacan_the_collection_description() {
function tainacan_the_faceted_search() {
$props = ' ';
$id = '';
// if in a collection page
$collection_id = tainacan_get_collection_id();
@ -190,7 +190,6 @@ function tainacan_the_faceted_search() {
$collection = new \Tainacan\Entities\Collection($collection_id);
$props .= 'default-view-mode="' . $collection->get_default_view_mode() . '" ';
$props .= 'enabled-view-modes="' . implode(',', $collection->get_enabled_view_modes()) . '" ';
$id = 'tainacan-items-page';
}
// if in a tainacan taxonomy
@ -198,10 +197,9 @@ function tainacan_the_faceted_search() {
if ($term) {
$props .= 'term-id="' . $term->term_id . '" ';
$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',
array(
'name' => 'collectionComments',
'comment_status' => 'closed'
'allow_comments' => 'closed'
),
true,
true
@ -303,8 +303,8 @@ class Items extends TAINACAN_UnitTestCase {
$this->assertFalse(comments_open($item->get_id()));
$collections = \Tainacan\Repositories\Collections::get_instance();
$collection->set('comment_status', 'open');
$collection->validate();
$collection->set('allow_comments', 'open');
$this->assertTrue($collection->validate());
$collections->update($collection);
$this->assertTrue(comments_open($item->get_id()));
@ -312,7 +312,7 @@ class Items extends TAINACAN_UnitTestCase {
$items = \Tainacan\Repositories\Items::get_instance();
$item->set('comment_status', 'closed');
$item->validate();
$this->assertTrue($item->validate());
$items->update($item);
$this->assertFalse(comments_open($item->get_id()));