Skip to content

Commit bb9bce7

Browse files
committed
Fix application settings dropdowns toggling each other
- Remove [(value)]="selected" binding from all dropdowns - Each dropdown now only uses [(ngModel)] for its specific property - Fixes issue where changing Embeddable would affect Load in Background - Simplify save methods to avoid change detection errors - Fix NG0100 ExpressionChangedAfterItHasBeenCheckedError
1 parent aa88be1 commit bb9bce7

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

src/app/components/admin-app/view-applications-select/view-applications-select.component.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
<mat-label>Embeddable</mat-label>
6666
<mat-select
6767
(selectionChange)="saveApplicationEmbeddable(app)"
68-
[(value)]="selected"
6968
[(ngModel)]="app.embeddable"
7069
>
7170
<mat-option [value]="null">Inherit from Template</mat-option>
@@ -77,7 +76,6 @@
7776
<mat-label>Load in Background</mat-label>
7877
<mat-select
7978
(selectionChange)="saveApplicationLoadInBackground(app)"
80-
[(value)]="selected"
8179
[(ngModel)]="app.loadInBackground"
8280
>
8381
<mat-option [value]="null">Inherit from Template</mat-option>
@@ -89,7 +87,6 @@
8987
<mat-label>Application Template</mat-label>
9088
<mat-select
9189
(selectionChange)="saveApplicationTemplateId(app)"
92-
[(value)]="selected"
9390
[(ngModel)]="app.applicationTemplateId"
9491
>
9592
<mat-option [value]="null">None</mat-option>
@@ -142,7 +139,6 @@
142139
<mat-label>Template Embeddable</mat-label>
143140
<mat-select
144141
[disabled]="true"
145-
[(value)]="selected"
146142
[(ngModel)]="template.embeddable"
147143
>
148144
<mat-option [value]="null">Inherit from Template</mat-option>
@@ -154,7 +150,6 @@
154150
<mat-label>Template Load in Background</mat-label>
155151
<mat-select
156152
[disabled]="true"
157-
[(value)]="selected"
158153
[(ngModel)]="template.loadInBackground"
159154
>
160155
<mat-option [value]="null">Inherit from Template</mat-option>

src/app/components/admin-app/view-applications-select/view-applications-select.component.ts

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,41 +141,28 @@ export class ViewApplicationsSelectComponent implements OnInit {
141141
* @param application The changed application object
142142
*/
143143
saveApplicationEmbeddable(application: Application): void {
144-
this.applicationService.getApplication(application.id).subscribe((app) => {
145-
app.embeddable = application.embeddable;
146-
this.saveApplication(app);
147-
});
144+
this.saveApplication(application);
148145
}
149146

150147
/**
151148
* Saves the application load in background flag
152149
* @param application The changed application object
153150
*/
154151
saveApplicationLoadInBackground(application: Application): void {
155-
this.applicationService.getApplication(application.id).subscribe((app) => {
156-
app.loadInBackground = application.loadInBackground;
157-
this.saveApplication(app);
158-
});
152+
this.saveApplication(application);
159153
}
160154

161155
saveApplicationTemplateId(application: Application): void {
162-
this.applicationService.getApplication(application.id).subscribe((app) => {
163-
app.applicationTemplateId = application.applicationTemplateId;
164-
this.saveApplication(app);
165-
});
156+
this.saveApplication(application);
166157
}
167158

168159
/**
169160
* Generically saves the application for the view and updates the applications list
170161
*/
171162
saveApplication(app: Application) {
172163
this.applicationService.updateApplication(app.id, app).subscribe(() => {
173-
this.applicationService
174-
.getViewApplications(this.view.id)
175-
.subscribe((appInsts) => {
176-
this.applications = appInsts;
177-
});
178-
console.log('Application name updated');
164+
// Don't update local array - ngModel binding keeps it in sync
165+
console.log('Application updated');
179166
});
180167
}
181168

@@ -204,36 +191,36 @@ export class ViewApplicationsSelectComponent implements OnInit {
204191
getAppName(app: Application) {
205192
if (app.name != null) {
206193
return app.name;
207-
} else if (app.applicationTemplateId != null) {
194+
} else if (app.applicationTemplateId != null && this.applicationTemplates?.length > 0) {
208195
const template = this.applicationTemplates.find(
209196
(x) => x.id === app.applicationTemplateId
210197
);
211198

212199
if (template != null) {
213200
return template.name;
214201
} else {
215-
return null;
202+
return 'Application';
216203
}
217204
} else {
218-
return null;
205+
return 'Application';
219206
}
220207
}
221208

222209
getAppIcon(app: Application) {
223210
if (app.icon != null) {
224211
return app.icon;
225-
} else if (app.applicationTemplateId != null) {
212+
} else if (app.applicationTemplateId != null && this.applicationTemplates?.length > 0) {
226213
const template = this.applicationTemplates.find(
227214
(x) => x.id === app.applicationTemplateId
228215
);
229216

230217
if (template != null) {
231218
return template.icon;
232219
} else {
233-
return null;
220+
return 'assets/img/SP_Icon_Dashboard.png';
234221
}
235222
} else {
236-
return null;
223+
return 'assets/img/SP_Icon_Dashboard.png';
237224
}
238225
}
239226

0 commit comments

Comments
 (0)