mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Move before actions in RepositoryColumnsController
This commit is contained in:
parent
285280827a
commit
cf9c3be4cf
8 changed files with 21 additions and 32 deletions
|
@ -3,9 +3,6 @@
|
|||
module RepositoryColumns
|
||||
class AssetColumnsController < RepositoryColumnsController
|
||||
include InputSanitizeHelper
|
||||
before_action :load_column, only: :update
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
|
||||
def create
|
||||
service = RepositoryColumns::CreateColumnService
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
module RepositoryColumns
|
||||
class ChecklistColumnsController < RepositoryColumnsController
|
||||
before_action :load_column, only: %i(update items)
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
helper_method :delimiters
|
||||
|
||||
def create
|
||||
|
@ -47,7 +44,7 @@ module RepositoryColumns
|
|||
private
|
||||
|
||||
def search_params
|
||||
params.permit(:query, :column_id)
|
||||
params.permit(:query, :repository_id, :id)
|
||||
end
|
||||
|
||||
def repository_column_params
|
||||
|
|
|
@ -3,15 +3,12 @@
|
|||
module RepositoryColumns
|
||||
class DateTimeColumnsController < RepositoryColumnsController
|
||||
include InputSanitizeHelper
|
||||
before_action :load_column, only: :update
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
|
||||
def create
|
||||
service = RepositoryColumns::CreateColumnService
|
||||
.call(user: current_user, repository: @repository, team: current_team,
|
||||
column_type: column_type_param,
|
||||
params: repository_column_params)
|
||||
column_type: column_type_param,
|
||||
params: repository_column_params)
|
||||
|
||||
if service.succeed?
|
||||
render json: service.column, status: :created, creating: true
|
||||
|
@ -23,9 +20,9 @@ module RepositoryColumns
|
|||
def update
|
||||
service = RepositoryColumns::UpdateColumnService
|
||||
.call(user: current_user,
|
||||
team: current_team,
|
||||
column: @repository_column,
|
||||
params: repository_column_params)
|
||||
team: current_team,
|
||||
column: @repository_column,
|
||||
params: repository_column_params)
|
||||
|
||||
if service.succeed?
|
||||
render json: service.column, status: :ok, editing: true
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
module RepositoryColumns
|
||||
class ListColumnsController < RepositoryColumnsController
|
||||
before_action :load_column, only: %i(update items)
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
helper_method :delimiters
|
||||
|
||||
def create
|
||||
|
@ -47,7 +44,7 @@ module RepositoryColumns
|
|||
private
|
||||
|
||||
def search_params
|
||||
params.permit(:query, :column_id)
|
||||
params.permit(:query, :repository_id, :id)
|
||||
end
|
||||
|
||||
def repository_column_params
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
module RepositoryColumns
|
||||
class NumberColumnsController < RepositoryColumnsController
|
||||
include InputSanitizeHelper
|
||||
before_action :load_column, only: :update
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
|
||||
def create
|
||||
service = RepositoryColumns::CreateColumnService
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
module RepositoryColumns
|
||||
class StatusColumnsController < RepositoryColumnsController
|
||||
include InputSanitizeHelper
|
||||
before_action :load_column, only: %i(update items)
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
|
||||
def create
|
||||
service = RepositoryColumns::CreateColumnService
|
||||
|
@ -47,7 +44,7 @@ module RepositoryColumns
|
|||
private
|
||||
|
||||
def search_params
|
||||
params.permit(:query, :column_id)
|
||||
params.permit(:query, :repository_id, :id)
|
||||
end
|
||||
|
||||
def repository_column_params
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
module RepositoryColumns
|
||||
class TextColumnsController < RepositoryColumnsController
|
||||
include InputSanitizeHelper
|
||||
before_action :load_column, only: :update
|
||||
before_action :check_create_permissions, only: :create
|
||||
before_action :check_manage_permissions, only: :update
|
||||
|
||||
def create
|
||||
service = RepositoryColumns::CreateColumnService
|
||||
|
|
|
@ -3,9 +3,9 @@ class RepositoryColumnsController < ApplicationController
|
|||
include RepositoryColumnsHelper
|
||||
|
||||
before_action :load_repository
|
||||
before_action :load_column, only: %i(edit destroy_html destroy)
|
||||
before_action :check_create_permissions, only: :new
|
||||
before_action :check_manage_permissions, only: %i(edit destroy_html destroy)
|
||||
before_action :load_column, only: %i(edit update destroy_html destroy items)
|
||||
before_action :check_create_permissions, only: %i(new create)
|
||||
before_action :check_manage_permissions, only: %i(edit update destroy_html destroy)
|
||||
before_action :load_asset_type_columns, only: :available_asset_type_columns
|
||||
|
||||
def index
|
||||
|
@ -30,6 +30,10 @@ class RepositoryColumnsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def edit
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
|
@ -38,6 +42,10 @@ class RepositoryColumnsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
def update
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def destroy_html
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
|
@ -74,6 +82,8 @@ class RepositoryColumnsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def items; end
|
||||
|
||||
def available_asset_type_columns
|
||||
if @asset_columns.empty?
|
||||
render json: {
|
||||
|
|
Loading…
Reference in a new issue