-<div class="row d-flex">
+<div class="d-flex">
+ <h3 class="mt-3" i18n>Holdings Preferences</h3>
<div class="flex-1"></div>
- <button class="btn btn-outline-dark" (click)="save()" i18n>Save Preferences</button>
+ <div i18n class="font-italic">Changes are saved automatically.</div>
</div>
-<h3 class="mt-3" i18n>Holdings Preferences</h3>
-
<div class="row">
<div class="col-lg-6">
<div class="row">
from the Item Attributes Form.
</span>
-<div class="row d-flex">
+<div class="row d-flex pb-5">
<!-- COLUMN 1 -->
<div class="flex-1 p-1">
</div>
</div>
-<div class="row d-flex">
- <div class="flex-1"></div>
- <button class="btn btn-outline-dark" (click)="save()" i18n>Save Preferences</button>
-</div>
-
-
-import {Component, Input, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
+import {Component, Input, OnInit, ViewChild, DoCheck} from '@angular/core';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {tap} from 'rxjs/operators';
import {IdlObject, IdlService} from '@eg/core/idl.service';
-import {EventService} from '@eg/core/event.service';
-import {OrgService} from '@eg/core/org.service';
-import {StoreService} from '@eg/core/store.service';
-import {NetService} from '@eg/core/net.service';
-import {AuthService} from '@eg/core/auth.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
import {VolCopyContext} from './volcopy';
import {VolCopyService} from './volcopy.service';
-import {FormatService} from '@eg/core/format.service';
-import {StringComponent} from '@eg/share/string/string.component';
-import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component';
@Component({
selector: 'eg-volcopy-config',
templateUrl: 'config.component.html'
})
-export class VolCopyConfigComponent implements OnInit, AfterViewInit {
+export class VolCopyConfigComponent implements OnInit, DoCheck {
@Input() context: VolCopyContext;
+ defaultsCopy: any;
+
constructor(
private router: Router,
private route: ActivatedRoute,
- private renderer: Renderer2,
- private evt: EventService,
private idl: IdlService,
- private org: OrgService,
- private net: NetService,
- private auth: AuthService,
- private pcrud: PcrudService,
- private holdings: HoldingsService,
- private format: FormatService,
- private store: StoreService,
public volcopy: VolCopyService
- ) { }
+ ) {}
ngOnInit() {
- console.log('DEFAULTS', this.volcopy.defaults);
+ console.debug('DEFAULTS', this.volcopy.defaults);
+
+ // Not an IDL object, but clones just the same
+ this.defaultsCopy = this.idl.clone(this.volcopy.defaults);
}
- ngAfterViewInit() {
+ // Watch for changes in the form and auto-save them.
+ ngDoCheck() {
+ const hidden = this.volcopy.defaults.hidden;
+ for (const key in hidden) {
+ if (hidden[key] !== this.defaultsCopy.hidden[key]) {
+ this.save();
+ return;
+ }
+ }
+
+ const values = this.volcopy.defaults.values;
+ for (const key in values) {
+ if (values[key] !== this.defaultsCopy.values[key]) {
+ this.save();
+ return;
+ }
+ }
}
save() {
- this.volcopy.saveDefaults();
+ this.volcopy.saveDefaults().then(_ =>
+ this.defaultsCopy = this.idl.clone(this.volcopy.defaults)
+ );
}
}