Skip to content

OD-746 [Feature] Added show password function #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions css/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
opacity: 0.65;
}

.fl-form .fa-eye, .fl-form .fa-eye-slash {
position: absolute;
top: 15px;
right: 30px;
display: inline-block;
}

.fl-form.form-offline .cover-form {
position: absolute;
top: 0;
Expand Down
2 changes: 1 addition & 1 deletion js/build.templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions js/components/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Fliplet.FormBuilder.field('password', {
type: Boolean,
default: false
},
canShowPassword: {
type: Boolean,
default: false
},
passwordConfirmation: {
type: String,
default: ''
Expand Down Expand Up @@ -56,6 +60,7 @@ Fliplet.FormBuilder.field('password', {
data: function() {
return {
isFocused: false,
isShowPassword: false,
passwordMinLength: 8,
defaultClass: 'panel-default',
invalidClass: 'panel-danger',
Expand Down Expand Up @@ -141,6 +146,10 @@ Fliplet.FormBuilder.field('password', {
this.value = oldVal;
this.updateValue();
}

if (!newVal) {
this.isShowPassword = false;
}
},
'$v.passwordConfirmation.$invalid': function(value) {
if (!value) {
Expand Down
2 changes: 1 addition & 1 deletion js/interface.templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion templates/components/password.build.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div v-if="description" class="help-block description">\{{ description }}</div>
<input
type="password"
:type="isShowPassword ? 'text' : 'password'"
class="form-control focus-outline"
:readonly="autogenerate"
autocomplete="new-password"
Expand All @@ -14,6 +14,7 @@
:placeholder="fieldPlaceholder"
tabindex="0"
/>
<i v-if="canShowPassword && value" class="fa" :class="isShowPassword ? 'fa-eye-slash' : 'fa-eye'" v-on:click="isShowPassword = !isShowPassword"></i>
<p class="text-danger" v-if="$v.value.required === false && $v.value.$dirty">Field is required.</p>

<div v-if="isFocused || $v.value.$model" class="panel password-checker" :class="validationClass.password">
Expand Down
16 changes: 14 additions & 2 deletions templates/configurations/password.interface.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
<div class="form-group" v-if="!autogenerate">
<label>Ask users to confirm the password before submitting?</label>
<div class="radio radio-icon">
<input type="radio" id="confirm-yes" name="confirm-option" v-bind:value="true" v-model="confirm">
<input type="radio" id="confirm-yes" name="confirm-option" v-bind:value="true" v-model="confirm" :disabled="canShowPassword">
<label for="confirm-yes">
<span class="check"><i class="fa fa-circle"></i></span> <strong>Yes</strong> - Add a password confirmation field
<span class="check"><i class="fa fa-circle"></i></span> <strong :class="{ 'text-muted': canShowPassword }">Yes</strong> - Add a password confirmation field
</label>
</div>
<div class="radio radio-icon">
Expand All @@ -60,3 +60,15 @@
</label>
</div>
</div>

<div class="form-group">
<label>Do you want to allow users to show/hide their password when typing?</label>
<p class="help-block"><small>An icon will be shown in the password field, allowing users to toggle between masked characters and plain text.</small></p>
<div class="checkbox checkbox-icon password-show-checkbox">
<input type="checkbox" :name="name" v-model="canShowPassword" id="password-show-checkbox" :disabled="confirm">
<label for="password-show-checkbox">
<span class="check"><i class="fa fa-check"></i></span>
<span class="hide-field" :class="{ 'text-muted': confirm }">Yes, please.</span>
</label>
</div>
</div>