Skip to content

Commit 34b60a4

Browse files
committed
minor fix to ensure tabs change
2sic/2sxc#2927
1 parent a875ad1 commit 34b60a4

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

projects/quick-dialog/src/app/template-picker/content-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ContentType {
1111
// * 2022-11-04 2dm - doesn't seem to be added in the UI either, so skip / remove this ???
1212
// * 2022-11-04 2dm disabled, think it's never used
1313
// */
14-
TemplateId: number;
14+
// TemplateId: number;
1515
IsDefault = false;
1616
}
1717

projects/quick-dialog/src/app/template-picker/data/content-types-processor.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export class ContentTypesProcessor {
3939
contentTypes
4040
// 2022-11-04 2dm disabled, think it's never used
4141
// 2022-11-11 trying to fix another issue....
42-
.filter(c => (currentTemplate?.TemplateId === c.TemplateId) || (c.StaticName === currentType?.StaticName))
43-
// .filter(c => (c.StaticName === currentType?.StaticName && c.StaticName !== undefined))
42+
// .filter(c => (currentTemplate?.TemplateId === c.TemplateId) || (c.StaticName === currentType?.StaticName))
43+
.filter(c => (c.StaticName === currentType?.StaticName && c.StaticName !== undefined))
4444
.forEach(c => c.IsHidden = false);
4545
// console.log('2dm after', contentTypes);
4646
return contentTypes;

projects/quick-dialog/src/app/template-picker/template-picker.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h4>Debug 2sxc 14 Quick Dialog</h4>
99
<li>Apps: {{ (apps$ | async)?.length }}, current: {{app?.AppId }} </li>
1010
<li>Templates: {{templates?.length}}, current: {{template?.TemplateId}}</li>
1111
<li>Config: isContent='{{isContent}}' Ready: {{ready}} </li>
12-
<li>Tab to show: '{{tabIndex}}' / {{tab$ | async}} / preventTypeSwitch '{{preventTypeSwitch}}' / preventAppSwitch '{{preventAppSwitch}}'</li>
12+
<li>Tab to show: '{{tabIndex}}' / preventTypeSwitch '{{preventTypeSwitch}}' / preventAppSwitch '{{preventAppSwitch}}'</li>
1313
<li>installerNeeded: {{installerNeeded}}, isInnerContent: {{isInnerContent}}, installerShow: {{installerShow}}, showInstallAndAllApps: {{showInstallAndAllApps}}</li>
1414
</ul>
1515
</div>
@@ -31,7 +31,7 @@ <h4>Debug 2sxc 14 Quick Dialog</h4>
3131
</div>
3232

3333
<!-- tabs -->
34-
<mat-tab-group [selectedIndex]="tab$ | async">
34+
<mat-tab-group [selectedIndex]="tabIndex">
3535
<mat-tab>
3636
<ng-template mat-tab-label>
3737
{{(isContent

projects/quick-dialog/src/app/template-picker/template-picker.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class TemplatePickerComponent implements OnInit {
4949

5050
/** Tab-id, when we set it, the tab switches */
5151
tabIndex = 0;
52-
tab$ = new BehaviorSubject<number>(0);
5352

5453
/** Indicate if the user is allowed to change content-types or not */
5554
preventTypeSwitch: boolean;
@@ -109,6 +108,7 @@ export class TemplatePickerComponent implements OnInit {
109108

110109
this.boot(dashInfo);
111110
if (debug) this.debugObservables();
111+
console.log('2dm - CONSTRUCTOR');
112112
}
113113

114114
ngOnInit(): void {
@@ -133,10 +133,12 @@ export class TemplatePickerComponent implements OnInit {
133133
}
134134

135135
private debugObservables() {
136+
console.log('debugObservables');
137+
// this.tab$.subscribe(t => log.add(`tab changed to ${t}`));
138+
136139
if (!DebugConfig.picker.streams) return;
137140
this.loading$.subscribe(l => log.add(`quick-dialog loading$:${l}`));
138141
this.ready$.subscribe(r => log.add(`quick-dialog ready$:${r}`));
139-
this.tab$.subscribe(t => log.add(`tab changed to ${t}`));
140142
}
141143

142144
/**
@@ -292,12 +294,11 @@ export class TemplatePickerComponent implements OnInit {
292294
const msg = `switchTab(${message})`;
293295
log.add(msg);
294296
this.tabIndex = 1;
295-
this.tab$.next(1);
297+
this.cdRef.detectChanges();
296298
// repeat after delay because of a bug in the tabs-updating (unclear why...)
297-
timer(100).toPromise().then(_ => {
298-
this.tab$.next(1);
299-
return this.tabIndex = 1;
300-
});
299+
// timer(100).toPromise().then(_ => {
300+
// return this.tabIndex = 1;
301+
// });
301302
}
302303

303304

0 commit comments

Comments
 (0)