Move editable? method from helper to model

This commit is contained in:
Urban Rotnik 2020-01-25 09:43:05 +01:00
parent 0effb3ee69
commit 503c05805d
3 changed files with 6 additions and 6 deletions

View file

@ -29,7 +29,7 @@ module RepositoryDatatableHelper
), ),
'recordInfoUrl': Rails.application.routes.url_helpers 'recordInfoUrl': Rails.application.routes.url_helpers
.repository_row_path(record.id), .repository_row_path(record.id),
'recordEditable': record_editable 'recordEditable': record.editable?
} }
# Add custom columns # Add custom columns
@ -75,10 +75,6 @@ module RepositoryDatatableHelper
Constants::REPOSITORY_TABLE_DEFAULT_STATE['columns'].to_json Constants::REPOSITORY_TABLE_DEFAULT_STATE['columns'].to_json
end end
def record_editable
true
end
def display_cell_value(cell, team) def display_cell_value(cell, team)
value_name = cell.repository_column.data_type.underscore value_name = cell.repository_column.data_type.underscore
serializer_class = "RepositoryDatatable::#{cell.repository_column.data_type}Serializer".constantize serializer_class = "RepositoryDatatable::#{cell.repository_column.data_type}Serializer".constantize

View file

@ -37,4 +37,8 @@ class RepositoryRow < ApplicationRecord
.where('repositories.team_id = ? and repository_rows.created_by_id = ?', team, user) .where('repositories.team_id = ? and repository_rows.created_by_id = ?', team, user)
.update_all(created_by_id: new_owner.id) .update_all(created_by_id: new_owner.id)
end end
def editable?
true
end
end end

View file

@ -52,7 +52,7 @@ class RepositoryDatatableService
.select('COUNT(DISTINCT my_modules.experiment_id) AS "assigned_experiments_count"') .select('COUNT(DISTINCT my_modules.experiment_id) AS "assigned_experiments_count"')
.select('COUNT(DISTINCT experiments.project_id) AS "assigned_projects_count"') .select('COUNT(DISTINCT experiments.project_id) AS "assigned_projects_count"')
end end
repository_rows.preload(Extends::REPOSITORY_ROWS_PRELOAD_RELATIONS) repository_rows = repository_rows.preload(Extends::REPOSITORY_ROWS_PRELOAD_RELATIONS)
@repository_rows = sort_rows(order_obj, repository_rows) @repository_rows = sort_rows(order_obj, repository_rows)
end end