Skip to content

Commit

Permalink
apps/documents: loading document js only in template, not globally to…
Browse files Browse the repository at this point in the history
… reduce chunk size
  • Loading branch information
philli-m committed Dec 1, 2021
1 parent fce4f4d commit 5228666
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
9 changes: 9 additions & 0 deletions meinberlin/apps/documents/assets/react_documents_init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as ReactDocuments from './react_documents.jsx'
import { widget as ReactWidget } from 'adhocracy4'

function init () {
ReactWidget.initialise('mb', 'document-management', ReactDocuments.renderDocumentManagement)
}

document.addEventListener('DOMContentLoaded', init, false)
document.addEventListener('a4.embed.ready', init, false)
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% extends "a4dashboard/base_dashboard_project.html" %}
{% load i18n react_documents %}
{% load i18n static react_documents %}

{% block dashboard_project_content %}
<h1 class="u-first-heading">{% trans 'Edit document' %}</h1>

{% react_documents module True %}

{% endblock %}

{% block extra_js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'documents.js' %}"></script>
{% endblock %}
2 changes: 0 additions & 2 deletions meinberlin/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
widget as ReactWidget
} from 'adhocracy4'

import * as ReactDocuments from '../../apps/documents/assets/react_documents.jsx'
import * as ReactMapTeaser from '../../apps/plans/assets/react_map_teaser.jsx'
import * as ReactQuestions from '../../apps/livequestions/assets/react_questions.jsx'
import * as ReactQuestionsPresent from '../../apps/livequestions/assets/react_questions_present.jsx'
Expand All @@ -47,7 +46,6 @@ function init () {
ReactWidget.initialise('a4', 'ratings', ReactRatings.renderRatings)
ReactWidget.initialise('a4', 'reports', ReactReports.renderReports)

ReactWidget.initialise('mb', 'document-management', ReactDocuments.renderDocumentManagement)
ReactWidget.initialise('mb', 'mapTeaser', ReactMapTeaser.renderFilter)
ReactWidget.initialise('mb', 'proposals', ReactBudget.renderProposals)

Expand Down
23 changes: 11 additions & 12 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ module.exports = {
'./meinberlin/assets/scss/style.scss',
'./meinberlin/assets/js/app.js'
],
blueprint_picker: {
import: [
'./meinberlin/assets/js/blueprint-picker.js'
],
dependOn: 'adhocracy4'
},
captcheck: {
import: [
'./meinberlin/apps/captcha/assets/captcheck.js'
Expand All @@ -43,19 +37,24 @@ module.exports = {
],
dependOn: 'adhocracy4'
},
unload_warning: {
import: [
'./meinberlin/assets/js/unload_warning.js'
],
dependOn: 'adhocracy4'
},
dsgvo_video_embed: {
import: [
'dsgvo-video-embed/dist/dsgvo-video-embed.min.css',
'dsgvo-video-embed/dist/dsgvo-video-embed.min.js'
],
dependOn: 'adhocracy4'
},
// these do not rely on adhocracy and adding the depend causes console error
// error possibly due to needing to be loaded at specific time
blueprint_picker: {
import: './meinberlin/assets/js/blueprint-picker.js'
},
documents: {
import: './meinberlin/apps/documents/assets/react_documents_init.js'
},
unload_warning: {
import: './meinberlin/assets/js/unload_warning.js'
},
// A4 dependencies - we want all of them to go through webpack
mb_plans_map: {
import: [
Expand Down

0 comments on commit 5228666

Please sign in to comment.