Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Incentive } from '../core/voucher';
|
||||
|
||||
import { Incentive } from '../core/incentive';
|
||||
|
||||
export class IncentiveDataSource extends DataSource<Incentive> {
|
||||
constructor(private data: Observable<Incentive[]>) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Voucher } from '../core/voucher';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -11,12 +11,11 @@ import { tap } from 'rxjs/operators';
|
||||
export class IncentiveResolver implements Resolve<Voucher> {
|
||||
constructor(private ser: VoucherService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Voucher> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Voucher> {
|
||||
const id = route.paramMap.get('id');
|
||||
if (id === null) {
|
||||
return this.ser.getOfType('Incentive');
|
||||
} else {
|
||||
return this.ser.get(id, 'Incentive');
|
||||
}
|
||||
return this.ser.get(id, 'Incentive');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { IncentiveResolver } from './incentive-resolver.service';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { IncentiveResolver } from './incentive-resolver.service';
|
||||
import { IncentiveComponent } from './incentive.component';
|
||||
|
||||
const incentiveRoutes: Routes = [
|
||||
|
||||
@@ -2,17 +2,20 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { IncentiveDataSource } from './incentive-datasource';
|
||||
import { Account } from '../core/account';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
import { Incentive, Voucher } from '../core/voucher';
|
||||
import * as moment from 'moment';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { Account } from '../core/account';
|
||||
import { Incentive } from '../core/incentive';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { Voucher } from '../core/voucher';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
import { IncentiveDataSource } from './incentive-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-incentive',
|
||||
templateUrl: './incentive.component.html',
|
||||
@@ -36,7 +39,7 @@ export class IncentiveComponent implements OnInit {
|
||||
private fb: FormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private auth: AuthService,
|
||||
public auth: AuthService,
|
||||
private ser: VoucherService,
|
||||
) {
|
||||
this.createForm();
|
||||
@@ -83,17 +86,14 @@ export class IncentiveComponent implements OnInit {
|
||||
this.loadVoucher(voucher);
|
||||
});
|
||||
}
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
totalPoints() {
|
||||
return this.voucher.incentives
|
||||
.map((item) => {
|
||||
return item.daysWorked * item.points;
|
||||
})
|
||||
.reduce((sum, item) => {
|
||||
return sum + item;
|
||||
});
|
||||
.map((item) => item.daysWorked * item.points)
|
||||
.reduce((sum, item) => sum + item);
|
||||
}
|
||||
|
||||
pointValue() {
|
||||
@@ -105,28 +105,25 @@ export class IncentiveComponent implements OnInit {
|
||||
row.points -= 1;
|
||||
this.form
|
||||
.get('incentives')
|
||||
.get('' + i)
|
||||
.setValue({ points: '' + row.points });
|
||||
.get(`${i}`)
|
||||
.setValue({ points: `${row.points}` });
|
||||
}
|
||||
}
|
||||
|
||||
change(row: Incentive, i: number) {
|
||||
row.points = +this.form
|
||||
.get('incentives')
|
||||
.get('' + i)
|
||||
.get('points').value;
|
||||
row.points = +this.form.get('incentives').get(`${i}`).get('points').value;
|
||||
this.form
|
||||
.get('incentives')
|
||||
.get('' + i)
|
||||
.setValue({ points: '' + row.points });
|
||||
.get(`${i}`)
|
||||
.setValue({ points: `${row.points}` });
|
||||
}
|
||||
|
||||
more(row: Incentive, i: number) {
|
||||
row.points += 1;
|
||||
this.form
|
||||
.get('incentives')
|
||||
.get('' + i)
|
||||
.setValue({ points: '' + row.points });
|
||||
.get(`${i}`)
|
||||
.setValue({ points: `${row.points}` });
|
||||
}
|
||||
|
||||
amount(row) {
|
||||
@@ -136,14 +133,14 @@ export class IncentiveComponent implements OnInit {
|
||||
canSave() {
|
||||
if (!this.voucher.id) {
|
||||
return true;
|
||||
} else if (this.voucher.posted && this.auth.user.perms.indexOf('edit-posted-vouchers') !== -1) {
|
||||
return true;
|
||||
} else {
|
||||
return (
|
||||
this.voucher.user.id === this.auth.user.id ||
|
||||
this.auth.user.perms.indexOf("edit-other-user's-vouchers") !== -1
|
||||
);
|
||||
}
|
||||
if (this.voucher.posted && this.auth.user.perms.indexOf('edit-posted-vouchers') !== -1) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
this.voucher.user.id === this.auth.user.id ||
|
||||
this.auth.user.perms.indexOf("edit-other-user's-vouchers") !== -1
|
||||
);
|
||||
}
|
||||
|
||||
post() {
|
||||
@@ -186,7 +183,7 @@ export class IncentiveComponent implements OnInit {
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.voucher.id).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/incentive'], { replaceUrl: true });
|
||||
},
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -20,14 +25,11 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
|
||||
import { IncentiveRoutingModule } from './incentive-routing.module';
|
||||
import { IncentiveComponent } from './incentive.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
|
||||
Reference in New Issue
Block a user