fix: pre commit issues
This commit is contained in:
@@ -1,39 +1,49 @@
|
||||
frappe.ready(function () {
|
||||
frappe.web_form.after_save = () => {
|
||||
let data = frappe.web_form.get_values();
|
||||
let slug = new URLSearchParams(window.location.search).get("slug")
|
||||
frappe.msgprint({
|
||||
message: __("Batch {0} has been successfully created!", [data.title]),
|
||||
clear: true
|
||||
});
|
||||
setTimeout(function () {
|
||||
window.location.href = `courses/${slug}`;
|
||||
}, 2000);
|
||||
}
|
||||
frappe.web_form.after_save = () => {
|
||||
let data = frappe.web_form.get_values();
|
||||
let slug = new URLSearchParams(window.location.search).get("slug");
|
||||
frappe.msgprint({
|
||||
message: __("Batch {0} has been successfully created!", [
|
||||
data.title,
|
||||
]),
|
||||
clear: true,
|
||||
});
|
||||
setTimeout(function () {
|
||||
window.location.href = `courses/${slug}`;
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
frappe.web_form.validate = () => {
|
||||
let sysdefaults = frappe.boot.sysdefaults;
|
||||
let time_format = sysdefaults && sysdefaults.time_format ? sysdefaults.time_format : 'HH:mm:ss';
|
||||
let data = frappe.web_form.get_values();
|
||||
frappe.web_form.validate = () => {
|
||||
let sysdefaults = frappe.boot.sysdefaults;
|
||||
let time_format =
|
||||
sysdefaults && sysdefaults.time_format
|
||||
? sysdefaults.time_format
|
||||
: "HH:mm:ss";
|
||||
let data = frappe.web_form.get_values();
|
||||
|
||||
data.start_time = moment(data.start_time, time_format).format(time_format)
|
||||
data.end_time = moment(data.end_time, time_format).format(time_format)
|
||||
data.start_time = moment(data.start_time, time_format).format(
|
||||
time_format
|
||||
);
|
||||
data.end_time = moment(data.end_time, time_format).format(time_format);
|
||||
|
||||
if (data.start_date < frappe.datetime.nowdate()) {
|
||||
frappe.msgprint(__('Start date cannot be a past date.'))
|
||||
return false;
|
||||
}
|
||||
if (data.start_date < frappe.datetime.nowdate()) {
|
||||
frappe.msgprint(__("Start date cannot be a past date."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!frappe.datetime.validate(data.start_time) || !frappe.datetime.validate(data.end_time)) {
|
||||
frappe.msgprint(__('Invalid Start or End Time.'));
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!frappe.datetime.validate(data.start_time) ||
|
||||
!frappe.datetime.validate(data.end_time)
|
||||
) {
|
||||
frappe.msgprint(__("Invalid Start or End Time."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.start_time > data.end_time) {
|
||||
frappe.msgprint(__('Start Time should be less than End Time.'));
|
||||
return false;
|
||||
}
|
||||
if (data.start_time > data.end_time) {
|
||||
frappe.msgprint(__("Start Time should be less than End Time."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
})
|
||||
return true;
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
# do your magic here
|
||||
pass
|
||||
|
||||
@@ -1,85 +1,96 @@
|
||||
frappe.ready(function () {
|
||||
frappe.web_form.after_load = () => {
|
||||
redirect_to_user_profile_form();
|
||||
add_listener_for_current_company();
|
||||
add_listener_for_certificate_expiry();
|
||||
add_listener_for_skill_add_rows();
|
||||
add_listener_for_functions_add_rows();
|
||||
add_listener_for_industries_add_rows();
|
||||
};
|
||||
|
||||
frappe.web_form.after_load = () => {
|
||||
|
||||
redirect_to_user_profile_form();
|
||||
add_listener_for_current_company();
|
||||
add_listener_for_certificate_expiry();
|
||||
add_listener_for_skill_add_rows();
|
||||
add_listener_for_functions_add_rows();
|
||||
add_listener_for_industries_add_rows();
|
||||
|
||||
}
|
||||
|
||||
frappe.web_form.validate = () => {
|
||||
let information_missing;
|
||||
const data = frappe.web_form.get_values();
|
||||
if (data && data.work_experience && data.work_experience.length) {
|
||||
data.work_experience.forEach(exp => {
|
||||
if (!exp.current && !exp.to_date) {
|
||||
information_missing = true
|
||||
frappe.msgprint('To Date is mandatory in Work Experience.');
|
||||
frappe.web_form.validate = () => {
|
||||
let information_missing;
|
||||
const data = frappe.web_form.get_values();
|
||||
if (data && data.work_experience && data.work_experience.length) {
|
||||
data.work_experience.forEach((exp) => {
|
||||
if (!exp.current && !exp.to_date) {
|
||||
information_missing = true;
|
||||
frappe.msgprint("To Date is mandatory in Work Experience.");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (information_missing)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
if (information_missing) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
frappe.web_form.after_save = () => {
|
||||
setTimeout(() => {
|
||||
window.location.href = `/profile_/${frappe.web_form.get_value(["username"])}`;
|
||||
})
|
||||
}
|
||||
frappe.web_form.after_save = () => {
|
||||
setTimeout(() => {
|
||||
window.location.href = `/profile_/${frappe.web_form.get_value([
|
||||
"username",
|
||||
])}`;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
const redirect_to_user_profile_form = () => {
|
||||
if (!frappe.utils.get_url_arg("name")) {
|
||||
window.location.href = `/edit-profile?name=${frappe.session.user}`;
|
||||
}
|
||||
if (!frappe.utils.get_url_arg("name")) {
|
||||
window.location.href = `/edit-profile?name=${frappe.session.user}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const add_listener_for_current_company = () => {
|
||||
$(document).on("click", "input[data-fieldname='current']", (e) => {
|
||||
if ($(e.currentTarget).prop("checked"))
|
||||
$("div[data-fieldname='to_date']").addClass("hide");
|
||||
else
|
||||
$("div[data-fieldname='to_date']").removeClass("hide");
|
||||
});
|
||||
$(document).on("click", "input[data-fieldname='current']", (e) => {
|
||||
if ($(e.currentTarget).prop("checked"))
|
||||
$("div[data-fieldname='to_date']").addClass("hide");
|
||||
else $("div[data-fieldname='to_date']").removeClass("hide");
|
||||
});
|
||||
};
|
||||
|
||||
const add_listener_for_certificate_expiry = () => {
|
||||
$(document).on("click", "input[data-fieldname='expire']", (e) => {
|
||||
if ($(e.currentTarget).prop("checked"))
|
||||
$("div[data-fieldname='expiration_date']").addClass("hide");
|
||||
else
|
||||
$("div[data-fieldname='expiration_date']").removeClass("hide");
|
||||
});
|
||||
$(document).on("click", "input[data-fieldname='expire']", (e) => {
|
||||
if ($(e.currentTarget).prop("checked"))
|
||||
$("div[data-fieldname='expiration_date']").addClass("hide");
|
||||
else $("div[data-fieldname='expiration_date']").removeClass("hide");
|
||||
});
|
||||
};
|
||||
|
||||
const add_listener_for_skill_add_rows = () => {
|
||||
$('[data-fieldname="skill"]').find(".grid-add-row").click((e) => {
|
||||
if ($('[data-fieldname="skill"]').find(".grid-row").length > 5) {
|
||||
$('[data-fieldname="skill"]').find(".grid-add-row").hide();
|
||||
}
|
||||
});
|
||||
$('[data-fieldname="skill"]')
|
||||
.find(".grid-add-row")
|
||||
.click((e) => {
|
||||
if ($('[data-fieldname="skill"]').find(".grid-row").length > 5) {
|
||||
$('[data-fieldname="skill"]').find(".grid-add-row").hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const add_listener_for_functions_add_rows = () => {
|
||||
$('[data-fieldname="preferred_functions"]').find(".grid-add-row").click((e) => {
|
||||
if ($('[data-fieldname="preferred_functions"]').find(".grid-row").length > 3) {
|
||||
$('[data-fieldname="preferred_functions"]').find(".grid-add-row").hide();
|
||||
}
|
||||
});
|
||||
$('[data-fieldname="preferred_functions"]')
|
||||
.find(".grid-add-row")
|
||||
.click((e) => {
|
||||
if (
|
||||
$('[data-fieldname="preferred_functions"]').find(".grid-row")
|
||||
.length > 3
|
||||
) {
|
||||
$('[data-fieldname="preferred_functions"]')
|
||||
.find(".grid-add-row")
|
||||
.hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const add_listener_for_industries_add_rows = () => {
|
||||
$('[data-fieldname="preferred_industries"]').find(".grid-add-row").click((e) => {
|
||||
if ($('[data-fieldname="preferred_industries"]').find(".grid-row").length > 3) {
|
||||
$('[data-fieldname="preferred_industries"]').find(".grid-add-row").hide();
|
||||
}
|
||||
});
|
||||
$('[data-fieldname="preferred_industries"]')
|
||||
.find(".grid-add-row")
|
||||
.click((e) => {
|
||||
if (
|
||||
$('[data-fieldname="preferred_industries"]').find(".grid-row")
|
||||
.length > 3
|
||||
) {
|
||||
$('[data-fieldname="preferred_industries"]')
|
||||
.find(".grid-add-row")
|
||||
.hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user