class="mr-2 btn btn-sm btn-outline-dark .mat-icon-shrunk-in-button">
<span class="material-icons">vertical_align_bottom</span>
</button>
- <span class="ml-2 font-italic" *ngIf="selectedEntry">
+ <span class="ml-2 font-italic" *ngIf="selected()">
Selected: {{selected().location().name()}}
({{orgSn(selected().location().owning_lib())}})
</span>
[ngClass]="{'border border-primary rounded': selectedEntry == entry.id()}">
{{entry.location().name()}} ({{orgSn(entry.location().owning_lib())}})
</span>
+ <span *ngIf="entry.isnew()" class="ml-2 font-italic text-info">(unsaved)</span>
</div>
</div>
</li>
.then(_ => {
- if (this.entries.length > 0) { return; }
-
- // If we have no position entries, create some now so they
- // can become the basis of our new list.
+ // Ensure we have an entry for every in-range copy location.
const locs = Object.values(this.locations)
.sort((o1, o2) => o1.name() < o2.name() ? -1 : 1);
- let pos = 1;
+ let pos = this.entries.length;
+
locs.forEach(loc => {
- const entry = this.idl.create('acplo');
+ pos++;
+
+ let entry = this.entries.filter(e => e.location().id() === loc.id())[0];
+ if (entry) { return; }
+
+ // Either we have no entries or we encountered a new copy
+ // location added since the last time entries were saved.
+
+ entry = this.idl.create('acplo');
entry.isnew(true);
- entry.id(-pos); // avoid using '0' as an ID
+ entry.id(-pos); // local temp ID
entry.location(loc);
- entry.position(pos++);
+ entry.position(pos);
entry.org(this.contextOrg);
this.entries.push(entry);
});