Refactor GlobalVariablesPage component to include default_fields in rowData
This commit is contained in:
parent
839822a308
commit
15de984bb6
2 changed files with 18 additions and 10 deletions
|
|
@ -860,13 +860,14 @@ export async function requestLogout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGlobalVariables(): Promise<{
|
export async function getGlobalVariables(): Promise<{
|
||||||
[key: string]: { id: string; type: string };
|
[key: string]: { id: string; type: string,default_fields:string[] };
|
||||||
}> {
|
}> {
|
||||||
const globalVariables = {};
|
const globalVariables = {};
|
||||||
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
|
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
|
||||||
globalVariables[element.name] = {
|
globalVariables[element.name] = {
|
||||||
id: element.id,
|
id: element.id,
|
||||||
type: element.type,
|
type: element.type,
|
||||||
|
default_fields:element.default_fields
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return globalVariables;
|
return globalVariables;
|
||||||
|
|
|
||||||
|
|
@ -33,18 +33,25 @@ export default function GlobalVariablesPage() {
|
||||||
<div></div>
|
<div></div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const [rowData, setRowData] = useState<{ type: string | undefined; id: string; name: string; }[]>();
|
|
||||||
|
|
||||||
|
const [rowData, setRowData] = useState<{ type: string | undefined;
|
||||||
|
id: string; name: string; default_fields:string | undefined }[]>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const rows:Array<{type: string | undefined; id: string; name: string}> = [];
|
const rows:Array<{type: string | undefined; id: string;
|
||||||
|
name: string;default_fields:string | undefined}> = [];
|
||||||
globalVariablesEntries.forEach((e) => {
|
globalVariablesEntries.forEach((e) => {
|
||||||
const globalVariableObj = globalVariables[e];
|
const globalVariableObj = globalVariables[e];
|
||||||
|
console.log(globalVariableObj);
|
||||||
rows.push({
|
rows.push({
|
||||||
type: globalVariableObj.type,
|
type: globalVariableObj.type,
|
||||||
id: globalVariableObj.id,
|
id: globalVariableObj.id,
|
||||||
|
default_fields: (globalVariableObj.default_fields??[]).join(", "),
|
||||||
name: e,
|
name: e,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
console.log(rows);
|
||||||
setRowData(rows);
|
setRowData(rows);
|
||||||
}, [globalVariables]);
|
}, [globalVariables]);
|
||||||
|
|
||||||
|
|
@ -75,15 +82,15 @@ export default function GlobalVariablesPage() {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
editable: false,
|
editable: false,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
field: "value",
|
// field: "value",
|
||||||
cellEditor: "agLargeTextCellEditor",
|
// cellEditor: "agLargeTextCellEditor",
|
||||||
flex: 2,
|
// flex: 2,
|
||||||
editable: false,
|
// editable: false,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
headerName: "Apply To Fields",
|
headerName: "Apply To Fields",
|
||||||
field: "defaultFields",
|
field: "default_fields",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
editable: false,
|
editable: false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue