mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Merge pull request #1447 from okriuchykhin/ok_SCI_2875_v2
Fix task tags update on canvas cards [SCI-2875]
This commit is contained in:
commit
0766ee96a7
6 changed files with 33 additions and 15 deletions
|
@ -873,18 +873,21 @@ function bindEditTagsAjax(elements) {
|
|||
manageTagsModalBody = manageTagsModal.find(".modal-body");
|
||||
|
||||
// Reload tags HTML element when modal is closed
|
||||
manageTagsModal.on("hide.bs.modal", function(){
|
||||
manageTagsModal.off().on("hide.bs.modal", function(){
|
||||
var task = $("div.panel[data-module-id='" +
|
||||
manageTagsModal.data('module-id') + "']");
|
||||
|
||||
// Load HTML
|
||||
$.ajax({
|
||||
url: task.attr("data-module-tags-url"),
|
||||
url: $('#canvas-container').attr('data-module-tags-url'),
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
task.find(".edit-tags-link")
|
||||
.html(data.html_canvas);
|
||||
success: function(data) {
|
||||
$.each(data.my_modules, function(index, my_module){
|
||||
$('div.panel[data-module-id=' + my_module.id + ']')
|
||||
.find(".edit-tags-link")
|
||||
.html(my_module.tags_html);
|
||||
});
|
||||
// initialize tooltips again
|
||||
$.initTooltips();
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class MyModuleTagsController < ApplicationController
|
||||
before_action :load_vars
|
||||
before_action :load_vars, except: :canvas_index
|
||||
before_action :check_view_permissions, only: :index
|
||||
before_action :check_manage_permissions, only: %i(create index_edit destroy)
|
||||
|
||||
|
@ -25,10 +25,6 @@ class MyModuleTagsController < ApplicationController
|
|||
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 }
|
||||
|
@ -38,6 +34,26 @@ class MyModuleTagsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def canvas_index
|
||||
experiment = Experiment.find(params[:id])
|
||||
render_403 unless can_read_experiment?(experiment)
|
||||
res = []
|
||||
experiment.active_my_modules.each do |my_module|
|
||||
res << {
|
||||
id: my_module.id,
|
||||
tags_html: render_to_string(
|
||||
partial: 'canvas/tags.html.erb',
|
||||
locals: { my_module: my_module }
|
||||
)
|
||||
}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: { my_modules: res }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@mt = MyModuleTag.new(mt_params.merge(my_module: @my_module))
|
||||
@mt.created_by = current_user
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
data-module-x="<%= my_module.x %>"
|
||||
data-module-y="<%= my_module.y %>"
|
||||
data-module-conns="<%= construct_module_connections(my_module) %>"
|
||||
data-module-tags-url="<%= my_module_my_module_tags_url(my_module, format: :json) %>"
|
||||
data-module-users-tab-url="<%= my_module_user_my_modules_url(my_module_id: my_module.id, format: :json) %>">
|
||||
data-module-tags-url="<%= my_module_tags_experiment_path(my_module.experiment, format: :json) %>">
|
||||
|
||||
<% if can_manage_module?(my_module) %>
|
||||
<a class="edit-tags-link pull-right" data-remote="true" href="<%= my_module_tags_edit_url(my_module, format: :json) %>">
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
<% end %>
|
||||
data-module-x="<%= my_module.x %>"
|
||||
data-module-y="<%= my_module.y %>"
|
||||
data-module-conns="<%= construct_module_connections(my_module) %>"
|
||||
data-module-tags-url="<%= my_module_my_module_tags_url(my_module, format: :json) %>">
|
||||
data-module-conns="<%= construct_module_connections(my_module) %>">
|
||||
|
||||
<% if can_manage_module?(my_module) %>
|
||||
<a class="edit-tags-link pull-right" data-remote="true" href="<%= my_module_tags_edit_url(my_module, format: :json) %>">
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>">
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>" data-module-tags-url="<%= my_module_tags_experiment_path(@experiment, format: :json) %>">
|
||||
<%= render partial: 'canvas/full_zoom', locals: { experiment: @experiment, my_modules: @active_modules } %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -311,6 +311,7 @@ Rails.application.routes.draw do
|
|||
get 'canvas/small_zoom', to: 'canvas#small_zoom' # AJAX-loaded canvas zoom
|
||||
post 'canvas', to: 'canvas#update' # Save updated canvas action
|
||||
get 'module_archive' # Module archive for single experiment
|
||||
get 'my_module_tags', to: 'my_module_tags#canvas_index'
|
||||
get 'archive' # archive experiment
|
||||
get 'clone_modal' # return modal with clone options
|
||||
post 'clone' # clone experiment
|
||||
|
|
Loading…
Reference in a new issue