@hedhog/setting 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/setting/setting.controller.d.ts +27 -3
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +3 -3
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +28 -4
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +6 -6
- package/dist/setting/setting.service.js.map +1 -1
- package/hedhog.yaml +285 -307
- package/package.json +39 -37
- package/frontend/setting/components/create-panel.tsx +0 -83
- package/frontend/setting/components/setting.screen.tsx +0 -105
- package/frontend/setting/components/update-panel.tsx +0 -96
- package/frontend/setting/locales/en/setting.setting.json +0 -11
- package/frontend/setting/locales/pt/setting.setting.json +0 -11
- package/frontend/setting/react-query/handlers.ts +0 -28
- package/frontend/setting/react-query/requests.ts +0 -55
- package/frontend/setting-group/components/create-panel.tsx +0 -62
- package/frontend/setting-group/components/setting-group.screen.tsx +0 -107
- package/frontend/setting-group/components/update-panel.tsx +0 -76
- package/frontend/setting-group/locales/en/setting.setting-group.json +0 -11
- package/frontend/setting-group/locales/pt/setting.setting-group.json +0 -11
- package/frontend/setting-group/react-query/handlers.ts +0 -28
- package/frontend/setting-group/react-query/requests.ts +0 -58
- package/frontend/setting-user/components/create-panel.tsx +0 -71
- package/frontend/setting-user/components/setting-user.screen.tsx +0 -107
- package/frontend/setting-user/components/update-panel.tsx +0 -85
- package/frontend/setting-user/locales/en/setting.setting-user.json +0 -11
- package/frontend/setting-user/locales/pt/setting.setting-user.json +0 -11
- package/frontend/setting-user/react-query/handlers.ts +0 -28
- package/frontend/setting-user/react-query/requests.ts +0 -57
@@ -1,83 +0,0 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from "@/components/panels/form-panel";
|
5
|
-
import { EnumFieldType } from "@/enums/EnumFieldType";
|
6
|
-
import { useSettingCreate } from "@/features/blog/setting";
|
7
|
-
import { Setting } from "@/types/models";
|
8
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
|
11
|
-
export type SettingCreatePanelRef = {
|
12
|
-
submit: () => void;
|
13
|
-
};
|
14
|
-
|
15
|
-
export type SettingCreatePanelProps = {
|
16
|
-
onCreated?: (data: Setting) => void;
|
17
|
-
};
|
18
|
-
|
19
|
-
const SettingCreatePanel = forwardRef(
|
20
|
-
({ onCreated }: SettingCreatePanelProps, ref) => {
|
21
|
-
const formRef = useRef<FormPanelRef>(null);
|
22
|
-
const { t } = useTranslation(["actions"]);
|
23
|
-
const { mutateAsync: createSetting } = useSettingCreate();
|
24
|
-
|
25
|
-
useImperativeHandle(
|
26
|
-
ref,
|
27
|
-
() => ({
|
28
|
-
submit: () => {
|
29
|
-
formRef.current?.submit();
|
30
|
-
},
|
31
|
-
}),
|
32
|
-
[formRef],
|
33
|
-
);
|
34
|
-
|
35
|
-
return (
|
36
|
-
<FormPanel
|
37
|
-
ref={formRef}
|
38
|
-
fields={[
|
39
|
-
{
|
40
|
-
name: "group_id",
|
41
|
-
label: { text: t("group_id", { ns: "translation" }) },
|
42
|
-
type: EnumFieldType.TEXT,
|
43
|
-
required: true,
|
44
|
-
},
|
45
|
-
|
46
|
-
{
|
47
|
-
name: "type",
|
48
|
-
label: { text: t("type", { ns: "translation" }) },
|
49
|
-
type: EnumFieldType.TEXT,
|
50
|
-
required: true,
|
51
|
-
},
|
52
|
-
|
53
|
-
{
|
54
|
-
name: "value",
|
55
|
-
label: { text: t("value", { ns: "translation" }) },
|
56
|
-
type: EnumFieldType.TEXT,
|
57
|
-
required: true,
|
58
|
-
},
|
59
|
-
|
60
|
-
{
|
61
|
-
name: "user_override",
|
62
|
-
label: { text: t("user_override", { ns: "translation" }) },
|
63
|
-
type: EnumFieldType.TEXT,
|
64
|
-
required: true,
|
65
|
-
},
|
66
|
-
|
67
|
-
...getFieldsLocale([{ name: "name" }]),
|
68
|
-
]}
|
69
|
-
button={{ text: t("create", { ns: "actions" }) }}
|
70
|
-
onSubmit={async (data) => {
|
71
|
-
const createdData = await createSetting(data);
|
72
|
-
if (typeof onCreated === "function") {
|
73
|
-
onCreated(createdData);
|
74
|
-
}
|
75
|
-
}}
|
76
|
-
/>
|
77
|
-
);
|
78
|
-
},
|
79
|
-
);
|
80
|
-
|
81
|
-
SettingCreatePanel.displayName = "SettingCreatePanel";
|
82
|
-
|
83
|
-
export default SettingCreatePanel;
|
@@ -1,105 +0,0 @@
|
|
1
|
-
import { PageTitle } from "@/components/custom/page-title";
|
2
|
-
import DataPanel from "@/components/panels/data-panel";
|
3
|
-
import { useSettingDelete } from "@/features/blog/setting";
|
4
|
-
import { useApp } from "@/hooks/use-app";
|
5
|
-
import { isPlural } from "@/lib/utils";
|
6
|
-
import { Setting } from "@/types/models";
|
7
|
-
import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
|
8
|
-
import { useState } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
import SettingCreatePanel from "./components/setting-create-panel";
|
11
|
-
import SettingUpdatePanel from "./components/setting-update-panel";
|
12
|
-
|
13
|
-
export default function Page() {
|
14
|
-
const [selectedItems, setSelectedItems] = useState<Setting[]>([]);
|
15
|
-
const { mutate: deleteSetting } = useSettingDelete();
|
16
|
-
const { openSheet, confirm, closeSheet } = useApp();
|
17
|
-
const { t } = useTranslation(["setting", "modules", "actions"]);
|
18
|
-
|
19
|
-
const openCreate = () => {
|
20
|
-
const id = openSheet({
|
21
|
-
title: t("create", { ns: "actions" }),
|
22
|
-
description: t("createText", { ns: "setting" }),
|
23
|
-
children: () => <SettingCreatePanel onCreated={() => closeSheet(id)} />,
|
24
|
-
});
|
25
|
-
|
26
|
-
return id;
|
27
|
-
};
|
28
|
-
|
29
|
-
const openDelete = (items: Setting[]) => {
|
30
|
-
return confirm({
|
31
|
-
title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
|
32
|
-
description: t("deleteText", { ns: "setting" }),
|
33
|
-
})
|
34
|
-
.then(() =>
|
35
|
-
deleteSetting(
|
36
|
-
items.map((item) => item.id).filter((id) => id !== undefined),
|
37
|
-
),
|
38
|
-
)
|
39
|
-
.catch(() => setSelectedItems(items));
|
40
|
-
};
|
41
|
-
|
42
|
-
const openUpdate = (item: Setting) => {
|
43
|
-
const id = openSheet({
|
44
|
-
children: () => (
|
45
|
-
<SettingUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
46
|
-
),
|
47
|
-
title: t("edit", { ns: "setting" }),
|
48
|
-
description: t("editText", { ns: "setting" }),
|
49
|
-
});
|
50
|
-
|
51
|
-
return id;
|
52
|
-
};
|
53
|
-
|
54
|
-
return (
|
55
|
-
<>
|
56
|
-
<PageTitle title={t("setting", { ns: "modules" })} />
|
57
|
-
<DataPanel
|
58
|
-
url="/setting"
|
59
|
-
layout="table"
|
60
|
-
id="setting"
|
61
|
-
selectable
|
62
|
-
columns={[
|
63
|
-
{ key: "id", header: "ID", width: 64 },
|
64
|
-
{ key: "name", header: t("name", { ns: "setting" }) },
|
65
|
-
]}
|
66
|
-
selected={selectedItems as Setting[]}
|
67
|
-
multiple
|
68
|
-
hasSearch
|
69
|
-
sortable
|
70
|
-
onItemDoubleClick={(item) => openUpdate(item)}
|
71
|
-
menuActions={[
|
72
|
-
{
|
73
|
-
icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
|
74
|
-
label: t("edit", { ns: "actions" }),
|
75
|
-
tooltip: t("editTooltip", { ns: "setting" }),
|
76
|
-
handler: (items: Setting[]) => {
|
77
|
-
if (items.length === 1) openUpdate(items[0]);
|
78
|
-
},
|
79
|
-
show: "once",
|
80
|
-
},
|
81
|
-
{
|
82
|
-
icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
|
83
|
-
label: t("delete", { ns: "actions" }),
|
84
|
-
tooltip: t("deleteTooltip", { ns: "setting" }),
|
85
|
-
variant: "destructive",
|
86
|
-
handler: (items: Setting[]) => {
|
87
|
-
openDelete(items);
|
88
|
-
},
|
89
|
-
show: "some",
|
90
|
-
},
|
91
|
-
{
|
92
|
-
icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
|
93
|
-
label: t("create", { ns: "actions" }),
|
94
|
-
tooltip: t("createTooltip", { ns: "setting" }),
|
95
|
-
variant: "default",
|
96
|
-
handler: () => {
|
97
|
-
openCreate();
|
98
|
-
},
|
99
|
-
show: "none",
|
100
|
-
},
|
101
|
-
]}
|
102
|
-
/>
|
103
|
-
</>
|
104
|
-
);
|
105
|
-
}
|
@@ -1,96 +0,0 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from "@/components/panels/form-panel";
|
5
|
-
import { Overlay } from "@/components/custom/overlay";
|
6
|
-
import { TabPanel } from "@/components/panels/tab-panel";
|
7
|
-
import { EnumFieldType } from "@/enums/EnumFieldType";
|
8
|
-
import { useSettingGet, useSettingUpdate } from "@/features/blog/setting";
|
9
|
-
import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
|
10
|
-
import { Setting } from "@/types/models";
|
11
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
12
|
-
import { useTranslation } from "react-i18next";
|
13
|
-
|
14
|
-
export type SettingUpdatePanelProps = {
|
15
|
-
data: Setting;
|
16
|
-
onUpdated?: (data: Setting) => void;
|
17
|
-
};
|
18
|
-
|
19
|
-
const SettingUpdatePanel = forwardRef(
|
20
|
-
({ data, onUpdated }: SettingUpdatePanelProps, ref) => {
|
21
|
-
const { t } = useTranslation(["actions"]);
|
22
|
-
const { data: item, isLoading } = useSettingGet(data.id as number);
|
23
|
-
const { mutate: settingUpdate } = useSettingUpdate();
|
24
|
-
const formRef = useRef<FormPanelRef>(null);
|
25
|
-
|
26
|
-
useEffectAfterFirstUpdate(() => {
|
27
|
-
if (item && formRef.current) {
|
28
|
-
formRef.current.setValuesFromItem(item);
|
29
|
-
}
|
30
|
-
}, [item]);
|
31
|
-
|
32
|
-
useImperativeHandle(ref, () => ({}));
|
33
|
-
|
34
|
-
return (
|
35
|
-
<TabPanel
|
36
|
-
activeTabIndex={0}
|
37
|
-
tabs={[
|
38
|
-
{
|
39
|
-
title: t("details", { ns: "actions" }),
|
40
|
-
children: (
|
41
|
-
<Overlay loading={isLoading}>
|
42
|
-
<FormPanel
|
43
|
-
ref={formRef}
|
44
|
-
fields={[
|
45
|
-
{
|
46
|
-
name: "group_id",
|
47
|
-
label: { text: t("group_id", { ns: "translation" }) },
|
48
|
-
type: EnumFieldType.TEXT,
|
49
|
-
required: true,
|
50
|
-
},
|
51
|
-
|
52
|
-
{
|
53
|
-
name: "type",
|
54
|
-
label: { text: t("type", { ns: "translation" }) },
|
55
|
-
type: EnumFieldType.TEXT,
|
56
|
-
required: true,
|
57
|
-
},
|
58
|
-
|
59
|
-
{
|
60
|
-
name: "value",
|
61
|
-
label: { text: t("value", { ns: "translation" }) },
|
62
|
-
type: EnumFieldType.TEXT,
|
63
|
-
required: true,
|
64
|
-
},
|
65
|
-
|
66
|
-
{
|
67
|
-
name: "user_override",
|
68
|
-
label: {
|
69
|
-
text: t("user_override", { ns: "translation" }),
|
70
|
-
},
|
71
|
-
type: EnumFieldType.TEXT,
|
72
|
-
required: true,
|
73
|
-
},
|
74
|
-
|
75
|
-
...getFieldsLocale([{ name: "name" }]),
|
76
|
-
]}
|
77
|
-
button={{ text: t("save", { ns: "actions" }) }}
|
78
|
-
onSubmit={(data) => {
|
79
|
-
settingUpdate({ id: data.id, data });
|
80
|
-
if (typeof onUpdated === "function") {
|
81
|
-
onUpdated(data);
|
82
|
-
}
|
83
|
-
}}
|
84
|
-
/>
|
85
|
-
</Overlay>
|
86
|
-
),
|
87
|
-
},
|
88
|
-
]}
|
89
|
-
/>
|
90
|
-
);
|
91
|
-
},
|
92
|
-
);
|
93
|
-
|
94
|
-
SettingUpdatePanel.displayName = "SettingUpdatePanel";
|
95
|
-
|
96
|
-
export default SettingUpdatePanel;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Create setting",
|
3
|
-
"createText": "Fill the setting informations.",
|
4
|
-
"createTooltip": "Create new setting",
|
5
|
-
"delete": "Delete setting",
|
6
|
-
"deleteText": "Are you sure to delete these setting?",
|
7
|
-
"deleteTooltip": "Delete the selected setting",
|
8
|
-
"edit": "Edit setting",
|
9
|
-
"editText": "View and edit setting information.",
|
10
|
-
"editTooltip": "Edit the selected setting"
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Criar configuração",
|
3
|
-
"createText": "Preencha as informações da configuração.",
|
4
|
-
"createTooltip": "Criar nova configuração",
|
5
|
-
"delete": "Deletar configuração",
|
6
|
-
"deleteText": "Você tem certeza de que deseja deletar estas configurações?",
|
7
|
-
"deleteTooltip": "Deletar a configuração selecionada",
|
8
|
-
"edit": "Editar configuração",
|
9
|
-
"editText": "Ver e editar informações da configuração.",
|
10
|
-
"editTooltip": "Editar a configuração selecionada"
|
11
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { requests } from "./requests";
|
4
|
-
|
5
|
-
const scope = "setting";
|
6
|
-
|
7
|
-
export function useSettingCreate() {
|
8
|
-
const { settingCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", settingCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function useSettingDelete() {
|
13
|
-
const { settingDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", settingDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function useSettingUpdate() {
|
18
|
-
const { settingUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", settingUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function useSettingGet(id: number) {
|
23
|
-
const { settingGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => settingGet(id),
|
27
|
-
});
|
28
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { useApp } from "@/hooks/use-app";
|
2
|
-
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
-
import { Setting } from "@/types/models";
|
4
|
-
import { HttpMethod } from "@/types/http-method";
|
5
|
-
import { formatDataWithLocale } from "@hedhog/utils";
|
6
|
-
|
7
|
-
export function requests() {
|
8
|
-
const { request } = useApp();
|
9
|
-
|
10
|
-
const settingList = async (params: PaginationParams) => {
|
11
|
-
return request<PaginationResult<Setting>>({
|
12
|
-
url: "/setting",
|
13
|
-
params,
|
14
|
-
}).then((res) => res.data);
|
15
|
-
};
|
16
|
-
|
17
|
-
const settingGet = async (id: number) => {
|
18
|
-
return request<Setting>({
|
19
|
-
url: `/setting/${id}`,
|
20
|
-
}).then((res) => res.data);
|
21
|
-
};
|
22
|
-
|
23
|
-
const settingCreate = async (data: Setting) => {
|
24
|
-
return request<Setting>({
|
25
|
-
url: "/setting",
|
26
|
-
method: HttpMethod.POST,
|
27
|
-
data: formatDataWithLocale(data),
|
28
|
-
}).then((res) => res.data);
|
29
|
-
};
|
30
|
-
|
31
|
-
const settingDelete = async (ids: number[]) => {
|
32
|
-
return request<Delete>({
|
33
|
-
url: "/setting",
|
34
|
-
data: { ids },
|
35
|
-
method: HttpMethod.DELETE,
|
36
|
-
}).then((res) => res.data);
|
37
|
-
};
|
38
|
-
|
39
|
-
const settingUpdate = async (params: { id: number; data: Setting }) => {
|
40
|
-
const { id, data } = params;
|
41
|
-
return request<Setting>({
|
42
|
-
url: `/setting/${id}`,
|
43
|
-
method: HttpMethod.PATCH,
|
44
|
-
data: formatDataWithLocale(data),
|
45
|
-
}).then((res) => res.data);
|
46
|
-
};
|
47
|
-
|
48
|
-
return {
|
49
|
-
settingCreate,
|
50
|
-
settingUpdate,
|
51
|
-
settingDelete,
|
52
|
-
settingList,
|
53
|
-
settingGet,
|
54
|
-
};
|
55
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from "@/components/panels/form-panel";
|
5
|
-
import { EnumFieldType } from "@/enums/EnumFieldType";
|
6
|
-
import { useSettingGroupCreate } from "@/features/blog/setting-group";
|
7
|
-
import { SettingGroup } from "@/types/models";
|
8
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
|
11
|
-
export type SettingGroupCreatePanelRef = {
|
12
|
-
submit: () => void;
|
13
|
-
};
|
14
|
-
|
15
|
-
export type SettingGroupCreatePanelProps = {
|
16
|
-
onCreated?: (data: SettingGroup) => void;
|
17
|
-
};
|
18
|
-
|
19
|
-
const SettingGroupCreatePanel = forwardRef(
|
20
|
-
({ onCreated }: SettingGroupCreatePanelProps, ref) => {
|
21
|
-
const formRef = useRef<FormPanelRef>(null);
|
22
|
-
const { t } = useTranslation(["actions"]);
|
23
|
-
const { mutateAsync: createSettingGroup } = useSettingGroupCreate();
|
24
|
-
|
25
|
-
useImperativeHandle(
|
26
|
-
ref,
|
27
|
-
() => ({
|
28
|
-
submit: () => {
|
29
|
-
formRef.current?.submit();
|
30
|
-
},
|
31
|
-
}),
|
32
|
-
[formRef],
|
33
|
-
);
|
34
|
-
|
35
|
-
return (
|
36
|
-
<FormPanel
|
37
|
-
ref={formRef}
|
38
|
-
fields={[
|
39
|
-
{
|
40
|
-
name: "icon",
|
41
|
-
label: { text: t("icon", { ns: "translation" }) },
|
42
|
-
type: EnumFieldType.TEXT,
|
43
|
-
required: true,
|
44
|
-
},
|
45
|
-
|
46
|
-
...getFieldsLocale([{ name: "name" }]),
|
47
|
-
]}
|
48
|
-
button={{ text: t("create", { ns: "actions" }) }}
|
49
|
-
onSubmit={async (data) => {
|
50
|
-
const createdData = await createSettingGroup(data);
|
51
|
-
if (typeof onCreated === "function") {
|
52
|
-
onCreated(createdData);
|
53
|
-
}
|
54
|
-
}}
|
55
|
-
/>
|
56
|
-
);
|
57
|
-
},
|
58
|
-
);
|
59
|
-
|
60
|
-
SettingGroupCreatePanel.displayName = "SettingGroupCreatePanel";
|
61
|
-
|
62
|
-
export default SettingGroupCreatePanel;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
import { PageTitle } from "@/components/custom/page-title";
|
2
|
-
import DataPanel from "@/components/panels/data-panel";
|
3
|
-
import { useSettingGroupDelete } from "@/features/blog/setting-group";
|
4
|
-
import { useApp } from "@/hooks/use-app";
|
5
|
-
import { isPlural } from "@/lib/utils";
|
6
|
-
import { SettingGroup } from "@/types/models";
|
7
|
-
import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
|
8
|
-
import { useState } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
import SettingGroupCreatePanel from "./components/setting-group-create-panel";
|
11
|
-
import SettingGroupUpdatePanel from "./components/setting-group-update-panel";
|
12
|
-
|
13
|
-
export default function Page() {
|
14
|
-
const [selectedItems, setSelectedItems] = useState<SettingGroup[]>([]);
|
15
|
-
const { mutate: deleteSettingGroup } = useSettingGroupDelete();
|
16
|
-
const { openSheet, confirm, closeSheet } = useApp();
|
17
|
-
const { t } = useTranslation(["setting-group", "modules", "actions"]);
|
18
|
-
|
19
|
-
const openCreate = () => {
|
20
|
-
const id = openSheet({
|
21
|
-
title: t("create", { ns: "actions" }),
|
22
|
-
description: t("createText", { ns: "setting-group" }),
|
23
|
-
children: () => (
|
24
|
-
<SettingGroupCreatePanel onCreated={() => closeSheet(id)} />
|
25
|
-
),
|
26
|
-
});
|
27
|
-
|
28
|
-
return id;
|
29
|
-
};
|
30
|
-
|
31
|
-
const openDelete = (items: SettingGroup[]) => {
|
32
|
-
return confirm({
|
33
|
-
title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
|
34
|
-
description: t("deleteText", { ns: "setting-group" }),
|
35
|
-
})
|
36
|
-
.then(() =>
|
37
|
-
deleteSettingGroup(
|
38
|
-
items.map((item) => item.id).filter((id) => id !== undefined),
|
39
|
-
),
|
40
|
-
)
|
41
|
-
.catch(() => setSelectedItems(items));
|
42
|
-
};
|
43
|
-
|
44
|
-
const openUpdate = (item: SettingGroup) => {
|
45
|
-
const id = openSheet({
|
46
|
-
children: () => (
|
47
|
-
<SettingGroupUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
48
|
-
),
|
49
|
-
title: t("edit", { ns: "setting-group" }),
|
50
|
-
description: t("editText", { ns: "setting-group" }),
|
51
|
-
});
|
52
|
-
|
53
|
-
return id;
|
54
|
-
};
|
55
|
-
|
56
|
-
return (
|
57
|
-
<>
|
58
|
-
<PageTitle title={t("settingGroup", { ns: "modules" })} />
|
59
|
-
<DataPanel
|
60
|
-
url="/setting-group"
|
61
|
-
layout="table"
|
62
|
-
id="setting-group"
|
63
|
-
selectable
|
64
|
-
columns={[
|
65
|
-
{ key: "id", header: "ID", width: 64 },
|
66
|
-
{ key: "name", header: t("name", { ns: "setting-group" }) },
|
67
|
-
]}
|
68
|
-
selected={selectedItems as SettingGroup[]}
|
69
|
-
multiple
|
70
|
-
hasSearch
|
71
|
-
sortable
|
72
|
-
onItemDoubleClick={(item) => openUpdate(item)}
|
73
|
-
menuActions={[
|
74
|
-
{
|
75
|
-
icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
|
76
|
-
label: t("edit", { ns: "actions" }),
|
77
|
-
tooltip: t("editTooltip", { ns: "setting-group" }),
|
78
|
-
handler: (items: SettingGroup[]) => {
|
79
|
-
if (items.length === 1) openUpdate(items[0]);
|
80
|
-
},
|
81
|
-
show: "once",
|
82
|
-
},
|
83
|
-
{
|
84
|
-
icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
|
85
|
-
label: t("delete", { ns: "actions" }),
|
86
|
-
tooltip: t("deleteTooltip", { ns: "setting-group" }),
|
87
|
-
variant: "destructive",
|
88
|
-
handler: (items: SettingGroup[]) => {
|
89
|
-
openDelete(items);
|
90
|
-
},
|
91
|
-
show: "some",
|
92
|
-
},
|
93
|
-
{
|
94
|
-
icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
|
95
|
-
label: t("create", { ns: "actions" }),
|
96
|
-
tooltip: t("createTooltip", { ns: "setting-group" }),
|
97
|
-
variant: "default",
|
98
|
-
handler: () => {
|
99
|
-
openCreate();
|
100
|
-
},
|
101
|
-
show: "none",
|
102
|
-
},
|
103
|
-
]}
|
104
|
-
/>
|
105
|
-
</>
|
106
|
-
);
|
107
|
-
}
|
@@ -1,76 +0,0 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from "@/components/panels/form-panel";
|
5
|
-
import { Overlay } from "@/components/custom/overlay";
|
6
|
-
import { TabPanel } from "@/components/panels/tab-panel";
|
7
|
-
import { EnumFieldType } from "@/enums/EnumFieldType";
|
8
|
-
import {
|
9
|
-
useSettingGroupGet,
|
10
|
-
useSettingGroupUpdate,
|
11
|
-
} from "@/features/blog/setting-group";
|
12
|
-
import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
|
13
|
-
import { SettingGroup } from "@/types/models";
|
14
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
15
|
-
import { useTranslation } from "react-i18next";
|
16
|
-
|
17
|
-
export type SettingGroupUpdatePanelProps = {
|
18
|
-
data: SettingGroup;
|
19
|
-
onUpdated?: (data: SettingGroup) => void;
|
20
|
-
};
|
21
|
-
|
22
|
-
const SettingGroupUpdatePanel = forwardRef(
|
23
|
-
({ data, onUpdated }: SettingGroupUpdatePanelProps, ref) => {
|
24
|
-
const { t } = useTranslation(["actions"]);
|
25
|
-
const { data: item, isLoading } = useSettingGroupGet(data.id as number);
|
26
|
-
const { mutate: settingGroupUpdate } = useSettingGroupUpdate();
|
27
|
-
const formRef = useRef<FormPanelRef>(null);
|
28
|
-
|
29
|
-
useEffectAfterFirstUpdate(() => {
|
30
|
-
if (item && formRef.current) {
|
31
|
-
formRef.current.setValuesFromItem(item);
|
32
|
-
}
|
33
|
-
}, [item]);
|
34
|
-
|
35
|
-
useImperativeHandle(ref, () => ({}));
|
36
|
-
|
37
|
-
return (
|
38
|
-
<TabPanel
|
39
|
-
activeTabIndex={0}
|
40
|
-
tabs={[
|
41
|
-
{
|
42
|
-
title: t("details", { ns: "actions" }),
|
43
|
-
children: (
|
44
|
-
<Overlay loading={isLoading}>
|
45
|
-
<FormPanel
|
46
|
-
ref={formRef}
|
47
|
-
fields={[
|
48
|
-
{
|
49
|
-
name: "icon",
|
50
|
-
label: { text: t("icon", { ns: "translation" }) },
|
51
|
-
type: EnumFieldType.TEXT,
|
52
|
-
required: true,
|
53
|
-
},
|
54
|
-
|
55
|
-
...getFieldsLocale([{ name: "name" }]),
|
56
|
-
]}
|
57
|
-
button={{ text: t("save", { ns: "actions" }) }}
|
58
|
-
onSubmit={(data) => {
|
59
|
-
settingGroupUpdate({ id: data.id, data });
|
60
|
-
if (typeof onUpdated === "function") {
|
61
|
-
onUpdated(data);
|
62
|
-
}
|
63
|
-
}}
|
64
|
-
/>
|
65
|
-
</Overlay>
|
66
|
-
),
|
67
|
-
},
|
68
|
-
]}
|
69
|
-
/>
|
70
|
-
);
|
71
|
-
},
|
72
|
-
);
|
73
|
-
|
74
|
-
SettingGroupUpdatePanel.displayName = "SettingGroupUpdatePanel";
|
75
|
-
|
76
|
-
export default SettingGroupUpdatePanel;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Create setting group",
|
3
|
-
"createText": "Fill the setting group informations.",
|
4
|
-
"createTooltip": "Create new setting group",
|
5
|
-
"delete": "Delete setting group",
|
6
|
-
"deleteText": "Are you sure to delete these setting group?",
|
7
|
-
"deleteTooltip": "Delete the selected setting group",
|
8
|
-
"edit": "Edit setting group",
|
9
|
-
"editText": "View and edit setting group information.",
|
10
|
-
"editTooltip": "Edit the selected setting group"
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Criar grupo de configurações",
|
3
|
-
"createText": "Preencha as informações do grupo de configurações.",
|
4
|
-
"createTooltip": "Criar novo grupo de configurações",
|
5
|
-
"delete": "Excluir grupo de configurações",
|
6
|
-
"deleteText": "Você tem certeza de que deseja excluir esses grupos de configurações?",
|
7
|
-
"deleteTooltip": "Excluir o grupo de configurações selecionado",
|
8
|
-
"edit": "Editar grupo de configurações",
|
9
|
-
"editText": "Visualizar e editar informações do grupo de configurações.",
|
10
|
-
"editTooltip": "Editar o grupo de configurações selecionado"
|
11
|
-
}
|