From a3a5b219510a10e73554f4d4e9a9007aadd7a5ac Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Tue, 10 Dec 2019 12:02:08 +0100 Subject: [PATCH] small fixes --- app/models/repository_cell.rb | 2 +- app/models/repository_number_value.rb | 4 ++-- app/models/user.rb | 4 ++-- .../manage_column_partials/_number.html.erb | 3 ++- config/initializers/constants.rb | 1 + .../20191204112549_create_repository_number_value.rb | 3 --- .../20191210103004_add_metadata_to_repository_column.rb | 7 +++++++ 7 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20191210103004_add_metadata_to_repository_column.rb diff --git a/app/models/repository_cell.rb b/app/models/repository_cell.rb index da25cd46d..67c06085c 100644 --- a/app/models/repository_cell.rb +++ b/app/models/repository_cell.rb @@ -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) diff --git a/app/models/repository_number_value.rb b/app/models/repository_number_value.rb index c31f9c7f8..824f6230a 100644 --- a/app/models/repository_number_value.rb +++ b/app/models/repository_number_value.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 4d106c97d..39263392d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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, diff --git a/app/views/repository_columns/manage_column_partials/_number.html.erb b/app/views/repository_columns/manage_column_partials/_number.html.erb index 52629e0d1..03ffa9b0f 100644 --- a/app/views/repository_columns/manage_column_partials/_number.html.erb +++ b/app/views/repository_columns/manage_column_partials/_number.html.erb @@ -5,6 +5,7 @@ <%= t('libraries.manange_modal_column.number_type.decimals_label') %>
- <%= 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') %>
diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index a71b9d7c7..9409c76cd 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -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", diff --git a/db/migrate/20191204112549_create_repository_number_value.rb b/db/migrate/20191204112549_create_repository_number_value.rb index 5ecd0c113..b67624e39 100644 --- a/db/migrate/20191204112549_create_repository_number_value.rb +++ b/db/migrate/20191204112549_create_repository_number_value.rb @@ -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 diff --git a/db/migrate/20191210103004_add_metadata_to_repository_column.rb b/db/migrate/20191210103004_add_metadata_to_repository_column.rb new file mode 100644 index 000000000..de674f6b7 --- /dev/null +++ b/db/migrate/20191210103004_add_metadata_to_repository_column.rb @@ -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