mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 21:24:23 +08:00
Allow tag creation on task level if you have permission [SCI-6573] (#4031)
This commit is contained in:
parent
e6cd26118c
commit
2b2888e6f7
2 changed files with 12 additions and 19 deletions
|
@ -2,7 +2,6 @@ class TagsController < ApplicationController
|
|||
before_action :load_vars, only: [:create, :update, :destroy]
|
||||
before_action :load_vars_nested, only: [:update, :destroy]
|
||||
before_action :check_manage_permissions, only: %i(create update destroy)
|
||||
before_action :check_manage_my_module_permissions, only: %i(create)
|
||||
|
||||
def create
|
||||
@tag = Tag.new(tag_params)
|
||||
|
@ -154,16 +153,12 @@ class TagsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def check_manage_my_module_permissions
|
||||
def check_manage_permissions
|
||||
my_module = MyModule.find_by id: params[:my_module_id]
|
||||
|
||||
render_403 if my_module && !can_manage_my_module_tags?(my_module)
|
||||
end
|
||||
|
||||
def check_manage_permissions
|
||||
render_403 unless can_manage_project_tags?(@project)
|
||||
end
|
||||
|
||||
def tag_params
|
||||
params.require(:tag).permit(:name, :color, :project_id)
|
||||
end
|
||||
|
|
|
@ -67,18 +67,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if can_manage_project_tags?(@my_module.experiment.project) && can_manage_my_module_tags?(@my_module) %>
|
||||
<div class="pull-right create-new-tag-btn">
|
||||
<%= bootstrap_form_for [@my_module.experiment.project, @new_tag], remote: true, format: :json, html: { class: 'add-tag-form' } do |f| %>
|
||||
<%= hidden_field_tag :my_module_id, @my_module.id %>
|
||||
<%= f.hidden_field :project_id, :value => @my_module.experiment.project.id %>
|
||||
<%= f.hidden_field :name, :value => t("tags.create.new_name") %>
|
||||
<%= f.hidden_field :color, :value => Constants::TAG_COLORS[0] %>
|
||||
<%= f.button class: "btn btn-primary" do %>
|
||||
<span class="fas fa-plus"></span>
|
||||
<span class="hidden-xs"><%=t "experiments.canvas.modal_manage_tags.create_new" %></span>
|
||||
<% end %>
|
||||
<div class="pull-right create-new-tag-btn">
|
||||
<%= bootstrap_form_for [@my_module.experiment.project, @new_tag], remote: true, format: :json, html: { class: 'add-tag-form' } do |f| %>
|
||||
<%= hidden_field_tag :my_module_id, @my_module.id %>
|
||||
<%= f.hidden_field :project_id, :value => @my_module.experiment.project.id %>
|
||||
<%= f.hidden_field :name, :value => t("tags.create.new_name") %>
|
||||
<%= f.hidden_field :color, :value => Constants::TAG_COLORS[0] %>
|
||||
<%= f.button class: "btn btn-primary" do %>
|
||||
<span class="fas fa-plus"></span>
|
||||
<span class="hidden-xs"><%=t "experiments.canvas.modal_manage_tags.create_new" %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue