From af9e272b2a341911d5b4daf2927ff79b41d0c7e3 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Tue, 3 Jan 2017 09:39:41 +0100 Subject: [PATCH] Re-add tags index controller action to render tags Closes SCI-166. --- app/controllers/my_module_tags_controller.rb | 19 ++++++++++++++++++- config/routes.rb | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/my_module_tags_controller.rb b/app/controllers/my_module_tags_controller.rb index 87e5eac9a..4703de1fc 100644 --- a/app/controllers/my_module_tags_controller.rb +++ b/app/controllers/my_module_tags_controller.rb @@ -1,6 +1,6 @@ class MyModuleTagsController < ApplicationController before_action :load_vars - before_action :check_view_permissions, only: [:index_edit] + before_action :check_view_permissions, only: [:index_edit, :index] before_action :check_create_permissions, only: [:create] before_action :check_destroy_permissions, only: [:destroy] @@ -22,6 +22,23 @@ class MyModuleTagsController < ApplicationController end end + def index + respond_to do |format| + format.json do + 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 + end + def create @mt = MyModuleTag.new(mt_params.merge(my_module: @my_module)) @mt.created_by = current_user diff --git a/config/routes.rb b/config/routes.rb index 7f0590363..045738fa8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -191,7 +191,7 @@ Rails.application.routes.draw do # Show action is a popup (JSON) for individual module in full-zoom canvas, # as well as "module info" page for single module (HTML) resources :my_modules, path: '/modules', only: [:show, :update] do - resources :my_module_tags, path: '/tags', only: [:create, :destroy] + resources :my_module_tags, path: '/tags', only: [:index, :create, :destroy] resources :user_my_modules, path: '/users', only: [:index, :create, :destroy] resources :my_module_comments,