Skip to content

Commit

Permalink
CMS-49: Remove smoking ban from park access status table (#1541)
Browse files Browse the repository at this point in the history
* CMS-49: Remove smoking ban from park access status table

* CMS-526: Remove natureAndCulture from protectedArea

* CMS-522: Change park-activity, park-facility, and park-camping-type required

* CMS-532: Remove subAreaTypeId from parkOperationSubArea

* CMS-532: Remove parkSubAreaId from parkOperationSubArea

* CMS-532: Add small fix

* CMS-522: Add small fix
  • Loading branch information
ayumi-oxd authored Dec 5, 2024
1 parent 1c8d395 commit ecf7da5
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export default function ParkAccessStatus() {
title: "Campfire Ban",
field: "hasCampfireBan",
},
{ title: "Smoking Ban", field: "hasSmokingBan" },
{
title: "Campfire Ban Effective Date",
field: "campfireBanEffectiveDate",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const { indexPark } = require("../../../../helpers/taskQueue.js");
const validator = require("../../../../helpers/validator.js");

/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#lifecycle-hooks)
Expand Down Expand Up @@ -36,10 +37,12 @@ module.exports = {
async beforeCreate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.activityTypeConnectValidator(data.activityType)
},
async beforeUpdate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.activityTypeDisconnectValidator(data.activityType)
for (const park of event.params.data?.protectedArea?.disconnect || []) {
await indexPark(park.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"activityType": {
"type": "relation",
"relation": "oneToOne",
"target": "api::activity-type.activity-type"
"target": "api::activity-type.activity-type",
"required": true
},
"modifiedBy": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const { indexPark } = require("../../../../helpers/taskQueue.js");
const validator = require("../../../../helpers/validator.js");

/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#lifecycle-hooks)
Expand Down Expand Up @@ -36,10 +37,12 @@ module.exports = {
async beforeCreate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.campingTypeConnectValidator(data.campingType)
},
async beforeUpdate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.campingTypeDisconnectValidator(data.campingType)
for (const park of event.params.data?.protectedArea?.disconnect || []) {
await indexPark(park.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"campingType": {
"type": "relation",
"relation": "oneToOne",
"target": "api::camping-type.camping-type"
"target": "api::camping-type.camping-type",
"required": true
},
"modifiedBy": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const { indexPark } = require("../../../../helpers/taskQueue.js");
const validator = require("../../../../helpers/validator.js");

/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#lifecycle-hooks)
Expand Down Expand Up @@ -36,10 +37,12 @@ module.exports = {
async beforeCreate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.facilityTypeConnectValidator(data.facilityType)
},
async beforeUpdate(event) {
let { data, where } = event.params;
data = await updateName(data, where);
validator.facilityTypeDisconnectValidator(data.facilityType)
for (const park of event.params.data?.protectedArea?.disconnect || []) {
await indexPark(park.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"facilityType": {
"type": "relation",
"relation": "oneToOne",
"target": "api::facility-type.facility-type"
"target": "api::facility-type.facility-type",
"required": true
},
"modifiedBy": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
"draftAndPublish": true
},
"attributes": {
"parkSubAreaId": {
"type": "integer"
},
"parkSubAreaTypeId": {
"type": "integer"
},
"parkSubArea": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,6 @@
},
"customField": "plugin::ckeditor5.CKEditor"
},
"natureAndCulture": {
"type": "customField",
"options": {
"preset": "toolbar"
},
"customField": "plugin::ckeditor5.CKEditor"
},
"partnerships": {
"type": "customField",
"options": {
Expand Down
38 changes: 37 additions & 1 deletion src/cms/src/helpers/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,42 @@ module.exports = {
throw new ApplicationError('Please add protectedArea relation.');
}
},
// saving without an activityType relation is not allowed
activityTypeConnectValidator: function (activityType) {
if (activityType?.connect?.length === 0) {
throw new ApplicationError('Please add activityType relation.');
}
},
// removing an activityType relation is not allowed
activityTypeDisconnectValidator: function (activityType) {
if (activityType?.disconnect?.length > 0 && activityType?.connect?.length === 0) {
throw new ApplicationError('Please add activityType relation.');
}
},
// saving without a facilityType relation is not allowed
facilityTypeConnectValidator: function (facilityType) {
if (facilityType?.connect?.length === 0) {
throw new ApplicationError('Please add facilityType relation.');
}
},
// removing a facilityType relation is not allowed
facilityTypeDisconnectValidator: function (facilityType) {
if (facilityType?.disconnect?.length > 0 && facilityType?.connect?.length === 0) {
throw new ApplicationError('Please add facilityType relation.');
}
},
// saving without a campingType relation is not allowed
campingTypeConnectValidator: function (campingType) {
if (campingType?.connect?.length === 0) {
throw new ApplicationError('Please add campingType relation.');
}
},
// removing a campingType relation is not allowed
campingTypeDisconnectValidator: function (campingType) {
if (campingType?.disconnect?.length > 0 && campingType?.connect?.length === 0) {
throw new ApplicationError('Please add campingType relation.');
}
},
// saving without a documentType relation is not allowed
documentTypeConnectValidator: function (documentType) {
if (documentType?.connect?.length === 0) {
Expand Down Expand Up @@ -85,4 +121,4 @@ module.exports = {
throw new ApplicationError('Do not add slash in slugs.');
}
},
}
}
7 changes: 2 additions & 5 deletions src/gatsby/src/components/park/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const AccordionList = ({ eventKey, data, openAccordions, toggleAccordion
}

export default function About({
parkType, natureAndCulture, conservation, culturalHeritage, history, wildlife, biogeoclimaticZones, terrestrialEcosections, marineEcosections
parkType, conservation, culturalHeritage, history, wildlife, biogeoclimaticZones, terrestrialEcosections, marineEcosections
}) {
const dataList = [
{ "title": "Cultural heritage", "code": "cultural-heritage", "description": culturalHeritage },
Expand Down Expand Up @@ -164,8 +164,7 @@ export default function About({
</p>
)}
</div>
{/* display conservation/culturalHeritage/history/wildlife accordion, otherwise display natureAndCulture */}
{dataList.length > 0 ? (
{dataList.length > 0 && (
// if parkType is ecological reserve, display conservation description without accordion
parkType === "ecological reserve" ? (
<HtmlContent>{dataList[0].description}</HtmlContent>
Expand Down Expand Up @@ -202,8 +201,6 @@ export default function About({
</Col>
</Row>
)
) : (
<HtmlContent>{natureAndCulture}</HtmlContent>
)}
</div>
)
Expand Down
11 changes: 2 additions & 9 deletions src/gatsby/src/templates/park.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default function ParkTemplate({ data }) {
const safetyInfo = park.safetyInfo.data.safetyInfo
const specialNotes = park.specialNotes.data.specialNotes
const locationNotes = park.locationNotes.data.locationNotes
const natureAndCulture = park.natureAndCulture.data.natureAndCulture
const conservation = park.conservation.data.conservation
const culturalHeritage = park.culturalHeritage.data.culturalHeritage
const history = park.history.data.history
Expand Down Expand Up @@ -205,8 +204,8 @@ export default function ParkTemplate({ data }) {
sectionIndex: 6,
display: `About this ${parkType}`,
link: "#about-this-park",
visible: !isNullOrWhiteSpace(natureAndCulture) ||
!isNullOrWhiteSpace(conservation) || !isNullOrWhiteSpace(culturalHeritage) ||
visible: !isNullOrWhiteSpace(conservation) ||
!isNullOrWhiteSpace(culturalHeritage) ||
!isNullOrWhiteSpace(history) || !isNullOrWhiteSpace(wildlife)
},
{
Expand Down Expand Up @@ -431,7 +430,6 @@ export default function ParkTemplate({ data }) {
<div ref={aboutRef} className="w-100">
<About
parkType={parkType}
natureAndCulture={natureAndCulture}
conservation={conservation}
culturalHeritage={culturalHeritage}
history={history}
Expand Down Expand Up @@ -529,11 +527,6 @@ export const query = graphql`
parkContact
}
}
natureAndCulture {
data {
natureAndCulture
}
}
conservation {
data {
conservation
Expand Down

0 comments on commit ecf7da5

Please sign in to comment.