-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tagging to tickets on items (#1796)
# What it does Allows admins to tag tickets and see them on the ticket index and show pages. # Why it is important #1746 # UI Change Screenshot Tags on the index page: ![Screenshot 2024-12-18 at 3 35 29 PM](https://github.com/user-attachments/assets/eab9fcc3-331f-4ad4-bbea-71435ced7af2) Tags on the show page: ![Screenshot 2024-12-18 at 3 37 17 PM](https://github.com/user-attachments/assets/f618af96-f482-4040-ae3a-823d05295e82) Tags on the edit page: ![Screenshot 2024-12-18 at 3 37 26 PM](https://github.com/user-attachments/assets/a187ebc9-a1a1-44db-9407-67a46553f7a4) Tags on the new page: ![Screenshot 2024-12-18 at 3 37 41 PM](https://github.com/user-attachments/assets/92f99a96-4836-48c1-acbd-fb3ee995c741) # Implementation notes I rebased #1795 into this since the tagging gem requires `>= 3.2` Ruby. Once that's merged this diff should be a little easier to understand. Right now the tags just appear as light gray chips or pills. We could add special styles for special tags (eg 'Urgent' with a red background) but I think this is a good first pass. The tags look case sensitive but actually aren't. So if you're the first person to tag something as `Urgent` it will show up as `Urgent` event if you change it to `urgent`. That also goes for any other tickets that are tagged `Urgent`. In terms of tests, I just added onto some existing controller tests. Maybe system tests for this ticket stuff, but converting them felt like a lot for right now. In the process of troubleshooting the gem setup I added a model test that probably isn't _really_ necessary but that file was empty anyway.
- Loading branch information
Showing
12 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ActsAsTaggableOn.force_lowercase = true |
36 changes: 36 additions & 0 deletions
36
db/migrate/20241218224853_acts_as_taggable_on_migration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class ActsAsTaggableOnMigration < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table "taggings", force: :cascade do |t| | ||
t.bigint "tag_id" | ||
t.string "taggable_type" | ||
t.bigint "taggable_id" | ||
t.string "tagger_type" | ||
t.bigint "tagger_id" | ||
t.string "context", limit: 128 | ||
t.datetime "created_at", precision: nil | ||
t.string "tenant", limit: 128 | ||
t.index ["context"], name: "index_taggings_on_context" | ||
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true | ||
t.index ["tag_id"], name: "index_taggings_on_tag_id" | ||
t.index ["taggable_id", "taggable_type", "context"], name: "taggings_taggable_context_idx" | ||
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy" | ||
t.index ["taggable_id"], name: "index_taggings_on_taggable_id" | ||
t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable_type_and_taggable_id" | ||
t.index ["taggable_type"], name: "index_taggings_on_taggable_type" | ||
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type" | ||
t.index ["tagger_id"], name: "index_taggings_on_tagger_id" | ||
t.index ["tagger_type", "tagger_id"], name: "index_taggings_on_tagger_type_and_tagger_id" | ||
t.index ["tenant"], name: "index_taggings_on_tenant" | ||
end | ||
|
||
create_table "tags", force: :cascade do |t| | ||
t.string "name" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.integer "taggings_count", default: 0 | ||
t.index ["name"], name: "index_tags_on_name", unique: true | ||
end | ||
|
||
add_foreign_key "taggings", "tags" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
require "test_helper" | ||
|
||
class TicketTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
test "has tags" do | ||
ticket = create(:ticket) | ||
|
||
ticket.tag_list.add("aWesoMe", "NOT awesome") | ||
assert ticket.save | ||
|
||
ticket.reload | ||
|
||
assert_equal ["awesome", "not awesome"], ticket.tag_list | ||
|
||
ticket.tag_list.remove("not awesome") | ||
|
||
assert ticket.save | ||
|
||
ticket.reload | ||
assert_equal ["awesome"], ticket.tag_list | ||
end | ||
end |