Skip to content

Commit b0e5a75

Browse files
committed
#2249 add check against dwc datasets based on extension list.
add settings to show and hide this option.
1 parent d59ef22 commit b0e5a75

File tree

19 files changed

+207
-40
lines changed

19 files changed

+207
-40
lines changed

BExIS++.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,8 @@ Global
16061606
{37402CAB-EB81-4D08-8791-8653949C0FEB} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
16071607
EndGlobalSection
16081608
GlobalSection(ExtensibilityGlobals) = postSolution
1609-
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35
16101609
SolutionGuid = {9B6E4921-8EBA-487D-A098-3E473A0EAC64}
1610+
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35
16111611
EndGlobalSection
16121612
GlobalSection(SubversionScc) = preSolution
16131613
Svn-Managed = True

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"type": "module",
5252
"dependencies": {
5353
"@bexis2/bexis2-core-ui": "0.4.58",
54-
"@bexis2/bexis2-rpm-ui": "0.2.13",
54+
"@bexis2/bexis2-rpm-ui": "0.2.14",
5555
"@floating-ui/dom": "1.6.8",
5656
"@fortawesome/free-solid-svg-icons": "6.6.0",
5757
"@sveltejs/adapter-static": "3.0.2",

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bexis2/bexis2-rpm-ui",
3-
"version": "0.2.13",
3+
"version": "0.2.14",
44
"private": false,
55
"scripts": {
66
"dev": "vite dev",

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/src/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
enforcePrimaryKey="true"
2626
changeablePrimaryKey="true"
2727
updateDescriptionByTemplate="false"
28+
showDarwinCoreValidation="true"
2829
>
2930
%sveltekit.body%
3031
</div>

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/src/lib/components/datastructure/services.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ export const getConstraints = async () => {
206206
}
207207
};
208208

209+
export const getDWCList = async () => {
210+
try {
211+
const response = await Api.get('/rpm/DataStructure/getDWCRequirements');
212+
return response.data;
213+
} catch (error) {
214+
console.error(error);
215+
}
216+
};
217+
209218
// go to a internal action
210219
export const goTo = async (url: string) => {
211220
window.open(host + url, '_self').focus();

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/src/lib/components/datastructure/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ export const enforcePrimaryKeyStore = writable<boolean>(false);
1515
export const changeablePrimaryKeyStore = writable<boolean>(false);
1616
export const meaningsStore = writable<meaningListItemType[]>([]);
1717
export const constraintsStore = writable<listItemType[]>([]);
18+
export const showDarwinCoreValidationStore = writable<boolean>(false);
1819

1920
export const x = writable(1);

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/src/lib/components/datastructure/structure/CreateStructure.svelte

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@
1717
import { goTo } from '$services/BaseCaller';
1818
import { get } from 'svelte/store';
1919
20-
import type { DataStructureCreationModel } from '../types';
21-
import { Alert, helpStore } from '@bexis2/bexis2-core-ui';
20+
import type { DataStructureCreationModel, dwcExtention } from '../types';
21+
import { Alert, helpStore, MultiSelect } from '@bexis2/bexis2-core-ui';
2222
import { type ModalSettings, getModalStore } from '@skeletonlabs/skeleton';
23+
import DwcRequirements from './DwcRequirements.svelte';
2324
const modalStore = getModalStore();
2425
2526
export let model: DataStructureCreationModel;
27+
export let dwcExtensions: dwcExtention[] = [];
28+
29+
// let dwcSelections:dwcExtention[] = [];
30+
// $: dwcSelections;
31+
let dwcSelection:dwcExtention;
32+
let notSet:string[] = [];
33+
2634
let enforcePrimaryKey: boolean = get(enforcePrimaryKeyStore);
2735
2836
$: isPKSet = false;
@@ -81,10 +89,11 @@
8189
};
8290
modalStore.trigger(confirm);
8391
}
92+
8493
</script>
8594

86-
<div>
87-
<div transition:fade class="flex">
95+
<div class="gap-4">
96+
<div transition:fade class="flex gap-5 items-start">
8897
<div class="grow">
8998
{#if model.file}
9099
<button
@@ -97,6 +106,7 @@
97106
>
98107
{/if}
99108
</div>
109+
100110
<div class="flex-none text-end">
101111
<button
102112
id="cancel"
@@ -118,6 +128,7 @@
118128
!areAttributesValid ||
119129
!((enforcePrimaryKey && isPKSet) || !enforcePrimaryKey)}><Fa icon={faSave} /></button
120130
>
131+
121132
</div>
122133
</div>
123134

@@ -127,6 +138,7 @@
127138
></Alert>
128139
{/if}
129140

141+
130142
<Variables
131143
bind:variables={model.variables}
132144
bind:valid={areVariablesValid}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<script lang="ts">
2+
import { MultiSelect } from "@bexis2/bexis2-core-ui";
3+
import { getDWCList } from "../services";
4+
import { onMount } from "svelte";
5+
import { get } from "svelte/store";
6+
import type { dwcExtention, VariableInstanceModel } from "../types";
7+
import { showDarwinCoreValidationStore } from "../store";
8+
9+
export let variables:VariableInstanceModel[] = [];
10+
$: variables, validateDWCfn();
11+
12+
let dwcExtensions: dwcExtention[] = [];
13+
let dwcSelection: dwcExtention | null = null;
14+
let notSet: string[] = [];
15+
16+
const isActive = get(showDarwinCoreValidationStore);
17+
18+
onMount( async () => {
19+
20+
// dwc extensions
21+
dwcExtensions = await getDWCList();
22+
console.log("🚀 ~ start ~ dwcExtensions:", dwcExtensions)
23+
24+
}
25+
);
26+
27+
28+
function validateDWCfn() {
29+
30+
if(!dwcSelection) return;
31+
32+
// get all set meanings
33+
const allMeanings = variables.map(v => v.meanings.map(m => m.text)).flat();
34+
// get all not set required fields
35+
const notSetFields = dwcSelection.requiredFields.filter((field) => !allMeanings.includes(field));
36+
37+
notSet = [...notSetFields];
38+
39+
if(notSet.length === 0){
40+
notSet = [];
41+
}
42+
}
43+
44+
45+
</script>
46+
47+
<div class="flex items-end gap-2">
48+
{#if dwcExtensions && isActive}
49+
<MultiSelect
50+
id="check_dwc"
51+
title="validate against darwin core datatset"
52+
source={dwcExtensions}
53+
bind:target = {dwcSelection}
54+
itemId="name"
55+
itemLabel="name"
56+
complexSource={true}
57+
complexTarget={true}
58+
isMulti={false}
59+
on:change={() => validateDWCfn()}
60+
on:clear={() => {
61+
notSet = [];
62+
dwcSelection = null;
63+
}}
64+
/>
65+
{#if notSet}
66+
{#if notSet.length > 0}
67+
{#each notSet as field, i}
68+
<div><span class="chip variant-filled-warning">{field}</span></div>
69+
{/each}
70+
{:else}
71+
{#if dwcSelection}
72+
<div><span class="chip variant-filled-success">All required fields are set.</span></div>
73+
{/if}
74+
{/if}
75+
{/if}
76+
{/if}
77+
</div>

Console/BExIS.Web.Shell/Areas/RPM/BExIS.Modules.Rpm.UI.Svelte/src/lib/components/datastructure/structure/Variables.svelte

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import Variable from './variable/Variable.svelte';
33
import { Spinner, helpStore } from '@bexis2/bexis2-core-ui';
4-
import { onMount } from 'svelte';
4+
import { onMount, createEventDispatcher } from 'svelte';
55
66
import type { missingValueType } from '../types';
77
import { VariableInstanceModel } from '../types';
@@ -39,12 +39,15 @@
3939
meaningsStore,
4040
constraintsStore
4141
} from '../store';
42+
import DwcRequirements from './DwcRequirements.svelte';
4243
4344
export let variables: VariableInstanceModel[] = [];
4445
export let missingValues: missingValueType[] = [];
4546
export let data: string[][];
4647
export let dataExist: boolean = false;
4748
49+
const dispatch = createEventDispatcher();
50+
4851
$: variables;
4952
5053
let expandAll = true;
@@ -92,10 +95,16 @@
9295
}
9396
}
9497
98+
function varChangeFn()
99+
{
100+
checkValidationState();
101+
dispatch("changed")
102+
}
95103
// every time when validation state of a variable is change,
96104
// this function triggered an check whether save button can be active or not
97105
function checkValidationState() {
98106
valid = variableValidationStates.every((v: boolean) => v === true);
107+
99108
//console.log("TCL ~ file: Variables.svelte:63 ~ checkValidationState ~ variableValidationStates:", variableValidationStates)
100109
}
101110
@@ -221,7 +230,7 @@
221230
</script>
222231

223232
<div class="p-2">
224-
<div class="flex gap-2 items-baseline">
233+
<div class="flex gap-2 items-end">
225234
<button
226235
id="variables-expander"
227236
class="btn variant-filled-secondary"
@@ -236,22 +245,25 @@
236245
{/if}
237246
</button>
238247

239-
<div class="pr-32 w-auto">
240-
{#if !valid}
241-
<span class="text-sm">Variables with errors:</span>
242-
{#each variableValidationStates as v, i}
243-
{#if v == false && variables[i] != undefined}
244-
<a class="chip variant-filled-error m-1" href="#{i}">
245-
{#if variables[i].name != ''}
246-
{variables[i].name}
247-
{:else}
248-
{i + 1}
249-
{/if}
250-
</a>
251-
{/if}
252-
{/each}
253-
{/if}
254-
</div>
248+
<DwcRequirements bind:variables={variables} />
249+
250+
251+
</div>
252+
<div class="pr-32 w-auto">
253+
{#if !valid}
254+
<span class="text-sm">Variables with errors:</span>
255+
{#each variableValidationStates as v, i}
256+
{#if v == false && variables[i] != undefined}
257+
<a class="chip variant-filled-error m-1" href="#{i}">
258+
{#if variables[i].name != ''}
259+
{variables[i].name}
260+
{:else}
261+
{i + 1}
262+
{/if}
263+
</a>
264+
{/if}
265+
{/each}
266+
{/if}
255267
</div>
256268
<div class="flex-col space-y-2 mt-1">
257269
{#if variables && missingValues && ready}
@@ -260,7 +272,7 @@
260272
<Variable
261273
bind:variable
262274
index={i}
263-
on:var-change={checkValidationState}
275+
on:var-change={varChangeFn}
264276
bind:isValid={variableValidationStates[i]}
265277
bind:missingValues
266278
data={getColumnData(i)}

0 commit comments

Comments
 (0)