diff --git a/cypress/constants/machete-constants.ts b/cypress/constants/machete-constants.ts index af69d48a..a2ac7b29 100644 --- a/cypress/constants/machete-constants.ts +++ b/cypress/constants/machete-constants.ts @@ -27,6 +27,11 @@ export const onlineOrderRoutes: IOnlineOrderRoute = { orderConfirm: `${onlineOrdersBase}/order-confirm`, }; +const settingsBase: string = "/configuration/settings"; +export const macheteSettingsRoutes: { list: string } = { + list: `${settingsBase}` +} + export const initConfirmCheckedTerms = [ { name: "completion", diff --git a/cypress/fixtures/settings/DisableOnlineOrders.json b/cypress/fixtures/settings/DisableOnlineOrders.json new file mode 100644 index 00000000..3d7d7e14 --- /dev/null +++ b/cypress/fixtures/settings/DisableOnlineOrders.json @@ -0,0 +1,12 @@ +{ + "key": "DisableOnlineOrders", + "value": "FALSE", + "description": "Enter either TRUE or FALSE. Enter TRUE to turn off access to the online hiring portal", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.263", + "dateupdated": "2022-05-24T13:10:33.07", + "id": 28, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/DisableOnlineOrdersBanner.json b/cypress/fixtures/settings/DisableOnlineOrdersBanner.json new file mode 100644 index 00000000..c66f1a44 --- /dev/null +++ b/cypress/fixtures/settings/DisableOnlineOrdersBanner.json @@ -0,0 +1,12 @@ +{ + "key": "DisableOnlineOrdersBanner", + "value": "Online orders are currently disabled. Please call the center.anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "The message for employers when the online hring portal is turned off", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.277", + "dateupdated": "2022-05-29T00:52:38.217", + "id": 29, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/DisableOnlineOrdersBannerInfoUrl.json b/cypress/fixtures/settings/DisableOnlineOrdersBannerInfoUrl.json new file mode 100644 index 00000000..c26b1bed --- /dev/null +++ b/cypress/fixtures/settings/DisableOnlineOrdersBannerInfoUrl.json @@ -0,0 +1,12 @@ +{ + "key": "DisableOnlineOrdersBannerInfoUrl", + "value": "DisableOnlineOrdersBannerInfoUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "The URL to your center's website explaining why online hiring is turned off", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.29", + "dateupdated": "2022-05-29T00:52:39.46", + "id": 30, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/DisableWorkersVaccineRequirement.json b/cypress/fixtures/settings/DisableWorkersVaccineRequirement.json new file mode 100644 index 00000000..407a75f2 --- /dev/null +++ b/cypress/fixtures/settings/DisableWorkersVaccineRequirement.json @@ -0,0 +1,12 @@ +{ + "key": "DisableWorkersVaccineRequirement", + "value": "FALSE", + "description": null, + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T15:13:12.66", + "dateupdated": "2022-05-24T15:13:12.66", + "id": 32, + "updatedby": "Init T. Script" +} diff --git a/cypress/fixtures/settings/OnlineOrdersEnglishReqNote.json b/cypress/fixtures/settings/OnlineOrdersEnglishReqNote.json new file mode 100644 index 00000000..28f0c87a --- /dev/null +++ b/cypress/fixtures/settings/OnlineOrdersEnglishReqNote.json @@ -0,0 +1,12 @@ +{ + "key": "OnlineOrdersEnglishReqNote", + "value": "OnlineOrdersEnglishReqNoteanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the site details step. When employers requests an English-speaking worker, this note provides any center-specific details", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.137", + "dateupdated": "2022-05-29T00:53:29.85", + "id": 18, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OnlineOrdersIntroMessage.json b/cypress/fixtures/settings/OnlineOrdersIntroMessage.json new file mode 100644 index 00000000..0106a2f1 --- /dev/null +++ b/cypress/fixtures/settings/OnlineOrdersIntroMessage.json @@ -0,0 +1,12 @@ +{ + "key": "OnlineOrdersIntroMessage", + "value": "OnlineOrdersIntroMessageanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displays in the 1st step of the online hiring. Include your center's basic information and how you program works, contact number, etc. Links to your website will also work.", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.113", + "dateupdated": "2022-05-29T00:53:28.473", + "id": 16, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OnlineOrdersTerms.json b/cypress/fixtures/settings/OnlineOrdersTerms.json new file mode 100644 index 00000000..3fa499d4 --- /dev/null +++ b/cypress/fixtures/settings/OnlineOrdersTerms.json @@ -0,0 +1,12 @@ +{ + "key": "OnlineOrdersTerms", + "value": "[{\"name\":\"term1\",\"text\":\"This is the term one\"},{\"name\":\"term2\",\"text\":\"This is the term two\"}]", + "description": "The terms that an employer has to accept before proceding with creating a work order", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-06-21T15:29:44.333", + "dateupdated": "2022-06-21T15:29:44.333", + "id": 1002, + "updatedby": "Init T. Script" +} diff --git a/cypress/fixtures/settings/OnlineOrdersTransportDetailsLink.json b/cypress/fixtures/settings/OnlineOrdersTransportDetailsLink.json new file mode 100644 index 00000000..00392460 --- /dev/null +++ b/cypress/fixtures/settings/OnlineOrdersTransportDetailsLink.json @@ -0,0 +1,12 @@ +{ + "key": "OnlineOrdersTransportDetailsLink", + "value": "OnlineOrdersTransportDetailsLinkanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will display if your transport provider cost rules have any fees. Include the link to your website with transport cost info ", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.15", + "dateupdated": "2022-05-29T00:53:31.323", + "id": 19, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderConfirmTransportFeesNotice.json b/cypress/fixtures/settings/OrderConfirmTransportFeesNotice.json new file mode 100644 index 00000000..5678350e --- /dev/null +++ b/cypress/fixtures/settings/OrderConfirmTransportFeesNotice.json @@ -0,0 +1,12 @@ +{ + "key": "OrderConfirmTransportFeesNotice", + "value": "OrderConfirmTransportFeesNoticeanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will display in the last step if employer chooses a transport method with fees. Inlcude text on why the fee applies", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.16", + "dateupdated": "2022-05-29T00:53:32.737", + "id": 20, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewLaborCostMethodHelper.json b/cypress/fixtures/settings/OrderReviewLaborCostMethodHelper.json new file mode 100644 index 00000000..969937fe --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewLaborCostMethodHelper.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewLaborCostMethodHelper", + "value": "OrderReviewLaborCostMethodHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The helper text for labor cost explaining payment options", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.213", + "dateupdated": "2022-05-29T00:52:33.313", + "id": 24, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewLaborCostPayMethodHelper.json b/cypress/fixtures/settings/OrderReviewLaborCostPayMethodHelper.json new file mode 100644 index 00000000..9c01209e --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewLaborCostPayMethodHelper.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewLaborCostPayMethodHelper", + "value": "OrderReviewLaborCostAboutUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The url to your website explaining the labor cost", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.24", + "dateupdated": "2022-05-29T00:52:35.697", + "id": 26, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewNextStepsHelper.json b/cypress/fixtures/settings/OrderReviewNextStepsHelper.json new file mode 100644 index 00000000..a2fb16d8 --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewNextStepsHelper.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewNextStepsHelper", + "value": "OrderReviewNextStepsHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. Describe the next steps in the process, will employer need to wait for confirmation via a call, text or wait for email, etc.", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.25", + "dateupdated": "2022-05-29T00:52:36.943", + "id": 27, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewSkillsSummaryLabel.json b/cypress/fixtures/settings/OrderReviewSkillsSummaryLabel.json new file mode 100644 index 00000000..900203c4 --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewSkillsSummaryLabel.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewSkillsSummaryLabel", + "value": "OrderReviewSkillsSummaryLabelanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The label for the work assignments summary table", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.183", + "dateupdated": "2022-05-29T00:52:30.817", + "id": 22, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewTransportFeeEmplanationUrl.json b/cypress/fixtures/settings/OrderReviewTransportFeeEmplanationUrl.json new file mode 100644 index 00000000..b9d5c325 --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewTransportFeeEmplanationUrl.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewTransportFeeEmplanationUrl", + "value": "OrderReviewTransportFeeAboutUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The url to your website explaining the transport fees", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.227", + "dateupdated": "2022-05-29T00:52:34.5", + "id": 25, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewTransportFeeMethodHelper.json b/cypress/fixtures/settings/OrderReviewTransportFeeMethodHelper.json new file mode 100644 index 00000000..9082fc9f --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewTransportFeeMethodHelper.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewTransportFeeMethodHelper", + "value": "OrderReviewTransportFeeMethodHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The helper text for transport fees explaining payment options", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.2", + "dateupdated": "2022-05-29T00:52:32.02", + "id": 23, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrderReviewWorkerCountLabel.json b/cypress/fixtures/settings/OrderReviewWorkerCountLabel.json new file mode 100644 index 00000000..4e1ba671 --- /dev/null +++ b/cypress/fixtures/settings/OrderReviewWorkerCountLabel.json @@ -0,0 +1,12 @@ +{ + "key": "OrderReviewWorkerCountLabel", + "value": "OrderReviewWorkerCountLabelanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The label for the count of work assignments", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.173", + "dateupdated": "2022-05-29T00:52:29.627", + "id": 21, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrganizationAddress.json b/cypress/fixtures/settings/OrganizationAddress.json new file mode 100644 index 00000000..b944d3f5 --- /dev/null +++ b/cypress/fixtures/settings/OrganizationAddress.json @@ -0,0 +1,12 @@ +{ + "key": "OrganizationAddress", + "value": "123 main st, seattle, wa 98101anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will be displayed in work order summaries, etc", + "category": "General", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.047", + "dateupdated": "2022-05-29T00:53:25.613", + "id": 10, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/OrganizationName.json b/cypress/fixtures/settings/OrganizationName.json new file mode 100644 index 00000000..0df79fdd --- /dev/null +++ b/cypress/fixtures/settings/OrganizationName.json @@ -0,0 +1,14 @@ +[ + { + "key": "OrganizationName", + "value": "from stub", + "description": "Will be displayed in the employer's portal and throughout the app", + "category": "General", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:32.937", + "dateupdated": "2022-05-29T00:53:24.283", + "id": 1, + "updatedby": "jciispam@gmail.com" + } +] diff --git a/cypress/fixtures/settings/WorkCenterDescription_EN.json b/cypress/fixtures/settings/WorkCenterDescription_EN.json new file mode 100644 index 00000000..ff123775 --- /dev/null +++ b/cypress/fixtures/settings/WorkCenterDescription_EN.json @@ -0,0 +1,12 @@ +{ + "key": "WorkCenterDescription_EN", + "value": "

Casa Latina is nonprofit organization that empowers Latino immigrants through educational and economic opportunities. Our employment program connects immigrants with individuals and businesses looking for temporary labor. Our workers are skilled and dependable. From landscaping to dry walling to catering and housecleaning, if you can dream the project our workers can do it! Learn more about Casa Latina.

anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will be visible in the welcome page for all users", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.103", + "dateupdated": "2022-05-29T00:53:27.143", + "id": 15, + "updatedby": "jciispam@gmail.com" +} diff --git a/cypress/fixtures/settings/settings.json b/cypress/fixtures/settings/settings.json new file mode 100644 index 00000000..622fab8b --- /dev/null +++ b/cypress/fixtures/settings/settings.json @@ -0,0 +1,232 @@ +{ + "data": [ + { + "key": "OrganizationName", + "value": "from stub", + "description": "Will be displayed in the employer's portal and throughout the app", + "category": "General", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:32.937", + "dateupdated": "2022-05-29T00:53:24.283", + "id": 1, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrganizationAddress", + "value": "123 main st, seattle, wa 98101anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will be displayed in work order summaries, etc", + "category": "General", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.047", + "dateupdated": "2022-05-29T00:53:25.613", + "id": 10, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "WorkCenterDescription_EN", + "value": "

Casa Latina is nonprofit organization that empowers Latino immigrants through educational and economic opportunities. Our employment program connects immigrants with individuals and businesses looking for temporary labor. Our workers are skilled and dependable. From landscaping to dry walling to catering and housecleaning, if you can dream the project our workers can do it! Learn more about Casa Latina.

anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will be visible in the welcome page for all users", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.103", + "dateupdated": "2022-05-29T00:53:27.143", + "id": 15, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OnlineOrdersIntroMessage", + "value": "OnlineOrdersIntroMessageanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displays in the 1st step of the online hiring. Include your center's basic information and how you program works, contact number, etc. Links to your website will also work.", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.113", + "dateupdated": "2022-05-29T00:53:28.473", + "id": 16, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OnlineOrdersEnglishReqNote", + "value": "OnlineOrdersEnglishReqNoteanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the site details step. When employers requests an English-speaking worker, this note provides any center-specific details", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.137", + "dateupdated": "2022-05-29T00:53:29.85", + "id": 18, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OnlineOrdersTransportDetailsLink", + "value": "OnlineOrdersTransportDetailsLinkanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will display if your transport provider cost rules have any fees. Include the link to your website with transport cost info ", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.15", + "dateupdated": "2022-05-29T00:53:31.323", + "id": 19, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderConfirmTransportFeesNotice", + "value": "OrderConfirmTransportFeesNoticeanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Will display in the last step if employer chooses a transport method with fees. Inlcude text on why the fee applies", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.16", + "dateupdated": "2022-05-29T00:53:32.737", + "id": 20, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewWorkerCountLabel", + "value": "OrderReviewWorkerCountLabelanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The label for the count of work assignments", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.173", + "dateupdated": "2022-05-29T00:52:29.627", + "id": 21, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewSkillsSummaryLabel", + "value": "OrderReviewSkillsSummaryLabelanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The label for the work assignments summary table", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.183", + "dateupdated": "2022-05-29T00:52:30.817", + "id": 22, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewTransportFeeMethodHelper", + "value": "OrderReviewTransportFeeMethodHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The helper text for transport fees explaining payment options", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.2", + "dateupdated": "2022-05-29T00:52:32.02", + "id": 23, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewLaborCostMethodHelper", + "value": "OrderReviewLaborCostMethodHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The helper text for labor cost explaining payment options", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.213", + "dateupdated": "2022-05-29T00:52:33.313", + "id": 24, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewTransportFeeEmplanationUrl", + "value": "OrderReviewTransportFeeAboutUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The url to your website explaining the transport fees", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.227", + "dateupdated": "2022-05-29T00:52:34.5", + "id": 25, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewLaborCostPayMethodHelper", + "value": "OrderReviewLaborCostAboutUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. The url to your website explaining the labor cost", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.24", + "dateupdated": "2022-05-29T00:52:35.697", + "id": 26, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "OrderReviewNextStepsHelper", + "value": "OrderReviewNextStepsHelperanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "Displayed in the pre-sumbit review step. Describe the next steps in the process, will employer need to wait for confirmation via a call, text or wait for email, etc.", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.25", + "dateupdated": "2022-05-29T00:52:36.943", + "id": 27, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "DisableOnlineOrders", + "value": "FALSE", + "description": "Enter either TRUE or FALSE. Enter TRUE to turn off access to the online hiring portal", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.263", + "dateupdated": "2022-05-24T13:10:33.07", + "id": 28, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "DisableOnlineOrdersBanner", + "value": "Online orders are currently disabled. Please call the center.anythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "The message for employers when the online hring portal is turned off", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.277", + "dateupdated": "2022-05-29T00:52:38.217", + "id": 29, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "DisableOnlineOrdersBannerInfoUrl", + "value": "DisableOnlineOrdersBannerInfoUrlanythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganythinganything", + "description": "The URL to your center's website explaining why online hiring is turned off", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T13:08:33.29", + "dateupdated": "2022-05-29T00:52:39.46", + "id": 30, + "updatedby": "jciispam@gmail.com" + }, + { + "key": "DisableWorkersVaccineRequirement", + "value": "FALSE", + "description": null, + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-05-24T15:13:12.66", + "dateupdated": "2022-05-24T15:13:12.66", + "id": 32, + "updatedby": "Init T. Script" + }, + { + "key": "OnlineOrdersTerms", + "value": "[{\"name\":\"term1\",\"text\":\"This is the term one\"},{\"name\":\"term2\",\"text\":\"This is the term two\"}]", + "description": "The terms that an employer has to accept before proceding with creating a work order", + "category": "OnlineOrders", + "publicConfig": true, + "createdby": "Init T. Script", + "datecreated": "2022-06-21T15:29:44.333", + "dateupdated": "2022-06-21T15:29:44.333", + "id": 1002, + "updatedby": "Init T. Script" + } + ] +} diff --git a/cypress/integration/settings/edit-settings.spec.ts b/cypress/integration/settings/edit-settings.spec.ts new file mode 100644 index 00000000..20d93700 --- /dev/null +++ b/cypress/integration/settings/edit-settings.spec.ts @@ -0,0 +1,134 @@ +import { macheteSettingsRoutes, MACHETE_ADMIN } from "cypress/constants"; +import { MS_NON_EDITABLE_CONFIGS_LOWER_CASE } from "src/app/configs/machete-settings/shared/machete-settings-constants"; +import { Config } from "src/app/shared/models/config"; + +describe("machete settings edit", () => { + const STUBBED_CONFGIS_KEY = "stubbed.configs"; + let userEditableConfigs: Config[]; + + let privateConfigs: Config[]; + + beforeEach(() => { + cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password); + + // Stubbing the response from server here + cy.fixture("settings/settings.json"); + cy.intercept( + { + method: "GET", + url: "/api/configs", + }, + { fixture: "settings/settings" } + ).as("configs"); + cy.visit(macheteSettingsRoutes.list); + + cy.wait("@configs").then((i) => { + Cypress.env(STUBBED_CONFGIS_KEY, i.response.body.data); + const configs = Cypress.env(STUBBED_CONFGIS_KEY) as Config[]; + + userEditableConfigs = configs.filter( + (c: Config) => + c.publicConfig && + !MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) + ); + + privateConfigs = configs.filter( + (c: Config) => + !c.publicConfig && + MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) + ); + }); + }); + + it("text field when valid saves", () => { + const nonTextFields = [ + "OnlineOrdersTerms", + "DisableOnlineOrders", + "DisableWorkersVaccineRequirement", + ]; + userEditableConfigs.forEach((c: Config) => { + if (!nonTextFields.includes(c.key)) { + // mock response + cy.intercept( + { + method: "PUT", + url: "/api/configs/*", + }, + (req) => { + req.body = {}; // don't acctually change anything + req.reply({ + statusCode: 200, + body: { fixture: `settings/${c.key}.json` }, + }); + } + ).as("edit"); + cy.visit(`${macheteSettingsRoutes.list}/${c.key}`); + cy.get("#value").type(" anything"); + cy.get(`button[label="Save"]`).click(); + cy.get(`.p-confirm-popup-accept`).click(); + cy.wait("@edit").then((i) => { + expect(i.request.body.value).to.contain("anything"); + }); + } + }); + }); + + it("text field when Invalid shows error", () => { + const nonTextFields = [ + "OnlineOrdersTerms", + "DisableOnlineOrders", + "DisableWorkersVaccineRequirement", + ]; + userEditableConfigs.forEach((c: Config) => { + if (!nonTextFields.includes(c.key)) { + cy.visit(`${macheteSettingsRoutes.list}/${c.key}`); + cy.get("#value").clear(); + cy.get(`button[label="Save"]`).should("have.attr", "disabled"); + cy.get("small").contains("Value is required"); + } + }); + }); + + it("TERMS field adds & removes children", () => { + const termField = ["OnlineOrdersTerms"]; + // Expect 3 divs. 2 divs for the stubbed 2 terms and one for the buttons + const elementPerChild = 3; + + cy.visit(`${macheteSettingsRoutes.list}/${termField}`); + cy.get("app-machete-settings-term-form") + .find("div") + .first() + .children() + .should("have.length", elementPerChild); + cy.get(".p-button-info > .p-button-icon").click(); + + cy.get("app-machete-settings-term-form") + .find("div") + .first() + .children() + .should("have.length", elementPerChild + 1); + + cy.get(".p-button-danger > .p-button-icon").click(); + cy.get("app-machete-settings-term-form") + .find("div") + .first() + .children() + .should("have.length", elementPerChild); + }); + + it("TERMS field when valid saves", () => { + const termField = ["OnlineOrdersTerms"]; + const elementPerChild = 3; + }); + + it("errors when saving", () => { + privateConfigs.forEach((c: Config) => { + cy.visit(`${macheteSettingsRoutes.list}/${c.key}`); + cy.get("#value").should("exist").type("test"); + cy.get(`button[label="Save"]`).click(); + cy.get("span.p-button-label"); + cy.get(`button[ng-reflect-label="Yes"]`).click(); + cy.contains("Action not allowed"); + }); + }); +}); diff --git a/cypress/integration/settings/list-settings.spec.ts b/cypress/integration/settings/list-settings.spec.ts new file mode 100644 index 00000000..06229b7d --- /dev/null +++ b/cypress/integration/settings/list-settings.spec.ts @@ -0,0 +1,76 @@ +import { + ENV_KEY_MACHETE_CONFIGS, + macheteSettingsRoutes, + MACHETE_ADMIN, +} from "cypress/constants"; +import { Config } from "src/app/shared/models/config"; +import { MS_NON_EDITABLE_CONFIGS_LOWER_CASE } from "src/app/configs/machete-settings/shared/machete-settings-constants"; + +describe("machete settings list", () => { + let userEditableConfigs: Config[]; + + let privateConfigs: Config[]; + + let configs: Config[]; + + beforeEach(() => { + cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password); + + // wait for data to load + cy.intercept({ + method: "GET", + url: "/api/configs", + }).as("configs"); + + cy.getMacheteConfigs(); + cy.visit(macheteSettingsRoutes.list); + + cy.wait("@configs").then(() => { + configs = Cypress.env(ENV_KEY_MACHETE_CONFIGS) as Config[]; + userEditableConfigs = configs.filter( + (c: Config) => + c.publicConfig && + !MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) + ); + + privateConfigs = configs.filter( + (c: Config) => + !c.publicConfig && + MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(c.key.toLowerCase()) + ); + }); + + }); + + it("when list loads, should display table", () => { + cy.visit(macheteSettingsRoutes.list); + cy.get("table") + .should("be.visible") + .should("have.class", "p-datatable-table"); + }); + it("when list loads, results should contain user-editable configs", () => { + cy.visit(macheteSettingsRoutes.list); + + userEditableConfigs.forEach((c: Config) => { + cy.get("input").type(c.key); + cy.get("table").should("contain.text", c.key); + cy.get("input").clear(); + }); + + privateConfigs.forEach((c: Config) => { + cy.get("input").type(c.key); + cy.get("table").should("not.contain.text", c.key); + cy.get("input").clear(); + }); + }); +}); + +describe("when record selected", () => { + it("should navigate to detail page", () => { + cy.contains("OrganizationName").click(); + cy.url().should( + "include", + `${macheteSettingsRoutes.list}/OrganizationName` + ); + }); +}); diff --git a/src/app/configs/configs-routing.module.ts b/src/app/configs/configs-routing.module.ts index 2fcdf80e..7e59c4b3 100644 --- a/src/app/configs/configs-routing.module.ts +++ b/src/app/configs/configs-routing.module.ts @@ -19,6 +19,13 @@ const routes: Routes = [ }, ], }, + { + path: "settings", + loadChildren: () => + import("./machete-settings/machete-settings.module").then( + (m) => m.MacheteSettingsModule + ), + }, ]; @NgModule({ diff --git a/src/app/configs/configs.service.ts b/src/app/configs/configs.service.ts index 57d490df..df4ab43e 100644 --- a/src/app/configs/configs.service.ts +++ b/src/app/configs/configs.service.ts @@ -1,17 +1,19 @@ -import { Observable, of } from "rxjs"; +import { Observable, of, throwError } from "rxjs"; -import { first, mergeMap, map } from "rxjs/operators"; +import { first, mergeMap, map, pluck, catchError, tap } from "rxjs/operators"; import { Injectable } from "@angular/core"; import { environment } from "../../environments/environment"; import { HttpClient } from "@angular/common/http"; import { Config, CCategory } from "../shared/models/config"; +import { MessagesService } from "../shared/components/messages/messages.service"; +import { MS_NON_EDITABLE_CONFIGS_LOWER_CASE } from "./machete-settings/shared/machete-settings-constants"; @Injectable() export class ConfigsService { uriBase = environment.dataUrl + "/api/configs"; configs = new Array(); configsAge = 0; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private appMessages: MessagesService) {} // TODO simplify isStale(): boolean { @@ -50,7 +52,42 @@ export class ConfigsService { getConfig(key: string): Observable { return this.getAllConfigs().pipe( mergeMap((a) => a.filter((ll) => ll.key === key)), + map((a) => ({ ...a })), // return a new object first() ); } + + update(config: Config): Observable { + if (MS_NON_EDITABLE_CONFIGS_LOWER_CASE.includes(config.key.toLowerCase())) { + return this.getConfig(config.key).pipe( + tap(() => { + this.appMessages.showErrors({ + Error: "Action not allowed", + }); + }) + ); + } + + return this.http + .put(`${this.uriBase}/${config.id}`, config, { withCredentials: true }) + .pipe( + catchError((error) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + const errorAsText: string = error["statusText"] as string; + this.appMessages.showErrors({ + Error: `${errorAsText}: Contact Machete support.`, + }); + console.log(error); + return throwError(error); + }), + pluck("data"), + map((data) => data as Config), + tap(() => { + this.appMessages.showSuccess({ + label: "Success", + message: "Record Saved", + }); + }) + ); + } } diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.css b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.html b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.html new file mode 100644 index 00000000..43d85b35 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.html @@ -0,0 +1,119 @@ + + + + + {{ r.key }} + + + + {{ tpHelperText }} + +
+
+
+
+
+
+ Description +
+
+ {{ r.description }} +
+
+
+ +
+
+
+
+
+
+
+ + + + +
+
+ + + + + Value is required +
+
+ +
+
+
+
+ + +
+ + +
+ +
+ +
+
+
+
+ +
+
+
+ Updated By +
+ {{ r.updatedby }} +
+ + + +
+
+ Date Updated +
+ + {{ r.dateupdated | date: "short" }} + +
+
+
+
diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.spec.ts b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.spec.ts new file mode 100644 index 00000000..a177d9b5 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.spec.ts @@ -0,0 +1,57 @@ +import { HttpClientTestingModule } from "@angular/common/http/testing"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { FormsModule } from "@angular/forms"; +import { ActivatedRoute } from "@angular/router"; +import { RouterTestingModule } from "@angular/router/testing"; +import { ConfirmationService } from "primeng/api"; +import { of } from "rxjs"; +import { ConfigsServiceSpy } from "src/app/shared/testing"; +import { ConfigsService } from "../../configs.service"; + +import { MacheteSettingsEditComponent } from "./machete-settings-edit.component"; + +describe("MacheteSettingsEditComponent", () => { + let component: MacheteSettingsEditComponent; + let fixture: ComponentFixture; + let confirmationSpy: jasmine.SpyObj; + + beforeEach(async () => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + confirmationSpy = jasmine.createSpyObj("ConfirmationService", ["confirm"]); + + await TestBed.configureTestingModule({ + imports: [ + HttpClientTestingModule, + RouterTestingModule.withRoutes([]), + FormsModule, + ], + declarations: [MacheteSettingsEditComponent], + providers: [ + { + provide: ConfigsService, + useClass: ConfigsServiceSpy, + }, + { + provide: ConfirmationService, + useValue: confirmationSpy, + }, + { + provide: ActivatedRoute, + useValue: { + params: of("someRoute"), + }, + }, + ], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MacheteSettingsEditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.ts b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.ts new file mode 100644 index 00000000..6fe77b7c --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-edit.component.ts @@ -0,0 +1,88 @@ +/* eslint-disable @typescript-eslint/unbound-method */ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { ActivatedRoute, Router } from "@angular/router"; +import { ConfirmationService } from "primeng/api"; +import { merge, Observable, Subject } from "rxjs"; +import { pluck, switchMap, takeWhile, tap } from "rxjs/operators"; +import { Config } from "src/app/shared/models/config"; +import { ConfigsService } from "../../configs.service"; + +@Component({ + selector: "app-machete-settings-edit", + templateUrl: "./machete-settings-edit.component.html", + styleUrls: ["./machete-settings-edit.component.css"], +}) +export class MacheteSettingsEditComponent implements OnInit, OnDestroy { + private routeRecordId: string; + private isAlive = true; + + public record$: Observable; + public activeTab = "register"; + public tpHelperText: string; + public readonly TERMS_KEY: string = "OnlineOrdersTerms"; + private updatedRecord$: Subject = new Subject(); + private initialData$ = this.activatedRoute.params.pipe( + pluck("id"), + switchMap((id: string) => { + this.routeRecordId = id; + return this.configsService.getConfig(this.routeRecordId); + }) + ); + + constructor( + private activatedRoute: ActivatedRoute, + private router: Router, + private configsService: ConfigsService, + private primeConfirmService: ConfirmationService + ) {} + + ngOnInit(): void { + this.tpHelperText = `Machete settings make system changes. Proceed with caution`; + + this.record$ = merge( + this.initialData$.pipe( + tap(() => console.log("on init: form set with initial")) + ), + this.updatedRecord$.pipe( + tap(() => + console.log("post update/create: form refresehed with API result") + ) + ) + ); + } + + public save(record: Config): void { + this.configsService + .update(record) + .pipe( + takeWhile(() => this.isAlive), + tap((config: Config) => this.updatedRecord$.next(config)) + ) + .subscribe(); + } + + public onConfirmSave(event: Event, record: Config): void { + this.primeConfirmService.confirm({ + target: event.target, + message: + "Are you sure that you want to save changes?. This cannot be undone", + icon: "pi pi-exclamation-triangle", + accept: () => { + this.save(record); + }, + reject: () => console.log("save canceled"), + }); + } + + public async onCancel(): Promise { + await this.router.navigate(["/configuration/settings"]); + } + + public onChildTermChange(data: string, r: Config): void { + this.updatedRecord$.next({ ...r, value: data }); + } + + ngOnDestroy(): void { + this.isAlive = false; + } +} diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.html b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.html new file mode 100644 index 00000000..00789e6e --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.html @@ -0,0 +1,67 @@ +
Terms
+
+ + +
+ + {{termForm.controls['name'].value}} + +
+ + + + + + Required + +
+
+ + + + + + Required + +
+
+
+ + +
+
+ + +
+
+
diff --git a/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.ts b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.ts new file mode 100644 index 00000000..522ec801 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/machete-settings-term-form.component.ts @@ -0,0 +1,95 @@ +/* eslint-disable @typescript-eslint/unbound-method */ +import { + Component, + EventEmitter, + Input, + OnDestroy, + OnInit, + Output, +} from "@angular/core"; +import { + FormArray, + FormBuilder, + FormControl, + FormGroup, + Validators, +} from "@angular/forms"; +import { debounceTime, takeWhile, tap } from "rxjs/operators"; +import { OnlineOrderTerm } from "./online-order-term"; + +@Component({ + selector: "app-machete-settings-term-form", + templateUrl: "./machete-settings-term-form.component.html", + styles: [], +}) +export class MacheteSettingsTermFormComponent implements OnInit, OnDestroy { + @Output() + public termChange = new EventEmitter(); + @Input() + public termsAsString = ""; + public termsFormArray: FormArray = new FormArray([]); + public records: OnlineOrderTerm[] = []; + private isAlive = true; + + constructor(private fb: FormBuilder) {} + + public onNewTerm(): void { + this.addBlankTerm(); + } + + public onPopTerm(): void { + this.popTerm(); + } + + private addBlankTerm(): void { + const termForm = new FormGroup({ + name: new FormControl("", Validators.required), + text: new FormControl("", Validators.required), + }); + this.termsFormArray.push(termForm); + } + + private addDefaultTerms(term: OnlineOrderTerm): void { + const termForm = new FormGroup({ + name: new FormControl(term.name, Validators.required), + text: new FormControl(term.text, Validators.required), + }); + this.termsFormArray.push(termForm); + } + + private popTerm(): void { + this.termsFormArray.removeAt(this.termsFormArray.length - 1); + } + + private parseTerms(termsString: string): OnlineOrderTerm[] { + return termsString === "" + ? [] + : (JSON.parse(termsString) as OnlineOrderTerm[]); + } + + private clearForm(): void { + this.termsFormArray.clear(); + } + + ngOnInit(): void { + this.records = this.parseTerms(this.termsAsString); + this.clearForm(); + this.records.forEach((term: OnlineOrderTerm) => { + this.addDefaultTerms(term); + }); + + this.termsFormArray.valueChanges + .pipe( + takeWhile(() => this.isAlive), + debounceTime(700), + tap((terms: OnlineOrderTerm[]) => { + this.termChange.emit(JSON.stringify(terms)); + }) + ) + .subscribe(); + } + + ngOnDestroy(): void { + this.isAlive = false; + } +} diff --git a/src/app/configs/machete-settings/machete-settings-edit/online-order-term.ts b/src/app/configs/machete-settings/machete-settings-edit/online-order-term.ts new file mode 100644 index 00000000..47a8296d --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-edit/online-order-term.ts @@ -0,0 +1,7 @@ +/** + * Model for Machete Setting Terms + */ +export class OnlineOrderTerm { + name: string; + text: string; +} diff --git a/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.css b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.html b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.html new file mode 100644 index 00000000..0af7889b --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.html @@ -0,0 +1,5 @@ + diff --git a/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.spec.ts b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.spec.ts new file mode 100644 index 00000000..23c519d3 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { Router } from "@angular/router"; +import { ConfigsServiceSpy, RouterSpy } from "src/app/shared/testing"; +import { ConfigsService } from "../../configs.service"; + +import { MacheteSettingsListComponent } from "./machete-settings-list.component"; + +describe("MacheteSettingsListComponent", () => { + let component: MacheteSettingsListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [MacheteSettingsListComponent], + providers: [ + { provide: ConfigsService, useClass: ConfigsServiceSpy }, + { provide: Router, useClass: RouterSpy }, + ], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MacheteSettingsListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.ts b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.ts new file mode 100644 index 00000000..0fae8f45 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-list/machete-settings-list.component.ts @@ -0,0 +1,39 @@ +import { Component, OnInit } from "@angular/core"; +import { Router } from "@angular/router"; +import { Observable } from "rxjs"; +import { map } from "rxjs/operators"; +import { Config } from "src/app/shared/models/config"; +import { ConfigsService } from "../../configs.service"; +import { MS_NON_EDITABLE_CONFIGS } from "../shared/machete-settings-constants"; + +@Component({ + selector: "app-machete-settings-list", + templateUrl: "./machete-settings-list.component.html", + styleUrls: ["./machete-settings-list.component.css"], +}) +export class MacheteSettingsListComponent implements OnInit { + public configs$: Observable; + public excludeCols: string[] = [ + "publicConfig", + "datecreated", + "createdby", + "id", + ]; + + constructor(private service: ConfigsService, private router: Router) {} + + async onRowSelect(selectedRecord: Config): Promise { + await this.router.navigate([ + `configuration/settings/${selectedRecord.key}`, + ]); + } + + ngOnInit(): void { + this.configs$ = this.service.getAllConfigs().pipe( + map((configs: Config[]) => configs.filter((c) => c.publicConfig)), + map((configs: Config[]) => + configs.filter((c) => !MS_NON_EDITABLE_CONFIGS.includes(c.key)) + ) + ); + } +} diff --git a/src/app/configs/machete-settings/machete-settings-routing.module.ts b/src/app/configs/machete-settings/machete-settings-routing.module.ts new file mode 100644 index 00000000..c08f235f --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings-routing.module.ts @@ -0,0 +1,30 @@ +import { NgModule } from "@angular/core"; +import { RouterModule, Routes } from "@angular/router"; +import { AuthGuardService } from "src/app/shared/services/auth-guard.service"; +import { MacheteSettingsEditComponent } from "./machete-settings-edit/machete-settings-edit.component"; +import { MacheteSettingsListComponent } from "./machete-settings-list/machete-settings-list.component"; +import { MacheteSettingsComponent } from "./machete-settings.component"; + +const routes: Routes = [ + { + path: "", + component: MacheteSettingsComponent, + canActivate: [AuthGuardService], + children: [ + { + path: "", + component: MacheteSettingsListComponent, + }, + { + path: ":id", + component: MacheteSettingsEditComponent, + }, + ], + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class MacheteSettingsRoutingModule {} diff --git a/src/app/configs/machete-settings/machete-settings.component.spec.ts b/src/app/configs/machete-settings/machete-settings.component.spec.ts new file mode 100644 index 00000000..22324490 --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from "@angular/core/testing"; + +import { MacheteSettingsComponent } from "./machete-settings.component"; + +describe("MacheteSettingsComponent", () => { + let component: MacheteSettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [MacheteSettingsComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MacheteSettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/configs/machete-settings/machete-settings.component.ts b/src/app/configs/machete-settings/machete-settings.component.ts new file mode 100644 index 00000000..3533f09b --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings.component.ts @@ -0,0 +1,9 @@ +import { Component } from "@angular/core"; + +@Component({ + selector: "app-machete-settings", + template: `

Machete Settings

+ `, + styles: [], +}) +export class MacheteSettingsComponent {} diff --git a/src/app/configs/machete-settings/machete-settings.module.ts b/src/app/configs/machete-settings/machete-settings.module.ts new file mode 100644 index 00000000..5dc7c3bf --- /dev/null +++ b/src/app/configs/machete-settings/machete-settings.module.ts @@ -0,0 +1,48 @@ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; + +import { MacheteSettingsRoutingModule } from "./machete-settings-routing.module"; +import { MacheteSettingsComponent } from "./machete-settings.component"; +import { MacheteSettingsListComponent } from "./machete-settings-list/machete-settings-list.component"; +import { RecordsTableModule } from "src/app/shared/components/records-table/records-table.module"; +import { MacheteSettingsEditComponent } from "./machete-settings-edit/machete-settings-edit.component"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; +import { DividerModule } from "primeng/divider"; +import { InputTextModule } from "primeng/inputtext"; +import { FieldsetModule } from "primeng/fieldset"; +import { ChipModule } from "primeng/chip"; +import { CardModule } from "primeng/card"; +import { ButtonModule } from "primeng/button"; +import { ToolbarModule } from "primeng/toolbar"; +import { ConfirmPopupModule } from "primeng/confirmpopup"; +import { InputTextareaModule } from "primeng/inputtextarea"; + +import { ConfirmationService } from "primeng/api"; +import { MacheteSettingsTermFormComponent } from "./machete-settings-edit/machete-settings-term-form.component"; + +@NgModule({ + declarations: [ + MacheteSettingsComponent, + MacheteSettingsListComponent, + MacheteSettingsEditComponent, + MacheteSettingsTermFormComponent, + ], + imports: [ + CommonModule, + FormsModule, + ReactiveFormsModule, + MacheteSettingsRoutingModule, + RecordsTableModule, + InputTextModule, + DividerModule, + FieldsetModule, + CardModule, + ChipModule, + ButtonModule, + ToolbarModule, + ConfirmPopupModule, + InputTextareaModule, + ], + providers: [ConfirmationService], +}) +export class MacheteSettingsModule {} diff --git a/src/app/configs/machete-settings/shared/machete-settings-constants.ts b/src/app/configs/machete-settings/shared/machete-settings-constants.ts new file mode 100644 index 00000000..1a4d8128 --- /dev/null +++ b/src/app/configs/machete-settings/shared/machete-settings-constants.ts @@ -0,0 +1,23 @@ +// Not configurable by users +export const MS_NON_EDITABLE_CONFIGS: string[] = [ + "EmailServerHostName", + "EmailServerPort", + "EmailEnableSSL", + "SmtpUser", + "SmtpPassword", + "EmailFromAddress", + "true", + "TimeZoneDifferenceFromPacific", + "PayPalClientID", + "PayPalUrl", + "PayPalClientSecret", + "PayPalEnvironment", + "MicrosoftTimeZoneIndex", + "FacebookAppId", + "GoogleClientId", + "OAuthStateParameter", +]; + +export const MS_NON_EDITABLE_CONFIGS_LOWER_CASE: string[] = [ + ...MS_NON_EDITABLE_CONFIGS, +].map((key) => key.toLowerCase()); diff --git a/src/app/menu/load-menu-rules.ts b/src/app/menu/load-menu-rules.ts index 6310ab42..a7ff5bf1 100644 --- a/src/app/menu/load-menu-rules.ts +++ b/src/app/menu/load-menu-rules.ts @@ -80,19 +80,17 @@ export function loadMenuRules(authList: string[]): Array { // }), new MenuRule({ id: 13, + label: "Machete Settings", + icon: "tune", + routerLink: ["configuration/settings"], + authorizedRoles: [LRole.ADMIN], + }), + new MenuRule({ + id: 14, label: "Transport Providers", icon: "airport_shuttle", routerLink: ["configuration/transport-providers"], authorizedRoles: [LRole.ADMIN], - items: [ - new MenuRule({ - id: 14, - label: "List", - icon: "list", - routerLink: ["configuration/transport-providers/list"], - authorizedRoles: [LRole.ADMIN], - }), - ], }), ], }),