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

feat: delete legacy widget fields & delete _ from new widget field types #5287

Merged
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
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import { green, red } from '@/styles/colors';

// TODO: Replace this with the actual value
export const _FORMAT_RULE_TYPE = {
export const FORMAT_RULE_TYPE = {
numberThreshold: 'numberThreshold',
percentThreshold: 'percentThreshold',
textThreshold: 'textThreshold',
textNumberThreshold: 'textNumberThreshold',
} as const;

export const FORMAT_RULE_TYPE = {
threshold: 'threshold',
percentThreshold: 'percentThreshold',
} as const;

export const ADVANCED_FORMAT_RULE_TYPE = {
textThreshold: 'textThreshold',
field: 'field',
} as const;

export const COLOR_SCHEMA = {
Coral: ['#FFD4C8', '#CA4F28'],
Yellow: ['#F8F6ED', '#D9AE00'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type { ComparisonOptions } from '@/common/modules/widgets/_widget-fields/
import type { DataFieldHeatmapColorOptions, DataFieldHeatmapColorValue } from '@/common/modules/widgets/_widget-fields/data-field-heatmap-color/type';
import type { DataFieldOptions } from '@/common/modules/widgets/_widget-fields/data-field/type';
import type { DateFormatOptions } from '@/common/modules/widgets/_widget-fields/date-format/type';
import type { _GroupByOptions } from '@/common/modules/widgets/_widget-fields/group-by/type';
import type { GroupByOptions } from '@/common/modules/widgets/_widget-fields/group-by/type';
import { ICON_FIELD_ITEMS } from '@/common/modules/widgets/_widget-fields/icon/constant';
import type { IconOptions } from '@/common/modules/widgets/_widget-fields/icon/type';
import type { _LegendOptions } from '@/common/modules/widgets/_widget-fields/legend/type';
import type { LegendOptions } from '@/common/modules/widgets/_widget-fields/legend/type';
import type { MaxOptions } from '@/common/modules/widgets/_widget-fields/max/type';
import type { MinOptions } from '@/common/modules/widgets/_widget-fields/min/type';
import type { MissingValueOptions } from '@/common/modules/widgets/_widget-fields/missing-value/type';
Expand Down Expand Up @@ -282,7 +282,7 @@ export const widgetFieldDefaultValueSetterRegistry: WidgetFieldDefaultValueSette
granularity: () => widgetFieldDefaultValueMap.granularity,
groupBy: (widgetConfig, dataTable) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const groupByOptions = (_fieldsSchema.groupBy?.options ?? {}) as _GroupByOptions;
const groupByOptions = (_fieldsSchema.groupBy?.options ?? {}) as GroupByOptions;

const result = widgetFieldDefaultValueMap.categoryBy;

Expand Down Expand Up @@ -319,7 +319,7 @@ export const widgetFieldDefaultValueSetterRegistry: WidgetFieldDefaultValueSette
},
legend: (widgetConfig) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const legendOptions = (_fieldsSchema.legend?.options ?? {}) as _LegendOptions;
const legendOptions = (_fieldsSchema.legend?.options ?? {}) as LegendOptions;

const initialValue = widgetFieldDefaultValueMap.legend;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { _FORMAT_RULE_TYPE } from '@/common/modules/widgets/_constants/widget-field-constant';
import { FORMAT_RULE_TYPE } from '@/common/modules/widgets/_constants/widget-field-constant';
import { integrateFieldsSchema } from '@/common/modules/widgets/_helpers/widget-field-helper';
import type { FieldValueValidator } from '@/common/modules/widgets/_widget-field-value-manager/type';
import type { FormatRulesOptions, FormatRulesValue } from '@/common/modules/widgets/_widget-fields/advanced-format-rules/type';
import type { _CategoryByValue as CategoryByValue, CategoryByOptions } from '@/common/modules/widgets/_widget-fields/category-by/type';
import type { CategoryByValue, CategoryByOptions } from '@/common/modules/widgets/_widget-fields/category-by/type';
import type { ColorSchemaValue } from '@/common/modules/widgets/_widget-fields/color-schema/type';
import type { ComparisonValue } from '@/common/modules/widgets/_widget-fields/comparison/type';
import type { CustomTableColumnWidthValue } from '@/common/modules/widgets/_widget-fields/custom-table-column-width/type';
Expand All @@ -13,16 +13,16 @@ import type { DateRangeValue } from '@/common/modules/widgets/_widget-fields/dat
import type { DisplayAnnotationValue } from '@/common/modules/widgets/_widget-fields/display-annotation/type';
import type { DisplaySeriesLabelValue } from '@/common/modules/widgets/_widget-fields/display-series-label/type';
import type { GranularityValue } from '@/common/modules/widgets/_widget-fields/granularity/type';
import type { _GroupByOptions, _GroupByValue } from '@/common/modules/widgets/_widget-fields/group-by/type';
import type { GroupByOptions, GroupByValue } from '@/common/modules/widgets/_widget-fields/group-by/type';
import type { WidgetHeaderValue } from '@/common/modules/widgets/_widget-fields/header/type';
import { ICON_FIELD_ITEMS } from '@/common/modules/widgets/_widget-fields/icon/constant';
import type { _IconValue } from '@/common/modules/widgets/_widget-fields/icon/type';
import type { IconValue } from '@/common/modules/widgets/_widget-fields/icon/type';
import type { MaxValue } from '@/common/modules/widgets/_widget-fields/max/type';
import type { MinValue } from '@/common/modules/widgets/_widget-fields/min/type';
import type { _StackByValue, StackByOptions } from '@/common/modules/widgets/_widget-fields/stack-by/type';
import type { StackByValue, StackByOptions } from '@/common/modules/widgets/_widget-fields/stack-by/type';
import type { TableColumnWidthValue } from '@/common/modules/widgets/_widget-fields/table-column-width/type';
import type { _XAxisValue, XAxisOptions } from '@/common/modules/widgets/_widget-fields/x-axis/type';
import type { _YAxisValue, YAxisOptions } from '@/common/modules/widgets/_widget-fields/y-axis/type';
import type { XAxisValue, XAxisOptions } from '@/common/modules/widgets/_widget-fields/x-axis/type';
import type { YAxisValue, YAxisOptions } from '@/common/modules/widgets/_widget-fields/y-axis/type';

export interface WidgetValidatorRegistry {
[fieldKey: string]: FieldValueValidator<any>;
Expand Down Expand Up @@ -53,13 +53,13 @@ export const widgetValidatorRegistry: WidgetValidatorRegistry = {
const formatRulesOptions = (_fieldsSchema.formatRules?.options ?? {}) as FormatRulesOptions;
const type = formatRulesOptions.formatRulesType;

if (type === _FORMAT_RULE_TYPE.textThreshold) {
if (type === FORMAT_RULE_TYPE.textThreshold) {
return fieldValue.rules.every((d) => !!d.text && !!d.color);
}
if (type === _FORMAT_RULE_TYPE.numberThreshold || type === _FORMAT_RULE_TYPE.percentThreshold) {
if (type === FORMAT_RULE_TYPE.numberThreshold || type === FORMAT_RULE_TYPE.percentThreshold) {
return fieldValue.rules.every((d) => !!d.number && !!d.color);
}
if (type === _FORMAT_RULE_TYPE.textNumberThreshold) {
if (type === FORMAT_RULE_TYPE.textNumberThreshold) {
return fieldValue.rules.every((d) => !!d.text && !!d.number && !!d.color);
}
if (formatRulesOptions.useField) {
Expand All @@ -73,19 +73,19 @@ export const widgetValidatorRegistry: WidgetValidatorRegistry = {
if (!fieldValue.data || !fieldValue.count || fieldValue.count < 0 || fieldValue.count > categoryByOptions.max) return false;
return true;
},
stackBy: (fieldValue: _StackByValue, widgetConfig) => {
stackBy: (fieldValue: StackByValue, widgetConfig) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const stackByOptions = (_fieldsSchema.stackBy?.options ?? {}) as StackByOptions;
if (!fieldValue.data || !fieldValue.count || fieldValue.count < 0 || fieldValue.count > stackByOptions.max) return false;
return true;
},
xAxis: (fieldValue: _XAxisValue, widgetConfig) => {
xAxis: (fieldValue: XAxisValue, widgetConfig) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const xAxisOptions = (_fieldsSchema.xAxis?.options ?? {}) as XAxisOptions;
if (!fieldValue.data || !fieldValue.count || fieldValue.count < 0 || fieldValue.count > xAxisOptions.max) return false;
return true;
},
yAxis: (fieldValue: _YAxisValue, widgetConfig) => {
yAxis: (fieldValue: YAxisValue, widgetConfig) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const yAxisOptions = (_fieldsSchema.yAxis?.options ?? {}) as YAxisOptions;
if (!fieldValue.data || !fieldValue.count || fieldValue.count < 0 || fieldValue.count > yAxisOptions.max) return false;
Expand Down Expand Up @@ -123,9 +123,9 @@ export const widgetValidatorRegistry: WidgetValidatorRegistry = {
if (!fieldValue.granularity) return false;
return true;
},
groupBy: (fieldValue: _GroupByValue, widgetConfig) => {
groupBy: (fieldValue: GroupByValue, widgetConfig) => {
const _fieldsSchema = integrateFieldsSchema(widgetConfig.requiredFieldsSchema, widgetConfig.optionalFieldsSchema);
const groupByOptions = (_fieldsSchema.groupBy?.options ?? {}) as _GroupByOptions;
const groupByOptions = (_fieldsSchema.groupBy?.options ?? {}) as GroupByOptions;
if (groupByOptions.fixedValue && fieldValue.data !== groupByOptions.fixedValue) return false;
if (groupByOptions.hideCount && !!fieldValue.count) return false;
if (!groupByOptions.hideCount && groupByOptions.max && groupByOptions.defaultMaxCount && (!fieldValue.count || fieldValue.count > groupByOptions.max)) return false;
Expand All @@ -137,7 +137,7 @@ export const widgetValidatorRegistry: WidgetValidatorRegistry = {
if (!fieldValue.toggleValue) return true;
return !!fieldValue.title?.trim();
},
icon: (fieldValue: _IconValue) => {
icon: (fieldValue: IconValue) => {
if (!fieldValue.toggleValue) return true;
return !!fieldValue.color && !!fieldValue.icon && ICON_FIELD_ITEMS.some((item) => item.name === fieldValue.icon?.name);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ import type { PrivateDataTableModel } from '@/schema/dashboard/private-data-tabl
import type { PublicDataTableModel } from '@/schema/dashboard/public-data-table/model';

import type { FormatRulesValue } from '@/common/modules/widgets/_widget-fields/advanced-format-rules/type';
import type { _CategoryByValue as CategoryByValue } from '@/common/modules/widgets/_widget-fields/category-by/type';
import type { CategoryByValue } from '@/common/modules/widgets/_widget-fields/category-by/type';
import type { ColorSchemaValue } from '@/common/modules/widgets/_widget-fields/color-schema/type';
import type { ComparisonValue } from '@/common/modules/widgets/_widget-fields/comparison/type';
import type { CustomTableColumnWidthValue } from '@/common/modules/widgets/_widget-fields/custom-table-column-width/type';
import type { DataFieldHeatmapColorValue } from '@/common/modules/widgets/_widget-fields/data-field-heatmap-color/type';
import type { DataFieldValue } from '@/common/modules/widgets/_widget-fields/data-field/type';
import type { _DateFormatValue } from '@/common/modules/widgets/_widget-fields/date-format/type';
import type { DateFormatValue } from '@/common/modules/widgets/_widget-fields/date-format/type';
import type { DateRangeValue } from '@/common/modules/widgets/_widget-fields/date-range/type';
import type { DisplayAnnotationValue } from '@/common/modules/widgets/_widget-fields/display-annotation/type';
import type { DisplaySeriesLabelValue } from '@/common/modules/widgets/_widget-fields/display-series-label/type';
import type { GranularityValue } from '@/common/modules/widgets/_widget-fields/granularity/type';
import type { _GroupByValue } from '@/common/modules/widgets/_widget-fields/group-by/type';
import type { GroupByValue } from '@/common/modules/widgets/_widget-fields/group-by/type';
import type { WidgetHeaderValue } from '@/common/modules/widgets/_widget-fields/header/type';
import type { _IconValue } from '@/common/modules/widgets/_widget-fields/icon/type';
import type { IconValue } from '@/common/modules/widgets/_widget-fields/icon/type';
import type { LegendValue } from '@/common/modules/widgets/_widget-fields/legend/type';
import type { MaxValue } from '@/common/modules/widgets/_widget-fields/max/type';
import type { MinValue } from '@/common/modules/widgets/_widget-fields/min/type';
import type { _MissingValueValue } from '@/common/modules/widgets/_widget-fields/missing-value/type';
import type { MissingValueValue } from '@/common/modules/widgets/_widget-fields/missing-value/type';
import type { NumberFormatValue } from '@/common/modules/widgets/_widget-fields/number-format/type';
import type { PieChartTypeValue } from '@/common/modules/widgets/_widget-fields/pie-chart-type/type';
import type { _StackByValue } from '@/common/modules/widgets/_widget-fields/stack-by/type';
import type { StackByValue } from '@/common/modules/widgets/_widget-fields/stack-by/type';
import type { SubTotalValue } from '@/common/modules/widgets/_widget-fields/sub-total/type';
import type { TableColumnWidthValue } from '@/common/modules/widgets/_widget-fields/table-column-width/type';
import type { TextWrapValue } from '@/common/modules/widgets/_widget-fields/text-wrap/type';
import type { TooltipNumberFormatValue } from '@/common/modules/widgets/_widget-fields/tooltip-number-format/type';
import type { TotalValue } from '@/common/modules/widgets/_widget-fields/total/type';
import type { _WidgetHeightValue } from '@/common/modules/widgets/_widget-fields/widget-height/type';
import type { _XAxisValue } from '@/common/modules/widgets/_widget-fields/x-axis/type';
import type { _YAxisValue } from '@/common/modules/widgets/_widget-fields/y-axis/type';
import type { WidgetHeightValue } from '@/common/modules/widgets/_widget-fields/widget-height/type';
import type { XAxisValue } from '@/common/modules/widgets/_widget-fields/x-axis/type';
import type { YAxisValue } from '@/common/modules/widgets/_widget-fields/y-axis/type';
import type { WidgetConfig } from '@/common/modules/widgets/types/widget-config-type';

export type FieldValueValidator<T extends WidgetFieldValue> = (fieldValue: T, widgetConfig: WidgetConfig, allValueMap?: WidgetFieldValueMap) => boolean;
Expand All @@ -46,30 +46,30 @@ export interface WidgetFieldValue<T = any> {
}

export interface WidgetFieldTypeMap {
xAxis: WidgetFieldValue<_XAxisValue>;
yAxis: WidgetFieldValue<_YAxisValue>;
widgetHeight: WidgetFieldValue<_WidgetHeightValue>;
xAxis: WidgetFieldValue<XAxisValue>;
yAxis: WidgetFieldValue<YAxisValue>;
widgetHeight: WidgetFieldValue<WidgetHeightValue>;
total: WidgetFieldValue<TotalValue>;
tooltipNumberFormat: WidgetFieldValue<TooltipNumberFormatValue>;
textWrap: WidgetFieldValue<TextWrapValue>;
tableColumnWidth: WidgetFieldValue<TableColumnWidthValue>;
subTotal: WidgetFieldValue<SubTotalValue>;
stackBy: WidgetFieldValue<_StackByValue>;
stackBy: WidgetFieldValue<StackByValue>;
pieChartType: WidgetFieldValue<PieChartTypeValue>;
numberFormat: WidgetFieldValue<NumberFormatValue>;
missingValue: WidgetFieldValue<_MissingValueValue>;
missingValue: WidgetFieldValue<MissingValueValue>;
min: WidgetFieldValue<MinValue>;
max: WidgetFieldValue<MaxValue>;
legend: WidgetFieldValue<LegendValue>;
icon: WidgetFieldValue<_IconValue>;
icon: WidgetFieldValue<IconValue>;
widgetHeader: WidgetFieldValue<WidgetHeaderValue>;
groupBy: WidgetFieldValue<_GroupByValue>;
groupBy: WidgetFieldValue<GroupByValue>;
granularity: WidgetFieldValue<GranularityValue>;
formatRules: WidgetFieldValue<FormatRulesValue>;
displaySeriesLabel: WidgetFieldValue<DisplaySeriesLabelValue>;
displayAnnotation: WidgetFieldValue<DisplayAnnotationValue>;
dateRange: WidgetFieldValue<DateRangeValue>;
dateFormat: WidgetFieldValue<_DateFormatValue>;
dateFormat: WidgetFieldValue<DateFormatValue>;
dataFieldHeatmapColor: WidgetFieldValue<DataFieldHeatmapColorValue>;
dataField: WidgetFieldValue<DataFieldValue>;
customTableColumnWidth: WidgetFieldValue<CustomTableColumnWidthValue>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { MenuItem } from '@cloudforet/mirinae/types/controls/context-menu/t

import ColorInput from '@/common/components/inputs/ColorInput.vue';
import {
_FORMAT_RULE_TYPE,
FORMAT_RULE_TYPE,
} from '@/common/modules/widgets/_constants/widget-field-constant';
import { sortWidgetTableFields } from '@/common/modules/widgets/_helpers/widget-helper';
import { useWidgetGenerateStore } from '@/common/modules/widgets/_store/widget-generate-store';
Expand Down Expand Up @@ -118,9 +118,9 @@ const handleUpdateField = (val: string) => {
class="format-rules-input-wrapper"
>
<div class="left-part"
:class="[state.type === _FORMAT_RULE_TYPE.textThreshold ? 'grid-cols-2' : 'grid-cols-1']"
:class="[state.type === FORMAT_RULE_TYPE.textThreshold ? 'grid-cols-2' : 'grid-cols-1']"
>
<p-field-group v-if="state.type === _FORMAT_RULE_TYPE.textNumberThreshold || state.type === _FORMAT_RULE_TYPE.textThreshold"
<p-field-group v-if="state.type === FORMAT_RULE_TYPE.textNumberThreshold || state.type === FORMAT_RULE_TYPE.textThreshold"
required
>
<p-text-input :value="rule.text"
Expand All @@ -129,9 +129,9 @@ const handleUpdateField = (val: string) => {
@update:value="handleFormatRuleInput(idx, 'text', $event)"
/>
</p-field-group>
<p-field-group v-if="state.type === _FORMAT_RULE_TYPE.textNumberThreshold
|| state.type === _FORMAT_RULE_TYPE.numberThreshold
|| state.type === _FORMAT_RULE_TYPE.percentThreshold"
<p-field-group v-if="state.type === FORMAT_RULE_TYPE.textNumberThreshold
|| state.type === FORMAT_RULE_TYPE.numberThreshold
|| state.type === FORMAT_RULE_TYPE.percentThreshold"
required
>
<p-text-input :value="rule.number"
Expand All @@ -141,7 +141,7 @@ const handleUpdateField = (val: string) => {
:invalid="Number.isNaN(rule.number)"
@update:value="handleFormatRuleInput(idx, 'number', $event)"
>
<template v-if="state.type === _FORMAT_RULE_TYPE.percentThreshold"
<template v-if="state.type === FORMAT_RULE_TYPE.percentThreshold"
#input-right
>
%
Expand Down
Loading
Loading