[develop]: Add extended method for stakeholders in irish service. Add getChartWidth and number to base component.

This commit is contained in:
Konstantinos Triantafyllou 2024-06-17 10:02:40 +03:00
parent 1b7179207d
commit 00724378a8
7 changed files with 42 additions and 74 deletions

View File

@ -1,5 +1,5 @@
import {Component, OnInit, QueryList, ViewChildren} from "@angular/core";
import {ManageStakeholders} from "../../monitor/entities/stakeholder";
import {ManageStakeholders, StakeholderType} from "../../monitor/entities/stakeholder";
import {Session} from "../../login/utils/helper.class";
import {StakeholderBaseComponent} from "../utils/stakeholder-base.component";
import {StakeholderService} from "../../monitor/services/stakeholder.service";
@ -75,7 +75,7 @@ export class ManageAllComponent extends StakeholderBaseComponent implements OnIn
* Filters
*/
public keyword: string;
public type: string = 'all';
public type: StakeholderType | 'all' = 'all';
public types: Option[] = [{value: 'all', label: 'All'}].concat(this.stakeholderUtils.types);
@ViewChildren(ManageStakeholdersComponent) manageStakeholdersList: QueryList<ManageStakeholdersComponent>;

View File

@ -565,12 +565,9 @@
<div *ngIf="getParameter(i, 'yAxisTitle')" input class="uk-width-1-3@s"
[formInput]="getParameter(i, 'yAxisTitle').get('value')"
placeholder="Y-Axis Title"></div>
<div *ngIf="getParameter(i, 'data_title_0')" input class="uk-width-1-3@s"
[formInput]="getParameter(i, 'data_title_0').get('value')"
placeholder="Data Title"></div>
<div *ngIf="getParameter(i, 'data_title_1')" input class="uk-width-1-3@s"
[formInput]="getParameter(i, 'data_title_1').get('value')"
placeholder="Data Title"></div>
<div *ngFor="let dataTitle of dataTitles(i); let j=index" input class="uk-width-1-3@s"
[formInput]="getParameter(i, dataTitle).get('value')"
[placeholder]="'Data Title ' + (j + 1)"></div>
<div *ngIf="getParameter(i, 'start_year')" input class="uk-width-1-3@s"
[formInput]="getParameter(i, 'start_year').get('value')"
placeholder="Year (From)"></div>

View File

@ -380,26 +380,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
}
}
public getNumberClassBySize(size: IndicatorSize) {
if (size === 'small') {
return 'uk-width-medium@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-4@l uk-width-1-2@m uk-width-1-1';
} else {
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
}
}
public getChartClassBySize(size: IndicatorSize) {
if (size === 'small') {
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-2@l uk-width-1-1';
} else {
return 'uk-width-1-1';
}
}
public addJsonPath(index: number) {
if (index == 0 && this.getJsonPath(index).getRawValue()[index].indexOf(",") != -1) {
//if in the first path there are more than one paths comma separated, split them and autogenerate the forms
@ -487,6 +467,19 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
return this.getParameters(index, type).controls.filter(control => control.value.key === key)[0] as UntypedFormControl;
}
public dataTitles(index: number): string[] {
let formControl: UntypedFormControl;
let i = 0;
let dataTitles: string[] = [];
formControl = this.getParameter(index, 'data_title_' + i);
while(formControl != null) {
dataTitles.push('data_title_' + i);
i++;
formControl = this.getParameter(index, 'data_title_' + i);
}
return dataTitles;
}
private getSecureUrlByStakeHolder(indicatorPath: IndicatorPath) {
return this.sanitizer.bypassSecurityTrustResourceUrl(
this.indicatorUtils.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)));
@ -1283,30 +1276,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
}));
}
migrateFromOldImportJsonFile(charts) {
// first section contains numbers
// second contains charts
let hasNumbers = false;
for (let chart of charts) {
if (chart['type'] == 'number') {
hasNumbers = true;
break;
}
}
let chartsSection = (hasNumbers ? 1 : 0); // no numbers: first sections contains charts
for (let chart of charts) {
if (chart['sectionIndex'] == null) {
chart['sectionIndex'] = chart['type'] == 'chart' ? chartsSection : 0;
}
if (chart.url && chart.jsonPath) {
chart.indicatorPaths = [{url: chart.url, jsonPath: chart.jsonPath}];
} else if(chart.url) {
chart.indicatorPaths = [{url: chart.url}];
}
}
return charts;
}
importIndicatorsAndSave(stakeholder: Stakeholder, charts: any[]) {
let sectionsToSave: Section[] = [];
let countIndicators = 0;
@ -1321,7 +1290,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
}
// name description additionalDescription, height, width, visibility
let duplicates = 0;
charts = this.migrateFromOldImportJsonFile(charts);
for (let chart of charts) {
chart.visibility = this.showVisibility ? chart.visibility : this.stakeholderUtils.defaultValue(this.stakeholderUtils.visibilities);
if (!sectionsToSave[chart['sectionIndex']]) {

View File

@ -2,6 +2,8 @@ import {Directive} from "@angular/core";
import {BaseComponent} from "../../sharedComponents/base/base.component";
import {IndicatorUtils, StakeholderUtils} from "./indicator-utils";
import {ConnectHelper} from "../../connect/connectHelper";
import {IndicatorSize} from "../../monitor/entities/stakeholder";
import {statsToolParser} from "./cache-indicators/cache-indicators";
@Directive()
export abstract class StakeholderBaseComponent extends BaseComponent {
@ -51,4 +53,24 @@ export abstract class StakeholderBaseComponent extends BaseComponent {
export abstract class IndicatorStakeholderBaseComponent extends StakeholderBaseComponent {
indicatorUtils: IndicatorUtils = new IndicatorUtils();
public getNumberClassBySize(size: IndicatorSize): string {
if (size === 'small') {
return 'uk-width-medium';
} else if (size === 'medium') {
return 'uk-width-large';
} else {
return 'uk-width-1-2@m uk-width-1-1';
}
}
public getChartClassBySize(size: IndicatorSize): string {
if (size === 'small') {
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-2@l uk-width-1-1';
} else {
return 'uk-width-1-1';
}
}
}

View File

@ -30,6 +30,7 @@ export class BrowseStakeholderBaseComponent<T> extends StakeholderBaseComponent
parameters = {};
keywordControl: FormControl;
hasPublications: boolean = true;
hasOpenAccess: boolean = true;
/* Services */
protected layoutService: LayoutService;

View File

@ -386,26 +386,6 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
return indicators.filter(indicator => this.hasPermission(indicator.visibility)).length;
}
public getNumberClassBySize(size: IndicatorSize) {
if (size === 'small') {
return 'uk-width-medium@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-4@l uk-width-1-2@m uk-width-1-1';
} else {
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
}
}
public getChartClassBySize(size: IndicatorSize): string {
if (size === 'small') {
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-2@l uk-width-1-1';
} else {
return 'uk-width-1-1';
}
}
public printReport() {
window.print();
}

View File

@ -129,7 +129,7 @@ export class StakeholderService {
}
getStakeholders(url: string, type: string = null, defaultId: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type) ? ('?type=' + type) : '') + ((!type && defaultId) ? ('?defaultId=' + defaultId) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type) ? ('?type=' + type) : (defaultId?'?defaultId=' + defaultId:'')) + ((type && defaultId) ? ('&defaultId=' + defaultId) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholders));
}));
}