Skip to content

Commit e6742bc

Browse files
committed
Added sourceHashMapping in frontend
1 parent cbef4f2 commit e6742bc

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

src/entities/synchronization/synchronization.mock.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const mockSynchronizationData = (): TSynchronization[] => [
99
sourceId: 'source1',
1010
sourceType: 'api',
1111
sourceHash: 'source1',
12+
sourceHashMapping: '1',
1213
sourceTargetMapping: 'source1',
1314
sourceConfig: {},
1415
sourceLastChanged: '2023-05-01T12:00:00Z',
@@ -32,6 +33,7 @@ export const mockSynchronizationData = (): TSynchronization[] => [
3233
sourceId: 'source2',
3334
sourceType: 'api',
3435
sourceHash: 'source2',
36+
sourceHashMapping: '1',
3537
sourceTargetMapping: 'source2',
3638
sourceConfig: {},
3739
sourceLastChanged: '2023-05-02T12:00:00Z',

src/entities/synchronization/synchronization.ts

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati
1111
public sourceId: string
1212
public sourceType: string
1313
public sourceHash: string
14+
public sourceHashMapping: string
1415
public sourceTargetMapping: string
1516
public sourceConfig: Record<string, string>
1617
public sourceLastChanged: string
@@ -35,6 +36,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati
3536
sourceId: synchronization.sourceId || '',
3637
sourceType: synchronization.sourceType || '',
3738
sourceHash: synchronization.sourceHash || '',
39+
sourceHashMapping: synchronization.sourceHashMapping || '',
3840
sourceTargetMapping: synchronization.sourceTargetMapping || '',
3941
sourceConfig: synchronization.sourceConfig || {},
4042
sourceLastChanged: synchronization.sourceLastChanged || '',
@@ -63,6 +65,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati
6365
sourceId: z.string(),
6466
sourceType: z.string(),
6567
sourceHash: z.string(),
68+
sourceHashMapping: z.string(),
6669
sourceTargetMapping: z.string(),
6770
sourceConfig: z.record(z.string(), z.string()),
6871
sourceLastChanged: z.string(),

src/entities/synchronization/synchronization.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type TSynchronization = {
55
sourceId: string
66
sourceType: string
77
sourceHash: string
8+
sourceHashMapping: string
89
sourceTargetMapping: string
910
sourceConfig: Record<string, string>
1011
sourceLastChanged: string

src/modals/Synchronization/EditSynchronization.vue

+17-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ import { synchronizationStore, navigationStore, sourceStore, mappingStore } from
9090
:loading="sourcesLoading"
9191
input-label="Source ID" />
9292

93+
<NcSelect v-bind="sourceTargetMappingOptions"
94+
v-model="sourceTargetMappingOptions.hashValue"
95+
:loading="sourceTargetMappingLoading"
96+
input-label="Source hash mapping" />
97+
9398
<NcSelect v-bind="sourceTargetMappingOptions"
9499
v-model="sourceTargetMappingOptions.sourceValue"
95100
:loading="sourceTargetMappingLoading"
96-
input-label="sourceTargetMapping" />
101+
input-label="Source target mapping" />
97102

98103
<NcTextField :value.sync="synchronizationItem.sourceConfig.idPosition"
99104
label="(optional) Position of id in source object" />
@@ -135,7 +140,7 @@ import { synchronizationStore, navigationStore, sourceStore, mappingStore } from
135140
<NcSelect v-bind="sourceTargetMappingOptions"
136141
v-model="sourceTargetMappingOptions.targetValue"
137142
:loading="sourceTargetMappingLoading"
138-
input-label="targetSourceMapping" />
143+
input-label="Target source mapping" />
139144
</form>
140145

141146
<NcButton v-if="!success"
@@ -208,6 +213,7 @@ export default {
208213
headers: {},
209214
query: {},
210215
},
216+
sourceHashMapping: '',
211217
sourceTargetMapping: '',
212218
targetId: '',
213219
targetType: 'register/schema',
@@ -234,6 +240,7 @@ export default {
234240
sourceTargetMappingLoading: false, // Indicates if the mappings are loading
235241
sourceTargetMappingOptions: { // A list of mappings
236242
options: [],
243+
hashValue: null,
237244
sourceValue: null,
238245
targetValue: null,
239246
},
@@ -340,12 +347,19 @@ export default {
340347
.then(({ entities }) => {
341348
const activeSourceMapping = entities.find(mapping => mapping.id.toString() === this.synchronizationItem.sourceTargetMapping.toString())
342349
const activeTargetMapping = entities.find(mapping => mapping.id.toString() === this.synchronizationItem.targetSourceMapping.toString())
350+
const sourceHashMapping = entities.find(mapping => mapping.id.toString() === this.synchronizationItem.sourceHashMapping.toString())
343351
344352
this.sourceTargetMappingOptions = {
345353
options: entities.map(mapping => ({
346354
label: mapping.name,
347355
id: mapping.id,
348356
})),
357+
hashValue: sourceHashMapping
358+
? {
359+
label: sourceHashMapping.name,
360+
id: sourceHashMapping.id,
361+
}
362+
: null,
349363
sourceValue: activeSourceMapping
350364
? {
351365
label: activeSourceMapping.name,
@@ -528,6 +542,7 @@ export default {
528542
...this.synchronizationItem,
529543
sourceId: this.sourceOptions.sourceValue?.id || null,
530544
sourceType: this.typeOptions.value?.id || null,
545+
sourceHashMapping: this.sourceTargetMappingOptions.hashValue?.id || null,
531546
sourceTargetMapping: this.sourceTargetMappingOptions.sourceValue?.id || null,
532547
targetType: this.targetTypeOptions.value?.id || null,
533548
targetId: targetId || null,

src/views/Synchronization/SynchronizationDetails.vue

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ import { synchronizationStore, navigationStore, logStore } from '../../store/sto
8888
<b>Source Hash:</b>
8989
<p>{{ synchronizationStore.synchronizationItem.sourceHash || 'N/A' }}</p>
9090
</div>
91+
<div class="gridContent gridFullWidth">
92+
<b>Source Hash mapping id:</b>
93+
<p>{{ synchronizationStore.synchronizationItem.sourceHashMapping || 'N/A' }}</p>
94+
</div>
9195
<div class="gridContent gridFullWidth">
9296
<b>Source Last Changed:</b>
9397
<p>{{ synchronizationStore.synchronizationItem.sourceLastChanged || 'N/A' }}</p>

0 commit comments

Comments
 (0)