Skip to content

Commit

Permalink
Remove field from Location model
Browse files Browse the repository at this point in the history
clementprdhomme committed Oct 8, 2024
1 parent 0722285 commit 4d2b660
Showing 8 changed files with 295 additions and 329 deletions.
15 changes: 6 additions & 9 deletions cms/config/sync/admin-role.strapi-super-admin.json
Original file line number Diff line number Diff line change
@@ -1065,14 +1065,13 @@
"groups",
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stat",
"mpaa_protection_level_stats",
"protection_coverage_stats",
"marine_bounds",
"total_terrestrial_area",
"terrestrial_bounds",
"name_es",
"name_fr",
"mpaa_fully_highly_protected_area"
"name_fr"
]
},
"conditions": [],
@@ -1097,14 +1096,13 @@
"groups",
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stat",
"mpaa_protection_level_stats",
"protection_coverage_stats",
"marine_bounds",
"total_terrestrial_area",
"terrestrial_bounds",
"name_es",
"name_fr",
"mpaa_fully_highly_protected_area"
"name_fr"
]
},
"conditions": [],
@@ -1122,14 +1120,13 @@
"groups",
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stat",
"mpaa_protection_level_stats",
"protection_coverage_stats",
"marine_bounds",
"total_terrestrial_area",
"terrestrial_bounds",
"name_es",
"name_fr",
"mpaa_fully_highly_protected_area"
"name_fr"
]
},
"conditions": [],
Original file line number Diff line number Diff line change
@@ -121,17 +121,17 @@
"sortable": false
}
},
"mpaa_protection_level_stat": {
"mpaa_protection_level_stats": {
"edit": {
"label": "mpaa_protection_level_stat",
"label": "mpaa_protection_level_stats",
"description": "",
"placeholder": "",
"visible": true,
"editable": true,
"mainField": "id"
},
"list": {
"label": "mpaa_protection_level_stat",
"label": "mpaa_protection_level_stats",
"searchable": true,
"sortable": true
}
@@ -221,20 +221,6 @@
"sortable": true
}
},
"mpaa_fully_highly_protected_area": {
"edit": {
"label": "mpaa_fully_highly_protected_area",
"description": "",
"placeholder": "",
"visible": true,
"editable": true
},
"list": {
"label": "mpaa_fully_highly_protected_area",
"searchable": true,
"sortable": true
}
},
"createdAt": {
"edit": {
"label": "createdAt",
@@ -295,12 +281,6 @@
}
},
"layouts": {
"list": [
"id",
"code",
"name",
"total_marine_area"
],
"edit": [
[
{
@@ -350,24 +330,20 @@
],
[
{
"name": "marine_bounds",
"size": 12
"name": "mpaa_protection_level_stats",
"size": 6
}
],
[
{
"name": "terrestrial_bounds",
"name": "marine_bounds",
"size": 12
}
],
[
{
"name": "mpaa_protection_level_stat",
"size": 6
},
{
"name": "mpaa_fully_highly_protected_area",
"size": 4
"name": "terrestrial_bounds",
"size": 12
}
],
[
@@ -380,6 +356,12 @@
"size": 4
}
]
],
"list": [
"id",
"code",
"name",
"total_marine_area"
]
}
},
6 changes: 6 additions & 0 deletions cms/config/sync/user-role.public.json
Original file line number Diff line number Diff line change
@@ -114,6 +114,12 @@
{
"action": "api::mpaa-protection-level.mpaa-protection-level.findOne"
},
{
"action": "api::pa.pa.find"
},
{
"action": "api::pa.pa.findOne"
},
{
"action": "api::protection-coverage-stat.protection-coverage-stat.find"
},
7 changes: 1 addition & 6 deletions cms/src/api/location/content-types/location/schema.json
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@
"target": "api::fishing-protection-level-stat.fishing-protection-level-stat",
"mappedBy": "location"
},
"mpaa_protection_level_stat": {
"mpaa_protection_level_stats": {
"type": "relation",
"relation": "oneToOne",
"target": "api::mpaa-protection-level-stat.mpaa-protection-level-stat",
@@ -93,11 +93,6 @@
"name_fr": {
"type": "string",
"required": true
},
"mpaa_fully_highly_protected_area": {
"type": "decimal",
"required": false,
"min": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location",
"mappedBy": "mpaa_protection_level_stat"
"mappedBy": "mpaa_protection_level_stats"
}
}
}
6 changes: 1 addition & 5 deletions cms/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1572,7 +1572,7 @@ export interface ApiLocationLocation extends Schema.CollectionType {
'oneToMany',
'api::fishing-protection-level-stat.fishing-protection-level-stat'
>;
mpaa_protection_level_stat: Attribute.Relation<
mpaa_protection_level_stats: Attribute.Relation<
'api::location.location',
'oneToOne',
'api::mpaa-protection-level-stat.mpaa-protection-level-stat'
@@ -1587,10 +1587,6 @@ export interface ApiLocationLocation extends Schema.CollectionType {
terrestrial_bounds: Attribute.JSON;
name_es: Attribute.String & Attribute.Required;
name_fr: Attribute.String & Attribute.Required;
mpaa_fully_highly_protected_area: Attribute.Decimal &
Attribute.SetMinMax<{
min: 0;
}>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<
Original file line number Diff line number Diff line change
@@ -28,7 +28,9 @@ export type GlobalRegionalTableColumns = {
name_es: string;
name_fr: string;
code: string;
mpaa_fully_highly_protected_area: number;
mpaa_protection_level_stats: {
percentage: number;
};
};
environment: {
name: string;
@@ -258,8 +260,8 @@ export const useColumns = (
...(environment === 'marine'
? [
{
id: 'location.mpaa_fully_highly_protected_area',
accessorKey: 'location.mpaa_fully_highly_protected_area',
id: 'location.mpaa_protection_level_stats.percentage',
accessorKey: 'location.mpaa_protection_level_stats.percentage',
header: ({ column }) => (
<HeaderItem>
<SortingButton column={column} />
@@ -271,7 +273,7 @@ export const useColumns = (
const { location } = row.original;
const formattedValue = cellFormatter.percentage(
locale,
location.mpaa_fully_highly_protected_area
location.mpaa_protection_level_stats.percentage
);
return (
<span className="text-xs">{t('percentage', { percentage: formattedValue })}</span>
@@ -352,19 +354,12 @@ export const useData = (
// @ts-ignore
populate: {
location: {
fields: ['name', 'name_es', 'name_fr', 'code', 'mpaa_fully_highly_protected_area'],
fields: ['name', 'name_es', 'name_fr', 'code'],
populate: {
...(environment === 'marine'
? {
mpaa_protection_level_stats: {
fields: ['percentage'],
filters: {
mpaa_protection_level: {
slug: {
$eq: 'fully-highly-protected',
},
},
},
},
}
: {}),
@@ -450,7 +445,9 @@ export const useData = (
name_es: location?.name_es,
name_fr: location?.name_fr,
code: location.code,
mpaa_fully_highly_protected_area: location.mpaa_fully_highly_protected_area,
mpaa_protection_level_stats: {
percentage: location?.mpaa_protection_level_stats.data.attributes.percentage,
},
},
environment: {
name: localizedEnvironment.name,
519 changes: 256 additions & 263 deletions frontend/src/types/generated/strapi.schemas.ts

Large diffs are not rendered by default.

0 comments on commit 4d2b660

Please sign in to comment.