Skip to content

Commit

Permalink
New intervention not working (#5489)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Szendrey authored Nov 14, 2024
1 parent b0a4cf7 commit 7f61bdd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const onBlur = () => {
watch(
() => props.modelValue,
(newValue) => {
if (isNaN(newValue)) return;
maskedValue.value = newValue?.toString() ?? '';
if (isNaN(newValue)) maskedValue.value = '';
else maskedValue.value = newValue?.toString() ?? '';
},
{ immediate: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:disabled="!props.node.inputs[0]?.value && !props.node.inputs[1]?.value"
@click="extractInterventionPolicyFromInputs"
/>
<Button class="ml-1" label="Create New" :disabled="!model?.id" @click="createNewInterventionPolicy" />
<Button class="ml-1" label="Create New" :disabled="!model?.id" @click="resetToBlankIntervention" />
</nav>
<tera-input-text v-model="filterInterventionsText" placeholder="Filter" />
<ul v-if="!isFetchingPolicies">
Expand Down Expand Up @@ -175,9 +175,9 @@
</tera-columnar-panel>
</tera-drilldown>
<tera-save-asset-modal
:initial-name="showCreatePolicyModal ? 'New Intervention Policy' : knobs.transientInterventionPolicy.name"
:initial-name="knobs.transientInterventionPolicy.name"
:is-visible="showSaveModal"
:asset="showCreatePolicyModal ? newBlankInterventionPolicy : knobs.transientInterventionPolicy"
:asset="knobs.transientInterventionPolicy"
:asset-type="AssetType.InterventionPolicy"
@close-modal="showSaveModal = false"
@on-save="onSaveAsInterventionPolicy"
Expand Down Expand Up @@ -261,12 +261,6 @@ const knobs = ref<BasicKnobs>({
}
});
const newBlankInterventionPolicy = ref({
name: '',
modelId: '',
interventions: [blankIntervention]
});
interface SelectedIntervention {
index: number;
name: string;
Expand All @@ -285,7 +279,6 @@ const isFetchingPDF = ref(false);
const pdfData = ref<{ document: DocumentAsset; data: string; isPdf: boolean; name: string }[]>([]);
const showSaveModal = ref(false);
const showCreatePolicyModal = ref(false);
const isSidebarOpen = ref(true);
const filterInterventionsText = ref('');
const model = ref<Model | null>(null);
Expand All @@ -297,8 +290,8 @@ const interventionPoliciesFiltered = computed(() =>
.filter((policy) => policy.name?.toLowerCase().includes(filterInterventionsText.value.toLowerCase()))
.sort((a, b) => sortDatesDesc(a.createdOn, b.createdOn))
);
const selectedOutputId = ref<string>('');
const selectedPolicyId = computed(() => props.node.outputs.find((o) => o.id === selectedOutputId.value)?.value?.[0]);
const selectedPolicyId = computed(() => props.node.outputs.find((o) => o.id === props.node.active)?.value?.[0]);
const selectedPolicy = ref<InterventionPolicy | null>(null);
const newDescription = ref('');
Expand Down Expand Up @@ -534,7 +527,6 @@ const onResetPolicy = () => {
};
const onSaveAsInterventionPolicy = (data: InterventionPolicy) => {
showCreatePolicyModal.value = false;
applyInterventionPolicy(data);
};
Expand All @@ -556,11 +548,19 @@ const onSaveInterventionPolicy = async () => {
}
};
const createNewInterventionPolicy = () => {
if (!model.value?.id) return;
showCreatePolicyModal.value = true;
newBlankInterventionPolicy.value.modelId = model.value.id;
showSaveModal.value = true;
const resetToBlankIntervention = () => {
const modelId = props.node.inputs[0].value?.[0];
if (!modelId) return;
knobs.value.transientInterventionPolicy = {
modelId,
interventions: [_.cloneDeep(blankIntervention)]
};
emit('append-output', {
type: InterventionPolicyOperation.outputs[0].type,
label: InterventionPolicyOperation.outputs[0].label,
value: null
});
};
const extractInterventionPolicyFromInputs = async () => {
Expand Down Expand Up @@ -600,7 +600,6 @@ watch(
() => props.node.active,
() => {
if (props.node.active) {
selectedOutputId.value = props.node.active;
initialize();
}
}
Expand All @@ -622,7 +621,6 @@ watch(
onMounted(() => {
if (props.node.active) {
selectedOutputId.value = props.node.active;
// setting true will force overwrite the intervention policy with the current state on the node
initialize(true);
} else {
Expand Down

0 comments on commit 7f61bdd

Please sign in to comment.