|
|
@@ -3,7 +3,7 @@
|
|
|
<div class="planning-view-panel">
|
|
|
<div
|
|
|
class="item"
|
|
|
- :class="{ selected: view.uuid == currentPlanningView.uuid }"
|
|
|
+ :class="{ selected: currentPlanningView != null && view.uuid == currentPlanningView.uuid }"
|
|
|
v-for="view in planningViewList"
|
|
|
:key="view.uuid"
|
|
|
@click="loadView(view.uuid)"
|
|
|
@@ -23,20 +23,8 @@
|
|
|
<div v-if="showEdit && currentPlanningView != null" class="modal" @click="closeEdit">
|
|
|
<div class="modal-content" ref="edit">
|
|
|
<styled-input label="Titre" id="planning-view-title" v-model="currentPlanningView.name" />
|
|
|
- <date-picker
|
|
|
- label="Début"
|
|
|
- id="planning-view-start"
|
|
|
- lang="fr"
|
|
|
- target="hour"
|
|
|
- v-model="currentPlanningView.start"
|
|
|
- />
|
|
|
- <date-picker
|
|
|
- label="Fin"
|
|
|
- id="planning-view-end"
|
|
|
- lang="fr"
|
|
|
- target="hour"
|
|
|
- v-model="currentPlanningView.end"
|
|
|
- />
|
|
|
+ <date-picker label="Début" id="planning-view-start" lang="fr" target="hour" v-model="start" />
|
|
|
+ <date-picker label="Fin" id="planning-view-end" lang="fr" target="hour" v-model="end" />
|
|
|
<select-chip-input
|
|
|
title="Ligne"
|
|
|
placeholder="Selectionner les lignes à afficher dans ce planning"
|
|
|
@@ -53,14 +41,16 @@
|
|
|
|
|
|
<script lang="ts">
|
|
|
import { PlanningView } from "@/models/PlanningView";
|
|
|
-import DatePicker from "@/components/date-picker.vue";
|
|
|
-import styledInput from "@/components/input.vue";
|
|
|
-import SelectChipInput from "@/components/SelectChipInput.vue";
|
|
|
+import DatePicker from "@/components/Form/date-picker.vue";
|
|
|
+import styledInput from "@/components/Form/Input.vue";
|
|
|
+import SelectChipInput from "@/components/Form/SelectChipInput.vue";
|
|
|
|
|
|
import PlanningViewRenderer from "@/components/PlanningViewRenderer.vue";
|
|
|
import { v4 as uuidv4 } from "uuid";
|
|
|
import { defineComponent } from "vue";
|
|
|
import AutocompleteOptions from "@/models/AutocompleteOptions";
|
|
|
+import Toast from "@/utils/Toast";
|
|
|
+import dayjs, { Dayjs } from "dayjs";
|
|
|
|
|
|
const API_URL = process.env.VUE_APP_API_URL;
|
|
|
|
|
|
@@ -70,9 +60,37 @@ export default defineComponent({
|
|
|
return {
|
|
|
showEdit: false,
|
|
|
currentPlanningView: null as null | PlanningView,
|
|
|
+ end: null as Dayjs | null,
|
|
|
+ start: null as Dayjs | null,
|
|
|
planningViewList: [] as Array<PlanningView>,
|
|
|
};
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ currentPlanningView(val: null | PlanningView) {
|
|
|
+ if (val) {
|
|
|
+ this.end = dayjs(val.end);
|
|
|
+ this.start = dayjs(val.start);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ start(val: Dayjs, oldval) {
|
|
|
+ if (
|
|
|
+ this.currentPlanningView &&
|
|
|
+ oldval &&
|
|
|
+ !val.isSame(this.currentPlanningView.start, "minutes")
|
|
|
+ ) {
|
|
|
+ this.currentPlanningView.start = val.startOf("h").toDate();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ end(val: Dayjs, oldval) {
|
|
|
+ if (
|
|
|
+ this.currentPlanningView &&
|
|
|
+ oldval &&
|
|
|
+ !val.isSame(this.currentPlanningView.end, "minutes")
|
|
|
+ ) {
|
|
|
+ this.currentPlanningView.end = val.subtract(1, "h").endOf("h").toDate();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
computed: {
|
|
|
autocompleteList(): Array<AutocompleteOptions> {
|
|
|
return this.$store.state.creneauGroupList
|
|
|
@@ -81,10 +99,28 @@ export default defineComponent({
|
|
|
return { id: o.id.toString(), name: o.title };
|
|
|
});
|
|
|
},
|
|
|
+ uuid(): string {
|
|
|
+ return this.$store.state.evenement.uuid;
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
closeEdit(e: MouseEvent) {
|
|
|
- if (!(this.$refs.edit as HTMLElement).contains(e.target as Node)) this.showEdit = false;
|
|
|
+ if (!(this.$refs.edit as HTMLElement).contains(e.target as Node)) {
|
|
|
+ this.showEdit = false;
|
|
|
+ if (this.currentPlanningView)
|
|
|
+ fetch(`${API_URL}api/evenements/${this.uuid}/views/${this.currentPlanningView.uuid}`, {
|
|
|
+ method: "PUT",
|
|
|
+ body: JSON.stringify(this.currentPlanningView),
|
|
|
+ headers: { "Content-Type": "application/json" },
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.status !== 200) {
|
|
|
+ Toast({
|
|
|
+ html: "Impossible de sauvegardé la vue:" + res.statusText,
|
|
|
+ classes: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
newView() {
|
|
|
const evt = this.$store.state.evenement;
|
|
|
@@ -98,6 +134,17 @@ export default defineComponent({
|
|
|
};
|
|
|
this.currentPlanningView = planning;
|
|
|
this.planningViewList.push(planning);
|
|
|
+ fetch(`${API_URL}api/evenements/${this.uuid}/views`, {
|
|
|
+ method: "POST",
|
|
|
+ body: JSON.stringify(planning),
|
|
|
+ headers: { "Content-Type": "application/json" },
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ Toast({ html: "Vue sauvergardée", classes: "success" });
|
|
|
+ } else {
|
|
|
+ Toast({ html: "Impossible de sauvegardé la vue:" + res.statusText, classes: "error" });
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
deleteVue() {
|
|
|
if (this.currentPlanningView && confirm("Êtes vous sûr de vouloir supprimer cette vue?")) {
|
|
|
@@ -105,12 +152,41 @@ export default defineComponent({
|
|
|
this.planningViewList = this.planningViewList.filter((p) => p.uuid != uuid);
|
|
|
this.currentPlanningView = null;
|
|
|
this.showEdit = false;
|
|
|
+ fetch(`${API_URL}api/evenements/${this.uuid}/views/${uuid}`, {
|
|
|
+ method: "DELETE",
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.status !== 200) {
|
|
|
+ Toast({ html: "Impossible de supprimé la vue:" + res.statusText, classes: "error" });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
loadView(uuid: string) {
|
|
|
this.currentPlanningView = this.planningViewList.find((p) => uuid == p.uuid) ?? null;
|
|
|
},
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ fetch(`${API_URL}api/evenements/${this.uuid}/views`, {
|
|
|
+ method: "GET",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ return res.json();
|
|
|
+ } else {
|
|
|
+ Toast({ html: "Impossible de chargé les données" + res.statusText, classes: "error" });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then((arr) => {
|
|
|
+ this.planningViewList = arr.map((o: PlanningView) => {
|
|
|
+ o.start = new Date(o.start);
|
|
|
+ o.end = new Date(o.end);
|
|
|
+ return o;
|
|
|
+ });
|
|
|
+ if (this.planningViewList.length > 0) {
|
|
|
+ this.currentPlanningView = this.planningViewList[0];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
});
|
|
|
</script>
|
|
|
|