OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
import { Title } from '@angular/platform-browser';
import { Injectable } from '@angular/core';
const titlePartsSeparator = ' | ';
@Injectable({ providedIn: 'root' })
export class OpTitleService {
constructor(private titleService:Title) {
}
public get current():string {
return this.titleService.getTitle();
}
public get base():string {
const appTitle = document.querySelector('meta[name=app_title]') as HTMLMetaElement;
return appTitle.content;
}
public get titleParts():string[] {
return this.current.split(titlePartsSeparator);
}
public get appTitle():string {
return this.titleParts[this.titleParts.length - 1];
}
public setFirstPart(value:string) {
if (this.current.includes(this.base) && this.current.includes(titlePartsSeparator)) {
const parts = this.titleParts;
parts[0] = value;
this.titleService.setTitle(parts.join(titlePartsSeparator));
} else {
const newTitle = [value, this.base].join(titlePartsSeparator);
this.titleService.setTitle(newTitle);
}
}
}