Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sonarlint issues #102

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,32 @@ import { MatIcon } from '@angular/material/icon';
import { MatToolbar } from '@angular/material/toolbar';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [
MatToolbar,
MatIcon,
NgIf,
MatIconButton,
MatSidenavContainer,
MatSidenav,
MatNavList,
MatListItem,
RouterLink,
MatSidenavContent,
RouterOutlet,
],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [
MatToolbar,
MatIcon,
NgIf,
MatIconButton,
MatSidenavContainer,
MatSidenav,
MatNavList,
MatListItem,
RouterLink,
MatSidenavContent,
RouterOutlet,
],
})
export class AppComponent {
user: User | null = null;
siteName = environment.siteName;

constructor(private auth: Auth, private router: Router) {
constructor(
private readonly auth: Auth,
private readonly router: Router,
) {
onAuthStateChanged(this.auth, (user) => {
this.user = user;
});
Expand Down
26 changes: 9 additions & 17 deletions src/app/components/item-selector/item-selector.component.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
import { AsyncPipe, NgClass, NgFor, NgIf } from '@angular/common';
import { Component, EventEmitter, Output } from '@angular/core';
import { MatGridList, MatGridTile } from '@angular/material/grid-list';
import { MatIcon } from '@angular/material/icon';
import { Observable } from 'rxjs';
import { ItemService } from 'src/app/services/item.service';
import { Item } from 'src/models/item.model';
import { MatIcon } from '@angular/material/icon';
import { MatGridList, MatGridTile } from '@angular/material/grid-list';
import { NgIf, NgFor, NgClass, AsyncPipe } from '@angular/common';

@Component({
selector: 'app-item-selector',
templateUrl: './item-selector.component.html',
styleUrls: ['./item-selector.component.scss'],
standalone: true,
imports: [
NgIf,
MatGridList,
NgFor,
MatGridTile,
NgClass,
MatIcon,
AsyncPipe,
],
selector: 'app-item-selector',
templateUrl: './item-selector.component.html',
styleUrls: ['./item-selector.component.scss'],
standalone: true,
imports: [NgIf, MatGridList, NgFor, MatGridTile, NgClass, MatIcon, AsyncPipe],
})
export class ItemSelectorComponent {
columns = Math.floor(window.innerWidth / 170).toString();
items: Observable<Item[]>;

@Output() choose = new EventEmitter<Item>();

constructor(private is: ItemService) {
constructor(private readonly is: ItemService) {
this.items = this.is.list();
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/customer/add-customer/add-customer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { CustomerDialogData } from 'src/models/customer.model';
export class AddCustomerComponent {
constructor(
@Inject(MAT_DIALOG_DATA) public data: CustomerDialogData,
private cs: CustomerService,
private readonly cs: CustomerService,
) {
if (typeof data.customer.id === 'undefined') {
data.customer = {
Expand Down
44 changes: 25 additions & 19 deletions src/app/customer/associate-item/associate-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
import { CdkScrollable } from '@angular/cdk/scrolling';
import { Component } from '@angular/core';
import { MatDialogRef, MatDialogTitle, MatDialogContent, MatDialogActions, MatDialogClose } from '@angular/material/dialog';
import { Item } from 'src/models/item.model';
import { MatIcon } from '@angular/material/icon';
import { MatButton } from '@angular/material/button';
import {
MatDialogActions,
MatDialogClose,
MatDialogContent,
MatDialogRef,
MatDialogTitle,
} from '@angular/material/dialog';
import { MatIcon } from '@angular/material/icon';
import { Item } from 'src/models/item.model';
import { ItemSelectorComponent } from '../../components/item-selector/item-selector.component';
import { CdkScrollable } from '@angular/cdk/scrolling';

@Component({
selector: 'app-associate-item',
templateUrl: './associate-item.component.html',
styleUrls: ['./associate-item.component.scss'],
standalone: true,
imports: [
MatDialogTitle,
CdkScrollable,
MatDialogContent,
ItemSelectorComponent,
MatDialogActions,
MatButton,
MatDialogClose,
MatIcon,
],
selector: 'app-associate-item',
templateUrl: './associate-item.component.html',
styleUrls: ['./associate-item.component.scss'],
standalone: true,
imports: [
MatDialogTitle,
CdkScrollable,
MatDialogContent,
ItemSelectorComponent,
MatDialogActions,
MatButton,
MatDialogClose,
MatIcon,
],
})
export class AssociateItemComponent {
constructor(private ref: MatDialogRef<AssociateItemComponent>) {}
constructor(private readonly ref: MatDialogRef<AssociateItemComponent>) {}

associateItem(item: Item) {
this.ref.close(item);
Expand Down
36 changes: 18 additions & 18 deletions src/app/customer/customer-detail/customer-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { NgFor } from '@angular/common';
import { Component, OnDestroy } from '@angular/core';
import { where } from '@angular/fire/firestore';
import { MatAnchor, MatButton, MatIconButton } from '@angular/material/button';
import {
MatCard,
MatCardActions,
MatCardContent,
MatCardSubtitle,
MatCardTitle,
} from '@angular/material/card';
import { MatDialog } from '@angular/material/dialog';
import { MatIcon } from '@angular/material/icon';
import { MatList, MatListItem } from '@angular/material/list';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { take } from 'rxjs';
Expand All @@ -11,17 +22,6 @@ import { Customer, CustomerDialogData } from 'src/models/customer.model';
import { Item } from 'src/models/item.model';
import { AddCustomerComponent } from '../add-customer/add-customer.component';
import { AssociateItemComponent } from '../associate-item/associate-item.component';
import { NgFor } from '@angular/common';
import { MatList, MatListItem } from '@angular/material/list';
import { MatIcon } from '@angular/material/icon';
import { MatButton, MatIconButton, MatAnchor } from '@angular/material/button';
import {
MatCard,
MatCardTitle,
MatCardSubtitle,
MatCardActions,
MatCardContent,
} from '@angular/material/card';

@Component({
selector: 'app-customer-detail',
Expand Down Expand Up @@ -50,13 +50,13 @@ export class CustomerDetailComponent implements OnDestroy {
private isUpdated = false;

constructor(
private cs: CustomerService,
private dialog: MatDialog,
private is: ItemService,
private route: ActivatedRoute,
private router: Router,
private snack: MatSnackBar,
private title: TitleService,
private readonly cs: CustomerService,
private readonly dialog: MatDialog,
private readonly is: ItemService,
private readonly route: ActivatedRoute,
private readonly router: Router,
private readonly snack: MatSnackBar,
private readonly title: TitleService,
) {
this.cs
.load(this.route.snapshot.paramMap.get('id') ?? '_')
Expand Down
49 changes: 26 additions & 23 deletions src/app/customer/customer-list/customer-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { Component } from '@angular/core';
import { MatFabButton } from '@angular/material/button';
import { MatDialog } from '@angular/material/dialog';
import { MatIcon } from '@angular/material/icon';
import { MatListItem, MatNavList } from '@angular/material/list';
import { MatTooltip } from '@angular/material/tooltip';
import { RouterLink } from '@angular/router';
import { Observable } from 'rxjs';
import { CustomerService } from 'src/app/services/customer.service';
import { Customer, CustomerDialogData } from 'src/models/customer.model';
import { AddCustomerComponent } from '../add-customer/add-customer.component';
import { MatTooltip } from '@angular/material/tooltip';
import { MatFabButton } from '@angular/material/button';
import { MatIcon } from '@angular/material/icon';
import { RouterLink } from '@angular/router';
import { NgFor, NgIf, AsyncPipe } from '@angular/common';
import { MatNavList, MatListItem } from '@angular/material/list';

@Component({
selector: 'app-customer-list',
templateUrl: './customer-list.component.html',
styleUrls: ['./customer-list.component.scss'],
standalone: true,
imports: [
MatNavList,
NgFor,
MatListItem,
RouterLink,
NgIf,
MatIcon,
MatFabButton,
MatTooltip,
AsyncPipe,
],
selector: 'app-customer-list',
templateUrl: './customer-list.component.html',
styleUrls: ['./customer-list.component.scss'],
standalone: true,
imports: [
MatNavList,
NgFor,
MatListItem,
RouterLink,
NgIf,
MatIcon,
MatFabButton,
MatTooltip,
AsyncPipe,
],
})
export class CustomerListComponent {
customers: Observable<Customer[]>;

constructor(private cs: CustomerService, private dialog: MatDialog) {
constructor(
private readonly cs: CustomerService,
private readonly dialog: MatDialog,
) {
this.customers = this.cs.list();
}

Expand All @@ -44,7 +47,7 @@ export class CustomerListComponent {
type: '追加',
customer: {},
},
}
},
)
.afterClosed()
.subscribe((customer) => {
Expand Down
61 changes: 33 additions & 28 deletions src/app/customer/order-sheet/order-sheet.component.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
import { CurrencyPipe, NgFor } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { where } from '@angular/fire/firestore';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatAnchor, MatButton } from '@angular/material/button';
import {
MatCard,
MatCardActions,
MatCardContent,
MatCardTitle,
} from '@angular/material/card';
import { MatIcon } from '@angular/material/icon';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { take } from 'rxjs';
import { CustomerService } from 'src/app/services/customer.service';
import { ItemService } from 'src/app/services/item.service';
import { TitleService } from 'src/app/services/title.service';
import { Customer } from 'src/models/customer.model';
import { Item } from 'src/models/item.model';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { NgFor, CurrencyPipe } from '@angular/common';
import { MatIcon } from '@angular/material/icon';
import { MatAnchor, MatButton } from '@angular/material/button';
import { MatCard, MatCardTitle, MatCardContent, MatCardActions } from '@angular/material/card';

@Component({
selector: 'app-order-sheet',
templateUrl: './order-sheet.component.html',
styleUrls: ['./order-sheet.component.scss'],
standalone: true,
imports: [
MatCard,
MatCardTitle,
MatCardContent,
MatCardActions,
MatAnchor,
RouterLink,
MatIcon,
MatButton,
NgFor,
ReactiveFormsModule,
FormsModule,
CurrencyPipe,
],
selector: 'app-order-sheet',
templateUrl: './order-sheet.component.html',
styleUrls: ['./order-sheet.component.scss'],
standalone: true,
imports: [
MatCard,
MatCardTitle,
MatCardContent,
MatCardActions,
MatAnchor,
RouterLink,
MatIcon,
MatButton,
NgFor,
ReactiveFormsModule,
FormsModule,
CurrencyPipe,
],
})
export class OrderSheetComponent implements OnInit {
customer: Customer | undefined;
Expand All @@ -43,13 +48,13 @@ export class OrderSheetComponent implements OnInit {
isNotReady = true;

constructor(
private route: ActivatedRoute,
private cs: CustomerService,
private is: ItemService,
private title: TitleService
private readonly route: ActivatedRoute,
private readonly cs: CustomerService,
private readonly is: ItemService,
private readonly title: TitleService,
) {
this.cs
.load(this.route.snapshot.paramMap.get('id') || '_')
.load(this.route.snapshot.paramMap.get('id') ?? '_')
.pipe(take(1))
.subscribe((customer) => {
if (!customer) return;
Expand Down
Loading