#16 pass default variables to add-address component when it is called from another vue component

This commit is contained in:
Mathieu Jaumotte 2022-11-17 16:12:30 +01:00
parent e90782500b
commit 3ca46efd2c
12 changed files with 18 additions and 4 deletions

View File

@ -117,7 +117,8 @@ export default {
target: { //name, id target: { //name, id
}, },
edit: false, edit: false,
addressId: null addressId: null,
defaults: window.addaddress
} }
} }
} }

View File

@ -22,6 +22,7 @@
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
}); });
window.activity = {{ activity_json|json_encode|raw }}; window.activity = {{ activity_json|json_encode|raw }};
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{{ encore_entry_script_tags('vue_activity') }} {{ encore_entry_script_tags('vue_activity') }}
{% endblock %} {% endblock %}

View File

@ -37,6 +37,7 @@
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
}); });
window.activity = {{ activity_json|json_encode|raw }}; window.activity = {{ activity_json|json_encode|raw }};
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{{ encore_entry_script_tags('vue_activity') }} {{ encore_entry_script_tags('vue_activity') }}
{% endblock %} {% endblock %}

View File

@ -18,6 +18,7 @@
{{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('mod_async_upload') }}
<script type="text/javascript"> <script type="text/javascript">
window.activity = {{ activity_json|json_encode|raw }}; window.activity = {{ activity_json|json_encode|raw }};
window.addaddress = {{ add_address|json_encode|raw }};
{% if default_location is not null %}window.default_location_id = {{ default_location.id }}{% endif %}; {% if default_location is not null %}window.default_location_id = {{ default_location.id }}{% endif %};
</script> </script>
{{ encore_entry_script_tags('vue_activity') }} {{ encore_entry_script_tags('vue_activity') }}

View File

@ -21,6 +21,7 @@
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
}); });
window.activity = {{ activity_json|json_encode|raw }}; window.activity = {{ activity_json|json_encode|raw }};
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{{ encore_entry_script_tags('vue_activity') }} {{ encore_entry_script_tags('vue_activity') }}
{% endblock %} {% endblock %}

View File

@ -109,6 +109,7 @@
}); });
chill.categoryLinkParentChildSelect(); chill.categoryLinkParentChildSelect();
}); });
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{% block js %}<!-- nothing added to js -->{% endblock %} {% block js %}<!-- nothing added to js -->{% endblock %}

View File

@ -164,7 +164,8 @@ export default {
id: this.accompanyingCourse.id id: this.accompanyingCourse.id
}, },
edit: false, edit: false,
addressId: null addressId: null,
defaults: window.addaddress
} }
if (this.accompanyingCourse.location) { if (this.accompanyingCourse.location) {
context['edit'] = true; context['edit'] = true;

View File

@ -5,6 +5,7 @@ import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/househol
import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js';
const debug = process.env.NODE_ENV !== 'production'; const debug = process.env.NODE_ENV !== 'production';
//console.log('AJAJAJA', window.addaddress);
const concerned = window.household_members_editor_data.persons.map(p => { const concerned = window.household_members_editor_data.persons.map(p => {
return { return {
@ -115,6 +116,7 @@ const store = createStore({
name: state.household.type, name: state.household.type,
id: state.household.id id: state.household.id
}, },
defaults: window.addaddress,
suggestions: state.addressesSuggestion suggestions: state.addressesSuggestion
}; };
} else { } else {
@ -125,6 +127,7 @@ const store = createStore({
name: state.household.type, name: state.household.type,
id: state.household.id id: state.household.id
}, },
defaults: window.addaddress,
}; };
} }
}, },

View File

@ -201,7 +201,8 @@ export default {
context: { context: {
target: {}, // boilerplate for getting the address id target: {}, // boilerplate for getting the address id
edit: false, edit: false,
addressId: null addressId: null,
defaults: window.addaddress
} }
}, },
errors: [] errors: []

View File

@ -10,6 +10,7 @@
<script type="text/javascript"> <script type="text/javascript">
window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }}; window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }};
window.vueRootComponent = 'app'; window.vueRootComponent = 'app';
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{{ encore_entry_script_tags('vue_accourse') }} {{ encore_entry_script_tags('vue_accourse') }}
{% endblock %} {% endblock %}

View File

@ -19,6 +19,7 @@
<script type="text/javascript"> <script type="text/javascript">
window.household_members_editor_data = {{ data|json_encode|raw }}; window.household_members_editor_data = {{ data|json_encode|raw }};
window.household_members_editor_expand_suggestions = {{ expandSuggestions }}; window.household_members_editor_expand_suggestions = {{ expandSuggestions }};
window.addaddress = {{ add_address|json_encode|raw }};
</script> </script>
{{ encore_entry_script_tags('vue_household_members_editor') }} {{ encore_entry_script_tags('vue_household_members_editor') }}
{% endblock %} {% endblock %}

View File

@ -232,7 +232,8 @@ export default {
id: this.id id: this.id
}, },
edit: false, edit: false,
addressId: null addressId: null,
defaults: window.addaddress
}; };
if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null) if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null)
&& this.thirdparty.address.address_id !== null && this.thirdparty.address.address_id !== null