feat: let's control alignment
This commit is contained in:
parent
43393bc4f6
commit
bfb8ccb628
3 changed files with 19 additions and 1 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue