Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
micnori committed Aug 28, 2024
2 parents b7a71a0 + 2a37789 commit df7bd53
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,35 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'addCampaign' | translate}}</h1>
|translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
<mat-label>{{'campaignPlacementMetrics' | translate}}</mat-label>
<mat-select id="campaignPlacementMetrics" formControlName="campaignPlacementMetrics" multiple>
<mat-option *ngFor="let value of getCampaignPlacementMetrics()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="input-half-right">
<mat-label>{{'campaignPlacementMeans' | translate}}</mat-label>
<mat-select id="campaignPlacementMeans" formControlName="campaignPlacementMeans">
<mat-option *ngFor="let val of [true,false]" [value]="val">{{ transformActiveBoolean(val)
|translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
<mat-label>{{'campaignPlacementPeriods' | translate}}</mat-label>
<mat-select id="campaignPlacementPeriods" formControlName="campaignPlacementPeriods" multiple>
<mat-option *ngFor="let value of getCampaignPlacementPeriods()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="input-half-right">
<mat-label>{{'defaultPlacementPeriod' | translate}}</mat-label>
<mat-select id="campaignDefaultPlacementPeriod" formControlName="campaignDefaultPlacementPeriod">
<mat-option *ngFor="let value of getSelectedCampaignPlacementPeriods()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
Expand Down Expand Up @@ -246,6 +269,26 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'addCampaign' | translate}}</h1>
<input matInput id="monthlyLimitTripsNumber" formControlName="monthlyLimitTripsNumber" type="text">
</mat-form-field>
</mat-grid-tile>
<mat-grid-tile>
{{"firstLimitBar" | translate}}
</mat-grid-tile>
<mat-grid-tile>
<mat-form-field appearance="fill" class="grid-tile-limit" style="margin-right: 10px">
<mat-select id="firstLimitBar" formControlName="firstLimitBar">
<mat-option *ngFor="let value of getLimits()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</mat-grid-tile>
<mat-grid-tile>
{{"secondLimitBar" | translate}}
</mat-grid-tile>
<mat-grid-tile>
<mat-form-field appearance="fill" class="grid-tile-limit" style="margin-right: 10px">
<mat-select id="secondLimitBar" formControlName="secondLimitBar">
<mat-option *ngFor="let value of getLimits()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</mat-grid-tile>
</mat-grid-list>
</div>
</div>
Expand Down Expand Up @@ -658,12 +701,35 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'modifyCampaign' | translate}} -
|translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
<mat-label>{{'campaignPlacementMetrics' | translate}}</mat-label>
<mat-select id="campaignPlacementMetrics" formControlName="campaignPlacementMetrics" multiple>
<mat-option *ngFor="let value of getCampaignPlacementMetrics()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="input-half-right">
<mat-label>{{'campaignPlacementMeans' | translate}}</mat-label>
<mat-select id="campaignPlacementMeans" formControlName="campaignPlacementMeans">
<mat-option *ngFor="let val of [true,false]" [value]="val">{{ transformActiveBoolean(val)
|translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
<mat-label>{{'campaignPlacementPeriods' | translate}}</mat-label>
<mat-select id="campaignPlacementPeriods" formControlName="campaignPlacementPeriods" multiple>
<mat-option *ngFor="let value of getCampaignPlacementPeriods()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="input-half-right">
<mat-label>{{'defaultPlacementPeriod' | translate}}</mat-label>
<mat-select id="campaignDefaultPlacementPeriod" formControlName="campaignDefaultPlacementPeriod">
<mat-option *ngFor="let value of getSelectedCampaignPlacementPeriods()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
<mat-form-field appearance="fill" class="input-half-left">
Expand Down Expand Up @@ -807,6 +873,26 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'modifyCampaign' | translate}} -
<input matInput id="monthlyLimitTripsNumber" formControlName="monthlyLimitTripsNumber" type="text">
</mat-form-field>
</mat-grid-tile>
<mat-grid-tile>
{{"firstLimitBar" | translate}}
</mat-grid-tile>
<mat-grid-tile>
<mat-form-field appearance="fill" class="grid-tile-limit" style="margin-right: 10px">
<mat-select id="firstLimitBar" formControlName="firstLimitBar">
<mat-option *ngFor="let value of getLimits()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</mat-grid-tile>
<mat-grid-tile>
{{"secondLimitBar" | translate}}
</mat-grid-tile>
<mat-grid-tile>
<mat-form-field appearance="fill" class="grid-tile-limit" style="margin-right: 10px">
<mat-select id="secondLimitBar" formControlName="secondLimitBar">
<mat-option *ngFor="let value of getLimits()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</mat-grid-tile>
</mat-grid-list>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -366,6 +376,30 @@ 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"],
})
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,
Expand All @@ -379,6 +413,12 @@ export class CampaignAddFormComponent implements OnInit {
this.validatingForm.patchValue({
campaignPlacementPeriods: [],
});
this.validatingForm.patchValue({
campaignPlacementMetrics: ["metricVirtualScore"],
});
this.validatingForm.patchValue({
campaignPlacementMeans: false,
})
}
if(!!this.campaignUpdated.specificData && !!this.campaignUpdated.specificData[USE_MULTI_LOCATION]){
this.validatingForm.patchValue({
Expand Down Expand Up @@ -483,6 +523,11 @@ export class CampaignAddFormComponent implements OnInit {
placementTitleIt: new FormControl("",),
placementTitleEn: new FormControl("",),
campaignPlacementPeriods: new FormControl("",),
campaignDefaultPlacementPeriod: new FormControl("",),
campaignPlacementMetrics: new FormControl("",),
campaignPlacementMeans: new FormControl("",),
firstLimitBar: new FormControl("",),
secondLimitBar: new FormControl("",)
});
} else {
this.validatingForm = this.formBuilder.group({
Expand Down Expand Up @@ -519,6 +564,11 @@ export class CampaignAddFormComponent implements OnInit {
placementTitleIt: new FormControl("",),
placementTitleEn: new FormControl("",),
campaignPlacementPeriods: new FormControl("",),
campaignDefaultPlacementPeriod: new FormControl("",),
campaignPlacementMetrics: new FormControl("",),
campaignPlacementMeans: new FormControl("",),
firstLimitBar: new FormControl("",),
secondLimitBar: new FormControl("",)
});
}
}
Expand Down Expand Up @@ -964,11 +1014,26 @@ 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 {
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 {
Expand All @@ -987,6 +1052,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{
Expand Down Expand Up @@ -1525,6 +1602,25 @@ 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;
}

getLimits() {
const vals = ['scoreDailyLimit', 'scoreWeeklyLimit', 'scoreMonthlyLimit', 'trackDailyLimit', 'trackWeeklyLimit', 'trackMonthlyLimit'];
return vals;
}

}

Expand Down
23 changes: 18 additions & 5 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,22 @@
"periodCurrentMonth":"Current month",
"periodGeneral":"General",
"campaignPlacementPeriods":"Periods",
"":"",
"":"",
"":"",
"":""
}
"defaultPlacementPeriod": "Default period",
"campaignPlacementMetrics":"Indicatori",
"campaignPlacementMeans":"Mostra dettaglio mezzi",
"metricCo2":"CO2",
"metricTrackNumber":"Num. tracce",
"metricDistance":"Distanza",
"metricDuration":"Durata",
"metricVirtualScore":"Punti virtuali",
"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"
}

20 changes: 17 additions & 3 deletions src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,21 @@
"periodCurrentMonth":"Questo mese",
"periodGeneral":"Generale",
"campaignPlacementPeriods":"Periodi",
"":"",
"":"",
"":""
"defaultPlacementPeriod": "Periodo di default",
"campaignPlacementMetrics":"Indicatori",
"campaignPlacementMeans":"Mostra dettaglio mezzi",
"metricCo2":"CO2",
"metricTrackNumber":"Num. tracce",
"metricDistance":"Distanza",
"metricDuration":"Durata",
"metricVirtualScore":"Punti virtuali",
"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"
}

0 comments on commit df7bd53

Please sign in to comment.