scinote-web/app/controllers/repository_columns/date_time_columns_controller.rb

45 lines
1.2 KiB
Ruby
Raw Normal View History

2019-11-18 22:56:22 +08:00
# frozen_string_literal: true
module RepositoryColumns
class DateTimeColumnsController < RepositoryColumnsController
2019-11-18 22:56:22 +08:00
include InputSanitizeHelper
def create
service = RepositoryColumns::CreateColumnService
.call(user: current_user, repository: @repository, team: current_team,
column_type: column_type_param,
params: repository_column_params)
2019-11-18 22:56:22 +08:00
if service.succeed?
2020-01-10 20:22:29 +08:00
render json: service.column, status: :created, creating: true
2019-11-18 22:56:22 +08:00
else
render json: service.errors, status: :unprocessable_entity
end
end
def update
service = RepositoryColumns::UpdateColumnService
.call(user: current_user,
team: current_team,
column: @repository_column,
params: repository_column_params)
2019-11-18 22:56:22 +08:00
if service.succeed?
2020-01-10 20:22:29 +08:00
render json: service.column, status: :ok, editing: true
2019-11-18 22:56:22 +08:00
else
render json: service.errors, status: :unprocessable_entity
end
end
private
def repository_column_params
2019-11-26 16:31:32 +08:00
params.require(:repository_column).permit(:name)
end
2019-11-28 22:56:34 +08:00
def column_type_param
2019-11-26 16:31:32 +08:00
params.require(:repository_column).require(:column_type)
2019-11-18 22:56:22 +08:00
end
end
end