Add archived tags to assigned repository rows

This commit is contained in:
Urban Rotnik 2020-06-10 14:42:44 +02:00
parent 9dd5996122
commit 9bac0fb867
4 changed files with 33 additions and 2 deletions

View file

@ -69,12 +69,19 @@ var MyModuleRepositories = (function() {
} }
}, { }, {
targets: 3, targets: 3,
className: 'item-name',
render: function(data, type, row) { render: function(data, type, row) {
return "<a href='" + row.recordInfoUrl + "' class='record-info-link'>" + data + '</a>'; return "<a href='" + row.recordInfoUrl + "' class='record-info-link'>" + data + '</a>';
} }
}); });
} else {
columnDefs.push({
targets: 3,
className: 'item-name'
});
} }
columnDefs.push( columnDefs.push(
{ {
targets: '_all', targets: '_all',
@ -116,6 +123,7 @@ var MyModuleRepositories = (function() {
}, },
columnDefs: [{ columnDefs: [{
targets: 0, targets: 0,
className: 'item-name',
render: function(data, type, row) { render: function(data, type, row) {
return "<a href='" + row.recordInfoUrl + "'" return "<a href='" + row.recordInfoUrl + "'"
+ "class='record-info-link'>" + data + '</a>'; + "class='record-info-link'>" + data + '</a>';
@ -126,6 +134,11 @@ var MyModuleRepositories = (function() {
repositoryContainer.find('.table.dataTable').removeClass('hidden'); repositoryContainer.find('.table.dataTable').removeClass('hidden');
repositoryContainer.find('.version-label').html(tableContainer.data('version-label')); repositoryContainer.find('.version-label').html(tableContainer.data('version-label'));
SIMPLE_TABLE.columns.adjust(); SIMPLE_TABLE.columns.adjust();
},
rowCallback: function(row, data) {
if (data.archived) {
$(row).addClass('archived');
}
} }
}); });
} }
@ -205,7 +218,11 @@ var MyModuleRepositories = (function() {
}); });
}, },
rowCallback: function(row) { rowCallback: function(row, data) {
if (data.archived) {
$(row).addClass('archived');
}
var checkbox = $(row).find('.repository-row-selector'); var checkbox = $(row).find('.repository-row-selector');
if (SELECTED_ROWS[row.id]) { if (SELECTED_ROWS[row.id]) {
$(row).addClass('selected'); $(row).addClass('selected');

View file

@ -66,4 +66,15 @@
} }
} }
} }
tr.archived {
td.item-name::after {
background-color: $color-concrete;
color: $color-silver-chalice;
content: "Archived";
margin-left: 20px;
padding: .3em;
white-space: nowrap;
}
}
} }

View file

@ -12,6 +12,7 @@ module RepositoryDatatableHelper
'3': escape_input(record.name), '3': escape_input(record.name),
'4': I18n.l(record.created_at, format: :full), '4': I18n.l(record.created_at, format: :full),
'5': escape_input(record.created_by.full_name), '5': escape_input(record.created_by.full_name),
'archived': record.archived,
'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(repository, record) 'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(repository, record)
} }
@ -38,6 +39,7 @@ module RepositoryDatatableHelper
{ {
'DT_RowId': record.id, 'DT_RowId': record.id,
'0': escape_input(record.name), '0': escape_input(record.name),
'archived': record.archived,
'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(record.repository, record) 'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(record.repository, record)
} }
end end
@ -51,6 +53,7 @@ module RepositoryDatatableHelper
'2': escape_input(record.name), '2': escape_input(record.name),
'3': I18n.l(record.created_at, format: :full), '3': I18n.l(record.created_at, format: :full),
'4': escape_input(record.created_by.full_name), '4': escape_input(record.created_by.full_name),
'archived': record.archived,
'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(record.repository, record) 'recordInfoUrl': Rails.application.routes.url_helpers.repository_repository_row_path(record.repository, record)
} }

View file

@ -432,7 +432,7 @@ class MyModule < ApplicationRecord
rows.find_each do |row| rows.find_each do |row|
row_json = [] row_json = []
row_json << (row.repository.is_a?(RepositorySnapshot) ? row.parent_id : row.id) row_json << (row.repository.is_a?(RepositorySnapshot) ? row.parent_id : row.id)
row_json << row.name row_json << (row.archived ? "#{row.name} [Archived]" : row.name)
row_json << I18n.l(row.created_at, format: :full) row_json << I18n.l(row.created_at, format: :full)
row_json << row.created_by.full_name row_json << row.created_by.full_name
data << row_json data << row_json