46063: saved currect state

This commit is contained in:
Lotte Hofstede
2018-01-23 10:21:35 +01:00
parent f381649112
commit 33e04fd324
15 changed files with 210 additions and 126 deletions

View File

@@ -0,0 +1,42 @@
import {
Component, Input
} from '@angular/core';
import { TruncatableService } from './truncatable.service';
@Component({
selector: 'ds-truncatable',
templateUrl: './truncatable.component.html',
styleUrls: ['./truncatable.component.scss']
})
export class TruncatableComponent {
@Input() minLines: number;
@Input() maxLines: number;
@Input() initialExpand = false;
@Input() id: string;
@Input() content;
private lines: number;
public constructor(private service: TruncatableService) {
}
ngOnInit() {
if (this.initialExpand) {
this.service.toggle(this.id);
}
this.setLines();
}
public toggleCollapse() {
this.service.toggle(this.id);
this.setLines();
}
private setLines() {
if (this.service.isCollapsed(this.id)) {
this.lines = this.minLines;
} else {
this.lines = this.maxLines;
}
}
}