Skip to content

Commit bc14432

Browse files
committed
add alias readonly state to input with alias
1 parent 6b42849 commit bc14432

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/packages/core/components/input-with-alias/input-with-alias.element.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
1+
import { css, customElement, html, nothing, property, state } from '@umbraco-cms/backoffice/external/lit';
22
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
33
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
44
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
@@ -13,6 +13,9 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string>(UmbLit
1313
@property({ type: String, reflect: false })
1414
alias?: string;
1515

16+
@property({ type: Boolean, reflect: true, attribute: 'alias-readonly' })
17+
aliasReadonly = false;
18+
1619
@property({ type: Boolean, attribute: 'auto-generate-alias' })
1720
autoGenerateAlias?: boolean;
1821

@@ -75,11 +78,14 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string>(UmbLit
7578
@input=${this.#onAliasChange}
7679
.value=${this.alias}
7780
placeholder="Enter alias..."
78-
?disabled=${this._aliasLocked}>
81+
?disabled=${this._aliasLocked && !this.aliasReadonly}
82+
?readonly=${this.aliasReadonly}>
7983
<!-- TODO: validation for bad characters -->
80-
<div @click=${this.#onToggleAliasLock} @keydown=${() => ''} id="alias-lock" slot="prepend">
81-
<uui-icon name=${this._aliasLocked ? 'icon-lock' : 'icon-unlocked'}></uui-icon>
82-
</div>
84+
${this.aliasReadonly
85+
? nothing
86+
: html`<div @click=${this.#onToggleAliasLock} @keydown=${() => ''} id="alias-lock" slot="prepend">
87+
<uui-icon name=${this._aliasLocked ? 'icon-lock' : 'icon-unlocked'}></uui-icon>
88+
</div>`}
8389
</uui-input>
8490
</uui-input>
8591
`;
@@ -105,6 +111,7 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string>(UmbLit
105111
justify-content: center;
106112
cursor: pointer;
107113
}
114+
108115
#alias-lock uui-icon {
109116
margin-bottom: 2px;
110117
}

0 commit comments

Comments
 (0)