Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog} from '@angular/material/dialog';
|
||||
|
||||
import { SectionService } from '../section.service';
|
||||
import { Section } from '../../core/section';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { SectionService } from '../section.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-section-detail',
|
||||
templateUrl: './section-detail.component.html',
|
||||
styleUrls: ['./section-detail.component.css']
|
||||
styleUrls: ['./section-detail.component.css'],
|
||||
})
|
||||
export class SectionDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
@ -24,28 +24,27 @@ export class SectionDetailComponent implements OnInit, AfterViewInit {
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: SectionService
|
||||
private ser: SectionService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
name: ''
|
||||
name: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Section }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
this.route.data.subscribe((data: { item: Section }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: Section) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name || ''
|
||||
name: this.item.name || '',
|
||||
});
|
||||
}
|
||||
|
||||
@ -56,35 +55,33 @@ export class SectionDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Section?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Section?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user