-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf3b589
commit 7af35a6
Showing
110 changed files
with
2,286 additions
and
2,358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# adminjs | ||
.adminjs/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 27 additions & 68 deletions
95
admin/resources/blue-carbon-project-planning/blue-carbon-project-planning.resource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,39 @@ | ||
import { | ||
ActionContext, | ||
ActionRequest, | ||
ActionResponse, | ||
BaseRecord, | ||
ResourceWithOptions, | ||
} from "adminjs"; | ||
import { dataSource } from "../../datasource.js"; | ||
import { BaseData } from "@shared/entities/base-data.entity.js"; | ||
import { Country } from "@shared/entities/country.entity.js"; | ||
import { BlueCarbonProjectPlanning } from "@shared/entities/blue-carbon-project-planning.entity.js"; | ||
import { COMMON_RESOURCE_LIST_PROPERTIES } from "../common/common.resources.js"; | ||
import { BlueCarbonProjectPlanning } from "@shared/entities/cost-inputs/blue-carbon-project-planning.entity.js"; | ||
import { ResourceWithOptions } from "adminjs"; | ||
|
||
export const BlueCarbonProjectPlanningResource: ResourceWithOptions = { | ||
resource: BlueCarbonProjectPlanning, | ||
options: { | ||
properties: COMMON_RESOURCE_LIST_PROPERTIES, | ||
listProperties: [ | ||
"inputSelection", | ||
"input1", | ||
"input2", | ||
"input3", | ||
"countryName", | ||
"ecosystem", | ||
"activity", | ||
], | ||
properties: { | ||
id: { | ||
isVisible: { list: false, show: false, edit: false, filter: false }, | ||
}, | ||
country: { | ||
isVisible: { list: true, show: true, edit: true, filter: true }, | ||
}, | ||
inputSelection: { | ||
isVisible: { list: true, show: true, edit: true, filter: true }, | ||
}, | ||
input1: { | ||
isVisible: { list: true, show: true, edit: true, filter: true }, | ||
}, | ||
input2: { | ||
isVisible: { list: true, show: true, edit: true, filter: true }, | ||
}, | ||
input3: { | ||
isVisible: { list: true, show: true, edit: true, filter: true }, | ||
}, | ||
blueCarbon: { | ||
isVisible: { list: true, show: true, edit: false, filter: true }, | ||
}, | ||
}, | ||
sort: { | ||
sortBy: "inputSelection", | ||
direction: "asc", | ||
sortBy: "blueCarbon", | ||
direction: "desc", | ||
}, | ||
navigation: { | ||
name: "Data Management", | ||
icon: "Database", | ||
}, | ||
actions: { | ||
list: { | ||
after: async ( | ||
request: ActionRequest, | ||
response: ActionResponse, | ||
context: ActionContext, | ||
) => { | ||
const { records } = context; | ||
const baseDataRepo = dataSource.getRepository(BaseData); | ||
const queryBuilder = baseDataRepo | ||
.createQueryBuilder("baseData") | ||
.leftJoin( | ||
BlueCarbonProjectPlanning, | ||
"r", | ||
"baseData.blueCarbonProjectPlanning = r.id", | ||
) | ||
.leftJoin(Country, "country", "country.code = baseData.countryCode") | ||
.select("r.id", "id") | ||
.addSelect("r.inputSelection", "inputSelection") | ||
.addSelect("r.input1", "input1") | ||
.addSelect("r.input2", "input2") | ||
.addSelect("r.input3", "input3") | ||
.addSelect("country.name", "countryName") | ||
.addSelect("baseData.ecosystem", "ecosystem") | ||
.addSelect("baseData.activity", "activity"); | ||
|
||
if (records?.length) { | ||
queryBuilder.andWhere("r.id IN (:...ids)", { | ||
ids: records.map((r) => r.params.id), | ||
}); | ||
} | ||
|
||
const result = await queryBuilder.getRawMany(); | ||
|
||
return { | ||
...request, | ||
records: records!.map((record: BaseRecord) => { | ||
record.params = result.find((q) => q.id === record.params.id); | ||
return record; | ||
}), | ||
}; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.