Merge develop
This commit is contained in:
parent
11c23c29ea
commit
c34a7776b6
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
|
@ -9,11 +9,11 @@
|
|||
"dependencies": {
|
||||
"@brainhubeu/react-carousel": "^1.10.1",
|
||||
"axios": "^0.18.0",
|
||||
"buefy": "^0.6.7",
|
||||
"bulma": "^0.7.1",
|
||||
"buefy": "^0.7.0",
|
||||
"bulma": "^0.7.2",
|
||||
"mdi": "^2.2.43",
|
||||
"moment": "^2.22.2",
|
||||
"node-sass": "^4.9.3",
|
||||
"node-sass": "^4.9.4",
|
||||
"qs": "^6.5.2",
|
||||
"react": "^16.5.2",
|
||||
"react-dom": "^16.5.2",
|
||||
|
@ -24,32 +24,36 @@
|
|||
"vue-masonry-css": "^1.0.3",
|
||||
"vue-router": "^3.0.1",
|
||||
"vue-the-mask": "^0.11.1",
|
||||
"vue2-hammer": "^2.0.1",
|
||||
"vuedraggable": "^2.16.0",
|
||||
"vuex": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.0",
|
||||
"@babel/core": "^7.1.2",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
<<<<<<< HEAD
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"autoprefixer": "^9.1.5",
|
||||
"babel-loader": "^8.0.2",
|
||||
=======
|
||||
"autoprefixer": "^9.2.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
>>>>>>> develop
|
||||
"cross-env": "^5.2.0",
|
||||
"css-loader": "^1.0.0",
|
||||
"element-theme-chalk": "^2.4.7",
|
||||
"eslint": "^5.6.0",
|
||||
"element-theme-chalk": "^2.4.8",
|
||||
"eslint": "^5.7.0",
|
||||
"eslint-loader": "^2.1.1",
|
||||
"eslint-plugin-vue": "^4.7.1",
|
||||
"file-loader": "^2.0.0",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"uglifyjs-webpack-plugin": "^2.0.1",
|
||||
"vue-custom-element": "^3.2.5",
|
||||
"vue-custom-element": "^3.2.6",
|
||||
"vue-loader": "^15.4.2",
|
||||
"vue-template-compiler": "^2.5.17",
|
||||
"webpack": "^4.20.2",
|
||||
"webpack-cli": "^3.1.1",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.1.9"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -638,6 +638,9 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('metadatumUpdated');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -298,13 +298,6 @@ export default {
|
|||
|
||||
@import "../../scss/_variables.scss";
|
||||
|
||||
form#filterEditForm {
|
||||
padding: 1.0em 2.0em;
|
||||
border-top: 1px solid $gray2;
|
||||
border-bottom: 1px solid $gray2;
|
||||
margin-top: 1.0em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="isLoading"
|
||||
:can-cancel="false"/>
|
||||
<button
|
||||
|
@ -18,6 +19,9 @@
|
|||
</a>
|
||||
<hr>
|
||||
</div>
|
||||
<transition
|
||||
mode="out-in"
|
||||
:name="isOnSequenceEdit && sequenceRightDirection != undefined ? (sequenceRightDirection ? 'page-right' : 'page-left') : ''">
|
||||
<form
|
||||
v-if="!isLoading"
|
||||
class="tainacan-form"
|
||||
|
@ -407,9 +411,26 @@
|
|||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
|
||||
</form>
|
||||
</transition>
|
||||
<footer class="footer">
|
||||
<!-- Sequence Progress -->
|
||||
<div
|
||||
v-if="isOnSequenceEdit"
|
||||
class="sequence-progress-background"/>
|
||||
<div
|
||||
v-if="isOnSequenceEdit && itemPosition != undefined && group != null && group.items_count != undefined"
|
||||
:style="{ width: (itemPosition/group.items_count)*100 + '%' }"
|
||||
class="sequence-progress"/>
|
||||
|
||||
<!-- Last Updated Info -->
|
||||
<div class="update-info-section">
|
||||
<p
|
||||
class="has-text-gray5"
|
||||
v-if="isOnSequenceEdit">
|
||||
{{ $i18n.get('label_sequence_editing_item') + " " + itemPosition + " " + $i18n.get('info_of') + " " + ((group != null && group.items_count != undefined) ? group.items_count : '') + "." }}
|
||||
</p>
|
||||
<p v-if="!isUpdatingValues">
|
||||
{{ ($i18n.get('info_updated_at') + ' ' + lastUpdated) }}
|
||||
<span class="help is-danger">{{ formErrorMessage }}</span>
|
||||
|
@ -420,11 +441,20 @@
|
|||
<b-icon icon="autorenew" />{{ $i18n.get('info_updating_metadata_values') }}
|
||||
<span class="help is-danger">{{ formErrorMessage }}</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div
|
||||
class="form-submission-footer"
|
||||
v-if="form.status == 'trash'">
|
||||
<button
|
||||
v-if="isOnSequenceEdit && itemPosition > 1"
|
||||
@click="onPrevInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-left"/>
|
||||
</span>
|
||||
<span>{{ $i18n.get('previous') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="onDeletePermanently()"
|
||||
type="button"
|
||||
|
@ -437,10 +467,30 @@
|
|||
@click="onSubmit(visibility)"
|
||||
type="button"
|
||||
class="button is-success">{{ $i18n.get('label_publish') }}</button>
|
||||
<button
|
||||
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count > itemPosition)"
|
||||
@click="onNextInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span>{{ $i18n.get('next') }}</span>
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-right"/>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="form-submission-footer"
|
||||
v-if="form.status == 'auto-draft' || form.status == 'draft' || form.status == undefined">
|
||||
<button
|
||||
v-if="isOnSequenceEdit && itemPosition > 1"
|
||||
@click="onPrevInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-left"/>
|
||||
</span>
|
||||
<span>{{ $i18n.get('previous') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="form.status == 'draft'"
|
||||
@click="onSubmit('trash')"
|
||||
|
@ -459,10 +509,30 @@
|
|||
@click="onSubmit(visibility)"
|
||||
type="button"
|
||||
class="button is-success">{{ $i18n.get('label_publish') }}</button>
|
||||
<button
|
||||
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count > itemPosition)"
|
||||
@click="onNextInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span>{{ $i18n.get('next') }}</span>
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-right"/>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="form-submission-footer"
|
||||
v-if="form.status == 'publish' || form.status == 'private'">
|
||||
<button
|
||||
v-if="isOnSequenceEdit && itemPosition > 1"
|
||||
@click="onPrevInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-left"/>
|
||||
</span>
|
||||
<span>{{ $i18n.get('previous') }}</span>
|
||||
</button>
|
||||
<button
|
||||
@click="onSubmit('trash')"
|
||||
type="button"
|
||||
|
@ -475,10 +545,19 @@
|
|||
:disabled="formErrorMessage != undefined && formErrorMessage != ''"
|
||||
@click="onSubmit(visibility)"
|
||||
type="button"
|
||||
class="button is-secondary">{{ $i18n.get('label_update') }}</button>
|
||||
class="button is-success">{{ $i18n.get('label_update') }}</button>
|
||||
<button
|
||||
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count > itemPosition)"
|
||||
@click="onNextInSequence()"
|
||||
type="button"
|
||||
class="button sequence-button">
|
||||
<span>{{ $i18n.get('next') }}</span>
|
||||
<span class="icon is-large">
|
||||
<i class="mdi mdi-24px mdi-chevron-right"/>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -500,7 +579,11 @@ export default {
|
|||
itemId: Number,
|
||||
item: {},
|
||||
collectionId: Number,
|
||||
sequenceId: Number,
|
||||
itemPosition: Number,
|
||||
isCreatingNewItem: false,
|
||||
isOnSequenceEdit: false,
|
||||
sequenceRightDirection: false,
|
||||
isLoading: false,
|
||||
isMetadataColumnCompressed: false,
|
||||
metadatumCollapses: [],
|
||||
|
@ -552,12 +635,51 @@ export default {
|
|||
},
|
||||
lastUpdated() {
|
||||
return this.getLastUpdated();
|
||||
},
|
||||
group() {
|
||||
return this.getGroup();
|
||||
},
|
||||
itemIdInSequence() {
|
||||
return this.getItemIdInSequence();
|
||||
}
|
||||
},
|
||||
components: {
|
||||
FileItem,
|
||||
DocumentItem
|
||||
},
|
||||
watch: {
|
||||
'$route.params.itemPosition'(newItemPosition, oldItemPosition) {
|
||||
if (oldItemPosition == undefined)
|
||||
this.sequenceRightDirection;
|
||||
else if (oldItemPosition == newItemPosition)
|
||||
this.sequenceRightDirection = undefined;
|
||||
|
||||
this.itemPosition = Number(newItemPosition);
|
||||
|
||||
// Saves current itemPosition to user prefs
|
||||
this.$userPrefs.set('sequence_' + this.sequenceId + '_position', this.itemPosition);
|
||||
|
||||
// Clear form variables
|
||||
this.cleanMetadata();
|
||||
eventBus.clearAllErrors();
|
||||
this.formErrorMessage = '';
|
||||
|
||||
this.isLoading = true;
|
||||
|
||||
// Obtains current Item ID from Sequence
|
||||
this.fetchItemIdInSequence({ collectionId: this.collectionId, sequenceId: this.sequenceId, itemPosition: this.itemPosition })
|
||||
.then(() => {
|
||||
this.itemId = this.itemIdInSequence;
|
||||
this.loadExistingItem();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
|
||||
// Obtains current Sequence Group Info
|
||||
this.fetchGroup({ collectionId: this.collectionId, groupId: this.sequenceId });
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('item', [
|
||||
'sendItem',
|
||||
|
@ -583,6 +705,14 @@ export default {
|
|||
'fetchCollectionAllowComments',
|
||||
'deleteItem',
|
||||
]),
|
||||
...mapActions('bulkedition', [
|
||||
'fetchItemIdInSequence',
|
||||
'fetchGroup'
|
||||
]),
|
||||
...mapGetters('bulkedition', [
|
||||
'getItemIdInSequence',
|
||||
'getGroup'
|
||||
]),
|
||||
onSubmit(status) {
|
||||
// Puts loading on Item edition
|
||||
this.isLoading = true;
|
||||
|
@ -607,10 +737,12 @@ export default {
|
|||
|
||||
this.isLoading = false;
|
||||
|
||||
if (!this.isOnSequenceEdit) {
|
||||
if (this.form.status != 'trash')
|
||||
this.$router.push(this.$routerHelper.getItemPath(this.form.collectionId, this.itemId));
|
||||
else
|
||||
this.$router.push(this.$routerHelper.getCollectionPath(this.form.collectionId));
|
||||
}
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
|
@ -831,30 +963,13 @@ export default {
|
|||
title: this.$i18n.get('label_warning'),
|
||||
message: this.isOnTrash ? this.$i18n.get('info_warning_item_delete') : this.$i18n.get('info_warning_item_trash'),
|
||||
onConfirm: () => {
|
||||
this.deleteItem({ itemId: this.itemId, isPermanently: true })
|
||||
this.deleteItem({ itemId: this.itemId, isPermanently: true });
|
||||
this.$router.push(this.$routerHelper.getCollectionPath(this.form.collectionId))
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
created(){
|
||||
// Obtains collection ID
|
||||
this.cleanMetadata();
|
||||
eventBus.clearAllErrors();
|
||||
this.formErrorMessage = '';
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
this.form.collectionId = this.collectionId;
|
||||
|
||||
if (this.$route.fullPath.split("/").pop() == "new") {
|
||||
this.isCreatingNewItem = true;
|
||||
this.createNewItem();
|
||||
} else if (this.$route.fullPath.split("/").pop() == "edit") {
|
||||
this.isLoading = true;
|
||||
|
||||
// Obtains current Item ID from URL
|
||||
this.itemId = this.$route.params.itemId;
|
||||
|
||||
loadExistingItem() {
|
||||
// Initializes Media Frames now that itemId exists
|
||||
this.initializeMediaFrames();
|
||||
|
||||
|
@ -887,6 +1002,62 @@ export default {
|
|||
|
||||
// Fetch current existing attachments
|
||||
this.fetchAttachments(this.itemId);
|
||||
},
|
||||
onNextInSequence() {
|
||||
this.sequenceRightDirection = true;
|
||||
this.$router.push(this.$routerHelper.getCollectionSequenceEditPath(this.collectionId, this.sequenceId, this.itemPosition + 1));
|
||||
},
|
||||
onPrevInSequence() {
|
||||
this.sequenceRightDirection = false;
|
||||
this.$router.push(this.$routerHelper.getCollectionSequenceEditPath(this.collectionId, this.sequenceId, this.itemPosition - 1));
|
||||
}
|
||||
},
|
||||
created(){
|
||||
// Obtains collection ID
|
||||
this.cleanMetadata();
|
||||
eventBus.clearAllErrors();
|
||||
this.formErrorMessage = '';
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
this.form.collectionId = this.collectionId;
|
||||
|
||||
// CREATING NEW SINGLE ITEM
|
||||
if (this.$route.fullPath.split("/").pop() == "new") {
|
||||
this.isCreatingNewItem = true;
|
||||
this.createNewItem();
|
||||
|
||||
// EDITING EXISTING ITEM
|
||||
} else if (this.$route.fullPath.split("/").pop() == "edit") {
|
||||
this.isLoading = true;
|
||||
|
||||
// Obtains current Item ID from URL
|
||||
this.itemId = this.$route.params.itemId;
|
||||
this.loadExistingItem();
|
||||
|
||||
// EDITING EXISTING SEQUENCE
|
||||
} else if (this.$route.params.collectionId != undefined && this.$route.params.sequenceId != undefined){
|
||||
this.isLoading = true;
|
||||
|
||||
this.sequenceId = this.$route.params.sequenceId;
|
||||
let savedItemPosition = (this.$userPrefs.get('sequence_' + this.sequenceId + '_position') != undefined ? Number(this.$userPrefs.get('sequence_' + this.sequenceId + '_position')) : 1);
|
||||
this.itemPosition = this.$route.params.itemPosition != undefined ? Number(this.$route.params.itemPosition) : savedItemPosition;
|
||||
|
||||
this.isOnSequenceEdit = true;
|
||||
|
||||
// Saves current itemPosition to user prefs
|
||||
this.$userPrefs.set('sequence_' + this.sequenceId + '_position', this.itemPosition);
|
||||
|
||||
// Obtains current Item ID from Sequence
|
||||
this.fetchItemIdInSequence({ collectionId: this.collectionId, sequenceId: this.sequenceId, itemPosition: this.itemPosition })
|
||||
.then(() => {
|
||||
this.itemId = this.itemIdInSequence;
|
||||
this.loadExistingItem();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
|
||||
// Obtains current Sequence Group Info
|
||||
this.fetchGroup({ collectionId: this.collectionId, groupId: this.sequenceId });
|
||||
}
|
||||
|
||||
// Obtains collection name
|
||||
|
@ -902,13 +1073,6 @@ export default {
|
|||
// Sets feedback variables
|
||||
eventBus.$on('isUpdatingValue', (status) => {
|
||||
this.isUpdatingValues = status;
|
||||
// if (this.isUpdatingValues) {
|
||||
// this.$toast.open({
|
||||
// duration: 2000,
|
||||
// message: this.$i18n.get('info_updating_metadata_values'),
|
||||
// position: 'is-bottom',
|
||||
// })
|
||||
// }
|
||||
});
|
||||
eventBus.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
if (hasErrors)
|
||||
|
@ -918,6 +1082,10 @@ export default {
|
|||
});
|
||||
this.cleanLastUpdated();
|
||||
},
|
||||
beforeDestroy () {
|
||||
eventBus.$off('isUpdatingValue');
|
||||
eventBus.$off('hasErrorsOnForm');
|
||||
},
|
||||
beforeRouteLeave ( to, from, next ) {
|
||||
if (this.item.status == 'auto-draft') {
|
||||
this.$modal.open({
|
||||
|
@ -1179,6 +1347,9 @@ export default {
|
|||
margin-left: 16px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.is-outlined {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
|
@ -1206,6 +1377,34 @@ export default {
|
|||
margin-top: 0;
|
||||
margin-left: 24px;
|
||||
}
|
||||
|
||||
.sequence-progress {
|
||||
height: 5px;
|
||||
background: $turquoise5;
|
||||
width: 0%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transition: width 0.2s;
|
||||
}
|
||||
.sequence-progress-background {
|
||||
height: 5px;
|
||||
background: $gray3;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.sequence-button {
|
||||
background-color: transparent;
|
||||
color: $turquoise5;
|
||||
border: none;
|
||||
|
||||
.icon {
|
||||
margin-top: 0.3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -101,20 +101,28 @@ export default {
|
|||
},
|
||||
}
|
||||
});
|
||||
},
|
||||
eventOnEditTerm() {
|
||||
this.isEditingTerm = true;
|
||||
},
|
||||
eventOnTermEditionSaved() {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
},
|
||||
eventOnTermEditionCanceled() {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$termsListBus.$on('editTerm', () => {
|
||||
this.isEditingTerm = true;
|
||||
});
|
||||
this.$termsListBus.$on('termEditionSaved', () => {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
});
|
||||
this.$termsListBus.$on('termEditionCanceled', () => {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
});
|
||||
this.$termsListBus.$on('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$on('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$on('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$termsListBus.$off('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$off('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$off('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<div
|
||||
class="active-filter-item"
|
||||
:class="{
|
||||
'not-sortable-item': (filter.id == undefined || openedFilterId != '' || choosenMetadatum.name == filter.name || isUpdatingFiltersOrder == true || isRepositoryLevel),
|
||||
'not-sortable-item': (isSelectingFilterType || filter.id == undefined || openedFilterId != '' || choosenMetadatum.name == filter.name || isUpdatingFiltersOrder == true || isRepositoryLevel),
|
||||
'not-focusable-item': openedFilterId == filter.id,
|
||||
'disabled-filter': filter.enabled == false,
|
||||
'inherited-filter': filter.collection_id != collectionId || isRepositoryLevel
|
||||
|
@ -146,12 +146,15 @@
|
|||
v-model="availableMetadatumList"
|
||||
:options="{
|
||||
sort: false,
|
||||
group: { name:'filters', pull: true, put: false, revertClone: true },
|
||||
group: { name:'filters', pull: !isSelectingFilterType, put: false, revertClone: true },
|
||||
dragClass: 'sortable-drag'
|
||||
}">
|
||||
<div
|
||||
class="available-metadatum-item"
|
||||
:class="{'inherited-metadatum': metadatum.collection_id != collectionId || isRepositoryLevel}"
|
||||
:class="{
|
||||
'inherited-metadatum': metadatum.collection_id != collectionId || isRepositoryLevel,
|
||||
'disabled-metadatum': isSelectingFilterType
|
||||
}"
|
||||
v-if="metadatum.enabled"
|
||||
v-for="(metadatum, index) in availableMetadatumList"
|
||||
:key="index"
|
||||
|
@ -207,6 +210,7 @@ export default {
|
|||
isLoadingFilters: false,
|
||||
isLoadingFilterTypes: false,
|
||||
isLoadingFilter: false,
|
||||
isSelectingFilterType: false,
|
||||
isUpdatingFiltersOrder: false,
|
||||
openedFilterId: '',
|
||||
formWithErrors: '',
|
||||
|
@ -325,6 +329,9 @@ export default {
|
|||
.catch(() => { this.isUpdatingFiltersOrder = false; });
|
||||
},
|
||||
addMetadatumViaButton(metadatumType, metadatumIndex) {
|
||||
|
||||
if (this.isSelectingFilterType == false) {
|
||||
this.isSelectingFilterType = true;
|
||||
this.availableMetadatumList.splice(metadatumIndex, 1);
|
||||
let lastIndex = this.activeFilterList.length;
|
||||
|
||||
|
@ -332,6 +339,8 @@ export default {
|
|||
this.addTemporaryFilter(metadatumType);
|
||||
|
||||
this.addNewFilter(metadatumType, lastIndex);
|
||||
}
|
||||
|
||||
},
|
||||
addNewFilter(choosenMetadatum, newIndex) {
|
||||
this.choosenMetadatum = choosenMetadatum;
|
||||
|
@ -348,7 +357,6 @@ export default {
|
|||
}
|
||||
},
|
||||
createChoosenFilter() {
|
||||
|
||||
this.sendFilter({
|
||||
collectionId: this.collectionId,
|
||||
metadatumId: this.choosenMetadatum.id,
|
||||
|
@ -391,9 +399,11 @@ export default {
|
|||
this.updateFiltersOrder();
|
||||
},
|
||||
confirmSelectedFilterType() {
|
||||
this.isSelectingFilterType = false;
|
||||
this.createChoosenFilter();
|
||||
},
|
||||
cancelFilterTypeSelection() {
|
||||
this.isSelectingFilterType = false;
|
||||
this.availableMetadatumList.push(this.choosenMetadatum);
|
||||
this.choosenMetadatum = {};
|
||||
this.allowedFilterTypes = [];
|
||||
|
@ -534,6 +544,13 @@ export default {
|
|||
transition: top 0.1s ease;
|
||||
cursor: grab;
|
||||
|
||||
form.tainacan-form {
|
||||
padding: 1.0em 2.0em;
|
||||
margin-top: 1.0em;
|
||||
border-top: 1px solid $gray2;
|
||||
border-bottom: 1px solid $gray2;
|
||||
}
|
||||
|
||||
&>.field, form {
|
||||
background-color: white !important;
|
||||
}
|
||||
|
@ -738,10 +755,11 @@ export default {
|
|||
.sortable-drag {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
.available-metadatum-item:hover {
|
||||
.available-metadatum-item:not(.disabled-metadatum) {
|
||||
&:hover{
|
||||
background-color: $secondary;
|
||||
border-color: $secondary;
|
||||
color: white;
|
||||
color: white !important;
|
||||
position: relative;
|
||||
left: -4px;
|
||||
|
||||
|
@ -759,6 +777,7 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.inherited-filter {
|
||||
&.active-filter-item:hover:not(.not-sortable-item) {
|
||||
|
|
|
@ -42,7 +42,12 @@
|
|||
<b-dropdown-item
|
||||
v-if="$route.params.collectionId && $userCaps.hasCapability('edit_others_posts') && !isOnTrash"
|
||||
@click="openBulkEditionModal()">
|
||||
{{ $i18n.get('label_edit_selected_items') }}
|
||||
{{ $i18n.get('label_bulk_edit_selected_items') }}
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item
|
||||
v-if="$route.params.collectionId && $userCaps.hasCapability('edit_others_posts') && !isOnTrash"
|
||||
@click="sequenceEditSelectedItems()">
|
||||
{{ $i18n.get('label_sequence_edit_selected_items') }}
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item
|
||||
v-if="collectionId"
|
||||
|
@ -182,8 +187,7 @@
|
|||
<!-- Title -->
|
||||
<div
|
||||
:style="{
|
||||
'padding-left': !collectionId ? '0.5rem !important' : '2.75rem',
|
||||
'margin-left': !collectionId ? '0 !important' : '24px'
|
||||
'padding-left': !collectionId ? '0 !important' : '1rem'
|
||||
}"
|
||||
@click="onClickItem($event, item, index)"
|
||||
class="metadata-title">
|
||||
|
@ -585,7 +589,7 @@
|
|||
column.metadatum !== 'row_actions' &&
|
||||
column.metadatum !== 'row_creation' &&
|
||||
column.metadatum !== 'row_author'"
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column, column.metadata_type_object.component) : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
|
||||
<span v-if="column.metadatum == 'row_thumbnail'">
|
||||
<img
|
||||
|
@ -721,6 +725,10 @@ export default {
|
|||
...mapGetters('bulkedition', [
|
||||
'getGroupID'
|
||||
]),
|
||||
...mapGetters('search', [
|
||||
'getOrder',
|
||||
'getOrderBy'
|
||||
]),
|
||||
openBulkEditionModal(){
|
||||
this.$modal.open({
|
||||
parent: this,
|
||||
|
@ -735,6 +743,17 @@ export default {
|
|||
width: 'calc(100% - 8.333333333%)',
|
||||
});
|
||||
},
|
||||
sequenceEditSelectedItems() {
|
||||
this.createEditGroup({
|
||||
object: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs.filter(item => item !== false),
|
||||
collectionID: this.collectionId,
|
||||
order: this.getOrder(),
|
||||
orderBy: this.getOrderBy()
|
||||
}).then(() => {
|
||||
let sequenceId = this.getGroupID();
|
||||
this.$router.push(this.$routerHelper.getCollectionSequenceEditPath(this.collectionId, sequenceId, 1));
|
||||
});
|
||||
},
|
||||
selectAllItemsOnPage() {
|
||||
for (let i = 0; i < this.selectedItems.length; i++) {
|
||||
this.selectedItems.splice(i, 1, !this.allItemsOnPageSelected);
|
||||
|
@ -881,7 +900,7 @@ export default {
|
|||
goToItemEditPage(item) {
|
||||
this.$router.push(this.$routerHelper.getItemEditPath(item.collection_id, item.id));
|
||||
},
|
||||
renderMetadata(itemMetadata, column) {
|
||||
renderMetadata(itemMetadata, column, component) {
|
||||
|
||||
let metadata = (itemMetadata != undefined && itemMetadata[column.slug] != undefined) ? itemMetadata[column.slug] : false;
|
||||
|
||||
|
@ -890,6 +909,9 @@ export default {
|
|||
} else if (metadata.date_i18n) {
|
||||
return metadata.date_i18n;
|
||||
} else {
|
||||
if (component != undefined && component == 'tainacan-textarea')
|
||||
return metadata.value_as_string;
|
||||
else
|
||||
return metadata.value_as_html;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
'not-sortable-item': isRepositoryLevel || metadatum.id == undefined || openedMetadatumId != '' || isUpdatingMetadataOrder,
|
||||
'not-focusable-item': openedMetadatumId == metadatum.id,
|
||||
'disabled-metadatum': metadatum.enabled == false,
|
||||
'inherited-metadatum': metadatum.collection_id != collectionId || isRepositoryLevel
|
||||
'inherited-metadatum': (metadatum.collection_id != collectionId && metadatum.parent == 0) || isRepositoryLevel
|
||||
}"
|
||||
v-for="(metadatum, index) in activeMetadatumList"
|
||||
:key="index">
|
||||
|
@ -50,7 +50,10 @@
|
|||
<grip-icon/>
|
||||
<span class="icon icon-level-identifier">
|
||||
<i
|
||||
:class="{ 'mdi-folder has-text-turquoise5': (metadatum.collection_id == collectionId && !isRepositoryLevel), 'mdi-folder-multiple has-text-blue5': metadatum.collection_id != collectionId || isRepositoryLevel}"
|
||||
:class="{
|
||||
'mdi-folder has-text-turquoise5': (metadatum.collection_id != 'default' && !isRepositoryLevel),
|
||||
'mdi-folder-multiple has-text-blue5': (metadatum.collection_id == 'default') || isRepositoryLevel
|
||||
}"
|
||||
class="mdi" />
|
||||
</span>
|
||||
<span
|
||||
|
@ -901,9 +904,9 @@ export default {
|
|||
cursor: default;
|
||||
background-color: white !important;
|
||||
|
||||
.handle .label-details, .handle .icon, {
|
||||
color: $gray3 !important;
|
||||
}
|
||||
// .handle .label-details, .handle .icon, {
|
||||
// color: $gray3 !important;
|
||||
// }
|
||||
}
|
||||
&.not-focusable-item, &.not-focusable-item:hover {
|
||||
cursor: default;
|
||||
|
|
|
@ -231,24 +231,34 @@ export default {
|
|||
},
|
||||
}
|
||||
});
|
||||
},
|
||||
eventOnChildTermDeleted(parentTermId) {
|
||||
if (this.term.id == parentTermId && this.totalTerms > 0)
|
||||
this.totalTerms--;
|
||||
},
|
||||
eventOnEditTerm() {
|
||||
this.isEditingTerm = true;
|
||||
},
|
||||
eventOnTermEditionSaved() {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
},
|
||||
eventOnTermEditionCanceled() {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$root.$on('onChildTermDeleted', (parentTermId) => {
|
||||
if (this.term.id == parentTermId && this.totalTerms > 0)
|
||||
this.totalTerms--;
|
||||
});
|
||||
this.$termsListBus.$on('editTerm', () => {
|
||||
this.isEditingTerm = true;
|
||||
});
|
||||
this.$termsListBus.$on('termEditionSaved', () => {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
});
|
||||
this.$termsListBus.$on('termEditionCanceled', () => {
|
||||
this.isEditingTerm = false;
|
||||
this.term.opened = false;
|
||||
});
|
||||
this.$root.$on('onChildTermDeleted', this.eventOnChildTermDeleted);
|
||||
this.$termsListBus.$on('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$on('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$on('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('onChildTermDeleted', this.eventOnChildTermDeleted);
|
||||
this.$termsListBus.$off('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$off('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$off('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -352,18 +352,12 @@ export default {
|
|||
.catch((error) => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.taxonomyId !== String) {
|
||||
this.loadTerms(0);
|
||||
}
|
||||
this.$root.$on('onChildTermDeleted', (parentTermId) => {
|
||||
eventOnChildTermDeleted(parentTermId) {
|
||||
if ((parentTermId == 0 || parentTermId == undefined ) && this.totalTerms > 0)
|
||||
this.totalTerms--;
|
||||
});
|
||||
this.$termsListBus.$on('editTerm', (term) => {
|
||||
|
||||
},
|
||||
eventOnEditTerm(term) {
|
||||
// Position edit form in a visible area
|
||||
let container = document.getElementById('repository-container');
|
||||
if (container && container.scrollTop && container.scrollTop > 80)
|
||||
|
@ -373,24 +367,37 @@ export default {
|
|||
|
||||
this.editTerm = term;
|
||||
this.isEditingTerm = true;
|
||||
});
|
||||
this.$termsListBus.$on('termEditionSaved', ({hasChangedParent}) => {
|
||||
},
|
||||
eventOnTermEditionSaved({hasChangedParent}) {
|
||||
this.isEditingTerm = false;
|
||||
this.editTerm = null;
|
||||
|
||||
if (hasChangedParent)
|
||||
this.loadTerms(0);
|
||||
});
|
||||
this.$termsListBus.$on('termEditionCanceled', () => {
|
||||
},
|
||||
eventOnTermEditionCanceled() {
|
||||
this.isEditingTerm = false;
|
||||
this.editTerm = null;
|
||||
});
|
||||
this.$termsListBus.$on('addNewChildTerm', (parentId) => {
|
||||
this.addNewTerm(parentId);
|
||||
});
|
||||
this.$termsListBus.$on('deleteBasicTermItem', (term) => {
|
||||
this.deleteBasicTerm(term);
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.taxonomyId !== String) {
|
||||
this.loadTerms(0);
|
||||
}
|
||||
this.$root.$on('onChildTermDeleted', this.eventOnChildTermDeleted);
|
||||
this.$termsListBus.$on('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$on('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$on('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
this.$termsListBus.$on('addNewChildTerm', this.addNewTerm);
|
||||
this.$termsListBus.$on('deleteBasicTermItem', this.deleteBasicTerm);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('onChildTermDeleted', this.eventOnChildTermDeleted);
|
||||
this.$termsListBus.$off('editTerm', this.eventOnEditTerm);
|
||||
this.$termsListBus.$off('termEditionSaved', this.eventOnTermEditionSaved);
|
||||
this.$termsListBus.$off('termEditionCanceled', this.eventOnTermEditionCanceled);
|
||||
this.$termsListBus.$off('addNewChildTerm', this.addNewTerm);
|
||||
this.$termsListBus.$off('deleteBasicTermItem', this.deleteBasicTerm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ export default {
|
|||
this.arrayRealPath = this.arrayRealPath.filter((item) => item.length != 0);
|
||||
|
||||
this.generateViewPath();
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -204,7 +205,7 @@ export default {
|
|||
switch(this.arrayRealPath[i-1]) {
|
||||
case 'collections':
|
||||
this.fetchCollectionNameAndURL(this.arrayRealPath[i])
|
||||
.then(collection => this.arrayViewPath.splice(i, 1, collection.name))
|
||||
.then(collection => this.arrayViewPath.splice(i, 1, collection.name) )
|
||||
.catch((error) => this.$console.error(error));
|
||||
|
||||
break;
|
||||
|
@ -225,6 +226,11 @@ export default {
|
|||
break;
|
||||
}
|
||||
|
||||
} else if (this.arrayRealPath[i-1] == 'sequence' && i > 0){
|
||||
if (this.$route.params.itemPosition != undefined) {
|
||||
this.arrayViewPath.splice(i, 1, this.$i18n.get('label_editing_item_number') + this.$route.params.itemPosition);
|
||||
} else
|
||||
this.arrayViewPath.splice(i, 1, this.$i18n.get('edit'));
|
||||
} else {
|
||||
if(this.arrayRealPath[i] == 'undefined'){
|
||||
this.arrayViewPath.splice(i, 1, '');
|
||||
|
|
|
@ -133,11 +133,13 @@
|
|||
},
|
||||
},
|
||||
created(){
|
||||
|
||||
this.$root.$on('closeAdvancedSearchShortcut', () => {
|
||||
this.$refs.advancedSearchShortcut.toggle();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('closeAdvancedSearchShortcut');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -157,7 +157,6 @@ export default {
|
|||
display: inline-block;
|
||||
width: 80%;
|
||||
flex-shrink: 1;
|
||||
flex-grow: 1;
|
||||
}
|
||||
a.back-link{
|
||||
font-weight: 500;
|
||||
|
|
|
@ -359,13 +359,17 @@
|
|||
getOptions(offset){
|
||||
let promise = '';
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
if ( this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
||||
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
|
||||
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
|
||||
|
||||
promise = this.getValuesRelationship( collectionTarget, this.optionName, [], offset, this.maxNumOptionsCheckboxList, true);
|
||||
|
||||
promise
|
||||
promise.request
|
||||
.then(() => {
|
||||
this.isCheckboxListLoading = false;
|
||||
this.isSearchingLoading = false;
|
||||
|
@ -376,7 +380,7 @@
|
|||
} else {
|
||||
promise = this.getValuesPlainText( this.metadatum_id, this.optionName, this.isRepositoryLevel, [], offset, this.maxNumOptionsCheckboxList, true);
|
||||
|
||||
promise
|
||||
promise.request
|
||||
.then(() => {
|
||||
this.isCheckboxListLoading = false;
|
||||
this.isSearchingLoading = false;
|
||||
|
@ -385,6 +389,9 @@
|
|||
this.$console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.getOptionsValuesCancel = promise.source;
|
||||
},
|
||||
autoComplete: _.debounce( function () {
|
||||
this.isSearching = !!this.optionName.length;
|
||||
|
@ -417,7 +424,7 @@
|
|||
|
||||
this.getOptions(0);
|
||||
}
|
||||
}, 300),
|
||||
}, 500),
|
||||
highlightHierarchyPath(){
|
||||
for(let [index, el] of this.hierarchicalPath.entries()){
|
||||
let htmlEl = this.$refs[`${el.column}.${el.element}-tainacan-li-checkbox-model`][0].$el;
|
||||
|
|
|
@ -52,7 +52,11 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.isLoading = true;
|
||||
this.fetchCollections({ page: 1, collectionsPerPage: 96 })
|
||||
this.fetchCollections({
|
||||
page: 1,
|
||||
collectionsPerPage: 96,
|
||||
contextEdit: true
|
||||
})
|
||||
.then((res) => {
|
||||
this.collections = res.collections;
|
||||
this.isLoading = false;
|
||||
|
|
|
@ -205,6 +205,9 @@ export default {
|
|||
}, 20000);
|
||||
|
||||
this.showProcessesList = false;
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.intervalID);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -42,7 +42,12 @@
|
|||
open: false,
|
||||
},
|
||||
created(){
|
||||
this.fetchCollections({page: 1, collectionsPerPage: -1, status: null});
|
||||
this.fetchCollections({
|
||||
page: 1,
|
||||
collectionsPerPage: -1,
|
||||
status: null,
|
||||
contextEdit: false
|
||||
});
|
||||
},
|
||||
mounted(){
|
||||
let routeQueries = this.$route.query;
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
import Vue from 'vue';
|
||||
import Buefy from 'buefy';
|
||||
import VTooltip from 'v-tooltip';
|
||||
import { VueHammer } from 'vue2-hammer';
|
||||
// import { VueHammer } from 'vue2-hammer';
|
||||
import VueMasonry from 'vue-masonry-css';
|
||||
import draggable from 'vuedraggable';
|
||||
import VueTheMask from 'vue-the-mask';
|
||||
|
||||
// Custom elements
|
||||
import Text from '../../classes/metadata-types/text/Text.vue';
|
||||
|
@ -38,18 +40,16 @@ import TainacanFiltersList from '../../classes/filter-types/tainacan-filter-item
|
|||
import AdminPage from '../admin.vue'
|
||||
import HelpButton from '../components/other/help-button.vue';
|
||||
import TainacanTitle from '../components/navigation/tainacan-title.vue';
|
||||
import draggable from 'vuedraggable'
|
||||
import store from '../../js/store/store'
|
||||
import router from './router'
|
||||
import eventBusSearch from '../../js/event-bus-search';
|
||||
import termsListBus from './terms-list-bus.js';
|
||||
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin } from './utilities';
|
||||
import VueTheMask from 'vue-the-mask';
|
||||
|
||||
// Configure and Register Plugins
|
||||
Vue.use(Buefy);
|
||||
Vue.use(VTooltip);
|
||||
Vue.use(VueHammer);
|
||||
// Vue.use(VueHammer);
|
||||
Vue.use(VueMasonry);
|
||||
Vue.use(I18NPlugin);
|
||||
Vue.use(UserPrefsPlugin);
|
||||
|
|
|
@ -51,7 +51,9 @@ const routes = [
|
|||
{ path: 'settings', component: CollectionEditionForm, name: 'CollectionEditionForm', meta: {title: i18nGet('title_collection_settings'), icon: 'folder-multiple'} },
|
||||
{ path: 'metadata', component: MetadataList, name: 'MetadataList', meta: {title: i18nGet('title_collection_metadata_edition'), icon: 'folder-multiple'} },
|
||||
{ path: 'filters', component: FiltersList, name: 'FiltersList', meta: {title: i18nGet('title_collection_filters_edition'), icon: 'folder-multiple'} },
|
||||
{ path: 'events', component: EventsPage, name: 'CollectionEventsPage', meta: {title: i18nGet('title_collection_events'), icon: 'flash'} }
|
||||
{ path: 'events', component: EventsPage, name: 'CollectionEventsPage', meta: {title: i18nGet('title_collection_events'), icon: 'flash'} },
|
||||
{ path: 'sequence/:sequenceId', name: 'SavedSequenceEditionForm', component: ItemEditionForm, meta: {title: i18nGet('title_edit_item'), icon: 'folder-multiple'} },
|
||||
{ path: 'sequence/:sequenceId/:itemPosition', name: 'SequenceEditionForm', component: ItemEditionForm, meta: {title: i18nGet('title_edit_item'), icon: 'folder-multiple'} },
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Vue from 'vue';
|
||||
import Buefy from 'buefy';
|
||||
import VTooltip from 'v-tooltip';
|
||||
import { VueHammer } from 'vue2-hammer';
|
||||
// import { VueHammer } from 'vue2-hammer';
|
||||
import VueMasonry from 'vue-masonry-css';
|
||||
|
||||
// Custom elements
|
||||
|
@ -48,7 +48,7 @@ import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin } from '
|
|||
// Configure and Register Plugins
|
||||
Vue.use(Buefy);
|
||||
Vue.use(VTooltip);
|
||||
Vue.use(VueHammer);
|
||||
// Vue.use(VueHammer);
|
||||
Vue.use(VueMasonry);
|
||||
Vue.use(I18NPlugin);
|
||||
Vue.use(UserPrefsPlugin);
|
||||
|
|
|
@ -134,7 +134,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
|
|||
}
|
||||
},
|
||||
get(key) {
|
||||
return this.tainacanPrefs[key];
|
||||
return this.tainacanPrefs[key] ? this.tainacanPrefs[key] : undefined;
|
||||
},
|
||||
set(key, value) {
|
||||
this.tainacanPrefs[key] = value;
|
||||
|
@ -147,7 +147,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
|
|||
if (prefs[key]) {
|
||||
resolve( prefs[key] );
|
||||
} else {
|
||||
reject('Key ' + key + ' does not exists in user preference.');
|
||||
this.tainacanPrefs[key] = value;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -175,6 +175,9 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getCollectionItemsPath(collectionId, query) {
|
||||
return '/collections/'+ collectionId + '/items/?' + qs.stringify(query);
|
||||
},
|
||||
getCollectionSequenceEditPath(collectionId, sequenceId, itemPosition) {
|
||||
return '/collections/'+ collectionId + '/sequence/' + sequenceId + '/' + itemPosition;
|
||||
},
|
||||
getCollectionMetadataPath(collectionId) {
|
||||
return '/collections/'+ collectionId + '/metadata/';
|
||||
},
|
||||
|
|
|
@ -205,7 +205,11 @@ export default {
|
|||
loadCollections() {
|
||||
this.cleanCollections();
|
||||
this.isLoading = true;
|
||||
this.fetchCollections({ 'page': this.page, 'collectionsPerPage': this.collectionsPerPage, 'status': this.status })
|
||||
this.fetchCollections({
|
||||
'page': this.page,
|
||||
'collectionsPerPage': this.collectionsPerPage,
|
||||
'status': this.status,
|
||||
'contextEdit': true })
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
this.totalCollections = res.total;
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<template>
|
||||
<div
|
||||
<!-- <div <IF WE USE HAMMERJS>
|
||||
v-hammer:swipe="onSwipeFiltersMenu"
|
||||
:class="{
|
||||
'repository-level-page': isRepositoryLevel,
|
||||
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
|
||||
}"> -->
|
||||
<div
|
||||
:class="{
|
||||
'repository-level-page': isRepositoryLevel,
|
||||
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
|
||||
|
@ -1140,6 +1145,19 @@
|
|||
this.searchControlHeight = this.$refs['search-control'] ? this.$refs['search-control'].clientHeight + this.$refs['search-control'].offsetTop : 0;
|
||||
this.isFiltersMenuCompressed = jQuery(window).width() <= 768;
|
||||
});
|
||||
},
|
||||
removeEventListeners() {
|
||||
// Component
|
||||
this.$off();
|
||||
// Window
|
||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||
// $root
|
||||
this.$root.$off('openAdvancedSearch');
|
||||
// $eventBusSearch
|
||||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
this.$eventBusSearch.$off('advancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -1153,6 +1171,7 @@
|
|||
|
||||
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {
|
||||
this.isLoadingItems = isLoadingItems;
|
||||
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasFiltered', hasFiltered => {
|
||||
|
@ -1233,8 +1252,12 @@
|
|||
window.addEventListener('resize', this.adjustSearchControlHeight);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$off();
|
||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||
this.removeEventListeners();
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.$eventBusSearch.searchCancel != undefined)
|
||||
this.$eventBusSearch.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<template>
|
||||
<div
|
||||
<!-- <div <IF WE USE HAMMER JS>
|
||||
v-hammer:swipe="onSwipeFiltersMenu"
|
||||
:class="{
|
||||
'repository-level-page': isRepositoryLevel,
|
||||
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
|
||||
}"> -->
|
||||
<div
|
||||
:class="{
|
||||
'repository-level-page': isRepositoryLevel,
|
||||
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
|
||||
|
@ -1118,6 +1123,19 @@
|
|||
});
|
||||
}
|
||||
},
|
||||
removeEventListeners() {
|
||||
// Component
|
||||
this.$off();
|
||||
// Window
|
||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||
// $root
|
||||
this.$root.$off('openAdvancedSearch');
|
||||
// $eventBusSearch
|
||||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
this.$eventBusSearch.$off('advancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
||||
},
|
||||
created() {
|
||||
|
||||
this.isOnTheme = (this.$route.name === null);
|
||||
|
@ -1210,8 +1228,11 @@
|
|||
window.addEventListener('resize', this.adjustSearchControlHeight);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$off();
|
||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||
this.removeEventListeners();
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.$eventBusSearch.searchCancel != undefined)
|
||||
this.$eventBusSearch.searchCancel.cancel('Item search Canceled.');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
<div class="columns is-fullheight">
|
||||
<section class="column is-secondary-content">
|
||||
<tainacan-collection-subheader :id="collectionId"/>
|
||||
|
||||
<router-view
|
||||
id="collection-page-container"
|
||||
:collection-id="collectionId"
|
||||
class="page-container page-container-small"/>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -155,8 +155,9 @@
|
|||
font-size: 0.875rem;
|
||||
margin: 0px;
|
||||
text-overflow: ellipsis;
|
||||
overflow-x: hidden;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
// max-height: 1rem;
|
||||
}
|
||||
}
|
||||
img.table-thumb {
|
||||
|
|
|
@ -400,7 +400,7 @@ $modal-z: 9999999;
|
|||
animation-duration: 0.2s;
|
||||
animation-timing-function: ease;
|
||||
}
|
||||
.filtes-menu-leave-active {
|
||||
.filters-menu-leave-active {
|
||||
animation-name: filters-menu-out;
|
||||
animation-duration: 0.2s;
|
||||
animation-timing-function: ease;
|
||||
|
@ -488,3 +488,88 @@ $modal-z: 9999999;
|
|||
animation-duration: 0.3s;
|
||||
animation-timing-function: ease;
|
||||
}
|
||||
|
||||
// Sequence page
|
||||
|
||||
// Slide
|
||||
@keyframes page-left-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
-ms-transform: translate(-5%, 0%); /* IE 9 */
|
||||
-webkit-transform: translate(-5%, 0%); /* Safari */
|
||||
transform: translate(-5%, 0%);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
-ms-transform: translate(0, 0); /* IE 9 */
|
||||
-webkit-transform: translate(0, 0); /* Safari */
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes page-left-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
-ms-transform: translate(0, 0); /* IE 9 */
|
||||
-webkit-transform: translate(0, 0); /* Safari */
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
-ms-transform: translate(10%, 0%); /* IE 9 */
|
||||
-webkit-transform: translate(10%, 0%); /* Safari */
|
||||
transform: translate(10%, 0%);
|
||||
}
|
||||
}
|
||||
|
||||
.page-left-enter-active {
|
||||
animation-name: page-left-in;
|
||||
animation-duration: 0.4s;
|
||||
animation-timing-function: ease;
|
||||
}
|
||||
.page-left-leave-active {
|
||||
animation-name: page-left-out;
|
||||
animation-duration: 0.4s;
|
||||
animation-timing-function: ease;
|
||||
}
|
||||
|
||||
@keyframes page-right-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
-ms-transform: translate(10%, 0%); /* IE 9 */
|
||||
-webkit-transform: translate(10%, 0%); /* Safari */
|
||||
transform: translate(10%, 0%);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
-ms-transform: translate(0, 0); /* IE 9 */
|
||||
-webkit-transform: translate(0, 0); /* Safari */
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes page-right-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
-ms-transform: translate(0, 0); /* IE 9 */
|
||||
-webkit-transform: translate(0, 0); /* Safari */
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
-ms-transform: translate(-5%, 0%); /* IE 9 */
|
||||
-webkit-transform: translate(-5%, 0%); /* Safari */
|
||||
transform: translate(-5%, 0%);
|
||||
}
|
||||
}
|
||||
|
||||
.page-right-enter-active {
|
||||
animation-name: page-right-in;
|
||||
animation-duration: 0.3s;
|
||||
animation-timing-function: ease;
|
||||
}
|
||||
.page-right-leave-active {
|
||||
animation-name: page-right-out;
|
||||
animation-duration: 0.3s;
|
||||
animation-timing-function: ease;
|
||||
}
|
|
@ -31,6 +31,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'mapping' => __( 'Mapping', 'tainacan' ),
|
||||
'importers' => __( 'Importers', 'tainacan' ),
|
||||
'processes' => __( 'Processes', 'tainacan' ),
|
||||
'sequence' => __( 'Sequence', 'tainacan' ),
|
||||
|
||||
// Actions
|
||||
'close' => __( 'Close', 'tainacan' ),
|
||||
|
@ -44,6 +45,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'remove_value' => __( 'Remove value', 'tainacan' ),
|
||||
'save' => __( 'Save', 'tainacan' ),
|
||||
'next' => __( 'Next', 'tainacan' ),
|
||||
'previous' => __( 'Previous', 'tainacan' ),
|
||||
'back' => __( 'Back', 'tainacan' ),
|
||||
'exit' => __( 'Exit', 'tainacan' ),
|
||||
'see' => __( 'View', 'tainacan' ),
|
||||
|
@ -232,7 +234,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_delete_permanently' => __( 'Delete permanently', 'tainacan' ),
|
||||
'label_send_to_trash' => __( 'Send to trash', 'tainacan' ),
|
||||
'label_delete_selected_taxonomies' => __( 'Delete selected taxonomies', 'tainacan' ),
|
||||
'label_edit_selected_items' => __( 'Edit selected items', 'tainacan' ),
|
||||
'label_bulk_edit_selected_items' => __( 'Bulk edit selected items', 'tainacan' ),
|
||||
'label_sequence_edit_selected_items' => __( 'Edit selected items in sequence', 'tainacan' ),
|
||||
'label_edit_selected_taxonomies' => __( 'Edit selected taxonomies', 'tainacan' ),
|
||||
'label_select_all_collections_page' => __( 'Select all collections on page', 'tainacan' ),
|
||||
'label_select_all_items_page' => __( 'Select all items on page', 'tainacan' ),
|
||||
|
@ -310,6 +313,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_show_metadata' => __( 'Show metadata', 'tainacan' ),
|
||||
'label_all_terms' => __( 'All terms', 'tainacan' ),
|
||||
'label_selected_terms' => __( 'Selected terms', 'tainacan'),
|
||||
'label_editing_item_number' => __( 'Editing item n.', 'tainacan'),
|
||||
'label_sequence_editing_item' => __( 'Sequence editing: Item', 'tainacan'),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Tainacan\API\EndPoints;
|
|||
use \Tainacan\API\REST_Controller;
|
||||
use Tainacan\Repositories;
|
||||
use Tainacan\Entities;
|
||||
use \Tainacan\Exposers\Mappers\Value;
|
||||
|
||||
/**
|
||||
* Represents the Exporters REST Controller
|
||||
|
@ -214,6 +215,48 @@ class REST_Exporters_Controller extends REST_Controller {
|
|||
return new \WP_REST_Response( $response, 200 );
|
||||
}
|
||||
|
||||
protected function map($item_arr, $mapper) {
|
||||
$ret = $item_arr;
|
||||
if(array_key_exists('metadatum', $item_arr)) { // getting a unique metadatum
|
||||
$ret = $this->map_metadatum($item_arr, $mapper);
|
||||
} else { // array of elements
|
||||
$ret = [];
|
||||
foreach ($item_arr as $item) {
|
||||
if(array_key_exists('metadatum', $item)) {
|
||||
$ret = array_merge($ret, $this->map($item, $mapper) );
|
||||
} else {
|
||||
$ret[] = $this->map($item, $mapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function map_metadatum($item_arr, $mapper) {
|
||||
$ret = $item_arr;
|
||||
$metadatum_mapping = $item_arr['metadatum']['exposer_mapping'];
|
||||
if(array_key_exists($mapper->slug, $metadatum_mapping)) {
|
||||
if(
|
||||
is_string($metadatum_mapping[$mapper->slug]) && is_array($mapper->metadata) && !array_key_exists( $metadatum_mapping[$mapper->slug], $mapper->metadata) ||
|
||||
is_array($metadatum_mapping[$mapper->slug]) && $mapper->allow_extra_metadata != true
|
||||
) {
|
||||
throw new \Exception('Invalid Mapper Option');
|
||||
}
|
||||
$slug = '';
|
||||
if(is_string($metadatum_mapping[$mapper->slug])) {
|
||||
$slug = $metadatum_mapping[$mapper->slug];
|
||||
} else {
|
||||
$slug = $metadatum_mapping[$mapper->slug]['slug'];
|
||||
}
|
||||
$ret = [$mapper->prefix.$slug.$mapper->sufix => $item_arr['value']]; //TODO Validate option
|
||||
} elseif($mapper->slug == 'value') {
|
||||
$ret = [$item_arr['metadatum']['name'] => $item_arr['value']];
|
||||
} else {
|
||||
$ret = [];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -8,6 +8,18 @@ use \Tainacan\API\REST_Controller;
|
|||
|
||||
class REST_Facets_Controller extends REST_Controller {
|
||||
|
||||
private $total_pages;
|
||||
private $total_items;
|
||||
|
||||
private $collection;
|
||||
private $collection_repository;
|
||||
private $metadatum_repository;
|
||||
private $filter_repository;
|
||||
private $terms_repository;
|
||||
private $taxonomy_repository;
|
||||
private $items_repository;
|
||||
private $taxonomy;
|
||||
|
||||
/**
|
||||
* REST_Facets_Controller constructor.
|
||||
*/
|
||||
|
@ -38,7 +50,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)', array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_item'),
|
||||
'callback' => array($this, 'get_items'),
|
||||
'permission_callback' => array($this, 'get_items_permissions_check')
|
||||
)
|
||||
));
|
||||
|
@ -46,7 +58,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)', array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_item'),
|
||||
'callback' => array($this, 'get_items'),
|
||||
'permission_callback' => array($this, 'get_items_permissions_check')
|
||||
)
|
||||
));
|
||||
|
@ -57,7 +69,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
*
|
||||
* @return \WP_Error|\WP_REST_Response
|
||||
*/
|
||||
public function get_item( $request ) {
|
||||
public function get_items( $request ) {
|
||||
|
||||
$metadatum_id = $request['metadatum_id'];
|
||||
$metadatum = $this->metadatum_repository->fetch($metadatum_id);
|
||||
|
@ -83,6 +95,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
*/
|
||||
public function prepare_item_for_response($metadatum, $request){
|
||||
$response = [];
|
||||
$metadatum_type = null;
|
||||
|
||||
if( !empty($metadatum) ){
|
||||
|
||||
|
@ -202,8 +215,8 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
else {
|
||||
|
||||
$metadatum_id = $metadatum->get_id();
|
||||
$offset = '';
|
||||
$number = '';
|
||||
$offset = null;
|
||||
$number = null;
|
||||
$collection_id = ( isset($request['collection_id']) ) ? $request['collection_id'] : false;
|
||||
$selected = $this->getTextSelectedValues($request, $metadatum_id);
|
||||
|
||||
|
@ -221,42 +234,40 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
|
||||
} else {
|
||||
if($collection_id) {
|
||||
$response = $this->metadatum_repository->fetch_all_metadatum_values( $collection_id, $metadatum_id, '', $offset, $number);
|
||||
$response = $this->metadatum_repository->fetch_all_metadatum_values( $collection_id, $metadatum_id, null, $offset, $number);
|
||||
} else {
|
||||
$response = $this->metadatum_repository->fetch_all_metadatum_values( null, $metadatum_id, '', $offset, $number);
|
||||
$response = $this->metadatum_repository->fetch_all_metadatum_values( null, $metadatum_id, null, $offset, $number);
|
||||
}
|
||||
}
|
||||
|
||||
$rawResponse = $response;
|
||||
|
||||
// retrieve selected items
|
||||
|
||||
if( $selected && $request['getSelected'] && $request['getSelected'] === '1'){
|
||||
if( count($selected) && $request['getSelected'] && $request['getSelected'] === '1'){
|
||||
$rawValues = $this->get_values( $response );
|
||||
$realResponse = [];
|
||||
|
||||
foreach( $selected as $index => $value ){
|
||||
|
||||
$row = ['mvalue' => $value, 'metadatum_id' => $metadatum_id ];
|
||||
$row = (object) ['mvalue' => $value, 'metadatum_id' => $metadatum_id ];
|
||||
$realResponse[] = $row;
|
||||
|
||||
}
|
||||
|
||||
foreach( $rawValues as $index => $row0 ){
|
||||
|
||||
if( in_array($row0, $selected) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
$realResponse[] = ['mvalue' => $row0, 'metadatum_id' => $metadatum_id];
|
||||
if( !in_array($row0, $selected) ){
|
||||
$realResponse[] = (object) ['mvalue' => $row0, 'metadatum_id' => $metadatum_id];
|
||||
|
||||
if( isset($request['number']) && count($realResponse) >= $request['number']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = $realResponse;
|
||||
}
|
||||
|
||||
$this->set_pagination_properties_text_type( $collection_id, $metadatum_id, ($request['search']) ? $request['search'] : '' , $offset, $number );
|
||||
$this->set_pagination_properties_text_type( $offset, $number, $rawResponse );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,8 +296,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
foreach ( $response as $key => $item ) {
|
||||
|
||||
if( $type === 'Tainacan\Metadata_Types\Taxonomy' ){
|
||||
|
||||
$row = [
|
||||
$result[] = [
|
||||
'label' => $item['name'],
|
||||
'value' => $item['id'],
|
||||
'img' => ( isset($item['header_image']) ) ? $item['header_image'] : false ,
|
||||
|
@ -296,10 +306,8 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
'taxonomy_id' => $this->taxonomy->WP_Post->ID,
|
||||
'taxonomy' => ( isset($item['taxonomy']) ) ? $item['taxonomy'] : false,
|
||||
];
|
||||
|
||||
} else if( $type === 'Tainacan\Metadata_Types\Relationship' ){
|
||||
|
||||
$row = [
|
||||
$result[] = [
|
||||
'label' => $item['title'],
|
||||
'value' => $item['id'],
|
||||
'img' => ( isset($item['thumbnail']['thumb']) ) ? $item['thumbnail']['thumb'] : false,
|
||||
|
@ -307,21 +315,16 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
'total_children' => 0,
|
||||
'type' => 'Relationship'
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
$row = [
|
||||
'label' => $item['mvalue'],
|
||||
'value' => $item['mvalue'],
|
||||
$result[] = [
|
||||
'label' => $item->mvalue,
|
||||
'value' => $item->mvalue,
|
||||
'img' => false,
|
||||
'parent' => false,
|
||||
'total_children' => 0,
|
||||
'type' => 'Text'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,15 +333,17 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
|
||||
/**
|
||||
* set attributes for text metadata
|
||||
*
|
||||
* @param $offset
|
||||
* @param $number
|
||||
* @param $response
|
||||
*/
|
||||
private function set_pagination_properties_text_type( $collection_id, $metadatum_id, $search , $offset, $number ){
|
||||
$response = $this->metadatum_repository->fetch_all_metadatum_values( $collection_id, $metadatum_id, $search);
|
||||
|
||||
private function set_pagination_properties_text_type( $offset, $number, $response ){
|
||||
if( $response && is_array( $response ) ){
|
||||
|
||||
if ( $offset !== '' && $number) {
|
||||
$per_page = (int) $number;
|
||||
$page = ceil( ( ( (int) $offset ) / $per_page ) + 1 );
|
||||
//$page = ceil( ( ( (int) $offset ) / $per_page ) + 1 );
|
||||
|
||||
$this->total_items = count( $response );
|
||||
|
||||
|
@ -357,12 +362,15 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
|
||||
/**
|
||||
* set attributes for term metadata
|
||||
*
|
||||
* @param $args
|
||||
* @param $response
|
||||
*/
|
||||
private function set_pagination_properties_term_type( $args, $response ){
|
||||
|
||||
if(isset($args['number'], $args['offset'])){
|
||||
$number = $args['number'];
|
||||
$offset = $args['offset'];
|
||||
//$offset = $args['offset'];
|
||||
|
||||
unset( $args['number'], $args['offset'] );
|
||||
$total_terms = wp_count_terms( $this->taxonomy->get_db_identifier(), $args );
|
||||
|
@ -372,7 +380,7 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
}
|
||||
|
||||
$per_page = (int) $number;
|
||||
$page = ceil( ( ( (int) $offset ) / $per_page ) + 1 );
|
||||
//$page = ceil( ( ( (int) $offset ) / $per_page ) + 1 );
|
||||
|
||||
$this->total_items = (int) $total_terms ;
|
||||
|
||||
|
@ -390,6 +398,8 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
*
|
||||
* @param $request
|
||||
* @param $taxonomy_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTaxonomySelectedValues($request, $taxonomy_id){
|
||||
$selected = [];
|
||||
|
@ -414,6 +424,8 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
*
|
||||
* @param $request
|
||||
* @param $metadatum_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTextSelectedValues($request, $metadatum_id){
|
||||
if( isset($request['current_query']['metaquery']) ){
|
||||
|
@ -435,6 +447,8 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
*
|
||||
* @param $request
|
||||
* @param $metadatum_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getRelationshipSelectedValues($request, $metadatum_id){
|
||||
$selected = [];
|
||||
|
@ -468,13 +482,15 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $rows
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_values( $rows ){
|
||||
$values = [];
|
||||
|
||||
foreach( $rows as $row ){
|
||||
$values[] = $row['mvalue'];
|
||||
$values[] = $row->mvalue;
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
@ -483,10 +499,11 @@ class REST_Facets_Controller extends REST_Controller {
|
|||
/**
|
||||
* method responsible to return the total of items for the facet value
|
||||
*
|
||||
* @param value string/int the facet value
|
||||
* @param reference_id int the taxonomy or the metadataid
|
||||
* @param is_taxonomy (default) false if the value param is a term
|
||||
* @param query the actual request query to filter the items
|
||||
* @param $value
|
||||
* @param $reference_id
|
||||
* @param bool $is_taxonomy
|
||||
* @param $query
|
||||
* @param $collection_id
|
||||
*
|
||||
* @return int total of items found
|
||||
*/
|
||||
|
|
|
@ -59,11 +59,7 @@
|
|||
this.$console.log(error);
|
||||
});
|
||||
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.cleanSearch();
|
||||
})
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -98,10 +94,16 @@
|
|||
});
|
||||
this.selectedValues();
|
||||
},
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
if (query != '') {
|
||||
let promise = null;
|
||||
this.options = [];
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
|
||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
||||
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
|
||||
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
|
||||
|
@ -111,13 +113,17 @@
|
|||
promise = this.getValuesPlainText( this.metadatum, query, this.isRepositoryLevel );
|
||||
}
|
||||
|
||||
promise.catch( error => {
|
||||
promise.request.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.getOptionsValuesCancel = promise.source;
|
||||
|
||||
} else {
|
||||
this.cleanSearch();
|
||||
}
|
||||
},
|
||||
}, 500),
|
||||
selectedValues(){
|
||||
const instance = this;
|
||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||
|
@ -162,6 +168,10 @@
|
|||
return false;
|
||||
}
|
||||
},
|
||||
cleanSearchFromTags(filterTag) {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.cleanSearch();
|
||||
},
|
||||
cleanSearch(){
|
||||
this.results = '';
|
||||
this.label = '';
|
||||
|
@ -173,6 +183,9 @@
|
|||
value: ''
|
||||
});
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
export default {
|
||||
created(){
|
||||
|
||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id;
|
||||
const vm = this;
|
||||
|
@ -55,38 +56,7 @@
|
|||
this.$console.log(error);
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option == filterTag.singleValue);
|
||||
let optionIndex = this.options.findIndex(option => option.label == filterTag.singleValue);
|
||||
let alternativeIndex;
|
||||
|
||||
if (optionIndex >= 0) {
|
||||
alternativeIndex = this.selected.findIndex(option => this.options[optionIndex].value == option);
|
||||
}
|
||||
|
||||
if (selectedIndex >= 0 || alternativeIndex >= 0) {
|
||||
|
||||
selectedIndex >= 0 ? this.selected.splice(selectedIndex, 1) : this.selected.splice(alternativeIndex, 1);
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'checkbox',
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.selectedValues();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
},
|
||||
props: {
|
||||
isRepositoryLevel: Boolean,
|
||||
|
@ -112,46 +82,56 @@
|
|||
methods: {
|
||||
loadOptions(){
|
||||
let promise = null;
|
||||
this.isLoading = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
||||
this.isLoading = true;
|
||||
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
|
||||
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
|
||||
|
||||
promise = this.getValuesRelationship( collectionTarget, null, [], 0, this.filter.max_options, false, '1');
|
||||
promise
|
||||
promise.request
|
||||
.then(() => {
|
||||
|
||||
this.isLoading = false;
|
||||
if(this.options.length > this.filter.max_options){
|
||||
this.options.splice(this.filter.max_options);
|
||||
}
|
||||
this.selectedValues();
|
||||
}).catch((error) => {
|
||||
this.$console.error(error);
|
||||
})
|
||||
} else {
|
||||
this.isLoading = true;
|
||||
promise = this.getValuesPlainText( this.metadatum, null, this.isRepositoryLevel, [], 0, this.filter.max_options, false, '1' );
|
||||
promise
|
||||
promise.request
|
||||
.then(() => {
|
||||
|
||||
this.isLoading = false;
|
||||
if(this.options.length > this.filter.max_options){
|
||||
this.options.splice(this.filter.max_options);
|
||||
}
|
||||
this.selectedValues();
|
||||
}).catch((error) => {
|
||||
this.$console.error(error);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
promise
|
||||
.then(() => {
|
||||
this.isLoading = false;
|
||||
this.selectedValues()
|
||||
})
|
||||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
this.isLoading = false;
|
||||
});
|
||||
// promise.request
|
||||
// .then(() => {
|
||||
// this.isLoading = false;
|
||||
|
||||
// })
|
||||
// .catch( error => {
|
||||
// this.$console.log('error select', error );
|
||||
// this.isLoading = false;
|
||||
// });
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.getOptionsValuesCancel = promise.source;
|
||||
|
||||
},
|
||||
onSelect(){
|
||||
this.$emit('input', {
|
||||
|
@ -213,7 +193,42 @@
|
|||
appliedCheckBoxModal: () => this.loadOptions()
|
||||
}
|
||||
});
|
||||
},
|
||||
cleanSearchFromTags(filterTag) {
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option == filterTag.singleValue);
|
||||
let optionIndex = this.options.findIndex(option => option.label == filterTag.singleValue);
|
||||
let alternativeIndex;
|
||||
|
||||
if (optionIndex >= 0) {
|
||||
alternativeIndex = this.selected.findIndex(option => this.options[optionIndex].value == option);
|
||||
}
|
||||
|
||||
if (selectedIndex >= 0 || alternativeIndex >= 0) {
|
||||
|
||||
selectedIndex >= 0 ? this.selected.splice(selectedIndex, 1) : this.selected.splice(alternativeIndex, 1);
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'checkbox',
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.selectedValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -69,10 +69,7 @@
|
|||
this.$console.log(error);
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.clearSearch();
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -193,6 +190,10 @@
|
|||
// return this.value_init + ' - ' +this.value_end;
|
||||
// }
|
||||
},
|
||||
cleanSearchFromTags(filterTag) {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.cleanSearch();
|
||||
},
|
||||
clearSearch(){
|
||||
|
||||
this.clear = true;
|
||||
|
@ -281,6 +282,9 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import qs from 'qs';
|
||||
import { tainacan as axios } from '../../js/axios/axios';
|
||||
import axios from '../../js/axios/axios';
|
||||
|
||||
export const filter_type_mixin = {
|
||||
data () {
|
||||
return {
|
||||
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png'
|
||||
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
|
||||
getOptionsValuesCancel: undefined
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -19,7 +20,17 @@ export const filter_type_mixin = {
|
|||
},
|
||||
methods: {
|
||||
getValuesPlainText(metadatumId, search, isRepositoryLevel, valuesToIgnore, offset, number, isInCheckboxModal, getSelected = '0') {
|
||||
let query_items = { 'current_query': this.query };
|
||||
|
||||
const source = axios.CancelToken.source();
|
||||
|
||||
let currentQuery = JSON.parse(JSON.stringify(this.query));
|
||||
if (currentQuery.fetch_only != undefined) {
|
||||
for (let key of Object.keys(currentQuery.fetch_only)) {
|
||||
if (currentQuery.fetch_only[key] == null)
|
||||
delete currentQuery.fetch_only[key];
|
||||
}
|
||||
}
|
||||
let query_items = { 'current_query': currentQuery };
|
||||
|
||||
let url = `/collection/${this.collection}/facets/${metadatumId}?getSelected=${getSelected}&`;
|
||||
|
||||
|
@ -36,10 +47,12 @@ export const filter_type_mixin = {
|
|||
} else if(search){
|
||||
url += `search=${search}&` + qs.stringify(query_items);
|
||||
} else {
|
||||
url += qs.stringify(query_items, { addQueryPrefix: true });
|
||||
url += qs.stringify(query_items);
|
||||
}
|
||||
|
||||
return axios.get(url)
|
||||
return new Object ({
|
||||
request:
|
||||
axios.tainacan.get(url, { cancelToken: source.token })
|
||||
.then(res => {
|
||||
let sResults = [];
|
||||
let opts = [];
|
||||
|
@ -98,12 +111,28 @@ export const filter_type_mixin = {
|
|||
}
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.error(error);
|
||||
.catch((thrown) => {
|
||||
if (axios.isCancel(thrown)) {
|
||||
console.log('Request canceled: ', thrown.message);
|
||||
} else {
|
||||
reject(thrown);
|
||||
}
|
||||
}),
|
||||
source: source
|
||||
});
|
||||
},
|
||||
getValuesRelationship(collectionTarget, search, valuesToIgnore, offset, number, isInCheckboxModal, getSelected = '0') {
|
||||
let query_items = { 'current_query': this.query };
|
||||
|
||||
const source = axios.CancelToken.source();
|
||||
|
||||
let currentQuery = JSON.parse(JSON.stringify(this.query));
|
||||
if (currentQuery.fetch_only != undefined) {
|
||||
for (let key of Object.keys(currentQuery.fetch_only)) {
|
||||
if (currentQuery.fetch_only[key] == null)
|
||||
delete currentQuery.fetch_only[key];
|
||||
}
|
||||
}
|
||||
let query_items = { 'current_query': currentQuery };
|
||||
let url = '/collection/' + this.filter.collection_id + '/facets/' + this.filter.metadatum.metadatum_id + `?getSelected=${getSelected}&`;
|
||||
|
||||
if(offset != undefined && number != undefined){
|
||||
|
@ -116,7 +145,9 @@ export const filter_type_mixin = {
|
|||
url += `&search=${search}`;
|
||||
}
|
||||
|
||||
return axios.get(url + '&fetch_only[0]=thumbnail&fetch_only[1]=title&fetch_only[2]=id&' + qs.stringify(query_items))
|
||||
return new Object ({
|
||||
request:
|
||||
axios.tainacan.get(url + '&fetch_only[0]=thumbnail&fetch_only[1]=title&fetch_only[2]=id&' + qs.stringify(query_items))
|
||||
.then(res => {
|
||||
let sResults = [];
|
||||
let opts = [];
|
||||
|
@ -181,6 +212,8 @@ export const filter_type_mixin = {
|
|||
})
|
||||
.catch(error => {
|
||||
this.$console.error(error);
|
||||
}),
|
||||
source: source
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,10 +46,7 @@
|
|||
this.$console.error(error);
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.onSelect();
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
},
|
||||
props: {
|
||||
isRepositoryLevel: Boolean,
|
||||
|
@ -81,16 +78,24 @@
|
|||
loadOptions(){
|
||||
this.isLoading = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
let promise = null;
|
||||
promise = this.getValuesPlainText( this.metadatum, null, this.isRepositoryLevel );
|
||||
|
||||
promise.then(() => {
|
||||
promise.request
|
||||
.then(() => {
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch( error => {
|
||||
this.$console.error('error select', error );
|
||||
this.isLoading = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.getOptionsValuesCancel = promise.source;
|
||||
},
|
||||
onSelect(value){
|
||||
this.selected = value;
|
||||
|
@ -120,7 +125,14 @@
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
cleanSearchFromTags(filterTag) {
|
||||
if (filterTag.filterId == this.filter.id)
|
||||
this.onSelect();
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -60,37 +60,7 @@
|
|||
this.$console.log(error);
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
let values = [];
|
||||
let labels = [];
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
labels.push( val.label );
|
||||
}
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'taginput',
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
value: values
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: labels
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -134,7 +104,7 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
let promise = null;
|
||||
this.options = [];
|
||||
let valuesToIgnore = [];
|
||||
|
@ -142,6 +112,10 @@
|
|||
for(let val of this.selected)
|
||||
valuesToIgnore.push( val.value );
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
||||
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
|
||||
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
|
||||
|
@ -151,11 +125,15 @@
|
|||
promise = this.getValuesPlainText( this.metadatum, query, this.isRepositoryLevel, valuesToIgnore );
|
||||
}
|
||||
|
||||
promise
|
||||
promise.request
|
||||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
});
|
||||
},
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.getOptionsValuesCancel = promise.source;
|
||||
|
||||
}, 500),
|
||||
selectedValues(){
|
||||
const instance = this;
|
||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||
|
@ -188,7 +166,41 @@
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
cleanSearchFromTags(filterTag) {
|
||||
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
let values = [];
|
||||
let labels = [];
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
labels.push( val.label );
|
||||
}
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'taginput',
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
value: values
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: labels
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -37,37 +37,7 @@
|
|||
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
|
||||
this.loadOptions();
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedOption = this.options.find(option => option.label == filterTag.singleValue);
|
||||
|
||||
if(selectedOption) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option == selectedOption.value);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'checkbox',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
terms: this.selected
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.selectedValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTag);
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -237,9 +207,43 @@
|
|||
},
|
||||
width: 'calc(100% - 8.333333333%)',
|
||||
});
|
||||
},
|
||||
cleanSearchFromTag(filterTag) {
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedOption = this.options.find(option => option.label == filterTag.singleValue);
|
||||
|
||||
if(selectedOption) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option == selectedOption.value);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'checkbox',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
terms: this.selected
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
this.selectedValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -38,38 +38,7 @@
|
|||
this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
let values = [];
|
||||
let labels = [];
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
labels.push( val.label );
|
||||
}
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'taginput',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
terms: values
|
||||
});
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: labels
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTag);
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -124,7 +93,7 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
this.isLoading = true;
|
||||
this.options = [];
|
||||
|
||||
|
@ -161,7 +130,7 @@
|
|||
this.isLoading = false;
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
}, 500),
|
||||
selectedValues( taxonomy ){
|
||||
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
|
||||
return false;
|
||||
|
@ -185,7 +154,42 @@
|
|||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
cleanSearchFromTag(filterTag) {
|
||||
|
||||
if (filterTag.filterId == this.filter.id) {
|
||||
|
||||
let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
|
||||
if (selectedIndex >= 0) {
|
||||
|
||||
this.selected.splice(selectedIndex, 1);
|
||||
|
||||
let values = [];
|
||||
let labels = [];
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
labels.push( val.label );
|
||||
}
|
||||
|
||||
this.$emit('input', {
|
||||
filter: 'taginput',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
terms: values
|
||||
});
|
||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
||||
filterId: this.filter.id,
|
||||
value: labels
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -996,7 +996,7 @@ class Metadata extends Repository {
|
|||
);
|
||||
}
|
||||
|
||||
$pre_result = $wpdb->get_results( $sql_string, ARRAY_A );
|
||||
$pre_result = $wpdb->get_results( $sql_string, OBJECT );
|
||||
|
||||
if ( ! empty( $pre_result ) ) {
|
||||
foreach ( $pre_result as $pre ) {
|
||||
|
@ -1045,7 +1045,7 @@ class Metadata extends Repository {
|
|||
);
|
||||
}
|
||||
|
||||
$pre_result = $wpdb->get_results( $sql_string, ARRAY_A );
|
||||
$pre_result = $wpdb->get_results( $sql_string, OBJECT );
|
||||
|
||||
if ( ! empty( $pre_result ) ) {
|
||||
foreach ( $pre_result as $pre ) {
|
||||
|
|
|
@ -753,10 +753,11 @@ abstract class Repository {
|
|||
$key_array = array();
|
||||
|
||||
foreach ( $array as $val ) {
|
||||
if ( ! in_array( $val[ $key ], $key_array ) ) {
|
||||
$key_array[ $i ] = $val[ $key ];
|
||||
if ( ! in_array( $val->$key, $key_array ) ) {
|
||||
$key_array[ $i ] = $val->$key;
|
||||
$temp_array[ $i ] = $val;
|
||||
}
|
||||
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ class CSV extends Exporter {
|
|||
|
||||
public function __construct($attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
$this->set_mapping_method('any');
|
||||
$this->set_mapping_method('any'); // set all method to mapping
|
||||
//$this->set_mapping_method('list', [ "dublin-core" => "Tainacan\\Exposers\\Mappers\\Dublin_Core" ]); // set specific list of methods to mapping
|
||||
}
|
||||
|
||||
public function process_item( $index, $collection_definition ) {
|
||||
|
@ -16,7 +17,7 @@ class CSV extends Exporter {
|
|||
$tainacan_items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$filters = [
|
||||
'posts_per_page' => 12,
|
||||
'posts_per_page' => 1,
|
||||
'paged' => $index+1,
|
||||
'order' => 'DESC'
|
||||
];
|
||||
|
@ -27,12 +28,87 @@ class CSV extends Exporter {
|
|||
while ($items->have_posts()) {
|
||||
$items->the_post();
|
||||
$item = new Entities\Item($items->post);
|
||||
$export_items .= json_encode($item);
|
||||
$printCol = $index == 0;
|
||||
$export_items .= $this->get_item_csv($item, $printCol);
|
||||
$this->add_log('export_items ' . $export_items );
|
||||
}
|
||||
wp_reset_postdata();
|
||||
return $export_items;
|
||||
}
|
||||
|
||||
private function get_item_csv($item, $printCol) {
|
||||
$items_metadata = $item->get_metadata();
|
||||
$prepared_item = [];
|
||||
foreach ($items_metadata as $item_metadata) {
|
||||
array_push($prepared_item, $item_metadata->_toArray());
|
||||
}
|
||||
$mapper = $this->mapping_list[$this->mapping_selected];
|
||||
$instance_mapper = new $mapper();
|
||||
$data = $this->map($prepared_item, $instance_mapper);
|
||||
return $this->str_putcsv($data, ',', '"', $printCol);
|
||||
}
|
||||
|
||||
protected function map($item_arr, $mapper) {
|
||||
$ret = $item_arr;
|
||||
if(array_key_exists('metadatum', $item_arr)) { // getting a unique metadatum
|
||||
$ret = $this->map_metadatum($item_arr, $mapper);
|
||||
} else { // array of elements
|
||||
$ret = [];
|
||||
foreach ($item_arr as $item) {
|
||||
if(array_key_exists('metadatum', $item)) {
|
||||
$ret = array_merge($ret, $this->map($item, $mapper) );
|
||||
} else {
|
||||
$ret[] = $this->map($item, $mapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function map_metadatum($item_arr, $mapper) {
|
||||
$ret = $item_arr;
|
||||
$metadatum_mapping = $item_arr['metadatum']['exposer_mapping'];
|
||||
if(array_key_exists($mapper->slug, $metadatum_mapping)) {
|
||||
if(
|
||||
is_string($metadatum_mapping[$mapper->slug]) && is_array($mapper->metadata) && !array_key_exists( $metadatum_mapping[$mapper->slug], $mapper->metadata) ||
|
||||
is_array($metadatum_mapping[$mapper->slug]) && $mapper->allow_extra_metadata != true
|
||||
) {
|
||||
throw new \Exception('Invalid Mapper Option');
|
||||
}
|
||||
$slug = '';
|
||||
if(is_string($metadatum_mapping[$mapper->slug])) {
|
||||
$slug = $metadatum_mapping[$mapper->slug];
|
||||
} else {
|
||||
$slug = $metadatum_mapping[$mapper->slug]['slug'];
|
||||
}
|
||||
$ret = [$mapper->prefix.$slug.$mapper->sufix => $item_arr['value']];
|
||||
} elseif($mapper->slug == 'value') {
|
||||
$ret = [$item_arr['metadatum']['name'] => $item_arr['value']];
|
||||
} else {
|
||||
$ret = [];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function str_putcsv($item, $delimiter = ',', $enclosure = '"', $printCol = false) {
|
||||
// Open a memory "file" for read/write...
|
||||
$fp = fopen('php://temp', 'r+');
|
||||
$out=[];
|
||||
$col=[];
|
||||
foreach ($item as $key => $value) {
|
||||
$col[] = $key;
|
||||
$out[] = $value;
|
||||
}
|
||||
if ($printCol) {
|
||||
fputcsv($fp, $col, $delimiter, $enclosure);
|
||||
}
|
||||
fputcsv($fp, $out, $delimiter, $enclosure);
|
||||
rewind($fp);
|
||||
$data = fread($fp, 1048576);
|
||||
fclose($fp);
|
||||
return rtrim($data, "\n");
|
||||
}
|
||||
|
||||
public function options_form() {
|
||||
ob_start();
|
||||
?>
|
||||
|
|
|
@ -469,10 +469,10 @@ class Exporter extends CommunImportExport {
|
|||
private $output_files = [];
|
||||
private $mapping_accept = [
|
||||
'any' => true,
|
||||
'list' => false,
|
||||
'none' => false,
|
||||
'list' => false
|
||||
];
|
||||
private $mapping_list = [];
|
||||
protected $mapping_list = [];
|
||||
public $mapping_selected = "";
|
||||
|
||||
public function __construct($attributess = array()) {
|
||||
$this->array_attributes = array_merge($this->array_attributes, ['current_collection_item', 'current_collection']);
|
||||
|
@ -488,6 +488,7 @@ class Exporter extends CommunImportExport {
|
|||
}
|
||||
}
|
||||
|
||||
//"Tainacan\\Exposers\\Mappers\\Value"
|
||||
public function _to_Array($short = false) {
|
||||
$return = ['id' => $this->get_id()];
|
||||
foreach ($this->array_attributes as $attr) {
|
||||
|
@ -501,7 +502,7 @@ class Exporter extends CommunImportExport {
|
|||
|
||||
if ($short === false) {
|
||||
$return['manual_collection'] = $exporter_definition['manual_collection'];
|
||||
$return['manual_mapping'] = $exporter_definition['manual_mapping'];
|
||||
$return['mapping_selected'] = $this->mapping_selected;
|
||||
$return['mapping_accept'] = $this->mapping_accept;
|
||||
$return['mapping_list'] = $this->mapping_list;
|
||||
$return['output_files'] = $this->output_files;
|
||||
|
@ -595,25 +596,39 @@ class Exporter extends CommunImportExport {
|
|||
}
|
||||
}
|
||||
|
||||
public function set_mapping_method($method, $list = []) {
|
||||
public function set_mapping_method($method, $default_mapping = 'value', $list = []) {
|
||||
if ( array_key_exists($method, $this->mapping_accept) ) {
|
||||
foreach ($this->mapping_accept as &$value) {
|
||||
$value = false;
|
||||
}
|
||||
$this->mapping_accept[$method] = true;
|
||||
if(!empty($list)) {
|
||||
if($method == 'any') {
|
||||
$Tainacan_Exposers = \Tainacan\Exposers\Exposers::get_instance();
|
||||
$metadatum_mappers = $Tainacan_Exposers->get_mappers();
|
||||
$this->mapping_list = $metadatum_mappers;
|
||||
} else if(!empty($list)) {
|
||||
$this->mapping_list = $list;
|
||||
}
|
||||
$this->mapping_selected = $default_mapping;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function set_mapping_selected($mapping_selected) {
|
||||
$this->mapping_selected = $mapping_selected;
|
||||
}
|
||||
|
||||
public function finished() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* runs one iteration
|
||||
*/
|
||||
public function run() {
|
||||
if ($this->is_finished()) {
|
||||
$this->finished();
|
||||
return false;
|
||||
}
|
||||
$steps = $this->get_steps();
|
||||
|
|
|
@ -25,14 +25,28 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
},
|
||||
selectedCollections: {
|
||||
type: 'array',
|
||||
source: 'html',
|
||||
source: 'query',
|
||||
selector: 'div',
|
||||
default: [],
|
||||
query: {
|
||||
dataValue: { source: 'attribute', attribute: 'data-value'},
|
||||
},
|
||||
featuredItems: {
|
||||
default: []
|
||||
},
|
||||
items: {
|
||||
type: 'array',
|
||||
source: 'html',
|
||||
selector: 'div',
|
||||
source: 'query',
|
||||
selector: 'picture',
|
||||
query: {
|
||||
style: { source: 'attribute', attribute: 'style'},
|
||||
img: {
|
||||
source: 'query',
|
||||
selector: 'img',
|
||||
query: {
|
||||
src: { source: 'attribute', attribute: 'src'},
|
||||
alt: { source: 'attribute', attribute: 'alt' },
|
||||
}
|
||||
}
|
||||
},
|
||||
default: [],
|
||||
},
|
||||
content1: {
|
||||
|
@ -42,7 +56,7 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
default: [],
|
||||
},
|
||||
content: {
|
||||
type: 'array',
|
||||
type: 'string',
|
||||
source: 'html',
|
||||
selector: 'div',
|
||||
default: []
|
||||
|
@ -52,10 +66,22 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
align: ['full']
|
||||
},
|
||||
edit({ attributes, setAttributes, className }) {
|
||||
console.log('edit', attributes);
|
||||
|
||||
function prepareCollection(collection) {
|
||||
return (<div key={ collection.id } data-value={collection}>{ collection.name }</div>);
|
||||
}
|
||||
|
||||
function prepareItem(item, style) {
|
||||
return (
|
||||
<picture style={style}>
|
||||
<img
|
||||
src={item.thumbnail.thumb ? item.thumbnail.thumb : 'https://dummyimage.com/150x150/cccccc/000000.png&text=+++NO+THUMBNAIL'}
|
||||
alt={item.title} />
|
||||
</picture>
|
||||
);
|
||||
}
|
||||
|
||||
function getTop3ItemsOf(collection) {
|
||||
let collectionID = collection.id;
|
||||
|
||||
|
@ -70,7 +96,7 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
});
|
||||
}
|
||||
|
||||
function prepareContent(content, featuredItems, setAttributes, collection){
|
||||
function prepareContent(content, items, setAttributes, collection){
|
||||
content.push(
|
||||
<div style={{display: 'flex', flexDirection: 'column', marginRight: '20px'}}>
|
||||
<div
|
||||
|
@ -78,27 +104,17 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
key={collection.id}>
|
||||
|
||||
<div style={{width: '99px', marginRight: '3px'}} className={`${className}__carousel-item-first`}>
|
||||
{featuredItems[0] ?
|
||||
<picture>
|
||||
<img src={featuredItems[0].thumbnail.thumb} alt={featuredItems[0].title}/>
|
||||
</picture> : null
|
||||
}
|
||||
{items[0] ? prepareItem(items[0]) : null}
|
||||
</div>
|
||||
|
||||
<div className={`${className}__carousel-item-others`}>
|
||||
{featuredItems[1] ?
|
||||
<picture style={{width: '42px', height: '42px', marginBottom: '3px'}}>
|
||||
<img src={featuredItems[1].thumbnail.thumb} alt={featuredItems[1].title}/>
|
||||
</picture> : null
|
||||
}
|
||||
{featuredItems[2] ?
|
||||
<picture style={{width: '42px', height: '42px'}}>
|
||||
<img src={featuredItems[2].thumbnail.thumb} alt={featuredItems[2].title}/>
|
||||
</picture> : null
|
||||
}
|
||||
{items[1] ? prepareItem(items[1], {width: '42px', height: '42px', marginBottom: '3px'}) : null}
|
||||
{items[2] ? prepareItem(items[2], {width: '42px', height: '42px'}) : null}
|
||||
</div>
|
||||
</div>
|
||||
<small><b>{collection.name}</b></small>
|
||||
<small>
|
||||
<b>{collection.name}</b>
|
||||
</small>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
@ -137,11 +153,13 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
attributes.selectedCollections.push(prepareCollection(option));
|
||||
|
||||
getTop3ItemsOf(option).then((res) => {
|
||||
attributes.featuredItems.push(res);
|
||||
res.map((item) => {
|
||||
attributes.items.push(prepareItem(item))
|
||||
});
|
||||
|
||||
prepareContent(attributes.content1, res, setAttributes, option);
|
||||
|
||||
setAttributes({ featuredItems: attributes.featuredItems });
|
||||
setAttributes({ items: attributes.items });
|
||||
});
|
||||
|
||||
setAttributes({ selectedCollections: attributes.selectedCollections });
|
||||
|
@ -160,7 +178,20 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
<Modal
|
||||
shouldCloseOnClickOutside={ false }
|
||||
title={ __('Add collection', 'tainacan') }
|
||||
onRequestClose={ () => setAttributes( { isOpen: false } ) }>
|
||||
onRequestClose={ () => {
|
||||
setAttributes( { isOpen: false } );
|
||||
setAttributes({
|
||||
content: (
|
||||
<div>
|
||||
{attributes.content1.length ?
|
||||
<Carousel
|
||||
slidesPerScroll={1}
|
||||
slidesPerPage={attributes.content1.length >= 3 ? 3 : attributes.content1.length}
|
||||
arrows
|
||||
slides={attributes.content1}/> : null
|
||||
}</div>
|
||||
)});
|
||||
}}>
|
||||
|
||||
<div>
|
||||
<Autocomplete completers={ autoCompleters }>
|
||||
|
@ -179,7 +210,20 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
<p>{ __('Type '+ autoCompleters[0].triggerPrefix +' for triggering the autocomplete.', 'tainacan') }</p>
|
||||
</div>
|
||||
|
||||
<Button isDefault onClick={ () => setAttributes( { isOpen: false } ) }>
|
||||
<Button isDefault onClick={ () => {
|
||||
setAttributes( { isOpen: false } );
|
||||
setAttributes({
|
||||
content: (
|
||||
<div>
|
||||
{attributes.content1.length ?
|
||||
<Carousel
|
||||
slidesPerScroll={1}
|
||||
slidesPerPage={attributes.content1.length >= 3 ? 3 : attributes.content1.length}
|
||||
arrows
|
||||
slides={attributes.content1}/> : null
|
||||
}</div>
|
||||
)});
|
||||
} }>
|
||||
{ __('Close', 'tainacan') }
|
||||
</Button>
|
||||
</Modal>
|
||||
|
@ -187,24 +231,28 @@ registerBlockType('tainacan/collections-carousel', {
|
|||
}
|
||||
|
||||
<div>
|
||||
{attributes.content1.length ?
|
||||
<Carousel
|
||||
slidesPerScroll={1}
|
||||
slidesPerPage={attributes.content1.length >= 3 ? 3 : attributes.content1.length}
|
||||
arrows
|
||||
slides={attributes.content1}/>
|
||||
slides={attributes.content1}/> : null
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
save({ attributes }) {
|
||||
return (
|
||||
<div>
|
||||
<Carousel
|
||||
slidesPerScroll={1}
|
||||
slidesPerPage={attributes.content1.length >= 3 ? 3 : attributes.content1.length}
|
||||
arrows
|
||||
slides={attributes.content1}/>
|
||||
</div>
|
||||
);
|
||||
// return (
|
||||
// <div>
|
||||
// <Carousel
|
||||
// slidesPerScroll={1}
|
||||
// slidesPerPage={attributes.content1.length >= 3 ? 3 : attributes.content1.length}
|
||||
// arrows
|
||||
// slides={attributes.content1}/>
|
||||
// </div>
|
||||
// );
|
||||
|
||||
return attributes.content;
|
||||
},
|
||||
});
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tainacan\Importer;
|
||||
use Tainacan;
|
||||
use Tainacan\Entities;
|
||||
|
||||
class CSV extends Importer {
|
||||
|
||||
|
@ -140,6 +141,10 @@ class CSV extends Importer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if( $this->get_option('item_id_index') ){
|
||||
$this->handle_item_id( $values );
|
||||
}
|
||||
|
||||
foreach ( $collection_definition['mapping'] as $metadatum_id => $header) {
|
||||
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
|
||||
|
||||
|
@ -562,6 +567,9 @@ class CSV extends Importer {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $status string the item ID
|
||||
*/
|
||||
private function handle_item_id( $values ){
|
||||
$item_id_index = $this->set_option('item_id_index');
|
||||
|
||||
|
@ -570,4 +578,151 @@ class CSV extends Importer {
|
|||
$this->add_transient( 'item_action',$this->get_option('repeated_item') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* insert processed item from source to Tainacan
|
||||
*
|
||||
* @param array $processed_item Associative array with metadatum source's as index with
|
||||
* its value or values
|
||||
* @param integet $collection_index The index in the $this->collections array of the collection the item is beeing inserted into
|
||||
*
|
||||
* @return Tainacan\Entities\Item Item inserted
|
||||
*/
|
||||
public function insert( $processed_item, $collection_index ) {
|
||||
|
||||
remove_action( 'post_updated', 'wp_save_post_revision' );
|
||||
$collections = $this->get_collections();
|
||||
$collection_definition = isset($collections[$collection_index]) ? $collections[$collection_index] : false;
|
||||
if ( !$collection_definition || !is_array($collection_definition) || !isset($collection_definition['id']) || !isset($collection_definition['mapping']) ) {
|
||||
$this->add_error_log('Collection misconfigured');
|
||||
return false;
|
||||
}
|
||||
|
||||
$collection = \Tainacan\Repositories\Collections::get_instance()->fetch($collection_definition['id']);
|
||||
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$Tainacan_Items->disable_logs();
|
||||
$Tainacan_Metadata->disable_logs();
|
||||
$Tainacan_Item_Metadata->disable_logs();
|
||||
|
||||
$item = new Entities\Item( ( $this->get_transient('item_id') ) ? $this->get_transient('item_id') : 0 );
|
||||
$itemMetadataArray = [];
|
||||
|
||||
if( is_array( $processed_item ) ){
|
||||
foreach ( $processed_item as $metadatum_source => $values ){
|
||||
$tainacan_metadatum_id = array_search( $metadatum_source, $collection_definition['mapping'] );
|
||||
$metadatum = $Tainacan_Metadata->fetch( $tainacan_metadatum_id );
|
||||
|
||||
if( $metadatum instanceof Entities\Metadatum ){
|
||||
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach
|
||||
|
||||
if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy' ){
|
||||
|
||||
$ids = $this->insert_hierarchy( $metadatum, $values );
|
||||
$singleItemMetadata->set_value( $ids );
|
||||
} else {
|
||||
$singleItemMetadata->set_value( $values );
|
||||
}
|
||||
|
||||
$itemMetadataArray[] = $singleItemMetadata;
|
||||
} else {
|
||||
$this->add_error_log('Metadata ' . $metadatum_source . ' not found');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty( $itemMetadataArray ) && $collection instanceof Entities\Collection ){
|
||||
$item->set_collection( $collection );
|
||||
|
||||
if( $item->validate() ){
|
||||
$insertedItem = $Tainacan_Items->insert( $item );
|
||||
} else {
|
||||
$this->add_error_log( 'Error inserting item' );
|
||||
$this->add_error_log( $item->get_errors() );
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $itemMetadataArray as $itemMetadata ) {
|
||||
$itemMetadata->set_item( $insertedItem ); // *I told you
|
||||
|
||||
if( $itemMetadata->validate() ){
|
||||
$result = $Tainacan_Item_Metadata->insert( $itemMetadata );
|
||||
} else {
|
||||
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name());
|
||||
$this->add_error_log($itemMetadata->get_errors());
|
||||
continue;
|
||||
}
|
||||
|
||||
//if( $result ){
|
||||
// $values = ( is_array( $itemMetadata->get_value() ) ) ? implode( PHP_EOL, $itemMetadata->get_value() ) : $itemMetadata->get_value();
|
||||
// $this->add_log( 'Item ' . $insertedItem->get_id() .
|
||||
// ' has inserted the values: ' . $values . ' on metadata: ' . $itemMetadata->get_metadatum()->get_name() );
|
||||
//} else {
|
||||
// $this->add_error_log( 'Item ' . $insertedItem->get_id() . ' has an error' );
|
||||
//}
|
||||
}
|
||||
|
||||
$insertedItem->set_status('publish' );
|
||||
|
||||
if($insertedItem->validate()) {
|
||||
$insertedItem = $Tainacan_Items->update( $insertedItem );
|
||||
|
||||
$this->after_inserted_item( $insertedItem, $collection_index );
|
||||
} else {
|
||||
$this->add_error_log( 'Error publishing Item' );
|
||||
$this->add_error_log( $insertedItem->get_errors() );
|
||||
return false;
|
||||
}
|
||||
|
||||
return $insertedItem;
|
||||
|
||||
} else {
|
||||
$this->add_error_log( 'Collection not set');
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $metadatum the metadata
|
||||
* @param $values the categories names
|
||||
*
|
||||
* @return array empty with no category or array with IDs
|
||||
*/
|
||||
private function insert_hierarchy( $metadatum, $values ){
|
||||
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
|
||||
$taxonomy = new Entities\Taxonomy( $metadatum->get_metadata_type_options()['taxonomy_id']);
|
||||
$exploded_values = explode(">>",$values);
|
||||
|
||||
if( is_array($exploded_values) ){
|
||||
$parent = 0;
|
||||
|
||||
foreach ( $exploded_values as $key => $value) {
|
||||
$value = trim($value);
|
||||
|
||||
$exists = term_exists( $value ,$taxonomy->get_db_identifier(), $parent );
|
||||
if( 0 !== $exists && null !== $exists && isset($exists['term_id']) ){
|
||||
$exists = new Entities\Term($exists['term_id']);
|
||||
$parent = $term->get_id();
|
||||
} else {
|
||||
$term = new Entities\Term();
|
||||
$term->set_name( $value );
|
||||
$term->set_parent( $parent );
|
||||
$term->set_taxonomy( $taxonomy->get_db_identifier() );
|
||||
$term = $Tainacan_Terms->insert( $term );
|
||||
|
||||
$parent = $term->get_id();
|
||||
}
|
||||
}
|
||||
|
||||
return $parent !== 0 ? $parent : false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -786,7 +786,7 @@ abstract class Importer {
|
|||
$Tainacan_Metadata->disable_logs();
|
||||
$Tainacan_Item_Metadata->disable_logs();
|
||||
|
||||
$item = new Entities\Item();
|
||||
$item = new Entities\Item( ( $this->get_transient('item_id') ) ? $this->get_transient('item_id') : 0 );
|
||||
$itemMetadataArray = [];
|
||||
|
||||
if( is_array( $processed_item ) ){
|
||||
|
|
|
@ -118,6 +118,8 @@ class Old_Tainacan extends Importer{
|
|||
|
||||
if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) {
|
||||
$metadatum_id = $this->create_metadata( $metadata );
|
||||
} elseif ( strpos($metadata->slug, 'socialdb_property_fixed_tags') !== false ){
|
||||
$metadatum_id = $this->create_metadata( $metadata );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -150,6 +152,14 @@ class Old_Tainacan extends Importer{
|
|||
$map[$metadatum_id] = $metadatum_old->id;
|
||||
}
|
||||
|
||||
} else if( isset($metadatum_old->slug) && strpos($metadatum_old->slug, 'socialdb_property_fixed_tags') !== false
|
||||
&& isset($metadatum_old->type) && strpos($metadatum_old->type, 'checkbox') !== false
|
||||
){
|
||||
$metadatum_id = $this->create_metadata( $metadatum_old, $collection_id );
|
||||
$this->add_log('Creating tag');
|
||||
if( $metadatum_id ){
|
||||
$map[$metadatum_id] = $metadatum_old->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,10 +393,6 @@ class Old_Tainacan extends Importer{
|
|||
$value = $values;
|
||||
}
|
||||
|
||||
if( is_array($value) ){
|
||||
$value = array_filter($value);
|
||||
}
|
||||
|
||||
$item_metadata->set_value($value);
|
||||
|
||||
} else if( $metadatum->type === 'item' ){ // RELATIONSHIPS
|
||||
|
@ -711,6 +717,8 @@ class Old_Tainacan extends Importer{
|
|||
* @return int $metadatum_id
|
||||
*/
|
||||
protected function create_metadata( $node_metadata_old, $collection_id = null){
|
||||
$this->add_log('Creating metadata' . $meta->name);
|
||||
|
||||
$newMetadatum = new Entities\Metadatum();
|
||||
$meta = $node_metadata_old;
|
||||
|
||||
|
@ -841,7 +849,7 @@ class Old_Tainacan extends Importer{
|
|||
$type = "Numeric";
|
||||
} else if(strcmp($type, 'item') === 0) {
|
||||
$type = "Relationship";
|
||||
} else if(strcmp($type, 'tree') === 0 || strcmp($type, 'selectbox')) {
|
||||
} else if(strcmp($type, 'tree') === 0 || strcmp($type, 'selectbox') || strcmp($type, 'checkbox')) {
|
||||
$type = "Taxonomy";
|
||||
} else if(strcmp($type, 'compound') === 0) {
|
||||
$type = "Compound";
|
||||
|
|
|
@ -12,4 +12,7 @@ export const wp = axios.create({
|
|||
|
||||
wp.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
||||
|
||||
export default { tainacan, wp };
|
||||
export const CancelToken = axios.CancelToken;
|
||||
export const isCancel = axios.isCancel;
|
||||
|
||||
export default { tainacan, wp, CancelToken, isCancel };
|
|
@ -11,10 +11,10 @@ export default {
|
|||
query: {},
|
||||
collectionId: undefined,
|
||||
taxonomy: undefined,
|
||||
termId: undefined
|
||||
termId: undefined,
|
||||
searchCancel: undefined
|
||||
},
|
||||
created(){
|
||||
|
||||
created() {
|
||||
this.$on('input', data => {
|
||||
this.$store.dispatch('search/setPage', 1);
|
||||
|
||||
|
@ -212,16 +212,16 @@ export default {
|
|||
let error = this.errors.find( errorItem => errorItem.metadatum_id === filter_id );
|
||||
return ( error ) ? error.errors : false;
|
||||
},
|
||||
listener(){
|
||||
const components = this.getAllComponents();
|
||||
for (let eventElement of components){
|
||||
eventElement.addEventListener('input', (event) => {
|
||||
if( event.detail ) {
|
||||
this.add_metaquery( event.detail[0] );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// listener(){
|
||||
// const components = this.getAllComponents();
|
||||
// for (let eventElement of components){
|
||||
// eventElement.addEventListener('input', (event) => {
|
||||
// if( event.detail ) {
|
||||
// this.add_metaquery( event.detail[0] );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
setPage(page) {
|
||||
this.$store.dispatch('search/setPage', page);
|
||||
this.updateURLQueries();
|
||||
|
@ -305,13 +305,19 @@ export default {
|
|||
if (this.$store.getters['search/getPostQuery']['fetch_only'] == undefined) {
|
||||
this.$emit( 'hasToPrepareMetadataAndFilters', to);
|
||||
} else {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.searchCancel != undefined)
|
||||
this.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
this.$store.dispatch('collection/fetchItems', {
|
||||
'collectionId': this.collectionId,
|
||||
'isOnTheme': (this.$route.name == null),
|
||||
'termId': this.termId,
|
||||
'taxonomy': this.taxonomy
|
||||
})
|
||||
.then((res) => {
|
||||
}).then((resp) => {
|
||||
// The actual fetch item request
|
||||
resp.request.then((res) => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
this.$emit( 'hasFiltered', res.hasFiltered);
|
||||
|
||||
|
@ -322,6 +328,12 @@ export default {
|
|||
.catch(() => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.searchCancel = resp.source;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ export const eventBus = new Vue({
|
|||
if( tainacan_plugin.components ){
|
||||
this.componentsTag = tainacan_plugin.components;
|
||||
}
|
||||
this.$on('input', data => this.updateValue(data) );
|
||||
this.$on('input', this.updateValue );
|
||||
},
|
||||
watch: {
|
||||
errors() {
|
||||
|
@ -24,21 +24,21 @@ export const eventBus = new Vue({
|
|||
this.componentsTag.push( name );
|
||||
}
|
||||
},
|
||||
listener(){
|
||||
const components = this.getAllComponents();
|
||||
for (let eventElement of components){
|
||||
eventElement.addEventListener('input', (event) => {
|
||||
// listener(){
|
||||
// const components = this.getAllComponents();
|
||||
// for (let eventElement of components){
|
||||
// eventElement.addEventListener('input', (event) => {
|
||||
|
||||
if (event.detail && event.detail[0] ){
|
||||
this.updateValue({
|
||||
item_id: $(eventElement).attr("item_id"),
|
||||
metadatum_id: $(eventElement).attr("metadatum_id"),
|
||||
values: event.detail
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// if (event.detail && event.detail[0] ){
|
||||
// this.updateValue({
|
||||
// item_id: $(eventElement).attr("item_id"),
|
||||
// metadatum_id: $(eventElement).attr("metadatum_id"),
|
||||
// values: event.detail
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
updateValue(data){
|
||||
|
||||
this.$emit('isUpdatingValue', true);
|
||||
|
@ -128,6 +128,9 @@ export const eventBus = new Vue({
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeUpdate() {
|
||||
this.$off('input', this.updateValue );
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -10,6 +10,12 @@ export const createEditGroup = ({commit}, parameters) => {
|
|||
bulkEditParams = {
|
||||
items_ids: object,
|
||||
};
|
||||
if (parameters.order != undefined && parameters.order != undefined)
|
||||
bulkEditParams['options'] = {
|
||||
order: parameters.order,
|
||||
orderby: parameters.orderBy
|
||||
};
|
||||
|
||||
} else if(object.constructor.name === 'Object'){
|
||||
bulkEditParams = {
|
||||
use_query: object,
|
||||
|
@ -25,6 +31,21 @@ export const createEditGroup = ({commit}, parameters) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const fetchGroup = ({commit}, { collectionId, groupId }) => {
|
||||
|
||||
return new Promise ((resolve, reject) => {
|
||||
axios.tainacan.get(`/collection/${collectionId}/bulk-edit/${groupId}`)
|
||||
.then(response => {
|
||||
commit('setGroup', response.data);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const setValueInBulk = ({commit}, parameters) => {
|
||||
let groupID = parameters.groupID;
|
||||
let collectionID = parameters.collectionID;
|
||||
|
@ -169,3 +190,19 @@ export const deleteItemsInBulk = ({commit}, parameters) => {
|
|||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
||||
|
||||
// SEQUENCE EDIT SPECIFIC
|
||||
export const fetchItemIdInSequence = ({commit}, { collectionId, sequenceId, itemPosition }) => {
|
||||
|
||||
return new Promise ((resolve, reject) => {
|
||||
axios.tainacan.get(`/collection/${collectionId}/bulk-edit/${sequenceId}/sequence/${itemPosition}`)
|
||||
.then(response => {
|
||||
commit('setItemIdInSequence', response.data);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
|
@ -2,6 +2,14 @@ export const getGroupID = state => {
|
|||
return state.group.id;
|
||||
};
|
||||
|
||||
export const getGroup = state => {
|
||||
return state.group;
|
||||
};
|
||||
|
||||
export const getActionResult = state => {
|
||||
return state.actionResult;
|
||||
};
|
||||
|
||||
export const getItemIdInSequence = state => {
|
||||
return state.itemIdInSequence;
|
||||
};
|
|
@ -5,6 +5,7 @@ import * as getters from './getters.js'
|
|||
const state = {
|
||||
group: null,
|
||||
actionResult: null,
|
||||
itemIdInSequence: null
|
||||
};
|
||||
|
||||
export default {
|
||||
|
|
|
@ -5,3 +5,7 @@ export const setGroup = (state, group) => {
|
|||
export const setActionResult = (state, actionResult) => {
|
||||
state.actionResult = actionResult;
|
||||
};
|
||||
|
||||
export const setItemIdInSequence = (state, itemIdInSequence) => {
|
||||
state.itemIdInSequence = itemIdInSequence;
|
||||
};
|
|
@ -1,10 +1,14 @@
|
|||
import axios from '../../../axios/axios';
|
||||
import qs from 'qs';
|
||||
|
||||
// THE ITEMS SEARCH
|
||||
export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme, termId, taxonomy }) => {
|
||||
commit('cleanItems');
|
||||
|
||||
return new Promise ((resolve, reject) => {
|
||||
const source = axios.CancelToken.source();
|
||||
|
||||
return new Object({
|
||||
request: new Promise ((resolve, reject) => {
|
||||
|
||||
// Adds queries for filtering
|
||||
let postQueries = JSON.parse(JSON.stringify(rootGetters['search/getPostQuery']));
|
||||
|
@ -67,7 +71,9 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
postQueries.admin_view_mode = null;
|
||||
}
|
||||
|
||||
axios.tainacan.get(endpoint+query)
|
||||
axios.tainacan.get(endpoint+query, {
|
||||
cancelToken: source.token
|
||||
})
|
||||
.then(res => {
|
||||
|
||||
let items = res.data;
|
||||
|
@ -88,10 +94,16 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } );
|
||||
dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } );
|
||||
})
|
||||
.catch(error => reject(error));
|
||||
|
||||
.catch((thrown) => {
|
||||
if (axios.isCancel(thrown)) {
|
||||
console.log('Request canceled: ', thrown.message);
|
||||
} else {
|
||||
reject(thrown);
|
||||
}
|
||||
});
|
||||
|
||||
}),
|
||||
source: source
|
||||
})
|
||||
};
|
||||
|
||||
export const deleteItem = ({ commit }, { itemId, isPermanently }) => {
|
||||
|
@ -115,9 +127,13 @@ export const deleteItem = ({ commit }, { itemId, isPermanently }) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const fetchCollections = ({commit} , { page, collectionsPerPage, status }) => {
|
||||
export const fetchCollections = ({commit} , { page, collectionsPerPage, status, contextEdit }) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '/collections?paged='+page+'&perpage='+collectionsPerPage+'&context=edit';
|
||||
let endpoint = '/collections?paged='+page+'&perpage='+collectionsPerPage;
|
||||
|
||||
if (contextEdit)
|
||||
endpoint = endpoint + '&context=edit';
|
||||
|
||||
if (status != '' && status != undefined)
|
||||
endpoint = endpoint + '&status=' + status;
|
||||
|
|
|
@ -8,6 +8,7 @@ export const set_postquery = ({ commit }, postquery ) => {
|
|||
};
|
||||
|
||||
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
|
||||
commit('removePostQueryAttribute', 'search');
|
||||
commit('setAdvancedSearchQuery', advancedSearchQuery);
|
||||
};
|
||||
|
||||
|
@ -74,7 +75,7 @@ export const setStatus= ({ commit }, status ) => {
|
|||
|
||||
// Sorting queries
|
||||
export const setOrderBy = ({ state, commit }, orderBy ) => {
|
||||
commit('cleanPostQueryAttribute', { attr: 'orderby' } );
|
||||
commit('removePostQueryAttribute', 'orderby');
|
||||
|
||||
// Primitive Types: string, date, item, term, compound, float
|
||||
if (orderBy.slug == 'creation_date') {
|
||||
|
|
|
@ -4,8 +4,8 @@ export const setPostQueryAttribute = ( state, { attr, value }) => {
|
|||
Vue.set( state.postquery, attr , value );
|
||||
};
|
||||
|
||||
export const cleanPostQueryAttribute = ( state, { attr }) => {
|
||||
Vue.set( state.postquery, attr , null );
|
||||
export const removePostQueryAttribute = ( state, attr) => {
|
||||
delete state.postquery[`${attr}`];
|
||||
};
|
||||
|
||||
export const setPostQuery = ( state, postquery ) => {
|
||||
|
@ -30,7 +30,7 @@ export const addMetaQuery = ( state, filter ) => {
|
|||
compare: filter.compare,
|
||||
type: filter.type
|
||||
} );
|
||||
} else{
|
||||
} else {
|
||||
state.postquery.metaquery.push({
|
||||
key: filter.metadatum_id,
|
||||
value: filter.value,
|
||||
|
@ -42,14 +42,16 @@ export const addMetaQuery = ( state, filter ) => {
|
|||
|
||||
export const addTaxQuery = ( state, filter ) => {
|
||||
state.postquery.taxquery = ( ! state.postquery.taxquery || state.postquery.taxquery.length == undefined ) ? [] : state.postquery.taxquery;
|
||||
|
||||
let index = state.postquery.taxquery.findIndex( item => item.taxonomy === filter.taxonomy);
|
||||
|
||||
if ( index >= 0 ){
|
||||
Vue.set( state.postquery.taxquery, index, {
|
||||
taxonomy: filter.taxonomy,
|
||||
terms: filter.terms,
|
||||
compare: filter.compare
|
||||
} );
|
||||
}else{
|
||||
} else {
|
||||
state.postquery.taxquery.push({
|
||||
taxonomy: filter.taxonomy,
|
||||
terms: filter.terms,
|
||||
|
@ -71,7 +73,9 @@ export const addFetchOnlyMeta = ( state, metadatum ) => {
|
|||
// console.log(state.postquery.fetch_only);
|
||||
//console.log(state.postquery.fetch_only['meta']);
|
||||
state.postquery.fetch_only['meta'] = ( ! state.postquery.fetch_only['meta'] ) ? [] : state.postquery.fetch_only['meta'];
|
||||
|
||||
let index = state.postquery.fetch_only['meta'].findIndex( item => item == metadatum);
|
||||
|
||||
if ( index >= 0 ){
|
||||
state.postquery.fetch_only['meta'][index] = metadatum;
|
||||
} else {
|
||||
|
@ -90,6 +94,7 @@ export const removeFetchOnly = ( state, metadatum ) => {
|
|||
export const removeFetchOnlyMeta = ( state, metadatum ) => {
|
||||
if(state.postquery.fetch_only['meta'] != undefined) {
|
||||
let index = state.postquery.fetch_only['meta'].findIndex( item => item == metadatum);
|
||||
|
||||
if (index >= 0) {
|
||||
state.postquery.fetch_only['meta'].splice(index, 1);
|
||||
}
|
||||
|
@ -98,7 +103,9 @@ export const removeFetchOnlyMeta = ( state, metadatum ) => {
|
|||
|
||||
export const removeMetaQuery = ( state, filter ) => {
|
||||
state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery;
|
||||
|
||||
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
|
||||
|
||||
if (index >= 0) {
|
||||
state.postquery.metaquery.splice(index, 1);
|
||||
}
|
||||
|
@ -106,15 +113,12 @@ export const removeMetaQuery = ( state, filter ) => {
|
|||
|
||||
export const removeTaxQuery = ( state, filter ) => {
|
||||
let index = state.postquery.taxquery.findIndex( item => item.taxonomy == filter.taxonomy);
|
||||
|
||||
if (index >= 0) {
|
||||
state.postquery.taxquery.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
export const removePostQueryAttribute = ( state, attribute) => {
|
||||
Vue.set( state.postquery, attribute , '');
|
||||
};
|
||||
|
||||
export const setTotalItems = ( state, total ) => {
|
||||
state.totalItems = total;
|
||||
};
|
||||
|
@ -125,10 +129,11 @@ export const setTotalPages = ( state, totalPages ) => {
|
|||
|
||||
export const setSearchQuery = ( state, searchQuery ) => {
|
||||
|
||||
if (searchQuery != '')
|
||||
if (searchQuery != '') {
|
||||
state.postquery.search = searchQuery;
|
||||
else
|
||||
state.postquery.search = undefined;
|
||||
} else {
|
||||
delete state.postquery.search;
|
||||
}
|
||||
};
|
||||
|
||||
export const setStatus = ( state, status ) => {
|
||||
|
@ -145,16 +150,21 @@ export const setAdminViewMode = ( state, adminViewMode ) => {
|
|||
|
||||
export const addFilterTag = ( state, filterTag ) => {
|
||||
state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags;
|
||||
|
||||
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId);
|
||||
if ( index >= 0 )
|
||||
Vue.set( state.filter_tags, index, filterTag );
|
||||
else
|
||||
|
||||
if ( index >= 0 ) {
|
||||
Vue.set(state.filter_tags, index, filterTag);
|
||||
} else {
|
||||
state.filter_tags.push(filterTag);
|
||||
}
|
||||
};
|
||||
|
||||
export const removeFilterTag = ( state, filterTag ) => {
|
||||
state.filter_tags = ( ! state.filter_tags ) ? [] : state.filter_tags;
|
||||
|
||||
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId);
|
||||
|
||||
if (index >= 0) {
|
||||
state.filter_tags.splice(index, 1);
|
||||
}
|
||||
|
@ -173,5 +183,5 @@ export const cleanTaxQueries = (state) => {
|
|||
};
|
||||
|
||||
export const cleanFetchOnly = (state) => {
|
||||
state.postquery.fetch_only = undefined;
|
||||
delete state.postquery.fetch_only;
|
||||
};
|
|
@ -14,7 +14,7 @@
|
|||
<p>{{ $i18n.get('info_no_item_found') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<!-- RECORDS VIEW MODE -->
|
||||
<!-- MASONRY VIEW MODE -->
|
||||
<masonry
|
||||
:cols="{default: 7, 1919: 6, 1407: 5, 1215: 4, 1023: 3, 767: 2, 343: 1}"
|
||||
:gutter="25"
|
||||
|
|
|
@ -106,9 +106,10 @@
|
|||
</span>
|
||||
</button>
|
||||
<div
|
||||
|
||||
class="slide-main-content">
|
||||
<!-- <div <IF WE USE HAMMER JS>
|
||||
class="slide-main-content"
|
||||
v-hammer:swipe.prevent="onSwipeFiltersMenu">
|
||||
v-hammer:swipe.prevent="onSwipeFiltersMenu"> -->
|
||||
<transition
|
||||
mode="out-in"
|
||||
:name="goingRight ? 'slide-right' : 'slide-left'" >
|
||||
|
@ -304,6 +305,7 @@ export default {
|
|||
return this.getItem();
|
||||
},
|
||||
page() {
|
||||
this.setMaxAndMinPages();
|
||||
return this.getPage();
|
||||
},
|
||||
totalPages() {
|
||||
|
@ -311,13 +313,6 @@ export default {
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.minPage = this.page < this.minPage ? this.page : this.minPage;
|
||||
this.maxPage = this.page > this.maxPage ? this.page : this.maxPage;
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
items: {
|
||||
handler () {
|
||||
if (this.items.length > 0) {
|
||||
|
@ -396,7 +391,6 @@ export default {
|
|||
this.readjustedSlideIndex = this.slideIndex;
|
||||
this.$refs.mySwiper.swiper.activeIndex = this.slideIndex + 0;
|
||||
|
||||
// console.log("Index: " + this.slideIndex, this.$refs.mySwiper.swiper.activeIndex, this.readjustedSlideIndex)
|
||||
} else if (this.slideItems.length > 0) {
|
||||
if (this.$refs.mySwiper.swiper.activeIndex == this.slideItems.length - 1 && this.page < this.totalPages)
|
||||
oldVal == undefined ? this.$eventBusSearch.setPage(this.page + 1) : this.$eventBusSearch.setPage(this.maxPage + 1);
|
||||
|
@ -437,6 +431,10 @@ export default {
|
|||
'getPage',
|
||||
'getItemsPerPage'
|
||||
]),
|
||||
setMaxAndMinPages () {
|
||||
this.minPage = JSON.parse(JSON.stringify(this.getPage() < this.minPage ? this.getPage() : this.minPage));
|
||||
this.maxPage = JSON.parse(JSON.stringify(this.getPage() > this.maxPage ? this.getPage() : this.maxPage));
|
||||
},
|
||||
onHideControls() {
|
||||
if (this.isSwiping == undefined || this.isSwiping == false)
|
||||
this.hideControls = !this.hideControls;
|
||||
|
@ -453,7 +451,7 @@ export default {
|
|||
}, 500);
|
||||
},
|
||||
onSlideChange() {
|
||||
// console.log(this.slideIndex, this.$refs.mySwiper.swiper.activeIndex, this.readjustedSlideIndex)
|
||||
|
||||
if (this.$refs.mySwiper.swiper != undefined)
|
||||
this.slideIndex = this.$refs.mySwiper.swiper.activeIndex;
|
||||
|
||||
|
@ -464,6 +462,10 @@ export default {
|
|||
// this.$refs.mySwiper.swiper.slides[this.slideIndex].click();
|
||||
this.$refs.mySwiper.swiper.activeIndex = this.slideIndex + 0;
|
||||
this.readjustedSlideIndex = undefined;
|
||||
|
||||
if (this.slideIndex != undefined && this.$refs.mySwiper.swiper.slides[this.slideIndex] != undefined)
|
||||
this.$refs.mySwiper.swiper.slides[this.slideIndex].click();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
column.metadatum !== 'row_actions' &&
|
||||
column.metadatum !== 'row_creation' &&
|
||||
column.metadatum !== 'row_author'"
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column, column.metadata_type_object.component) : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
|
||||
<span v-if="column.metadatum == 'row_thumbnail'">
|
||||
<img
|
||||
|
@ -132,7 +132,7 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
renderMetadata(itemMetadata, column) {
|
||||
renderMetadata(itemMetadata, column, component) {
|
||||
|
||||
let metadata = (itemMetadata != undefined && itemMetadata[column.slug] != undefined) ? itemMetadata[column.slug] : false;
|
||||
|
||||
|
@ -141,6 +141,9 @@ export default {
|
|||
} else if (metadata.date_i18n) {
|
||||
return metadata.date_i18n;
|
||||
} else {
|
||||
if (component != undefined && component == 'tainacan-textarea')
|
||||
return metadata.value_as_string;
|
||||
else
|
||||
return metadata.value_as_html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -483,15 +483,10 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
//=======================
|
||||
|
||||
$query = [
|
||||
'fetch' => 'all_metadatum_values'
|
||||
];
|
||||
|
||||
$request = new \WP_REST_Request(
|
||||
'GET',
|
||||
$this->namespace . '/collection/' . $collection->get_id() . '/metadata/' . $metadatum->get_id()
|
||||
$this->namespace . '/collection/' . $collection->get_id() . '/facets/' . $metadatum->get_id()
|
||||
);
|
||||
$request->set_query_params($query);
|
||||
|
||||
//=======================
|
||||
|
||||
|
@ -503,7 +498,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$data1 = $response1->get_data();
|
||||
|
||||
$this->assertCount(1, $data1);
|
||||
$this->assertEquals('12/12/2017', $data1[0]['mvalue']);
|
||||
$this->assertEquals('12/12/2017', $data1[0]['value']);
|
||||
|
||||
//=======================
|
||||
|
||||
|
@ -515,7 +510,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$data1 = $response1->get_data();
|
||||
|
||||
$this->assertCount(1, $data1);
|
||||
$this->assertEquals('12/12/2017', $data1[0]['mvalue']);
|
||||
$this->assertEquals('12/12/2017', $data1[0]['value']);
|
||||
|
||||
//=======================
|
||||
|
||||
|
@ -528,8 +523,8 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
// Only two without duplicates
|
||||
$this->assertCount(2, $data2);
|
||||
$this->assertEquals('12/12/2017', $data2[0]['mvalue']);
|
||||
$this->assertEquals('02/03/2018', $data2[1]['mvalue']);
|
||||
$this->assertEquals('12/12/2017', $data2[0]['value']);
|
||||
$this->assertEquals('02/03/2018', $data2[1]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tainacan\Tests;
|
||||
use Tainacan\Importer;
|
||||
use Tainacan\Entities;
|
||||
/**
|
||||
* Class Importer
|
||||
*
|
||||
|
@ -261,7 +262,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
|
||||
// Sample data
|
||||
$data = array(
|
||||
array('Data 11', 'Data 12', 'Data 13||TESTE', 'Data 14', 'Data 15'),
|
||||
array('Data 11', 'Data 12', 'Data 13||TESTE', 'Data 14', 'Data 15>>DATA 151'),
|
||||
array('Data 21', 'Data 22', 'this
|
||||
is
|
||||
having
|
||||
|
@ -269,7 +270,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
lines', 'Data 24', 'Data 25'),
|
||||
array('Data 31', 'Data 32', utf8_decode( 'Data 33||Rééço' ), 'Data 34', 'Data 35'),
|
||||
array('Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
|
||||
array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55')
|
||||
array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55>>DATA551')
|
||||
);
|
||||
|
||||
// save each row of the data
|
||||
|
@ -330,6 +331,27 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$taxonomy = $this->tainacan_entity_factory->create_entity(
|
||||
'taxonomy',
|
||||
array(
|
||||
'name' => 'genero',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadata_taxonomy =$this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'taxonomia',
|
||||
'collection_id' => $collection->get_id(),
|
||||
'metadata_type_options' => ['taxonomy_id' => $taxonomy->get_id(), 'allow_new_terms' => true ],
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'status' => 'publish'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$collection_definition = [
|
||||
'id' => $collection->get_id(),
|
||||
'total_items' => $_SESSION['tainacan_importer'][$id]->get_source_number_of_items(),
|
||||
|
@ -359,7 +381,19 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$this->assertEquals(false, $_SESSION['tainacan_importer'][$id]->run(), '5 items and return false because its finished');
|
||||
$this->assertEquals(false, $_SESSION['tainacan_importer'][$id]->run(), 'if call run again after finish, do nothing');
|
||||
|
||||
$items = $Tainacan_Items->fetch( [], $collection, 'OBJECT' );
|
||||
$items = $Tainacan_Items->fetch( ['orderby' => 'date'], $collection, 'OBJECT' );
|
||||
|
||||
foreach ( $items as $index => $item ) {
|
||||
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadata_taxonomy );
|
||||
|
||||
if( $index === 0 ){
|
||||
$term = $singleItemMetadata->get_value();
|
||||
|
||||
if( in_array( $item->get_title(),['Data 11','Data 51'] ) )
|
||||
$this->assertTrue(in_array( $term->get_name(),['DATA 151','DATA551'] ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_source_number_of_items(), count( $items ) );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue