Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,37 @@
}),
});

const { form, errors, submit, enhance } = superForm(
const { form, errors, validateForm } = superForm(
defaults(initialValues, yup(validationSchema)),
{
SPA: true,
validators: yup(validationSchema),
onUpdate({ form }) {
if (!form.valid) return;
const values = form.data;

onApply({
dimension: values.dimension,
oldDimension: dimensionName,
filter: {
measure: name,
operation: values.operation,
type: MeasureFilterType.Value,
value1: values.value1,
value2: values.value2 ?? "",
},
});

open = false;
},
dataType: "json",
invalidateAll: false,
resetForm: false,
},
);

async function submit() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? Cant we just use the old onUpdate with dataType: "json"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing without

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah idk when i revert to 10ac1c4, it doesnt close the modal and apply; tried a few variations and the one i landed on works;

lmk if you want to take over a look at it properly

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of nested forms with measure filter dropdown. Making sure measure filter form submits correctly instead here: #9322

That way it will also work with reports.

const result = await validateForm({ update: true });
if (!result.valid) return;
const values = result.data;

onApply({
dimension: values.dimension,
oldDimension: dimensionName,
filter: {
measure: name,
operation: values.operation,
type: MeasureFilterType.Value,
value1: values.value1,
value2: values.value2 ?? "",
},
});

open = false;
}

$: ({ operation } = $form);

$: isBetweenExpression = expressionIsBetween(operation);
Expand Down Expand Up @@ -141,12 +144,7 @@
/>
</div>
{/if}
<form
use:enhance
autocomplete="off"
class="flex flex-col gap-y-3"
id="measure"
>
<div class="flex flex-col gap-y-3">
<Select
bind:value={$form["dimension"]}
id="dimension"
Expand Down Expand Up @@ -193,6 +191,6 @@
/>
{/if}

<Button submitForm type="primary" form="measure">Apply</Button>
</form>
<Button type="primary" onClick={submit}>Apply</Button>
</div>
</Popover.Content>
Loading