Skip to content

Commit

Permalink
Merge pull request #35161 from dimagi/jls/b5-export-list
Browse files Browse the repository at this point in the history
[B5] Exports: list and download pages
  • Loading branch information
orangejenny authored Oct 22, 2024
2 parents 2cde1b2 + 2c231ce commit bd6a16e
Show file tree
Hide file tree
Showing 41 changed files with 750 additions and 536 deletions.
7 changes: 0 additions & 7 deletions corehq/apps/export/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,6 @@ def __init__(self, domain_object, *args, **kwargs):
self.domain_object = domain_object
super(EmwfFilterFormExport, self).__init__(domain_object, *args, **kwargs)

self.helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
self.helper.field_class = 'col-sm-9 col-md-8 col-lg-3'

def get_model_filter(self, mobile_user_and_group_slugs, can_access_all_locations, accessible_location_ids):
"""
:param mobile_user_and_group_slugs: slug from request like
Expand Down Expand Up @@ -988,8 +985,6 @@ def __init__(self, domain_object, timezone, *args, **kwargs):
self.timezone = timezone
super(FilterCaseESExportDownloadForm, self).__init__(domain_object, *args, **kwargs)

self.helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
self.helper.field_class = 'col-sm-9 col-md-8 col-lg-3'
# update date_range filter's initial values to span the entirety of
# the domain's submission range
default_datespan = datespan_from_beginning(self.domain_object, self.timezone)
Expand Down Expand Up @@ -1046,8 +1041,6 @@ def __init__(self, domain_object, timezone, *args, **kwargs):
self.timezone = timezone
super(FilterSmsESExportDownloadForm, self).__init__(domain_object, *args, **kwargs)

self.helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
self.helper.field_class = 'col-sm-9 col-md-8 col-lg-3'
# update date_range filter's initial values to span the entirety of
# the domain's submission range
default_datespan = datespan_from_beginning(self.domain_object, self.timezone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ hqDefine('export/js/bootstrap5/download_export', [
'underscore',
'hqwebapp/js/assert_properties',
'hqwebapp/js/initial_page_data',
'hqwebapp/js/tempus_dominus',
'analytix/js/google',
'analytix/js/kissmetrix',
'reports/js/filters/bootstrap5/main',
'reports/js/reports.util',
'export/js/utils',
'hqwebapp/js/daterangepicker.config', // createDateRangePicker
'jquery.cookie/jquery.cookie', // for resuming export downloads on refresh
], function (
$,
ko,
_,
assertProperties,
initialPageData,
hqTempusDominus,
googleAnalytics,
kissmetricsAnalytics,
reportFilters,
Expand Down Expand Up @@ -435,12 +436,7 @@ hqDefine('export/js/bootstrap5/download_export', [

$(".hqwebapp-datespan").each(function () {
var $el = $(this).find("input");
$el.createDateRangePicker( /* todo B5: plugin:createDateRangePicker */
$el.data("labels"),
$el.data("separator"),
$el.data('startDate'),
$el.data('endDate')
);
hqTempusDominus.createDateRangePicker($el.get(0), $el.data("separator"));
});
});
});
28 changes: 8 additions & 20 deletions corehq/apps/export/static/export/js/bootstrap5/export_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hqDefine("export/js/bootstrap5/export_list", [
'knockout',
'underscore',
'hqwebapp/js/assert_properties',
'es6!hqwebapp/js/bootstrap5_loader',
'clipboard/dist/clipboard',
'analytix/js/google',
'analytix/js/kissmetrix',
Expand All @@ -30,6 +31,7 @@ hqDefine("export/js/bootstrap5/export_list", [
ko,
_,
assertProperties,
bootstrap,
Clipboard,
googleAnalytics,
kissmetricsAnalytics,
Expand Down Expand Up @@ -183,7 +185,8 @@ hqDefine("export/js/bootstrap5/export_list", [
self.isAutoRebuildEnabled(data.isAutoRebuildEnabled);
}
$button.enableButton();
$('#modalEnableDisableAutoRefresh-' + self.id() + '-' + self.emailedExport.groupId()).modal('hide'); /* todo B5: plugin:modal */
const modalId = 'modalEnableDisableAutoRefresh-' + self.id() + '-' + self.emailedExport.groupId();
bootstrap.Modal.getInstance('#' + modalId).hide();
},
});
};
Expand Down Expand Up @@ -263,7 +266,9 @@ hqDefine("export/js/bootstrap5/export_list", [
};

self.updateData = function () {
$('#modalRefreshExportConfirm-' + exportId + '-' + self.groupId()).modal('hide'); /* todo B5: plugin:modal */
const modalId = 'modalRefreshExportConfirm-' + exportId + '-' + self.groupId();
bootstrap.Modal.getInstance('#' + modalId).hide();

self.updatingData(true);
$.ajax({
method: 'POST',
Expand Down Expand Up @@ -464,23 +469,6 @@ hqDefine("export/js/bootstrap5/export_list", [
return true;
};

var tooltipText = "";
if (self.isOData || self.isFeed) {
tooltipText = gettext("All of the selected feeds will be deleted.");
} else {
tooltipText = gettext("All of the selected exports will be deleted.");
}

$(function () {
$('[data-toggle="tooltip-bulkExport"]').attr('title',
gettext("All of the selected exports will be collected for download to a " +
"single Excel file, with each export as a separate sheet.")).tooltip(); /* todo B5: plugin:tooltip */
});

$(function () {
$('[data-toggle="tooltip-bulkDelete"]').attr('title', tooltipText).tooltip({trigger: 'hover'}); /* todo B5: plugin:tooltip */
});

self.isMultiple = ko.computed(function () {
if (self.bulkDeleteList().length > 1) { return true; }
return false;
Expand Down Expand Up @@ -682,7 +670,7 @@ hqDefine("export/js/bootstrap5/export_list", [
if (export_.hasEmailedExport) {
export_.emailedExport.pollProgressBar();
}
self.$filterModal.modal('hide'); /* todo B5: plugin:modal */
bootstrap.Modal.getInstance(self.$filterModal.get(0)).hide();
} else {
self.formSubmitErrorMessage(data.error);
}
Expand Down
2 changes: 2 additions & 0 deletions corehq/apps/export/static/export/js/create_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ hqDefine("export/js/create_export", [
$formElem.select2({
data: self._app_types || [],
width: '100%',
dropdownParent: $("#createExportOptionsModal"),
}).val(drilldownDefaults.app_type).trigger('change');
}
},
Expand All @@ -152,6 +153,7 @@ hqDefine("export/js/create_export", [
$formElem.select2({
data: fieldData || [],
width: '100%',
dropdownParent: $("#createExportOptionsModal"),
}).val(drilldownDefaults[fieldSlug]).trigger('change');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,6 @@
{% load hq_shared_tags %}
{% load compress %}

{% block stylesheets %}
<style type="text/css">
.form-notice-container {
position: relative;
}
.form-notice {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.6);
/*The z-index is set to cover date input text-box with class .input-group .form-control */
/*Its z-index is set to 2 by bootstrap, so making this 3 */
z-index: 3;

}
.form-notice .label {
display: block;
}
.progress-exports {
margin-bottom: 2px;
margin-top: 6px;
}
.form-actions-exports {
margin-bottom: 30px;
}
</style>
{% endblock stylesheets %}

{% requirejs_main_b5 'export/js/bootstrap5/download_export' %}

{% block page_title %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'hqwebapp/bootstrap3/base_section.html' %}
{% extends 'hqwebapp/bootstrap5/base_section.html' %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load hq_shared_tags %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<div data-bind="attr: {id: 'bulk-delete-export-modal'}" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="color:black;"> {# todo B5: css:modal-header, inline style #}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> {# todo B5: css:close #}
<div class="modal-header">
<h4 class="modal-title">
<!-- ko if: isOData || isFeed -->
<!-- ko if: isMultiple -->
Expand All @@ -27,8 +26,9 @@ <h4 class="modal-title">
<!-- /ko -->
<!-- /ko -->
</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans_html_attr "Close" %}"></button>
</div>
<div class="modal-body" style="color:black;"> {# todo B5: inline style #}
<div class="modal-body">
<p>
<!-- ko if: isOData || isFeed -->
<!-- ko if: isMultiple -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<div data-bind="attr: {id: 'delete-export-modal-' + id()}" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> {# todo B5: css:modal-header #}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> {# todo B5: css:close #}
<div class="modal-header">
<h4 class="modal-title">
<!-- ko if: isOData() -->
{% blocktrans %}
Expand All @@ -17,6 +16,7 @@ <h4 class="modal-title">
{% endblocktrans %}
<!-- /ko -->
</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans_html_attr "Close" %}"></button>
</div>
<form name="drop_report" data-bind="attr: {action: deleteUrl}" method="post">
{% csrf_token %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
<div class="modal fade" tabindex="-1" role="dialog" id="export-process-deleted-applications">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"> {# todo B5: css:modal-header #}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> {# todo B5: css:close #}
<span aria-hidden="true">&times;</span>
</button>
<div class="modal-header">
<h4 class="modal-title">
{% if export_instance.type == 'form' %}
{% trans "Show Deleted Questions" %}
{% else %}
{% trans "Show Deleted Properties" %}
{% endif %}
</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans_html_attr "Close" %}"></button>
</div>
<div class="modal-body">
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
<div class="modal fade" tabindex="-1" role="dialog" id="export-process-deprecated-properties">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"> {# todo B5: css:modal-header #}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> {# todo B5: css:close #}
<span aria-hidden="true">&times;</span>
</button>
<div class="modal-header">
<h4 class="modal-title">
{% trans "Show Deprecated Properties" %}
</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans_html_attr "Close" %}"></button>
</div>
<div class="modal-body">
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
{% load i18n %}
<div data-bind="visible: bulkExportDownloadCount()">
<div class="float-end" data-bs-toggle="tooltip-bulkDelete" data-placement="top">
<input name="delete_list" type="hidden"/>
<p style="float:right"> {# todo B5: inline style #}
<a class="btn btn-outline-danger btn-primary"
data-bs-toggle="modal"
data-bind="attr: {
href: '#bulk-delete-export-modal'
}">
<!-- ko if: isOData || isFeed -->
<!-- ko if: isMultiple -->
{% trans "Delete Selected Feeds" %}
<!-- /ko -->
<!-- ko if: !isMultiple() -->
{% trans "Delete Selected Feed" %}
<!-- /ko -->
<!-- /ko -->
<!-- ko if: !isOData && !isFeed -->
<!-- ko if: isMultiple -->
{% trans "Delete Selected Exports" %}
<!-- /ko -->
<!-- ko if: !isMultiple() -->
{% trans "Delete Selected Export" %}
<!-- /ko -->
<!-- /ko -->
</a>
{% include "export/dialogs/bootstrap5/bulk_delete_custom_export_dialog.html" %}
</p>
</div>
</div>
<span data-bind="visible: bulkExportDownloadCount()">
<input name="delete_list" type="hidden"/>
<a class="btn btn-outline-danger float-end"
data-bs-toggle="modal"
data-bind="attr: {
href: '#bulk-delete-export-modal'
}">
<!-- ko if: isOData || isFeed -->
<!-- ko if: isMultiple -->
{% trans "Delete Selected Feeds" %}
<!-- /ko -->
<!-- ko if: !isMultiple() -->
{% trans "Delete Selected Feed" %}
<!-- /ko -->
<!-- /ko -->
<!-- ko if: !isOData && !isFeed -->
<!-- ko if: isMultiple -->
{% trans "Delete Selected Exports" %}
<!-- /ko -->
<!-- ko if: !isMultiple() -->
{% trans "Delete Selected Export" %}
<!-- /ko -->
<!-- /ko -->
</a>
{% include "export/dialogs/bootstrap5/bulk_delete_custom_export_dialog.html" %}
</span>
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
{% load i18n %}
<div data-bind="visible: bulkExportDownloadCount()"
style="float:right; margin-left:8px; margin-bottom:8px"> {# todo B5: inline style #}
<form class="form form-inline" method="post" {# todo B5: css:form-inline #}
<span class="d-inline-block ms-2 float-end" data-bind="visible: bulkExportDownloadCount()">
<form class="form d-inline" method="post"
data-bind="submit: submitBulkExportDownload"
action="{{ bulk_download_url }}">
{% csrf_token %}
<div style="min-width:110px;" data-bs-toggle="tooltip-bulkExport" data-container=".tooltip-bulk-export" data-placement="top"> {# todo B5: inline style #}
<input name="export_list" type="hidden" data-bind="value: bulkExportList" />
<button type="submit"
class="btn btn-primary tooltip-bulk-export"
style="width: 100%;"> {# todo B5: inline style #}
{% trans 'Bulk Export' %}
(<!-- ko text: bulkExportDownloadCount() --><!-- /ko -->)
</button>
</div>
<input name="export_list" type="hidden" data-bind="value: bulkExportList" />
<button type="submit"
class="btn btn-primary">
{% trans 'Bulk Export' %}
(<!-- ko text: bulkExportDownloadCount() --><!-- /ko -->)
</button>
<span class="hq-help-template"
data-title="{% trans "Bulk Export" %}"
data-content="{% trans "All of the selected exports will be collected for download to a single Excel file, with each export as a separate sheet." %}"
data-placement="left"
></span>
</form>
</div>

<style>
.tooltip-bulk-export .tooltip .tooltip-inner {
margin-right: 10px;
}
</style>
</span>
Loading

0 comments on commit bd6a16e

Please sign in to comment.