first time include all file
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-form-field {
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
}
|
||||
td.mat-column-edit, .mat-column-delete {
|
||||
width: 35px;
|
||||
padding-right: 2px;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<div class="edit-content">
|
||||
<h3>Concession Validation</h3>
|
||||
<div *ngIf="isAdmin">
|
||||
<mat-form-field>
|
||||
<mat-label>Choose a from date</mat-label>
|
||||
<input matInput [(ngModel)]="fromDate" (focus)="pickerfrom.open()" [matDatepicker]="pickerfrom">
|
||||
<mat-datepicker-toggle matSuffix [for]="pickerfrom"></mat-datepicker-toggle>
|
||||
<mat-datepicker #pickerfrom></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field >
|
||||
<mat-label>Choose a to date</mat-label>
|
||||
<input matInput [(ngModel)]="toDate" (focus)="pickerto.open()" [matDatepicker]="pickerto">
|
||||
<mat-datepicker-toggle matSuffix [for]="pickerto"></mat-datepicker-toggle>
|
||||
<mat-datepicker #pickerto></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button mat-mini-fab color="primary" aria-label="loading record" (click)="onLoad()" matTooltip="Loading">
|
||||
<mat-icon>bolt</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="addlink">
|
||||
<a [routerLink]='["/home/concessionvalidation", 0]' [queryParams]="{returnUrl:'/home/concessionvalidation'}" (click)="setDate()">
|
||||
<i class="material-icons">add_task</i>
|
||||
Add Concession Validation
|
||||
</a>
|
||||
</div>
|
||||
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
|
||||
<!-- validateDate Column -->
|
||||
<ng-container matColumnDef="validateDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Date </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.validateDate | date: 'dd/MM/yyyy HH:mm'}} </td>
|
||||
</ng-container>
|
||||
<!-- concessionType Column -->
|
||||
<ng-container matColumnDef="concessionType">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Concession Type </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.concessionType}} </td>
|
||||
</ng-container>
|
||||
<!-- concessionCard Column -->
|
||||
<ng-container matColumnDef="concessionCard">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Concession Card</th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.concessionCard}} </td>
|
||||
</ng-container>
|
||||
<!-- concessionHolder Column -->
|
||||
<ng-container matColumnDef="concessionHolder">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Concession Holder</th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.concessionHolder}} </td>
|
||||
</ng-container>
|
||||
<!-- validationPoint Column -->
|
||||
<ng-container matColumnDef="validationPoint">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Validation Point </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.validationPoint}} </td>
|
||||
</ng-container>
|
||||
<!-- concessionExpiry Column -->
|
||||
<ng-container matColumnDef="concessionExpiry">
|
||||
<th mat-header-cell *matHeaderCellDef>Expiry date checked</th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<mat-checkbox [checked] ="element.concessionExpiry" name="concessionExpiry" color="primary" >
|
||||
</mat-checkbox>
|
||||
</td>
|
||||
</ng-container>
|
||||
<div *ngIf="isAdmin">
|
||||
<!-- staffFirstName Column -->
|
||||
<ng-container matColumnDef="staffFirstName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Staff Name</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.staffFirstName}} {{element.staffLastName}} </td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="edit" stickyEnd >
|
||||
<div *ngIf="isAdmin">
|
||||
<th mat-header-cell *matHeaderCellDef>Edit</th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
|
||||
<!--a [routerLink]='["/home/concessionvalidation", element.id]' [queryParams]="{returnUrl:'/home/concessionvalidation'}">
|
||||
<mat-icon>edit</mat-icon>
|
||||
</a-->
|
||||
<button mat-icon-button (click)="showEdit(element)" ><mat-icon>edit</mat-icon></button>
|
||||
</td>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="delete" stickyEnd>
|
||||
<th mat-header-cell *matHeaderCellDef>Delete</th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<a (click)='deleteItem(element.id)'>
|
||||
<mat-icon>delete</mat-icon>
|
||||
</a>
|
||||
</td>
|
||||
</ng-container>
|
||||
</div>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="tr-mouseover"></tr>
|
||||
</table>
|
||||
<mat-paginator [pageSize]="10" [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
|
||||
</div>
|
||||
@@ -0,0 +1,170 @@
|
||||
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy} from '@angular/core';
|
||||
|
||||
import { ConcessionValidation } from '../models';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
/* ngRx */
|
||||
/*
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import * as validationActions from './store/actions/validationpoint.action';
|
||||
import * as validationSelector from './store/selectors/validationpoint.selector';
|
||||
import { appValidationState } from './store/reducers';
|
||||
*/
|
||||
|
||||
import { Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ConcessionValidationService } from './concessionvalidation.service';
|
||||
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Utils } from '../shares';
|
||||
|
||||
@Component({
|
||||
selector: 'concessionvalidation-list',
|
||||
templateUrl: './concessionvalidation.component.html',
|
||||
styleUrls: ['./concessionvalidation.component.css']
|
||||
})
|
||||
export class ConcessionValidationComponent implements OnInit, AfterViewInit, OnDestroy{
|
||||
dataSource: MatTableDataSource<ConcessionValidation>;
|
||||
isAdmin = false;
|
||||
isAllowFilter = true;
|
||||
fromDate = new Date();
|
||||
toDate = new Date();
|
||||
username = '';
|
||||
private subscription :Subscription = new Subscription();
|
||||
displayedColumns: string[] =
|
||||
[
|
||||
'validateDate',
|
||||
'concessionType',
|
||||
'concessionCard',
|
||||
'concessionHolder',
|
||||
'concessionExpiry',
|
||||
'validationPoint',
|
||||
];
|
||||
msg ="[ConcessionValidation component]";
|
||||
@ViewChild(MatSort) sort!: MatSort;
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||
|
||||
/*
|
||||
private store: Store<appValidationState>
|
||||
*/
|
||||
constructor(
|
||||
private concessionValidationService: ConcessionValidationService,
|
||||
private router: Router,
|
||||
|
||||
public dialog: MatDialog,
|
||||
) {
|
||||
this.dataSource = new MatTableDataSource<ConcessionValidation>();
|
||||
this.isAdmin = Utils.getIsAdmin();
|
||||
if (this.isAdmin) {
|
||||
this.displayedColumns =
|
||||
[
|
||||
'validateDate',
|
||||
'concessionType',
|
||||
'concessionCard',
|
||||
'concessionHolder',
|
||||
'concessionExpiry',
|
||||
'validationPoint',
|
||||
'staffFirstName',
|
||||
'edit',
|
||||
'delete'
|
||||
];
|
||||
}
|
||||
}
|
||||
/*
|
||||
applyFilter($event:any) {
|
||||
const filterValue = $event.target.value;
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
*/
|
||||
ngOnInit(): void
|
||||
{
|
||||
const user = Utils.getCurrentUser();
|
||||
console.log(this.msg + "current login user ", user);
|
||||
if (user.username === "")
|
||||
{
|
||||
user.username = "60249360";
|
||||
//this.toastr.warning("you are not login! using my number " + user.username);
|
||||
}
|
||||
this.username = user.username;
|
||||
if (this.isAdmin)
|
||||
this.username = '';
|
||||
const dateRange = this.concessionValidationService.getDate();
|
||||
console.log("the date range for now ", dateRange);
|
||||
if (dateRange.fromDate != '')
|
||||
this.fromDate = dateRange.fromDate;
|
||||
if (dateRange.toDate != '')
|
||||
this.toDate = dateRange.toDate;
|
||||
this.onLoad();
|
||||
/*
|
||||
this.store.dispatch(validationActions.LoadValidationpoints());
|
||||
this.store.pipe(select(validationSelector.getAllValidations)).subscribe(result => this.dataSource.data = result);
|
||||
*/
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.dataSource.sort = this.sort;
|
||||
this.dataSource.paginator = this.paginator;
|
||||
}
|
||||
onLoad() :void {
|
||||
const cDate = this.fromDate;
|
||||
const tDate = this.toDate;
|
||||
|
||||
this.subscription.add(
|
||||
this.concessionValidationService.loadConcessionvalidationByStaffId(this.username, cDate, tDate).subscribe(result => {
|
||||
console.log(this.msg + "onInit load Data by staffId "+ this.username, result);
|
||||
this.dataSource.data = result.data;
|
||||
}, error => console.error(error.message))
|
||||
);
|
||||
}
|
||||
setDate() :void {
|
||||
this.concessionValidationService.setDateRange(this.fromDate, this.toDate);
|
||||
}
|
||||
showEdit(item: ConcessionValidation)
|
||||
{
|
||||
console.log(this.msg + "on row click", item);
|
||||
this.setDate();
|
||||
this.router.navigate(['/home/concessionvalidation/'+item.id], { queryParams: {returnUrl:'/home/concessionvalidation' } });
|
||||
}
|
||||
|
||||
deleteItem(id: number): void {
|
||||
const message ="Are you sure you want to delete this?";
|
||||
const title = " Confirmation";
|
||||
/*
|
||||
MessageBox.show(this.dialog, message, title, '', MessageBoxButton.YesNo,
|
||||
false, MessageBoxStyle.Simple, "450px").subscribe(x => {
|
||||
if (x.result == "yes")
|
||||
{
|
||||
this.concessionValidationService.deleteConcessionvalidation(id)
|
||||
.subscribe(result => {
|
||||
console.log(this.msg + " deleteItem success", result);
|
||||
let data = this.dataSource.data;
|
||||
let index: number = data.findIndex(d => d.id === id);
|
||||
console.log(this.msg + "delete from datasource");
|
||||
data.splice(index, 1)
|
||||
this.dataSource.data = data;
|
||||
},
|
||||
error =>
|
||||
{
|
||||
const message = error || error.message;
|
||||
this.toastr.error(message);
|
||||
console.log("error ", error);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(this.msg + "click on No to delete");
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-form-field {
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
}
|
||||
td.mat-column-edit, .mat-column-delete {
|
||||
width: 35px;
|
||||
padding-right: 2px;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<div class="edit-content">
|
||||
<div class="title">
|
||||
{{getEditText()}}
|
||||
</div>
|
||||
<form [formGroup]="concessionvalidationForm" (ngSubmit)="onSubmit()" fxLayout="column" fxLayoutGap="10px">
|
||||
<div class="flex flex-row">
|
||||
<mat-card >
|
||||
<!-- OLD one
|
||||
<div *ngIf="isAdmin" fxLayout="row" fxLayout.xs="column" fxLayoutGap="7px" fxLayoutGap.sm="0px" >
|
||||
<mat-form-field appearance="outline" [hideRequiredMarker]="true">
|
||||
<mat-label>Choose a date<strong class="app-require">*</strong></mat-label>
|
||||
<input matInput formControlName="validateDate" (focus)="picker.open()" [matDatepicker]="picker">
|
||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
-->
|
||||
<!--Date and time picker
|
||||
try this one now -->
|
||||
|
||||
<div *ngIf="isAdmin" >
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Date Time" formControlName="validateDate">
|
||||
<mat-icon matSuffix matTooltip="click to pick date">today</mat-icon>
|
||||
<!--owl-date-time #dt1></owl-date-time-->
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<!--end-->
|
||||
<div >
|
||||
<mat-form-field appearance="outline" [hideRequiredMarker]="true">
|
||||
<mat-label>Concession Type<strong class="app-require">*</strong></mat-label>
|
||||
<mat-select formControlName="concessionTypeId" required>
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let concessionType of concessionTypes" [value]="concessionType.id">
|
||||
{{concessionType.description}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="f['concessionTypeId'].hasError('required')">Please choose concession Type</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<mat-form-field fxFlex appearance="outline" [hideRequiredMarker]="true">
|
||||
<mat-label>Concession Card<strong class="app-require">*</strong></mat-label>
|
||||
<input matInput formControlName="concessionCard" maxlength="60"
|
||||
name="concessionCard" placeholder="Concession Card" required>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<mat-form-field fxFlex appearance="outline" [hideRequiredMarker]="true" >
|
||||
<mat-label>Concession Holder<strong class="app-require">*</strong></mat-label>
|
||||
<input matInput formControlName="concessionHolder" maxlength="100" name="" placeholder="Concession Holder" required >
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<mat-checkbox formControlName="concessionExpiry" color="primary">Expiry date checked</mat-checkbox>
|
||||
</div>
|
||||
|
||||
<div *ngIf="isAdmin" fxLayout="row" fxLayout.xs="column" fxLayoutGap="7px" fxLayoutGap.sm="0px">
|
||||
<mat-form-field fxFlex appearance="outline" [hideRequiredMarker]="true">
|
||||
<mat-label>Validation Point<strong class="app-require">*</strong></mat-label>
|
||||
<mat-select formControlName="validationPointId" required (selectionChange)="onSelectionChange($event)">
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let validationPoint of validationPoints" [value]="validationPoint.id">
|
||||
{{validationPoint.description}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="f['validationPointId'].hasError('required')">Please choose validation Point</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2 mt-2 justify-end">
|
||||
<button type="submit" mat-raised-button color="primary" [disabled]="isFieldsChange">Submit</button>
|
||||
<button type="button" mat-raised-button color="primary" (click)="goBack()">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
<!--pre>{{ concessionvalidationForm.value|json}}</pre-->
|
||||
</div>
|
||||
@@ -0,0 +1,282 @@
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import {ConcessionValidation, Lookup, ResultModel} from '../models';
|
||||
import { Subject,Subscription } from 'rxjs';
|
||||
import { LookupService} from '../shares';
|
||||
import { ConcessionValidationService } from './concessionvalidation.service';
|
||||
import { Utils } from '../shares';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import moment from 'moment';
|
||||
|
||||
import { ThemePalette } from '@angular/material/core';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'concessionvalidation.edit.component.html',
|
||||
selector: 'concessionvalidation-edit',
|
||||
styleUrls: ['concessionvalidation.edit.component.css']
|
||||
})
|
||||
export class ConcessionValidationEditComponent implements OnInit, OnDestroy {
|
||||
returnUrl="";
|
||||
msg = "[concessionvalidation edit Component] "
|
||||
isChange = true; // disable use false//true for not disable. make sure it true is disable button.
|
||||
subChanged$ = new Subject<boolean>();
|
||||
_id = -1;
|
||||
isAdmin = false;
|
||||
concessionTypes?: Lookup[];
|
||||
validationPoints?: Lookup[];
|
||||
public color: ThemePalette = 'primary';
|
||||
public minDate: moment.Moment|null = null;
|
||||
public maxDate: moment.Moment|null = null;
|
||||
private subscription :Subscription = new Subscription();
|
||||
concessionvalidationForm:FormGroup;
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private lookupService: LookupService,
|
||||
private concessionValidationService: ConcessionValidationService,
|
||||
private router: Router,
|
||||
public dialog: MatDialog,
|
||||
|
||||
private route :ActivatedRoute) {
|
||||
this.concessionvalidationForm = this.formBuilder.group({
|
||||
id: [0], //Validators.required
|
||||
validateDate: [], //Validators.required
|
||||
concessionCard: ['',Validators.required],
|
||||
concessionHolder: ['', Validators.required],
|
||||
concessionExpiry: [false], //Validators.required
|
||||
concessionTypeId: [-1,Validators.min(1)],
|
||||
stafflinkNo: [''], //Validators.required
|
||||
validationPointId: [-1,Validators.min(1)],
|
||||
validationPoint: [''], //Validators.required
|
||||
staffFirstName: [''], //Validators.required
|
||||
staffLastName: [''], //Validators.required
|
||||
staffEmail: [''], //Validators.required
|
||||
active: [false], //Validators.required
|
||||
});
|
||||
/*
|
||||
this.concessionTypes = [];
|
||||
let item:Lookup = {id:1,categoryId:0, description:'Health Care Card'};
|
||||
this.concessionTypes.push(item);
|
||||
item = {id:3,categoryId:1, description:'Gold Veterans Affairs Card'};
|
||||
this.concessionTypes.push(item);
|
||||
item = {id:3,categoryId:1, description:'Pensioner Concession Card'};
|
||||
this.concessionTypes.push(item);
|
||||
*/
|
||||
|
||||
}
|
||||
ngOnInit():void {
|
||||
|
||||
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
|
||||
const id = Number(this.route.snapshot.paramMap.get('id'));
|
||||
|
||||
// now load thing up
|
||||
this._id = id;
|
||||
|
||||
this.isAdmin = Utils.getIsAdmin();
|
||||
|
||||
this.subscription.add(this.lookupService.loadConcessionType().subscribe(x => this.concessionTypes = x.data,
|
||||
error => console.error(error)) );
|
||||
this.subscription.add(this.lookupService.loadValidationPoint().subscribe(x => this.validationPoints = x.data,
|
||||
error => console.error(error)) );
|
||||
this.subscription.add(this.concessionvalidationForm.valueChanges.subscribe(x => this.isChange = false));
|
||||
this.subscription.add(this.subChanged$.subscribe(x => this.isChange = x));
|
||||
const user = Utils.getCurrentUser();
|
||||
|
||||
console.log(this.msg + "current login user ", user);
|
||||
if (user.username === "")
|
||||
{
|
||||
user.username = "60249360";
|
||||
// this.toastr.warning("you are not login! using my number " + user.username);
|
||||
}
|
||||
|
||||
if (this._id < 1)
|
||||
{
|
||||
this.concessionvalidationForm.patchValue({
|
||||
validateDate: new Date(),
|
||||
stafflinkNo: user.username,
|
||||
staffFirstName: user.firstName,
|
||||
staffLastName: user.lastName,
|
||||
staffEmail: user.email,
|
||||
validationPointId: user.validationPointId,
|
||||
active: true});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.subscription.add(
|
||||
this.concessionValidationService.loadConcessionvalidationById(id)
|
||||
.subscribe({
|
||||
next: x=> this.assignValue(x.data),
|
||||
error: e => console.error(e.message)
|
||||
})
|
||||
|
||||
);
|
||||
// console.log(this.msg + " load from db"+id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
get isFieldsChange()
|
||||
{
|
||||
const chan = this.isChange || !this.concessionvalidationForm.valid; // this disable so need true valid = true not
|
||||
const fvalid = this.concessionvalidationForm.valid;
|
||||
// console.log(this.msg + "is fields change is valid: " + fvalid , chan,);
|
||||
return chan;
|
||||
}
|
||||
getEditText(): string {
|
||||
if (this._id > 0)
|
||||
return "Edit Concession Validation";
|
||||
else
|
||||
return "New Concession Validation";
|
||||
}
|
||||
onChangeValidation($event:Event) {
|
||||
//$event.target.value
|
||||
//this.selectedCar = (event.target as HTMLSelectElement).value;
|
||||
var val = ($event.target as HTMLSelectElement).value;
|
||||
// console.log("the log for val " , val);
|
||||
}
|
||||
onSelectionChange($event:MatSelectChange) {
|
||||
const text = $event.source.triggerValue;
|
||||
// console.log("this is selectionchange "+ "'" + text + "'");
|
||||
this.concessionvalidationForm.patchValue({validationPoint: text});
|
||||
}
|
||||
assignValue(concessionvalidation:ConcessionValidation):void {
|
||||
this.concessionvalidationForm.patchValue({
|
||||
id: concessionvalidation.id,
|
||||
validateDate: concessionvalidation.validateDate,
|
||||
concessionCard: concessionvalidation.concessionCard,
|
||||
concessionHolder: concessionvalidation.concessionHolder,
|
||||
concessionExpiry: concessionvalidation.concessionExpiry,
|
||||
concessionTypeId: concessionvalidation.concessionTypeId,
|
||||
stafflinkNo: concessionvalidation.stafflinkNo,
|
||||
staffFirstName: concessionvalidation.staffFirstName,
|
||||
staffLastName: concessionvalidation.staffLastName,
|
||||
staffEmail: concessionvalidation.staffEmail,
|
||||
validationPointId: concessionvalidation.validationPointId,
|
||||
active: concessionvalidation.active,
|
||||
});
|
||||
// disable use false//true for not disable.
|
||||
this.subChanged$.next(true);
|
||||
|
||||
}
|
||||
|
||||
// convenience getter for easy access in form fields
|
||||
get f() { return this.concessionvalidationForm.controls;}
|
||||
|
||||
onSubmit() :void {
|
||||
const OkToSave = this.concessionvalidationForm.valid;
|
||||
if (OkToSave)
|
||||
{
|
||||
const concessionvalidationValue = this.concessionvalidationForm.value;
|
||||
const concessionvalidation:ConcessionValidation = {
|
||||
id: concessionvalidationValue.id,
|
||||
validateDate: moment(concessionvalidationValue.validateDate).toDate(),
|
||||
concessionCard: concessionvalidationValue.concessionCard,
|
||||
concessionHolder: concessionvalidationValue.concessionHolder,
|
||||
concessionExpiry: concessionvalidationValue.concessionExpiry,
|
||||
concessionTypeId: concessionvalidationValue.concessionTypeId,
|
||||
stafflinkNo: concessionvalidationValue.stafflinkNo,
|
||||
staffFirstName: concessionvalidationValue.staffFirstName,
|
||||
staffLastName: concessionvalidationValue.staffLastName,
|
||||
staffEmail: concessionvalidationValue.staffEmail,
|
||||
validationPointId: concessionvalidationValue.validationPointId,
|
||||
active: concessionvalidationValue.active,
|
||||
};
|
||||
// console.log(this.msg + "this is OKTOsave", concessionvalidation);
|
||||
//if edit mode just save it don't check
|
||||
if (concessionvalidation.id > 0) {
|
||||
this.saveConcession(concessionvalidation);
|
||||
}
|
||||
else {
|
||||
//check first only if new
|
||||
this.checkAndSave(concessionvalidation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// console.log(this.msg + "this is NOT OKTOsave");
|
||||
//this.toastr.error("please fill in the required fields");
|
||||
}
|
||||
}
|
||||
|
||||
checkAndSave(concessionvalidation: ConcessionValidation) :void {
|
||||
const currentDate = moment(concessionvalidation.validateDate).format("YYYY-MM-DD");
|
||||
const id = concessionvalidation.id;
|
||||
this.subscription.add(
|
||||
this.concessionValidationService.checkConcessionValidationByStaff(concessionvalidation.stafflinkNo,
|
||||
concessionvalidation.concessionCard, currentDate, id)
|
||||
.subscribe ( x =>
|
||||
{
|
||||
let okTo = true;
|
||||
if (x.data < 0)
|
||||
{
|
||||
const message = "This card was used earlier today. Is it Ok to continue?";
|
||||
const title ="Alert";
|
||||
/*
|
||||
okTo = confirm(message);
|
||||
if (okTo == true)
|
||||
{
|
||||
this.saveConcession(concessionvalidation);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.router.navigate([this.returnUrl]);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
MessageBox.show(this.dialog, message, title,
|
||||
'', MessageBoxButton.YesNo,
|
||||
false, MessageBoxStyle.Simple, "400px").subscribe(x => {
|
||||
if (x.result === "yes")
|
||||
{
|
||||
//console.log(this.msg + "after confirm", x);
|
||||
this.saveConcession(concessionvalidation);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.router.navigate([this.returnUrl]);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveConcession(concessionvalidation);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
saveConcession(concessionvalidation: ConcessionValidation) :void {
|
||||
//console.log(this.msg + " Save Concession validation to server");
|
||||
this.subscription.add(
|
||||
this.concessionValidationService.saveConcessionvalidation(concessionvalidation)
|
||||
.subscribe({
|
||||
next: x => {
|
||||
if (x.statusCode >= 1) {
|
||||
//this.toastr.success("Save is ok");
|
||||
this.router.navigate([this.returnUrl]);
|
||||
}
|
||||
|
||||
//this.toastr.error("Fail to Save " + x.message);
|
||||
}, error: e => {
|
||||
const message = e || e.message;
|
||||
//this.toastr.error(message);
|
||||
console.log("error ", e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
goBack(): void {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ConcessionValidation, ResultModel, ConfigureUrl } from '../models';
|
||||
import moment from 'moment';
|
||||
import { AppSettingService } from '../shares';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConcessionValidationService {
|
||||
private dateRange:any;
|
||||
constructor(private http: HttpClient,
|
||||
private appSetting :AppSettingService
|
||||
) {
|
||||
this.dateRange = {};
|
||||
this.dateRange.fromDate = '';
|
||||
this.dateRange.toDate = '';
|
||||
console.log("constructor concessionValidationService daterange", this.dateRange);
|
||||
}
|
||||
public setDateRange(fromDate:any, toDate:any)
|
||||
{
|
||||
this.dateRange.fromDate = moment(fromDate).toDate();
|
||||
this.dateRange.toDate = moment(toDate).toDate();
|
||||
console.log("concessionValidationService setdaterange", this.dateRange);
|
||||
}
|
||||
public getDate() :any {
|
||||
console.log("concessionValidationService getdaterange", this.dateRange);
|
||||
return this.dateRange;
|
||||
}
|
||||
loadConcessionvalidations(): Observable<ResultModel<ConcessionValidation[]>> {
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl +"/"+ConfigureUrl.concessionValidationUrl;
|
||||
let config = { headers : { 'Content-Type': 'application/json' } };
|
||||
// console.log("the concession", baseUrl);
|
||||
return this.http.get<ResultModel<ConcessionValidation[]>>(baseUrl);
|
||||
}
|
||||
loadConcessionvalidationByStaffId(staffLinkId:string, fromDate:Date, toDate:Date): Observable<ResultModel<ConcessionValidation[]>> {
|
||||
const strDate = moment(fromDate).format("YYYY-MM-DD");
|
||||
const strtoDate = moment(toDate).format("YYYY-MM-DD");
|
||||
const url = this.appSetting.appSetting.baseUrl + "/" +ConfigureUrl.concessionValidationByIdUrl;
|
||||
const params = new HttpParams().set("staffLinkNo", staffLinkId)
|
||||
.set("fromDate", strDate)
|
||||
.set("toDate", strtoDate);
|
||||
const headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
const options = {
|
||||
headers: headers,
|
||||
params: params
|
||||
};
|
||||
console.log("loadConcessionvalidationByStaffId url", url);
|
||||
return this.http.get<ResultModel<ConcessionValidation[]>>(url, options);
|
||||
}
|
||||
loadConcessionvalidationById(id:number): Observable<ResultModel<ConcessionValidation>> {
|
||||
let params = new HttpParams().set("id", ""+id);
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl +"/"+ConfigureUrl.concessionValidationUrl;
|
||||
let headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
let options = {
|
||||
headers: headers,
|
||||
params: params
|
||||
};
|
||||
//return this.http.get<Concessionvalidation>(this.baseUrl + 'api/Concessionvalidation/LoadConcessionvalidationById',options);
|
||||
return this.http.get<ResultModel<ConcessionValidation>>(baseUrl + "/" + id);
|
||||
}
|
||||
checkConcessionValidationByStaff(staffLinkNo:string, concessionCard: string, currentDate:string, id :number): Observable<ResultModel<number>> {
|
||||
let params = new HttpParams().set("staffLinkNo", staffLinkNo)
|
||||
.set("concessionCard", concessionCard)
|
||||
.set("currentDate", currentDate)
|
||||
.set("id", "" +id);
|
||||
|
||||
let headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
let options = {
|
||||
headers: headers,
|
||||
params: params
|
||||
};
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl;
|
||||
const url = baseUrl + "/" + ConfigureUrl.CheckConcessionValidationByStaffUrl;
|
||||
//return this.http.get<Concessionvalidation>(this.baseUrl + 'api/Concessionvalidation/LoadConcessionvalidationById',options);
|
||||
return this.http.get<ResultModel<number>>(url,options);
|
||||
}
|
||||
saveConcessionvalidation(item:ConcessionValidation): Observable<ResultModel<number>> { //insert Concessionvalidation
|
||||
let config = { headers : { 'Content-Type': 'application/json' } };
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl +"/"+ConfigureUrl.concessionValidationUrl;
|
||||
return this.http.post<ResultModel<number>>(baseUrl, item, config);
|
||||
}
|
||||
deleteConcessionvalidation(Id:number): Observable<ResultModel<number>>{
|
||||
let config = { headers : { 'Content-Type': 'application/json' } };
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl +"/"+ConfigureUrl.concessionValidationUrl;
|
||||
return this.http.delete<ResultModel<number>>(baseUrl + "/" + Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './concessionvalidation.component';
|
||||
export * from './concessionvalidation.edit.component';
|
||||
export * from './concessionvalidation.service';
|
||||
|
||||
Reference in New Issue
Block a user