-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass filter via url params and tweak message threads table title base…
…d on filter or query
- Loading branch information
Showing
13 changed files
with
85 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
class MessageThreadsBulkActionsComponent < ViewComponent::Base | ||
def initialize(ids:) | ||
def initialize(ids: nil, filter: nil, query: nil) | ||
@ids = ids | ||
@filter = filter | ||
@query = query | ||
end | ||
|
||
def title | ||
return t(:selected_message, count: @ids.count) if @ids.present? | ||
return "Správy z filtra '#{@filter.name}'" if @filter.present? | ||
return "Správy vyhovujúce hľadanému výrazu '#{@query}'" if @query.present? | ||
|
||
"Správy v schránke" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
class MessageThreadsTableComponent < ViewComponent::Base | ||
renders_many :message_threads | ||
renders_one :next_page_area | ||
|
||
attr_reader :filter, :query | ||
|
||
def initialize(filter: nil, query: nil) | ||
@filter = filter | ||
@query = query | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
class TW::TopNavigationComponent < ViewComponent::Base | ||
include MessageThreadHelper | ||
|
||
def initialize(current_tenant_boxes_count) | ||
@current_tenant_boxes_count = current_tenant_boxes_count | ||
end | ||
|
||
def query | ||
query_params = params | ||
.permit(:filter_id, :q) | ||
.slice(:filter_id, :q) | ||
|
||
Searchable::QueryBuilder.new( | ||
filter_id: query_params[:filter_id], | ||
query: query_params[:q], | ||
).build | ||
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module MessageThreadHelper | ||
def filtered_message_threads_path(filter: nil, query: nil) | ||
args = { | ||
filter_id: filter&.id, | ||
q: query | ||
}.compact | ||
|
||
message_threads_path(args) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Searchable::QueryBuilder | ||
attr_reader :filter, :filter_id, :query, :user | ||
|
||
def initialize(filter: nil, filter_id: nil, query: nil, user: nil) | ||
@filter = filter | ||
@filter_id = filter_id | ||
@query = query | ||
@user = user | ||
end | ||
|
||
def build | ||
if filter.nil? && filter_id.present? | ||
@filter = FilterPolicy::ScopeShowable.new(user, Filter).resolve.find_by(id: filter_id) | ||
end | ||
|
||
[ | ||
filter&.query, | ||
query, | ||
] | ||
.compact | ||
.map(&:strip) | ||
.join(' ') | ||
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