Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 920127b

Browse files
committed
big refactor of headerMenu
1 parent 2ec14b8 commit 920127b

File tree

8 files changed

+214
-89
lines changed

8 files changed

+214
-89
lines changed

src/components/HeaderMenu.tsx

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import {
55
StyleVariables,
66
} from "helpers/Constants";
77
import { dbTrim, c, getLabelHeader } from "helpers/StylesHelper";
8-
import TrashIcon from "components/img/Trash";
9-
import TextIcon from "components/img/Text";
10-
import MultiIcon from "components/img/Multi";
118
import HashIcon from "components/img/Hash";
12-
import TaskIcon from "components/img/TaskIcon";
13-
import TagsIcon from "components/img/TagsIcon";
149
import CalendarTimeIcon from "components/img/CalendarTime";
1510
import CalendarIcon from "components/img/CalendarIcon";
1611
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
@@ -111,89 +106,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
111106
setKeyState: setkeyState,
112107
},
113108
};
114-
const typesTest =
115-
header_action_types_section.run(headerActionResponse).buttons;
116-
const types = [
117-
{
118-
onClick: (e: any) => {
119-
dispatch({
120-
type: ActionTypes.UPDATE_COLUMN_TYPE,
121-
columnId: column.id,
122-
dataType: DataTypes.SELECT,
123-
});
124-
setShowType(false);
125-
setExpanded(false);
126-
},
127-
icon: <MultiIcon />,
128-
label: DataTypes.SELECT,
129-
},
130-
{
131-
onClick: (e: any) => {
132-
dispatch({
133-
type: ActionTypes.UPDATE_COLUMN_TYPE,
134-
columnId: column.id,
135-
dataType: DataTypes.TAGS,
136-
});
137-
setShowType(false);
138-
setExpanded(false);
139-
},
140-
icon: <TagsIcon />,
141-
label: DataTypes.TAGS,
142-
},
143-
{
144-
onClick: (e: any) => {
145-
dispatch({
146-
type: ActionTypes.UPDATE_COLUMN_TYPE,
147-
columnId: column.id,
148-
dataType: DataTypes.TEXT,
149-
});
150-
setShowType(false);
151-
setExpanded(false);
152-
},
153-
icon: <TextIcon />,
154-
label: DataTypes.TEXT,
155-
},
156-
{
157-
onClick: (e: any) => {
158-
dispatch({
159-
type: ActionTypes.UPDATE_COLUMN_TYPE,
160-
columnId: column.id,
161-
dataType: DataTypes.NUMBER,
162-
});
163-
setShowType(false);
164-
setExpanded(false);
165-
},
166-
icon: <HashIcon />,
167-
label: DataTypes.NUMBER,
168-
},
169-
{
170-
onClick: (e: any) => {
171-
dispatch({
172-
type: ActionTypes.UPDATE_COLUMN_TYPE,
173-
columnId: column.id,
174-
dataType: DataTypes.CALENDAR,
175-
});
176-
setShowType(false);
177-
setExpanded(false);
178-
},
179-
icon: <CalendarIcon />,
180-
label: MetadataLabels.CALENDAR,
181-
},
182-
{
183-
onClick: (e: any) => {
184-
dispatch({
185-
type: ActionTypes.UPDATE_COLUMN_TYPE,
186-
columnId: column.id,
187-
dataType: DataTypes.CALENDAR_TIME,
188-
});
189-
setShowType(false);
190-
setExpanded(false);
191-
},
192-
icon: <CalendarTimeIcon />,
193-
label: MetadataLabels.CALENDAR_TIME,
194-
},
195-
];
196-
types.push(...typesTest);
109+
const types = header_action_types_section.run(headerActionResponse).buttons;
110+
197111
const typePopper = usePopper(typeReferenceElement, typePopperElement, {
198112
placement: "right",
199113
strategy: "fixed",

src/components/headerActions/HeaderActiontypesSection.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import { HeaderActionResponse } from "cdm/HeaderActionModel";
22
import { AbstractChain, AbstractHandler } from "patterns/AbstractFactoryChain";
33
import CheckboxTypeHandlerAction from "components/headerActions/handlers/types/CheckboxTypeHeaderAction";
4+
import TextTypeHeaderAction from "components/headerActions/handlers/types/TextTypeHeaderAction";
5+
import SelectTypeHeaderAction from "components/headerActions/handlers/types/SelectTypeHeaderAction";
6+
import TagsTypeHeaderAction from "components/headerActions/handlers/types/TagsTypeHeaderAction";
7+
import NumberTypeHeaderAction from "components/headerActions/handlers/types/NumberTypeHeaderAction";
8+
import DateTypeHeaderAction from "components/headerActions/handlers/types/DateTypeHeaderAction";
9+
import DatetimeTypeHeaderAction from "components/headerActions/handlers/types/DatetimeTypeHeaderAction";
410
class HeaderActionTypesSection extends AbstractChain<HeaderActionResponse> {
511
protected customHandle(abstractResponse: HeaderActionResponse): HeaderActionResponse {
612
return abstractResponse;
713
}
814

915
protected getHandlers(): AbstractHandler<HeaderActionResponse>[] {
1016
return [
11-
new CheckboxTypeHandlerAction()
17+
new TextTypeHeaderAction(),
18+
new NumberTypeHeaderAction(),
19+
new SelectTypeHeaderAction(),
20+
new TagsTypeHeaderAction(),
21+
new CheckboxTypeHandlerAction(),
22+
new DateTypeHeaderAction(),
23+
new DatetimeTypeHeaderAction(),
1224
];
1325
}
1426
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import CalendarIcon from "components/img/CalendarIcon";
4+
import React from "react";
5+
import { ActionTypes, DataTypes, MetadataLabels } from "helpers/Constants";
6+
7+
export default class DateTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addDateType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addDateType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const checkBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.CALENDAR,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <CalendarIcon />,
29+
label: MetadataLabels.CALENDAR,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
32+
}
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import React from "react";
4+
import { ActionTypes, DataTypes, MetadataLabels } from "helpers/Constants";
5+
import TaskIcon from "components/img/TaskIcon";
6+
import CalendarTimeIcon from "components/img/CalendarTime";
7+
8+
export default class DatetimeTypeHeaderAction extends AbstractHeaderAction {
9+
globalHeaderActionResponse: HeaderActionResponse;
10+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
11+
this.globalHeaderActionResponse = headerActionResponse;
12+
this.addDatetimeType();
13+
return this.goNext(this.globalHeaderActionResponse);
14+
}
15+
private addDatetimeType() {
16+
const { hooks } = this.globalHeaderActionResponse;
17+
const { initialState, column } =
18+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
19+
const checkBoxType = {
20+
onClick: (e: any) => {
21+
initialState.dispatch({
22+
type: ActionTypes.UPDATE_COLUMN_TYPE,
23+
columnId: column.id,
24+
dataType: DataTypes.CALENDAR_TIME,
25+
});
26+
hooks.setShowType(false);
27+
hooks.setExpanded(false);
28+
},
29+
icon: <CalendarTimeIcon />,
30+
label: MetadataLabels.CALENDAR_TIME,
31+
};
32+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import HashIcon from "components/img/Hash";
4+
import React from "react";
5+
import { ActionTypes, DataTypes } from "helpers/Constants";
6+
7+
export default class NumberTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addNumberType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addNumberType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const checkBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.NUMBER,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <HashIcon />,
29+
label: DataTypes.NUMBER,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import MultiIcon from "components/img/Multi";
4+
import React from "react";
5+
import { ActionTypes, DataTypes } from "helpers/Constants";
6+
7+
export default class SelectTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addSelectType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addSelectType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const selectType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.SELECT,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <MultiIcon />,
29+
label: DataTypes.SELECT,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(selectType);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import React from "react";
4+
import { ActionTypes, DataTypes } from "helpers/Constants";
5+
import TagsIcon from "components/img/TagsIcon";
6+
7+
export default class TagsTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addTagsType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addTagsType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const checkBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.TAGS,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <TagsIcon />,
29+
label: DataTypes.TAGS,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import TextIcon from "components/img/Text";
4+
import React from "react";
5+
import { ActionTypes, DataTypes } from "helpers/Constants";
6+
7+
export default class TextTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addTextType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addTextType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const textBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.TEXT,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <TextIcon />,
29+
label: DataTypes.TEXT,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(textBoxType);
32+
}
33+
}

0 commit comments

Comments
 (0)