-
-
Notifications
You must be signed in to change notification settings - Fork 218
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 #35117 from dimagi/jls/b5-export-1
[B5] Exports: split files into B3 and B5 versions
- Loading branch information
Showing
100 changed files
with
7,398 additions
and
45 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
4 changes: 2 additions & 2 deletions
4
.../static/export/js/customize_export_new.js → ...ort/js/bootstrap3/customize_export_new.js
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
2 changes: 1 addition & 1 deletion
2
...t/static/export/js/download_data_files.js → ...port/js/bootstrap3/download_data_files.js
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
4 changes: 2 additions & 2 deletions
4
...port/static/export/js/export_list_main.js → .../export/js/bootstrap3/export_list_main.js
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
2 changes: 1 addition & 1 deletion
2
...rt/static/export/js/incremental_export.js → ...xport/js/bootstrap3/incremental_export.js
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
58 changes: 58 additions & 0 deletions
58
corehq/apps/export/static/export/js/bootstrap5/customize_export_new.js
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,58 @@ | ||
hqDefine('export/js/bootstrap5/customize_export_new', [ | ||
'jquery', | ||
'knockout', | ||
'hqwebapp/js/initial_page_data', | ||
'export/js/bootstrap5/models', | ||
'hqwebapp/js/toggles', | ||
'export/js/const', | ||
], function ( | ||
$, | ||
ko, | ||
initialPageData, | ||
models, | ||
toggles, | ||
constants | ||
) { | ||
$(function () { | ||
var customExportView = new models.ExportInstance( | ||
initialPageData.get('export_instance'), | ||
{ | ||
saveUrl: initialPageData.get('full_path'), | ||
hasExcelDashboardAccess: initialPageData.get('has_excel_dashboard_access'), | ||
hasDailySavedAccess: initialPageData.get('has_daily_saved_export_access'), | ||
formatOptions: initialPageData.get('format_options'), | ||
sharingOptions: initialPageData.get('sharing_options'), | ||
hasOtherOwner: initialPageData.get('has_other_owner'), | ||
numberOfAppsToProcess: initialPageData.get('number_of_apps_to_process'), | ||
geoProperties: initialPageData.get('geo_properties'), | ||
} | ||
); | ||
initialPageData.registerUrl( | ||
"build_schema", "/a/---/data/export/build_full_schema/" | ||
); | ||
$('#customize-export').koApplyBindings(customExportView); | ||
$('.export-tooltip').tooltip(); /* todo B5: plugin:tooltip */ | ||
|
||
if (toggles.toggleEnabled('SUPPORT_GEO_JSON_EXPORT')) { | ||
const exportFormat = initialPageData.get('export_instance').export_format; | ||
if (exportFormat === constants.EXPORT_FORMATS.GEOJSON) { | ||
$("#select-geo-property").show(); | ||
$("#split-multiselects-checkbox-div").hide(); | ||
$("#split-multiselects-checkbox").prop("checked", false); | ||
} | ||
|
||
$('#format-select').change(function () { | ||
const selectedValue = $(this).val(); | ||
if (selectedValue === constants.EXPORT_FORMATS.GEOJSON) { | ||
$("#select-geo-property").show(); | ||
// Hiding and unchecking this checkbox is a temporary measure | ||
$("#split-multiselects-checkbox-div").hide(); | ||
$("#split-multiselects-checkbox").prop("checked", false); | ||
} else { | ||
$("#select-geo-property").hide(); | ||
$("#split-multiselects-checkbox-div").show(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); |
67 changes: 67 additions & 0 deletions
67
corehq/apps/export/static/export/js/bootstrap5/download_data_files.js
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,67 @@ | ||
hqDefine("export/js/bootstrap5/download_data_files",[ | ||
'jquery', | ||
'hqwebapp/js/bootstrap5/alert_user', | ||
'hqwebapp/js/initial_page_data', | ||
'hqwebapp/js/assert_properties', | ||
], function ($, alertUserModule, initialPageData, assertProperties) { | ||
var alertUser = alertUserModule.alert_user; | ||
/** | ||
* Copies the URL of a data file to the clipboard | ||
* | ||
* The function will first attempt to copy the URL to the clipboard without | ||
* any further user interaction. If that fails, the user will be given a | ||
* dialog box with the URL selected, and prompted to press Ctrl-C and Enter. | ||
* | ||
* @param url: The URL to be copied to the clipboard | ||
* @param textareaElem: A hidden <textarea> element containing the URL | ||
*/ | ||
var copyDataFileUrl = function () { | ||
assertProperties.assertRequired($(this).data(), ['id', 'name']); | ||
|
||
var url = window.location.origin + initialPageData.reverse('download_data_file',$(this).data("id"), $(this).data("name")); | ||
var textareaElem = $('#url_'.concat($(this).data("id"))); | ||
|
||
var showCopyDialog = function () { | ||
window.prompt(gettext("Copy to clipboard: Ctrl-C, Enter (Mac: Cmd-C, Enter)"), url); | ||
}; | ||
try { | ||
// Most browsers since Sept 2015 | ||
textareaElem.show(); | ||
textareaElem.select(); | ||
var copied = document.execCommand("copy"); | ||
textareaElem.hide(); | ||
if (copied) { | ||
alertUser(gettext("Data file URL copied to clipboard."), "success", true); | ||
} else { | ||
showCopyDialog(); | ||
} | ||
} catch (err) { | ||
// Older browsers | ||
showCopyDialog(); | ||
} | ||
}; | ||
|
||
/** | ||
* Makes an async DELETE request to url, and on success deletes rowElem. | ||
* | ||
* @param url: The URL to send the DELETE request to | ||
* @param rowElem: The <tr> element of the data file to remove on successful deletion | ||
*/ | ||
var deleteDataFile = function () { | ||
assertProperties.assertRequired($(this).data(), ['id','name']); | ||
var url = initialPageData.reverse('download_data_file', $(this).data("id"), $(this).data("name")); | ||
var rowElem = $('#row_'.concat($(this).data("id"))); | ||
|
||
$.ajax({ | ||
url: url, | ||
type: "DELETE", | ||
success: function () { | ||
rowElem.remove(); | ||
alertUser(gettext("Data file deleted."), "success", true); | ||
}, | ||
}); | ||
}; | ||
$(document).on('click', '.copy-data-file', copyDataFileUrl); | ||
$(document).on('click', '.delete-data-file', deleteDataFile); | ||
|
||
}); |
Oops, something went wrong.