Skip to content

Commit

Permalink
feat(forms): enable access form component
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalshaikh42 committed Mar 17, 2020
1 parent d2e35e8 commit 741afa3
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mat-select
[formControl]="control"
required
class="form-input"
disableRipple="true"
panelClass="form-select-input-panel"
>
<mat-option *ngFor="let option of accessLevels" [value]="option.value">{{
option.name
}}</mat-option>
</mat-select>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { AccessFormComponent } from './access-form.component';

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

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AccessFormComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AccessFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
31 changes: 31 additions & 0 deletions CRBM-Viz/src/app/Shared/Forms/access-form/access-form.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, OnInit, forwardRef } from '@angular/core';
import { ValueSubForm } from '../value-sub-form';
import { accessLevels, AccessLevel } from '../../Enums/access-level';
import { NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';

@Component({
selector: 'app-access-form',
templateUrl: './access-form.component.html',
styleUrls: ['./access-form.component.sass'],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AccessFormComponent),
multi: true,
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => AccessFormComponent),
multi: true,
},
],
})
export class AccessFormComponent extends ValueSubForm implements OnInit {
accessLevels: { value: AccessLevel; name: string }[];
constructor() {
super();
this.accessLevels = accessLevels;
}

ngOnInit(): void {}
}

0 comments on commit 741afa3

Please sign in to comment.