Merge branch 'develop' into grid-in-3-column-ux
This commit is contained in:
commit
aabe357ebf
4 changed files with 111 additions and 32 deletions
|
|
@ -88,8 +88,7 @@
|
|||
"fieldtype": "Link",
|
||||
"label": "Default User Role",
|
||||
"mandatory_depends_on": "eval: doc.default_user_type == \"System User\"",
|
||||
"options": "Role",
|
||||
"reqd": 1
|
||||
"options": "Role"
|
||||
},
|
||||
{
|
||||
"description": "Must be enclosed in '()' and include '{0}', which is a placeholder for the user/login name. i.e. (&(objectclass=user)(uid={0}))",
|
||||
|
|
@ -302,7 +301,7 @@
|
|||
"in_create": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-12-05 21:52:31.146035",
|
||||
"modified": "2023-01-24 11:20:06.049708",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Integrations",
|
||||
"name": "LDAP Settings",
|
||||
|
|
|
|||
|
|
@ -7,22 +7,49 @@ frappe.ui.form.ControlPassword = class ControlPassword extends frappe.ui.form.Co
|
|||
make_input() {
|
||||
var me = this;
|
||||
super.make_input();
|
||||
this.$input
|
||||
.parent()
|
||||
.append($('<span class="password-strength-indicator indicator"></span>'));
|
||||
this.$wrapper
|
||||
.find(".control-input-wrapper")
|
||||
.append($('<p class="password-strength-message text-muted small hidden"></p>'));
|
||||
|
||||
this.indicator = this.$wrapper.find(".password-strength-indicator");
|
||||
this.indicator = $(
|
||||
`<div class="password-strength-indicator hidden">
|
||||
<div class="progress-text"></div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar"
|
||||
aria-valuenow="0"
|
||||
aria-valuemin="0" aria-valuemax="100">
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
).insertAfter(this.$input);
|
||||
|
||||
this.progress_text = this.indicator.find(".progress-text");
|
||||
this.progress_bar = this.indicator.find(".progress-bar");
|
||||
this.message = this.$wrapper.find(".help-box");
|
||||
|
||||
this.$input.on("keyup", () => {
|
||||
clearTimeout(this.check_password_timeout);
|
||||
this.check_password_timeout = setTimeout(() => {
|
||||
this.$input.on(
|
||||
"keyup",
|
||||
frappe.utils.debounce(() => {
|
||||
let hide_icon = me.$input.val() && !me.$input.val().includes("*");
|
||||
me.toggle_password.toggleClass("hidden", !hide_icon);
|
||||
me.get_password_strength(me.$input.val());
|
||||
}, 500);
|
||||
}, 500)
|
||||
);
|
||||
|
||||
this.toggle_password = $(`
|
||||
<div class="toggle-password hidden">
|
||||
${frappe.utils.icon("unhide", "sm")}
|
||||
</div>
|
||||
`).insertAfter(this.$input);
|
||||
|
||||
this.toggle_password.on("click", () => {
|
||||
if (this.$input.attr("type") === "password") {
|
||||
this.$input.attr("type", "text");
|
||||
this.toggle_password.html(frappe.utils.icon("hide", "sm"));
|
||||
} else {
|
||||
this.$input.attr("type", "password");
|
||||
this.toggle_password.html(frappe.utils.icon("unhide", "sm"));
|
||||
}
|
||||
});
|
||||
|
||||
!this.value && this.toggle_password.removeClass("hidden");
|
||||
}
|
||||
|
||||
disable_password_checks() {
|
||||
|
|
@ -33,6 +60,13 @@ frappe.ui.form.ControlPassword = class ControlPassword extends frappe.ui.form.Co
|
|||
if (!this.enable_password_checks) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
this.indicator.addClass("hidden");
|
||||
this.message.addClass("hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
var me = this;
|
||||
frappe.call({
|
||||
type: "POST",
|
||||
|
|
@ -43,15 +77,34 @@ frappe.ui.form.ControlPassword = class ControlPassword extends frappe.ui.form.Co
|
|||
callback: function (r) {
|
||||
if (r.message) {
|
||||
let score = r.message.score;
|
||||
var indicators = ["red", "red", "orange", "yellow", "green"];
|
||||
var indicators = ["red", "red", "orange", "blue", "green"];
|
||||
me.set_strength_indicator(indicators[score]);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
set_strength_indicator(color) {
|
||||
var message = __("Include symbols, numbers and capital letters in the password");
|
||||
this.indicator.removeClass().addClass("password-strength-indicator indicator " + color);
|
||||
let strength = {
|
||||
red: [__("Weak"), "danger", 25],
|
||||
orange: [__("Average"), "warning", 50],
|
||||
blue: [__("Strong"), "info", 75],
|
||||
green: [__("Excellent"), "success", 100],
|
||||
};
|
||||
let progress_text = strength[color][0];
|
||||
let progress_color = strength[color][1];
|
||||
let progress_percent = strength[color][2];
|
||||
|
||||
this.indicator.removeClass("hidden");
|
||||
|
||||
this.progress_text.html(progress_text).css("color", `var(--${color}-500)`);
|
||||
|
||||
this.progress_bar
|
||||
.css("width", progress_percent + "%")
|
||||
.attr("aria-valuenow", progress_percent)
|
||||
.removeClass()
|
||||
.addClass("progress-bar progress-bar-" + progress_color);
|
||||
|
||||
let message = __("Include symbols, numbers and capital letters in the password");
|
||||
this.message.html(message).toggleClass("hidden", color == "green");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,20 +5,43 @@
|
|||
@import "phone_picker";
|
||||
|
||||
// password
|
||||
.form-control[data-fieldtype="Password"] {
|
||||
position: inherit;
|
||||
}
|
||||
.frappe-control[data-fieldtype="Password"] {
|
||||
.control-input-wrapper {
|
||||
position: relative;
|
||||
|
||||
.password-strength-indicator {
|
||||
// TODO: Review
|
||||
float: right;
|
||||
padding: 15px;
|
||||
margin-top: -41px;
|
||||
margin-right: -7px;
|
||||
}
|
||||
.form-control[data-fieldtype="Password"] {
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
.password-strength-message {
|
||||
margin-top: -10px;
|
||||
.password-strength-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
gap: 5px;
|
||||
top: -20px;
|
||||
right: 0px;
|
||||
|
||||
.progress-text {
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.progress {
|
||||
background-color: var(--bg-light-gray);
|
||||
width: 100px;
|
||||
height: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-password {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 8px;
|
||||
padding: 3px;
|
||||
z-index: 3;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// select
|
||||
|
|
@ -232,6 +255,10 @@ a.progress-small {
|
|||
background-color: var(--red-500);
|
||||
}
|
||||
|
||||
.progress-bar-info {
|
||||
background-color: var(--blue-500);
|
||||
}
|
||||
|
||||
.progress-bar-warning {
|
||||
background-color: var(--orange-500);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -742,9 +742,9 @@ cookie@^0.4.0, cookie@~0.4.1:
|
|||
integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==
|
||||
|
||||
cookiejar@^2.1.0:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c"
|
||||
integrity sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b"
|
||||
integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==
|
||||
|
||||
copy-anything@^2.0.1:
|
||||
version "2.0.3"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue