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

revert: changes to form stories #4648

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
36 changes: 6 additions & 30 deletions apps/tailwind-components/components/form/Field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,30 @@ function validate(value: columnValue) {

formFieldInput.value.validate(value);
}

const refData = ref();

onMounted(async () => {
if (["ONTOLOGY", "ONTOLOGY_ARRAY"].includes(props.column.columnType)) {
const response = await fetchTableData(
props.column.refSchemaId as string,
props.column.refTableId as string
);
refData.value = response.rows.map((row) => row.name);
}
});
</script>

<template>
<div class="flex flex-col gap-1">
<div>
<label
:id="`${column.id}-label`"
:for="column.id"
class="capitalize text-title font-bold"
>{{ column.label }}</label
>
<label :for="column.id" class="capitalize text-title font-bold">{{
column.label
}}</label>
<span class="text-disabled text-body-sm ml-3" v-show="column.required"
>Required</span
>
</div>
<span
:id="`${column.id}-description`"
class="text-input-description text-body-sm"
v-if="column.description"
>
<div class="text-input-description text-body-sm" v-if="column.description">
{{ column.description }}
</span>
</div>
<div>
<FormFieldInput
:type="column.columnType"
:id="column.id"
:label="column.label"
:data="data"
:options="refData ? refData : null"
:required="!!column.required"
:aria-invalid="hasError"
:aria-desribedBy="
column.description
? `${column.id}-description ${column.id}-input-error`
: `${column.id}-input-error`
"
:aria-desribedBy="`${column.id}-input-error`"
@focus="touched = true"
@input="pristine = false"
@update:modelValue="$emit('update:modelValue', $event)"
Expand Down
6 changes: 2 additions & 4 deletions apps/tailwind-components/components/form/FieldInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
columnId,
columnValue,
CellValueType,
IInputValueLabel,
} from "../../../metadata-utils/src/types";

type inputComponent =
Expand All @@ -22,7 +21,6 @@ defineProps<{
label: string;
required: boolean;
data: columnValue;
options?: IInputValueLabel[];
}>();

defineEmits(["focus", "error", "update:modelValue"]);
Expand All @@ -49,7 +47,7 @@ function validate(value: columnValue) {
:id="id"
:label="label"
:required="required"
:value="(data as string)"
:value="data as string"
@focus="$emit('focus')"
@update:modelValue="$emit('update:modelValue', $event)"
@error="$emit('error', $event)"
Expand All @@ -60,7 +58,7 @@ function validate(value: columnValue) {
:id="id"
:label="label"
:required="required"
:value="(data as string)"
:value="data as string"
@focus="$emit('focus')"
@update:modelValue="$emit('update:modelValue', $event)"
@error="$emit('error', $event)"
Expand Down
15 changes: 4 additions & 11 deletions apps/tailwind-components/pages/Form.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ import type {
IFieldError,
ISchemaMetaData,
ITableMetaData,
IInputValueLabel,
} from "../../metadata-utils/src/types";

const exampleForms: IInputValueLabel[] = [
{ value: "simple", label: "Simple form example" },
{ value: "complex", label: "Complex form example" },
];

const formType = ref<IInputValueLabel>(exampleForms[0]);
const sampleType = ref("simple");

// just assuming that the table is there for the demo
const schemaId = computed(() =>
formType.value.value === "simple" ? "pet store" : "catalogue-demo"
sampleType.value === "simple" ? "pet store" : "catalogue-demo"
);
const tableId = computed(() =>
formType.value.value === "simple" ? "Pet" : "Resources"
sampleType.value === "simple" ? "Pet" : "Resources"
);

const {
Expand All @@ -37,8 +31,7 @@ const tableMeta = computed(
) as ITableMetaData
);

function refetch(value: IInputValueLabel) {
formType.value = value;
function refetch() {
refetchMetadata();
}

Expand Down