2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
class Admin::LabelsController < Admin::ApplicationController
|
|
|
|
before_action :set_label, only: [:show, :edit, :update, :destroy]
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :issue_tracking
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
def index
|
2016-06-02 11:05:42 +05:30
|
|
|
@labels = Label.templates.page(params[:page])
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@label = Label.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-08-17 22:00:37 +05:30
|
|
|
@label = Labels::CreateService.new(label_params).execute(template: true)
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
if @label.persisted?
|
2019-07-07 11:18:12 +05:30
|
|
|
redirect_to admin_labels_url, notice: _("Label was created")
|
2015-09-25 12:07:36 +05:30
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2017-08-17 22:00:37 +05:30
|
|
|
@label = Labels::UpdateService.new(label_params).execute(@label)
|
|
|
|
|
|
|
|
if @label.valid?
|
2019-07-07 11:18:12 +05:30
|
|
|
redirect_to admin_labels_path, notice: _('Label was successfully updated.')
|
2015-09-25 12:07:36 +05:30
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@label.destroy
|
|
|
|
@labels = Label.templates
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2019-12-26 22:10:19 +05:30
|
|
|
redirect_to admin_labels_path, status: :found, notice: _('Label was removed')
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
format.js { head :ok }
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_label
|
|
|
|
@label = Label.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def label_params
|
2016-04-02 18:10:28 +05:30
|
|
|
params[:label].permit(:title, :description, :color)
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|