Fix sorting for date time columns [SCI-4197]

This commit is contained in:
Oleksii Kriuchykhin 2020-01-09 16:18:28 +01:00
parent 54c78cf4d1
commit ad5a5f3ebf
5 changed files with 25 additions and 10 deletions

View file

@ -8,7 +8,7 @@ var RepositoryColumns = (function() {
RepositoryStatusValue: 'RepositoryStatusColumnType',
RepositoryDateValue: 'RepositoryDateColumnType',
RepositoryDateTimeValue: 'RepositoryDateTimeColumnType',
RepositoryTimeValue: 'RepositoryDateTimeColumnType',
RepositoryTimeValue: 'RepositoryTimeColumnType',
RepositoryChecklistValue: 'RepositoryChecklistColumnType',
RepositoryNumberValue: 'RepositoryNumberColumnType'
};
@ -84,14 +84,14 @@ var RepositoryColumns = (function() {
</div>
<div class="col-xs-4">
<span class="controlls pull-right">
<button class="btn btn-default edit-repo-column manage-repo-column"
<button class="btn btn-default edit-repo-column manage-repo-column"
data-action="edit"
data-modal-url="${attributes.edit_html_url}"
>
<span class="fas fa-pencil-alt"></span>
${ I18n.t('libraries.repository_columns.index.edit_column')}
</button>
<button class="btn btn-default delete-repo-column manage-repo-column"
<button class="btn btn-default delete-repo-column manage-repo-column"
data-action="destroy"
data-modal-url="${attributes.destroy_html_url}"
>

View file

@ -13,7 +13,7 @@ class RepositoryCell < ApplicationRecord
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryTextValue' })
end),
optional: true, foreign_key: :value_id
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_number_value,
(lambda do
includes(:repository_cell)
@ -31,13 +31,13 @@ class RepositoryCell < ApplicationRecord
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryListValue' })
end),
optional: true, foreign_key: :value_id
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_asset_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryAssetValue' })
end),
optional: true, foreign_key: :value_id
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_status_value,
(lambda do
@ -53,6 +53,13 @@ class RepositoryCell < ApplicationRecord
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_date_time_value_base,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_date_time_value,
(lambda do
includes(:repository_cell)
@ -67,6 +74,13 @@ class RepositoryCell < ApplicationRecord
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_date_time_range_value_base,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeRangeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_date_time_range_value,
(lambda do
includes(:repository_cell)

View file

@ -12,8 +12,8 @@ class RepositoryDateTimeRangeValueBase < ApplicationRecord
validates :repository_cell, :start_time, :end_time, presence: true
SORTABLE_COLUMN_NAME = 'repository_date_time_values.start_time'
SORTABLE_VALUE_INCLUDE = :repository_date_time_range_value
SORTABLE_COLUMN_NAME = 'repository_date_time_range_values.start_time'
SORTABLE_VALUE_INCLUDE = :repository_date_time_range_value_base
def update_data!(new_data, user)
data = JSON.parse(new_data).symbolize_keys

View file

@ -13,7 +13,7 @@ class RepositoryDateTimeValueBase < ApplicationRecord
validates :repository_cell, :data, presence: true
SORTABLE_COLUMN_NAME = 'repository_date_time_values.data'
SORTABLE_VALUE_INCLUDE = :repository_date_time_value
SORTABLE_VALUE_INCLUDE = :repository_date_time_value_base
def update_data!(new_data, user)
self.data = Time.zone.parse(new_data)

View file

@ -72,7 +72,8 @@ class Extends
REPOSITORY_SEARCH_INCLUDES = [:repository_text_value,
:repository_number_value,
repository_list_value: :repository_list_item,
repository_checklist_value: :repository_checklist_items,
repository_checklist_value:
{ repository_cell_values_checklist_items: :repository_checklist_item },
repository_status_value: :repository_status_item,
repository_asset_value: { asset: { file_attachment: :blob } }]