From 8682bc6a83198bae457f8e8227a9484e78b034f7 Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Thu, 3 Oct 2024 15:27:51 -0400 Subject: [PATCH] Wire up filters for tags and assignees --- app/controllers/bubbles_controller.rb | 5 ++ app/views/bubbles/_filters.html.erb | 82 +++++++++++++++++++++++++ app/views/bubbles/index.html.erb | 86 ++------------------------- config/brakeman.ignore | 36 +---------- 4 files changed, 92 insertions(+), 117 deletions(-) create mode 100644 app/views/bubbles/_filters.html.erb diff --git a/app/controllers/bubbles_controller.rb b/app/controllers/bubbles_controller.rb index d4a475cb0..711b52a51 100644 --- a/app/controllers/bubbles_controller.rb +++ b/app/controllers/bubbles_controller.rb @@ -14,6 +14,11 @@ class BubblesController < ApplicationController @tag = Current.account.tags.find(params[:tag_id]) @bubbles = @bubbles.tagged_with(@tag) end + + if params[:assignee_id] + @assignee = @bucket.users.find(params[:assignee_id]) + @bubbles = @bubbles.assigned_to(@assignee) + end end def new diff --git a/app/views/bubbles/_filters.html.erb b/app/views/bubbles/_filters.html.erb new file mode 100644 index 000000000..29fa9a5fa --- /dev/null +++ b/app/views/bubbles/_filters.html.erb @@ -0,0 +1,82 @@ +

+
+ + + + +
  • Most active
  • +
  • Most discussed
  • +
  • Most boosted
  • +
  • Newest
  • +
  • Oldest
  • +
  • Popped
  • +
    +
    +
    + + in + +
    + + + + + <% Current.user.buckets.order(:name).each do |bucket| %> +
  • <%= link_to bucket.name, bucket_bubbles_path(bucket), class: "filter__button" %>
  • + <% end %> +
    +
    +
    +

    + +

    + <%= tag ? "Tagged" : "with" %> + +
    + + + + + <% Current.account.tags.order(:title).each do |tag| %> +
  • <%= link_to tag.title, params.permit(:filter, :assignee_id).merge(tag_id: tag.id) %>
  • + <% end %> +
    +
    + + <% if tag %> + <%= link_to params.permit(:filter, :assignee_id), class: "btn", style: "font-size: 0.4em;" do %> + <%= image_tag "remove.svg", aria: { hidden: true }, size: 24 %> + Clear + <% end %> + <% end %> +
    + + and + +
    + + + + + <% Current.account.users.order(:name).each do |user| %> +
  • <%= link_to user.name, params.permit(:filter, :tag_id).merge(assignee_id: user.id) %>
  • + <% end %> +
    +
    + + <% if assignee %> + <%= link_to params.permit(:filter, :tag_id), class: "btn", style: "font-size: 0.4em;" do %> + <%= image_tag "remove.svg", aria: { hidden: true }, size: 24 %> + Clear + <% end %> + <% end %> +
    +

    diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb index aacfebfd8..d1107512f 100644 --- a/app/views/bubbles/index.html.erb +++ b/app/views/bubbles/index.html.erb @@ -8,88 +8,7 @@ <% end %>
    -

    -
    - - - -
  • -
  • -
  • -
  • -
  • -
  • -
    -
    -
    - in -
    - - - - <% Current.user.buckets.order(:name).each do |bucket| %> -
  • - <% end %> -
    -
    -
    -

    - -

    - <% if @tag %> - Tagged - -
    - - - - <% Current.account.tags.order(:title).each do |tag| %> -
  • - <% end %> -
    -
    -
    - - <%= link_to bucket_bubbles_path(@bucket), class: "btn", style: "font-size: 0.4em;" do %> - <%= image_tag "remove.svg", aria: { hidden: true }, size: 24 %> - Clear - <% end %> - <% else %> - with - -
    - - - - <% Current.account.tags.order(:title).each do |tag| %> -
  • - <% end %> -
    -
    -
    - <% end %> - and -
    - - - - <% Current.account.users.order(:name).each do |user| %> -
  • - <% end %> -
    -
    -
    -

    + <%= render "bubbles/filters", bucket: @bucket, tag: @tag, assignee: @assignee %>
    <%= button_to bucket_bubbles_path(@bucket), method: :post, class: "btn btn--plain", form_class: "flex-item-justify-end" do %> @@ -107,6 +26,9 @@
    + <% params.permit(:tag_id, :assignee_id).each do |name, value| %> + <%= hidden_field_tag name, value %> + <% end %>
    diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 1ab2530ac..add1499e7 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -22,42 +22,8 @@ 89 ], "note": "" - }, - { - "warning_type": "Dynamic Render Path", - "warning_code": 15, - "fingerprint": "95ded3afec947789921bb5e8ce5d29bd8b2e1a7be03623ecd8810051769ef72d", - "check_name": "Render", - "message": "Render path contains parameter value", - "file": "app/views/bubbles/index.html.erb", - "line": 103, - "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", - "code": "render(action => @bucket.bubbles.not_popped.reverse_chronologically.mentioning(params[:filter]).ordered_by_activity.limit(10).tagged_with(Current.account.tags.find(params[:tag_id])), {})", - "render_path": [ - { - "type": "controller", - "class": "BubblesController", - "method": "index", - "line": 16, - "file": "app/controllers/bubbles_controller.rb", - "rendered": { - "name": "bubbles/index", - "file": "app/views/bubbles/index.html.erb" - } - } - ], - "location": { - "type": "template", - "template": "bubbles/index" - }, - "user_input": "params[:tag_id]", - "confidence": "Weak", - "cwe_id": [ - 22 - ], - "note": "" } ], - "updated": "2024-10-03 16:25:56 +0100", + "updated": "2024-10-03 15:28:53 -0400", "brakeman_version": "6.2.1" }