From 6964ed2dbbab5fdfffb20163494c89538c9aa7f5 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 28 Nov 2017 16:34:30 +0100 Subject: [PATCH 1/4] Add initialization of the selectpicker on experiments actions [SCI-1840] --- app/assets/javascripts/experiments/dropdown_actions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/experiments/dropdown_actions.js b/app/assets/javascripts/experiments/dropdown_actions.js index 7ba6fe909..b752370ee 100644 --- a/app/assets/javascripts/experiments/dropdown_actions.js +++ b/app/assets/javascripts/experiments/dropdown_actions.js @@ -25,6 +25,7 @@ }) .on("ajax:complete", function(){ animateSpinner(null, false); + $(id).find('.selectpicker').selectpicker(); }); } From 7bb52191cd5671ac3c3791ea6a93b89466e819c8 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 29 Nov 2017 16:13:28 +0100 Subject: [PATCH 2/4] Fix Ajax calls with redirect [SCI-1837] --- app/controllers/my_module_tags_controller.rb | 4 +- app/controllers/tags_controller.rb | 48 +++++++++++++------ app/controllers/user_my_modules_controller.rb | 8 ++-- app/controllers/user_projects_controller.rb | 8 ++-- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/app/controllers/my_module_tags_controller.rb b/app/controllers/my_module_tags_controller.rb index 4703de1fc..7946f36dd 100644 --- a/app/controllers/my_module_tags_controller.rb +++ b/app/controllers/my_module_tags_controller.rb @@ -46,7 +46,7 @@ class MyModuleTagsController < ApplicationController respond_to do |format| format.json do - redirect_to my_module_tags_edit_path(format: :json), + redirect_to my_module_tags_edit_path(format: :json), turbolinks: false, status: 303 end end @@ -58,7 +58,7 @@ class MyModuleTagsController < ApplicationController respond_to do |format| format.json do - redirect_to my_module_tags_edit_path(format: :json), + redirect_to my_module_tags_edit_path(format: :json), turbolinks: false, status: 303 end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 3a7eb04da..1df5da37e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -35,9 +35,13 @@ class TagsController < ApplicationController flash[:success] = flash_success redirect_to session.delete(:return_to) } - format.json { - redirect_to my_module_tags_edit_path(params[:my_module_id], @tag, format: :json), :status => 303 - } + format.json do + redirect_to my_module_tags_edit_path(params[:my_module_id], + @tag, + format: :json), + turbolinks: false, + status: 303 + end end else flash_error = t("tags.create.error_flash") @@ -46,10 +50,14 @@ class TagsController < ApplicationController flash[:error] = flash_error render :new } - format.json { + format.json do # TODO - redirect_to my_module_tags_edit_path(params[:my_module_id], @tag, format: :json), :status => 303 - } + redirect_to my_module_tags_edit_path(params[:my_module_id], + @tag, + format: :json), + turbolinks: false, + status: 303 + end end end end @@ -59,9 +67,13 @@ class TagsController < ApplicationController if @tag.update_attributes(tag_params) respond_to do |format| format.html - format.json { - redirect_to my_module_tags_edit_path(params[:my_module_id], @tag, format: :json), :status => 303 - } + format.json do + redirect_to my_module_tags_edit_path(params[:my_module_id], + @tag, + format: :json), + turbolinks: false, + status: 303 + end end else respond_to do |format| @@ -84,9 +96,13 @@ class TagsController < ApplicationController flash[:success] = flash_success redirect_to root_path } - format.json { - redirect_to my_module_tags_edit_path(params[:my_module_id], @tag, format: :json), :status => 303 - } + format.json do + redirect_to my_module_tags_edit_path(params[:my_module_id], + @tag, + format: :json), + turbolinks: false, + status: 303 + end end else flash_error = t( @@ -98,10 +114,12 @@ class TagsController < ApplicationController flash[:error] = flash_error redirect_to root_path } - format.json { + format.json do # TODO - redirect_to my_module_tags_edit_path(format: :json), :status => 303 - } + redirect_to my_module_tags_edit_path(format: :json), + turbolinks: false, + status: 303 + end end end end diff --git a/app/controllers/user_my_modules_controller.rb b/app/controllers/user_my_modules_controller.rb index 29701f721..e4555b71d 100644 --- a/app/controllers/user_my_modules_controller.rb +++ b/app/controllers/user_my_modules_controller.rb @@ -94,9 +94,11 @@ class UserMyModulesController < ApplicationController ) respond_to do |format| - format.json { - redirect_to my_module_users_edit_path(format: :json), :status => 303 - } + format.json do + redirect_to my_module_users_edit_path(format: :json), + turbolinks: false, + status: 303 + end end else respond_to do |format| diff --git a/app/controllers/user_projects_controller.rb b/app/controllers/user_projects_controller.rb index 7a912209f..f8f2aa4e7 100644 --- a/app/controllers/user_projects_controller.rb +++ b/app/controllers/user_projects_controller.rb @@ -145,9 +145,11 @@ class UserProjectsController < ApplicationController generate_notification(current_user, @up.user, false, false, @project) respond_to do |format| - format.json { - redirect_to project_users_edit_path(format: :json), :status => 303 - } + format.json do + redirect_to project_users_edit_path(format: :json), + turbolinks: false, + status: 303 + end end else respond_to do |format| From 194054d973daa750c259af7ba48aeb0a14d00ae0 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 29 Nov 2017 22:55:10 +0100 Subject: [PATCH 3/4] Fix assignment of users to projects [SCI-1838] --- app/controllers/user_projects_controller.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/user_projects_controller.rb b/app/controllers/user_projects_controller.rb index 7a912209f..779d2479d 100644 --- a/app/controllers/user_projects_controller.rb +++ b/app/controllers/user_projects_controller.rb @@ -66,9 +66,9 @@ class UserProjectsController < ApplicationController ) respond_to do |format| - format.json { - redirect_to :action => :index_edit, :format => :json - } + format.json do + redirect_to project_users_edit_path(format: :json), turbolinks: false + end end else error = t('user_projects.create.can_add_user_to_project') @@ -110,9 +110,9 @@ class UserProjectsController < ApplicationController ) respond_to do |format| - format.json { - redirect_to :action => :index_edit, :format => :json - } + format.json do + redirect_to project_users_edit_path(format: :json), turbolinks: false + end end else respond_to do |format| @@ -145,9 +145,11 @@ class UserProjectsController < ApplicationController generate_notification(current_user, @up.user, false, false, @project) respond_to do |format| - format.json { - redirect_to project_users_edit_path(format: :json), :status => 303 - } + format.json do + redirect_to project_users_edit_path(format: :json), + turbolinks: false, + status: 303 + end end else respond_to do |format| From c4fe2b1c1132531f0dda016638334071db02b791 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Fri, 1 Dec 2017 10:48:07 +0100 Subject: [PATCH 4/4] Fix jsPlumb library loading [SCI-1839] --- app/assets/javascripts/application.js.erb | 2 ++ app/views/experiments/canvas.html.erb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index c235a5032..a32cb5713 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -29,6 +29,8 @@ //= require nested_form_fields //= require highlight.pack //= require tinymce-jquery +//= require jsPlumb-2.0.4-min +//= require jsnetworkx //= require_directory ./sitewide //= require jquery.dataTables.yadcf //= require datatables diff --git a/app/views/experiments/canvas.html.erb b/app/views/experiments/canvas.html.erb index ef6a09b04..279c5c3b6 100644 --- a/app/views/experiments/canvas.html.erb +++ b/app/views/experiments/canvas.html.erb @@ -65,8 +65,6 @@ <%= render partial: "my_modules/modals/manage_module_tags_modal", locals: { my_module: nil } %> -<%= javascript_include_tag("jsPlumb-2.0.4-min") %> -<%= javascript_include_tag("jsnetworkx") %> <%= javascript_include_tag("eventPause-min") %> <%= javascript_include_tag("projects/canvas") %>