mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add serializer to activityController
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
Controleur:
|
||||
|
||||
activity_json = $this->serializer->serialize($activity, 'json', []);
|
||||
|
||||
return render('@ChillActivity/...', [
|
||||
'activity' => $activity,
|
||||
'activity_json' => $activity_json
|
||||
])
|
||||
|
||||
|
||||
{# template twig de activity #}
|
||||
|
||||
{{ form(activity) }}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
{# window.activity = {{ activity_json|e('json') }}; #}
|
||||
window.activity = {
|
||||
"type": "activity",
|
||||
"persons": [
|
||||
{ type: person, id: xxx, ...}
|
||||
{ ...}
|
||||
],
|
||||
""
|
||||
};
|
||||
</script>
|
||||
{{ encore_entry_script_tags('activity_form') }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{# -----
|
||||
dans le fichier app.js: #}
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state(): return {
|
||||
activity: window.activity
|
||||
},
|
||||
getters: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
addPerson(state, payload) {
|
||||
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addPerson() {
|
||||
let el = document.getElementById('form['activity']['xxx']['xxxx']');
|
||||
let option = document.createElement('option');
|
||||
option.value = person.id;
|
||||
el.appendChild(option);
|
||||
commit('addPerson', payload)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const i18n = _createI18n(appMessages);
|
||||
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount('#activity');
|
||||
|
||||
|
||||
</script>
|
@@ -6,15 +6,27 @@
|
||||
|
||||
{% block content %}
|
||||
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
||||
{{ dump() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||
window.activity =
|
||||
{
|
||||
"type": "activity",
|
||||
"persons": [],
|
||||
""
|
||||
};
|
||||
{#
|
||||
{{ activity_json|e('json') }};
|
||||
#}
|
||||
</script>
|
||||
{{ encore_entry_script_tags('vue_activity') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||
{{ encore_entry_link_tags('vue_activity') }}
|
||||
{% endblock %}
|
||||
|
@@ -12,9 +12,12 @@
|
||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||
window.activity = {{ activity_json|e('json') }};
|
||||
</script>
|
||||
{{ encore_entry_script_tags('vue_activity') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||
{{ encore_entry_link_tags('vue_activity') }}
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user