mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
webui: remove column sizing in tables, use PF styles
https://fedorahosted.org/freeipa/ticket/4136 usage of .table-striped class also fixes: https://fedorahosted.org/freeipa/ticket/3050 Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
parent
4333161ac3
commit
0e15a282e8
@ -563,7 +563,7 @@ aci.attributes_widget = function(spec) {
|
|||||||
that.$node = that.table = $('<table/>', {
|
that.$node = that.table = $('<table/>', {
|
||||||
id: id,
|
id: id,
|
||||||
name: that.name,
|
name: that.name,
|
||||||
'class': 'search-table aci-attribute-table scrollable'
|
'class': 'table table-bordered table-condensed aci-attribute-table scrollable'
|
||||||
}).
|
}).
|
||||||
append('<thead/>').
|
append('<thead/>').
|
||||||
append('<tbody/>').
|
append('<tbody/>').
|
||||||
|
@ -1955,12 +1955,11 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
|
|||||||
that.init_table = function(entity) {
|
that.init_table = function(entity) {
|
||||||
|
|
||||||
that.table = IPA.table_widget({
|
that.table = IPA.table_widget({
|
||||||
'class': 'content-table',
|
|
||||||
name: that.table_name || entity.metadata.primary_key,
|
name: that.table_name || entity.metadata.primary_key,
|
||||||
label: entity.metadata.label,
|
label: entity.metadata.label,
|
||||||
entity: entity,
|
entity: entity,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
scrollable: true,
|
scrollable: false,
|
||||||
selectable: that.selectable && !that.read_only
|
selectable: that.selectable && !that.read_only
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2372,10 +2372,10 @@ IPA.table_widget = function (spec) {
|
|||||||
|
|
||||||
that.widget_create(container);
|
that.widget_create(container);
|
||||||
|
|
||||||
container.addClass('table-widget');
|
container.addClass('table-widget table-responsive');
|
||||||
|
|
||||||
that.table = $('<table/>', {
|
that.table = $('<table/>', {
|
||||||
'class': 'search-table',
|
'class': 'content-table table table-condensed table-striped table-bordered',
|
||||||
name: that.name
|
name: that.name
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
|
|
||||||
@ -2414,58 +2414,15 @@ IPA.table_widget = function (spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var columns = that.columns.values;
|
var columns = that.columns.values;
|
||||||
var column;
|
|
||||||
|
|
||||||
var columns_without_width = 0;
|
|
||||||
var per_column_space = 16; //cell padding(2x6px), border (2x1px), spacing (2px)
|
|
||||||
var available_width = that.thead.width();
|
|
||||||
available_width -= 2; //first cell spacing
|
|
||||||
|
|
||||||
//subtract checkbox column
|
|
||||||
if(that.selectable) {
|
|
||||||
available_width -= IPA.checkbox_column_width;
|
|
||||||
available_width -= per_column_space;
|
|
||||||
}
|
|
||||||
|
|
||||||
//subtract width of columns with their width set
|
|
||||||
for (i=0; i<columns.length; i++) {
|
|
||||||
column = columns[i];
|
|
||||||
if (column.width) {
|
|
||||||
available_width -= parseInt(
|
|
||||||
column.width.substring(0, column.width.length-2),10);
|
|
||||||
available_width -= per_column_space;
|
|
||||||
} else {
|
|
||||||
columns_without_width++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//width for columns without width set
|
|
||||||
var new_column_width = (available_width -
|
|
||||||
per_column_space * columns_without_width) /
|
|
||||||
columns_without_width;
|
|
||||||
|
|
||||||
|
|
||||||
//set the new width, now all columns should have width set
|
|
||||||
for (i=0; i<columns.length; i++) {
|
|
||||||
column = columns[i];
|
|
||||||
if (!column.width) {
|
|
||||||
column.width = new_column_width+"px";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i<columns.length; i++) {
|
for (i=0; i<columns.length; i++) {
|
||||||
column = columns[i];
|
var column = columns[i];
|
||||||
|
|
||||||
th = $('<th/>').appendTo(tr);
|
th = $('<th/>').appendTo(tr);
|
||||||
|
|
||||||
th.css('width', column.width);
|
|
||||||
th.css('max-width', column.width);
|
|
||||||
|
|
||||||
var label = column.label;
|
|
||||||
|
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'style': 'float: left;',
|
'html': column.label,
|
||||||
'html': label
|
'style': 'float: left;'
|
||||||
}).appendTo(th);
|
}).appendTo(th);
|
||||||
|
|
||||||
if (i == columns.length-1) {
|
if (i == columns.length-1) {
|
||||||
@ -2495,12 +2452,19 @@ IPA.table_widget = function (spec) {
|
|||||||
that.tbody.css('height', that.height);
|
that.tbody.css('height', that.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.create_footer();
|
||||||
|
|
||||||
|
that.set_enabled(that.enabled);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create_footer = function() {
|
||||||
|
|
||||||
that.tfoot = $('<tfoot/>').appendTo(that.table);
|
that.tfoot = $('<tfoot/>').appendTo(that.table);
|
||||||
|
|
||||||
tr = $('<tr/>').appendTo(that.tfoot);
|
var tr = $('<tr/>').appendTo(that.tfoot);
|
||||||
|
|
||||||
var td = $('<td/>', {
|
var td = $('<td/>', {
|
||||||
colspan: columns.length + (that.selectable ? 1 : 0)
|
colspan: that.columns.values.length + (that.selectable ? 1 : 0)
|
||||||
}).appendTo(tr);
|
}).appendTo(tr);
|
||||||
|
|
||||||
that.create_error_link(td);
|
that.create_error_link(td);
|
||||||
@ -2509,55 +2473,57 @@ IPA.table_widget = function (spec) {
|
|||||||
'name': 'summary'
|
'name': 'summary'
|
||||||
}).appendTo(td);
|
}).appendTo(td);
|
||||||
|
|
||||||
|
if (that.pagination) {
|
||||||
|
that.create_pagination(td);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create_pagination = function(container) {
|
||||||
|
|
||||||
that.pagination_control = $('<span/>', {
|
that.pagination_control = $('<span/>', {
|
||||||
'class': 'pagination-control'
|
'class': 'pagination-control'
|
||||||
}).appendTo(td);
|
}).appendTo(container);
|
||||||
|
|
||||||
if (that.pagination) {
|
$('<a/>', {
|
||||||
|
text: text.get('@i18n:widget.prev'),
|
||||||
|
name: 'prev_page',
|
||||||
|
click: function() {
|
||||||
|
that.prev_page();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).appendTo(that.pagination_control);
|
||||||
|
|
||||||
$('<a/>', {
|
that.pagination_control.append(' ');
|
||||||
text: text.get('@i18n:widget.prev'),
|
|
||||||
name: 'prev_page',
|
$('<a/>', {
|
||||||
click: function() {
|
text: text.get('@i18n:widget.next'),
|
||||||
that.prev_page();
|
name: 'next_page',
|
||||||
return false;
|
click: function() {
|
||||||
|
that.next_page();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).appendTo(that.pagination_control);
|
||||||
|
|
||||||
|
that.pagination_control.append(' ');
|
||||||
|
that.pagination_control.append(text.get('@i18n:widget.page'));
|
||||||
|
that.pagination_control.append(': ');
|
||||||
|
|
||||||
|
that.current_page_input = $('<input/>', {
|
||||||
|
type: 'text',
|
||||||
|
name: 'current_page',
|
||||||
|
keypress: function(e) {
|
||||||
|
if (e.which == 13) {
|
||||||
|
var page = parseInt(that.current_page_input.val(), 10) || 1;
|
||||||
|
that.set_page(page);
|
||||||
}
|
}
|
||||||
}).appendTo(that.pagination_control);
|
}
|
||||||
|
}).appendTo(that.pagination_control);
|
||||||
|
|
||||||
that.pagination_control.append(' ');
|
that.pagination_control.append(' / ');
|
||||||
|
|
||||||
$('<a/>', {
|
that.total_pages_span = $('<span/>', {
|
||||||
text: text.get('@i18n:widget.next'),
|
name: 'total_pages'
|
||||||
name: 'next_page',
|
}).appendTo(that.pagination_control);
|
||||||
click: function() {
|
|
||||||
that.next_page();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).appendTo(that.pagination_control);
|
|
||||||
|
|
||||||
that.pagination_control.append(' ');
|
|
||||||
that.pagination_control.append(text.get('@i18n:widget.page'));
|
|
||||||
that.pagination_control.append(': ');
|
|
||||||
|
|
||||||
that.current_page_input = $('<input/>', {
|
|
||||||
type: 'text',
|
|
||||||
name: 'current_page',
|
|
||||||
keypress: function(e) {
|
|
||||||
if (e.which == 13) {
|
|
||||||
var page = parseInt(that.current_page_input.val(), 10) || 1;
|
|
||||||
that.set_page(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).appendTo(that.pagination_control);
|
|
||||||
|
|
||||||
that.pagination_control.append(' / ');
|
|
||||||
|
|
||||||
that.total_pages_span = $('<span/>', {
|
|
||||||
name: 'total_pages'
|
|
||||||
}).appendTo(that.pagination_control);
|
|
||||||
}
|
|
||||||
|
|
||||||
that.set_enabled(that.enabled);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2570,6 +2536,7 @@ IPA.table_widget = function (spec) {
|
|||||||
var td;
|
var td;
|
||||||
|
|
||||||
if (that.selectable) {
|
if (that.selectable) {
|
||||||
|
|
||||||
td = $('<td/>', {
|
td = $('<td/>', {
|
||||||
'style': 'width: '+ (IPA.checkbox_column_width + 7) +'px;'
|
'style': 'width: '+ (IPA.checkbox_column_width + 7) +'px;'
|
||||||
}).appendTo(row);
|
}).appendTo(row);
|
||||||
@ -2589,14 +2556,6 @@ IPA.table_widget = function (spec) {
|
|||||||
var column = columns[i];
|
var column = columns[i];
|
||||||
|
|
||||||
td = $('<td/>').appendTo(row);
|
td = $('<td/>').appendTo(row);
|
||||||
if (column.width) {
|
|
||||||
width = parseInt(
|
|
||||||
column.width.substring(0, column.width.length-2),10);
|
|
||||||
width += 7; //data cells lack right padding
|
|
||||||
width += 'px';
|
|
||||||
td.css('width', width);
|
|
||||||
td.css('max-width', width);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'name': column.name
|
'name': column.name
|
||||||
|
@ -917,7 +917,7 @@ class UI_driver(object):
|
|||||||
s = "table"
|
s = "table"
|
||||||
if name:
|
if name:
|
||||||
s += "[name='%s']" % name
|
s += "[name='%s']" % name
|
||||||
s += '.search-table'
|
s += '.table'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def select_record(self, pkey, parent=None, table_name=None):
|
def select_record(self, pkey, parent=None, table_name=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user