mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 10:54:30 +08:00
truncate and display text in tooltip in custom repository fields
This commit is contained in:
parent
3df034ff21
commit
a195c9a5af
4 changed files with 23 additions and 4 deletions
|
@ -355,6 +355,13 @@ function initHeaderTooltip() {
|
|||
offsetLeft -= 150;
|
||||
}
|
||||
var offsetTop = $tooltip.offset().top;
|
||||
var width = 200;
|
||||
|
||||
// set tooltip params in the table body
|
||||
if ( $(this).parents('#repository-table').length ) {
|
||||
offsetLeft -= 130;
|
||||
width = $('#repository-table').width() - 200;
|
||||
}
|
||||
$('body').append($tooltip);
|
||||
$tooltip.css('background-color', '#d2d2d2');
|
||||
$tooltip.css('border-radius', '6px');
|
||||
|
@ -366,7 +373,7 @@ function initHeaderTooltip() {
|
|||
$tooltip.css('text-align', 'center');
|
||||
$tooltip.css('top', offsetTop + 'px');
|
||||
$tooltip.css('visibility', 'visible');
|
||||
$tooltip.css('width', '200px');
|
||||
$tooltip.css('width', width + 'px');
|
||||
$tooltip.css('word-wrap', 'break-word');
|
||||
$(this).data('dropdown-tooltip', $tooltip);
|
||||
}, function() {
|
||||
|
@ -431,12 +438,14 @@ function onClickAddRecord() {
|
|||
viewAssigned = 'assigned';
|
||||
table.ajax.reload(function() {
|
||||
initRowSelection();
|
||||
initHeaderTooltip();
|
||||
}, false);
|
||||
});
|
||||
$('#all-repo-records').on('click', function() {
|
||||
viewAssigned = 'all';
|
||||
table.ajax.reload(function() {
|
||||
initRowSelection();
|
||||
initHeaderTooltip();
|
||||
}, false);
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -1576,6 +1576,11 @@ table.dataTable {
|
|||
visibility: visible;
|
||||
}
|
||||
|
||||
// don't display tooltip, it's handeled with js
|
||||
.repository-table .modal-tooltip:hover .modal-tooltiptext {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
// Comments
|
||||
|
||||
.comment-more {
|
||||
|
|
|
@ -118,9 +118,12 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
|||
# Add custom columns
|
||||
record.repository_cells.each do |cell|
|
||||
row[@columns_mappings[cell.repository_column.id]] =
|
||||
custom_auto_link(cell.value.data,
|
||||
custom_auto_link(
|
||||
display_tooltip(cell.value.data,
|
||||
Constants::TABLE_FIELDS_TRUNCATION_LENGTH),
|
||||
simple_format: true,
|
||||
team: @team)
|
||||
team: @team
|
||||
)
|
||||
end
|
||||
row
|
||||
end
|
||||
|
|
|
@ -11,6 +11,8 @@ class Constants
|
|||
NAME_TRUNCATION_LENGTH = 25
|
||||
# Max characters for short text fields, in dropdownList
|
||||
NAME_TRUNCATION_LENGTH_DROPDOWN = 20
|
||||
# Max characters for datatables fields
|
||||
TABLE_FIELDS_TRUNCATION_LENGTH = 250
|
||||
# Max characters for long text fields
|
||||
TEXT_MAX_LENGTH = 10000
|
||||
# Max characters for rich text fields (in html format)
|
||||
|
|
Loading…
Add table
Reference in a new issue