Skip to content

Commit

Permalink
add default metric
Browse files Browse the repository at this point in the history
  • Loading branch information
micnori committed Aug 29, 2024
1 parent 2a37789 commit f4f147e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'addCampaign' | translate}}</h1>
|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">
Expand All @@ -110,11 +117,10 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'addCampaign' | translate}}</h1>
</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-label>{{'defaultPlacementMetric' | translate}}</mat-label>
<mat-select id="campaignDefaultPlacementMetric" formControlName="campaignDefaultPlacementMetric">
<mat-option *ngFor="let value of getSelectedCampaignPlacementMetrics()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
Expand Down Expand Up @@ -701,6 +707,13 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'modifyCampaign' | translate}} -
|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">
Expand All @@ -710,11 +723,10 @@ <h1 style="width: 100%;margin-bottom: 0px;">{{'modifyCampaign' | translate}} -
</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-label>{{'defaultPlacementMetric' | translate}}</mat-label>
<mat-select id="campaignDefaultPlacementMetric" formControlName="campaignDefaultPlacementMetric">
<mat-option *ngFor="let value of getSelectedCampaignPlacementMetrics()" [value]="value">{{value |translate}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="in-line-forms">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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("",)
Expand Down Expand Up @@ -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("",)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
"campaignPlacementPeriods":"Periods",
"defaultPlacementPeriod": "Default period",
"campaignPlacementMetrics":"Indicatori",
"defaultPlacementMetric":"Indicatore di default",
"campaignPlacementMeans":"Mostra dettaglio mezzi",
"metricCo2":"CO2",
"metricTrackNumber":"Num. tracce",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f4f147e

Please sign in to comment.