@@ -96,35 +96,6 @@ export class DialogLovelaceDashboardDetail extends LitElement {
9696 const showBackgroundTab =
9797 Boolean ( this . _params . lovelaceConfig ) && Boolean ( this . _params . saveConfig ) ;
9898
99- let content : string | TemplateResult < 1 > | typeof nothing = nothing ;
100-
101- if ( this . _params . dashboard ?. mode === "yaml" ) {
102- content = this . hass . localize (
103- "ui.panel.config.lovelace.dashboards.cant_edit_yaml"
104- ) ;
105- } else if ( this . _currTab === "tab-background" && showBackgroundTab ) {
106- content = html `
107- <hui- view- background- edito r
108- .hass = ${ this . hass }
109- .config = ${ this . _backgroundConfig }
110- @background-config-changed = ${ this . _backgroundConfigChanged }
111- > </ hui- view- background- edito r>
112- ` ;
113- } else {
114- content = html `
115- <ha- for m
116- auto focus
117- .schema = ${ this . _schema ( this . _params , this . _data ?. require_admin ) }
118- .data = ${ this . _data }
119- .hass = ${ this . hass }
120- .error = ${ this . _error }
121- .computeLabel = ${ this . _computeLabel }
122- .computeHelper = ${ this . _computeHelper }
123- @value-changed = ${ this . _valueChanged }
124- > </ ha- for m>
125- ` ;
126- }
127-
12899 const cancelButton = html `
129100 <ha- butto n
130101 appearance= "plain"
@@ -183,7 +154,7 @@ export class DialogLovelaceDashboardDetail extends LitElement {
183154 </ ha- dialog- header>
184155 `
185156 : nothing }
186- <div> ${ content } </ div>
157+ <div> ${ this . _renderContent ( showBackgroundTab ) } </ div>
187158 <ha- dialog- footer slot= "footer" >
188159 ${ this . _params . urlPath
189160 ? html `
@@ -227,6 +198,39 @@ export class DialogLovelaceDashboardDetail extends LitElement {
227198 ` ;
228199 }
229200
201+ private _renderContent (
202+ showBackgroundTab : boolean
203+ ) : string | TemplateResult < 1 > | typeof nothing {
204+ if ( this . _params ?. dashboard ?. mode === "yaml" ) {
205+ return this . hass . localize (
206+ "ui.panel.config.lovelace.dashboards.cant_edit_yaml"
207+ ) ;
208+ }
209+
210+ if ( this . _currTab === "tab-background" && showBackgroundTab ) {
211+ return html `
212+ <hui- view- background- edito r
213+ .hass = ${ this . hass }
214+ .config = ${ this . _backgroundConfig }
215+ @background-config-changed = ${ this . _backgroundConfigChanged }
216+ > </ hui- view- background- edito r>
217+ ` ;
218+ }
219+
220+ return html `
221+ <ha- for m
222+ auto focus
223+ .schema = ${ this . _schema ( this . _params ! , this . _data ?. require_admin ) }
224+ .data = ${ this . _data }
225+ .hass = ${ this . hass }
226+ .error = ${ this . _error }
227+ .computeLabel = ${ this . _computeLabel }
228+ .computeHelper = ${ this . _computeHelper }
229+ @value-changed = ${ this . _valueChanged }
230+ > </ ha- for m>
231+ ` ;
232+ }
233+
230234 private _schema = memoizeOne (
231235 ( params : LovelaceDashboardDetailsDialogParams , requireAdmin ?: boolean ) =>
232236 [
0 commit comments