Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#317: Improve validation logic and button formatting #563

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 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 @@ -139,6 +142,7 @@ Licensed under the Elastic License 2.0. */
}

function toggleRowEdit(item: InterventionTriggerUpdateItem): void {
console.log(item);
janoliver20 marked this conversation as resolved.
Show resolved Hide resolved
if (typeof triggerConditionObj.value.value !== 'undefined') {
triggerConditionObj.value.value[item.groupIndex].parameter[
item.rowIndex
Expand Down Expand Up @@ -183,11 +187,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 +241,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 +293,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 +339,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() === '')
);
};
Loading