Skip to content

Commit

Permalink
Disable header row bulk_coop report
Browse files Browse the repository at this point in the history
  • Loading branch information
aintluks committed Aug 13, 2022
1 parent 4766c7a commit 8e85960
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/views/admin/reports/_rendering_options.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
.omega.fourteen.columns
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))

.row.rendering-options{ "data-controller": "csv-header-report" }
.alpha.two.columns
= label_tag :report_format, t(".generate_report")
.omega.fourteen.columns
= select_tag :report_format, grouped_options_for_select({ |
t('.formatted_data') => { t('.on_screen') => '', "PDF" => 'pdf', t('.spreadsheet') => 'xlsx' }, |
t('.raw_data') => { "CSV" => 'csv' }, |
}), { "data-csv-header-report-target": "reportType", "data-action": "csv-header-report#handleSelectChange" }

- if @report.header_option? || @report.summary_row_option?
.row
Expand All @@ -33,14 +41,3 @@
.omega.fourteen.columns
= select_tag(:fields_to_hide, options_for_select(@report.available_headers, params[:fields_to_hide]),
class: "select2 fullwidth", multiple: true)
.row.rendering-options
.alpha.two.columns
= label_tag :report_format, t(".generate_report")
.omega.fourteen.columns
= select_tag :report_format, grouped_options_for_select({ |
t('.formatted_data') => { t('.on_screen') => '', "PDF" => 'pdf', t('.spreadsheet') => 'xlsx' }, |
t('.raw_data') => { "CSV" => 'csv' }, |
})
19 changes: 19 additions & 0 deletions app/webpacker/controllers/csv_header_report_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Controller } from "stimulus";

export default class extends Controller {
static targets = ["reportType"]

handleSelectChange() {
let displayHeaderRow = document.querySelector("#display_header_row");
let displayHeaderRowLabel = displayHeaderRow.nextElementSibling;

if (this.reportTypeTarget.value == "csv") {
displayHeaderRow.checked = false;
displayHeaderRow.disabled = true;
displayHeaderRowLabel.style.color = "#CCCCCC";
} else {
displayHeaderRow.disabled = false;
displayHeaderRowLabel.style.color = "#809CB1";
}
}
}

0 comments on commit 8e85960

Please sign in to comment.