<service>open-ils.vandelay</service>
<service>open-ils.serial</service>
<service>open-ils.ebook_api</service>
+ <service>open-ils.sip2</service>
</services>
</router>
// custom function for munging the record before it gets saved;
// will get passed mode and the record itself
- @Input() preSave: Function;
+ @Input() preSave: (mode: string, recToSave: IdlObject) => void;
// recordId and record getters and setters.
// Note that setting the this.recordId to NULL does not clear the
<a routerLink="/staff/admin/server/sip/account">
<button class="btn btn-outline-dark label-with-material-icon">
<span class="material-icons">reply</span>
- <span i18n>Setting Groups</span>
+ <span i18n>SIP Accounts</span>
</button>
</a>
fieldOrder="sip_username,setting_group,usr,workstation,transient,activity_who,enabled"
[fieldOptions]="{
setting_group:{customTemplate:{template:grpTemplate}},
- usr:{customTemplate:{template:usrTemplate}}
- }"
+ usr:{customTemplate:{template:usrTemplate}}}"
+ [preSave]="accountPreSave"
(recordSaved)="accountSaved()" [recordId]="accountId">
</eg-fm-record-editor>
</div>
<div class="col-lg-5">
<ul>
- <li i18n>Save account changes before modifying settings.</li>
+ <li i18n>Save account changes before modifying individual settings.</li>
<li i18n>Setting values must be entered as valid JSON.</li>
- <li i18n>The "Default Settings" settings group cannot be modified</li>
+ <li i18n>The "Default Settings" group cannot be modified.</li>
+ <li i18n>The same "SIP Institution" value may be used for multiple groups.</li>
</ul>
</div>
</div>
usrId: number;
settingsSource: GridDataSource = new GridDataSource();
deleteGroupAccounts: IdlObject[] = [];
+ accountPreSave: (mode: string, account: IdlObject) => void;
@ViewChild('cloneDialog') cloneDialog: FmRecordEditorComponent;
@ViewChild('settingDialog') settingDialog: FmRecordEditorComponent;
{setting_group: this.account.setting_group().id()},
{order_by: orderBy},
);
- }
+ };
+
+ this.accountPreSave = (mode: string, account: IdlObject) => {
+ if (mode === 'update') {
+ // Migrate the setting group selected in our local group
+ // combobox to the object to be saved.
+ account.setting_group(this.account.setting_group().id());
+ }
+ };
}
modified.ischanged(true);
this.pcrud.autoApply(settings.concat(modified)).toPromise()
- .then(_ => this.loadAccount());
+ .then(_ => this.refreshAccount());
});
}
this.deleteGroupDialog.open().subscribe(
ok => {
- console.log('group deleted');
+ if (ok) {
+ this.refreshAccount();
+ }
}
);
-
-
- /*
- const grp = this.account.setting_group();
-
- // Find accounts that use this group
- this.pcrud.search('sipacc', {setting_group: grp.id()}, {atomic: true})
-
- // Confirm deletion
- .pipe(switchMap(accounts => {
- this.deleteGroupAccounts = accounts;
- return this.confirmDelete.open();
- })
-
- // Modify accounts that use this group so the delete can continue
- .pipe(switchMap(approved => {
- if (!approved) { return of(); }
-
- // Clone the accounts so we can avoid modifying the currently
- // edited account, which can lead to fleshing-related JS errors
- const clones = accounts.map(acc => {
- const one = this.idl.clone(acc);
- one.setting_group(1); // defaults
- return one;
- });
-
- return this.pcrud.update(clones);
- })
- .pipe(switchMap(result => {
- if (!result) { return of(); }
- return this.pcrud.remove(grp);
- })
- .pipe(tap(result => {
- if (result)
- */
}
accountSaved() {
- this.loadAccount();
+ this.refreshAccount();
}
editFirstSetting(rows: any) {
}
}
+ refreshAccount() {
+ this.loadAccount().subscribe(_ => {
+ setTimeout(() => {
+ if (this.settingGrid) {
+ this.settingGrid.reload();
+ }
+ });
+ });
+ }
+
editSetting(row: any) {
// Default Settings group is read-only
if (row.setting_group() === 1) { return; }
this.settingDialog.record = this.idl.clone(row);
this.settingDialog.open().subscribe(
- ok => {
- // Easier to simply refresh the whole account.
- // After refresh, force a grid reload.
- this.loadAccount().subscribe(ok2 => {
- setTimeout(() => {
- if (this.settingGrid) {
- this.settingGrid.reload();
- }
- });
- });
- },
+ ok => this.refreshAccount(),
err => {} // todo toast
);
}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success"
- (click)="close(true)" i18n>Confirm</button>
+ (click)="doDelete(true)" i18n>Confirm</button>
<button type="button" class="btn btn-warning"
(click)="close(false)" i18n>Cancel</button>
</div>
constructor(
private modal: NgbModal,
- private idl: IdlService,
+ private auth: AuthService,
private net: NetService
) {
super(modal);
ngOnInit() {
this.onOpen$.subscribe(_ => {
- console.log('my group', this.group);
this.trimmedSettingGroups = this.settingGroups.filter(
entry => entry.id !== this.group.id());
});
this.targetGroup = entry.id;
}
}
+
+ doDelete() {
+ this.net.request('open-ils.sip2',
+ 'open-ils.sip2.setting_group.delete',
+ this.auth.token(), this.group.id(), this.targetGroup
+ ).subscribe(ok => this.close((Number(ok) === 1)));
+ }
}
}
);
-sub dispatch_sip2_request {
+sub delete_setting_group {
my ($self, $client, $auth, $del_grp_id, $xfer_grp_id) = @_;
$xfer_grp_id ||= 1; # Defaults Group
my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('SIP_ADMIN');
return $e->die_event unless
}
# note: sip.setting objects are deleted via cascade
- return $e->die_event unless $e->delete_sip_setting_group($grp);
+ return $e->die_event
+ unless $e->delete_sip_setting_group($grp) && $e->commit;
return 1;
}
'Checkout override copy alert message',
'sipset', 'description')
), (
+ 1, 'checkout.override.COPY_NOT_AVAILABLE', 'true',
+ oils_i18n_gettext(
+ (SELECT id FROM sip.setting WHERE name = 'checkout.override.COPY_NOT_AVAILABLE'),
+ 'Checkout override copy not available message',
+ 'sipset', 'description')
+), (
1, 'checkin.override.COPY_ALERT_MESSAGE', 'true',
oils_i18n_gettext(
(SELECT id FROM sip.setting WHERE name = 'checkin.override.COPY_ALERT_MESSAGE'),