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

41 lines
1.2 KiB
Ruby
Raw Normal View History

2019-12-09 23:38:21 +08:00
# frozen_string_literal: true
module RepositoryColumns
class NumberColumnsController < RepositoryColumnsController
2019-12-09 23:38:21 +08:00
include InputSanitizeHelper
def create
service = RepositoryColumns::CreateColumnService
.call(user: current_user, repository: @repository, team: current_team,
column_type: Extends::REPOSITORY_DATA_TYPES[:RepositoryNumberValue],
params: repository_column_params)
if service.succeed?
render json: service.column, status: :created, creating: true
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)
if service.succeed?
render json: service.column, status: :ok, editing: true
else
render json: service.errors, status: :unprocessable_entity
end
end
private
def repository_column_params
params.require(:repository_column).permit(:name, metadata: [:decimals])
end
end
end