Display sum on column header

Closes #8134
This commit is contained in:
Cédric Krier
2023-04-10 01:34:19 +02:00
parent 5335a2022d
commit 63e6036c04
4 changed files with 22 additions and 20 deletions
+3
View File
@@ -496,6 +496,9 @@ img.icon {
& > label {
display: none;
}
& > div.value {
white-space: pre;
}
}
> tbody > tr > td {
cursor: pointer;
+4 -5
View File
@@ -113,11 +113,10 @@
}
if (Boolean(parseInt(attributes.sum || '0', 10))) {
var label = attributes.string + Sao.i18n.gettext(': ');
var sum = jQuery('<label/>', {
'text': label,
'text': attributes.string,
});
var aggregate = jQuery('<span/>', {
var aggregate = jQuery('<div/>', {
'class': 'value',
});
this.view.sum_widgets.set(column, [sum, aggregate]);
@@ -1067,11 +1066,11 @@
sum_ = (sum_ || 0).toLocaleString(
Sao.i18n.BC47(Sao.i18n.getlang()), options);
}
aggregate = selected_sum + ' / ' + sum_;
aggregate = selected_sum + '\n' + sum_;
}
sum_value.text(aggregate);
sum_value.parent().attr(
'title', sum_label.text() + ' ' + sum_value.text());
'title', sum_label.text() + '\n' + sum_value.text());
}
},
get selected_records() {
+1
View File
@@ -1,3 +1,4 @@
* Display sum on column header
Version 6.8.0 - 2023-05-01
--------------------------
+14 -15
View File
@@ -337,19 +337,6 @@ class TreeXMLViewParser(XMLViewParser):
if 'optional' in attributes:
self.view.optionals.append(column)
if bool(int(attributes.get('sum', 0))):
text = attributes['string'] + _(':')
label, sum_ = Gtk.Label(label=text), Gtk.Label()
hbox = Gtk.HBox()
hbox.pack_start(label, expand=True, fill=False, padding=2)
hbox.pack_start(sum_, expand=True, fill=False, padding=2)
hbox.show_all()
self.view.sum_box.pack_start(
hbox, expand=False, fill=False, padding=0)
self.view.sum_widgets.append((attributes['name'], sum_))
def _parse_button(self, node, attributes):
button = Button(self.view, attributes)
self.view.state_widgets.append(button)
@@ -392,7 +379,19 @@ class TreeXMLViewParser(XMLViewParser):
hbox.pack_start(arrow_widget, expand=False, fill=False, padding=0)
column.set_clickable(True)
hbox.show()
column.set_widget(hbox)
if bool(int(attributes.get('sum', 0))):
vbox = Gtk.VBox(homogeneous=False, spacing=0)
vbox.pack_start(hbox, expand=False, fill=True, padding=0)
sum_ = Gtk.Label()
sum_.set_justify(Gtk.Justification.RIGHT)
sum_.show()
vbox.pack_start(sum_, expand=False, fill=True, padding=0)
self.view.sum_widgets.append((attributes['name'], sum_))
vbox.show()
widget = vbox
else:
widget = hbox
column.set_widget(widget)
column.set_alignment(align)
def _set_column_width(self, column, attributes):
@@ -1205,7 +1204,7 @@ class ViewTree(View):
'{}'.format(selected_sum or 0), True)
sum_ = locale.localize('{}'.format(sum_ or 0), True)
text = '%s / %s' % (selected_sum, sum_)
text = '%s\n%s' % (selected_sum, sum_)
else:
text = '-'
label.set_text(text)