Skip to content

Commit 97d2414

Browse files
Create dropdown using JSdialog
- Temp commit to for JsDialog Signed-off-by: Darshan-upadhyay1110 <[email protected]> Change-Id: Ic9271aaf42b87e7e34c10a40eb6e5a83671c1ad2
1 parent fd30645 commit 97d2414

File tree

3 files changed

+124
-225
lines changed

3 files changed

+124
-225
lines changed

browser/src/control/Control.Sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Sidebar extends SidebarBase {
143143
this.builder.build(this.container, [this.model.getSnapshot()], false);
144144

145145
if (!this.isVisible()) {
146-
if ((this.builder as any).windowId === WindowId.Sidebar)
146+
if (this.isCoreBased())
147147
$('#sidebar-dock-wrapper').addClass('coreBased');
148148
$('#sidebar-dock-wrapper').addClass('visible');
149149

browser/src/control/Control.SidebarBase.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,40 @@ abstract class SidebarBase extends JSDialogComponent {
7979
return node.hasClass('visible') && node.hasClass('coreBased');
8080
}
8181

82-
closeSidebar() {
83-
$(`#${this.type}-dock-wrapper`).removeClass('visible');
84-
$(`#${this.type}-dock-wrapper`).removeClass('coreBased');
82+
/// checks if this sidebar is core-based (uses WindowId.Sidebar)
83+
protected isCoreBased(): boolean {
84+
return this.builder && (this.builder as any).windowId === WindowId.Sidebar;
85+
}
86+
87+
/// shared implementation for showing/hiding sidebar
88+
protected showSidebarImpl(show: boolean) {
89+
const wrapper = $(`#${this.type}-dock-wrapper`);
8590

86-
if (!this.map.editorHasFocus()) {
87-
this.map.fire('editorgotfocus');
88-
this.map.focus();
91+
if (show) {
92+
wrapper.addClass('visible');
93+
if (this.isCoreBased()) {
94+
wrapper.addClass('coreBased');
95+
}
96+
} else {
97+
wrapper.removeClass('visible');
98+
wrapper.removeClass('coreBased');
99+
100+
if (!this.map.editorHasFocus()) {
101+
this.map.fire('editorgotfocus');
102+
this.map.focus();
103+
}
89104
}
90105

91106
const upperCaseType = this.type[0].toUpperCase() + this.type.slice(1);
92-
this.map.uiManager.setDocTypePref('Show' + upperCaseType, false);
107+
this.map.uiManager.setDocTypePref('Show' + upperCaseType, show);
93108
}
94109

95-
showSidebar() {
96-
$(`#${this.type}-dock-wrapper`).addClass('visible');
97-
if (this.builder && (this.builder as any).windowId === WindowId.Sidebar)
98-
$(`#${this.type}-dock-wrapper`).addClass('coreBased');
110+
closeSidebar() {
111+
this.showSidebarImpl(false);
112+
}
99113

100-
const upperCaseType = this.type[0].toUpperCase() + this.type.slice(1);
101-
this.map.uiManager.setDocTypePref('Show' + upperCaseType, true);
114+
showSidebar() {
115+
this.showSidebarImpl(true);
102116
}
103117

104118
protected onJSUpdate(e: FireEvent) {

0 commit comments

Comments
 (0)