mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Merge pull request #1192 from ZmagoD/zd_SCI_2435
removes visibility toggle from Name column [fixes SCI-2435]
This commit is contained in:
commit
e06ab02f68
3 changed files with 46 additions and 28 deletions
|
@ -87,6 +87,7 @@ var RepositoryDatatable = (function(global) {
|
|||
}, {
|
||||
// Name column is clickable
|
||||
targets: 3,
|
||||
visible: true,
|
||||
render: function(data, type, row) {
|
||||
return "<a href='" + row.recordInfoUrl + "'" +
|
||||
"class='record-info-link'>" + data + '</a>';
|
||||
|
@ -1129,10 +1130,11 @@ var RepositoryDatatable = (function(global) {
|
|||
listItem.addClass(visLi);
|
||||
listItem.removeClass('repository-columns-list-template hide');
|
||||
listItem.find('.text').html(generateColumnNameTooltip(thederName));
|
||||
listItem.find('.vis').addClass(visClass);
|
||||
listItem.find('.vis')
|
||||
.attr('title', $(TABLE_ID).data('columns-visibility-text'));
|
||||
|
||||
if(thederName !== 'Name') {
|
||||
listItem.find('.vis').addClass(visClass);
|
||||
listItem.find('.vis')
|
||||
.attr('title', $(TABLE_ID).data('columns-visibility-text'));
|
||||
}
|
||||
dropdownList.append(listItem);
|
||||
}
|
||||
});
|
||||
|
@ -1164,20 +1166,21 @@ var RepositoryDatatable = (function(global) {
|
|||
var li = self.closest('li');
|
||||
var column = TABLE.column(li.attr('data-position'));
|
||||
|
||||
if (column.visible()) {
|
||||
self.addClass('fa-eye-slash');
|
||||
self.removeClass('fa-eye');
|
||||
li.addClass('col-invisible');
|
||||
column.visible(false);
|
||||
TABLE.setColumnSearchable(column.index(), false);
|
||||
} else {
|
||||
self.addClass('fa-eye');
|
||||
self.removeClass('fa-eye-slash');
|
||||
li.removeClass('col-invisible');
|
||||
column.visible(true);
|
||||
TABLE.setColumnSearchable(column.index(), true);
|
||||
if(column.header.id !== 'row-name') {
|
||||
if (column.visible()) {
|
||||
self.addClass('fa-eye-slash');
|
||||
self.removeClass('fa-eye');
|
||||
li.addClass('col-invisible');
|
||||
column.visible(false);
|
||||
TABLE.setColumnSearchable(column.index(), false);
|
||||
} else {
|
||||
self.addClass('fa-eye');
|
||||
self.removeClass('fa-eye-slash');
|
||||
li.removeClass('col-invisible');
|
||||
column.visible(true);
|
||||
TABLE.setColumnSearchable(column.index(), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-filter/search if neccesary
|
||||
var searchText = $('div.dataTables_filter input').val();
|
||||
if (!_.isEmpty(searchText)) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
namespace :clear_repository_rows_and_columns_without_repository do
|
||||
desc 'Removes all repository rows/columns and ' \
|
||||
'referenced entities with dependent: destroy'
|
||||
task run: :environment do
|
||||
repository_ids = Repository.select(:id)
|
||||
RepositoryColumn.skip_callback(:destroy, :around, :update_repository_table_states_with_removed_column)
|
||||
RepositoryRow.where.not(repository_id: repository_ids).destroy_all
|
||||
RepositoryColumn.where.not(repository_id: repository_ids).destroy_all
|
||||
RepositoryColumn.set_callback(:destroy, :around, :update_repository_table_states_with_removed_column)
|
||||
end
|
||||
end
|
26
lib/tasks/repositories.rake
Normal file
26
lib/tasks/repositories.rake
Normal file
|
@ -0,0 +1,26 @@
|
|||
namespace :repositories do
|
||||
desc 'Removes all repository rows/columns and ' \
|
||||
'referenced entities with dependent: destroy'
|
||||
task remove_rows_and_columns_without_repository: :environment do
|
||||
repository_ids = Repository.select(:id)
|
||||
RepositoryColumn.skip_callback(
|
||||
:destroy, :around, :update_repository_table_states_with_removed_column
|
||||
)
|
||||
RepositoryRow.where.not(repository_id: repository_ids).destroy_all
|
||||
RepositoryColumn.where.not(repository_id: repository_ids).destroy_all
|
||||
RepositoryColumn.set_callback(
|
||||
:destroy, :around, :update_repository_table_states_with_removed_column
|
||||
)
|
||||
end
|
||||
|
||||
desc 'Set\'s the Name column visibility value to true. Needed if ' \
|
||||
'the user has the Name column hidden when [SCI-2435] is merged. ' \
|
||||
'Check: https://github.com/biosistemika/scinote-web/commits/master'
|
||||
task set_name_column_visibility: :environment do
|
||||
RepositoryTableState.find_each do |repository_table_state|
|
||||
next unless repository_table_state.state['columns']['3']
|
||||
repository_table_state.state['columns']['3']['visible'] = 'true'
|
||||
repository_table_state.save
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue