Update task comments & task tags controllers & localized Strings

(Remove a lot of unused code)
This commit is contained in:
Luka Murn 2016-11-22 14:26:35 +01:00
parent 8505d75bca
commit 1f7a8712fb
3 changed files with 16 additions and 112 deletions

View file

@ -58,16 +58,10 @@ class MyModuleCommentsController < ApplicationController
)
)
format.html {
flash[:success] = t(
"my_module_comments.create.success_flash",
module: @my_module.name)
redirect_to session.delete(:return_to)
}
format.json {
format.json do
render json: {
html: render_to_string(
partial: "comment.html.erb",
partial: 'comment.html.erb',
locals: {
comment: @comment
}
@ -75,15 +69,14 @@ class MyModuleCommentsController < ApplicationController
date: @comment.created_at.strftime('%d.%m.%Y')
},
status: :created
}
end
else
response.status = 400
format.html { render :new }
format.json {
format.json do
render json: {
errors: @comment.errors.to_hash(true)
}
}
end
end
end
end

View file

@ -1,6 +1,6 @@
class MyModuleTagsController < ApplicationController
before_action :load_vars
before_action :check_view_permissions, only: [:index_edit, :index]
before_action :check_view_permissions, only: [:index_edit]
before_action :check_create_permissions, only: [:new, :create]
before_action :check_destroy_permissions, only: [:destroy]
@ -22,23 +22,6 @@ class MyModuleTagsController < ApplicationController
end
end
def index
respond_to do |format|
format.json {
render json: {
html_canvas: render_to_string(
partial: "canvas/tags.html.erb",
locals: { my_module: @my_module }
),
html_module_header: render_to_string(
partial: "my_modules/tags.html.erb",
locals: { my_module: @my_module }
)
}
}
end
end
def new
session[:return_to] ||= request.referer
@mt = MyModuleTag.new(my_module: @my_module)
@ -48,75 +31,24 @@ class MyModuleTagsController < ApplicationController
def create
@mt = MyModuleTag.new(mt_params.merge(my_module: @my_module))
@mt.created_by = current_user
@mt.save
if @mt.save
flash_success = t(
"my_module_tags.create.success_flash",
tag: @mt.tag.name,
module: @mt.my_module.name)
respond_to do |format|
format.html {
flash[:success] = flash_success
redirect_to session.delete(:return_to)
}
format.json {
redirect_to my_module_tags_edit_path(format: :json), :status => 303
}
end
else
flash_error = t(
"my_module_tags.create.error_flash",
module: @mt.my_module.name)
respond_to do |format|
format.html {
flash[:error] = flash_error
init_gui
render :new
}
format.json {
# TODO
redirect_to my_module_tags_edit_path(format: :json), :status => 303
}
respond_to do |format|
format.json do
redirect_to my_module_tags_edit_path(format: :json),
status: 303
end
end
end
def destroy
session[:return_to] ||= request.referer
@mt = MyModuleTag.find_by_id(params[:id])
@mt.destroy
if @mt.present? and @mt.destroy
flash_success = t(
"my_module_tags.destroy.success_flash",
tag: @mt.tag.name,
module: @mt.my_module.name)
respond_to do |format|
format.html {
flash[:success] = flash_success
redirect_to session.delete(:return_to)
}
format.json {
redirect_to my_module_tags_edit_path(format: :json), :status => 303
}
end
else
flash_success = t(
"my_module_tags.destroy.error_flash",
tag: @mt.tag.name,
module: @mt.my_module.name)
respond_to do |format|
format.html {
flash[:error] = flash_error
redirect_to session.delete(:return_to)
}
format.json {
# TODO
redirect_to my_module_tags_edit_path(format: :json), :status => 303
}
respond_to do |format|
format.json do
redirect_to my_module_tags_edit_path(format: :json),
status: 303
end
end
end

View file

@ -754,27 +754,6 @@ en:
archived_on: "Archived on"
archived_on_title: "Module archived on %{date} at %{time}."
my_module_tags:
new:
head_title: "%{project} | %{module} | Add tag"
title: "Add tag to task %{module}"
create: "Add tag"
new_tag: "Create new tag"
create:
success_flash: "Successfully added tag <strong>%{tag}</strong> to task <strong>%{module}</strong>."
error_flash: "Could not create new tag for task <strong>%{module}</strong>."
destroy:
success_flash: "Successfully removed tag <strong>%{tag}</strong> from task <strong>%{module}</strong>."
error_flash: "Tag <strong>%{tag}</strong> could not be removed from <strong>%{module}</strong>."
my_module_comments:
new:
head_title: "%{project} | %{module} | Add comment"
title: "Add comment to task %{module}"
create: "Add comment"
create:
success_flash: "Successfully added comment to task <strong>%{module}</strong>."
my_module_groups:
new:
name: "Workflow %{index}"