feat: Enhance Data Exporter and MultiCheck UI with warning titles and tooltips
This commit is contained in:
parent
041ab77e55
commit
9995bee63c
2 changed files with 29 additions and 10 deletions
|
|
@ -309,11 +309,17 @@ frappe.data_import.DataExporter = class DataExporter {
|
|||
if (autoname_field && df.fieldname == autoname_field.fieldname) {
|
||||
return true;
|
||||
}
|
||||
if (df.fieldname === "name") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
let get_info_title = (df) => {
|
||||
if (df.depends_on) {
|
||||
return __("Depends on: {0}", [df.depends_on]);
|
||||
}
|
||||
if (autoname_field && df.fieldname == autoname_field.fieldname) {
|
||||
return __("Autoname: {0}", [autoname_field.label]);
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
return fields
|
||||
.filter((df) => {
|
||||
|
|
@ -332,6 +338,7 @@ frappe.data_import.DataExporter = class DataExporter {
|
|||
value: df.fieldname,
|
||||
danger: is_field_mandatory(df),
|
||||
warning: is_field_depends_on(df),
|
||||
warning_title: get_info_title(df),
|
||||
include_in_import_template: !!df.include_in_import_template,
|
||||
checked: false,
|
||||
description: `${df.fieldname} ${df.reqd ? __("(Mandatory)") : ""}`,
|
||||
|
|
|
|||
|
|
@ -82,12 +82,10 @@ frappe.ui.form.ControlMultiCheck = class ControlMultiCheck extends frappe.ui.for
|
|||
}
|
||||
this.options.forEach((option) => {
|
||||
let checkbox = this.get_checkbox_element(option).appendTo(this.$checkbox_area);
|
||||
if (option.danger) {
|
||||
checkbox.find(".label-area").addClass("text-danger");
|
||||
}
|
||||
if (option.warning) {
|
||||
checkbox.find(".label-area").addClass("text-warning");
|
||||
}
|
||||
checkbox.find('[data-toggle="tooltip"]').tooltip({
|
||||
delay: { show: 600, hide: 100 },
|
||||
trigger: "hover",
|
||||
});
|
||||
|
||||
option.$checkbox = checkbox;
|
||||
});
|
||||
|
|
@ -165,11 +163,25 @@ frappe.ui.form.ControlMultiCheck = class ControlMultiCheck extends frappe.ui.for
|
|||
}
|
||||
|
||||
get_checkbox_element(option) {
|
||||
const mandatory_marker = option.danger
|
||||
? `<span class="text-danger" style="margin-left: 4px;">*</span>`
|
||||
: "";
|
||||
const warning_title = frappe.utils.escape_html(
|
||||
option.warning_title || __("Condition based field")
|
||||
);
|
||||
const warning_icon = option.warning
|
||||
? `<span class="text-muted" style="margin-left: 4px; display: inline-flex; align-items: center; vertical-align: middle; line-height: 1;" data-toggle="tooltip" title="${warning_title}">${frappe.utils.icon(
|
||||
"info",
|
||||
"xs"
|
||||
)}</span>`
|
||||
: "";
|
||||
return $(`
|
||||
<div class="checkbox unit-checkbox">
|
||||
<label title="${option.description || ""}" style="display: flex; align-items: center;">
|
||||
<input type="checkbox" data-unit="${option.value}" style="flex-shrink: 0;">
|
||||
<span class="label-area" data-unit="${option.value}">${option.label}</span>
|
||||
<span class="label-area" data-unit="${option.value}">${
|
||||
option.label
|
||||
}${mandatory_marker}${warning_icon}</span>
|
||||
</label>
|
||||
</div>
|
||||
`);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue