Add new columns to the repository [SCI-10400]

This commit is contained in:
Andrej 2024-05-22 17:23:39 +02:00
parent 4471ad40dc
commit 794d176535
16 changed files with 90 additions and 22 deletions

View file

@ -340,8 +340,8 @@ var MyModuleRepositories = (function() {
json.state.columns[0].visible = false;
}
if ($(tableContainer).data('type') !== 'snapshot') {
json.state.columns[6].visible = false;
json.state.columns[7].visible = false;
json.state.columns[9].visible = false;
json.state.columns[10].visible = false;
}
if (json.state.search) delete json.state.search;
if ($(tableContainer).data('stockConsumptionColumn')) {

View file

@ -662,6 +662,14 @@ var RepositoryDatatable = (function(global) {
targets: 6,
class: 'added-by',
visible: true
}, {
targets: 7,
class: 'updated-on',
visible: true
}, {
targets: 8,
class: 'updated-by',
visible: true
}, {
targets: '_all',
render: function(data) {
@ -752,8 +760,8 @@ var RepositoryDatatable = (function(global) {
var state = localStorage.getItem(`datatables_repositories_state/${repositoryId}/${viewType}`);
json.state.start = state !== null ? JSON.parse(state).start : 0;
if (json.state.columns[7]) json.state.columns[7].visible = archived;
if (json.state.columns[8]) json.state.columns[8].visible = archived;
if (json.state.columns[9]) json.state.columns[9].visible = archived;
if (json.state.columns[10]) json.state.columns[10].visible = archived;
if (json.state.search) delete json.state.search;
if (json.state.ColSizes && json.state.ColSizes.length > 0) {

View file

@ -53,15 +53,21 @@ function prepareRepositoryHeaderForExport(th) {
case 'added-on':
val = -6;
break;
case 'archived-by':
case 'updated-on':
val = -7;
break;
case 'archived-on':
case 'updated-by':
val = -8;
break;
case 'relationship':
case 'archived-by':
val = -9;
break;
case 'archived-on':
val = -10;
break;
case 'relationship':
val = -11;
break;
default:
val = th.attr('id');
}

View file

@ -239,8 +239,10 @@ module RepositoryDatatableHelper
'4': "#{record.parent_connections_count || 0} / #{record.child_connections_count || 0}",
'5': I18n.l(record.created_at, format: :full),
'6': escape_input(record.created_by.full_name),
'7': (record.archived_on ? I18n.l(record.archived_on, format: :full) : ''),
'8': escape_input(record.archived_by&.full_name)
'7': (record.updated_at ? I18n.l(record.updated_at, format: :full) : ''),
'8': escape_input(record.last_modified_by.full_name),
'9': (record.archived_on ? I18n.l(record.archived_on, format: :full) : ''),
'10': escape_input(record.archived_by&.full_name)
}
end

View file

@ -97,6 +97,26 @@
</span>
</div>
<!-- UPDATED ON-->
<div class="flex flex-col ">
<span class="inline-block font-semibold pb-[6px]">{{
i18n.t('repositories.item_card.default_columns.updated_on')
}}</span>
<span class="inline-block text-sn-dark-grey line-clamp-3" :title="defaultColumns?.updated_on" data-e2e="e2e-TX-itemCard-updatedOn">
{{ defaultColumns?.updated_on }}
</span>
</div>
<!-- UPDATED BY -->
<div class="flex flex-col ">
<span class="inline-block font-semibold pb-[6px]">{{
i18n.t('repositories.item_card.default_columns.updated_by')
}}</span>
<span class="inline-block text-sn-dark-grey line-clamp-3" :title="defaultColumns?.updated_by" data-e2e="e2e-TX-itemCard-updatedBy">
{{ defaultColumns?.updated_by }}
</span>
</div>
<!-- ARCHIVED ON -->
<div v-if="defaultColumns.archived_on" class="flex flex-col ">
<div class="sci-divider pb-4"></div>

View file

@ -49,8 +49,8 @@ class RepositoriesExportJob < ApplicationJob
file_name = FileUtils.touch("#{path}/#{repository_name}.#{@file_type}").first
# Define headers and columns IDs
col_ids = [-3, -4, -5, -6, -7, -8]
col_ids << -9 if Repository.repository_row_connections_enabled?
col_ids = [-3, -4, -5, -6, -7, -8, -9, -10]
col_ids << -11 if Repository.repository_row_connections_enabled?
col_ids += repository.repository_columns.map(&:id)
# Define callback function for file name

View file

@ -20,8 +20,11 @@ class LinkedRepository < Repository
'assigned',
'repository_rows.id',
'repository_rows.name',
'relationships',
'repository_rows.created_at',
'users.full_name',
'repository_rows.updated_at',
'last_modified_bies_repository_rows.full_name',
'repository_rows.archived_on',
'archived_bies_repository_rows.full_name',
'repository_rows.external_id'

View file

@ -102,6 +102,8 @@ class Repository < RepositoryBase
'relationships',
'repository_rows.created_at',
'users.full_name',
'repository_rows.updated_at',
'last_modified_bies_repository_rows.full_name',
'repository_rows.archived_on',
'archived_bies_repository_rows.full_name'
]

View file

@ -20,10 +20,14 @@ module RepositoryCsvExport
when -6
csv_header << I18n.t('repositories.table.added_on')
when -7
csv_header << I18n.t('repositories.table.archived_by')
csv_header << I18n.t('repositories.table.updated_on')
when -8
csv_header << I18n.t('repositories.table.archived_on')
csv_header << I18n.t('repositories.table.updated_by')
when -9
csv_header << I18n.t('repositories.table.archived_by')
when -10
csv_header << I18n.t('repositories.table.archived_on')
when -11
csv_header << I18n.t('repositories.table.parents')
csv_header << I18n.t('repositories.table.children')
else
@ -50,10 +54,14 @@ module RepositoryCsvExport
when -6
csv_row << I18n.l(row.created_at, format: :full)
when -7
csv_row << (row.archived? && row.archived_by.present? ? row.archived_by.full_name : '')
csv_row << row.updated_at ? I18n.l(row.updated_at, format: :full) : ''
when -8
csv_row << (row.archived? && row.archived_on.present? ? I18n.l(row.archived_on, format: :full) : '')
csv_row << row.last_modified_by.full_name
when -9
csv_row << (row.archived? && row.archived_by.present? ? row.archived_by.full_name : '')
when -10
csv_row << (row.archived? && row.archived_on.present? ? I18n.l(row.archived_on, format: :full) : '')
when -11
csv_row << row.parent_repository_rows.map(&:code).join(' | ')
csv_row << row.child_repository_rows.map(&:code).join(' | ')
else

View file

@ -127,7 +127,7 @@ class RepositoryDatatableService
repository_rows = repository_rows.where(id: advanced_search(repository_rows)) if @params[:advanced_search].present?
repository_rows.left_outer_joins(:created_by, :archived_by)
repository_rows.left_outer_joins(:created_by, :archived_by, :last_modified_by)
.select('repository_rows.*')
.select('COUNT("repository_rows"."id") OVER() AS filtered_count')
.group('repository_rows.id')

View file

@ -23,10 +23,14 @@ module RepositoryXlsxExport
when -6
header << I18n.t('repositories.table.added_on')
when -7
header << I18n.t('repositories.table.archived_by')
csv_header << I18n.t('repositories.table.updated_on')
when -8
header << I18n.t('repositories.table.archived_on')
csv_header << I18n.t('repositories.table.updated_by')
when -9
header << I18n.t('repositories.table.archived_by')
when -10
header << I18n.t('repositories.table.archived_on')
when -11
header << I18n.t('repositories.table.parents')
header << I18n.t('repositories.table.children')
else
@ -51,10 +55,14 @@ module RepositoryXlsxExport
when -6
row_data << I18n.l(row.created_at, format: :full)
when -7
row_data << (row.archived? && row.archived_by.present? ? row.archived_by.full_name : '')
csv_row << row.updated_at ? I18n.l(row.updated_at, format: :full) : ''
when -8
row_data << (row.archived? && row.archived_on.present? ? I18n.l(row.archived_on, format: :full) : '')
csv_row << row.last_modified_by.full_name
when -9
row_data << (row.archived? && row.archived_by.present? ? row.archived_by.full_name : '')
when -10
row_data << (row.archived? && row.archived_on.present? ? I18n.l(row.archived_on, format: :full) : '')
when -11
row_data << row.parent_repository_rows.map(&:code).join(' | ')
row_data << row.child_repository_rows.map(&:code).join(' | ')
else

View file

@ -26,6 +26,8 @@
<th id="relationship"><%= t("repositories.table.relationships") %></th>
<th id="added-on"><%= t("repositories.table.added_on") %></th>
<th id="added-by"><%= t("repositories.table.added_by") %></th>
<th id="updated-on" ><%= t("repositories.table.updated_on") %></th>
<th id="updated-by" ><%= t("repositories.table.updated_by") %></th>
<th id="archived-on"><%= t("repositories.table.archived_on") %></th>
<th id="archived-by"><%= t("repositories.table.archived_by") %></th>
<% if @repository.is_a?(LinkedRepository) %>

View file

@ -40,6 +40,8 @@
<th id="relationship" title="<%= t("repositories.table.relationships") %>"><%= t("repositories.table.relationships") %></th>
<th id="added-on" ><%= t("repositories.table.added_on") %></th>
<th id="added-by" ><%= t("repositories.table.added_by") %></th>
<th id="updated-on" ><%= t("repositories.table.updated_on") %></th>
<th id="updated-by" ><%= t("repositories.table.updated_by") %></th>
<th id="archived-on"><%= t("repositories.table.archived_on") %></th>
<th id="archived-by"><%= t("repositories.table.archived_by") %></th>
<% if @repository.is_a?(LinkedRepository) %>

View file

@ -42,6 +42,8 @@ json.default_columns do
json.code @repository_row.code
json.added_on I18n.l(@repository_row.created_at, format: :full)
json.added_by @repository_row.created_by&.full_name
json.updated_on I18n.l(@repository_row.updated_at, format: :full)
json.updated_by @repository_row.last_modified_by&.full_name
json.archived @repository_row.archived?
if @repository_row.archived?
json.archived_on I18n.l(@repository_row.archived_on, format: :full)

View file

@ -360,9 +360,9 @@ class Constants
'order' => [[3, 'asc']], # Default sorting by 'name' column
'columns' => [],
'assigned' => 'assigned',
'ColReorder' => [*0..8]
'ColReorder' => [*0..10]
}
9.times do |i|
11.times do |i|
REPOSITORY_TABLE_DEFAULT_STATE['columns'] << {
'visible' => (i < 7 && i != 4), # relationship column is hidden by default
'searchable' => (i >= 1 && i != 4), # Checkboxes and relationship column is not searchable
@ -386,6 +386,7 @@ class Constants
}
REPOSITORY_SNAPSHOT_TABLE_DEFAULT_STATE['columns'] = REPOSITORY_TABLE_DEFAULT_STATE['columns'][0..4]
REPOSITORY_SNAPSHOT_TABLE_DEFAULT_STATE['columns'][4]['visible'] = true
REPOSITORY_SNAPSHOT_TABLE_DEFAULT_STATE.freeze

View file

@ -2137,6 +2137,8 @@ en:
row_name: "Name"
added_on: "Created on"
added_by: "Added by"
updated_on: "Updated on"
updated_by: "Updated by"
archived_on: "Archived on"
archived_by: "Archived by"
relationships: "Relationships"
@ -2486,6 +2488,8 @@ en:
added_on: "Added on"
added_at: "Added at"
added_by: "Added by"
updated_on: 'Updated on'
updated_by: 'Updated by'
archived_on: "Archived on"
archived_by: "Archived by"
reminders: