Skip to content

Commit

Permalink
Merge pull request #18 from Vizzuality/feature/cms/data_model_changes…
Browse files Browse the repository at this point in the history
…_to_support_data_table

Bidirectional relations for data table endpoints
  • Loading branch information
Agnieszka Figiel authored Oct 24, 2023
2 parents 5353a14 + 90a2fd7 commit f6f2992
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 21 deletions.
24 changes: 18 additions & 6 deletions cms/config/sync/admin-role.strapi-super-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@
"totalMarineArea",
"type",
"groups",
"members"
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stats",
"protection_coverage_stats"
]
},
"conditions": []
Expand All @@ -227,7 +230,10 @@
"totalMarineArea",
"type",
"groups",
"members"
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stats",
"protection_coverage_stats"
]
},
"conditions": []
Expand All @@ -243,7 +249,10 @@
"totalMarineArea",
"type",
"groups",
"members"
"members",
"fishing_protection_level_stats",
"mpaa_protection_level_stats",
"protection_coverage_stats"
]
},
"conditions": []
Expand Down Expand Up @@ -311,7 +320,8 @@
"area",
"year",
"mpaa_establishment_stage",
"protection_status"
"protection_status",
"mpa_protection_coverage_stats"
]
},
"conditions": []
Expand All @@ -334,7 +344,8 @@
"area",
"year",
"mpaa_establishment_stage",
"protection_status"
"protection_status",
"mpa_protection_coverage_stats"
]
},
"conditions": []
Expand All @@ -350,7 +361,8 @@
"area",
"year",
"mpaa_establishment_stage",
"protection_status"
"protection_status",
"mpa_protection_coverage_stats"
]
},
"conditions": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,51 @@
"sortable": false
}
},
"fishing_protection_level_stats": {
"edit": {
"label": "fishing_protection_level_stats",
"description": "",
"placeholder": "",
"visible": true,
"editable": true,
"mainField": "id"
},
"list": {
"label": "fishing_protection_level_stats",
"searchable": false,
"sortable": false
}
},
"mpaa_protection_level_stats": {
"edit": {
"label": "mpaa_protection_level_stats",
"description": "",
"placeholder": "",
"visible": true,
"editable": true,
"mainField": "id"
},
"list": {
"label": "mpaa_protection_level_stats",
"searchable": false,
"sortable": false
}
},
"protection_coverage_stats": {
"edit": {
"label": "protection_coverage_stats",
"description": "",
"placeholder": "",
"visible": true,
"editable": true,
"mainField": "id"
},
"list": {
"label": "protection_coverage_stats",
"searchable": false,
"sortable": false
}
},
"createdAt": {
"edit": {
"label": "createdAt",
Expand Down Expand Up @@ -203,6 +248,20 @@
{
"name": "members",
"size": 6
},
{
"name": "fishing_protection_level_stats",
"size": 6
}
],
[
{
"name": "mpaa_protection_level_stats",
"size": 6
},
{
"name": "protection_coverage_stats",
"size": 6
}
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@
"sortable": true
}
},
"mpa_protection_coverage_stats": {
"edit": {
"label": "mpa_protection_coverage_stats",
"description": "",
"placeholder": "",
"visible": true,
"editable": true,
"mainField": "id"
},
"list": {
"label": "mpa_protection_coverage_stats",
"searchable": false,
"sortable": false
}
},
"createdAt": {
"edit": {
"label": "createdAt",
Expand Down Expand Up @@ -204,6 +219,12 @@
"name": "protection_status",
"size": 6
}
],
[
{
"name": "mpa_protection_coverage_stats",
"size": 6
}
]
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"attributes": {
"location": {
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location"
"relation": "manyToOne",
"target": "api::location.location",
"inversedBy": "fishing_protection_level_stats"
},
"fishing_protection_level": {
"type": "relation",
Expand Down
18 changes: 18 additions & 0 deletions cms/src/api/location/content-types/location/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
"relation": "manyToMany",
"target": "api::location.location",
"inversedBy": "groups"
},
"fishing_protection_level_stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::fishing-protection-level-stat.fishing-protection-level-stat",
"mappedBy": "location"
},
"mpaa_protection_level_stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::mpaa-protection-level-stat.mpaa-protection-level-stat",
"mappedBy": "location"
},
"protection_coverage_stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::protection-coverage-stat.protection-coverage-stat",
"mappedBy": "location"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"info": {
"singularName": "mpa-protection-coverage-stat",
"pluralName": "mpa-protection-coverage-stats",
"displayName": "MPA Protection Coverage Stats"
"displayName": "MPA Protection Coverage Stats",
"description": ""
},
"options": {
"draftAndPublish": false
Expand All @@ -13,8 +14,9 @@
"attributes": {
"mpa": {
"type": "relation",
"relation": "oneToOne",
"target": "api::mpa.mpa"
"relation": "manyToOne",
"target": "api::mpa.mpa",
"inversedBy": "mpa_protection_coverage_stats"
},
"fishing_protection_level": {
"type": "relation",
Expand Down
6 changes: 6 additions & 0 deletions cms/src/api/mpa/content-types/mpa/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"type": "relation",
"relation": "oneToOne",
"target": "api::protection-status.protection-status"
},
"mpa_protection_coverage_stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::mpa-protection-coverage-stat.mpa-protection-coverage-stat",
"mappedBy": "mpa"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"info": {
"singularName": "mpaa-protection-level-stat",
"pluralName": "mpaa-protection-level-stats",
"displayName": "MPAA Protection Level Stats"
"displayName": "MPAA Protection Level Stats",
"description": ""
},
"options": {
"draftAndPublish": false
Expand All @@ -13,8 +14,9 @@
"attributes": {
"location": {
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location"
"relation": "manyToOne",
"target": "api::location.location",
"inversedBy": "mpaa_protection_level_stats"
},
"mpaa_protection_level": {
"type": "relation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"attributes": {
"location": {
"type": "relation",
"relation": "oneToOne",
"target": "api::location.location"
"relation": "manyToOne",
"target": "api::location.location",
"inversedBy": "protection_coverage_stats"
},
"protection_status": {
"type": "relation",
Expand Down
2 changes: 1 addition & 1 deletion cms/src/extensions/documentation/public/index.html

Large diffs are not rendered by default.

30 changes: 26 additions & 4 deletions cms/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ export interface ApiFishingProtectionLevelStatFishingProtectionLevelStat
attributes: {
location: Attribute.Relation<
'api::fishing-protection-level-stat.fishing-protection-level-stat',
'oneToOne',
'manyToOne',
'api::location.location'
>;
fishing_protection_level: Attribute.Relation<
Expand Down Expand Up @@ -862,6 +862,21 @@ export interface ApiLocationLocation extends Schema.CollectionType {
'manyToMany',
'api::location.location'
>;
fishing_protection_level_stats: Attribute.Relation<
'api::location.location',
'oneToMany',
'api::fishing-protection-level-stat.fishing-protection-level-stat'
>;
mpaa_protection_level_stats: Attribute.Relation<
'api::location.location',
'oneToMany',
'api::mpaa-protection-level-stat.mpaa-protection-level-stat'
>;
protection_coverage_stats: Attribute.Relation<
'api::location.location',
'oneToMany',
'api::protection-coverage-stat.protection-coverage-stat'
>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<
Expand Down Expand Up @@ -908,6 +923,11 @@ export interface ApiMpaMpa extends Schema.CollectionType {
'oneToOne',
'api::protection-status.protection-status'
>;
mpa_protection_coverage_stats: Attribute.Relation<
'api::mpa.mpa',
'oneToMany',
'api::mpa-protection-coverage-stat.mpa-protection-coverage-stat'
>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<'api::mpa.mpa', 'oneToOne', 'admin::user'> &
Expand All @@ -924,14 +944,15 @@ export interface ApiMpaProtectionCoverageStatMpaProtectionCoverageStat
singularName: 'mpa-protection-coverage-stat';
pluralName: 'mpa-protection-coverage-stats';
displayName: 'MPA Protection Coverage Stats';
description: '';
};
options: {
draftAndPublish: false;
};
attributes: {
mpa: Attribute.Relation<
'api::mpa-protection-coverage-stat.mpa-protection-coverage-stat',
'oneToOne',
'manyToOne',
'api::mpa.mpa'
>;
fishing_protection_level: Attribute.Relation<
Expand Down Expand Up @@ -1096,14 +1117,15 @@ export interface ApiMpaaProtectionLevelStatMpaaProtectionLevelStat
singularName: 'mpaa-protection-level-stat';
pluralName: 'mpaa-protection-level-stats';
displayName: 'MPAA Protection Level Stats';
description: '';
};
options: {
draftAndPublish: false;
};
attributes: {
location: Attribute.Relation<
'api::mpaa-protection-level-stat.mpaa-protection-level-stat',
'oneToOne',
'manyToOne',
'api::location.location'
>;
mpaa_protection_level: Attribute.Relation<
Expand Down Expand Up @@ -1148,7 +1170,7 @@ export interface ApiProtectionCoverageStatProtectionCoverageStat
attributes: {
location: Attribute.Relation<
'api::protection-coverage-stat.protection-coverage-stat',
'oneToOne',
'manyToOne',
'api::location.location'
>;
protection_status: Attribute.Relation<
Expand Down

0 comments on commit f6f2992

Please sign in to comment.