-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7795 from aignatov-bio/ai-sci-10967-prepare-custo…
…m-docx-reports Add basic support for custom templates docx [SCI-10967]
- Loading branch information
Showing
25 changed files
with
552 additions
and
87 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
11 changes: 11 additions & 0 deletions
11
app/components/reports/repositories_input_component.html.erb
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,11 @@ | ||
<% if @editing %> | ||
<div class="sci-select-container"> | ||
<%= label_tag @name, @label %> | ||
<%= select_tag @name, options_from_collection_for_select(@repositories, :id, :name, @value), placeholder: @placeholder, class: 'sci-input-field report-template-value-dropdown', data: { type: 'RepositoriesInputComponent' }, multiple: true %> | ||
</div> | ||
<% else %> | ||
<% @project_members.where(id: @value).each do |member| %> | ||
<%= member.public_send(@displayed_field) %> | ||
<br> | ||
<% 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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Reports | ||
class RepositoriesInputComponent < TemplateValueComponent | ||
def initialize(report:, name:, label:, placeholder: nil, editing: true, displayed_field: :name) | ||
super(report: report, name: name, label: label, placeholder: placeholder, editing: editing) | ||
|
||
live_repositories = Repository.accessible_by_teams(report.team).sort_by { |r| r.name.downcase } | ||
snapshots_of_deleted = RepositorySnapshot.left_outer_joins(:original_repository) | ||
.where(team: report.team) | ||
.where.not(original_repository: live_repositories) | ||
.select('DISTINCT ON ("repositories"."parent_id") "repositories".*') | ||
.sort_by { |r| r.name.downcase } | ||
@repositories = live_repositories + snapshots_of_deleted | ||
@displayed_field = displayed_field | ||
end | ||
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
Oops, something went wrong.