mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
adapting vuejs form for accompanyingPeriodWork: include template for
specific evaluation
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { fetchResults } from "ChillMainAssets/lib/api/apiMethods.js";
|
||||
|
||||
const fetchTemplates = (entityClass) => {
|
||||
let fqdnEntityClass = encodeURI(entityClass);
|
||||
return fetchResults(`/api/1.0/docgen/templates/by-entity/${fqdnEntityClass}`);
|
||||
}
|
||||
|
||||
export {
|
||||
fetchTemplates
|
||||
};
|
@@ -1,24 +1,27 @@
|
||||
import {createApp} from 'vue';
|
||||
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
|
||||
import {fetchTemplates} from 'ChillDocGeneratorAssets/api/pickTemplate.js';
|
||||
import {_createI18n} from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
|
||||
const i18n = _createI18n({});
|
||||
|
||||
document.querySelectorAll('div[data-docgen-template-picker]').forEach(el => {
|
||||
let
|
||||
picker = {
|
||||
template: '<pick-template :entityClass="this.entityClass" :entityId="this.entityId"></pick-template>',
|
||||
components: {
|
||||
PickTemplate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
entityClass: el.dataset.entityClass,
|
||||
entityId: el.dataset.entityId,
|
||||
}
|
||||
},
|
||||
}
|
||||
;
|
||||
fetchTemplates(el.dataset.entityClass).then(templates => {
|
||||
let
|
||||
picker = {
|
||||
template: '<pick-template :templates="this.templates" :entityId="this.entityId"></pick-template>',
|
||||
components: {
|
||||
PickTemplate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
templates: templates,
|
||||
entityId: el.dataset.entityId,
|
||||
}
|
||||
},
|
||||
}
|
||||
;
|
||||
createApp(picker).use(i18n).mount(el);
|
||||
})
|
||||
|
||||
createApp(picker).use(i18n).mount(el);
|
||||
});
|
||||
|
@@ -20,7 +20,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchResults } from "ChillMainAssets/lib/api/apiMethods.js";
|
||||
|
||||
export default {
|
||||
name: "PickTemplate",
|
||||
@@ -30,6 +29,10 @@ export default {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
templates: {
|
||||
required: true,
|
||||
},
|
||||
// beforeMove execute "something" before
|
||||
beforeMove: {
|
||||
type: Function,
|
||||
required: false,
|
||||
@@ -38,7 +41,6 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
template: null,
|
||||
templates: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -58,10 +60,13 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
generateDocument() {
|
||||
console.log('generateDocument');
|
||||
console.log('beforeMove', this.beforeMove);
|
||||
if (this.beforeMove != null) {
|
||||
console.log('execute before move');
|
||||
let r = this.beforeMove();
|
||||
if (r instanceof Promise) {
|
||||
r.then(() => this.goToGenerate());
|
||||
r.then((obj) => this.goToGenerate(obj));
|
||||
} else {
|
||||
this.goToGenerate();
|
||||
}
|
||||
@@ -69,11 +74,31 @@ export default {
|
||||
this.goToGenerate();
|
||||
}
|
||||
},
|
||||
goToGenerate() {
|
||||
goToGenerate(obj) {
|
||||
console.log('goToGenerate');
|
||||
console.log('obj', obj);
|
||||
console.log('entityId', this.entityId);
|
||||
let
|
||||
realId = this.entityId,
|
||||
realEntityClass = this.entityClass
|
||||
;
|
||||
|
||||
if (obj !== undefined) {
|
||||
if (obj.entityId !== undefined) {
|
||||
realId = obj.entityId;
|
||||
}
|
||||
if (obj.entityClass !== undefined) {
|
||||
realEntityClass = obj.entityClass;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('realId', realId);
|
||||
console.log('realEntityClass', realEntityClass);
|
||||
|
||||
const
|
||||
entityId = encodeURI(this.entityId),
|
||||
entityId = encodeURI(realId),
|
||||
returnPath = encodeURIComponent(window.location.pathname + window.location.search + window.location.hash),
|
||||
fqdnEntityClass = encodeURI(this.entityClass),
|
||||
fqdnEntityClass = encodeURI(realEntityClass),
|
||||
url = `/fr/doc/gen/generate/from/${this.template}/for/${fqdnEntityClass}/${entityId}?returnPath=${returnPath}`
|
||||
;
|
||||
|
||||
@@ -81,12 +106,6 @@ export default {
|
||||
window.location.assign(url);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
let fqdnEntityClass = encodeURI(this.entityClass);
|
||||
fetchResults(`/api/1.0/docgen/templates/by-entity/${fqdnEntityClass}`).then(templates => {
|
||||
this.templates = templates;
|
||||
})
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user