{"version":3,"sources":["webpack:///./src/components/Reservations/ModalEditOptionSortOrder.vue","webpack:///src/components/Reservations/ModalEditOptionSortOrder.vue","webpack:///./src/components/Reservations/ModalEditOptionSortOrder.vue?3a8c","webpack:///./src/components/Reservations/ModalEditOptionSortOrder.vue?8659"],"names":["render","_vm","this","_c","_self","attrs","isSaving","isSavingSuccess","isSavingError","onClickCancel","saveSortOrder","showModal","on","scopedSlots","_u","key","fn","_l","categories","cat","cIndex","staticClass","_v","_s","$t","CategoryId","Options","filter","o","resOption","Id","staticStyle","InternalName","proxy","slot","staticRenderFns","components","draggable","props","type","Boolean","default","Function","required","reservationDate","Object","deafault","data","options","computed","_objectSpread","mapState","created","cleanSource","setupCategories","methods","mapMutations","_this","_loop","option","i","findIndex","c","push","length","sort","a","b","_this2","reservationOptionIds","j","opt","reservationProvider","updateReservationOptionSortOrder","reservation","Key","then","response","status","setReservation","EventBus","$emit","message","finally","component"],"mappings":"qKAAIA,EAAS,WAAkB,IAAIC,EAAIC,KAAKC,EAAGF,EAAIG,MAAMD,GAAG,OAAOA,EAAG,qBAAqB,CAACE,MAAM,CAAC,WAAa,GAAG,SAAWJ,EAAIK,SAAS,gBAAkBL,EAAIM,gBAAgB,cAAgBN,EAAIO,cAAc,kBAAoBP,EAAIO,eAAiBP,EAAIM,gBAAgB,cAAgBN,EAAIQ,cAAc,YAAcR,EAAIS,cAAc,UAAYT,EAAIU,WAAWC,GAAG,CAAC,WAAaX,EAAIQ,eAAeI,YAAYZ,EAAIa,GAAG,CAAC,CAACC,IAAI,UAAUC,GAAG,WAAW,OAAOf,EAAIgB,GAAIhB,EAAIiB,YAAY,SAASC,EAAIC,GAAQ,OAAOjB,EAAG,MAAM,CAACY,IAAIK,EAAOC,YAAY,QAAQ,CAAClB,EAAG,IAAI,CAACkB,YAAY,SAAS,CAACpB,EAAIqB,GAAG,IAAIrB,EAAIsB,GAAGtB,EAAIuB,GAAI,sDAAwDL,EAAIM,aAAc,OAAOtB,EAAG,YAAY,C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AAC,GAAA,OAAAA,EAAAH,aAAAkC,EAAAlC,iBATAmC,EAAA,EAAAA,EAAA,KAAAZ,QAAAgB,OAAAJ,IAAAF,IAeA,KAAAxC,aAAA+C,MAAA,SAAAC,EAAAC,GAAA,OAAAD,EAAAzC,WAAA0C,EAAA1C,eAGAf,cAAA,eAAA0D,EAAA,KACA,SAAA9D,SAAA,CACA,KAAAA,UAAA,EAIA,IAFA,IAAA+D,EAAA,GAEAT,EAAA,EAAAA,EAAA,KAAA1C,WAAA8C,OAAAJ,IAGA,IAFA,IAAAzC,EAAA,KAAAD,WAAA0C,GAEAU,EAAA,EAAAA,EAAAnD,EAAAO,QAAAsC,OAAAM,IAAA,CACA,IAAAC,EAAApD,EAAAO,QAAA4C,GACAD,EAAAN,KAAAQ,EAAAzC,IAIA0C,OAAAjB,QACAkB,iCACA,KAAAC,YAAAC,IACAN,GAEAO,MAAA,SAAAC,GACA,MAAAA,EAAAC,SAEAV,EAAAW,eAAAF,EAAA9B,MAGAiC,OAAAC,MAAA,aACA1C,KAAA,OACA2C,QAAAd,EAAA5C,GAAA,sCAGA4C,EAAA3D,oBAGA0E,SAAA,WACAf,EAAA9D,UAAA,UCrKgX,I,YCO5W8E,EAAY,eACd,EACApF,EACAmC,GACA,EACA,KACA,KACA,MAIa,aAAAiD,E","file":"js/chunk-2d0c89c7.js?id=84f6c6d90f3d122c6460","sourcesContent":["var render = function render(){var _vm=this,_c=_vm._self._c;return _c('ui-component-modal',{attrs:{\"modalTitle\":\"\",\"isSaving\":_vm.isSaving,\"isSavingSuccess\":_vm.isSavingSuccess,\"isSavingError\":_vm.isSavingError,\"hideFooterButtons\":_vm.isSavingError || _vm.isSavingSuccess,\"onClickCancel\":_vm.onClickCancel,\"onClickSave\":_vm.saveSortOrder,\"showModal\":_vm.showModal},on:{\"closeModal\":_vm.onClickCancel},scopedSlots:_vm._u([{key:\"content\",fn:function(){return _vm._l((_vm.categories),function(cat,cIndex){return _c('div',{key:cIndex,staticClass:\"mb-6\"},[_c('p',{staticClass:\"title\"},[_vm._v(\" \"+_vm._s(_vm.$t( 'Components.Reservation.ReservationOptions.Category_' + cat.CategoryId ))+\" \")]),_c('draggable',{attrs:{\"group\":'cat_' + cat.CategoryId,\"list\":cat.Options,\"sort\":true,\"handle\":\".handle\",\"draggable\":\".resOption\"}},_vm._l((cat.Options.filter(\n            (o) => o.CategoryId === cat.CategoryId\n          )),function(resOption){return _c('div',{key:resOption.Id,staticClass:\"resOption card has-margin-bottom has-padding\",staticStyle:{\"cursor\":\"move\"}},[_c('span',{staticClass:\"icon handle\"},[_c('font-awesome-icon',{attrs:{\"icon\":['fas', 'align-justify']}})],1),_c('span',{staticClass:\"has-margin-left\"},[_vm._v(_vm._s(resOption.InternalName))])])}),0)],1)})},proxy:true}])},[_c('template',{slot:\"modalTitle\"})],2)\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","<template>\n  <ui-component-modal\n    modalTitle=\"\"\n    :isSaving=\"isSaving\"\n    :isSavingSuccess=\"isSavingSuccess\"\n    :isSavingError=\"isSavingError\"\n    :hideFooterButtons=\"isSavingError || isSavingSuccess\"\n    :onClickCancel=\"onClickCancel\"\n    :onClickSave=\"saveSortOrder\"\n    :showModal=\"showModal\"\n    @closeModal=\"onClickCancel\"\n  >\n    <template slot=\"modalTitle\"></template>\n    <template v-slot:content>\n      <div\n        v-for=\"(cat, cIndex) in categories\"\n        :key=\"cIndex\"\n        class=\"mb-6\"\n      >\n        <p class=\"title\">\n          {{\n            $t(\n              'Components.Reservation.ReservationOptions.Category_' +\n                cat.CategoryId\n            )\n          }}\n        </p>\n\n        <draggable\n          :group=\"'cat_' + cat.CategoryId\"\n          :list=\"cat.Options\"\n          :sort=\"true\"\n          handle=\".handle\"\n          draggable=\".resOption\"\n        >\n          <div\n            v-for=\"resOption in cat.Options.filter(\n              (o) => o.CategoryId === cat.CategoryId\n            )\"\n            :key=\"resOption.Id\"\n            class=\"resOption card has-margin-bottom has-padding\"\n            style=\"cursor: move;\"\n          >\n            <span class=\"icon handle\">\n              <font-awesome-icon :icon=\"['fas', 'align-justify']\" />\n            </span>\n            <span class=\"has-margin-left\">{{ resOption.InternalName }}</span>\n          </div>\n        </draggable>\n      </div>\n    </template>\n  </ui-component-modal>\n</template>\n\n<script>\nimport { mapState, mapMutations } from 'vuex'\nimport { EventBus } from '@/eventbus/event-bus'\nimport draggable from 'vuedraggable'\nimport reservationProvider from '@/providers/reservation'\nimport { cleanSource } from '@/utils/objectHelper'\n\n\nexport default {\n  components: {\n    draggable,\n  },\n\n  props: {\n    showModal: {\n      type: Boolean,\n      default: false,\n    },\n\n    onClickCancel: {\n      type: Function,\n      required: true,\n    },\n\n    reservationDate: {\n      type: Object,\n      deafault: null,\n      required: true\n    }\n  },\n\n  data() {\n    return {\n      isSaving: false,\n      isSavingSuccess: false,\n      isSavingError: false,\n\n      categories: [],\n      options: [],\n    }\n  },\n\n  computed: {\n    ...mapState('reservationStore', ['reservation']),\n  },\n\n  created() {\n    this.options = cleanSource(this.reservationDate.Options);\n\n    this.setupCategories();\n  },\n\n  methods: {\n    ...mapMutations('reservationStore', ['setReservation']),\n\n    setupCategories() {\n      let categories = []\n\n      for (let i = 0; i < this.options.length; i++) {\n        let option = this.options[i]\n\n        if (\n          categories.findIndex((c) => c.CategoryId === option.CategoryId) === -1\n        ) {\n          categories.push({\n            CategoryId: option.CategoryId,\n            Options: this.options.filter(\n              (o) => o.CategoryId === option.CategoryId\n            ),\n          })\n        }\n      }\n\n      this.categories = categories.sort((a, b) => a.CategoryId - b.CategoryId)\n    },\n\n    saveSortOrder() {\n      if (!this.isSaving) {\n        this.isSaving = true\n\n        let reservationOptionIds = []\n\n        for (let i = 0; i < this.categories.length; i++) {\n          let cat = this.categories[i]\n\n          for (let j = 0; j < cat.Options.length; j++) {\n            let opt = cat.Options[j]\n            reservationOptionIds.push(opt.Id)\n          }\n        }\n\n        reservationProvider.methods\n          .updateReservationOptionSortOrder(\n            this.reservation.Key,\n            reservationOptionIds\n          )\n          .then((response) => {\n            if (response.status === 200) {\n              // Update reservation store\n              this.setReservation(response.data);\n\n              // Send message to display toast on screen\n              EventBus.$emit('showToast', {\n                type: 'info',\n                message: this.$t('General.Toast_ReservationUpdated'),\n              });\n\n              this.onClickCancel();\n            }\n          })\n          .finally(() => {\n            this.isSaving = false;\n          })\n\n      }\n    },\n  },\n}\n</script>\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ModalEditOptionSortOrder.vue?vue&type=script&lang=js\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ModalEditOptionSortOrder.vue?vue&type=script&lang=js\"","import { render, staticRenderFns } from \"./ModalEditOptionSortOrder.vue?vue&type=template&id=7bcf4f2d\"\nimport script from \"./ModalEditOptionSortOrder.vue?vue&type=script&lang=js\"\nexport * from \"./ModalEditOptionSortOrder.vue?vue&type=script&lang=js\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\nexport default component.exports"],"sourceRoot":""}