From a31b6788f2d240e4c7d683f9d0a9250ca70a3707 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 2 Sep 2025 17:23:40 +0200 Subject: [PATCH] Add new tags controller [SCI-12286] --- app/controllers/tags_controller.rb | 7 +++++++ app/javascript/vue/shared/tags_input.vue | 7 ++----- app/serializers/my_module_serializer.rb | 6 +----- app/views/tags/index.json.jbuilder | 7 +++++++ config/routes.rb | 2 ++ 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 app/controllers/tags_controller.rb create mode 100644 app/views/tags/index.json.jbuilder diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb new file mode 100644 index 000000000..c68feefca --- /dev/null +++ b/app/controllers/tags_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class TagsController < ApplicationController + def index + @tags = current_team.tags.order(:name) + end +end diff --git a/app/javascript/vue/shared/tags_input.vue b/app/javascript/vue/shared/tags_input.vue index 3d579f367..a25a5301a 100644 --- a/app/javascript/vue/shared/tags_input.vue +++ b/app/javascript/vue/shared/tags_input.vue @@ -44,7 +44,7 @@ import axios from '../../packs/custom_axios.js'; import GeneralDropdown from './general_dropdown.vue'; import { - list_users_settings_team_tags_path, + tags_path } from '../../routes.js'; export default { @@ -59,9 +59,6 @@ export default { GeneralDropdown, }, computed: { - tagsUrl() { - return list_users_settings_team_tags_path({team_id: this.subject.attributes.team_id}); - }, tagResourceUrl() { return this.subject.attributes.urls.tag_resource; }, @@ -83,7 +80,7 @@ export default { }, methods: { loadAllTags() { - axios.get(this.tagsUrl).then((response) => { + axios.get(tags_path()).then((response) => { this.allTags = response.data.data; }); }, diff --git a/app/serializers/my_module_serializer.rb b/app/serializers/my_module_serializer.rb index 3599c232d..7c9ed1f0b 100644 --- a/app/serializers/my_module_serializer.rb +++ b/app/serializers/my_module_serializer.rb @@ -6,7 +6,7 @@ class MyModuleSerializer < ActiveModel::Serializer include ApplicationHelper include ActionView::Helpers::TextHelper - attributes :name, :description, :permissions, :description_view, :urls, :last_modified_by_name, :created_at, :updated_at, :tags, :team_id, + attributes :name, :description, :permissions, :description_view, :urls, :last_modified_by_name, :created_at, :updated_at, :tags, :project_name, :experiment_name, :created_by_name, :is_creator_current_user, :code, :designated_user_ids, :due_date_cell, :start_date_cell, :completed_on def project_name @@ -17,10 +17,6 @@ class MyModuleSerializer < ActiveModel::Serializer object.experiment.name end - def team_id - object.team.id - end - def created_by_name object.created_by&.full_name end diff --git a/app/views/tags/index.json.jbuilder b/app/views/tags/index.json.jbuilder new file mode 100644 index 000000000..a3813789f --- /dev/null +++ b/app/views/tags/index.json.jbuilder @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +json.data do + json.array! @tags do |t| + json.array! [t.id, t.name, t.color] + end +end diff --git a/config/routes.rb b/config/routes.rb index 7d3838542..35a606ba3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -225,6 +225,8 @@ Rails.application.routes.draw do to: 'zip_exports#file_expired', as: 'file_expired' + resources :tags, only: :index + resources :teams do resources :repositories, only: %i(index create destroy update) do collection do