Adds related objects to activities modal #261.
This commit is contained in:
parent
63cd0fdce7
commit
c0ead5b941
|
@ -117,7 +117,7 @@
|
|||
@input="onChangeEnable($event, index)"/>
|
||||
<a
|
||||
:style="{ visibility: filter.collection_id != collectionId && !isRepositoryLevel? 'hidden' : 'visible' }"
|
||||
@click.prevent="editFilter(filter)">
|
||||
@click.prevent="toggleFilterEdition(filter.id)">
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: $i18n.get('edit'),
|
||||
|
@ -353,6 +353,18 @@ export default {
|
|||
components: {
|
||||
FilterEditionForm
|
||||
},
|
||||
watch: {
|
||||
'$route.query': {
|
||||
handler(newQuery) {
|
||||
if (newQuery.edit != undefined) {
|
||||
let existingFilterIndex = this.activeFilterList.findIndex((filter) => filter.id == newQuery.edit);
|
||||
if (existingFilterIndex >= 0)
|
||||
this.editFilter(this.activeFilterList[existingFilterIndex])
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
beforeRouteLeave ( to, from, next ) {
|
||||
let hasUnsavedForms = false;
|
||||
for (let editForm in this.editForms) {
|
||||
|
@ -524,7 +536,7 @@ export default {
|
|||
this.selectedFilterType = {}
|
||||
this.allowedFilterTypes = [];
|
||||
|
||||
this.editFilter(filter);
|
||||
this.toggleFilterEdition(filter.id);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
|
@ -559,34 +571,29 @@ export default {
|
|||
// this.deleteTemporaryFilter(this.newFilterIndex);
|
||||
this.newFilterIndex = 0;
|
||||
},
|
||||
editFilter(filter) {
|
||||
toggleFilterEdition(filterId) {
|
||||
// Closing collapse
|
||||
if (this.openedFilterId == filter.id) {
|
||||
if (this.openedFilterId == filterId) {
|
||||
this.openedFilterId = '';
|
||||
this.$router.push({ query: {}});
|
||||
|
||||
// Opening collapse
|
||||
} else {
|
||||
this.$router.push({ query: { edit: filterId}})
|
||||
}
|
||||
},
|
||||
editFilter(filter) {
|
||||
this.openedFilterId = filter.id;
|
||||
|
||||
if (this.openedFilterId == '' && this.choosenMetadatum.id != undefined) {
|
||||
this.availableMetadata.push(this.choosenMetadatum);
|
||||
this.choosenMetadatum = {};
|
||||
this.allowedFilterTypes = [];
|
||||
this.selectedFilterType = {};
|
||||
// this.deleteTemporaryFilter(this.newFilterIndex);
|
||||
this.newFilterIndex = 0;
|
||||
}
|
||||
this.openedFilterId = filter.id;
|
||||
// First time opening
|
||||
if (this.editForms[this.openedFilterId] == undefined) {
|
||||
this.editForms[this.openedFilterId] = JSON.parse(JSON.stringify(filter));
|
||||
this.editForms[this.openedFilterId].saved = true;
|
||||
|
||||
// First time opening
|
||||
if (this.editForms[this.openedFilterId] == undefined) {
|
||||
this.editForms[this.openedFilterId] = JSON.parse(JSON.stringify(filter));
|
||||
this.editForms[this.openedFilterId].saved = true;
|
||||
|
||||
// Filter inserted now
|
||||
if (this.editForms[this.openedFilterId].status == 'auto-draft') {
|
||||
this.editForms[this.openedFilterId].status = 'publish';
|
||||
this.editForms[this.openedFilterId].saved = false;
|
||||
}
|
||||
// Filter inserted now
|
||||
if (this.editForms[this.openedFilterId].status == 'auto-draft') {
|
||||
this.editForms[this.openedFilterId].status = 'publish';
|
||||
this.editForms[this.openedFilterId].saved = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -594,11 +601,13 @@ export default {
|
|||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedFilterId];
|
||||
this.openedFilterId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
onEditionCanceled() {
|
||||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedFilterId];
|
||||
this.openedFilterId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
getProperPreviewMinHeight() {
|
||||
for (let filterType of this.allowedFilterTypes) {
|
||||
|
@ -610,6 +619,55 @@ export default {
|
|||
}
|
||||
}
|
||||
return 190;
|
||||
},
|
||||
refreshFilters() {
|
||||
this.fetchFilters({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: !this.isOnTheme,
|
||||
includeDisabled: true,
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
|
||||
this.isLoadingMetadatumTypes = true;
|
||||
|
||||
// Checks URL as router watcher would not wait for list to load
|
||||
if (this.$route.query.edit != undefined) {
|
||||
let existingFilterIndex = this.activeFilterList.findIndex((filter) => filter.id == this.$route.query.edit);
|
||||
if (existingFilterIndex >= 0)
|
||||
this.editFilter(this.activeFilterList[existingFilterIndex]);
|
||||
}
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: true
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
this.updateListOfMetadata();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
});
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingMetadatumTypes = false);
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.filtersSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
@ -643,46 +701,8 @@ export default {
|
|||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
this.fetchFilters({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: !this.isOnTheme,
|
||||
includeDisabled: true,
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
|
||||
this.isLoadingMetadatumTypes = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: true
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
this.updateListOfMetadata();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
});
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingMetadatumTypes = false);
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.filtersSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
// Loads Filters
|
||||
this.refreshFilters();
|
||||
|
||||
// On repository level we also fetch collection filters
|
||||
if (this.isRepositoryLevel) {
|
||||
|
|
|
@ -594,7 +594,14 @@ export default {
|
|||
|
||||
},
|
||||
addNewMetadatum(newMetadatum, newIndex) {
|
||||
this.sendMetadatum({collectionId: this.collectionId, name: newMetadatum.name, metadatumType: newMetadatum.className, status: 'auto-draft', isRepositoryLevel: this.isRepositoryLevel, newIndex: newIndex})
|
||||
this.sendMetadatum({
|
||||
collectionId: this.collectionId,
|
||||
name: newMetadatum.name,
|
||||
metadatumType: newMetadatum.className,
|
||||
status: 'auto-draft',
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
newIndex: newIndex
|
||||
})
|
||||
.then((metadatum) => {
|
||||
|
||||
if (!this.isRepositoryLevel)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<template>
|
||||
<div class="tainacan-modal-content">
|
||||
<header class="tainacan-modal-title">
|
||||
<header
|
||||
v-if="!isLoadingActivity"
|
||||
class="tainacan-modal-title">
|
||||
<h2>{{ activity.title ? activity.title : $i18n.get('activity') }}</h2>
|
||||
<hr>
|
||||
<p>{{ activityCreationDate + ', ' + $i18n.get('info_by_inner') }} <strong> {{ activity.user_name }}</strong></p>
|
||||
</header>
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
|
@ -13,8 +16,10 @@
|
|||
class="modal-card-body">
|
||||
<div class="content">
|
||||
<p v-if="activity.description"><strong>{{ $i18n.get('label_activity_description') }}:</strong> {{ activity.description }}</p>
|
||||
<p><strong>{{ $i18n.get('label_activity_creation_date') }}:</strong> {{ activityCreationDate }}</p>
|
||||
<p><strong>{{ $i18n.get('label_activity_author') }}:</strong> {{ activity.user_name }}</p>
|
||||
<p v-if="activity.object">
|
||||
<strong>{{ $i18n.get('label_related_to') }}: </strong>
|
||||
<span v-html="relatedToLink" />
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- LEGACY LOG API RETURN -->
|
||||
|
@ -609,15 +614,54 @@
|
|||
dateFormat: '',
|
||||
activityCreationDate: '',
|
||||
placeholderSquareImage: `${tainacan_plugin.base_url}/admin/images/placeholder_square.png`,
|
||||
isLoadingActivity: false
|
||||
isLoadingActivity: false,
|
||||
adminFullURL: tainacan_plugin.admin_url + 'admin.php?page=tainacan_admin#',
|
||||
}
|
||||
},
|
||||
components: {
|
||||
FileItem
|
||||
},
|
||||
watch: {
|
||||
'$route' (to, from) {
|
||||
if (to !== from)
|
||||
this.$parent.close();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
activity() {
|
||||
return this.getActivity();
|
||||
},
|
||||
relatedToLink() {
|
||||
switch(this.activity.object_type) {
|
||||
case 'Tainacan\\Entities\\Collection':
|
||||
return `${ this.$i18n.get('collection') }
|
||||
<a href="${ this.adminFullURL + this.$routerHelper.getCollectionPath(this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-collections"/></span>`;
|
||||
case 'Tainacan\\Entities\\Taxonomy':
|
||||
return `${ this.$i18n.get('taxonomy') }
|
||||
<a href="${ this.adminFullURL + this.$routerHelper.getTaxonomyPath(this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-taxonomies"/></span>`;
|
||||
case 'Tainacan\\Entities\\Metadatum':
|
||||
return `${ this.$i18n.get('metadatum') }
|
||||
<a href="${ this.adminFullURL + (this.activity.object.collection_id == 'default' ? this.$routerHelper.getMetadataEditPath(this.activity.object_id) : this.$routerHelper.getCollectionMetadataEditPath(this.activity.object.collection_id, this.activity.object_id)) }">${ this.activity.object.name }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-metadata"/></span>`;
|
||||
case 'Tainacan\\Entities\\Filter':
|
||||
return `${ this.$i18n.get('filter') }
|
||||
<a href="${ this.adminFullURL + (this.activity.object.collection_id == 'default' || this.activity.object.collection_id == 'filter_in_repository' ? this.$routerHelper.getFilterEditPath(this.activity.object_id) : this.$routerHelper.getCollectionFilterEditPath(this.activity.object.collection_id, this.activity.object_id)) }">${ this.activity.object.name }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-filters"/></span>`;
|
||||
case 'Tainacan\\Entities\\Term':
|
||||
return `${ this.$i18n.get('term') }
|
||||
<a href="${ this.adminFullURL + this.$routerHelper.getTermEditPath(this.activity.object.taxonomy.split('tnc_tax_')[1], this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-terms"/></span>`;
|
||||
case 'Tainacan\\Entities\\Item':
|
||||
return `${ this.$i18n.get('item') }
|
||||
<a href="${ this.adminFullURL + this.$routerHelper.getItemEditPath(this.activity.object.collection_id, this.activity.object_id) }">${ this.activity.object.title }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-items"/></span>`;
|
||||
case 'Tainacan\\Entities\\Item_Metadata_Entity':
|
||||
return `${ this.$i18n.get('item') }
|
||||
<a href="${ this.adminFullURL + this.$routerHelper.getItemEditPath(this.activity.object.collection_id, this.activity.item.id) }">${ this.activity.item.title }</a>
|
||||
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-items"/></span>`;
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -635,9 +679,6 @@
|
|||
},
|
||||
notApproveActivity(){
|
||||
this.$emit('notApproveActivity', this.activity.id);
|
||||
},
|
||||
undo(){
|
||||
|
||||
},
|
||||
loadActivity() {
|
||||
this.isLoadingActivity = true;
|
||||
|
@ -677,11 +718,15 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
|
||||
p {
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-modal-content {
|
||||
width: auto;
|
||||
min-height: 600px;
|
||||
min-height: 500px;
|
||||
|
||||
p {
|
||||
font-size: 0.875rem;
|
||||
|
@ -689,10 +734,10 @@
|
|||
}
|
||||
|
||||
.modal-card-body {
|
||||
min-height: 400px;
|
||||
min-height: 300px;
|
||||
padding: 0;
|
||||
.columns {
|
||||
margin: 12px $page-side-padding;
|
||||
margin: 6px $page-side-padding 0 $page-side-padding;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -227,9 +227,6 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getFiltersPath(query) {
|
||||
return '/filters/?' + qs.stringify(query);
|
||||
},
|
||||
getMetadataPath(query) {
|
||||
return '/metadata/?' + qs.stringify(query);
|
||||
},
|
||||
getActivitiesPath(query) {
|
||||
return '/activities/?' + qs.stringify(query);
|
||||
},
|
||||
|
@ -302,14 +299,23 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getItemEditPath(collectionId, itemId) {
|
||||
return '/collections/' + collectionId + '/items/' + itemId + '/edit';
|
||||
},
|
||||
getFilterEditPath(id) {
|
||||
return '/filters/' + id + '/edit';
|
||||
getMetadataEditPath(metadatumId) {
|
||||
return '/metadata/?edit=' + metadatumId;
|
||||
},
|
||||
getFilterEditPath(filterId) {
|
||||
return '/filters/?edit=' + filterId;
|
||||
},
|
||||
getCollectionMetadataEditPath(collectionId, metadatumId) {
|
||||
return '/collections/' + collectionId + '/metadata/?edit=' + metadatumId;
|
||||
},
|
||||
getCollectionFilterEditPath(collectionId, filterId) {
|
||||
return '/collections/' + collectionId + '/filters/?edit=' + filterId;
|
||||
},
|
||||
getTaxonomyEditPath(id, isRecent) {
|
||||
return isRecent != undefined ? '/taxonomies/' + id + '/edit?recent=true' : '/taxonomies/' + id + '/edit';
|
||||
},
|
||||
getTermEditPath(taxonomyId, termId) {
|
||||
return '/taxonomies/' + taxonomyId + '/terms/' + termId + '/edit';
|
||||
return '/taxonomies/' + taxonomyId + '/edit?tab=terms';
|
||||
},
|
||||
getImporterEditionPath(importerType) {
|
||||
return '/importers/' + importerType;
|
||||
|
|
|
@ -434,6 +434,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_day' => __( 'Day', 'tainacan' ),
|
||||
'label_month' => __( 'Month', 'tainacan' ),
|
||||
'label_year' => __( 'Year', 'tainacan' ),
|
||||
'label_related_to' => __( 'Related to', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
|
Loading…
Reference in New Issue