Skip to content

Commit

Permalink
fix: fix validation bug in ADD_LABELS (#5237)
Browse files Browse the repository at this point in the history
* fix: fix validation bug in ADD_LABELS

Signed-off-by: yuda <[email protected]>

* fix: fix type error

Signed-off-by: yuda <[email protected]>

---------

Signed-off-by: yuda <[email protected]>
  • Loading branch information
yuda110 authored Dec 17, 2024
1 parent 08d52c5 commit 9aba5b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from 'vue';
import type { TranslateResult } from 'vue-i18n';
import { random } from 'lodash';
import { cloneDeep, random } from 'lodash';
import {
PIconButton, PFieldGroup, PTextInput, PButton, PFieldTitle,
Expand Down Expand Up @@ -49,7 +49,7 @@ const storeState = reactive({
const dataTableInfo = ref<TransformDataTableInfo>({
dataTableId: props.originData?.data_table_id,
});
const labelsInfo = ref<AddLabelsOptions['labels']>(props.originData.labels);
const labelsInfo = ref<AddLabelsOptions['labels']>(cloneDeep(props.originData.labels));
const state = reactive({
proxyOperatorOptions: useProxyValue<AddLabelsOptions>('operator-options', props, emit),
refinedLabels: [] as AdditionalLabel[],
Expand All @@ -60,7 +60,7 @@ const state = reactive({
const fieldNames = state.refinedLabels.map((label) => label.name);
if (fieldNames.includes(DATE_FIELD)) return true;
if (fieldNames.length !== new Set(fieldNames).size) return true;
if (Object.keys(labelsInfo.value).some((d) => !isFieldNameValid(d, storeState.currentDataTable))) return true;
if (state.refinedLabels.some((d) => !isFieldNameValid(d.name, storeState.currentDataTable))) return true;
return false;
}),
});
Expand Down Expand Up @@ -151,7 +151,7 @@ onMounted(() => {
<div class="label-set">
<p-text-input class="label-input"
block
:invalid="getInvalidText(idx)"
:invalid="!!getInvalidText(idx)"
:value.sync="labelInfo.name"
/>
<p-text-input class="label-input"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { TranslateResult } from 'vue-i18n';

import type { WIDGET_SIZE } from '@/schema/dashboard/_constants/widget-constant';

import type { WidgetFieldValue } from '@/common/modules/widgets/_widget-field-value-manager/type';
import type { WidgetFieldName } from '@/common/modules/widgets/types/widget-field-type';
import type { WidgetFieldValues } from '@/common/modules/widgets/types/widget-field-value-type';
import type { WidgetState } from '@/common/modules/widgets/types/widget-model';
Expand All @@ -15,7 +16,7 @@ export interface FullDataLink {

export interface WidgetFrameProps {
widgetId: string;
widgetOptions?: Record<WidgetFieldName, WidgetFieldValues>;
widgetOptions?: Record<WidgetFieldName, WidgetFieldValue<WidgetFieldValues>>;
widgetSizes: WidgetSize[];
dataTableId?: string;
//
Expand Down

0 comments on commit 9aba5b2

Please sign in to comment.