/*-------------------------------------------------------------------------------------------------------------- * Copyright (c) insite-gmbh. All rights reserved. * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------------------------*/ import { Injectable } from '@angular/core'; import { IExpandablePanel, IExpandablePanelCollection } from '../../../commonUi/src/expandablePanel/interfaces/index'; @Injectable() export class ExpandablePanelCollectionService implements IExpandablePanelCollection { private _panels: Array = new Array(); get(panelId: string): IExpandablePanel { return this._panels.find(p => p.id === panelId); } add(panel: IExpandablePanel): void { if (!this.get(panel.id)) { this._panels.push(panel); } } remove(panel: IExpandablePanel): void { let idx = this._panels.findIndex(p => p.id === panel.id) if (idx >= 0) { this._panels.splice(idx, 1); } } }