From 9a959f932600fb39b075b1c6c4c8d7bac3d184f9 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 3 Dec 2019 22:32:07 +0200 Subject: add "completed" panel --- ui/src/app/master-checkbox.component.ts | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ui/src/app/master-checkbox.component.ts (limited to 'ui/src/app/master-checkbox.component.ts') diff --git a/ui/src/app/master-checkbox.component.ts b/ui/src/app/master-checkbox.component.ts new file mode 100644 index 0000000..683ea71 --- /dev/null +++ b/ui/src/app/master-checkbox.component.ts @@ -0,0 +1,53 @@ +import { Component, Input, ViewChild, ElementRef, Output, EventEmitter } from '@angular/core'; + +interface Checkable { + checked: boolean; +} + +@Component({ + selector: 'app-master-checkbox', + template: ` +
+ + +
+` +}) +export class MasterCheckboxComponent { + @Input() id: string; + @Input() list: Map; + @Output() changed = new EventEmitter(); + + @ViewChild('masterCheckbox', {static: false}) masterCheckbox: ElementRef; + selected: boolean; + + clicked() { + this.list.forEach(item => item.checked = this.selected); + this.selectionChanged(); + } + + selectionChanged() { + if (!this.masterCheckbox) + return; + let checked: number = 0; + this.list.forEach(item => { if(item.checked) checked++ }); + this.selected = checked > 0 && checked == this.list.size; + this.masterCheckbox.nativeElement.indeterminate = checked > 0 && checked < this.list.size; + this.changed.emit(checked); + } +} + +@Component({ + selector: 'app-slave-checkbox', + template: ` +
+ + +
+` +}) +export class SlaveCheckboxComponent { + @Input() id: string; + @Input() master: MasterCheckboxComponent; + @Input() checkable: Checkable; +} -- cgit