Skip to content

Commit

Permalink
fix: move attribute select field down to indicator
Browse files Browse the repository at this point in the history
Therefore extracted an SimpleIndicatorComponent wich accepts conditional children (based on indicator-key)

Refs: #42
  • Loading branch information
mcauer committed Oct 25, 2024
1 parent 158c7ce commit 2e882e7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="ui toggle checkbox" [ngClass]="(indicator.checked)? 'checked':''">
<input type="checkbox" name="{{indicator.key}}" id="{{qualityDimension}}-{{indicator.key}}" attr.data-indicator-key="{{indicator.key}}"
[ngModel]="indicator.checked" (change)="this.indicatorToggle.emit({indicator, state: indicator.checked = !indicator.checked })">
<label for="{{indicator.key}}">
<div class="content">
<a class="header">{{indicator.name}}</a>
<div class="description">{{indicator.description}}</div>
<ng-content></ng-content>
</div>
</label>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SimpleIndicatorComponent } from './simple-indicator.component';

describe('SimpleIndicatorComponent', () => {
let component: SimpleIndicatorComponent;
let fixture: ComponentFixture<SimpleIndicatorComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SimpleIndicatorComponent]
})
.compileComponents();

fixture = TestBed.createComponent(SimpleIndicatorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Checkbox, Indicator} from '../../../types/types';
import {ControlContainer, FormsModule, NgForm} from '@angular/forms';
import {NgClass} from '@angular/common';

@Component({
selector: 'app-simple-indicator',
// standalone: true,
// imports: [
// FormsModule,
// NgClass
// ],
templateUrl: './simple-indicator.component.html',
styleUrl: './simple-indicator.component.css',
viewProviders: [{provide: ControlContainer, useExisting: NgForm}],
})
export class SimpleIndicatorComponent {
@Input() indicator!: Checkbox<Indicator>;
@Input() qualityDimension!: string;
@Output() indicatorToggle: EventEmitter<any> = new EventEmitter<{indicator: Indicator, state: boolean}>();
}

0 comments on commit 2e882e7

Please sign in to comment.