feat: let's control alignment

This commit is contained in:
git-avc 2026-01-13 23:01:16 +01:00
parent 43393bc4f6
commit bfb8ccb628
3 changed files with 19 additions and 1 deletions

View file

@ -72,6 +72,7 @@
"mandatory_depends_on",
"read_only_depends_on",
"display",
"alignment",
"print_width",
"width",
"max_height",
@ -475,6 +476,13 @@
"max_height": "3rem",
"options": "JS"
},
{
"depends_on": "eval:in_list([\"Data\", \"Int\", \"Float\"], doc.fieldtype)",
"fieldname": "alignment",
"fieldtype": "Select",
"label": "Alignment",
"options": "\nLeft\nCenter\nRight"
},
{
"fieldname": "column_break_38",
"fieldtype": "Column Break"

View file

@ -165,7 +165,13 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
let doc = this.doc || (this.frm && this.frm.doc);
let display_value = frappe.format(value, this.df, { no_icon: true, inline: true }, doc);
// This is used to display formatted output AND showing values in read only fields
this.disp_area && $(this.disp_area).html(display_value);
if (this.disp_area) {
$(this.disp_area).html(display_value);
// Apply alignment for Data, Int, Float fields
if (this.df.alignment && ["Data", "Int", "Float"].includes(this.df.fieldtype)) {
$(this.disp_area).css("text-align", this.df.alignment.toLowerCase());
}
}
}
set_label(label) {
if (label) this.df.label = label;

View file

@ -251,6 +251,10 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp
if (this.df.input_class) {
this.$input.addClass(this.df.input_class);
}
// Apply alignment if specified
if (this.df.alignment) {
this.$input.css("text-align", this.df.alignment.toLowerCase());
}
}
set_input(value) {
this.last_value = this.value;