Skip to content

Commit 7a1cad7

Browse files
committed
IOT-1487: Improved error-message when http- or oddk-datatarget has devices-decoder-elements with no device specified...
1 parent ef2410d commit 7a1cad7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/app/applications/datatarget/httppush/httppush-edit/httppush-edit.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class HttppushEditComponent
154154
onSubmit(): void {
155155
this.counter = 0;
156156
if (this.datatargetid) {
157+
if (!this.validatePayloadDeviceDatatarget()) return;
157158
this.updateDatatarget();
158159
this.addPayloadDeviceDatatarget();
159160
} else {
@@ -209,6 +210,20 @@ export class HttppushEditComponent
209210
});
210211
}
211212

213+
private validatePayloadDeviceDatatarget = () => {
214+
const isError = this.payloadDeviceDatatarget?.some(
215+
(relation) => (relation.iotDeviceIds?.length ?? 0) < 1
216+
);
217+
if (isError) {
218+
this.errorFields = ['devices'];
219+
this.errorMessages = [
220+
'Must attach at least one IoT-device for each element in list of devices / decoders',
221+
];
222+
this.scrollToTopService.scrollToTop();
223+
}
224+
return !isError;
225+
};
226+
212227
countToRedirect() {
213228
this.counter -= 1;
214229
if (this.counter <= 0 && !this.formFailedSubmit) {

src/app/applications/datatarget/opendatadk/opendatadk-edit/opendatadk-edit.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
158158
onSubmit(): void {
159159
this.resetErrors();
160160
if (this.datatargetId) {
161+
if (!this.validatePayloadDeviceDatatarget()) return;
161162
this.pendingRequestsCounter =
162163
1 + (this.payloadDeviceDatatarget?.length ?? 0);
163164
this.updateDatatarget();
@@ -206,6 +207,19 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
206207
}
207208
});
208209
}
210+
private validatePayloadDeviceDatatarget = () => {
211+
const isError = this.payloadDeviceDatatarget?.some(
212+
(relation) => (relation.iotDeviceIds?.length ?? 0) < 1
213+
);
214+
if (isError) {
215+
this.errorFields = ['devices'];
216+
this.errorMessages = [
217+
'Must attach at least one IoT-device for each element in list of devices / decoders',
218+
];
219+
this.scrollToTopService.scrollToTop();
220+
}
221+
return !isError;
222+
};
209223
private createDatatarget() {
210224
this.pendingRequestsCounter = 0;
211225
this.datatarget.applicationId = this.applicationId;

0 commit comments

Comments
 (0)