mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
controller return json to vue via twig; init vue App
This commit is contained in:
parent
b89cffce68
commit
b1d7e543fc
@ -209,18 +209,7 @@ class ActivityController extends AbstractController
|
|||||||
throw $this->createNotFoundException('Template not found');
|
throw $this->createNotFoundException('Template not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
//$activity_json = $this->serializer->serialize($entity, 'json', []);
|
$activity_json = $this->serializer->serialize($entity, 'json', ['groups' => 'read']);
|
||||||
// "A circular reference has been detected when serializing the object of class "Chill\PersonBundle\Entity\AccompanyingPeriod" (configured limit: 1)."
|
|
||||||
|
|
||||||
$activity_json = null;
|
|
||||||
// activity_json doit retourner qqch comme :
|
|
||||||
// {
|
|
||||||
// "type": "activity",
|
|
||||||
// "persons": [
|
|
||||||
// { type: person, id: xxx, ...}
|
|
||||||
// { ...}
|
|
||||||
// ], ""
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $this->render($view, [
|
return $this->render($view, [
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
@ -334,13 +323,15 @@ class ActivityController extends AbstractController
|
|||||||
throw $this->createNotFoundException('Template not found');
|
throw $this->createNotFoundException('Template not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$activity_json = $this->serializer->serialize($entity, 'json', ['groups' => ['read']]);
|
||||||
|
|
||||||
return $this->render($view, array(
|
return $this->render($view, array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $form->createView(),
|
'edit_form' => $form->createView(),
|
||||||
'delete_form' => $deleteForm->createView(),
|
'delete_form' => $deleteForm->createView(),
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'accompanyingCourse' => $accompanyingPeriod,
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
'activity_json' => null
|
'activity_json' => $activity_json
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
hello
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "App",
|
||||||
|
components: {},
|
||||||
|
computed: mapState([
|
||||||
|
'activity'
|
||||||
|
])
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
@ -0,0 +1,8 @@
|
|||||||
|
const appMessages = {
|
||||||
|
fr: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {
|
||||||
|
appMessages
|
||||||
|
};
|
@ -0,0 +1,16 @@
|
|||||||
|
import { createApp } from 'vue';
|
||||||
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
|
import { appMessages } from './i18n'
|
||||||
|
import store from './store'
|
||||||
|
|
||||||
|
import App from './App.vue';
|
||||||
|
|
||||||
|
const i18n = _createI18n(appMessages);
|
||||||
|
|
||||||
|
const app = createApp({
|
||||||
|
template: `<app></app>`,
|
||||||
|
})
|
||||||
|
.use(store)
|
||||||
|
.use(i18n)
|
||||||
|
.component('app', App)
|
||||||
|
.mount('#activity');
|
@ -0,0 +1,31 @@
|
|||||||
|
import 'es6-promise/auto';
|
||||||
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
//console.log('window.activity', window.activity);
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
strict: debug,
|
||||||
|
state: {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default store;
|
@ -1,6 +1,15 @@
|
|||||||
<h1>{{ "Update activity"|trans }}</h1>
|
<h1>{{ "Update activity"|trans }}</h1>
|
||||||
|
|
||||||
{{ form_start(edit_form) }}
|
{{ form_start(edit_form) }}
|
||||||
|
{{ form_errors(edit_form) }}
|
||||||
|
|
||||||
|
{%- if edit_form.emergency is defined -%}
|
||||||
|
{{ form_row(edit_form.emergency) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if edit_form.sentReceived is defined -%}
|
||||||
|
{{ form_row(edit_form.sentReceived) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{%- if edit_form.user is defined -%}
|
{%- if edit_form.user is defined -%}
|
||||||
{{ form_row(edit_form.user) }}
|
{{ form_row(edit_form.user) }}
|
||||||
@ -10,45 +19,55 @@
|
|||||||
{{ form_row(edit_form.scope) }}
|
{{ form_row(edit_form.scope) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>{{ 'Activity data'|trans }}</h2>
|
.. type
|
||||||
|
|
||||||
{%- if form.date is defined -%}
|
{%- if edit_form.reasons is defined -%}
|
||||||
{{ form_row(form.date) }}
|
{{ form_row(edit_form.reasons) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.durationTime is defined -%}
|
|
||||||
{{ form_row(form.durationTime) }}
|
<h2 class="chill-red">Parties concernées</h2>
|
||||||
|
|
||||||
|
{%- if edit_form.persons is defined -%}
|
||||||
|
{{ form_row(edit_form.persons) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.travelTime is defined -%}
|
{%- if edit_form.thirdParties is defined -%}
|
||||||
{{ form_row(form.travelTime) }}
|
{{ form_row(edit_form.thirdParties) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.attendee is defined -%}
|
{%- if edit_form.users is defined -%}
|
||||||
{{ form_row(form.attendee) }}
|
{{ form_row(edit_form.users) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.comment is defined -%}
|
|
||||||
{{ form_row(form.comment) }}
|
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if edit_form.date is defined -%}
|
||||||
|
{{ form_row(edit_form.date) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.reasons is defined -%}
|
|
||||||
{{ form_row(form.reasons) }}
|
.. location
|
||||||
|
|
||||||
|
{%- if edit_form.durationTime is defined -%}
|
||||||
|
{{ form_row(edit_form.durationTime) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.persons is defined -%}
|
|
||||||
{{ form_row(form.persons) }}
|
{%- if edit_form.travelTime is defined -%}
|
||||||
|
{{ form_row(edit_form.travelTime) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.thirdParties is defined -%}
|
|
||||||
{{ form_row(form.thirdParties) }}
|
{%- if edit_form.comment is defined -%}
|
||||||
|
.. public and private
|
||||||
|
{{ form_row(edit_form.comment) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.users is defined -%}
|
|
||||||
{{ form_row(form.users) }}
|
{%- if edit_form.documents is defined -%}
|
||||||
|
{{ form_row(edit_form.documents) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if form.emergency is defined -%}
|
|
||||||
{{ form_row(form.emergency) }}
|
{%- if edit_form.attendee is defined -%}
|
||||||
{% endif %}
|
{{ form_row(edit_form.attendee) }}
|
||||||
{%- if form.sentReceived is defined -%}
|
|
||||||
{{ form_row(form.sentReceived) }}
|
|
||||||
{% endif %}
|
|
||||||
{%- if form.documents is defined -%}
|
|
||||||
{{ form_row(form.documents) }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
.. status
|
||||||
|
|
||||||
{% set person_id = null %}
|
{% set person_id = null %}
|
||||||
{% if entity.person %}
|
{% if entity.person %}
|
||||||
{% set person_id = entity.person.id %}
|
{% set person_id = entity.person.id %}
|
||||||
|
@ -5,16 +5,21 @@
|
|||||||
{% block title 'Update activity'|trans %}
|
{% block title 'Update activity'|trans %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
||||||
|
{{ dump() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_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|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||||
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -22,15 +22,19 @@
|
|||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_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('js') }};
|
||||||
</script>
|
</script>
|
||||||
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||||
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h2 class="chill-red">{{ "Activity creation"|trans }}</h2>
|
<h1>{{ "Activity creation"|trans }}</h1>
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
@ -20,7 +20,7 @@
|
|||||||
{{ form_row(form.scope) }}
|
{{ form_row(form.scope) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
type..
|
.. type
|
||||||
|
|
||||||
{%- if form.reasons is defined -%}
|
{%- if form.reasons is defined -%}
|
||||||
{{ form_row(form.reasons) }}
|
{{ form_row(form.reasons) }}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
{% block title 'Activity creation' |trans %}
|
{% block title 'Activity creation' |trans %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
||||||
{{ dump() }}
|
{{ dump() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -13,15 +14,7 @@
|
|||||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<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 }}');
|
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 =
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
{
|
|
||||||
"type": "activity",
|
|
||||||
"persons": [],
|
|
||||||
""
|
|
||||||
};
|
|
||||||
{#
|
|
||||||
{{ activity_json|e('json') }};
|
|
||||||
#}
|
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -6,13 +6,14 @@
|
|||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<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 }}');
|
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') }};
|
window.activity = {{ activity_json|e('js') }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user