import {InvoiceResultsComponent} from './invoice-results.component';
import {PicklistResultsComponent} from './picklist-results.component';
import {PicklistCreateDialogComponent} from './picklist-create-dialog.component';
+import {PicklistCloneDialogComponent} from './picklist-clone-dialog.component';
@NgModule({
declarations: [
PurchaseOrderResultsComponent,
InvoiceResultsComponent,
PicklistResultsComponent,
- PicklistCreateDialogComponent
+ PicklistCreateDialogComponent,
+ PicklistCloneDialogComponent
],
imports: [
StaffCommonModule,
--- /dev/null
+<ng-template #dialogContent>
+ <div class="modal-header bg-info">
+ <h3 class="modal-title" i18n>Clone Selection List: {{leadListName}}</h3>
+ <button type="button" class="close"
+ i18n-aria-label aria-label="Close" (click)="close()">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <h4 i18n>Selection list name:</h4>
+ <input type="text" id="create-picklist-name"
+ class="form-control" [(ngModel)]="selectionListName">
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success"
+ (click)="cloneList()" i18n>Clone</button>
+ <button type="button" class="btn btn-warning"
+ (click)="close()" i18n>Cancel</button>
+ </div>
+</ng-template>
+<eg-alert-dialog #fail i18n-dialogBody
+ dialogBody="Could not create this selection list.">
+</eg-alert-dialog>
--- /dev/null
+import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core';
+import {Observable, from, empty, throwError} from 'rxjs';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
+import {AuthService} from '@eg/core/auth.service';
+import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
+import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
+
+@Component({
+ selector: 'eg-picklist-clone-dialog',
+ templateUrl: './picklist-clone-dialog.component.html'
+})
+
+export class PicklistCloneDialogComponent
+ extends DialogComponent implements OnInit {
+
+ @Input() grid: any;
+ selectionListName: String;
+ leadListName: String;
+ selections: IdlObject[];
+
+ constructor(
+ private idl: IdlService,
+ private net: NetService,
+ private auth: AuthService,
+ private modal: NgbModal
+ ) {
+ super(modal);
+ }
+
+ ngOnInit() {
+ }
+
+ update() {
+ this.leadListName = this.grid.context.getSelectedRows()[0].name();
+ }
+
+ cloneList() {
+ const picklist = this.idl.create('acqpl');
+ picklist.owner(this.auth.user().id())
+ picklist.name(this.selectionListName)
+ this.net.request(
+ 'open-ils.acq',
+ 'open-ils.acq.picklist.clone',
+ this.auth.token(),
+ this.grid.context.getSelectedRows()[0].id(),
+ this.selectionListName
+ ).subscribe(
+ new_id => this.close(new_id),
+ err => throwError(err)
+ );
+ }
+}
+
+
<eg-string #createSelectionListString i18n-text text="Selection List Created">
</eg-string>
+<eg-string #cloneSelectionListString i18n-text text="Selection List Cloned">
+</eg-string>
<ng-template #nameTmpl let-selectionlist="row">
<a href="/eg/acq/picklist/view/{{selectionlist.id()}}"
<eg-picklist-create-dialog #picklistCreateDialog>
</eg-picklist-create-dialog>
+<eg-picklist-clone-dialog #picklistCloneDialog [grid]="picklistResultsGrid">
+</eg-picklist-clone-dialog>
+
<eg-grid #acqSearchPicklistsGrid
persistKey="acq.search.selectionlists"
[stickyHeader]="true"
(onClick)="openCreateDialog()" [disableOnRows]="createNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Clone Selected" i18n-label
- (onClick)="cloneSelected($event)" [disableOnRows]="cloneNotAppropriate">
+ (onClick)="openCloneDialog($event)" [disableOnRows]="cloneNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Merge Selected" i18n-label
- (onClick)="mergeSelected($event)" [disableOnRows]="mergeNotAppropriate">
+ (onClick)="openMergeDialog($event)" [disableOnRows]="mergeNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Delete Selected" i18n-label
- (onClick)="deleteSelected($event)" [disableOnRows]="deleteNotAppropriate">
+ (onClick)="openDeleteConfirmation($event)" [disableOnRows]="deleteNotAppropriate">
</eg-grid-toolbar-action>
<eg-grid-column path="name" [cellTemplate]="nameTmpl"></eg-grid-column>
import {GridDataSource} from '@eg/share/grid/grid';
import {AcqSearchService} from './acq-search.service';
import {PicklistCreateDialogComponent} from './picklist-create-dialog.component';
+import {PicklistCloneDialogComponent} from './picklist-clone-dialog.component';
@Component({
selector: 'eg-picklist-results',
gridSource: GridDataSource;
@ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent;
@ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent;
+ @ViewChild('picklistCloneDialog', { static: true }) picklistCloneDialog: PicklistCloneDialogComponent;
@ViewChild('createSelectionListString', { static: true }) createSelectionListString: StringComponent;
+ @ViewChild('cloneSelectionListString', { static: true }) cloneSelectionListString: StringComponent;
permissions: {[name: string]: boolean};
noSelectedRows: (rows: IdlObject[]) => boolean;
+ oneSelectedRows: (rows: IdlObject[]) => boolean;
createNotAppropriate: (rows: IdlObject[]) => boolean;
cloneNotAppropriate: (rows: IdlObject[]) => boolean;
mergeNotAppropriate: (rows: IdlObject[]) => boolean;
then(perms => this.permissions = perms);
this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0);
+ this.oneSelectedRows = (rows: IdlObject[]) => (rows.length === 1);
this.createNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST);
- this.cloneNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST || this.noSelectedRows(rows));
+ this.cloneNotAppropriate = (rows: IdlObject[]) => (!this.permissions.CREATE_PICKLIST || !this.oneSelectedRows(rows));
this.mergeNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows));
this.deleteNotAppropriate = (rows: IdlObject[]) => (!this.permissions.UPDATE_PICKLIST || this.noSelectedRows(rows));
}
);
}
+ openCloneDialog(rows: IdlObject[]) {
+ this.picklistCloneDialog.open().subscribe(
+ modified => {
+ this.cloneSelectionListString.current().then(msg => this.toast.success(msg));
+ this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh
+ }
+ );
+ this.picklistCloneDialog.update(); // set the dialog title
+ }
}