-
+
+
+ add
+ Ajouter une catégorie
+
+
+
+
+ Aucune catégorie horaires ajoutées pour le moment
+
+
+
-
-
- {{ item.name }}
- {{ item.description }}
-
+
+
+
+
+
{{ item.name }}
+
{{ item.description }}
+
+
+
+
+ edit
+
+
+ delete
+
+
+
+ Ajouter un horaire
+
+
+
-
-
-
-
- {{ when.day }}
-
- {{ when.from }} - {{ when.to }}
-
-
-
+
+
+
+
+
+
+
+
{{ when.day }}
+
{{ when.from }} - {{ when.to }}
+
+
+
+
+
+
+ edit
+
+
+
+ delete
+
+
+
+
+
+
+
+
+ Pas d'interval horaires pour cette catégorie pour l'instant
+
+
+
+
+
+
+
+
+
+
+
+
+ Fermer
+
+
+
+ Valider
+
+
+
+
+
+
+
+ Voulez vous vraiment supprimer cette catégorie horaire ?
+
+
+
+ Fermer
+
+
+
+ Supprimer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Fermer
+
+ OK
+
+
+
+
+
+
+
+ Fermer
+
+ OK
+
+
+
+
+
+ Fermer
+
+
+
+ Valider
+
+
+
+
+
+
+
+ Voulez vous vraiment supprimer cette interval horaire ?
+
+
+
+ Fermer
+
+
+
+ Supprimer
+
+
+
+
@@ -103,13 +316,171 @@ export default {
}
]
}
+ ],
+ mode: '',
+ categoryModal: false,
+ category: {
+ name: '',
+ description: ''
+ },
+ deleteCategoryModal: false,
+ toDeleteCategory: {},
+ oldEditCategory: {},
+ whenModal: false,
+ when: {
+ day: '',
+ from: '',
+ to: ''
+ },
+ deleteWhenModal: false,
+ toDeleteWhen: {},
+ oldEditWhen: {},
+ fromMenu: false,
+ toMenu: false,
+ days: [
+ 'Lundi',
+ 'Mardi',
+ 'Mercredi',
+ 'Jeudi',
+ 'Vendredi',
+ 'Samedi'
]
- })
+ }),
+
+ computed: {
+ modalTitle () { return this.mode === 'add' ? 'Ajouter' : 'Editer' }
+ },
+
+ methods: {
+ openAddCategoryModal () {
+ this.mode = 'add'
+ this.categoryModal = true
+ },
+ openEditCategoryModal (item) {
+ this.category = item
+ this.oldEditCategory = item
+ this.mode = 'edit'
+ this.categoryModal = true
+ },
+ openDeleteCategoryModal (item) {
+ this.deleteCategoryModal = true
+ this.toDeleteCategory = item
+ },
+ saveCategory () {
+ let schedule = this.$store.state.data.schedule
+ if (this.mode === 'add') {
+ this.category._id = Date.now().toString()
+ schedule.push(this.category)
+ } else {
+ schedule = schedule.map(i => i.name === this.oldEditCategory.name && i.description === this.oldEditCategory.description ? this.category : i)
+ }
+
+ this.category = {
+ name: '',
+ description: ''
+ }
+ this.$store.commit('SET_DATA', { schedule })
+ this.categoryModal = false
+ },
+ deleteCategory () {
+ let schedule = this.$store.state.data.schedule
+ schedule = schedule.filter(item => item.name !== this.toDeleteCategory.name && item.description !== this.toDeleteCategory.description)
+ this.$store.commit('SET_DATA', { schedule })
+ this.deleteCategoryModal = false
+ },
+
+ openAddWhenModal (parent) {
+ this.mode = 'add'
+ this.whenParent = parent
+ this.whenModal = true
+ },
+ openEditWhenModal (item) {
+ this.when = item
+ this.oldEditWhen = item
+ this.mode = 'edit'
+ this.whenModal = true
+ },
+ openDeleteWhenModal (item) {
+ this.deleteWhenModal = true
+ this.toDeleteWhen = item
+ },
+ saveWhen () {
+ let schedule = this.$store.state.data.schedule
+ if (this.mode === 'add') {
+ this.when._id = Date.now().toString()
+ schedule = schedule.map(i => {
+ if (this.whenParent._id === i._id) {
+ if (!Array.isArray(i.when)) {
+ i.when = []
+ }
+ i.when.push(this.when)
+ }
+ return i
+ })
+ } else {
+ schedule = schedule.map(i => {
+ if (this.whenParent._id === i._id) {
+ i.when = i.when.map(w => w._id === this.when._id ? this.when : w)
+ }
+ return i
+ })
+ }
+ this.when = {
+ day: '',
+ from: '10:00',
+ to: '11:00'
+ }
+ this.$store.commit('SET_DATA', { schedule })
+ this.whenModal = false
+ },
+ deleteWhen () {
+ let schedule = this.$store.state.data.schedule
+ schedule = schedule.map(i => {
+ if (this.whenParent._id === i._id) {
+ i.when = i.when.filter(w => w._id !== this.toDeleteWhen._id)
+ }
+ return i
+ })
+ this.$store.commit('SET_DATA', { schedule })
+ this.deleteWhenModal = false
+ }
+ }
}
-
diff --git a/yarn.lock b/yarn.lock
index 8549978..8e8a116 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9120,6 +9120,11 @@ vue-hot-reload-api@^2.3.0:
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"
integrity sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==
+vue-input-facade@^1.3.1:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/vue-input-facade/-/vue-input-facade-1.3.1.tgz#87cdca62f75fcdf8205fc7345e4f6a560f4daaa8"
+ integrity sha512-8tgWiBObwVT3v9XD9OruwPDdWFwbTxaGdtUd1vXqAwNMZceETxZdfsgkMjUtwT1u2tCY3Ptu09WNDPwiwa4huw==
+
vue-loader@^15.9.2:
version "15.9.3"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.9.3.tgz#0de35d9e555d3ed53969516cac5ce25531299dda"