<ng-template #grpTemplate>
<div class="form-inline">
- <eg-combobox #grpCbox idlClass="sipsetg" required="true"
+ <eg-combobox #grpCbox required="true"
[selectedId]="account.setting_group() ? account.setting_group().id() : null"
- [asyncSupportsEmptyTermClick]="true"
- (onChange)="grpChanged($event)">
+ [entries]="settingGroups" (onChange)="grpChanged($event)">
</eg-combobox>
<button class="btn btn-outline-dark ml-2"
(click)="openCloneDialog()" i18n>Clone</button>
(recordSaved)="accountSaved()" [recordId]="accountId">
</eg-fm-record-editor>
</div>
+ <div class="col-lg-6">
+ <ul>
+ <li i18n>Apply changes to the account before modifying settings</li>
+ <li i18n>Setting values must be entered as valid JSON.</li>
+ </ul>
+ </div>
</div>
<div class="row" *ngIf="account && account.setting_group()">
<div class="col-lg-12 border-top mt-2 pt-2">
<h4 class="mb-2" i18n>Settings For Group
- <span class="font-weight-bold">{{account.setting_group().label()}}</span>
+ <span class="font-weight-bold">'{{account.setting_group().label()}}'</span>
</h4>
- <span class="font-italic mt-2 mb-2" i18n>
- Setting values must be entered as valid JSON.
- </span>
-
<eg-grid #settingGrid idlClass="sipset" [dataSource]="settingsSource"
[sortable]="true" (onRowActivate)="editSetting($event)"
persistKey="admin.server.sip.account.settings" hideFields="id,setting_group">
account: IdlObject;
usrCboxSource: (term: string) => Observable<ComboboxEntry>;
usrCboxEntries: ComboboxEntry[];
+ settingGroups: ComboboxEntry[];
usrId: number;
settingsSource: GridDataSource = new GridDataSource();
this.loadAccount().toPromise(); // force it to run
});
+ this.fetchGroups();
+
this.usrCboxSource = term => {
return this.pcrud.search('au', {
deleted: 'f', active: 't',
}
}
+
+ fetchGroups() {
+ this.pcrud.retrieveAll('sipsetg',
+ {order_by: {sipsetg: 'label'}}, {atomic: true})
+ .subscribe(grps => {
+ this.settingGroups =
+ grps.map(g => ({id: g.id(), label: g.label()}));
+ });
+ }
+
loadAccount(): Observable<any> {
return this.pcrud.retrieve('sipacc', this.accountId, {
flesh: 2,
this.pcrud.retrieve('sipsetg', entry.id,
{flesh: 1, flesh_fields: {sipsetg: ['settings']}})
- .subscribe(grp => this.account.setting_group(grp));
+ .subscribe(grp => {
+ this.account.setting_group(grp);
+ if (this.settingGrid) {
+ this.settingGrid.reload();
+ }
+ });
}
// Create a new setting group
this.cloneDialog.open().subscribe(resp => {
if (!resp) { return; }
+ this.settingGroups.unshift({id: resp.id(), label: resp.label()});
+
const settings = this.account.setting_group().settings()
.map(setting => {
const clone = this.idl.clone(setting);