From c8d284da3746dd3cf741099905d0405d60352b09 Mon Sep 17 00:00:00 2001 From: micnori Date: Fri, 19 Jul 2024 13:41:13 +0200 Subject: [PATCH 1/9] add placement conf --- .../api/generated/model/campaignPlacement.ts | 16 +++++++ .../campaign-add-form.component.html | 44 +++++++++++++++++ .../campaign-add-form.component.ts | 47 +++++++++++++++++++ src/app/shared/classes/campaing-class.ts | 2 + src/assets/i18n/en.json | 27 +++-------- src/assets/i18n/it.json | 12 ++--- 6 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 src/app/core/api/generated/model/campaignPlacement.ts diff --git a/src/app/core/api/generated/model/campaignPlacement.ts b/src/app/core/api/generated/model/campaignPlacement.ts new file mode 100644 index 00000000..79cf2dd4 --- /dev/null +++ b/src/app/core/api/generated/model/campaignPlacement.ts @@ -0,0 +1,16 @@ +/** + * Play&Go Project + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 2.0 + * Contact: info@smartcommunitylab.it + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +export interface CampaignPlacement { + active?: boolean; + title?: { [key: string]: string }; + configuration?: any; +} 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 1cce259e..2e2166e1 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,28 @@

{{'addCampaign' | translate}}

+ + {{"placement" | translate}} + +
+ + {{'placementActive' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + +
+
+ + {{'placementTitleIt' | translate}} + + + + {{'placementTitleEn' | translate}} + + +
{{"modality" | translate}} @@ -619,6 +641,28 @@

{{'modifyCampaign' | translate}} -

+ + {{"placement" | translate}} + +
+ + {{'placementActive' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + + +
+
+ + {{'placementTitleIt' | translate}} + + + + {{'placementTitleEn' | translate}} + + +
{{"modality" | 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 d491f7b3..b8e80c59 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 @@ -207,6 +207,10 @@ export class CampaignAddFormComponent implements OnInit { this.campaignCreated = new CampaignClass(); this.campaignCreated.validationData = new ValidationData(); this.campaignCreated.specificData = {}; + this.campaignCreated.campaignPlacement = { + active: false, + title: {}, + }; const keysWebHook = Object.keys(CampaignWebhook.EventsEnum); keysWebHook.forEach((item) => { this.weebHooksEventsList.push(CampaignWebhook.EventsEnum[item]); @@ -237,6 +241,7 @@ export class CampaignAddFormComponent implements OnInit { useMultiLocation: false, useEmployeeLocation: false, hideCompanyDesc: false, + placementActive: false, }); this.expandableDescription = false; this.expandableLimitCompanyDesc = false; @@ -341,6 +346,27 @@ export class CampaignAddFormComponent implements OnInit { labelAddModifyCampaign: this.campaignUpdated.specificData[VIRTUAL_SCORE][LABEL], }); } + if(!!this.campaignUpdated.campaignPlacement){ + this.validatingForm.patchValue({ + placementActive: this.campaignUpdated.campaignPlacement.active, + }); + this.validatingForm.patchValue({ + placementTitleIt: this.campaignUpdated.campaignPlacement.title["it"], + }); + this.validatingForm.patchValue({ + placementTitleEn: this.campaignUpdated.campaignPlacement.title["en"], + }); + } else { + this.validatingForm.patchValue({ + placementActive: false, + }); + this.validatingForm.patchValue({ + placementTitleIt: "Clasifiche azienda", + }); + this.validatingForm.patchValue({ + placementTitleEn: "Company standings", + }); + } if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){ this.validatingForm.patchValue({ useMultiLocation: this.campaignUpdated.specificData[USE_MULTI_LOCATION], @@ -440,6 +466,9 @@ export class CampaignAddFormComponent implements OnInit { useMultiLocation: new FormControl("", [Validators.required]), useEmployeeLocation: new FormControl("", [Validators.required]), hideCompanyDesc: new FormControl("", [Validators.required]), + placementActive: new FormControl("", [Validators.required]), + placementTitleIt: new FormControl("", [Validators.required]), + placementTitleEn: new FormControl("", [Validators.required]), }); } else { this.validatingForm = this.formBuilder.group({ @@ -472,6 +501,9 @@ export class CampaignAddFormComponent implements OnInit { useMultiLocation: new FormControl("", [Validators.required]), useEmployeeLocation: new FormControl("", [Validators.required]), hideCompanyDesc: new FormControl("", [Validators.required]), + placementActive: new FormControl("", [Validators.required]), + placementTitleIt: new FormControl("", [Validators.required]), + placementTitleEn: new FormControl("", [Validators.required]), }); } } @@ -917,6 +949,21 @@ export class CampaignAddFormComponent implements OnInit { }else{ this.campaignCreated.specificData[VIRTUAL_SCORE][MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE] = undefined; } + if(this.validatingForm.get("placementActive")) { + this.campaignCreated.campaignPlacement.active = this.validatingForm.get("placementActive").value; + } else { + this.campaignCreated.campaignPlacement.active = false; + } + if(this.validatingForm.get("placementTitleIt")) { + this.campaignCreated.campaignPlacement.title["it"] = this.validatingForm.get("placementTitleIt").value; + } else { + this.campaignCreated.campaignPlacement.title["it"] = ""; + } + if(this.validatingForm.get("placementTitleEn")) { + this.campaignCreated.campaignPlacement.title["en"] = this.validatingForm.get("placementTitleEn").value; + } else { + this.campaignCreated.campaignPlacement.title["en"] = ""; + } if(this.validatingForm.get(USE_MULTI_LOCATION).value!==null){ this.campaignCreated.specificData[USE_MULTI_LOCATION] = this.validatingForm.get(USE_MULTI_LOCATION).value; }else{ diff --git a/src/app/shared/classes/campaing-class.ts b/src/app/shared/classes/campaing-class.ts index a95ed110..d73e345c 100644 --- a/src/app/shared/classes/campaing-class.ts +++ b/src/app/shared/classes/campaing-class.ts @@ -3,6 +3,7 @@ import { CampaignDetail } from "src/app/core/api/generated/model/campaignDetail" import { CampaignWeekConf } from "src/app/core/api/generated/model/campaignWeekConf"; import { Image } from "src/app/core/api/generated/model/image"; import { SurveyRequest } from "src/app/core/api/generated/model/surveyRequest"; +import { CampaignPlacement } from "src/app/core/api/generated/model/campaignPlacement"; export interface CampaignTypeInterface{ weekStart?: string; @@ -49,6 +50,7 @@ export class CampaignClass implements Campaign { validationData?: any; weekConfs?: Array; visible?: boolean; + campaignPlacement?: CampaignPlacement; } export class ImageClass implements Image { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index da9cf872..2eae4cf6 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -355,27 +355,12 @@ "registrationCompanyDesc":"Registration form message", "limitCompanyDesc":"Limit popup message", "privacy":"Privacy policy", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", + "placement":"Classifiche", + "placementActive":"Attiva 'Classifica azienda' in HP campagna", + "placementTitleIt":"titolo italiano", + "placementTitleItPlaceholder":"Titolo italiano (dafault 'Clasifiche azienda')", + "placementTitleEn":"titolo inglese", + "placementTitleEnPlaceholder":"Titolo inglese (default 'Company standings')", "":"", "":"", "":"", diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 0039d587..b497337e 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -359,12 +359,12 @@ "registrationCompanyDesc":"Messaggio form iscrizione", "limitCompanyDesc":"Messaggio popup limiti", "privacy":"Privacy policy", -"":"", -"":"", -"":"", -"":"", -"":"", -"":"", +"placement":"Classifiche", +"placementActive":"Attiva 'Classifica azienda' in HP campagna", +"placementTitleIt":"titolo italiano", +"placementTitleItPlaceholder":"Titolo italiano (dafault 'Clasifiche azienda')", +"placementTitleEn":"titolo inglese", +"placementTitleEnPlaceholder":"Titolo inglese (default 'Company standings')", "":"", "":"", "":"", From 63fa94ca33381a5d81c7baef20b8047c6bcd7ad1 Mon Sep 17 00:00:00 2001 From: micnori Date: Mon, 19 Aug 2024 11:00:52 +0200 Subject: [PATCH 2/9] placement label non required --- .../campaign-add-form/campaign-add-form.component.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 b8e80c59..98d1eed1 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 @@ -466,9 +466,9 @@ export class CampaignAddFormComponent implements OnInit { useMultiLocation: new FormControl("", [Validators.required]), useEmployeeLocation: new FormControl("", [Validators.required]), hideCompanyDesc: new FormControl("", [Validators.required]), - placementActive: new FormControl("", [Validators.required]), - placementTitleIt: new FormControl("", [Validators.required]), - placementTitleEn: new FormControl("", [Validators.required]), + placementActive: new FormControl("",), + placementTitleIt: new FormControl("",), + placementTitleEn: new FormControl("",), }); } else { this.validatingForm = this.formBuilder.group({ @@ -501,9 +501,9 @@ export class CampaignAddFormComponent implements OnInit { useMultiLocation: new FormControl("", [Validators.required]), useEmployeeLocation: new FormControl("", [Validators.required]), hideCompanyDesc: new FormControl("", [Validators.required]), - placementActive: new FormControl("", [Validators.required]), - placementTitleIt: new FormControl("", [Validators.required]), - placementTitleEn: new FormControl("", [Validators.required]), + placementActive: new FormControl("",), + placementTitleIt: new FormControl("",), + placementTitleEn: new FormControl("",), }); } } From 1514c73ef3f0ffa10ad93b77f90912dc53a02303 Mon Sep 17 00:00:00 2001 From: micnori Date: Wed, 21 Aug 2024 14:44:41 +0200 Subject: [PATCH 3/9] add campaignPlacementPeriods --- .../campaign-add-form.component.html | 12 ++++++++ .../campaign-add-form.component.ts | 28 +++++++++++++++++++ src/assets/i18n/en.json | 12 ++++---- src/assets/i18n/it.json | 12 ++++---- 4 files changed, 52 insertions(+), 12 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 2e2166e1..66ef6d21 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 @@ -101,6 +101,12 @@

{{'addCampaign' | translate}}

|translate}} + + {{'campaignPlacementPeriods' | translate}} + + {{value |translate}} + +
@@ -652,6 +658,12 @@

{{'modifyCampaign' | translate}} - |translate}} + + {{'campaignPlacementPeriods' | translate}} + + {{value |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 98d1eed1..16cb1256 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 @@ -210,6 +210,7 @@ export class CampaignAddFormComponent implements OnInit { this.campaignCreated.campaignPlacement = { active: false, title: {}, + configuration: {}, }; const keysWebHook = Object.keys(CampaignWebhook.EventsEnum); keysWebHook.forEach((item) => { @@ -356,6 +357,15 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ placementTitleEn: this.campaignUpdated.campaignPlacement.title["en"], }); + const periods = []; + for(let key of this.getCampaignPlacementPeriods()) { + if(this.campaignUpdated.campaignPlacement.configuration[key] && (this.campaignUpdated.campaignPlacement.configuration[key] == true)) { + periods.push(key); + } + } + this.validatingForm.patchValue({ + campaignPlacementPeriods: periods, + }); } else { this.validatingForm.patchValue({ placementActive: false, @@ -366,6 +376,9 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ placementTitleEn: "Company standings", }); + this.validatingForm.patchValue({ + campaignPlacementPeriods: [], + }); } if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){ this.validatingForm.patchValue({ @@ -469,6 +482,7 @@ export class CampaignAddFormComponent implements OnInit { placementActive: new FormControl("",), placementTitleIt: new FormControl("",), placementTitleEn: new FormControl("",), + campaignPlacementPeriods: new FormControl("",), }); } else { this.validatingForm = this.formBuilder.group({ @@ -504,6 +518,7 @@ export class CampaignAddFormComponent implements OnInit { placementActive: new FormControl("",), placementTitleIt: new FormControl("",), placementTitleEn: new FormControl("",), + campaignPlacementPeriods: new FormControl("",), }); } } @@ -964,6 +979,14 @@ export class CampaignAddFormComponent implements OnInit { } else { this.campaignCreated.campaignPlacement.title["en"] = ""; } + if(this.validatingForm.get("campaignPlacementPeriods")) { + for (let p of this.getCampaignPlacementPeriods()) { + this.campaignCreated.campaignPlacement.configuration[p] = false; + } + for (let p of this.validatingForm.get("campaignPlacementPeriods").value) { + this.campaignCreated.campaignPlacement.configuration[p] = true; + } + } if(this.validatingForm.get(USE_MULTI_LOCATION).value!==null){ this.campaignCreated.specificData[USE_MULTI_LOCATION] = this.validatingForm.get(USE_MULTI_LOCATION).value; }else{ @@ -1497,6 +1520,11 @@ export class CampaignAddFormComponent implements OnInit { } } + getCampaignPlacementPeriods() { + const vals = ['periodToday', 'periodCurrentWeek', 'periodLastWeek', 'periodCurrentMonth', 'periodGeneral']; + return vals; + } + } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 2eae4cf6..db59fc21 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -361,12 +361,12 @@ "placementTitleItPlaceholder":"Titolo italiano (dafault 'Clasifiche azienda')", "placementTitleEn":"titolo inglese", "placementTitleEnPlaceholder":"Titolo inglese (default 'Company standings')", - "":"", - "":"", - "":"", - "":"", - "":"", - "":"", + "periodToday":"Today", + "periodCurrentWeek":"Current week", + "periodLastWeek":"Last week", + "periodCurrentMonth":"Current month", + "periodGeneral":"General", + "campaignPlacementPeriods":"Periods", "":"", "":"", "":"", diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index b497337e..4fc8c93b 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -365,12 +365,12 @@ "placementTitleItPlaceholder":"Titolo italiano (dafault 'Clasifiche azienda')", "placementTitleEn":"titolo inglese", "placementTitleEnPlaceholder":"Titolo inglese (default 'Company standings')", -"":"", -"":"", -"":"", -"":"", -"":"", -"":"", +"periodToday":"Oggi", +"periodCurrentWeek":"Questa settimana", +"periodLastWeek":"Settimana scorsa", +"periodCurrentMonth":"Questo mese", +"periodGeneral":"Generale", +"campaignPlacementPeriods":"Periodi", "":"", "":"", "":"" From be3ad856e3aae3b015dd185558b91878bceb5e76 Mon Sep 17 00:00:00 2001 From: micnori Date: Tue, 27 Aug 2024 10:54:42 +0200 Subject: [PATCH 4/9] add default period and metrics conf --- .../campaign-add-form.component.html | 28 +++++++++++ .../campaign-add-form.component.ts | 48 +++++++++++++++++++ src/assets/i18n/en.json | 14 ++++-- src/assets/i18n/it.json | 11 +++-- 4 files changed, 93 insertions(+), 8 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 66ef6d21..7d7c3180 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 @@ -102,11 +102,25 @@

{{'addCampaign' | translate}}

+ {{'campaignPlacementMetrics' | translate}} + + {{value |translate}} + + +
+
+ {{'campaignPlacementPeriods' | translate}} {{value |translate}} + + {{'defaultPlacementPeriod' | translate}} + + {{value |translate}} + +
@@ -659,11 +673,25 @@

{{'modifyCampaign' | translate}} - + {{'campaignPlacementMetrics' | translate}} + + {{value |translate}} + + +

+
+ {{'campaignPlacementPeriods' | translate}} {{value |translate}} + + {{'defaultPlacementPeriod' | translate}} + + {{value |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 16cb1256..2b8e93cb 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 @@ -366,6 +366,21 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ campaignPlacementPeriods: periods, }); + const metrics = []; + for(let key of this.getCampaignPlacementMetrics()) { + if(this.campaignUpdated.campaignPlacement.configuration[key] && (this.campaignUpdated.campaignPlacement.configuration[key] == true)) { + metrics.push(key); + } + } + if(!metrics.includes("metricVirtualScore")){ + metrics.push("metricVirtualScore"); + } + this.validatingForm.patchValue({ + campaignPlacementMetrics: metrics, + }); + this.validatingForm.patchValue({ + campaignDefaultPlacementPeriod: this.campaignUpdated.campaignPlacement.configuration["periodDefault"], + }) } else { this.validatingForm.patchValue({ placementActive: false, @@ -379,6 +394,9 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ campaignPlacementPeriods: [], }); + this.validatingForm.patchValue({ + campaignPlacementMetrics: ["metricVirtualScore"], + }); } if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){ this.validatingForm.patchValue({ @@ -483,6 +501,8 @@ export class CampaignAddFormComponent implements OnInit { placementTitleIt: new FormControl("",), placementTitleEn: new FormControl("",), campaignPlacementPeriods: new FormControl("",), + campaignDefaultPlacementPeriod: new FormControl("",), + campaignPlacementMetrics: new FormControl("",), }); } else { this.validatingForm = this.formBuilder.group({ @@ -519,6 +539,8 @@ export class CampaignAddFormComponent implements OnInit { placementTitleIt: new FormControl("",), placementTitleEn: new FormControl("",), campaignPlacementPeriods: new FormControl("",), + campaignDefaultPlacementPeriod: new FormControl("",), + campaignPlacementMetrics: new FormControl("",), }); } } @@ -987,6 +1009,18 @@ export class CampaignAddFormComponent implements OnInit { this.campaignCreated.campaignPlacement.configuration[p] = true; } } + if(this.validatingForm.get("campaignDefaultPlacementPeriod")) { + this.campaignCreated.campaignPlacement.configuration["periodDefault"] = this.validatingForm.get("campaignDefaultPlacementPeriod").value; + } + if(this.validatingForm.get("campaignPlacementMetrics")) { + for (let p of this.getCampaignPlacementMetrics()) { + this.campaignCreated.campaignPlacement.configuration[p] = false; + } + for (let p of this.validatingForm.get("campaignPlacementMetrics").value) { + this.campaignCreated.campaignPlacement.configuration[p] = true; + } + this.campaignCreated.campaignPlacement.configuration["metricVirtualScore"] = true; + } if(this.validatingForm.get(USE_MULTI_LOCATION).value!==null){ this.campaignCreated.specificData[USE_MULTI_LOCATION] = this.validatingForm.get(USE_MULTI_LOCATION).value; }else{ @@ -1525,6 +1559,20 @@ export class CampaignAddFormComponent implements OnInit { return vals; } + getSelectedCampaignPlacementPeriods() { + const values = []; + if(this.validatingForm.get("campaignPlacementPeriods")) { + for (let p of this.validatingForm.get("campaignPlacementPeriods").value) { + values.push(p); + } + } + return values; + } + + getCampaignPlacementMetrics() { + const vals = ['metricCo2', 'metricDistance', 'metricDuration', 'metricTrackNumber', 'metricVirtualScore', 'metricVirtualTrack']; + return vals; + } } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index db59fc21..97641911 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -367,9 +367,13 @@ "periodCurrentMonth":"Current month", "periodGeneral":"General", "campaignPlacementPeriods":"Periods", - "":"", - "":"", - "":"", - "":"" - } + "defaultPlacementPeriod": "Default period", + "campaignPlacementMetrics":"Indicatori", + "metricCo2":"CO2", + "metricTrackNumber":"Num. tracce", + "metricDistance":"Distanza", + "metricDuration":"Durata", + "metricVirtualScore":"Punti virtuali", + "metricVirtualTrack":"Num. viaggi" +} \ No newline at end of file diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 4fc8c93b..dddabadb 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -371,7 +371,12 @@ "periodCurrentMonth":"Questo mese", "periodGeneral":"Generale", "campaignPlacementPeriods":"Periodi", -"":"", -"":"", -"":"" +"defaultPlacementPeriod": "Periodo di default", +"campaignPlacementMetrics":"Indicatori", +"metricCo2":"CO2", +"metricTrackNumber":"Num. tracce", +"metricDistance":"Distanza", +"metricDuration":"Durata", +"metricVirtualScore":"Punti virtuali", +"metricVirtualTrack":"Num. viaggi" } From 0c3bc25760fa787beff3f98e74326b3b9a440680 Mon Sep 17 00:00:00 2001 From: micnori Date: Tue, 27 Aug 2024 15:07:02 +0200 Subject: [PATCH 5/9] add limit bar --- .../campaign-add-form.component.html | 40 +++++++++++++++++++ .../campaign-add-form.component.ts | 29 ++++++++++++++ src/assets/i18n/en.json | 10 ++++- src/assets/i18n/it.json | 10 ++++- 4 files changed, 87 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 7d7c3180..b55a2921 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 @@ -260,6 +260,26 @@

{{'addCampaign' | translate}}

+ + {{"firstLimitBar" | translate}} + + + + + {{value |translate}} + + + + + {{"secondLimitBar" | translate}} + + + + + {{value |translate}} + + +
@@ -835,6 +855,26 @@

{{'modifyCampaign' | translate}} - + + {{"firstLimitBar" | translate}} + + + + + {{value |translate}} + + + + + {{"secondLimitBar" | translate}} + + + + + {{value |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 2b8e93cb..798be43c 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 @@ -347,6 +347,16 @@ export class CampaignAddFormComponent implements OnInit { labelAddModifyCampaign: this.campaignUpdated.specificData[VIRTUAL_SCORE][LABEL], }); } + if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[VIRTUAL_SCORE] && this.campaignUpdated.specificData[VIRTUAL_SCORE]['firstLimitBar']){ + this.validatingForm.patchValue({ + firstLimitBar: this.campaignUpdated.specificData[VIRTUAL_SCORE]['firstLimitBar'], + }); + } + if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[VIRTUAL_SCORE] && this.campaignUpdated.specificData[VIRTUAL_SCORE]['secondLimitBar']){ + this.validatingForm.patchValue({ + secondLimitBar: this.campaignUpdated.specificData[VIRTUAL_SCORE]['secondLimitBar'], + }); + } if(!!this.campaignUpdated.campaignPlacement){ this.validatingForm.patchValue({ placementActive: this.campaignUpdated.campaignPlacement.active, @@ -503,6 +513,8 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + firstLimitBar: new FormControl("",), + secondLimitBar: new FormControl("",) }); } else { this.validatingForm = this.formBuilder.group({ @@ -541,6 +553,8 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + firstLimitBar: new FormControl("",), + secondLimitBar: new FormControl("",) }); } } @@ -986,6 +1000,16 @@ export class CampaignAddFormComponent implements OnInit { }else{ this.campaignCreated.specificData[VIRTUAL_SCORE][MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE] = undefined; } + if(this.validatingForm.get("firstLimitBar")) { + this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = this.validatingForm.get("firstLimitBar").value; + } else { + this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = undefined; + } + if(this.validatingForm.get("secondLimitBar")) { + this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = this.validatingForm.get("secondLimitBar").value; + } else { + this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = undefined; + } if(this.validatingForm.get("placementActive")) { this.campaignCreated.campaignPlacement.active = this.validatingForm.get("placementActive").value; } else { @@ -1574,6 +1598,11 @@ export class CampaignAddFormComponent implements OnInit { return vals; } + getLimits() { + const vals = ['scoreDailyLimit', 'scoreWeeklyLimit', 'scoreMonthlyLimit', 'trackDailyLimit', 'trackWeeklyLimit', 'trackMonthlyLimit']; + return vals; + } + } export class SelectedLimits { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 97641911..234adb8a 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -374,6 +374,14 @@ "metricDistance":"Distanza", "metricDuration":"Durata", "metricVirtualScore":"Punti virtuali", - "metricVirtualTrack":"Num. viaggi" + "metricVirtualTrack":"Num. viaggi", + "firstLimitBar": "Primo limite", + "secondLimitBar": "Secondo limite", + "scoreDailyLimit": "Punti virtuali - limite giornaliero", + "scoreWeeklyLimit": "Punti virtuali - limite settimanale", + "scoreMonthlyLimit": "Punti virtuali - limite mensile", + "trackDailyLimit": "Numero viaggi - limite giornaliero", + "trackWeeklyLimit": "Numero viaggi - limite settimanale", + "trackMonthlyLimit": "Numero viaggi - limite mensile" } \ No newline at end of file diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index dddabadb..da93b7eb 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -378,5 +378,13 @@ "metricDistance":"Distanza", "metricDuration":"Durata", "metricVirtualScore":"Punti virtuali", -"metricVirtualTrack":"Num. viaggi" +"metricVirtualTrack":"Num. viaggi", +"firstLimitBar": "Primo limite", +"secondLimitBar": "Secondo limite", +"scoreDailyLimit": "Punti virtuali - limite giornaliero", +"scoreWeeklyLimit": "Punti virtuali - limite settimanale", +"scoreMonthlyLimit": "Punti virtuali - limite mensile", +"trackDailyLimit": "Numero viaggi - limite giornaliero", +"trackWeeklyLimit": "Numero viaggi - limite settimanale", +"trackMonthlyLimit": "Numero viaggi - limite mensile" } From 2a37789fdf903a167127d0f775e2aa80f6b28851 Mon Sep 17 00:00:00 2001 From: micnori Date: Tue, 27 Aug 2024 17:09:14 +0200 Subject: [PATCH 6/9] add conf means --- .../campaign-add-form.component.html | 22 +++++++++++++++++-- .../campaign-add-form.component.ts | 19 ++++++++++++++++ src/assets/i18n/en.json | 1 + src/assets/i18n/it.json | 1 + 4 files changed, 41 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 b55a2921..f7f4b835 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 @@ -101,12 +101,21 @@

{{'addCampaign' | translate}}

|translate}} - + +
+ {{'campaignPlacementMetrics' | translate}} {{value |translate}} + + {{'campaignPlacementMeans' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + +
@@ -692,12 +701,21 @@

{{'modifyCampaign' | translate}} - |translate}} - +

+
+ {{'campaignPlacementMetrics' | translate}} {{value |translate}} + + {{'campaignPlacementMeans' | translate}} + + {{ transformActiveBoolean(val) + |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 798be43c..e806580f 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 @@ -391,6 +391,15 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ campaignDefaultPlacementPeriod: this.campaignUpdated.campaignPlacement.configuration["periodDefault"], }) + if(!!this.campaignUpdated.campaignPlacement.configuration["meansShow"]){ + this.validatingForm.patchValue({ + campaignPlacementMeans: this.campaignUpdated.campaignPlacement.configuration["meansShow"], + }); + } else { + this.validatingForm.patchValue({ + campaignPlacementMeans: false, + }); + } } else { this.validatingForm.patchValue({ placementActive: false, @@ -407,6 +416,9 @@ export class CampaignAddFormComponent implements OnInit { this.validatingForm.patchValue({ campaignPlacementMetrics: ["metricVirtualScore"], }); + this.validatingForm.patchValue({ + campaignPlacementMeans: false, + }) } if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){ this.validatingForm.patchValue({ @@ -513,6 +525,7 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + campaignPlacementMeans: new FormControl("",), firstLimitBar: new FormControl("",), secondLimitBar: new FormControl("",) }); @@ -553,6 +566,7 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + campaignPlacementMeans: new FormControl("",), firstLimitBar: new FormControl("",), secondLimitBar: new FormControl("",) }); @@ -1015,6 +1029,11 @@ export class CampaignAddFormComponent implements OnInit { } else { this.campaignCreated.campaignPlacement.active = false; } + if(this.validatingForm.get("campaignPlacementMeans")) { + this.campaignCreated.campaignPlacement.configuration['meansShow'] = this.validatingForm.get("campaignPlacementMeans").value; + } else { + this.campaignCreated.campaignPlacement.configuration['meansShow'] = false; + } if(this.validatingForm.get("placementTitleIt")) { this.campaignCreated.campaignPlacement.title["it"] = this.validatingForm.get("placementTitleIt").value; } else { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 234adb8a..ac7e824b 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -369,6 +369,7 @@ "campaignPlacementPeriods":"Periods", "defaultPlacementPeriod": "Default period", "campaignPlacementMetrics":"Indicatori", + "campaignPlacementMeans":"Mostra dettaglio mezzi", "metricCo2":"CO2", "metricTrackNumber":"Num. tracce", "metricDistance":"Distanza", diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index da93b7eb..54ea9942 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -373,6 +373,7 @@ "campaignPlacementPeriods":"Periodi", "defaultPlacementPeriod": "Periodo di default", "campaignPlacementMetrics":"Indicatori", +"campaignPlacementMeans":"Mostra dettaglio mezzi", "metricCo2":"CO2", "metricTrackNumber":"Num. tracce", "metricDistance":"Distanza", From f4f147ec7dfd7fb723f74573871797521f1b9731 Mon Sep 17 00:00:00 2001 From: micnori Date: Thu, 29 Aug 2024 10:03:27 +0200 Subject: [PATCH 7/9] add default metric --- .../campaign-add-form.component.html | 32 +++++++++++++------ .../campaign-add-form.component.ts | 20 +++++++++++- src/assets/i18n/en.json | 1 + src/assets/i18n/it.json | 1 + 4 files changed, 43 insertions(+), 11 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 f7f4b835..3a62b2d3 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 @@ -101,6 +101,13 @@

{{'addCampaign' | translate}}

|translate}}
+ + {{'campaignPlacementMeans' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + +
@@ -110,11 +117,10 @@

{{'addCampaign' | translate}}

- {{'campaignPlacementMeans' | translate}} - - {{ transformActiveBoolean(val) - |translate}} - + {{'defaultPlacementMetric' | translate}} + + {{value |translate}} +
@@ -701,6 +707,13 @@

{{'modifyCampaign' | translate}} - |translate}} + + {{'campaignPlacementMeans' | translate}} + + {{ transformActiveBoolean(val) + |translate}} + +

@@ -710,11 +723,10 @@

{{'modifyCampaign' | translate}} - - {{'campaignPlacementMeans' | translate}} - - {{ transformActiveBoolean(val) - |translate}} - + {{'defaultPlacementMetric' | translate}} + + {{value |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 e806580f..6baf4630 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 @@ -390,7 +390,10 @@ export class CampaignAddFormComponent implements OnInit { }); this.validatingForm.patchValue({ campaignDefaultPlacementPeriod: this.campaignUpdated.campaignPlacement.configuration["periodDefault"], - }) + }); + this.validatingForm.patchValue({ + campaignDefaultPlacementMetric: this.campaignUpdated.campaignPlacement.configuration["metricDefault"], + }); if(!!this.campaignUpdated.campaignPlacement.configuration["meansShow"]){ this.validatingForm.patchValue({ campaignPlacementMeans: this.campaignUpdated.campaignPlacement.configuration["meansShow"], @@ -525,6 +528,7 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + campaignDefaultPlacementMetric: new FormControl("",), campaignPlacementMeans: new FormControl("",), firstLimitBar: new FormControl("",), secondLimitBar: new FormControl("",) @@ -566,6 +570,7 @@ export class CampaignAddFormComponent implements OnInit { campaignPlacementPeriods: new FormControl("",), campaignDefaultPlacementPeriod: new FormControl("",), campaignPlacementMetrics: new FormControl("",), + campaignDefaultPlacementMetric: new FormControl("",), campaignPlacementMeans: new FormControl("",), firstLimitBar: new FormControl("",), secondLimitBar: new FormControl("",) @@ -1064,6 +1069,9 @@ export class CampaignAddFormComponent implements OnInit { } this.campaignCreated.campaignPlacement.configuration["metricVirtualScore"] = true; } + if(this.validatingForm.get("campaignDefaultPlacementMetric")) { + this.campaignCreated.campaignPlacement.configuration["metricDefault"] = this.validatingForm.get("campaignDefaultPlacementMetric").value; + } if(this.validatingForm.get(USE_MULTI_LOCATION).value!==null){ this.campaignCreated.specificData[USE_MULTI_LOCATION] = this.validatingForm.get(USE_MULTI_LOCATION).value; }else{ @@ -1612,6 +1620,16 @@ export class CampaignAddFormComponent implements OnInit { return values; } + getSelectedCampaignPlacementMetrics() { + const values = []; + if(this.validatingForm.get("campaignPlacementMetrics")) { + for (let p of this.validatingForm.get("campaignPlacementMetrics").value) { + values.push(p); + } + } + return values; + } + getCampaignPlacementMetrics() { const vals = ['metricCo2', 'metricDistance', 'metricDuration', 'metricTrackNumber', 'metricVirtualScore', 'metricVirtualTrack']; return vals; diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index ac7e824b..d6da3730 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -369,6 +369,7 @@ "campaignPlacementPeriods":"Periods", "defaultPlacementPeriod": "Default period", "campaignPlacementMetrics":"Indicatori", + "defaultPlacementMetric":"Indicatore di default", "campaignPlacementMeans":"Mostra dettaglio mezzi", "metricCo2":"CO2", "metricTrackNumber":"Num. tracce", diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 54ea9942..f986158c 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -373,6 +373,7 @@ "campaignPlacementPeriods":"Periodi", "defaultPlacementPeriod": "Periodo di default", "campaignPlacementMetrics":"Indicatori", +"defaultPlacementMetric":"Indicatore di default", "campaignPlacementMeans":"Mostra dettaglio mezzi", "metricCo2":"CO2", "metricTrackNumber":"Num. tracce", From beaa9d9487a837fc4426fc17b96575630dc588f8 Mon Sep 17 00:00:00 2001 From: micnori Date: Tue, 10 Sep 2024 09:03:41 +0200 Subject: [PATCH 8/9] fix monthly limit --- src/app/shared/constants/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/constants/constants.ts b/src/app/shared/constants/constants.ts index 739122f9..a983f520 100644 --- a/src/app/shared/constants/constants.ts +++ b/src/app/shared/constants/constants.ts @@ -66,7 +66,7 @@ export const WEEKLY_LIMIT_VIRTUAL_POINTS= "weeklyLimitvirtualPoints"; export const MONTHLY_LIMIT_VIRTUAL_POINTS= "monthlyLimitvirtualPoints"; export const DAILY_LIMIT_TRIPS_NUMBER= "dailyLimitTripsNumber"; export const WEEKLY_LIMIT_TRIPS_NUMBER= "weeklyLimitTripsNumber"; -export const MONTHLY_LIMIT_TRIPS_NUMBER= "weeklyLimitTripsNumber"; +export const MONTHLY_LIMIT_TRIPS_NUMBER= "monthlyLimitTripsNumber"; export const DAILY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE= "scoreDailyLimit"; export const WEEKLY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE= "scoreWeeklyLimit"; export const MONTHLY_LIMIT_VIRTUAL_POINTS_SPEC_LABLE= "scoreMonthlyLimit"; From 6cecb1a58fb5f76671b1582c07d3e3d736d00c20 Mon Sep 17 00:00:00 2001 From: micnori Date: Mon, 16 Sep 2024 09:53:57 +0200 Subject: [PATCH 9/9] fix no limit bar --- .../campaign-add-form.component.html | 4 ++++ .../campaign-add-form/campaign-add-form.component.ts | 12 ++++++++++-- src/assets/i18n/en.json | 3 ++- src/assets/i18n/it.json | 3 ++- 4 files changed, 18 insertions(+), 4 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 3a62b2d3..028c6349 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 @@ -281,6 +281,7 @@

{{'addCampaign' | translate}}

+ {{'noLimitBar' |translate}} {{value |translate}} @@ -291,6 +292,7 @@

{{'addCampaign' | translate}}

+ {{'noLimitBar' |translate}} {{value |translate}} @@ -891,6 +893,7 @@

{{'modifyCampaign' | translate}} - + {{'noLimitBar' |translate}} {{value |translate}} @@ -901,6 +904,7 @@

{{'modifyCampaign' | translate}} - + {{'noLimitBar' |translate}} {{value |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 6baf4630..51846b46 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 @@ -1020,12 +1020,20 @@ export class CampaignAddFormComponent implements OnInit { this.campaignCreated.specificData[VIRTUAL_SCORE][MONTHLY_LIMIT_TRIPS_NUMBER_SPEC_LABLE] = undefined; } if(this.validatingForm.get("firstLimitBar")) { - this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = this.validatingForm.get("firstLimitBar").value; + if((this.validatingForm.get("firstLimitBar").value == "noLimitBar") || (this.validatingForm.get("firstLimitBar").value == "")) { + this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = undefined; + } else { + this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = this.validatingForm.get("firstLimitBar").value; + } } else { this.campaignCreated.specificData[VIRTUAL_SCORE]['firstLimitBar'] = undefined; } if(this.validatingForm.get("secondLimitBar")) { - this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = this.validatingForm.get("secondLimitBar").value; + if((this.validatingForm.get("secondLimitBar").value == "noLimitBar") || (this.validatingForm.get("secondLimitBar").value == "")) { + this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = undefined; + } else { + this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = this.validatingForm.get("secondLimitBar").value; + } } else { this.campaignCreated.specificData[VIRTUAL_SCORE]['secondLimitBar'] = undefined; } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index d6da3730..562ce4f9 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -384,6 +384,7 @@ "scoreMonthlyLimit": "Punti virtuali - limite mensile", "trackDailyLimit": "Numero viaggi - limite giornaliero", "trackWeeklyLimit": "Numero viaggi - limite settimanale", - "trackMonthlyLimit": "Numero viaggi - limite mensile" + "trackMonthlyLimit": "Numero viaggi - limite mensile", + "noLimitBar": "Nessun limite" } \ No newline at end of file diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index f986158c..432fc874 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -388,5 +388,6 @@ "scoreMonthlyLimit": "Punti virtuali - limite mensile", "trackDailyLimit": "Numero viaggi - limite giornaliero", "trackWeeklyLimit": "Numero viaggi - limite settimanale", -"trackMonthlyLimit": "Numero viaggi - limite mensile" +"trackMonthlyLimit": "Numero viaggi - limite mensile", +"noLimitBar": "Nessun limite" }