mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 14:15:35 +08:00
Move delimiter from column to metadata
This commit is contained in:
parent
2da7eeaedd
commit
7153711570
11 changed files with 22 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/* global GLOBAL_CONSTANTS dropdownSelector RepositoryListColumnType */
|
||||
|
||||
|
||||
var RepositoryChecklistColumnType = (function() {
|
||||
var manageModal = '#manage-repository-column';
|
||||
var delimiterDropdown = '.checklist-column-type .delimiter';
|
||||
|
@ -69,7 +69,7 @@ var RepositoryChecklistColumnType = (function() {
|
|||
var repositoryColumnParams = {};
|
||||
var options = JSON.parse($(dropdownOptions).val());
|
||||
repositoryColumnParams.repository_checklist_items_attributes = options;
|
||||
repositoryColumnParams.delimiter = $(delimiterDropdown).data('used-delimiter');
|
||||
repositoryColumnParams.metadata = { delimiter: $(delimiterDropdown).data('used-delimiter') };
|
||||
return repositoryColumnParams;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -145,7 +145,7 @@ var RepositoryListColumnType = (function() {
|
|||
var repositoryColumnParams = {};
|
||||
var options = JSON.parse($(dropdownOptions).val());
|
||||
repositoryColumnParams.repository_list_items_attributes = options;
|
||||
repositoryColumnParams.delimiter = $(delimiterDropdown).data('used-delimiter');
|
||||
repositoryColumnParams.metadata = { delimiter: $(delimiterDropdown).data('used-delimiter') };
|
||||
return repositoryColumnParams;
|
||||
},
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ module RepositoryColumns
|
|||
end
|
||||
|
||||
def repository_column_params
|
||||
params.require(:repository_column).permit(:name, :delimiter, repository_checklist_items_attributes: %i(data))
|
||||
params
|
||||
.require(:repository_column)
|
||||
.permit(:name, metadata: [:delimiter], repository_checklist_items_attributes: %i(data))
|
||||
end
|
||||
|
||||
def delimiters
|
||||
|
|
|
@ -62,7 +62,9 @@ module RepositoryColumns
|
|||
end
|
||||
|
||||
def repository_column_params
|
||||
params.require(:repository_column).permit(:name, :delimiter, repository_list_items_attributes: %i(data))
|
||||
params
|
||||
.require(:repository_column)
|
||||
.permit(:name, metadata: [:delimiter], repository_list_items_attributes: %i(data))
|
||||
end
|
||||
|
||||
def delimiters
|
||||
|
|
|
@ -69,5 +69,4 @@ class RepositoryColumn < ApplicationRecord
|
|||
def importable?
|
||||
Extends::REPOSITORY_IMPORTABLE_TYPES.include?(data_type.to_sym)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ module RepositoryColumns
|
|||
end
|
||||
return self unless valid?
|
||||
|
||||
@errors[:repository_column] = @column.errors.messages unless @column.update(@params.slice(:name, :delimiter))
|
||||
@errors[:repository_column] = @column.errors.messages unless @column.update(@params.slice(:name, :metadata))
|
||||
return self unless valid?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
|
|
|
@ -25,7 +25,7 @@ module RepositoryColumns
|
|||
end
|
||||
return self unless valid?
|
||||
|
||||
@errors[:repository_column] = @column.errors.messages unless @column.update(@params.slice(:name, :delimiter))
|
||||
@errors[:repository_column] = @column.errors.messages unless @column.update(@params.slice(:name, :metadata))
|
||||
return self unless valid?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
delimiters = defined_delimiters_options
|
||||
selected_delimiter = column.delimiter || 'return'
|
||||
selected_delimiter = column.metadata['delimiter'] || 'return'
|
||||
selected_delimiter_char = Constants::REPOSITORY_LIST_ITEMS_DELIMITERS_MAP[selected_delimiter.to_sym]
|
||||
%>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
delimiters = defined_delimiters_options
|
||||
selected_delimiter = column.delimiter || 'return'
|
||||
selected_delimiter = column.metadata['delimiter'] || 'return'
|
||||
selected_delimiter_char = Constants::REPOSITORY_LIST_ITEMS_DELIMITERS_MAP[selected_delimiter.to_sym]
|
||||
%>
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveDelimiterFromRepositoryColumn < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
remove_column :repository_columns, :delimiter, :string
|
||||
end
|
||||
end
|
|
@ -1257,7 +1257,6 @@ CREATE TABLE public.repository_columns (
|
|||
data_type integer NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
delimiter character varying,
|
||||
metadata jsonb DEFAULT '{}'::jsonb NOT NULL
|
||||
);
|
||||
|
||||
|
@ -7120,7 +7119,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20191205133447'),
|
||||
('20191205133522'),
|
||||
('20191206105058'),
|
||||
('20191210103004');
|
||||
|
||||
('20191210103004'),
|
||||
('20191218072619');
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue