LP 1855781 Circulation Policy Configuration
authorZavier Banks <zbanks@catalyte.io>
Fri, 3 Jan 2020 18:24:36 +0000 (18:24 +0000)
committerZavier Banks <zbanks@catalyte.io>
Fri, 17 Jan 2020 16:59:01 +0000 (16:59 +0000)
I made the necessary changes, so that I am no longer manipulating
the DOM directly. There is also an error message that displays
if the user tries to match a limit set with more than one matchpoint.

Signed-off-by: Zavier Banks <zbanks@catalyte.io>
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.module.ts
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/linked-circ-limit-sets.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/linked-circ-limit-sets.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/routing.module.ts

diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.html
new file mode 100644 (file)
index 0000000..06861fc
--- /dev/null
@@ -0,0 +1,9 @@
+<ng-template #dialogContent>
+    <div class="modal-body">
+        <ng-content>
+        </ng-content>
+        <button type="button" class="btn btn-warning ml-2"
+          (click)="closeEditor()" i18n>Cancel
+        </button>
+    </div>
+</ng-template>
\ No newline at end of file
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint-dialog.component.ts
new file mode 100644 (file)
index 0000000..a26506a
--- /dev/null
@@ -0,0 +1,53 @@
+import {Component, OnInit, Input,
+    Output, EventEmitter} from '@angular/core';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
+import {Observable} from 'rxjs';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+
+@Component({
+    selector: 'eg-circ-matrix-matchpoint-dialog',
+    templateUrl: './circ-matrix-matchpoint-dialog.component.html'
+})
+export class CircMatrixMatchpointDialogComponent extends DialogComponent implements OnInit {
+
+    // Emit the modified object when the save action completes.
+    @Output() recordSaved = new EventEmitter<any>();
+
+    // Emit the original object when the save action is canceled.
+    @Output() recordCanceled = new EventEmitter<any>();
+
+    constructor(
+        private modal: NgbModal // required for passing to parent
+        ) {
+        super(modal);
+      }
+
+    ngOnInit() {
+    }
+
+    open(args?: NgbModalOptions): Observable<any> {
+        if (!args) {
+            args = {};
+        }
+        // ensure we don't hang on to our copy of the record
+        // if the user dismisses the dialog
+        args.beforeDismiss = () => {
+            return true;
+        };
+        return super.open(args);
+    }
+
+    cancel() {
+        this.recordCanceled.emit();
+        this.close();
+    }
+
+    closeEditor() {
+        this.recordCanceled.emit();
+        this.close();
+    }
+
+    save() {
+        this.recordSaved.emit();
+    }
+}
index 925a022..ae4d404 100644 (file)
@@ -5,35 +5,86 @@
 <eg-string #successString i18n-text text="Circulation Policy Update Succeeded"></eg-string>
 <eg-string #createString i18n-text text="Circulation Policy Creation Succeeded"></eg-string>
 
-<div #limitSets>
-  <ng-container >
-      <linked-circ-limit-sets
+<eg-grid #grid idlClass="ccmm"
+  [dataSource]="dataSource"
+  [sortable]="true"
+  (onRowActivate)="editSelected([$event])"
+  [showFields]='"is_renewal,active,org_unit,copy_circ_lib,copy_owning_lib,user_home_ou"'>
+  <eg-grid-toolbar-button 
+    label="New Circ Matrix Matchpoint" i18n-label (onClick)="createNew()">
+  </eg-grid-toolbar-button>
+  <eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)">
+  </eg-grid-toolbar-action>
+</eg-grid>
+
+<eg-circ-matrix-matchpoint-dialog #matchpointDialog
+  (recordCanceled)="clearLinkedCircLimitSets()"
+  (recordError)="clearLinkedCircLimitSets()">
+  <div #limitSets [ngStyle]="{marginBottom:'10px'}">
+    <ng-container>
+      <eg-linked-circ-limit-sets
         #circLimitSets
-        (outputLinkedLimitSet)="setLimitSets($event)" >
-      </linked-circ-limit-sets>
-  </ng-container>
-</div>
+        (outputLinkedLimitSet)="setLimitSets($event)">
+      </eg-linked-circ-limit-sets>
+    </ng-container>
+  </div>
+  <ng-template #active let-idPrefix="idPrefix" let-field="field" let-record="record">
+    <div class="col-lg-9">
+      <input
+        class="form-check-input"
+        type="checkbox"
+        name="{{field.name}}"
+        id="{{idPrefix}}-{{field.name}}"
+        [disabled]="field.readOnly"
+        [ngModel]="record[field.name]()"
+        (ngModelChange)="record[field.name]($event)"/>
+    </div>
+    <div class="row" [ngStyle]="{
+      width:'100%',
+      marginTop:'3.5%',
+      marginBottom:'-4%',
+      marginLeft:'-10%',
+      opacity:'90%',
+      fontSize:'18px',
+      textAlign:'center'}">
+      <div [ngStyle]="{backgroundColor:'black', height:'3px', marginTop:'3%', width:'25%'}"></div>
+      <div [ngStyle]="{width:'40%'}">Circulation Policies</div>
+      <div [ngStyle]="{backgroundColor:'black', height:'3px', marginTop:'3%', width:'25%'}"></div>
+    </div>
+  </ng-template>
 
-<eg-grid #grid idlClass="ccmm"
-    [dataSource]="dataSource"
-    [sortable]="true"
-    (onRowActivate)="editSelected([$event])"
-    [showFields]='"is_renewal,active,org_unit,copy_circ_lib,copy_owning_lib,user_home_ou"'
-    >
-    <eg-grid-toolbar-button 
-      label="New Circ Matrix Matchpoint" i18n-label (onClick)="createNew()">
-    </eg-grid-toolbar-button>
-    <eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)">
-    </eg-grid-toolbar-action>
-  </eg-grid>
+  <ng-template #item_age let-idPrefix="idPrefix" let-field="field" let-record="record">
+    <div class="col-lg-9">
+      <input
+        class="form-control"
+        id="{{idPrefix}}-{{field.name}}" name="{{field.name}}"
+        type="text"
+        placeholder="{{field.label}}..." i18n-placeholder
+        [required]="field.isRequired()"
+        [ngModel]="record[field.name]()"
+        (ngModelChange)="record[field.name]($event)"/>
+    </div>
+    <div class="row" [ngStyle]="{
+      width:'100%',
+      marginTop:'1%',
+      marginLeft:'-10%',
+      marginBottom:'-3.5%',
+      opacity:'90%',
+      fontSize:'18px',
+      textAlign:'center'}">
+      <div [ngStyle]="{backgroundColor:'black', height:'3px', marginTop:'2.5%', width:'25%'}"></div>
+      <div [ngStyle]="{width:'40%'}">Circulation Policy Effects</div>
+      <div [ngStyle]="{backgroundColor:'black', height:'3px', marginTop:'2.5%', width:'25%'}"></div>
+    </div>
+  </ng-template>
 
-  
-<eg-fm-record-editor #editDialog
-    idlClass="ccmm" 
-    [preloadLinkedValues]="true" 
+  <eg-fm-record-editor #editDialog
+    idlClass="ccmm"
+    [preloadLinkedValues]="true"
     readonlyFields="name"
-    (recordSaved)="configureLimitSets($event); clearLinkedCircLimitSets()"
-    (recordCanceled)="clearLinkedCircLimitSets()"
-    (recordError)="clearLinkedCircLimitSets()"
-    >
-</eg-fm-record-editor>
\ No newline at end of file
+    displayMode="inline"
+    fieldOrder="id,active,grp,org_unit,copy_circ_lib,copy_owning_lib,user_home_ou,is_renewal,juvenile_flag,circ_modifier,copy_location,marc_type,marc_form,marc_bib_level,marc_vr_format,ref_flag,usr_age_lower_bound,usr_age_upper_bound,item_age,circulate,duration_rule,renewals,hard_due_date,recurring_fine_rule,grace_period,max_fine_rule,available_copy_hold_ratio,total_copy_hold_ratio,script_test,description"
+    (recordSaved)="configureLimitSets($event); clearLinkedCircLimitSets(); closeDialog()"
+    [fieldOptions]="{active:{customTemplate:{template:active}}, item_age:{customTemplate:{template:item_age}}}">
+  </eg-fm-record-editor>
+</eg-circ-matrix-matchpoint-dialog>
\ No newline at end of file
index 3c6b060..535aa0a 100644 (file)
@@ -1,32 +1,37 @@
 import {Pager} from '@eg/share/util/pager';
-import {Component, OnInit, Input, ViewChild, ElementRef} from '@angular/core';
+import {Component, OnInit, AfterViewInit, Input, ViewChild, ElementRef} from '@angular/core';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
 import {IdlObject} from '@eg/core/idl.service';
 import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
 import {LinkedCircLimitSetsComponent} from './linked-circ-limit-sets.component';
+import {CircMatrixMatchpointDialogComponent} from './circ-matrix-matchpoint-dialog.component';
 import {StringComponent} from '@eg/share/string/string.component';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {ToastService} from '@eg/share/toast/toast.service';
 
-@Component({
+  @Component({
     templateUrl: './circ-matrix-matchpoint.component.html'
 })
-
 export class CircMatrixMatchpointComponent implements OnInit {
     recId: number;
     gridDataSource: GridDataSource;
     initDone = false;
     dataSource: GridDataSource = new GridDataSource();
     showLinkLimitSets = false;
-    usedSetLimitList = [];
+    usedSetLimitList = {};
     linkedLimitSets = [];
     limitSetNames = {};
+    dividerStyle = {
+        width: '30%',
+        marginTop: '25px',
+        marginLeft: '73%'
+    };
 
-    
     @ViewChild('limitSets', { static: false }) limitSets: ElementRef;
     @ViewChild('circLimitSets', { static: true }) limitSetsComponent: LinkedCircLimitSetsComponent;
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
+    @ViewChild('matchpointDialog', { static: true }) matchpointDialog: CircMatrixMatchpointDialogComponent;
     @ViewChild('grid', { static: true }) grid: GridComponent;
     @ViewChild('successString', { static: true }) successString: StringComponent;
     @ViewChild('createString', { static: false }) createString: StringComponent;
@@ -39,7 +44,6 @@ export class CircMatrixMatchpointComponent implements OnInit {
 
     @Input() dialogSize: 'sm' | 'lg' = 'lg';
 
-    
     constructor(
         private pcrud: PcrudService,
         private toast: ToastService
@@ -65,23 +69,37 @@ export class CircMatrixMatchpointComponent implements OnInit {
                 order_by: orderBy
             };
             return this.pcrud.retrieveAll('ccmm', searchOps, {fleshSelectors: true});
-        }
+        };
     }
 
-
     clearLinkedCircLimitSets() {
-        this.limitSetsComponent.usedSetLimitList = [];
+        this.limitSetsComponent.usedSetLimitList = {};
         this.limitSetsComponent.linkedSetList = [];
         this.linkedLimitSets = [];
     }
 
+    closeDialog() {
+        this.matchpointDialog.closeEditor();
+        this.grid.reload();
+    }
+
+    editSelected(fields: IdlObject[]) {
+        // Edit each IDL thing one at a time
+        const editOneThing = (field: IdlObject) => {
+            if (!field) { return; }
+            this.showEditDialog(field).then(
+                () => editOneThing(fields.shift()));
+        };
+        editOneThing(fields.shift());
+    }
+
     showEditDialog(field: IdlObject): Promise<any> {
         this.limitSetsComponent.showLinkLimitSets = true;
         this.getLimitSets(field.id());
         this.editDialog.mode = 'update';
         this.editDialog.recordId = field['id']();
         return new Promise((resolve, reject) => {
-            this.editDialog.open({size: this.dialogSize}).subscribe(
+            this.matchpointDialog.open({size: this.dialogSize}).subscribe(
                 result => {
                     this.successString.current()
                         .then(str => this.toast.success(str));
@@ -94,30 +112,19 @@ export class CircMatrixMatchpointComponent implements OnInit {
                     reject(error);
                 }
             );
-            const modalBody = document.getElementsByClassName("modal-body");
-            modalBody[modalBody.length-1].appendChild(this.limitSets.nativeElement)
-        })
-    }
-
-    editSelected(fields: IdlObject[]) {
-        // Edit each IDL thing one at a time
-        const editOneThing = (field: IdlObject) => {
-            if (!field) { return; }
-            this.showEditDialog(field).then(
-                () => editOneThing(fields.shift()));
-        };
-        editOneThing(fields.shift());
+        });
     }
 
     createNew() {
         this.getLimitSets(null);
         this.limitSetsComponent.showLinkLimitSets = true;
         this.editDialog.mode = 'create';
-        // We reuse the same editor for all actions.  Be sure
-        // create action does not try to modify an existing record.
         this.editDialog.recordId = null;
         this.editDialog.record = null;
-        this.editDialog.open({size: this.dialogSize}).subscribe(
+        this.editDialog.handleRecordChange();
+        // We reuse the same editor for all actions.  Be sure
+        // create action does not try to modify an existing record.
+        this.matchpointDialog.open({size: this.dialogSize}).subscribe(
             ok => {
                 this.createString.current()
                     .then(str => this.toast.success(str));
@@ -132,8 +139,6 @@ export class CircMatrixMatchpointComponent implements OnInit {
                 this.limitSetsComponent.showLinkLimitSets = false;
             }
         );
-        const modalBody = document.getElementsByClassName("modal-body");
-        modalBody[modalBody.length-1].appendChild(this.limitSets.nativeElement)
     }
 
     setLimitSets(sets) {
@@ -142,70 +147,70 @@ export class CircMatrixMatchpointComponent implements OnInit {
 
     /**
      * Runs through the different CRUD operations, specified by the object that is passed into each.
-     * @param matchpoint 
+     * @param matchpoint
      */
     configureLimitSets(matchpoint) {
         const linkedSets = this.linkedLimitSets;
-        Object.keys(linkedSets).forEach((key) =>{
-            let ls = linkedSets[key]
-            if(ls.created) {
-                this.deleteLimitSets(ls).then(()=>{
+        Object.keys(linkedSets).forEach((key) => {
+            const ls = linkedSets[key];
+            if (ls.created) {
+                this.deleteLimitSets(ls).then(() => {
                     if (ls.isNew && !ls.isDeleted) {
-                        this.pcrud.create(this.createLimitSets(ls.linkedLimitSet,matchpoint)).subscribe(() =>{})
-                    } else if(!ls.isNew && !ls.isDeleted) {
+                        this.pcrud.create(this.createLimitSets(ls.linkedLimitSet, matchpoint)).subscribe(() => {});
+                    } else if (!ls.isNew && !ls.isDeleted) {
                         this.updateLimitSets(ls.linkedLimitSet);
                     }
-                })
+                });
             }
-        })
+        });
     }
 
     getLimitSets(id) {
-        this.pcrud.retrieveAll("ccmlsm").subscribe((res) =>{
+        this.clearLinkedCircLimitSets();
+        this.pcrud.retrieveAll('ccmlsm').subscribe((res) => {
             /**
              * If the limit set's matchpoint equals the matchpoint given
              * by the user, then add that to the set limit list
              */
-            this.limitSetsComponent.usedSetLimitList.push(res.limit_set());
-            if (res.matchpoint() == id) {
-                this.limitSetsComponent.createFilledLimitSetObject(res)
+            this.limitSetsComponent.usedSetLimitList[res.limit_set()] = res.id();
+            if (res.matchpoint() === id) {
+                this.limitSetsComponent.createFilledLimitSetObject(res);
             }
-        })
+        });
         /**
          * Retrives all limit set names
          */
-        this.pcrud.retrieveAll("ccls").subscribe(res =>{
+        this.pcrud.retrieveAll('ccls').subscribe((res) => {
             this.limitSetsComponent.limitSetNames[res.id()] = res.name();
-        })
+        });
     }
 
-    createLimitSets(limitSet,matchpoint) {
-        if(typeof matchpoint == "number" || typeof matchpoint == "string") {
-            limitSet.matchpoint(matchpoint)
+    createLimitSets(limitSet, matchpoint) {
+        if (typeof matchpoint === 'number' || typeof matchpoint === 'string') {
+            limitSet.matchpoint(matchpoint);
         } else {
-            limitSet.matchpoint(matchpoint.id())
+            limitSet.matchpoint(matchpoint.id());
         }
-        return limitSet
+        return limitSet;
     }
 
     updateLimitSets(limitSet) {
-        this.pcrud.update(limitSet).subscribe(() =>{})
+        this.pcrud.update(limitSet).subscribe(() => {});
     }
 
     deleteLimitSets(limitSet) {
-        return new Promise((resolve, reject) =>{
+        return new Promise((resolve, reject) => {
             if (limitSet.isDeleted) {
-                if(limitSet.linkedLimitSet.id()) {
-                    this.pcrud.remove(limitSet.linkedLimitSet).subscribe(res =>{
+                if (limitSet.linkedLimitSet.id()) {
+                    this.pcrud.remove(limitSet.linkedLimitSet).subscribe(res => {
                         resolve();
-                    })
+                    });
                 } else {
                     resolve();
                 }
             } else {
                 resolve();
             }
-        })
+        });
     }
 }
-
index f4299aa..516fb90 100644 (file)
@@ -2,13 +2,15 @@ import {NgModule} from '@angular/core';
 import {TreeModule} from '@eg/share/tree/tree.module';
 import {CircMatrixMatchpointRoutingModule} from './routing.module';
 import {AdminCommonModule} from '@eg/staff/admin/common.module';
-import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component'
-import {LinkedCircLimitSetsComponent} from './linked-circ-limit-sets.component'
+import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component';
+import {LinkedCircLimitSetsComponent} from './linked-circ-limit-sets.component';
+import {CircMatrixMatchpointDialogComponent} from './circ-matrix-matchpoint-dialog.component';
 
 @NgModule({
   declarations: [
     CircMatrixMatchpointComponent,
-    LinkedCircLimitSetsComponent
+    LinkedCircLimitSetsComponent,
+    CircMatrixMatchpointDialogComponent
   ],
   imports: [
     AdminCommonModule,
index bd33b07..9b3dbe0 100644 (file)
@@ -1,3 +1,6 @@
+
+<eg-string #errorString i18n-text text="The Linked Set Name Already Exists on Another Matchpoint"></eg-string>
+
 <div *ngIf="showLinkLimitSets">
     <div class="col-lg-15 bg-info d-flex justify-content-center"><h3 class="modal-title mt-3 mb-3" i18n>Linked Limit Sets</h3></div>
     <ng-container *ngIf="getObjectKeys().length > 0">
index 665ceea..0921345 100644 (file)
@@ -1,30 +1,35 @@
 
-import {Component, OnInit, Input,Output,EventEmitter} from '@angular/core';
+import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
 import { IdlService} from '@eg/core/idl.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {StringComponent} from '@eg/share/string/string.component';
+
 class LinkedLimitSetObjects {
-    linkedLimitSet:any;
-    created:boolean;
-    isDeleted:boolean;
-    isNew:boolean;
+    linkedLimitSet: any;
+    created: boolean;
+    isDeleted: boolean;
+    isNew: boolean;
 }
 
 @Component({
-    selector:'linked-circ-limit-sets',
+    selector: 'eg-linked-circ-limit-sets',
     templateUrl: './linked-circ-limit-sets.component.html'
 })
 
-
 export class LinkedCircLimitSetsComponent implements OnInit {
 
-    @Input() usedSetLimitList = [];
+    @ViewChild('errorString', { static: true }) errorString: StringComponent;
+
+    @Input() usedSetLimitList = {};
     @Input() limitSetNames = {};
     @Output() outputLinkedLimitSet: EventEmitter<any>;
     linkedSetList = {};
-    linkedSet:any;
-    showLinkLimitSets:boolean
+    linkedSet: any;
+    showLinkLimitSets: boolean;
 
-    constructor( 
-        private idl: IdlService
+    constructor(
+        private idl: IdlService,
+        private toast: ToastService
         ) {
         this.outputLinkedLimitSet = new EventEmitter();
     }
@@ -32,15 +37,15 @@ export class LinkedCircLimitSetsComponent implements OnInit {
     ngOnInit() {}
 
     displayLinkedLimitSets() {
-        this.createEmptyLimitSetObject()
+        this.createEmptyLimitSetObject();
     }
 
     createFilledLimitSetObject(element) {
-        let newLinkedSetObject = new LinkedLimitSetObjects();
-        if(element.fallthrough() == "f") element.fallthrough(false)
-        if(element.fallthrough() == "t") element.fallthrough(true)
-        if(element.active() == "f") element.active(false)
-        if(element.active() == "t") element.active(true)
+        const newLinkedSetObject = new LinkedLimitSetObjects();
+        if (element.fallthrough() === 'f') { element.fallthrough(false); }
+        if (element.fallthrough() === 't') { element.fallthrough(true); }
+        if (element.active() === 'f') { element.active(false); }
+        if (element.active() === 't') { element.active(true); }
         newLinkedSetObject.linkedLimitSet = element;
         newLinkedSetObject.created = true;
         newLinkedSetObject.isNew = false;
@@ -49,8 +54,8 @@ export class LinkedCircLimitSetsComponent implements OnInit {
     }
 
     createEmptyLimitSetObject() {
-        let object = this.idl.create("ccmlsm")
-        let newLinkedSetObject = new LinkedLimitSetObjects();
+        const object = this.idl.create('ccmlsm');
+        const newLinkedSetObject = new LinkedLimitSetObjects();
         newLinkedSetObject.linkedLimitSet = object;
         newLinkedSetObject.linkedLimitSet.fallthrough(false);
         newLinkedSetObject.linkedLimitSet.active(true);
@@ -60,39 +65,40 @@ export class LinkedCircLimitSetsComponent implements OnInit {
         this.linkedSetList[this.getObjectKeys().length] = newLinkedSetObject;
     }
 
-    onChange(object:any) {
+    onChange(object: any) {
         this.linkedSet = object;
     }
 
     getObjectKeys() {
-        if(this.linkedSetList) {
+        if (this.linkedSetList) {
             return Object.keys(this.linkedSetList);
         } else {
-            this.linkedSetList = {}
-            return Object.keys({})
+            this.linkedSetList = {};
+            return Object.keys({});
         }
     }
 
     addLinkedSet() {
         if (this.linkedSet) {
-            if( !this.usedSetLimitList.find(element => element == this.linkedSet.id)) {
+            if ( !this.usedSetLimitList[this.linkedSet.id]) {
                 this.createEmptyLimitSetObject();
-                this.linkedSetList[this.getObjectKeys().length-1].linkedLimitSet.limit_set(this.linkedSet.id);
-                this.linkedSetList[this.getObjectKeys().length-1].created = true;
+                this.linkedSetList[this.getObjectKeys().length - 1].linkedLimitSet.limit_set(this.linkedSet.id);
+                this.linkedSetList[this.getObjectKeys().length - 1].created = true;
                 this.emitLimitSet();
-                this.usedSetLimitList.push(this.linkedSet.id)
+                this.usedSetLimitList[this.linkedSet.id] = this.linkedSet.label;
+            } else {
+                this.errorString.current()
+                    .then(str => this.toast.danger(str));
             }
         }
     }
 
     emitLimitSet() {
-        this.outputLinkedLimitSet.emit(this.linkedSetList)
+        this.outputLinkedLimitSet.emit(this.linkedSetList);
     }
 
     removeLinkedSet(index) {
-        if(!this.linkedSetList[index].isNew) {
-            this.usedSetLimitList.splice(index,1);
-        }
+        delete this.usedSetLimitList[this.linkedSetList[index].linkedLimitSet.limit_set()];
         this.linkedSetList[index].isDeleted = true;
         this.emitLimitSet();
     }
index 5690d3c..193dc77 100644 (file)
@@ -1,6 +1,6 @@
 import {NgModule} from '@angular/core';
 import {RouterModule, Routes} from '@angular/router';
-import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component'
+import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component';
 const routes: Routes = [{
     path: '',
     component: CircMatrixMatchpointComponent
@@ -11,4 +11,4 @@ const routes: Routes = [{
   exports: [RouterModule]
 })
 
-export class CircMatrixMatchpointRoutingModule {}
\ No newline at end of file
+export class CircMatrixMatchpointRoutingModule {}