From 377872dda31a380349b29253809379a9689c3d12 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Tue, 20 Dec 2022 10:37:40 +0400 Subject: [PATCH] hound code cleanup --- app/assets/javascripts/experiments/show.js | 28 +++++----------------- app/controllers/projects_controller.rb | 9 ++++--- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/experiments/show.js b/app/assets/javascripts/experiments/show.js index e8cad83d9..c67a209d7 100644 --- a/app/assets/javascripts/experiments/show.js +++ b/app/assets/javascripts/experiments/show.js @@ -27,9 +27,7 @@ // For submitting correct id values of the chosen tags $.map(dropdownSelector.getValues(myModuleTagsSelector), function(val) { if ($(`${myModuleTagsSelector} option[value=${val}]`).length === 0) { - $(myModuleTagsSelector).append( - $(``) - ); + $(myModuleTagsSelector).append($(``)); } else { $(`${myModuleTagsSelector} option[value=${val}]`).prop('selected', true); } @@ -100,9 +98,6 @@ if (lastTagId > 0) { newTag = { my_module_tag: { tag_id: lastTagId } }; - (function() { - dropdownSelector.removeValue(myModuleTagsSelector, lastTagId, '', true); - }); } else { newTag = { tag: { @@ -113,32 +108,21 @@ my_module_id: selectElement.data('module-id'), simple_creation: true }; - $.post(selectElement.data('tags-create-url'), newTag, function(result) { + $.post(selectElement.data('tags-create-url'), newTag, function(res) { dropdownSelector.removeValue(myModuleTagsSelector, 0, '', true); dropdownSelector.addValue(myModuleTagsSelector, { - value: result.tag.id, - label: result.tag.name, + value: res.tag.id, + label: res.tag.name, params: { - color: result.tag.color + color: res.tag.color } }, true); }).fail(function() { dropdownSelector.removeValue(myModuleTagsSelector, lastTagId, '', true); }); } - }, - onUnSelect: (id) => { - $.post(`${$(myModuleTagsSelector).data('update-module-tags-url')}/${id}/destroy_by_tag_id`) - .success(function() { - dropdownSelector.closeDropdown(myModuleTagsSelector); - }) - .fail(function(r) { - if (r.status === 403) { - HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger'); - } - }); } - }) + }); }); } diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d85d9effe..56edfb4ab 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -264,15 +264,14 @@ class ProjectsController < ApplicationController end end - def create_tag render_403 unless can_manage_project_tags?(@project) @tag = @project.tags.create(tag_params.merge({ - created_by: current_user, - last_modified_by: current_user, - color: Constants::TAG_COLORS.sample - })) + created_by: current_user, + last_modified_by: current_user, + color: Constants::TAG_COLORS.sample + })) render json: { tag: {