</button>
</div>
<div class="modal-body">
- <div class="row">
- <div class="col-lg-3 font-weight-bold" i18n>Name of existing bucket</div>
- <div class="col-lg-5">
- <eg-combobox [entries]="formatBucketEntries()"
- (onChange)="bucketChanged($event)"
- placeholder="Existing Bucket..." i18n-placeholder>
- </eg-combobox>
- </div>
- <div class="col-lg-4">
- <button class="btn btn-info" (click)="addToSelected()" i18n
- [disabled]="!selectedBucket">
- Add To Selected Bucket
- </button>
- </div>
- </div>
- <div class="row mt-3">
- <div class="col-lg-3 font-weight-bold" i18n>Name of new bucket</div>
- <div class="col-lg-5">
- <input type="text" class="form-control"
- placeholder="New Bucket Name..."
- i18n-placeholder
- [(ngModel)]="newBucketName"/>
- </div>
- <div class="col-lg-4">
- <button class="btn btn-info" (click)="addToNew()" i18n
- [disabled]="!newBucketName">
- Add To New Bucket
- </button>
- </div>
- </div>
- <div class="row mt-3">
- <div class="col-lg-3 font-weight-bold" i18n>New bucket description</div>
- <div class="col-lg-5">
- <textarea size="3" type="text" class="form-control"
- placeholder="Optional New Bucket Description..."
- i18n-placeholder
- [(ngModel)]="newBucketDesc">
- </textarea>
- </div>
- </div>
+ <ngb-tabset>
+ <ngb-tab title="Existing bucket" i18n-title>
+ <ng-template ngbTabContent>
+ <div class="row">
+ <div class="col-lg-3 font-weight-bold" i18n>Name of existing bucket</div>
+ <div class="col-lg-5">
+ <eg-combobox [entries]="formatBucketEntries()"
+ (onChange)="bucketChanged($event)"
+ placeholder="Existing Bucket..." i18n-placeholder>
+ </eg-combobox>
+ </div>
+ <div class="col-lg-4">
+ <button class="btn btn-info" (click)="addToSelected()" i18n
+ [disabled]="!selectedBucket">
+ Add To Selected Bucket
+ </button>
+ </div>
+ </div>
+ </ng-template>
+ </ngb-tab>
+ <ngb-tab title="New bucket" i18n-title>
+ <ng-template ngbTabContent>
+ <div class="row mt-3">
+ <div class="col-lg-3 font-weight-bold" i18n>Name of new bucket</div>
+ <div class="col-lg-5">
+ <input type="text" class="form-control"
+ placeholder="New Bucket Name..."
+ i18n-placeholder
+ [(ngModel)]="newBucketName"/>
+ </div>
+ <div class="col-lg-4">
+ <button class="btn btn-info" (click)="addToNew()" i18n
+ [disabled]="!newBucketName">
+ Add To New Bucket
+ </button>
+ </div>
+ </div>
+ <div class="row mt-3">
+ <div class="col-lg-3 font-weight-bold" i18n>New bucket description</div>
+ <div class="col-lg-5">
+ <textarea size="3" type="text" class="form-control"
+ placeholder="Optional New Bucket Description..."
+ i18n-placeholder
+ [(ngModel)]="newBucketDesc">
+ </textarea>
+ </div>
+ </div>
+ </ng-template>
+ </ngb-tab>
+ <ngb-tab title="Shared bucket" i18n-title>
+ <ng-template ngbTabContent>
+ <div class="row">
+ <div class="col-lg-3 font-weight-bold" i18n>ID of shared bucket</div>
+ <div class="col-lg-5">
+ <input type="number" class="form-control"
+ [(ngModel)]="sharedBucketId"/>
+ </div>
+ <div class="col-lg-4">
+ <button class="btn btn-info" (click)="addToShared()" i18n
+ [disabled]="!sharedBucketId">
+ Add To Shared Bucket
+ </button>
+ </div>
+ </div>
+ </ng-template>
+ </ngb-tab>
+ </ngb-tabset>
</div>
</ng-template>
+<eg-confirm-dialog #confirmAddToShared
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Confirm Add to Shared Bucket"
+ dialogBody="Add to shared bucket named '{{sharedBucketName}}'?">
+</eg-confirm-dialog>
-import {Component, OnInit, Input, Renderer2} from '@angular/core';
+import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
+import {throwError} from 'rxjs';
+import {switchMap} from 'rxjs/operators';
import {NetService} from '@eg/core/net.service';
import {IdlService} from '@eg/core/idl.service';
import {EventService} from '@eg/core/event.service';
import {AuthService} from '@eg/core/auth.service';
import {DialogComponent} from '@eg/share/dialog/dialog.component';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
+import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
/**
export class BucketDialogComponent extends DialogComponent implements OnInit {
selectedBucket: number;
+ sharedBucketId: number;
+ sharedBucketName: string;
newBucketName: string;
newBucketDesc: string;
buckets: any[];
bucketFmClass: 'ccb' | 'ccnb' | 'cbreb' | 'cub';
targetField: string;
+ @ViewChild('confirmAddToShared', {static: true}) confirmAddToShared: ConfirmDialogComponent;
+
constructor(
private modal: NgbModal, // required for passing to parent
private renderer: Renderer2,
reset() {
this.selectedBucket = null;
+ this.sharedBucketId = null;
+ this.sharedBucketName = '';
this.newBucketName = '';
this.newBucketDesc = '';
this.addToBucket(this.selectedBucket);
}
+ addToShared() {
+ this.net.request('open-ils.actor',
+ 'open-ils.actor.container.flesh',
+ this.auth.token(), this.bucketClass,
+ this.sharedBucketId)
+ .pipe(switchMap((resp) => {
+ const evt = this.evt.parse(resp);
+ if (evt) {
+ this.toast.danger(evt.toString());
+ return throwError(evt);
+ } else {
+ this.sharedBucketName = resp.name();
+ return this.confirmAddToShared.open();
+ }
+ })).subscribe(() => {
+ this.addToBucket(this.sharedBucketId);
+ });
+ }
+
bucketChanged(entry: ComboboxEntry) {
if (entry) {
this.selectedBucket = entry.id;
+