mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Refactor export download script to use ES6 and webpack
The export download script was refactored to use ES6 syntax and webpack's modular system. This included separating out the download script into its own file for better organization, removing globally-scoped JavaScript, and adding the new download script as a webpack entry point. Also, the import method for the 'mime' library was adjusted to use ES6 syntax.
This commit is contained in:
parent
84ce8a93f3
commit
59f721934e
@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var mime = require('mime')
|
||||
import mime from 'mime';
|
||||
|
||||
var download_report = (url, container) => {
|
||||
export const download_report = (url, container) => {
|
||||
var download_text = container.dataset.downloadText,
|
||||
alias = container.dataset.alias;
|
||||
|
||||
@ -63,5 +63,3 @@ var download_report = (url, container) => {
|
||||
.replaceChild(problem_text, container.firstChild);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = download_report;
|
||||
|
@ -0,0 +1,16 @@
|
||||
import {download_report} from "../../lib/download-report/download-report";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function(e) {
|
||||
const export_generate_url = window.export_generate_url;
|
||||
|
||||
if (typeof export_generate_url === 'undefined') {
|
||||
console.error('Alias not found!');
|
||||
throw new Error('Alias not found!');
|
||||
}
|
||||
|
||||
const query = window.location.search,
|
||||
container = document.querySelector("#download_container")
|
||||
;
|
||||
|
||||
download_report(export_generate_url + "?" + query.toString(), container);
|
||||
});
|
@ -22,15 +22,13 @@
|
||||
|
||||
{% block js %}
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("DOMContentLoaded", function(e) {
|
||||
var url = "{{ path('chill_main_export_generate', { 'alias' : alias } ) }}",
|
||||
query = window.location.search,
|
||||
container = document.querySelector("#download_container")
|
||||
;
|
||||
|
||||
chill.download_report(url+query, container);
|
||||
});
|
||||
window.export_generate_url = "{{ path('chill_main_export_generate', { 'alias' : alias } ) }}";
|
||||
</script>
|
||||
{{ encore_entry_link_tags('page_download_exports') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_script_tags('page_download_exports') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -52,12 +52,14 @@ module.exports = function(encore, entries)
|
||||
Tabs: __dirname + '/Resources/public/lib/tabs'
|
||||
});
|
||||
|
||||
|
||||
// Page entrypoints
|
||||
encore.addEntry('page_login', __dirname + '/Resources/public/page/login/index.js');
|
||||
encore.addEntry('page_location', __dirname + '/Resources/public/page/location/index.js');
|
||||
encore.addEntry('page_workflow_show', __dirname + '/Resources/public/page/workflow-show/index.js');
|
||||
encore.addEntry('page_homepage_widget', __dirname + '/Resources/public/page/homepage_widget/index.js');
|
||||
encore.addEntry('page_export', __dirname + '/Resources/public/page/export/index.js');
|
||||
encore.addEntry('page_download_exports', __dirname + '/Resources/public/page/export/download-export.js');
|
||||
|
||||
buildCKEditor(encore);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user