From 91208544b39b2120c7d46bbb4e7166698efa6001 Mon Sep 17 00:00:00 2001 From: micnori Date: Mon, 8 Jan 2024 17:20:33 +0100 Subject: [PATCH] add flags for company camp. --- .../campaign-add-form.component.html | 34 ++++++++++++++++ .../campaign-add-form.component.ts | 39 ++++++++++++++++++- src/app/shared/constants/constants.ts | 4 +- src/assets/i18n/en.json | 3 ++ src/assets/i18n/it.json | 3 ++ 5 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.html b/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.html index 2c427061..c7b7da79 100644 --- a/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.html +++ b/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.html @@ -90,6 +90,23 @@

{{'addCampaign' | translate}}

+ + {{"modality" | translate}} + + + {{'useMultiLocation' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + + + {{'useEmployeeLocation' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + {{"indicator" | translate}} @@ -545,6 +562,23 @@

{{'modifyCampaign' | translate}} -

+ + {{"modality" | translate}} + + + {{'useMultiLocation' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + + + {{'useEmployeeLocation' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + {{"indicator" | translate}} diff --git a/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.ts b/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.ts index a9dbd648..df91da59 100644 --- a/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.ts +++ b/src/app/pages/campaign/campaign-add-form/campaign-add-form.component.ts @@ -57,7 +57,9 @@ import { MONTHLY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE, DAILY_LIMIT_TRIPS_NUMBER_SPEC_LABLE, WEEKLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE, - MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE + MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE, + USE_MULTI_LOCATION, + USE_EMPLOYEE_LOCATION } from "src/app/shared/constants/constants"; import { trigger, @@ -227,6 +229,8 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ territoryId: localStorage.getItem(TERRITORY_ID_LOCAL_STORAGE_KEY), active: false, + useMultiLocation: false, + useEmployeeLocation: false, }); this.expandableDescription = false; this.campaignCreated.specificData.periods = []; @@ -329,6 +333,25 @@ export class CampaignAddFormComponent implements OnInit { labelAddModifyCampaign: this.campaignUpdated.specificData[VIRTUAL_SCORE][LABEL], }); } + if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){ + this.validatingForm.patchValue({ + useMultiLocation: this.campaignUpdated.specificData[USE_MULTI_LOCATION], + }); + } else { + this.validatingForm.patchValue({ + useMultiLocation: false, + }); + } + if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_EMPLOYEE_LOCATION]){ + this.validatingForm.patchValue({ + useEmployeeLocation: this.campaignUpdated.specificData[USE_EMPLOYEE_LOCATION], + }); + } else { + this.validatingForm.patchValue({ + useEmployeeLocation: false, + }); + } + // if ( // !this.campaignUpdated.specificData || !this.campaignUpdated.specificData[VIRTUAL_SCORE] || // Object.keys(this.campaignUpdated.specificData[VIRTUAL_SCORE]).length <= 0 @@ -396,6 +419,8 @@ export class CampaignAddFormComponent implements OnInit { monthlyLimitTripsNumber: new FormControl("",), periodFrom: new FormControl("",), periodTo: new FormControl("",), + useMultiLocation: new FormControl("", [Validators.required]), + useEmployeeLocation: new FormControl("", [Validators.required]), }); } else { this.validatingForm = this.formBuilder.group({ @@ -425,6 +450,8 @@ export class CampaignAddFormComponent implements OnInit { monthlyLimitTripsNumber: new FormControl("",), periodFrom: new FormControl("",), periodTo: new FormControl("",), + useMultiLocation: new FormControl("", [Validators.required]), + useEmployeeLocation: new FormControl("", [Validators.required]), }); } } @@ -870,6 +897,16 @@ export class CampaignAddFormComponent implements OnInit { }else{ this.campaignCreated.specificData[VIRTUAL_SCORE][MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE] = undefined; } + if(this.validatingForm.get(USE_MULTI_LOCATION).value!==null){ + this.campaignCreated.specificData[USE_MULTI_LOCATION] = this.validatingForm.get(USE_MULTI_LOCATION).value; + }else{ + this.campaignCreated.specificData[USE_MULTI_LOCATION] = false; + } + if(this.validatingForm.get(USE_EMPLOYEE_LOCATION).value!==null){ + this.campaignCreated.specificData[USE_EMPLOYEE_LOCATION] = this.validatingForm.get(USE_EMPLOYEE_LOCATION).value; + }else{ + this.campaignCreated.specificData[USE_EMPLOYEE_LOCATION] = false; + } } if(this.campaignCreated.type === "city" || this.campaignCreated.type === "school"){ if(this.validatingForm.get("challengePlayerProposedHour").value!==null && this.validatingForm.get("challengePlayerProposedDay").value!==null){ diff --git a/src/app/shared/constants/constants.ts b/src/app/shared/constants/constants.ts index f055bf1b..db21b07c 100644 --- a/src/app/shared/constants/constants.ts +++ b/src/app/shared/constants/constants.ts @@ -72,4 +72,6 @@ export const WEEKLY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE= "scoreWeeklyLimit"; export const MONTHLY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE= "scoreMonthlyLimit"; export const DAILY_LIMIT_TRIPS_NUMBER_SPEC_LABLE= "trackDailyLimit"; export const WEEKLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE= "trackWeeklyLimit"; -export const MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE= "trackMonthlyLimit"; \ No newline at end of file +export const MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE= "trackMonthlyLimit"; +export const USE_MULTI_LOCATION= "useMultiLocation"; +export const USE_EMPLOYEE_LOCATION= "useEmployeeLocation"; \ No newline at end of file diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 7fa02409..8099d0ae 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -333,6 +333,9 @@ "COMPUTED":"Computed", "UNASSIGNED":"Unassigned", "indicator":"Indicator", + "modality":"Modality", + "useMultiLocation":"Check all the company locations", + "useEmployeeLocation":"Check the employee's location", "periods":"Pay periods", "labelAddModifyCampaign":"Label", "labelAddModifyCampaignPlaceholder": "Indicator denomitation for the APP (Default ecoLeaves)", diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 2d22d7b6..df0b6b26 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -334,6 +334,9 @@ "COMPUTED":"Valutato", "UNASSIGNED":"Non assegnato", "indicator":"Indicatore", +"modality":"Modalità", +"useMultiLocation":"Controlla tutte le sedi", +"useEmployeeLocation":"Controlla sede del dipendente", "periods": "Periodi di retribuzione", "labelAddModifyCampaign":"Label", "labelAddModifyCampaignPlaceholder": "Denominazione indicatore per la APP (Default ecoLeaves)",