/*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "./resources/js/components/addressPopup.js":
/*!*************************************************!*\
  !*** ./resources/js/components/addressPopup.js ***!
  \*************************************************/
/***/ (() => {

eval("window.AddressPopUp = function (options, itemData) {\n  /*\n   * Variables accessible\n   * in the class\n   */\n  var Opts = {\n    active: false,\n    array: [],\n    onAfterSave: function onAfterSave() {},\n    onClose: function onClose() {}\n  };\n  var data = {};\n  var root = this;\n  /*\n   * Constructor\n   */\n\n  this.construct = function (options, itemData) {\n    console.log(' Address constructor called');\n  };\n\n  this.init = function (options, itemData) {\n    console.log(' Address  nit called');\n    $.extend(Opts, options);\n    $.extend(data, itemData);\n    root.bindClickAction();\n  };\n\n  this.clearData = function () {\n    data = {};\n    root.renderForm();\n  };\n\n  this.setData = function (itemData) {\n    $.extend(data, itemData);\n  };\n\n  this.show = function () {\n    $('.addressModal').modal().show();\n  };\n\n  this.renderForm = function () {\n    $('.addressModal input').val('');\n    $('.addressModal textarea').val('');\n    $.each(data, function (key, value) {\n      /*\n                      console.log('key:'+key+' value:'+value);\n                      console.log('.addressModal'+' *[name=contact'+$.ucFirst(key)+']');\n      */\n      $('.addressModal' + ' *[name=address' + $.ucFirst(key) + ']').val(value);\n    });\n  };\n\n  this.loadData = function (id) {\n    console.log('loading id:' + id);\n    $('.addressModal .spinnerDiv').removeClass('d-none');\n    $('.addressModal .addressModalForm').addClass('d-none');\n    $('.addressModal').modal().show();\n    var url = APP.getOpts()[\"Url\"][\"addressPopup\"]['show'];\n    url = url.replaceAll('*id*', id);\n    $.ajax({\n      url: url,\n      type: 'GET',\n      headers: {\n        'X-CSRF-TOKEN': APP.getApiToken()\n      },\n      success: function success(data) {\n        root.setData(data);\n        root.renderForm();\n        $('.spinnerDiv').addClass('d-none');\n        $('.addressModalForm').removeClass('d-none');\n      },\n      error: function error(xhr, ajaxOptions, thrownError) {\n        if (xhr.responseJSON.errors) {\n          ajaxErrorFieldHandler(xhr.responseJSON.errors);\n        } else {\n          if (xhr.status == 404) {\n            ajaxErrorFieldHandler([{\n              'detail': 'Nincs ilyen elem.'\n            }]);\n          } else {\n            ajaxErrorFieldHandler([{\n              'detail': 'Általános hiba.'\n            }]);\n          }\n        }\n\n        $('.addressModal').modal('hide');\n      }\n    });\n    return;\n    var contactData = {\n      id: 76,\n      name: 'Miksóné Borbély Erzsébet',\n      email: 'szamlazas1@funkcio.hu',\n      phone: '+36203407500'\n    };\n    root.setData(contactData);\n    root.renderForm();\n    $('.spinnerDiv').addClass('d-none');\n    $('.addressModalForm').removeClass('d-none');\n  };\n\n  this.getOpts = function () {\n    return Opts;\n  };\n\n  this.bindClickAction = function () {\n    $('.addressModal .btn').unbind('click');\n    $('.addressModal .buttonClose').bind('click', root.clickActionButtonClose);\n    $('.addressModal .buttonSave').bind('click', root.clickActionButtonSave);\n  };\n\n  this.clickActionButtonClose = function (event) {\n    console.log('click close');\n    Opts.onClose(event, root.formDataToDataObjectAPICall());\n  };\n\n  this.save = function (data) {\n    var form = $('.addressModal form');\n    var url = form.attr('action');\n    var ajaxType = 'POST';\n\n    if (data.id) {\n      url = APP.getOpts()[\"Url\"][\"addressPopup\"]['update'];\n      url = url.replaceAll('*id*', data.id);\n      ajaxType = 'PUT';\n    }\n\n    if (!data.status) {\n      data.status = APP.getOpts()[\"addressPopup\"]['defaultStatus'];\n    }\n\n    debug('!!!!URL!!!!! ' + url);\n    $.ajax({\n      url: url,\n      type: ajaxType,\n      headers: {\n        'X-CSRF-TOKEN': APP.getApiToken()\n      },\n      data: data,\n      success: function success(data) {\n        Opts.onAfterSave(data);\n        $('.addressModal').modal('toggle');\n      },\n      error: function error(xhr, ajaxOptions, thrownError) {\n        if (xhr.responseJSON.errors) {\n          ajaxErrorFieldHandler(xhr.responseJSON.errors);\n        }\n      }\n    });\n    return false;\n  };\n\n  this.clickActionButtonSave = function (event) {\n    console.log('click save');\n    var itemData = root.formDataToDataObjectAPICall(),\n        savedData;\n    debug(itemData);\n\n    if (savedData = root.save(itemData)) {\n      return true;\n    }\n\n    return false;\n  };\n\n  this.formDataToDataObjectAPICall = function () {\n    var data = new FormData(document.querySelector('.addressModal form'));\n    var formJSON = Object.fromEntries(data.entries());\n    /*Multiselect or checkbox to array:\n    formJSON.multiselectName = data.getAll('multiselectName');\n    */\n\n    $.each(formJSON, function (item, value) {\n      debug($.lcFirst(item.replace('address', '')));\n      formJSON[$.lcFirst(item.replace('address', ''))] = value;\n      delete formJSON[item];\n    });\n\n    if (formJSON.phone) {\n      formJSON.phone = formJSON.phone.replaceAll('_', '');\n    }\n\n    if (formJSON.email) {\n      formJSON.email = formJSON.email.replaceAll('_', '');\n    }\n\n    return formJSON;\n  };\n\n  this.construct(options, itemData);\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 16648 characters]\n//# sourceURL=webpack-internal:///./resources/js/components/addressPopup.js\n");

/***/ }),

/***/ "./resources/js/components/contactPopup.js":
/*!*************************************************!*\
  !*** ./resources/js/components/contactPopup.js ***!
  \*************************************************/
/***/ (() => {

eval("window.ContactPopUp = function (options, itemData) {\n  /*\r\n   * Variables accessible\r\n   * in the class\r\n   */\n  var Opts = {\n    active: false,\n    array: [],\n    onAfterSave: function onAfterSave() {},\n    onClose: function onClose() {}\n  };\n  var data = {};\n  var root = this;\n  /*\r\n   * Constructor\r\n   */\n\n  this.construct = function (options, itemData) {\n    console.log(' ContactPopUp constructor called');\n  };\n\n  this.init = function (options, itemData) {\n    console.log(' ContactPopUp nit called');\n    $.extend(Opts, options);\n    $.extend(data, itemData);\n    root.bindClickAction();\n    $(\"select.contactType\").select2({\n      maximumSelectionLength: 1\n    });\n  };\n\n  this.clearData = function () {\n    data = {};\n    root.renderForm();\n  };\n\n  this.setData = function (itemData) {\n    $.extend(data, itemData);\n  };\n\n  this.show = function () {\n    $('.contactModal').modal().show();\n  };\n\n  this.renderForm = function () {\n    $('.contactModal input').val('');\n    $('.contactModal textarea').val(''); //console.log(data.type);\n\n    $.each(data, function (key, value) {\n      /*\r\n                      console.log('key:'+key+' value:'+value);\r\n                      console.log('.contactModal'+' *[name=contact'+$.ucFirst(key)+']');\r\n      */\n      $('.contactModal' + ' *[name=contact' + $.ucFirst(key) + ']').val(value);\n    });\n\n    if (data.type === undefined || data.type === null) {\n      $(\"select.contactType\").select2().val();\n    } else {\n      $(\"select.contactType\").select2().val(data.type.split(','));\n    }\n\n    $(\"select.contactType\").select2().trigger('change');\n  };\n\n  this.loadData = function (contactId) {\n    console.log('loading id:' + contactId);\n    $('.contactModal .spinnerDiv').removeClass('d-none');\n    $('.contactModal .contactModalForm').addClass('d-none');\n    $('.contactModal').modal().show();\n    var url = APP.getOpts()[\"Url\"][\"contactPopup\"]['show'];\n    url = url.replaceAll('*contactId*', contactId);\n    $.ajax({\n      url: url,\n      type: 'GET',\n      headers: {\n        'X-CSRF-TOKEN': APP.getApiToken()\n      },\n      success: function success(data) {\n        root.setData(data);\n        root.renderForm();\n        $('.spinnerDiv').addClass('d-none');\n        $('.contactModalForm').removeClass('d-none');\n      },\n      error: function error(xhr, ajaxOptions, thrownError) {\n        if (xhr.responseJSON.errors) {\n          ajaxErrorFieldHandler(xhr.responseJSON.errors);\n        } else {\n          if (xhr.status == 404) {\n            ajaxErrorFieldHandler([{\n              'detail': 'Nincs ilyen elem.'\n            }]);\n          } else {\n            ajaxErrorFieldHandler([{\n              'detail': 'Általános hiba.'\n            }]);\n          }\n        }\n\n        $('.contactModal').modal('hide');\n      }\n    });\n    return;\n    var contactData = {\n      id: 76,\n      name: 'Miksóné Borbély Erzsébet',\n      email: 'szamlazas1@funkcio.hu',\n      phone: '+36203407500'\n    };\n    root.setData(contactData);\n    root.renderForm();\n    $('.spinnerDiv').addClass('d-none');\n    $('.contactModalForm').removeClass('d-none');\n  };\n\n  this.getOpts = function () {\n    return Opts;\n  };\n\n  this.bindClickAction = function () {\n    $('.contactModal .btn').unbind('click');\n    $('.contactModal .buttonClose').bind('click', root.clickActionButtonClose);\n    $('.contactModal .buttonSave').bind('click', root.clickActionButtonSave);\n  };\n\n  this.clickActionButtonClose = function (event) {\n    console.log('click close');\n    Opts.onClose(event, root.formDataToDataObjectAPICall());\n  };\n\n  this.saveContact = function (contactData) {\n    var form = $('.contactModal form');\n    var url = form.attr('action');\n    var ajaxType = 'POST';\n\n    if (contactData.id) {\n      url = APP.getOpts()[\"Url\"][\"contactPopup\"]['update']; //'{{route(\"admin.contact.update\",\"*contactId*\")}}';\n\n      url = url.replaceAll('*contactId*', contactData.id);\n      ajaxType = 'PUT';\n    }\n\n    if (!contactData.status) {\n      contactData.status = APP.getOpts()[\"contactPopup\"]['defaultStatus'];\n    }\n\n    $.ajax({\n      url: url,\n      type: ajaxType,\n      headers: {\n        'X-CSRF-TOKEN': APP.getApiToken()\n      },\n      data: contactData,\n      success: function success(data) {\n        Opts.onAfterSave(data);\n        $('.contactModal').modal('toggle');\n      },\n      error: function error(xhr, ajaxOptions, thrownError) {\n        if (xhr.responseJSON.errors) {\n          ajaxErrorFieldHandler(xhr.responseJSON.errors);\n        }\n      }\n    });\n    return false;\n  };\n\n  this.clickActionButtonSave = function (event) {\n    console.log('click save');\n    var contactData = root.formDataToDataObjectAPICall(),\n        savedData;\n\n    if (savedData = root.saveContact(contactData)) {\n      Opts.onAfterSave(event, contactData);\n      $('.contactModal').modal('toggle');\n      return true;\n    }\n\n    return false;\n  };\n\n  this.formDataToDataObjectAPICall = function () {\n    var data = new FormData(document.querySelector('.contactModal form'));\n    var formJSON = Object.fromEntries(data.entries());\n    /*Multiselect or checkbox to array:\r\n    formJSON.multiselectName = data.getAll('multiselectName');\r\n    */\n\n    $.each(formJSON, function (item, value) {\n      formJSON[$.lcFirst(item.replace('contact', ''))] = value;\n      delete formJSON[item];\n    });\n\n    if (formJSON.phone) {\n      formJSON.phone = formJSON.phone.replaceAll('_', '');\n    }\n\n    if (formJSON.email) {\n      formJSON.email = formJSON.email.replaceAll('_', '');\n    }\n\n    formJSON.type = $(\"select.contactType\").select2().val();\n    return formJSON;\n  };\n\n  this.construct(options, itemData);\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 18792 characters]\n//# sourceURL=webpack-internal:///./resources/js/components/contactPopup.js\n");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval-source-map devtool is used.
/******/ 	__webpack_modules__["./resources/js/components/addressPopup.js"]();
/******/ 	var __webpack_exports__ = {};
/******/ 	__webpack_modules__["./resources/js/components/contactPopup.js"]();
/******/ 	
/******/ })()
;