Added the right box to rename columns on export CSV
This commit is contained in:
parent
ed0ea58202
commit
4f68749cb4
3 changed files with 33 additions and 15 deletions
|
|
@ -863,7 +863,7 @@ function copy_clipboard(shareable_link) {
|
|||
}
|
||||
|
||||
function display_rename_column(bool, id) {
|
||||
if (bool) document.getElementById(id).style.display = 'block';
|
||||
if (bool) document.getElementById(id).style.display = 'flex';
|
||||
else document.getElementById(id).style.display = 'none';
|
||||
}
|
||||
|
||||
|
|
@ -877,24 +877,31 @@ function export_csv() {
|
|||
let final_export = [];
|
||||
// Verify which items are checked
|
||||
let export_lists = document.getElementsByName('checkedItems');
|
||||
let checked_items = [];
|
||||
let checked_items = []; // The column to be added, with the id to be identified.
|
||||
let checked_names = []; // The column with the respective rename.
|
||||
let has_alternative_scenario = false;
|
||||
export_lists.forEach(e => {
|
||||
if (e.checked) {
|
||||
if (e.id != "Alternative Scenarios") checked_items.push(e.id);
|
||||
let has_rename = document.getElementById(`${e.id}__rename`).value;
|
||||
let column_name = has_rename != '' ? has_rename : e.id;
|
||||
if (e.id != "Alternative Scenarios") {
|
||||
checked_names.push(column_name);
|
||||
checked_items.push(e.id);
|
||||
}
|
||||
else if (e.id == "Alternative Scenarios") {
|
||||
Object.entries(alternative_scenarios).map((scenario) => {
|
||||
if (scenario[0] != 'Current scenario') {
|
||||
checked_items.push(`Alternative scenario - ${scenario[0]}`);
|
||||
checked_names.push(`Alternative scenario - ${column_name}`);
|
||||
checked_items.push(`Alternative scenario - ${e.id}`);
|
||||
has_alternative_scenario = true;
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
final_export.push(checked_items);
|
||||
final_export.push(checked_names);
|
||||
|
||||
// Add the data for each column.
|
||||
// Add data for each column.
|
||||
times.forEach((e, i) => {
|
||||
let this_row = [];
|
||||
checked_items.includes("Times") && this_row.push(times[i]);
|
||||
|
|
|
|||
|
|
@ -50,34 +50,46 @@
|
|||
<div class="form-check mt-3">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Times" onclick="display_rename_column(this.checked, 'times-rename-div')">
|
||||
<label class="form-check-label" for="Times">Times of day</label>
|
||||
<div id="times-rename-div" style="display:none">
|
||||
<label class="col-form-label" for="times-rename">Column name:</label>
|
||||
<input type="text" class="form-control form-control-sm col-sm-4" id="times-rename" placeholder="Times" value="Times">
|
||||
<div id="times-rename-div" class="align-items-center" style="display:none">
|
||||
<label class="col-form-label" for="times-rename-div">Column name:</label>
|
||||
<input type="text" class="form-control form-control-sm col-sm-4 ml-2" id="Times__rename" placeholder="Times" value="Times">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Concentrations">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Concentrations" onclick="display_rename_column(this.checked, 'concentrations-rename-div')">
|
||||
<label class="form-check-label" for="Concentrations">Concentrations</label>
|
||||
<div id="concentrations-rename-div" class="align-items-center" style="display:none">
|
||||
<label class="col-form-label" for="concentrations-rename-div">Column name:</label>
|
||||
<input type="text" class="form-control form-control-sm col-sm-4 ml-2" id="Concentrations__rename" placeholder="Concentrations" value="Concentrations">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Cumulative Dose">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Cumulative Dose" onclick="display_rename_column(this.checked, 'cumulative-dose-rename-div')">
|
||||
<label class="form-check-label" for="Cumulative Dose">Cumulative dose</label>
|
||||
<div id="cumulative-dose-rename-div" class="align-items-center" style="display:none">
|
||||
<label class="col-form-label" for="cumulative-dose-rename-div">Column name:</label>
|
||||
<input type="text" class="form-control form-control-sm col-sm-4 ml-2" id="Cumulative Dose__rename" placeholder="Cumulative Dose" value="Cumulative Dose">
|
||||
</div>
|
||||
</div>
|
||||
{% if form.short_range_option == "short_range_yes" %}
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Long-Range Dose">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Long-Range Dose" onclick="display_rename_column(this.checked, 'long-range-rename-div')">
|
||||
<label class="form-check-label" for="Long-Range Dose">Long-range dose</label>
|
||||
<div id="long-range-rename-div" class="align-items-center" style="display:none">
|
||||
<label class="col-form-label" for="long-range-rename-div">Column name:</label>
|
||||
<input type="text" class="form-control form-control-sm col-sm-4 ml-2" id="Long-Range Dose__rename" placeholder="Long-Range Dose" value="Long-Range Dose">
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Alternative Scenarios">
|
||||
<input type="checkbox" class="form-check-input" name="checkedItems" id="Alternative Scenarios" onclick="display_rename_column(this.checked, 'alternative-scenarios-rename-div')">
|
||||
<label class="form-check-label" for="Alternative Scenarios">Alternative Scenarios</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" onclick="export_csv();">Export</button>
|
||||
<button type="button" class="btn btn-primary" onclick="export_csv();">Download</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
{% set active_page="home/" %}
|
||||
|
||||
{% block main %}
|
||||
{# <div style="height: 5em; display: block;"></div> #}
|
||||
<header class= "bg-light">
|
||||
<div class="container container--padding">
|
||||
<img src="/static/images/cara_full_text.png" class="logo d-block m-auto" id="desktop_logo">
|
||||
|
|
|
|||
Loading…
Reference in a new issue