Skip to content

Commit

Permalink
Merge pull request #15 from ConductionNL/feature/CONNECTOR-21/mappings
Browse files Browse the repository at this point in the history
feature/CONNECTOR-21/mappings
  • Loading branch information
remko48 authored Oct 3, 2024
2 parents d0783b9 + d74c0af commit ce1ff2c
Show file tree
Hide file tree
Showing 14 changed files with 470 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/node_modules/
/js/
/custom_apps/
/custom-apps/
/config/

/coverage/
Expand Down
11 changes: 11 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,14 @@
margin-left: 16px;
color: inherit;
}

.h1 {
display: block !important;
font-size: 2em !important;
margin-block-start: 0.67em !important;
margin-block-end: 0.67em !important;
margin-inline-start: 0px !important;
margin-inline-end: 0px !important;
font-weight: bold !important;
unicode-bidi: isolate !important;
}
2 changes: 1 addition & 1 deletion lib/Db/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function jsonSerialize(): array
'cast' => $this->cast,
'passTrough' => $this->passTrough,
'dateCreated' => $this->dateCreated,
'dateModified' => $this->dateModified
'dateModified' => $this->dateModified,
];
}
}
1 change: 1 addition & 0 deletions src/modals/JobArgument/EditJobArgument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default {
}
},
checkIfKeyIsUnique(key) {
if (!jobStore.jobItem.arguments) return false
const keys = Object.keys(jobStore.jobItem.arguments)
if (this.oldKey === key) return false
if (keys.includes(key)) return true
Expand Down
13 changes: 7 additions & 6 deletions src/modals/Mapping/DeleteMapping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { mappingStore, navigationStore } from '../../store/store.js'

<template>
<NcDialog v-if="navigationStore.dialog === 'deleteMapping'"
name="Mapping verwijderen"
name="Delete mapping"
size="normal"
:can-close="false">
<p v-if="!success">
Wil je <b>{{ mappingStore.mappingItem.name }}</b> definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
Do you want to delete <b>{{ mappingStore.mappingItem.name }}</b>? This action cannot be undone.
</p>

<NcNoteCard v-if="success" type="success">
<p>Mapping succesvol verwijderd</p>
<p>Mapping successfully deleted</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
Expand All @@ -24,7 +24,7 @@ import { mappingStore, navigationStore } from '../../store/store.js'
<template #icon>
<Cancel :size="20" />
</template>
{{ success ? 'Sluiten' : 'Annuleer' }}
{{ success ? 'Close' : 'Cancel' }}
</NcButton>
<NcButton
v-if="!success"
Expand All @@ -35,7 +35,7 @@ import { mappingStore, navigationStore } from '../../store/store.js'
<NcLoadingIcon v-if="loading" :size="20" />
<TrashCanOutline v-if="!loading" :size="20" />
</template>
Verwijderen
Delete
</NcButton>
</template>
</NcDialog>
Expand Down Expand Up @@ -79,14 +79,15 @@ export default {
this.success = true
this.loading = false
this.error = false
mappingStore.setMappingItem(null)
setTimeout(() => {
this.success = false
navigationStore.setDialog(false)
}, 2000)
} catch (error) {
this.loading = false
this.success = false
this.error = error.message || 'Er is een fout opgetreden bij het verwijderen van de mapping'
this.error = error.message || 'An error occurred while deleting the mapping'
}
},
},
Expand Down
75 changes: 52 additions & 23 deletions src/modals/Mapping/EditMapping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,40 @@ import { mappingStore, navigationStore } from '../../store/store.js'
</script>

<template>
<NcModal v-if="navigationStore.modal === 'editMapping'" ref="modalRef" @close="navigationStore.setModal(false)">
<NcModal v-if="navigationStore.modal === 'editMapping'"
ref="modalRef"
label-id="editMapping"
@close="closeModal">
<div class="modalContent">
<h2>Mapping {{ mappingStore.mappingItem.id ? 'Aanpassen' : 'Aanmaken' }}</h2>
<h2>Mapping {{ mappingStore.mappingItem?.id ? 'Edit' : 'Add' }}</h2>
<NcNoteCard v-if="success" type="success">
<p>Mapping succesvol toegevoegd</p>
<p>Mapping successfully added</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>

<form v-if="!success" @submit.prevent="handleSubmit">
<div class="form-group">
<label for="name">Name:</label>
<input id="name" v-model="mappingStore.mappingItem.name" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea id="description" v-model="mappingStore.mappingItem.description" />
</div>
<div class="form-group">
<label for="sourceField">Source Field:</label>
<input id="sourceField" v-model="mappingStore.mappingItem.sourceField" required>
</div>
<div class="form-group">
<label for="targetField">Target Field:</label>
<input id="targetField" v-model="mappingStore.mappingItem.targetField" required>
<NcTextField
id="name"
label="Name"
:value.sync="mappingItem.name" />

<NcTextArea
id="description"
label="Description"
:value.sync="mappingItem.description" />

<NcTextField
id="reference"
label="Reference"
:value.sync="mappingItem.reference" />

<NcTextField
id="version"
label="Version"
:value.sync="mappingItem.version" />
</div>
</form>

Expand All @@ -41,7 +49,7 @@ import { mappingStore, navigationStore } from '../../store/store.js'
<NcLoadingIcon v-if="loading" :size="20" />
<ContentSaveOutline v-if="!loading" :size="20" />
</template>
Opslaan
Save
</NcButton>
</div>
</NcModal>
Expand All @@ -53,6 +61,8 @@ import {
NcModal,
NcLoadingIcon,
NcNoteCard,
NcTextField,
NcTextArea,
} from '@nextcloud/vue'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
Expand All @@ -63,29 +73,48 @@ export default {
NcButton,
NcLoadingIcon,
NcNoteCard,
NcTextField,
NcTextArea,
// Icons
ContentSaveOutline,
},
data() {
return {
mappingItem: {
id: mappingStore.mappingItem.id ?? null,
name: '',
description: '',
reference: '',
version: '',
},
success: false,
loading: false,
error: false,
}
},
methods: {
closeModal() {
navigationStore.setModal(false)
this.success = false
this.loading = false
this.error = false
this.mappingItem = {
id: null,
name: '',
description: '',
reference: '',
version: '',
}
},
async editMapping() {
this.loading = true
try {
await mappingStore.saveMapping()
await mappingStore.saveMapping(this.mappingItem)
// Close modal or show success message
this.success = true
this.loading = false
setTimeout(() => {
this.success = false
this.loading = false
this.error = false
navigationStore.setModal(false)
this.closeModal()
}, 2000)
} catch (error) {
this.loading = false
Expand Down
7 changes: 7 additions & 0 deletions src/modals/Modals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<EditLog />
<DeleteMapping />
<EditMapping />
<EditMappingMapping />
<DeleteMappingMapping />
<DeleteSynchronization />
<EditSynchronization />
<EditJobArgument />
Expand Down Expand Up @@ -39,6 +41,9 @@ import DeleteJobArgument from './JobArgument/DeleteJobArgument.vue'
import EditSourceConfiguration from './SourceConfiguration/EditSourceConfiguration.vue'
import DeleteSourceConfiguration from './SourceConfiguration/DeleteSourceConfiguration.vue'
import ViewLog from './Log/ViewLog.vue'
import EditMappingMapping from './mappingMapping/EditMappingMapping.vue'
import DeleteMappingMapping from './mappingMapping/DeleteMappingMapping.vue'
export default {
name: 'Modals',
components: {
Expand All @@ -59,6 +64,8 @@ export default {
EditSourceConfiguration,
DeleteSourceConfiguration,
ViewLog,
EditMappingMapping,
DeleteMappingMapping,
},
setup() {
return {
Expand Down
118 changes: 118 additions & 0 deletions src/modals/mappingMapping/DeleteMappingMapping.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<script setup>
import { navigationStore, mappingStore } from '../../store/store.js'
</script>

<template>
<NcDialog
v-if="navigationStore.modal === 'deleteMappingMapping'"
name="Delete Mapping"
:can-close="false">
<div v-if="success !== null || error">
<NcNoteCard v-if="success" type="success">
<p>Successfully deleted mapping</p>
</NcNoteCard>
<NcNoteCard v-if="!success" type="error">
<p>Something went wrong deleting the mapping</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>
</div>
<p v-if="success === null">
Do you want to delete <b>{{ mappingStore.mappingMappingKey }}</b>? This action cannot be undone.
</p>
<template #actions>
<NcButton :disabled="loading" icon="" @click="navigationStore.setModal(false)">
<template #icon>
<Cancel :size="20" />
</template>
{{ success !== null ? 'Close' : 'Cancel' }}
</NcButton>
<NcButton
v-if="success === null"
:disabled="loading"
icon="Delete"
type="error"
@click="deleteMappingMapping()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<Delete v-if="!loading" :size="20" />
</template>
Delete
</NcButton>
</template>
</NcDialog>
</template>

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
export default {
name: 'DeleteMappingMapping',
components: {
NcDialog,
NcButton,
NcNoteCard,
NcLoadingIcon,
// Icons
Cancel,
Delete,
},
data() {
return {
loading: false,
success: null,
error: false,
}
},
methods: {
deleteMappingMapping() {
this.loading = true
const mappingClone = { ...mappingStore.mappingItem }
delete mappingClone?.mapping[mappingStore.mappingMappingKey]
const mappingItem = {
...mappingStore.mappingItem,
}
mappingStore.saveMapping(mappingItem)
.then(() => {
this.loading = false
this.success = true
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
self.success = null
navigationStore.setModal(false)
}, 2000)
})
.catch((err) => {
this.error = err
this.loading = false
})
},
},
}
</script>
<style>
.modal__content {
margin: var(--OC-margin-50);
text-align: center;
}
.zaakDetailsContainer {
margin-block-start: var(--OC-margin-20);
margin-inline-start: var(--OC-margin-20);
margin-inline-end: var(--OC-margin-20);
}
.success {
color: green;
}
</style>
Loading

0 comments on commit ce1ff2c

Please sign in to comment.