Apply prettier rules

This commit is contained in:
2024-11-14 18:47:38 +01:00
parent 610227815a
commit aa0785fc71
291 changed files with 23646 additions and 22071 deletions

View File

@@ -1,10 +1,8 @@
import { fetchResults } from "ChillMainAssets/lib/api/apiMethods.ts";
const fetchTemplates = (entityClass) => {
let fqdnEntityClass = encodeURI(entityClass);
return fetchResults(`/api/1.0/docgen/templates/by-entity/${fqdnEntityClass}`);
}
export {
fetchTemplates
let fqdnEntityClass = encodeURI(entityClass);
return fetchResults(`/api/1.0/docgen/templates/by-entity/${fqdnEntityClass}`);
};
export { fetchTemplates };

View File

@@ -1,13 +1,12 @@
const buildLink = function(templateId, entityId, entityClass) {
const
entityIdEncoded = encodeURI(entityId),
returnPath = encodeURIComponent(window.location.pathname + window.location.search + window.location.hash),
entityClassEncoded = encodeURI(entityClass),
url = `/fr/doc/gen/generate/from/${templateId}/for/${entityClassEncoded}/${entityIdEncoded}?returnPath=${returnPath}`
;
console.log('computed Url');
return url;
const buildLink = function (templateId, entityId, entityClass) {
const entityIdEncoded = encodeURI(entityId),
returnPath = encodeURIComponent(
window.location.pathname + window.location.search + window.location.hash,
),
entityClassEncoded = encodeURI(entityClass),
url = `/fr/doc/gen/generate/from/${templateId}/for/${entityClassEncoded}/${entityIdEncoded}?returnPath=${returnPath}`;
console.log("computed Url");
return url;
};
export {buildLink};
export { buildLink };

View File

@@ -1,27 +1,25 @@
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';
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 => {
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);
})
document.querySelectorAll("div[data-docgen-template-picker]").forEach((el) => {
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);
});
});

View File

@@ -1,70 +1,60 @@
<template>
<div>
<template v-if="templates.length > 0">
<slot name="title">
<h2>{{ $t('generate_document') }}</h2>
</slot>
<div class="container">
<div class="row">
<div class="col-md-4">
<slot name="label">
<label>{{ $t('select_a_template') }}</label>
<div>
<template v-if="templates.length > 0">
<slot name="title">
<h2>{{ $t("generate_document") }}</h2>
</slot>
</div>
<div class="col-md-8">
<div class="input-group mb-3">
<select
class="form-select"
v-model="template"
>
<option
disabled
selected
value=""
>
{{ $t('choose_a_template') }}
</option>
<template
v-for="t in templates"
:key="t.id"
>
<option :value="t.id">
{{ t.name.fr || 'Aucun nom défini' }}
</option>
</template>
</select>
<a
v-if="canGenerate"
class="btn btn-update btn-sm change-icon"
:href="buildUrlGenerate"
@click.prevent="clickGenerate($event, buildUrlGenerate)"
><i class="fa fa-fw fa-cog" /></a>
<a
v-else
class="btn btn-update btn-sm change-icon"
href="#"
disabled
><i class="fa fa-fw fa-cog" /></a>
<div class="container">
<div class="row">
<div class="col-md-4">
<slot name="label">
<label>{{ $t("select_a_template") }}</label>
</slot>
</div>
<div class="col-md-8">
<div class="input-group mb-3">
<select class="form-select" v-model="template">
<option disabled selected value="">
{{ $t("choose_a_template") }}
</option>
<template v-for="t in templates" :key="t.id">
<option :value="t.id">
{{ t.name.fr || "Aucun nom défini" }}
</option>
</template>
</select>
<a
v-if="canGenerate"
class="btn btn-update btn-sm change-icon"
:href="buildUrlGenerate"
@click.prevent="
clickGenerate($event, buildUrlGenerate)
"
><i class="fa fa-fw fa-cog"
/></a>
<a
v-else
class="btn btn-update btn-sm change-icon"
href="#"
disabled
><i class="fa fa-fw fa-cog"
/></a>
</div>
</div>
</div>
<div class="row" v-if="hasDescription">
<div class="col-md-8 align-self-end">
<p>{{ getDescription }}</p>
</div>
</div>
</div>
</div>
</div>
<div
class="row"
v-if="hasDescription"
>
<div class="col-md-8 align-self-end">
<p>{{ getDescription }}</p>
</div>
</div>
</div>
</template>
</div>
</template>
</div>
</template>
<script>
import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator';
import { buildLink } from "ChillDocGeneratorAssets/lib/document-generator";
export default {
name: "PickTemplate",
@@ -82,13 +72,13 @@ export default {
type: Boolean,
required: false,
default: false,
}
},
},
emits: ['goToGenerateDocument'],
emits: ["goToGenerateDocument"],
data() {
return {
template: null,
}
};
},
computed: {
canGenerate() {
@@ -103,21 +93,21 @@ export default {
},
getDescription() {
if (null === this.template) {
return '';
return "";
}
let desc = this.templates.find(t => t.id === this.template);
let desc = this.templates.find((t) => t.id === this.template);
if (null === desc) {
return '';
return "";
}
return desc.description || '';
return desc.description || "";
},
buildUrlGenerate() {
if (null === this.template) {
return '#';
return "#";
}
return buildLink(this.template, this.entityId, this.entityClass);
}
},
},
methods: {
clickGenerate(event, link) {
@@ -125,21 +115,23 @@ export default {
window.location.assign(link);
}
this.$emit('goToGenerateDocument', {event, link, template: this.template});
this.$emit("goToGenerateDocument", {
event,
link,
template: this.template,
});
},
},
i18n: {
messages: {
fr: {
generate_document: 'Générer un document',
select_a_template: 'Choisir un modèle',
choose_a_template: 'Choisir',
}
}
}
}
generate_document: "Générer un document",
select_a_template: "Choisir un modèle",
choose_a_template: "Choisir",
},
},
},
};
</script>
<style scoped>
</style>
<style scoped></style>