Skip to content

Commit

Permalink
Template picker showing on module in skin for non-editors, fix 2sic/2…
Browse files Browse the repository at this point in the history
  • Loading branch information
tvatavuk committed Oct 31, 2024
1 parent b360e86 commit e9eecfe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions projects/inpage/src/bootstrap/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class BootstrapInPage extends HasLog {


private initInstance(module: HTMLElement, isFirstRun: boolean): void {
const cl = this.log.call('initInstance', `module: obj, isFirstRun: ${isFirstRun}) initialized: ${this.initializedInstances}`);
const cl = this.log.call('initInstance', `isFirstRun: ${isFirstRun}) initialized: ${this.initializedInstances} module: obj`, null, {module});

// if instance is already in the list of initialized modules, skip
// otherwise add for next time to prevent recursions
Expand Down Expand Up @@ -210,7 +210,7 @@ export class BootstrapInPage extends HasLog {


private showGlassesButtonIfUninitialized(sxci: Sxc): boolean {
const callLog = this.log.call('showGlassesButtonIfUninitialized');
const callLog = this.log.call('showGlassesButtonIfUninitialized',`sxci:`, null, {sxci});

// already initialized
if (this.isInitialized(sxci))
Expand Down Expand Up @@ -238,7 +238,12 @@ export class BootstrapInPage extends HasLog {
isInitialized(sxci: Sxc): boolean {
const manage = sxci?.manage as EditManager;
const cg = manage?.editContext?.contentBlock;
return cg && cg.TemplateId !== 0;

// special case, when app is rendered in skin and should not offer templates picker
// when js assets are loaded because of other app (2sic/2sxc#3380)
const hasJsApi = manage?.editContext?.jsApi != null;

return (cg && cg?.TemplateId !== 0) || (!cg && hasJsApi);
}
}

Expand Down
3 changes: 3 additions & 0 deletions projects/inpage/src/constants/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ export const Debug = {
'Cmd.Exec': false,
'Cms.Api': false,
'Q-E.Main': false,
'debugObservables': false,
'Sys.Bootst': false,
'Bts.Module': false,
}
};
6 changes: 4 additions & 2 deletions projects/inpage/src/quick-dialog/iframe-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ export class IFrameBridge extends HasLog implements IIFrameBridge {
setup(sxc: Sxc, dialogName: string): void {
const cl = this.log.call('setup');
cl.data('rewire with sxc: ', sxc);

cl.data('dialogName: ', dialogName);
this.changed = false;
this.instanceSxc = sxc;
this.tagModule = DomTools.getTag(sxc).parentElement;
const tag = DomTools.getTag(sxc);
cl.data('tag: ', tag);
this.tagModule = tag?.parentElement;
this.sxcCacheKey = sxc.cacheKey;
if (dialogName) this.dialogName = dialogName;
cl.done();
Expand Down

0 comments on commit e9eecfe

Please sign in to comment.