From 8987ca4fb9a4bdf3c3f9b8c7c56fe3e4e7cb2029 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 1 Apr 2021 18:01:54 -0400 Subject: [PATCH] LP1904036 Messages Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../app/staff/circ/patron/messages.component.html | 34 +++++++ .../app/staff/circ/patron/messages.component.ts | 113 +++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.html new file mode 100644 index 0000000000..bec7338a8f --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.html @@ -0,0 +1,34 @@ + +
+
+

Penalties and Messages

+
+
+ + + + + + + + + + +
+ +
+
+

Archived Penalties / Messages

+
+
+ + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.ts new file mode 100644 index 0000000000..b5f0a91ef7 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/messages.component.ts @@ -0,0 +1,113 @@ +import {Component, ViewChild, OnInit, Input, AfterViewInit} from '@angular/core'; +import {empty} from 'rxjs'; +import {NetService} from '@eg/core/net.service'; +import {OrgService} from '@eg/core/org.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {AuthService} from '@eg/core/auth.service'; +import {ServerStoreService} from '@eg/core/server-store.service'; +import {PatronService} from '@eg/staff/share/patron/patron.service'; +import {PatronContextService} from './patron.service'; +import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {Pager} from '@eg/share/util/pager'; +import {DateUtil} from '@eg/share/util/date'; + +@Component({ + selector: 'eg-patron-messages', + templateUrl: 'messages.component.html' +}) +export class PatronMessagesComponent implements OnInit { + + @Input() patronId: number; + + mainDataSource: GridDataSource = new GridDataSource(); + archiveDataSource: GridDataSource = new GridDataSource(); + + startDateYmd: string; + endDateYmd: string; + + @ViewChild('mainGrid') private mainGrid: GridComponent; + @ViewChild('archiveGrid') private archiveGrid: GridComponent; + + constructor( + private org: OrgService, + private net: NetService, + private pcrud: PcrudService, + private auth: AuthService, + private serverStore: ServerStoreService, + public patronService: PatronService, + public context: PatronContextService + ) {} + + ngOnInit() { + + const orgIds = this.org.fullPath(this.auth.user().ws_ou(), true); + + const start = new Date(); + start.setFullYear(start.getFullYear() - 1); + this.startDateYmd = DateUtil.localYmdFromDate(start); + this.endDateYmd = DateUtil.localYmdFromDate(); // now + + const flesh = { + flesh: 1, + flesh_fields: { + ausp: ['standing_penalty', 'staff'] + }, + order_by: {} + }; + + this.mainDataSource.getRows = (pager: Pager, sort: any[]) => { + + const orderBy: any = {ausp: 'set_date'}; + if (sort.length) { + orderBy.ausp = sort[0].name + ' ' + sort[0].dir; + } + + const query = { + usr: this.patronId, + org_unit: orgIds, + '-or' : [ + {stop_date: null}, + {stop_date: {'>' : 'now'}} + ] + }; + + flesh.order_by = orderBy; + return this.pcrud.search('ausp', query, flesh); + } + + this.archiveDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {ausp: 'set_date'}; + if (sort.length) { + orderBy.ausp = sort[0].name + ' ' + sort[0].dir; + } + + const query = { + usr: this.patronId, + org_unit: orgIds, + stop_date: {'<' : 'now'}, + set_date: {between: this.dateRange()} + }; + + flesh.order_by = orderBy; + + return this.pcrud.search('ausp', query, flesh); + } + } + + dateRange(): string[] { + + let endDate = this.endDateYmd; + const today = DateUtil.localYmdFromDate(); + + if (endDate == today) { endDate = 'now'; } + + return [this.startDateYmd, endDate]; + } + + applyPenalty() { + } +} + + + -- 2.11.0