2019-11-18 22:56:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RepositoryColumns
|
2020-05-28 18:18:46 +08:00
|
|
|
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,
|
2020-06-30 19:44:49 +08:00
|
|
|
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,
|
2020-06-30 19:44:49 +08:00
|
|
|
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
|
2022-03-18 21:40:09 +08:00
|
|
|
params.require(:repository_column).permit(:name, :reminder_delta, :reminder_value, :reminder_unit, :reminder_message)
|
2019-11-26 16:31:32 +08:00
|
|
|
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
|