Strict done!!
This commit is contained in:
1 parent
af343cb7f9
commit
afe746ecdc
142 files changed
+1258
-907
No files matched your search
@@ -219,5 +219,5 @@
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<footer class="footer">
|
||||
<p>Backend: v{{ auth.user.ver }} / Frontend: v{{ version }}</p>
|
||||
<p>Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }}</p>
|
||||
</footer>
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -28,7 +28,7 @@ export class SettingsComponent implements OnInit {
|
||||
rebaseDataForm: FormGroup;
|
||||
|
||||
resetStockForm: FormGroup;
|
||||
product: Product;
|
||||
product: Product = new Product();
|
||||
products: Observable<Product[]>;
|
||||
|
||||
maintenance: any;
|
||||
@@ -75,8 +75,14 @@ export class SettingsComponent implements OnInit {
|
||||
lockNewer: false,
|
||||
newerRolling: false,
|
||||
};
|
||||
this.listenToProductChanges();
|
||||
|
||||
// Listen to Product Changes
|
||||
this.products = (this.resetStockForm.get('product') as FormControl).valueChanges.pipe(
|
||||
startWith(''),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocomplete(x))),
|
||||
);
|
||||
this.maintenance = { enabled: false, user: '' };
|
||||
this.version = environment.version;
|
||||
}
|
||||
@@ -101,16 +107,16 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
listenToLockForm() {
|
||||
this.lockDatesForm.get('lockOlder').valueChanges.subscribe((x) => {
|
||||
(this.lockDatesForm.get('lockOlder') as FormControl).valueChanges.subscribe((x) => {
|
||||
this.lockInformation.lockOlder = x;
|
||||
});
|
||||
this.lockDatesForm.get('lockNewer').valueChanges.subscribe((x) => {
|
||||
(this.lockDatesForm.get('lockNewer') as FormControl).valueChanges.subscribe((x) => {
|
||||
this.lockInformation.lockNewer = x;
|
||||
});
|
||||
this.lockDatesForm.get('olderRolling').valueChanges.subscribe((x) => {
|
||||
(this.lockDatesForm.get('olderRolling') as FormControl).valueChanges.subscribe((x) => {
|
||||
this.lockInformation.olderRolling = x;
|
||||
});
|
||||
this.lockDatesForm.get('newerRolling').valueChanges.subscribe((x) => {
|
||||
(this.lockDatesForm.get('newerRolling') as FormControl).valueChanges.subscribe((x) => {
|
||||
this.lockInformation.newerRolling = x;
|
||||
});
|
||||
}
|
||||
@@ -123,20 +129,20 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
setLockDates() {
|
||||
if (this.lockInformation.lockOlder && this.lockInformation.olderRolling) {
|
||||
this.lockInformation.olderDays = +this.lockDatesForm.get('olderDays').value;
|
||||
this.lockInformation.olderDays = +(this.lockDatesForm.get('olderDays') as FormControl).value;
|
||||
}
|
||||
if (this.lockInformation.lockOlder && !this.lockInformation.olderRolling) {
|
||||
this.lockInformation.olderDate = moment(this.lockDatesForm.get('olderDate').value).format(
|
||||
'DD-MMM-YYYY',
|
||||
);
|
||||
this.lockInformation.olderDate = moment(
|
||||
(this.lockDatesForm.get('olderDate') as FormControl).value,
|
||||
).format('DD-MMM-YYYY');
|
||||
}
|
||||
if (this.lockInformation.lockNewer && this.lockInformation.newerRolling) {
|
||||
this.lockInformation.newerDays = +this.lockDatesForm.get('newerDays').value;
|
||||
this.lockInformation.newerDays = +(this.lockDatesForm.get('newerDays') as FormControl).value;
|
||||
}
|
||||
if (this.lockInformation.lockOlder && !this.lockInformation.newerRolling) {
|
||||
this.lockInformation.newerDate = moment(this.lockDatesForm.get('newerDate').value).format(
|
||||
'DD-MMM-YYYY',
|
||||
);
|
||||
this.lockInformation.newerDate = moment(
|
||||
(this.lockDatesForm.get('newerDate') as FormControl).value,
|
||||
).format('DD-MMM-YYYY');
|
||||
}
|
||||
this.ser.setLockInformation(this.lockInformation).subscribe(
|
||||
(result) => {
|
||||
@@ -150,7 +156,9 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
confirmRebase(): void {
|
||||
const rebaseDate = moment(this.rebaseDataForm.get('date').value).format('DD-MMM-YYYY');
|
||||
const rebaseDate = moment((this.rebaseDataForm.get('date') as FormControl).value).format(
|
||||
'DD-MMM-YYYY',
|
||||
);
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {
|
||||
@@ -178,18 +186,8 @@ export class SettingsComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
listenToProductChanges() {
|
||||
this.products = this.resetStockForm.get('product').valueChanges.pipe(
|
||||
startWith(''),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocomplete(x))),
|
||||
);
|
||||
}
|
||||
|
||||
displayFn(product?: Product): string | undefined {
|
||||
return product ? product.name : undefined;
|
||||
displayFn(product?: Product): string {
|
||||
return product ? product.name : '';
|
||||
}
|
||||
|
||||
selectedProduct(event: MatAutocompleteSelectedEvent): void {
|
||||
@@ -197,9 +195,13 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
confirmResetStock(): void {
|
||||
const resetDate = moment(this.resetStockForm.get('resetDate').value).format('DD-MMM-YYYY');
|
||||
const stockDate = moment(this.resetStockForm.get('stockDate').value).format('DD-MMM-YYYY');
|
||||
const quantity = +this.resetStockForm.get('quantity').value;
|
||||
const resetDate = moment((this.resetStockForm.get('resetDate') as FormControl).value).format(
|
||||
'DD-MMM-YYYY',
|
||||
);
|
||||
const stockDate = moment((this.resetStockForm.get('stockDate') as FormControl).value).format(
|
||||
'DD-MMM-YYYY',
|
||||
);
|
||||
const quantity = +(this.resetStockForm.get('quantity') as FormControl).value;
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {
|
||||
|
||||
@@ -46,8 +46,8 @@ export class SettingsService {
|
||||
quantity: number,
|
||||
): Observable<boolean> {
|
||||
const url = '/api/reset-stock';
|
||||
return this.http
|
||||
.post<any>(`${url}/${product.id}`, { stockDate, resetDate, quantity })
|
||||
return <Observable<boolean>>this.http
|
||||
.post<boolean>(`${url}/${product.id}`, { stockDate, resetDate, quantity })
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'resetStock')));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user