Skip to content

Commit

Permalink
Allow to override showTrailingButton from an NcAction
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Apr 27, 2023
1 parent 5bce4bc commit 69e8a67
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/components/NcActionInput/NcActionInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ For the multiselect component, all events will be passed through. Please see the
<Pencil :size="20" />
</template>
</NcActionInput>
<NcActionInput :value.sync="text" :show-trailing-button="false">
<template #icon>
<Pencil :size="20" />
</template>
</NcActionInput>
<NcActionInput :value.sync="text">
<template #icon>
<Pencil :size="20" />
Expand All @@ -45,6 +50,12 @@ For the multiselect component, all events will be passed through. Please see the
</template>
Password placeholder
</NcActionInput>
<NcActionInput type="password" :value.sync="text" :show-trailing-button="false">
<template #icon>
<Key :size="20" />
</template>
Password placeholder
</NcActionInput>
<NcActionInput type="color" :value.sync="color">
<template #icon>
<Eyedropper :size="20" />
Expand Down Expand Up @@ -191,7 +202,7 @@ For the multiselect component, all events will be passed through. Please see the
:disabled="disabled"
:input-class="{ focusable: isFocusable }"
trailing-button-icon="arrowRight"
:show-trailing-button="value !== '' && !disabled"
:show-trailing-button="showTrailingButton && value !== '' && !disabled"
v-bind="$attrs"
v-on="$listeners"
@trailing-button-click="$refs.form.requestSubmit()"
Expand Down Expand Up @@ -219,7 +230,7 @@ For the multiselect component, all events will be passed through. Please see the
:input-class="{ focusable: isFocusable }"
:type="type"
trailing-button-icon="arrowRight"
:show-trailing-button="value !== '' && !disabled"
:show-trailing-button="showTrailingButton && value !== '' && !disabled"
v-bind="$attrs"
v-on="$listeners"
@trailing-button-click="$refs.form.requestSubmit()"
Expand Down Expand Up @@ -349,6 +360,13 @@ export default {
type: Boolean,
default: null,
},
/**
* Attribute forwarded to the underlining NcPasswordField and NcTextField
*/
showTrailingButton: {
type: Boolean,
default: true,
},
},

emits: [
Expand Down
10 changes: 9 additions & 1 deletion src/components/NcPasswordField/NcPasswordField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
<NcInputField v-bind="{...$attrs, ...$props }"
ref="inputField"
:type="isPasswordHidden ? 'password' : 'text'"
:show-trailing-button="true"
:show-trailing-button="showTrailingButton && true"
:trailing-button-label="trailingButtonLabelPassword"
:helper-text="computedHelperText"
:error="computedError"
Expand Down Expand Up @@ -181,6 +181,14 @@ export default {
type: Number,
default: null,
},

/**
* Controls whether to display the trailing button.
*/
showTrailingButton: {
type: Boolean,
default: true,
},
},

emits: [
Expand Down

0 comments on commit 69e8a67

Please sign in to comment.