Skip to content

Commit 8a26148

Browse files
committed
Fixes Problem with deleting optional idShort in SMLs
1 parent 4af2bb6 commit 8a26148

File tree

13 files changed

+94
-41
lines changed

13 files changed

+94
-41
lines changed

aas-web-ui/src/components/EditorComponents/SubmodelElements/AnnotatedRelationshipElementForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,14 @@
251251
annotatedRelationshipElementObject.value = new aasTypes.AnnotatedRelationshipElement();
252252
}
253253
254-
if (annotatedRelationshipElementIdShort.value !== null) {
255-
annotatedRelationshipElementObject.value.idShort = annotatedRelationshipElementIdShort.value;
254+
const normalizedIdShort = annotatedRelationshipElementIdShort.value?.trim() ?? null;
255+
if (normalizedIdShort) {
256+
annotatedRelationshipElementObject.value.idShort = normalizedIdShort;
256257
} else if (!isParentSubmodelElementList.value) {
257258
errors.value.set('idShort', 'Annotated Relationship Element IdShort is required');
258259
return;
260+
} else {
261+
(annotatedRelationshipElementObject.value as Record<string, unknown>).idShort = null;
259262
}
260263
261264
annotatedRelationshipElementObject.value.first = firstReference.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/BlobForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,14 @@ usage of the 'Enter' key, make sure to edit the keyDown/keyUp method to not exec
282282
blobObject.value = new aasTypes.Blob();
283283
}
284284
285-
if (blobIdShort.value !== null) {
286-
blobObject.value.idShort = blobIdShort.value;
285+
const normalizedIdShort = blobIdShort.value?.trim() ?? null;
286+
if (normalizedIdShort) {
287+
blobObject.value.idShort = normalizedIdShort;
287288
} else if (!isParentSubmodelElementList.value) {
288289
errors.value.set('idShort', 'Blob Element IdShort is required');
289290
return;
291+
} else {
292+
(blobObject.value as Record<string, unknown>).idShort = null;
290293
}
291294
292295
blobObject.value.value = blobContent.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/CollectionForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,14 @@
211211
smcObject.value = new aasTypes.SubmodelElementCollection();
212212
}
213213
214-
if (smcIdShort.value !== null) {
215-
smcObject.value.idShort = smcIdShort.value;
214+
const normalizedIdShort = smcIdShort.value?.trim() ?? null;
215+
if (normalizedIdShort) {
216+
smcObject.value.idShort = normalizedIdShort;
216217
} else if (!isParentSubmodelElementList.value) {
217218
errors.value.set('idShort', 'SubmodelElementCollection IdShort is required');
218219
return;
220+
} else {
221+
(smcObject.value as Record<string, unknown>).idShort = null;
219222
}
220223
221224
if (semanticId.value !== null) {

aas-web-ui/src/components/EditorComponents/SubmodelElements/EntityForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,14 @@
240240
entityObject.value = new aasTypes.Entity();
241241
}
242242
243-
if (entityIdShort.value !== null) {
244-
entityObject.value.idShort = entityIdShort.value;
243+
const normalizedIdShort = entityIdShort.value?.trim() ?? null;
244+
if (normalizedIdShort) {
245+
entityObject.value.idShort = normalizedIdShort;
245246
} else if (!isParentSubmodelElementList.value) {
246247
errors.value.set('idShort', 'Entity IdShort is required');
247248
return;
249+
} else {
250+
(entityObject.value as Record<string, unknown>).idShort = null;
248251
}
249252
250253
entityObject.value.entityType = entityType.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/FileForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,14 @@
284284
fileObject.value = new aasTypes.File();
285285
}
286286
287-
if (fileIdShort.value !== null) {
288-
fileObject.value.idShort = fileIdShort.value;
287+
const normalizedIdShort = fileIdShort.value?.trim() ?? null;
288+
if (normalizedIdShort) {
289+
fileObject.value.idShort = normalizedIdShort;
289290
} else if (!isParentSubmodelElementList.value) {
290291
errors.value.set('idShort', 'File Element IdShort is required');
291292
return;
293+
} else {
294+
(fileObject.value as Record<string, unknown>).idShort = null;
292295
}
293296
294297
fileObject.value.value = filePath.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/ListForm.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
v-model="smlIdShort"
1818
label="IdShort"
1919
:error="hasError('idShort')"
20-
:rules="[rules.required]"
20+
:rules="isParentSubmodelElementList ? [] : [rules.required]"
2121
:error-messages="getError('idShort')" />
2222
</v-col>
2323
<v-col cols="auto" class="px-0">
@@ -182,6 +182,8 @@
182182
183183
const errors = ref<Map<string, string>>(new Map());
184184
185+
const isParentSubmodelElementList = computed(() => props.parentElement?.modelType === 'SubmodelElementList');
186+
185187
const rules = {
186188
required: (value: any) => !!value || 'Required.',
187189
};
@@ -296,11 +298,14 @@
296298
smlObject.value = new aasTypes.SubmodelElementList(aasTypes.AasSubmodelElements.SubmodelElement);
297299
}
298300
299-
if (smlIdShort.value !== null) {
300-
smlObject.value.idShort = smlIdShort.value;
301-
} else {
301+
const normalizedIdShort = smlIdShort.value?.trim() ?? null;
302+
if (normalizedIdShort) {
303+
smlObject.value.idShort = normalizedIdShort;
304+
} else if (!isParentSubmodelElementList.value) {
302305
errors.value.set('idShort', 'SubmodelElementList IdShort is required');
303306
return;
307+
} else {
308+
(smlObject.value as Record<string, unknown>).idShort = null;
304309
}
305310
306311
if (semanticId.value !== null) {

aas-web-ui/src/components/EditorComponents/SubmodelElements/MLPForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,14 @@
234234
mlpObject.value = new aasTypes.MultiLanguageProperty();
235235
}
236236
237-
if (mlpIdShort.value !== null) {
238-
mlpObject.value.idShort = mlpIdShort.value;
237+
const normalizedIdShort = mlpIdShort.value?.trim() ?? null;
238+
if (normalizedIdShort) {
239+
mlpObject.value.idShort = normalizedIdShort;
239240
} else if (!isParentSubmodelElementList.value) {
240241
errors.value.set('idShort', 'MultiLanguageProperty IdShort is required');
241242
return;
243+
} else {
244+
(mlpObject.value as Record<string, unknown>).idShort = null;
242245
}
243246
244247
if (semanticId.value !== null) {

aas-web-ui/src/components/EditorComponents/SubmodelElements/PropertyForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,14 @@
289289
propertyObject.value = new aasTypes.Property(valueType.value);
290290
}
291291
292-
if (propertyIdShort.value !== null) {
293-
propertyObject.value.idShort = propertyIdShort.value;
292+
const normalizedIdShort = propertyIdShort.value?.trim() ?? null;
293+
if (normalizedIdShort) {
294+
propertyObject.value.idShort = normalizedIdShort;
294295
} else if (!isParentSubmodelElementList.value) {
295296
errors.value.set('idShort', 'Property IdShort is required');
296297
return;
298+
} else {
299+
(propertyObject.value as Record<string, unknown>).idShort = null;
297300
}
298301
299302
propertyObject.value.value = propertyValue.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/RangeForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,14 @@
258258
rangeObject.value = new aasTypes.Range(valueType.value);
259259
}
260260
261-
if (rangeIdShort.value !== null) {
262-
rangeObject.value.idShort = rangeIdShort.value;
261+
const normalizedIdShort = rangeIdShort.value?.trim() ?? null;
262+
if (normalizedIdShort) {
263+
rangeObject.value.idShort = normalizedIdShort;
263264
} else if (!isParentSubmodelElementList.value) {
264265
errors.value.set('idShort', 'Range IdShort is required');
265266
return;
267+
} else {
268+
(rangeObject.value as Record<string, unknown>).idShort = null;
266269
}
267270
268271
rangeObject.value.min = minValue.value;

aas-web-ui/src/components/EditorComponents/SubmodelElements/ReferenceElementForm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,14 @@
241241
referenceElementObject.value = new aasTypes.ReferenceElement();
242242
}
243243
244-
if (referenceElementIdShort.value !== null) {
245-
referenceElementObject.value.idShort = referenceElementIdShort.value;
244+
const normalizedIdShort = referenceElementIdShort.value?.trim() ?? null;
245+
if (normalizedIdShort) {
246+
referenceElementObject.value.idShort = normalizedIdShort;
246247
} else if (!isParentSubmodelElementList.value) {
247248
errors.value.set('idShort', 'Reference Element IdShort is required');
248249
return;
250+
} else {
251+
(referenceElementObject.value as Record<string, unknown>).idShort = null;
249252
}
250253
251254
referenceElementObject.value.value = referenceElementValue.value;

0 commit comments

Comments
 (0)