</ng-container>
<ng-container *ngIf="context.settingsCache['circ.privacy_waiver']">
- <div class="row pt-1 pb-1 mt-1">
- <div class="col-lg-3" i18n>Allow others to use my account</div>
+ <div class="row pt-1 pb-1 mt-1"
+ *ngFor="let waiver of patron.waiver_entries(); let index = index">
<div class="col-lg-3">
- <input type="text" class="form-control" [(ngModel)]="waiverName"/>
+ <span *ngIf="index == 0" i18n>Allow others to use my account</span>
</div>
<div class="col-lg-3">
- <div class="form-inline">
- <input class="form-check-input" type="checkbox"/>
- <label class="form-check-label"
- for="" i18n>Place Holds?</label>
+ <input type="text" class="form-control" [ngModel]="waiver.name()"
+ [disabled]="waiver.isdeleted()"
+ (ngModelChange)="fieldValueChange('waiver_entries', index, 'name', $event)"
+ (change)="afterFieldChange('waiver_entries', index, 'name')"
+ i18n-placeholder placeholder="Enter Name..."/>
+ </div>
+ <div class="col-lg-6 d-flex">
+ <div>
+ <div class="form-inline">
+ <input class="form-check-input" type="checkbox"
+ [disabled]="waiver.isdeleted()"
+ id="waiver-holds-{{waiver.id()}}" [ngModel]="waiver.place_holds() == 't'"
+ (ngModelChange)="fieldValueChange('waiver_entries', index, 'place_holds', $event)"
+ (change)="afterFieldChange('waiver_entries', index, 'place_holds')"/>
+ <label class="form-check-label"
+ for="waiver-holds-{{waiver.id()}}" i18n>Place Holds?</label>
+ </div>
+ <div class="form-inline">
+ <input class="form-check-input" type="checkbox"
+ [disabled]="waiver.isdeleted()"
+ id="waiver-history-{{waiver.id()}}" [ngModel]="waiver.view_history() == 't'"
+ (ngModelChange)="fieldValueChange('waiver_entries', index, 'view_history', $event)"
+ (change)="afterFieldChange('waiver_entries', index, 'view_history')"/>
+ <label class="form-check-label"
+ for="waiver-history-{{waiver.id()}}" i18n>View Borrowing History?</label>
+ </div>
</div>
- <div class="form-inline">
- <input class="form-check-input" type="checkbox"/>
- <label class="form-check-label"
- for="" i18n>View Borrowing History?</label>
+ <div class="ml-3">
+ <div class="form-inline">
+ <input class="form-check-input" type="checkbox"
+ [disabled]="waiver.isdeleted()"
+ id="waiver-pickup-{{waiver.id()}}" [ngModel]="waiver.pickup_holds() == 't'"
+ (ngModelChange)="fieldValueChange('waiver_entries', index, 'pickup_hold', $event)"
+ (change)="afterFieldChange('waiver_entries', index, 'pickup_hold')"/>
+ <label class="form-check-label"
+ for="waiver-pickup-{{waiver.id()}}" i18n>Pick Up Holds?</label>
+ </div>
+ <div class="form-inline">
+ <input class="form-check-input" type="checkbox"
+ [disabled]="waiver.isdeleted()"
+ id="waiver-checkout-{{waiver.id()}}" [ngModel]="waiver.checkout_items() == 't'"
+ (ngModelChange)="fieldValueChange('waiver_entries', index, 'checkout_items', $event)"
+ (change)="afterFieldChange('waiver_entries', index, 'checkout_items')"/>
+ <label class="form-check-label"
+ for="waiver-checkout-{{waiver.id()}}" i18n>Check Out Items?</label>
+ </div>
</div>
- </div>
- <div class="col-lg-3">
- <div class="form-inline">
- <input class="form-check-input" type="checkbox"/>
- <label class="form-check-label"
- for="" i18n>Place Holdck Up Holds?</label>
+ <div class="ml-3">
+ <button class="btn btn-danger material-icon-button"
+ [ngClass]="{'invisible': waiver.isdeleted()}"
+ (click)="removeWaiver(waiver)"
+ i18n-title title="Remove Privacy Waiver">
+ <span class="text-danger material-icons">delete</span>
+ </button>
</div>
- <div class="form-inline">
- <input class="form-check-input" type="checkbox"/>
- <label class="form-check-label"
- for="" i18n>Check Out Items?</label>
+ <div class="ml-2" *ngIf="index == patron.waiver_entries().length - 1">
+ <button class="btn btn-success material-icon-button"
+ (click)="addWaiver()" i18n-title title="Add Privacy Waiver">
+ <span class="text-success material-icons">add</span>
+ </button>
</div>
</div>
</div>
this.userStatCats[map.stat_cat()] = cboxEntry;
});
+
+ if (this.patron.waiver_entries().length === 0) {
+ this.addWaiver();
+ }
}
createNewPatron() {
patron.addresses([addr]);
this.patron = patron;
+ this.addWaiver();
}
-
-
objectFromPath(path: string, index: number): IdlObject {
const base = path ? this.patron[path]() : this.patron;
if (index === null || index === undefined) {
saveUser(): Promise<IdlObject> {
this.modifiedPatron = null;
+ // A dummy waiver is added on load. Remove it if no values were added.
+ this.patron.waiver_entries(
+ this.patron.waiver_entries().filter(e => !e.isnew() || e.name()));
+
return this.net.request(
'open-ils.actor',
'open-ils.actor.patron.update',
&& !this.editProfiles.includes(this.patron.profile())
);
}
+
+ addWaiver() {
+ const waiver = this.idl.create('aupw');
+ waiver.isnew(true);
+ waiver.id(this.autoId--);
+ waiver.usr(this.patronId);
+ this.patron.waiver_entries().push(waiver);
+ }
+
+ removeWaiver(waiver: IdlObject) {
+ if (waiver.isnew()) {
+ this.patron.waiver_entries(
+ this.patron.waiver_entries().filter(w => w.id() !== waiver.id()));
+
+ if (this.patron.waiver_entries().length === 0) {
+ // We need at least one waiver to access action buttons
+ this.addWaiver();
+ }
+ } else {
+ waiver.isdeleted(true);
+ }
+ }
}