91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
//import {Injectable} from '@angular/core';
|
|
//import {BehaviorSubject, Observable} from 'rxjs';
|
|
//import {HttpClient} from '@angular/common/http';
|
|
//import {tap, map} from 'rxjs/operators';
|
|
//import {attendanceBenefitsProcessList} from './attendance-benefits-process';
|
|
|
|
//const CREATE_ACTION = 'create';
|
|
//const UPDATE_ACTION = 'update';
|
|
//const REMOVE_ACTION = 'destroy';
|
|
|
|
//@Injectable()
|
|
//export class AttendanceBenefitsProcessService extends BehaviorSubject<any[]> {
|
|
// constructor(private http: HttpClient) {
|
|
// super([]);
|
|
// }
|
|
|
|
// data: any[] = [];
|
|
|
|
// public read() {
|
|
// if (this.data.length) {
|
|
// return super.next(this.data);
|
|
// }
|
|
|
|
// this.fetch()
|
|
// .pipe(
|
|
// tap(data => {
|
|
// this.data = data;
|
|
// })
|
|
// )
|
|
// .subscribe(data => {
|
|
// super.next(data);
|
|
// });
|
|
// }
|
|
|
|
// public save(data: any, isNew?: boolean) {
|
|
// const action = isNew ? CREATE_ACTION : UPDATE_ACTION;
|
|
|
|
// this.reset();
|
|
|
|
// this.fetch(action, data)
|
|
// .subscribe(() => this.read(), () => this.read());
|
|
// }
|
|
|
|
// public remove(data: any) {
|
|
// this.reset();
|
|
|
|
// this.fetch(REMOVE_ACTION, data)
|
|
// .subscribe(() => this.read(), () => this.read());
|
|
// }
|
|
|
|
// public resetItem(dataItem: any) {
|
|
// if (!dataItem) {
|
|
// return;
|
|
// }
|
|
|
|
// // find orignal data item
|
|
// const originalDataItem = this.data.find(item => item.id === dataItem.id);
|
|
|
|
// // revert changes
|
|
// Object.assign(originalDataItem, dataItem);
|
|
|
|
// super.next(this.data);
|
|
// }
|
|
|
|
// reset() {
|
|
// this.data = [];
|
|
// }
|
|
|
|
// fetch(action: string = '', data?: any): Observable<any[]> {
|
|
// //return this.http
|
|
// // .jsonp(`https://demos.telerik.com/kendo-ui/service/Products/${action}?${this.serializeModels(data)}`, 'callback')
|
|
// // .pipe(map(res => <any[]>res));
|
|
// //
|
|
// return this.getattendanceBenefitsProcesss();
|
|
// }
|
|
|
|
// serializeModels(data?: any): string {
|
|
// return data ? `&models=${JSON.stringify([data])}` : '';
|
|
// }
|
|
|
|
// getattendanceBenefitsProcesss(): any {
|
|
// const rolesObservable = new Observable(observer => {
|
|
// setTimeout(() => {
|
|
// observer.next(attendanceBenefitsProcessList);
|
|
// }, 1000);
|
|
// });
|
|
|
|
// return rolesObservable;
|
|
// }
|
|
//}
|