mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
feat: gantt block time range
This commit is contained in:
parent
95524bddbe
commit
b4bb90ad3e
@ -59,12 +59,27 @@ export const GanttDesigner = () => {
|
|||||||
dn.refresh();
|
dn.refresh();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<SchemaSettings.SwitchItem
|
<SchemaSettings.SelectItem
|
||||||
title={t('Time Range')}
|
title={t('Time Range')}
|
||||||
checked={field.decoratorProps.showLunar}
|
value={fieldNames.range}
|
||||||
onChange={(v) => {
|
options={[
|
||||||
field.decoratorProps.showLunar = v;
|
{ label: compile('{{t("Hour")}}'), value: 'hour', color: 'orange' },
|
||||||
fieldSchema['x-decorator-props']['showLunar'] = v;
|
{ 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', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
['x-uid']: fieldSchema['x-uid'],
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
@ -149,7 +164,7 @@ export const GanttDesigner = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<SchemaSettings.Divider />
|
<SchemaSettings.Divider />
|
||||||
<SchemaSettings.Template componentName={'Calendar'} collectionName={name} resourceName={defaultResource} />
|
<SchemaSettings.Template componentName={'Gantt'} collectionName={name} resourceName={defaultResource} />
|
||||||
<SchemaSettings.Divider />
|
<SchemaSettings.Divider />
|
||||||
<SchemaSettings.Remove
|
<SchemaSettings.Remove
|
||||||
removeParentsIfNoChildren
|
removeParentsIfNoChildren
|
||||||
|
@ -123,7 +123,7 @@ const formatData = (data = [], fieldNames) => {
|
|||||||
name: v[fieldNames.title],
|
name: v[fieldNames.title],
|
||||||
id: v.id + '',
|
id: v.id + '',
|
||||||
type: 'task',
|
type: 'task',
|
||||||
progress: 10,
|
progress: v[fieldNames.progress],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return tasks;
|
return tasks;
|
||||||
|
@ -2,6 +2,7 @@ import { Task, ViewMode } from '../types/public-types';
|
|||||||
|
|
||||||
const DateTimeFormat = Intl.DateTimeFormat;
|
const DateTimeFormat = Intl.DateTimeFormat;
|
||||||
type DateTimeFormat = typeof DateTimeFormat;
|
type DateTimeFormat = typeof DateTimeFormat;
|
||||||
|
//@ts-ignore
|
||||||
const DateTimeFormatOptions = Intl.DateTimeFormatOptions;
|
const DateTimeFormatOptions = Intl.DateTimeFormatOptions;
|
||||||
type DateTimeFormatOptions = typeof DateTimeFormatOptions;
|
type DateTimeFormatOptions = typeof DateTimeFormatOptions;
|
||||||
type DateHelperScales = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
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) => {
|
export const getLocaleMonth = (date: Date, locale: string) => {
|
||||||
let bottomValue = getCachedDateTimeFormat(locale, {
|
let bottomValue = getCachedDateTimeFormat(locale, {
|
||||||
month: 'long',
|
month: 'long',
|
||||||
|
//@ts-ignore
|
||||||
}).format(date);
|
}).format(date);
|
||||||
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
|
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
|
||||||
return bottomValue;
|
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) => {
|
export const getLocalDayOfWeek = (date: Date, locale: string, format?: 'long' | 'short' | 'narrow' | undefined) => {
|
||||||
let bottomValue = getCachedDateTimeFormat(locale, {
|
let bottomValue = getCachedDateTimeFormat(locale, {
|
||||||
weekday: format,
|
weekday: format,
|
||||||
|
//@ts-ignore
|
||||||
}).format(date);
|
}).format(date);
|
||||||
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
|
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
|
||||||
return bottomValue;
|
return bottomValue;
|
||||||
|
@ -8,26 +8,18 @@ export const GanttActionInitializers = {
|
|||||||
type: 'itemGroup',
|
type: 'itemGroup',
|
||||||
title: '{{t("Enable actions")}}',
|
title: '{{t("Enable actions")}}',
|
||||||
children: [
|
children: [
|
||||||
{
|
// {
|
||||||
type: 'item',
|
// type: 'item',
|
||||||
title: '{{t("Show linkto")}}',
|
// title: '{{t("Show linkto")}}',
|
||||||
component: 'ActionInitializer',
|
// component: 'ActionInitializer',
|
||||||
schema: {
|
// schema: {
|
||||||
title: '{{t("Select view")}}',
|
// title: '{{t("Select view")}}',
|
||||||
'x-component': 'GanttV2.ViewSelect',
|
// 'x-component': 'GanttV2.ViewSelect',
|
||||||
'x-action': `gantt:showLinkto`,
|
// 'x-action': `gantt:showLinkto`,
|
||||||
'x-align': 'right',
|
// 'x-align': 'right',
|
||||||
'x-designer': 'Action.Designer',
|
// 'x-designer': 'Action.Designer',
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: "{{t('Time range')}}",
|
|
||||||
component: 'FilterActionInitializer',
|
|
||||||
schema: {
|
|
||||||
'x-align': 'right',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: "{{t('Filter')}}",
|
title: "{{t('Filter')}}",
|
||||||
|
@ -37,6 +37,14 @@ export const GanttBlockInitializer = (props) => {
|
|||||||
value: field.name,
|
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'), () => {
|
const values = await FormDialog(t('Create gantt block'), () => {
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
||||||
@ -64,6 +72,12 @@ export const GanttBlockInitializer = (props) => {
|
|||||||
enum: dateFields,
|
enum: dateFields,
|
||||||
'x-component': 'Select',
|
'x-component': 'Select',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
|
progress: {
|
||||||
|
title: t('Progress field'),
|
||||||
|
enum: numberFields,
|
||||||
|
'x-component': 'Select',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
range: {
|
range: {
|
||||||
title: t('Time range'),
|
title: t('Time range'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user