More advancements on moving metadata mapping in importer to a saparate page.

This commit is contained in:
Mateus Machado Luna 2018-07-24 16:25:49 -03:00
parent dc3bbd3ab3
commit b98956c3c4
7 changed files with 138 additions and 44 deletions

View File

@ -212,19 +212,39 @@ export default {
// Creates draft Importer
this.sendImporter(this.importerType)
.then(res => {
.then(res => {
this.sessionId = res.id;
this.importer = JSON.parse(JSON.stringify(res));
this.sessionId = res.id;
this.importer = JSON.parse(JSON.stringify(res));
this.form = this.importer.options;
this.isLoading = false;
this.form = this.importer.options;
this.isLoading = false;
if (this.importer.manual_collection)
this.loadCollections();
})
.catch(error => this.$console.error(error));
if (this.importer.manual_collection)
this.loadCollections();
})
.catch(error => this.$console.error(error));
},
loadImporter() {
// Puts loading on Draft Importer creation
this.isLoading = true;
// Creates draft Importer
this.fetchImporter(this.sessionId)
.then(res => {
this.sessionId = res.id;
this.importer = JSON.parse(JSON.stringify(res));
this.form = this.importer.options;
this.isLoading = false;
if (this.importer.manual_collection)
this.loadCollections();
})
.catch(error => this.$console.error(error));
},
cancelBack(){
this.$router.go(-1);
@ -326,7 +346,7 @@ export default {
});
},
goToMappingPage() {
this.$router.push(this.$routerHelper.getImporterMappingPath(this.sessionId, this.collectionId));
this.$router.push(this.$routerHelper.getImporterMappingPath(this.importerType, this.sessionId, this.collectionId));
},
loadCollections() {
// Generates options for target collection
@ -340,17 +360,37 @@ export default {
this.$console.error(error);
this.isFetchingCollections = false;
});
},
onSelectCollection(collectionId) {
this.collectionId = collectionId;
this.mappedCollection['id'] = collectionId;
// Generates options for metadata listing
this.isFetchingCollectionMetadata = true;
this.fetchMetadata({collectionId: this.collectionId, isRepositoryLevel: false, isContextEdit: false })
.then((metadata) => {
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
this.isFetchingCollectionMetadata = false;
})
.catch((error) => {
this.$console.error(error);
this.isFetchingCollectionMetadata = false;
});
}
},
created() {
this.importerType = this.$route.params.importerSlug;
this.collectionId = this.$route.query.targetCollection;
this.sessionId = this.$route.params.sessionId;
if (this.collectionId != undefined) {
this.onSelectCollection(this.collectionId);
}
this.createImporter();
if (this.sessionId != undefined)
this.loadImporter();
else
this.createImporter();
}
}
@ -376,6 +416,16 @@ export default {
line-height: 1.2em;
}
.source-metadatum {
padding: 2px 0;
border-bottom: 1px solid $tainacan-input-background;
width: 100%;
margin-bottom: 6px;
display: flex;
justify-content: space-between;
align-items: center;
}
.is-inline .control{
display: inline;
}

View File

@ -1,8 +1,7 @@
<template>
<div
class="primary-page page-container">
<div
class="tainacan-page-title">
<div class="tainacan-page-title">
<h1>{{ $i18n.get('label_metadata_mapping') }} </h1>
<a
@click="$router.go(-1)"
@ -10,21 +9,20 @@
{{ $i18n.get('back') }}
</a>
<hr>
<!-- <nav class="breadcrumbs">
<nav class="breadcrumbs">
<router-link
tag="a"
:to="$routerHelper.getCollectionsPath()">{{ $i18n.get('repository') }}</router-link> >
<span
v-for="(pathItem, index) in arrayRealPath"
:key="index">
<router-link
tag="a"
:to="'/' + arrayRealPath.slice(0, index + 1).join('/')">
{{ arrayViewPath[index] }}
</router-link>
<span v-if="index != arrayRealPath.length - 1"> > </span>
</span>
</nav> -->
<router-link
tag="a"
:to="$routerHelper.getAvailableImportersPath()">{{ $i18n.get('importers') }}</router-link> >
<router-link
tag="a"
:to="$routerHelper.getImporterPath(importerType, sessionId)">{{ importerType }}</router-link> >
<router-link
tag="a"
:to="$routerHelper.getImporterMappingPath(importerType, sessionId, collectionId)">{{ $i18n.get('label_metadata_mapping') }}</router-link>
</nav>
</div>
<form
@ -146,24 +144,13 @@
type="button"
@click="cancelBack">{{ $i18n.get('cancel') }}</button>
</div>
<div
v-if="!hasRunImporter"
class="control">
<div class="control">
<button
:disabled="sessionId == undefined || importer == undefined"
id="button-submit-collection-creation"
@click.prevent="onRunImporter"
class="button is-success">{{ $i18n.get('run') }}</button>
</div>
<div
v-if="hasRunImporter"
class="control">
<button
:disabled="sessionId == undefined || importer == undefined"
id="button-submit-collection-creation"
@click.prevent="onCheckBackgroundProcessStatus"
class="button is-success">Check Status</button>
</div>
</div>
</form>
@ -289,7 +276,7 @@ export default {
});
},
cancelBack(){
this.$router.go(-1);
this.$router.go(-2);
},
checkIfMetadatumIsAvailable(metadatumId) {
return this.mappedCollection['mapping'][metadatumId] != undefined;
@ -402,6 +389,7 @@ export default {
}
},
created() {
this.importerType = this.$route.params.importerType;
this.sessionId = this.$route.params.sessionId;
this.collectionId = this.$route.params.collectionId;
this.mappedCollection['id'] = this.collectionId;
@ -417,6 +405,49 @@ export default {
@import "../../scss/_variables.scss";
.tainacan-page-title {
margin-bottom: 40px;
h1, h2 {
font-size: 20px;
font-weight: 500;
color: $tertiary;
display: inline-block;
}
a.back-link{
font-weight: 500;
float: right;
margin-top: 5px;
}
hr{
margin: 3px 0px 4px 0px;
height: 1px;
background-color: $secondary;
}
.breadcrumbs {
font-size: 12px;
}
.level-left {
.level-item {
display: inline-block;
margin-left: 268px;
}
}
@media screen and (max-width: 769px) {
.level-left {
margin-left: 0px !important;
.level-item {
margin-left: 30px;
}
}
.level-right {
display: none;
}
top: 206px;
margin-bottom: 0px !important;
}
}
.field {
position: relative;

View File

@ -105,6 +105,8 @@ export default {
this.fetchAvailableImporters()
.then(importers => {
this.arrayViewPath.splice(i, 1, importers[this.arrayRealPath[i]].name);
if (i != this.arrayRealPath.length - 1)
this.arrayRealPath.pop();
})
.catch((error) => this.$console.error(error));
} else {

View File

@ -72,7 +72,8 @@ const routes = [
{ path: '/importers/', name: 'AvailableImportersPage', component: AvailableImportersPage, meta: {title: i18nGet('title_importers_page'), icon: 'file-multiple'} },
{ path: '/importers/:importerSlug', name: 'ImporterEditionForm', component: ImporterEditionForm, meta: {title: i18nGet('title_importer_page'), icon: 'file-multiple'} },
{ path: '/importers/:sessionId/mapping/:collectionId', name: 'ImporterMappingForm', component: ImporterMappingForm, meta: {title: i18nGet('title_importer_mapping_page'), icon: 'file-multiple'} },
{ path: '/importers/:importerSlug/:sessionId', name: 'ImporterCreationForm', component: ImporterEditionForm, meta: { title: i18nGet('title_importer_page'), icon: 'file-multiple' } },
{ path: '/importers/:importerType/:sessionId/mapping/:collectionId', name: 'ImporterMappingForm', component: ImporterMappingForm, meta: {title: i18nGet('title_importer_mapping_page'), icon: 'file-multiple'} },
{ path: '/export/collection/:collectionId', name: 'ExportCollection', component: ExportPage, meta: {title: i18nGet('title_export_collection_page'), icon: 'export'} },
{ path: '/export/item/:itemId', name: 'ExportItem', component: ExportPage, meta: {title: i18nGet('title_export_item_page'), icon: 'export'} },

View File

@ -227,6 +227,9 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
getEventPath(id) {
return '/events/' + id;
},
getImporterPath(importerType, sessionId) {
return '/importers/' + importerType + '/' + sessionId;
},
// New
getNewCollectionPath() {
return '/collections/new';
@ -280,8 +283,8 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
getImporterEditionPath(importerType) {
return '/importers/' + importerType;
},
getImporterMappingPath(sessionId, collectionId) {
return '/importers/' + sessionId + '/mapping/' + collectionId;
getImporterMappingPath(importerType, sessionId, collectionId) {
return '/importers/' + importerType + '/' + sessionId + '/mapping/' + collectionId;
},
}
}

View File

@ -3,7 +3,14 @@ import axios from '../../../axios/axios';
// Actions related to background processes
export const fetchProcesses = ({ commit }, {page, processesPerPage}) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/bg-processes?paged=' + page + '&perpage=' + processesPerPage)
let endpoint = '/bg-processes?';
if (page != undefined)
endpoint += 'paged=' + page;
if (processesPerPage != undefined)
endpoint += '&perpage=' + processesPerPage;
axios.tainacan.get(endpoint)
.then( res => {
let processes = res.data;
commit('setProcesses', processes);

View File

@ -154,7 +154,7 @@ export const runImporter = ( { dispatch } , importerId ) => {
axios.tainacan.post('importers/session/' + importerId + '/run')
.then( res => {
let backgroundProcessId = res.data;
dispatch('bgprocess/fetchProcesses', null, { root: true });
dispatch('bgprocess/fetchProcesses', { }, { root: true });
resolve( backgroundProcessId );
})
.catch(error => {