Fix layout service change header-height variable only in browser. Fix formControlName in helptext forms. Change resources menu item structure.

This commit is contained in:
Konstantinos Triantafyllou 2022-08-02 23:13:12 +03:00
parent a42140bb1c
commit c1e1a3508c
8 changed files with 36 additions and 32 deletions

View File

@ -1,7 +1,7 @@
<div page-content> <div page-content>
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-top uk-margin-bottom info"> <div class="uk-flex uk-flex-middle uk-margin-top uk-margin-bottom info">
<a routerLink="../" [queryParams]=" { 'pageId': pageId }" class="uk-button uk-button-link uk-margin-right"> <a routerLink="../" [queryParams]=" { 'pageId': pageId }" class="uk-button uk-button-link uk-margin-medium-right">
<icon name="west" ratio="2" [flex]="true"></icon> <icon name="west" ratio="2" [flex]="true"></icon>
</a> </a>
<div> <div>
@ -57,7 +57,7 @@
<ckeditor (change)="contentChanged()" <ckeditor (change)="contentChanged()"
[readonly]="false" [readonly]="false"
debounce="500" debounce="500"
formControlName="content" [formControl]="myForm.get('content')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', [config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
removeButtons: 'Save,NewPage,DocProps,Preview,Print,' + removeButtons: 'Save,NewPage,DocProps,Preview,Print,' +
'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' + 'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' +

View File

@ -1,7 +1,7 @@
<div page-content> <div page-content>
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-top info"> <div class="uk-flex uk-flex-middle uk-margin-top info">
<a routerLink="../pages" class="uk-button uk-button-link uk-margin-right"> <a routerLink="../pages" class="uk-button uk-button-link uk-margin-medium-right">
<icon name="west" ratio="2" [flex]="true"></icon> <icon name="west" ratio="2" [flex]="true"></icon>
</a> </a>
<div> <div>

View File

@ -1,7 +1,7 @@
<div page-content> <div page-content>
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-top uk-margin-bottom info"> <div class="uk-flex uk-flex-middle uk-margin-top uk-margin-bottom info">
<a routerLink="../" [queryParams]=" { 'pageId': pageId }" class="uk-button uk-button-link uk-margin-right"> <a routerLink="../" [queryParams]=" { 'pageId': pageId }" class="uk-button uk-button-link uk-margin-medium-right">
<icon name="west" ratio="2" [flex]="true"></icon> <icon name="west" ratio="2" [flex]="true"></icon>
</a> </a>
<div> <div>
@ -61,7 +61,7 @@
<ckeditor (change)="contentChanged()" <ckeditor (change)="contentChanged()"
[readonly]="false" [readonly]="false"
debounce="500" debounce="500"
formControlName="content" [formControl]="myForm.get('content')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', [config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
removeButtons: 'Save,NewPage,DocProps,Preview,Print,' + removeButtons: 'Save,NewPage,DocProps,Preview,Print,' +
'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' + 'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' +

View File

@ -1,7 +1,7 @@
<div page-content> <div page-content>
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-top info"> <div class="uk-flex uk-flex-middle uk-margin-top info">
<a routerLink="../pages" class="uk-button uk-button-link uk-margin-right"> <a routerLink="../pages" class="uk-button uk-button-link uk-margin-medium-right">
<icon name="west" ratio="2" [flex]="true"></icon> <icon name="west" ratio="2" [flex]="true"></icon>
</a> </a>
<div> <div>

View File

@ -3,7 +3,6 @@ import {Session, User} from "../../../login/utils/helper.class";
import {UserManagementService} from "../../../services/user-management.service"; import {UserManagementService} from "../../../services/user-management.service";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import { properties } from 'src/environments/environment';
@Component({ @Component({
selector: 'admin-tabs', selector: 'admin-tabs',

View File

@ -66,11 +66,15 @@ export class LayoutService {
if (data['hasHeader'] !== undefined && if (data['hasHeader'] !== undefined &&
data['hasHeader'] === false) { data['hasHeader'] === false) {
this.setHasHeader(false); this.setHasHeader(false);
if(typeof document !== "undefined") {
document.documentElement.style.setProperty('--header-height', '0'); document.documentElement.style.setProperty('--header-height', '0');
}
} else { } else {
this.setHasHeader(true); this.setHasHeader(true);
if(typeof document !== "undefined") {
document.documentElement.style.setProperty('--header-height', LayoutService.HEADER_HEIGHT); document.documentElement.style.setProperty('--header-height', LayoutService.HEADER_HEIGHT);
} }
}
if (data['hasAdminMenu'] !== undefined && if (data['hasAdminMenu'] !== undefined &&
data['hasAdminMenu'] === true) { data['hasAdminMenu'] === true) {
this.setHasAdminMenu(true); this.setHasAdminMenu(true);

View File

@ -9,7 +9,9 @@ import {ResourcesService} from "../services/resources.service";
@Component({ @Component({
selector: 'indicators-page', selector: 'indicators-page',
template: `<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper>` template: `
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper>
`
}) })
export class IndicatorsComponent implements OnInit, OnDestroy { export class IndicatorsComponent implements OnInit, OnDestroy {
private subscriptions: any[] = []; private subscriptions: any[] = [];
@ -32,8 +34,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy {
let type = this.types.find(type => type.value === params['type']); let type = this.types.find(type => type.value === params['type']);
if(type) { if(type) {
this.getPageContents(type.value); this.getPageContents(type.value);
const description = "Monitor | Indicators " + type.label; const description = "Monitor | Indicators for " + type.label;
const title = "Monitor | Indicators " + type.label; const title = "Monitor | Indicators for " + type.label;
this.metaTags(title, description); this.metaTags(title, description);
} }
} }
@ -60,7 +62,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy {
public getPageContents(type: string) { public getPageContents(type: string) {
this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => { this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => {
if(status[0]) { let index = this.types.findIndex(t => t.value === type);
if(index !== -1 && status[index]) {
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'monitor', '/indicators/' + type, 'monitor').subscribe(contents => { this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'monitor', '/indicators/' + type, 'monitor').subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
})); }));

View File

@ -27,24 +27,23 @@ export class ResourcesService {
} }
private async getResourcesItemsAsync(prefix = '', portal: string = null): Promise<MenuItem[]> { private async getResourcesItemsAsync(prefix = '', portal: string = null): Promise<MenuItem[]> {
let items = []; let items = [
let methodology = ResourcesService.setLink(new MenuItem("methodology", "Methodology", "", "", false, [], new MenuItem("methodology", "Methodology", "", "", false, [],
null, {}, null, null, null, null, '_self'), null, {}, null, null, null, null, '_self'),
prefix + "/methodology", portal); ResourcesService.setLink(new MenuItem("methodology", "Terminology and construction",
methodology.items = [ResourcesService.setLink(new MenuItem("methodology", "Terminology and construction",
"", "", false, [], null, {}, null, null, null, null, '_self'), "", "", false, [], null, {}, null, null, null, null, '_self'),
prefix + "/methodology", portal), prefix + "/methodology", portal),
ResourcesService.setLink(new MenuItem("methodology", "See how it works", ResourcesService.setLink(new MenuItem("methodology", "See how it works",
"", "", false, [], null, {}, null, "how", null, null, '_self'), "", "", false, [], null, {}, null, "how", null, null, '_self'),
prefix + "/methodology", portal)]; prefix + "/methodology", portal)];
items.push(methodology);
let indicators = new MenuItem("indicators-page", "Indicators", let indicators = new MenuItem("indicators-page", "Indicators",
"", "", false, [], null, {}, null, null, null, null, '_self'); "", "", false, [], null, {}, null, null, null, null, '_self');
let indicatorsItems = [];
let promise = new Promise(resolve => { let promise = new Promise(resolve => {
this.isPagesEnabled().subscribe(status => { this.isPagesEnabled().subscribe(status => {
ResourcesService.types.forEach((type, index) => { ResourcesService.types.forEach((type, index) => {
if(status[index]) { if (status[index]) {
indicators.items.push(ResourcesService.setLink( indicatorsItems.push(ResourcesService.setLink(
new MenuItem("indicators-" + type.value, type.label, new MenuItem("indicators-" + type.value, type.label,
"", "", false, [], null, {}, null, null, null, null, '_self'), "", "", false, [], null, {}, null, null, null, null, '_self'),
prefix + "/indicators/" + type.value, portal) prefix + "/indicators/" + type.value, portal)
@ -58,10 +57,9 @@ export class ResourcesService {
}); });
}) })
await promise; await promise;
if(indicators.items.length > 0) { if (indicatorsItems.length > 0) {
indicators.url = indicators.items[0].url;
indicators.route = indicators.items[0].route;
items.push(indicators); items.push(indicators);
indicatorsItems.forEach(item => items.push(item));
} }
return items; return items;
} }
@ -70,7 +68,7 @@ export class ResourcesService {
* @deprecated * @deprecated
* */ * */
setResourcesDeprecated(items: RootMenuItem[], prefix = '', portal: string = null) { setResourcesDeprecated(items: RootMenuItem[], prefix = '', portal: string = null) {
if(this.subscription) { if (this.subscription) {
this.subscription.unsubscribe(); this.subscription.unsubscribe();
} }
let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {}); let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {});
@ -81,7 +79,7 @@ export class ResourcesService {
} }
setResources(items: MenuItem[], prefix = '', portal: string = null) { setResources(items: MenuItem[], prefix = '', portal: string = null) {
if(this.subscription) { if (this.subscription) {
this.subscription.unsubscribe(); this.subscription.unsubscribe();
} }
let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {}); let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {});
@ -98,7 +96,7 @@ export class ResourcesService {
let result = this.routes.map(() => false); let result = this.routes.map(() => false);
pages.forEach(page => { pages.forEach(page => {
let index = this.routes.findIndex(route => route === page.route && page.isEnabled); let index = this.routes.findIndex(route => route === page.route && page.isEnabled);
if(index !== -1) { if (index !== -1) {
result[index] = true; result[index] = true;
} }
}); });
@ -107,8 +105,8 @@ export class ResourcesService {
} }
private static setLink(item: MenuItem, route: string, portal: string = null) { private static setLink(item: MenuItem, route: string, portal: string = null) {
if(portal) { if (portal) {
item.url = portal + route + (item.fragment?'#' + item.fragment:''); item.url = portal + route + (item.fragment ? '#' + item.fragment : '');
} else { } else {
item.route = route; item.route = route;
} }