From 1bb26a25e3f02c127d1d08fc7e692e0bcd659f53 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Fri, 19 Oct 2018 12:56:42 -0300 Subject: [PATCH 1/3] Adds CollectionEvent Page to router. Creates breadcrumb event logic for receiving paths from pages in CollectionSubheader. --- .../edition/collection-edition-form.vue | 2 + .../components/edition/item-edition-form.vue | 22 +++ src/admin/components/lists/events-list.vue | 5 +- src/admin/components/lists/filters-list.vue | 6 +- src/admin/components/lists/metadata-list.vue | 4 + .../tainacan-collection-subheader.vue | 134 ++++++------------ src/admin/js/main.js | 3 +- src/admin/js/router.js | 1 + src/admin/js/utilities.js | 3 + src/admin/pages/lists/events-page.vue | 3 + src/admin/pages/lists/items-page.vue | 4 + src/admin/pages/singles/event-page.vue | 21 +-- src/admin/pages/singles/item-page.vue | 9 +- 13 files changed, 109 insertions(+), 108 deletions(-) diff --git a/src/admin/components/edition/collection-edition-form.vue b/src/admin/components/edition/collection-edition-form.vue index 22018a4b5..23ff992a6 100644 --- a/src/admin/components/edition/collection-edition-form.vue +++ b/src/admin/components/edition/collection-edition-form.vue @@ -811,6 +811,8 @@ export default { }, mounted(){ + this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('settings') }]); + if (this.$route.query.fromImporter != undefined) this.fromImporter = this.$route.query.fromImporter; diff --git a/src/admin/components/edition/item-edition-form.vue b/src/admin/components/edition/item-edition-form.vue index f5f5b4e74..174a202fa 100644 --- a/src/admin/components/edition/item-edition-form.vue +++ b/src/admin/components/edition/item-edition-form.vue @@ -765,6 +765,12 @@ export default { // Puts loading on Draft Item creation this.isLoading = true; + // Updates Collection BreadCrumb + this.$root.$emit('onCollectionBreadCrumbUpdate', [ + { path: this.$routerHelper.getCollectionPath(this.collectionId), label: this.$i18n.get('items') }, + { path: '', label: this.$i18n.get('new') } + ]); + // Creates draft Item let data = {collection_id: this.form.collectionId, status: 'auto-draft', comment_status: this.form.comment_status}; this.fillExtraFormData(data); @@ -976,6 +982,22 @@ export default { this.fetchItem(this.itemId).then(res => { this.item = res; + // Updates Collection BreadCrumb + if (this.isOnSequenceEdit) { + this.$root.$emit('onCollectionBreadCrumbUpdate', [ + { path: this.$routerHelper.getCollectionPath(this.collectionId), label: this.$i18n.get('items') }, + { path: '', label: this.$i18n.get('sequence') }, + { path: '', label: this.item.title }, + { path: '', label: this.$i18n.get('edit') } + ]); + } else { + this.$root.$emit('onCollectionBreadCrumbUpdate', [ + { path: this.$routerHelper.getCollectionPath(this.collectionId), label: this.$i18n.get('items') }, + { path: this.$routerHelper.getItemPath(this.form.collectionId, this.itemId), label: this.item.title }, + { path: '', label: this.$i18n.get('edit') } + ]); + } + // Fills hook forms with it's real values this.$nextTick() .then(() => { diff --git a/src/admin/components/lists/events-list.vue b/src/admin/components/lists/events-list.vue index 23e81031d..8f7ad2cb6 100644 --- a/src/admin/components/lists/events-list.vue +++ b/src/admin/components/lists/events-list.vue @@ -144,7 +144,10 @@ // this.notApprove(eventId); // }, goToEventPage(eventId) { - this.$router.push(this.$routerHelper.getEventPath(eventId)); + if (this.$route.params.collectionId == undefined) + this.$router.push(this.$routerHelper.getEventPath(eventId)); + else + this.$router.push(this.$routerHelper.getCollectionEventPath(this.$route.params.collectionId, eventId)); } } } diff --git a/src/admin/components/lists/filters-list.vue b/src/admin/components/lists/filters-list.vue index f7e099ac3..3f52b86f3 100644 --- a/src/admin/components/lists/filters-list.vue +++ b/src/admin/components/lists/filters-list.vue @@ -215,7 +215,7 @@ export default { openedFilterId: '', formWithErrors: '', editForms: {}, - allowedFilterTypes: [], + allowedFilterTypes: [], selectedFilterType: {}, choosenMetadatum: {}, newIndex: 0, @@ -451,10 +451,12 @@ export default { delete this.editForms[this.openedFilterId]; this.openedFilterId = ''; } - }, mounted() { + if (!this.isRepositoryLevel) + this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('filter') }]); + this.isRepositoryLevel = this.$route.name == 'FiltersPage' ? true : false; if (this.isRepositoryLevel) this.collectionId = 'default'; diff --git a/src/admin/components/lists/metadata-list.vue b/src/admin/components/lists/metadata-list.vue index 4b48fe608..1738212cf 100644 --- a/src/admin/components/lists/metadata-list.vue +++ b/src/admin/components/lists/metadata-list.vue @@ -760,6 +760,10 @@ export default { } }, mounted() { + + if (!this.isRepositoryLevel) + this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('metadata') }]); + this.cleanMetadata(); this.isLoadingMetadatumTypes = true; this.isLoadingMetadata = true; diff --git a/src/admin/components/navigation/tainacan-collection-subheader.vue b/src/admin/components/navigation/tainacan-collection-subheader.vue index b68d1fcc9..7e3ec96e8 100644 --- a/src/admin/components/navigation/tainacan-collection-subheader.vue +++ b/src/admin/components/navigation/tainacan-collection-subheader.vue @@ -28,7 +28,21 @@ {{ $i18n.get('repository') }} > - {{ collectionBreadCrumbItem.name }} + + @@ -137,7 +151,7 @@ diff --git a/src/admin/js/main.js b/src/admin/js/main.js index 3a3051b87..bd856d720 100644 --- a/src/admin/js/main.js +++ b/src/admin/js/main.js @@ -93,7 +93,8 @@ Vue.use(eventBusSearch, { store: store, router: router}); // Changing title of pages router.beforeEach((to, from, next) => { document.title = to.meta.title; - next(); + if (next() != undefined) + next(); }); new Vue({ diff --git a/src/admin/js/router.js b/src/admin/js/router.js index fd625de9e..d75b0f991 100644 --- a/src/admin/js/router.js +++ b/src/admin/js/router.js @@ -52,6 +52,7 @@ const routes = [ { 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/:eventId', name: 'EventPage', component: EventPage, meta: {title: i18nGet('title_event_page'), 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'} }, ] diff --git a/src/admin/js/utilities.js b/src/admin/js/utilities.js index b711c5bbf..e18452aec 100644 --- a/src/admin/js/utilities.js +++ b/src/admin/js/utilities.js @@ -236,6 +236,9 @@ RouterHelperPlugin.install = function (Vue, options = {}) { getImporterPath(importerType, sessionId) { return '/importers/' + importerType + '/' + sessionId; }, + getCollectionEventPath(collectionId, eventId) { + return '/collections/' + collectionId + '/events/' + eventId; + }, // New getNewCollectionPath() { return '/collections/new'; diff --git a/src/admin/pages/lists/events-page.vue b/src/admin/pages/lists/events-page.vue index b22c369f4..91ea63053 100644 --- a/src/admin/pages/lists/events-page.vue +++ b/src/admin/pages/lists/events-page.vue @@ -285,6 +285,9 @@ this.isRepositoryLevel = (this.$route.params.collectionId === undefined); }, mounted(){ + if (!this.isRepositoryLevel) + this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('events') }]); + if (this.$route.query.tab == 'processes' && this.isRepositoryLevel) this.tab = 'processes'; diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index b6807f0c8..86d71bd51 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -1209,6 +1209,10 @@ this.prepareMetadata(); this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata)); + // Updates Collection Header Breadcrumb + if (!this.isOnTheme) + this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('items') }]); + // Setting initial view mode on Theme if (this.isOnTheme) { let prefsViewMode = !this.isRepositoryLevel ? 'view_mode_' + this.collectionId : 'view_mode'; diff --git a/src/admin/pages/singles/event-page.vue b/src/admin/pages/singles/event-page.vue index e7319d300..65bec2792 100644 --- a/src/admin/pages/singles/event-page.vue +++ b/src/admin/pages/singles/event-page.vue @@ -1,7 +1,9 @@