feat: gantt block time range

This commit is contained in:
katherinehhh 2023-01-18 10:10:22 +08:00
parent 95524bddbe
commit b4bb90ad3e
5 changed files with 51 additions and 27 deletions

View File

@ -59,12 +59,27 @@ export const GanttDesigner = () => {
dn.refresh();
}}
/>
<SchemaSettings.SwitchItem
<SchemaSettings.SelectItem
title={t('Time Range')}
checked={field.decoratorProps.showLunar}
onChange={(v) => {
field.decoratorProps.showLunar = v;
fieldSchema['x-decorator-props']['showLunar'] = v;
value={fieldNames.range}
options={[
{ label: compile('{{t("Hour")}}'), value: 'hour', color: 'orange' },
{ label: compile('{{t("Quarter of day")}}'), value: 'quarterOfDay', color: 'default' },
{ label: compile('{{t("Half of day")}}'), value: 'halOfDay', color: 'blue' },
{ label: compile('{{t("Day")}}'), value: 'day', color: 'yellow' },
{ label: compile('{{t("Week")}}'), value: 'week', color: 'pule' },
{ label: compile('{{t("Month")}}'), value: 'month', color: 'green' },
{ label: compile('{{t("Year")}}'), value: 'year', color: 'green' },
{ label: compile('{{t("QuarterYear")}}'), value: 'quarterYear', color: 'red' },
]}
onChange={(range) => {
const fieldNames = field.decoratorProps.fieldNames || {};
fieldNames['range'] = range;
field.decoratorProps.params = fieldNames;
fieldSchema['x-decorator-props']['params'] = fieldNames;
// Select切换option后value未按照预期切换固增加以下代码
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
service.refresh();
dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],
@ -149,7 +164,7 @@ export const GanttDesigner = () => {
}}
/>
<SchemaSettings.Divider />
<SchemaSettings.Template componentName={'Calendar'} collectionName={name} resourceName={defaultResource} />
<SchemaSettings.Template componentName={'Gantt'} collectionName={name} resourceName={defaultResource} />
<SchemaSettings.Divider />
<SchemaSettings.Remove
removeParentsIfNoChildren

View File

@ -123,7 +123,7 @@ const formatData = (data = [], fieldNames) => {
name: v[fieldNames.title],
id: v.id + '',
type: 'task',
progress: 10,
progress: v[fieldNames.progress],
});
});
return tasks;

View File

@ -2,6 +2,7 @@ import { Task, ViewMode } from '../types/public-types';
const DateTimeFormat = Intl.DateTimeFormat;
type DateTimeFormat = typeof DateTimeFormat;
//@ts-ignore
const DateTimeFormatOptions = Intl.DateTimeFormatOptions;
type DateTimeFormatOptions = typeof DateTimeFormatOptions;
type DateHelperScales = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
@ -154,6 +155,7 @@ export const seedDates = (startDate: Date, endDate: Date, viewMode: ViewMode) =>
export const getLocaleMonth = (date: Date, locale: string) => {
let bottomValue = getCachedDateTimeFormat(locale, {
month: 'long',
//@ts-ignore
}).format(date);
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
return bottomValue;
@ -162,6 +164,7 @@ export const getLocaleMonth = (date: Date, locale: string) => {
export const getLocalDayOfWeek = (date: Date, locale: string, format?: 'long' | 'short' | 'narrow' | undefined) => {
let bottomValue = getCachedDateTimeFormat(locale, {
weekday: format,
//@ts-ignore
}).format(date);
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
return bottomValue;

View File

@ -8,26 +8,18 @@ export const GanttActionInitializers = {
type: 'itemGroup',
title: '{{t("Enable actions")}}',
children: [
{
type: 'item',
title: '{{t("Show linkto")}}',
component: 'ActionInitializer',
schema: {
title: '{{t("Select view")}}',
'x-component': 'GanttV2.ViewSelect',
'x-action': `gantt:showLinkto`,
'x-align': 'right',
'x-designer': 'Action.Designer',
},
},
{
type: 'item',
title: "{{t('Time range')}}",
component: 'FilterActionInitializer',
schema: {
'x-align': 'right',
},
},
// {
// type: 'item',
// title: '{{t("Show linkto")}}',
// component: 'ActionInitializer',
// schema: {
// title: '{{t("Select view")}}',
// 'x-component': 'GanttV2.ViewSelect',
// 'x-action': `gantt:showLinkto`,
// 'x-align': 'right',
// 'x-designer': 'Action.Designer',
// },
// },
{
type: 'item',
title: "{{t('Filter')}}",

View File

@ -37,6 +37,14 @@ export const GanttBlockInitializer = (props) => {
value: field.name,
};
});
const numberFields = collectionFields
?.filter((field) => field.type === 'double')
?.map((field) => {
return {
label: field?.uiSchema?.title,
value: field.name,
};
});
const values = await FormDialog(t('Create gantt block'), () => {
return (
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
@ -64,6 +72,12 @@ export const GanttBlockInitializer = (props) => {
enum: dateFields,
'x-component': 'Select',
'x-decorator': 'FormItem',
},
progress: {
title: t('Progress field'),
enum: numberFields,
'x-component': 'Select',
'x-decorator': 'FormItem',
},
range: {
title: t('Time range'),