Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/components/form/dt-location-map/dt-location-map-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class DtLocationMapItem extends LitElement {
},
loading: { type: Boolean },
saved: { type: Boolean },
disableDeleteButton: { type: Boolean },
filteredOptions: { type: Array, state: true },
};
}
Expand Down Expand Up @@ -233,6 +234,7 @@ export default class DtLocationMapItem extends LitElement {
this.filteredOptions = [];
this.detectTap = false;
this.debounceTimer = null;
this.disableDeleteButton = false;
}

connectedCallback() {
Expand Down Expand Up @@ -635,7 +637,7 @@ export default class DtLocationMapItem extends LitElement {
class="${this.disabled ? 'disabled' : null}"
placeholder="${this.placeholder}"
.value="${this.metadata?.label ?? ''}"
.disabled=${(existingValue && hasGeometry) || this.disabled}
.disabled=${(!this.disableDeleteButton && existingValue && hasGeometry) || this.disabled}
@focusin="${this._inputFocusIn}"
@blur="${this._inputFocusOut}"
@keydown="${this._inputKeyDown}"
Expand All @@ -652,21 +654,23 @@ export default class DtLocationMapItem extends LitElement {
</button>
` : null }
${existingValue ? html`
<button
class="input-addon btn-delete"
@click=${this._delete}
?disabled=${this.disabled}
>
<dt-icon icon="mdi:trash-can-outline"></dt-icon>
</button>
${this.disableDeleteButton ? null : html`
<button
class="input-addon btn-delete"
@click=${this._delete}
?disabled=${this.disabled}
>
<slot name="delete-icon"><dt-icon icon="mdi:trash-can-outline"></dt-icon></slot>
</button>
`}
` : html`
<button
class="input-addon btn-pin"
@click=${this._openMapModal}
?disabled=${this.disabled}
>
<dt-icon icon="mdi:map-marker-radius"></dt-icon>
</button>
<button
class="input-addon btn-pin"
@click=${this._openMapModal}
?disabled=${this.disabled}
>
<slot name="pin-icon"><dt-icon icon="mdi:map-marker-radius"></dt-icon></slot>
</button>
` }
</div>
<ul class="option-list" style=${styleMap(optionListStyles)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ export default {
},
},
},
disableDeleteButton: {
control: 'boolean',
description:
'(true|false) If attribute is present, the delete button will be disabled',
table: {
type: {
summary: 'disableDeleteButton',
detail: '<dt-location disableDeleteButton />',
},
},
},
...argTypes,
},
args: {
Expand All @@ -106,6 +117,7 @@ function Template(args) {
onchange,
open,
i18n,
disableDeleteButton,
} = args;
return html`
<style>
Expand All @@ -120,6 +132,7 @@ function Template(args) {
?disabled=${disabled}
?loading="${loading}"
?saved="${saved}"
?disableDeleteButton="${disableDeleteButton}"
.open="${open}"
i18n="${JSON.stringify(i18n)}"
>
Expand Down Expand Up @@ -162,6 +175,12 @@ AutoSave.args = {
onchange: 'onAutoSave(event)',
};

export const DisableDeleteButton = Template.bind({});
DisableDeleteButton.args = {
metadata: basicOptions[0],
disableDeleteButton: true,
};

export const Disabled = Template.bind({});
Disabled.args = {
value: [basicOptions[0]],
Expand Down