Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -5,29 +5,41 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name">
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Tax</mat-label>
|
||||
<mat-select placeholder="Tax" formControlName="tax">
|
||||
<mat-option *ngFor="let t of taxes" [value]="t.id">
|
||||
{{ t.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
|
||||
Delete
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {SaleCategoryDetailComponent} from './sale-category-detail.component';
|
||||
import { SaleCategoryDetailComponent } from './sale-category-detail.component';
|
||||
|
||||
describe('SaleCategoryDetailComponent', () => {
|
||||
let component: SaleCategoryDetailComponent;
|
||||
@ -8,9 +8,8 @@ describe('SaleCategoryDetailComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SaleCategoryDetailComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SaleCategoryDetailComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { SaleCategoryService } from '../sale-category.service';
|
||||
import { SaleCategory } from '../../core/sale-category';
|
||||
import { Tax } from '../../core/tax';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { Tax } from '../../core/tax';
|
||||
import { SaleCategoryService } from '../sale-category.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sale-category-detail',
|
||||
templateUrl: './sale-category-detail.component.html',
|
||||
styleUrls: ['./sale-category-detail.component.css']
|
||||
styleUrls: ['./sale-category-detail.component.css'],
|
||||
})
|
||||
export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
@ -26,7 +26,7 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: SaleCategoryService
|
||||
private ser: SaleCategoryService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -34,23 +34,22 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
tax: ''
|
||||
tax: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: SaleCategory, taxes: Tax[] }) => {
|
||||
this.showItem(data.item);
|
||||
this.taxes = data.taxes;
|
||||
});
|
||||
this.route.data.subscribe((data: { item: SaleCategory; taxes: Tax[] }) => {
|
||||
this.showItem(data.item);
|
||||
this.taxes = data.taxes;
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: SaleCategory) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
tax: this.item.tax.id ? this.item.tax.id : ''
|
||||
tax: this.item.tax.id ? this.item.tax.id : '',
|
||||
});
|
||||
}
|
||||
|
||||
@ -61,35 +60,33 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sale-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sale-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sale-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sale-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Sale Category?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Sale Category?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user