Skip to content

Commit

Permalink
Merge pull request #563 from MORE-Platform/317-configuring-a-trigger-…
Browse files Browse the repository at this point in the history
…--0-for-gps-data-throws-error

#317: Improve validation logic and button formatting
  • Loading branch information
janoliver20 authored Dec 3, 2024
2 parents 94e3ed6 + 54463dd commit 6656909
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/forms/InterventionTriggerConditions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Licensed under the Elastic License 2.0. */
QueryObjectInner,
} from '../../models/InputModels';
import { useI18n } from 'vue-i18n';
import { hasData } from '../../utils/dataUtils';
const studyStore = useStudyStore();
const { t } = useI18n();
Expand Down Expand Up @@ -83,6 +85,7 @@ Licensed under the Elastic License 2.0. */
emit('onError', rowOpenError.value);
}
}
function setTriggerConditionError(triggerTableE?: string): void {
emit('onError', triggerTableE ? triggerTableE : '');
}
Expand Down Expand Up @@ -183,11 +186,11 @@ Licensed under the Elastic License 2.0. */
function validateEditedRow(triggerConfig: QueryObjectInner): boolean {
return !!(
triggerConfig.observationId &&
triggerConfig.observationId !== undefined &&
triggerConfig.observationType &&
triggerConfig.observationProperty &&
triggerConfig.operator &&
triggerConfig.propertyValue
hasData(triggerConfig.propertyValue)
);
}
Expand Down Expand Up @@ -237,6 +240,7 @@ Licensed under the Elastic License 2.0. */
}
checkTriggerConditionErrors();
}
function deleteRow(item: InterventionTriggerUpdateItem): void {
if (typeof triggerConditionObj.value.value !== 'undefined') {
triggerConditionObj.value.value[item.groupIndex].parameter.splice(
Expand Down Expand Up @@ -288,10 +292,10 @@ Licensed under the Elastic License 2.0. */
"
class="my-6 w-full text-center"
>
<Button type="button" class="p-button my-6" @click="addTriggerGroup()"
><span class="pi pi-plus mr-2"></span>
{{ $t('intervention.dialog.label.addTriggerGroup') }}</Button
>
<Button type="button" class="p-button my-6" @click="addTriggerGroup()">
<span class="pi pi-plus mr-2" />
{{ $t('intervention.dialog.label.addTriggerGroup') }}
</Button>
</div>
</Suspense>

Expand Down Expand Up @@ -334,8 +338,8 @@ Licensed under the Elastic License 2.0. */
:disabled="!editable"
@click="addTriggerGroup(-1)"
><span class="pi pi-plus mr-2"></span>
{{ $t('intervention.dialog.label.addTriggerGroup') }}</Button
>
{{ $t('intervention.dialog.label.addTriggerGroup') }}
</Button>
</div>
</div>
</Suspense>
Expand Down
7 changes: 7 additions & 0 deletions src/utils/dataUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const hasData = (data?: string | number): boolean => {
return !(
data === undefined ||
data === null ||
(typeof data === 'string' && data.trim() === '')
);
};

0 comments on commit 6656909

Please sign in to comment.