Updated to angular 11

Now compiling with strict mode in typescript
Need to error checking now
This commit is contained in:
2020-11-22 10:13:37 +05:30
parent cabd6f2ea1
commit 6567f560ab
187 changed files with 1709 additions and 1184 deletions

View File

@ -1,4 +1,4 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HeaderFooterComponent } from './header-footer.component';
@ -6,11 +6,13 @@ describe('HeaderFooterComponent', () => {
let component: HeaderFooterComponent;
let fixture: ComponentFixture<HeaderFooterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HeaderFooterComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [HeaderFooterComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(HeaderFooterComponent);

View File

@ -15,10 +15,10 @@ import { HeaderFooterService } from './header-footer.service';
styleUrls: ['./header-footer.component.css'],
})
export class HeaderFooterComponent implements OnInit {
@ViewChild('section', { static: true }) sectionElement: ElementRef;
@ViewChild('section', { static: true }) sectionElement?: ElementRef;
form: FormGroup;
list: HeaderFooter[];
id: string;
list: HeaderFooter[] = [];
id = '';
constructor(
private route: ActivatedRoute,
@ -28,30 +28,29 @@ export class HeaderFooterComponent implements OnInit {
private dialog: MatDialog,
private ser: HeaderFooterService,
) {
this.createForm();
// Create form
this.form = this.fb.group({
id: '',
text: '',
});
route.params.pipe(map((p) => p.id)).subscribe((x) => {
this.id = x;
});
}
createForm() {
this.form = this.fb.group({
id: '',
text: '',
});
}
ngOnInit() {
this.route.data.subscribe((data: { list: HeaderFooter[] }) => {
this.route.data.subscribe((value) => {
const data = value as { list: HeaderFooter[] };
this.showItem(data.list);
});
}
showItem(list: HeaderFooter[]) {
this.list = list;
const val = this.list.find((v) => v.id === this.id) as HeaderFooter;
this.form.setValue({
id: this.id,
text: this.list.find((v) => v.id === this.id).text,
text: val.text,
});
}
@ -70,6 +69,7 @@ export class HeaderFooterComponent implements OnInit {
getItem(): HeaderFooter {
const formModel = this.form.value;
const item = this.list.find((v) => v.id === this.id);
if (item === undefined) return new HeaderFooter();
item.text = formModel.text;
return item;
}

View File

@ -1,5 +1,12 @@
export class HeaderFooter {
id: string;
name: string;
text?: string;
text: string;
public constructor(init?: Partial<HeaderFooter>) {
this.id = '';
this.name = '';
this.text = '';
Object.assign(this, init);
}
}