small fixes

This commit is contained in:
Mojca Lorber 2019-12-10 12:02:08 +01:00
parent 1122fe2d2f
commit a3a5b21951
7 changed files with 15 additions and 9 deletions

View file

@ -19,7 +19,7 @@ class RepositoryCell < ApplicationRecord
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryNumberValue' })
end),
optional: true, foreign_key: :value_id
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
belongs_to :repository_date_time_value,
(lambda do
includes(:repository_cell)

View file

@ -2,9 +2,9 @@
class RepositoryNumberValue < ApplicationRecord
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User',
inverse_of: :created_repositroy_number_values
inverse_of: :created_repository_number_values
belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User',
inverse_of: :modified_repositroy_number_values
inverse_of: :modified_repository_number_values
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
accepts_nested_attributes_for :repository_cell

View file

@ -264,12 +264,12 @@ class User < ApplicationRecord
foreign_key: 'last_modified_by_id',
inverse_of: :last_modified_by,
dependent: :nullify
has_many :created_repositroy_number_values,
has_many :created_repository_number_values,
class_name: 'RepositoryNumberValue',
foreign_key: 'created_by_id',
inverse_of: :created_by,
dependent: :nullify
has_many :modified_repositroy_number_values,
has_many :modified_repository_number_values,
class_name: 'RepositoryNumberValue',
foreign_key: 'last_modified_by_id',
inverse_of: :last_modified_by,

View file

@ -5,6 +5,7 @@
<%= t('libraries.manange_modal_column.number_type.decimals_label') %>
</label>
<div class="col-sm-3">
<%= number_field_tag('decimals', selected_decimals, in: 0...101, class: 'form-control') %>
<%= number_field_tag('decimals', selected_decimals, in: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS,
class: 'form-control') %>
</div>
</div>

View file

@ -976,6 +976,7 @@ class Constants
EXPORTABLE_ZIP_EXPIRATION_DAYS = 7
REPOSITORY_LIST_ITEMS_PER_COLUMN = 500
REPOSITORY_NUMBER_TYPE_MAX_DECIMALS = 11
REPOSITORY_LIST_ITEMS_DELIMITERS_MAP = {
return: "\n",

View file

@ -9,8 +9,5 @@ class CreateRepositoryNumberValue < ActiveRecord::Migration[6.0]
t.timestamps
end
# add jsonb column for repository columns metadata
add_column :repository_columns, :metadata, :jsonb, default: {}, null: false
end
end

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddMetadataToRepositoryColumn < ActiveRecord::Migration[6.0]
def change
add_column :repository_columns, :metadata, :jsonb, default: {}, null: false
end
end