{"version":3,"file":"Compilator.MVC-5.55.8.8.min.js","names":["compilator","MVC","formDirty","isFormDirty","setFormDirty","value","toggleGridScrollbar","e","gridWrapper","sender","wrapper","gridDataTable","table","gridDataArea","closest","toggleClass","offsetHeight","ribbonBarButtonVisible","ribbonbarButtonId","visible","$","toggle","ribbonBarButtonEnabled","ribbonBarButtonId","shouldBeEnabled","image_url_prop","button","image_url","data","removeAttr","removeClass","attr","addClass","temp_image_url","undefined","validForm","element","form","length","getKendoValidator","validate","HistoryText","getText","prefix","text","vehicleExtensions","_urls","urlGetTreadDepth","_data","branchId","setBranchId","searchLicensePlateIfValueAvailableOnLoad","idPrefix","cmb","compilatorProperties","onDataBound","skipLicensePlateChangedCallback","input","blur","trigger","dataSource","read","licensePlateChanged","callback","licensePlateComboBox","nameLabel","cbDimensions","lowTreadDepth","vehicleDataLink","dataItem","setDataSource","hide","show","$string","isNullOrEmpty","DisplayMake","Colour","$url","Common","Vehicle","SearchVehicleDimensions","ajax","licensePlate","success","dimensions","dataTextField","dataValueField","serverFiltering","suggest","articleTemplateId","getArticleTemplateId","articleTemplateTypeId","inArray","parseInt","articleTemplatesWithDimensionSearch","open","focus","GetTreadDepth","tyreTreadDepth","HasLowTreadDepth","LowestTreadDepthForSetIs","error","licensePlateDataBound","searchLicensePlate","SearchVehicle","argsObject","suppressErrors","response","selectedItem","extend","add","select","LicensePlate","status","$kendo","openKendoWindowNotification","$translations","Information","Error_CouldNotFindRequestedLicensePlate","OK","openKendoErrorDialog","showVehicleData","vehicleInputId","vehicleInput","val","windowHandler","openVehicleDetails","compTextBox","numericOnly","replace","numericDecimalInputOnly","formatValue","txtField","format","decimalValue","kendo","parseFloat","Number","isNaN","on","this","type","$mvc"],"sources":["Compilator.MVC.js"],"mappings":"AAAA,aAUA,IAAIA,WAAaA,YAAc,CAAC,EAEhCA,WAAWC,IAAM,CAEfC,WAAW,EAEXC,YAAa,WACX,OAAOH,WAAWC,IAAIC,SACxB,EAEAE,aAAc,SAAUC,GAC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M,qBAAqBb,EAElC,GAEJ,EAEAc,gBAAiB,SAAUhH,GACzB,MAAMiH,EAAiBtG,EAAEX,GAAQmB,KAAK,oBAChC+F,EAAevG,EAAE,IAAMsG,GAC7B,IAAKC,EACH,OAEF,MAAMzC,EAAeyC,EAAaC,MAC9B1C,GACFlF,WAAW6H,cAAcC,mBAAmB5C,EAAclF,WAAWC,IAAI4C,kBAAkBG,MAAMC,UAAU,EAE/G,GAGFjD,WAAWC,IAAI8H,YAAc,CAC3BC,YAAa,SAAUzH,GACrBA,EAAEF,MAAQE,EAAEF,MAAM4H,QAAQ,UAAW,GACvC,EAEAC,wBAAyB,SAAU3H,GACjCA,EAAEF,MAAQE,EAAEF,MAAM4H,QAAQ,0BAA2B,GACvD,EAEAE,YAAa,SAAUC,GACrB,MAAMC,EAASjH,EAAEgH,GAAUxG,KAAK,eAChC,IAAKyG,EACH,OAEF,IAAIC,EAAeC,MAAMC,WAAWJ,EAAS/H,QACxB,OAAjBiI,GAAyBG,OAAOC,MAAMJ,MACxCA,OAAepG,GAEjB,MAAM7B,EAAQkI,MAAMF,OAAOA,EAAQC,GACnCF,EAAS/H,MAAQA,GAAS,EAC5B,GAGFe,GAAE,WACAA,EAAE,QAAQuH,GAAG,mBAAoB,4BAA4B,SAAUpI,GACrE,MAAM8C,EAAMjC,EAAE,sBAAuBwH,MAAMhH,KAAK,iBACjC,YAAXrB,EAAEsI,KACJxF,EAAI3C,QAAQsB,SAAS,aAEjBqB,GAAOA,EAAI3C,SACb2C,EAAI3C,QAAQoB,YAAY,YAG9B,GACF,IAEA,IAAIgH,KAAO9I,WAAWC","sourcesContent":["\"use strict\";\r\n/*\r\n\r\nINCLUDES SCRIPT ONLY INTENDED FOR / FIXES FOR MVC\r\n\r\nSHORTHANDS:\r\n$mvc  - compilator.MVC\r\n\r\n*/\r\n// Defines compilator global namespace.\r\nvar compilator = compilator || {};\r\n\r\ncompilator.MVC = {\r\n\r\n  formDirty: false,\r\n\r\n  isFormDirty: function () {\r\n    return compilator.MVC.formDirty;\r\n  },\r\n\r\n  setFormDirty: function (value) {\r\n    compilator.MVC.formDirty = value;\r\n  },\r\n\r\n  toggleGridScrollbar: function (e) {\r\n    const gridWrapper = e.sender.wrapper;\r\n    const gridDataTable = e.sender.table;\r\n    const gridDataArea = gridDataTable.closest(\".k-grid-content\");\r\n\r\n    gridWrapper.toggleClass(\"no-scrollbar\", gridDataTable[0].offsetHeight <= gridDataArea[0].offsetHeight);\r\n  },\r\n\r\n  ribbonBarButtonVisible: function (ribbonbarButtonId, visible) {\r\n    const button = $(\".RibbonBar #\" + ribbonbarButtonId);\r\n    button.toggle(visible);\r\n  },\r\n\r\n  ribbonBarButtonEnabled: function (ribbonBarButtonId, shouldBeEnabled) {\r\n    const image_url_prop = \"imageurl\";\r\n    const button = $(\".RibbonBar #\" + ribbonBarButtonId);\r\n\r\n    //Get image url (when not disabled)\r\n    let image_url = button.data(image_url_prop);\r\n\r\n    button.removeAttr(\"disabled\");\r\n    button.removeClass(\"rrbDisabled\");\r\n    if (!shouldBeEnabled) {\r\n      //Button click will be stopped by click event handler\r\n      //  Attaching a click event here will make it execute last (meaning the actual click event will execute first).\r\n      button.attr(\"disabled\", \"disabled\");\r\n      button.addClass(\"rrbDisabled\");\r\n\r\n      //Extract image url, if any (when disabled)\r\n      const temp_image_url = button.data(image_url_prop + \"-disabled\");\r\n      if (temp_image_url !== undefined && temp_image_url !== \"\") {\r\n        image_url = temp_image_url;\r\n      }\r\n    }\r\n\r\n    //Set image\r\n    if (image_url !== undefined && image_url !== \"\") {\r\n      $(\"img\", button).attr(\"src\", image_url);\r\n    }\r\n  },\r\n\r\n  validForm: function (element) {\r\n    const form = $(element).closest(\"form\");\r\n    if (form.length > 0) {\r\n      const validator = $(form).getKendoValidator();\r\n      return validator.validate();\r\n    }\r\n\r\n    return true;\r\n  }\r\n};\r\n\r\ncompilator.MVC.HistoryText = {\r\n  // Returns the selected text\r\n  getText: function (prefix) {\r\n    const cb = $(\"#\" + prefix + \"_cbHistoryText\").data(\"kendoComboBox\");\r\n    return cb.text();\r\n  }\r\n};\r\n\r\ncompilator.MVC.vehicleExtensions = {\r\n  _urls: {\r\n    urlGetTreadDepth: undefined\r\n  },\r\n\r\n  _data: {\r\n    branchId: undefined\r\n  },\r\n\r\n  setBranchId: function (branchId) {\r\n    compilator.MVC.vehicleExtensions._data.branchId = branchId;\r\n  },\r\n\r\n  searchLicensePlateIfValueAvailableOnLoad: function (idPrefix) {\r\n    const cmb = $(\"#\" + idPrefix + \"_licensePlate\").data(\"kendoComboBox\");\r\n    if (cmb.value()) {\r\n      if (!cmb.compilatorProperties) {\r\n        cmb.compilatorProperties = {};\r\n      }\r\n      cmb.compilatorProperties.onDataBound = function () {\r\n        cmb.compilatorProperties.skipLicensePlateChangedCallback = true;\r\n        cmb.input.blur();\r\n        cmb.trigger(\"change\");\r\n        cmb.compilatorProperties.onDataBound = undefined;\r\n      };\r\n      cmb.dataSource.read();\r\n    }\r\n  },\r\n\r\n  licensePlateChanged: function (idPrefix, callback) {\r\n    const licensePlateComboBox = $(\"#\" + idPrefix + \"_licensePlate\").data(\"kendoComboBox\");\r\n    const nameLabel = $(\"[for=\" + idPrefix + \"_description]\");\r\n    const cbDimensions = $(\"#\" + idPrefix + \"_dimensions\").data(\"kendoComboBox\");\r\n    const lowTreadDepth = $(\"#\" + idPrefix + \"_lowTreadDepth\");\r\n    const vehicleDataLink = $(\"#\" + idPrefix + \"_vehicleDataLink\");\r\n\r\n    const dataItem = licensePlateComboBox.dataItem();\r\n    if (callback && (!licensePlateComboBox.compilatorProperties || !licensePlateComboBox.compilatorProperties.skipLicensePlateChangedCallback)) {\r\n      callback(licensePlateComboBox, licensePlateComboBox.text());\r\n    }\r\n    if (licensePlateComboBox.compilatorProperties) {\r\n      licensePlateComboBox.compilatorProperties.skipLicensePlateChangedCallback = false;\r\n    }\r\n    if (dataItem === undefined) {\r\n      if (cbDimensions) {\r\n        cbDimensions.setDataSource();\r\n      }\r\n      if (nameLabel) {\r\n        nameLabel.text(\"\");\r\n        nameLabel.trigger(\"change\");\r\n      }\r\n      if (lowTreadDepth) {\r\n        lowTreadDepth.hide();\r\n      }\r\n      vehicleDataLink.hide();\r\n      return;\r\n    }\r\n\r\n    vehicleDataLink.show();\r\n\r\n    if (nameLabel) {\r\n      const text = $string.isNullOrEmpty(dataItem.DisplayMake) ? ($string.isNullOrEmpty(dataItem.Colour) ? \"\" : dataItem.Colour) : $string.isNullOrEmpty(dataItem.Colour) ? dataItem.DisplayMake : dataItem.DisplayMake + \" \" + dataItem.Colour;\r\n      nameLabel.text(text);\r\n      nameLabel.trigger(\"change\");\r\n    }\r\n\r\n    if (cbDimensions) {\r\n      $url.Common.Vehicle.SearchVehicleDimensions.ajax({\r\n        licensePlate: licensePlateComboBox.text()\r\n      }, {\r\n        success: function (dimensions) {\r\n          // Load into dimension combobox\r\n          cbDimensions.setDataSource({\r\n            dataTextField: \"Dimension\",\r\n            dataValueField: \"ID\",\r\n            serverFiltering: false,\r\n            suggest: true,\r\n            data: dimensions\r\n          });\r\n\r\n          // Open combobox\r\n          cbDimensions.value(\"\");\r\n          const articleTemplateId = getArticleTemplateId().articleTemplateTypeId;\r\n          if ($.inArray(parseInt(articleTemplateId), articleTemplatesWithDimensionSearch) !== -1) {\r\n              cbDimensions.open();\r\n              cbDimensions.input.focus();\r\n          }\r\n\r\n          if (lowTreadDepth) {\r\n            //Checks if vehicle has low tread depth\r\n            $url.Common.Vehicle.GetTreadDepth.ajax({\r\n              licensePlate: licensePlateComboBox.text()\r\n            }, {\r\n              success: function (tyreTreadDepth) {\r\n                if (tyreTreadDepth.HasLowTreadDepth) {\r\n                  lowTreadDepth.show();\r\n                  lowTreadDepth.attr(\"title\", tyreTreadDepth.LowestTreadDepthForSetIs);\r\n                }\r\n                else {\r\n                  lowTreadDepth.hide();\r\n                  lowTreadDepth.attr(\"title\", \"\");\r\n                }\r\n              },\r\n              error: function () {\r\n                lowTreadDepth.hide();\r\n                lowTreadDepth.attr(\"title\", \"\");\r\n              }\r\n            });\r\n          }\r\n        }\r\n      });\r\n    }\r\n  },\r\n\r\n  licensePlateDataBound: function (e) {\r\n    if (e.sender.compilatorProperties && e.sender.compilatorProperties.onDataBound) {\r\n      e.sender.compilatorProperties.onDataBound();\r\n    }\r\n  },\r\n\r\n  searchLicensePlate: function (idPrefix) {\r\n    const cmb = $(\"#\" + idPrefix + \"_licensePlate\").data(\"kendoComboBox\");\r\n    const text = cmb.text();\r\n    $url.Common.Vehicle.SearchVehicle.ajax($url.Common.Vehicle.SearchVehicle.argsObject(text, compilator.MVC.vehicleExtensions._data.branchId, false), {\r\n      suppressErrors: true,\r\n      success: function (response) {\r\n        let selectedItem = cmb.dataItem();\r\n        if (selectedItem) {\r\n          $.extend(selectedItem, response);\r\n        } else {\r\n          selectedItem = cmb.dataSource.add(response);\r\n        }\r\n\r\n        cmb.select(function (dataItem) {\r\n          return dataItem.LicensePlate === selectedItem.LicensePlate;\r\n        });\r\n        cmb.trigger(\"change\");\r\n      },\r\n      error: function (response) {\r\n        switch (response.status) {\r\n          case 404:\r\n            $kendo.openKendoWindowNotification($translations.Common.Information, $translations.Common.Error_CouldNotFindRequestedLicensePlate, $translations.Common.OK, null, false, null);\r\n            break;\r\n          default:\r\n            $kendo.openKendoErrorDialog(response);\r\n        }\r\n      }\r\n    });\r\n  },\r\n\r\n  showVehicleData: function (sender) {\r\n    const vehicleInputId = $(sender).data(\"vehicle-input-id\");\r\n    const vehicleInput = $(\"#\" + vehicleInputId);\r\n    if (!vehicleInput) {\r\n      return;\r\n    }\r\n    const licensePlate = vehicleInput.val();\r\n    if (licensePlate) {\r\n      compilator.windowHandler.openVehicleDetails(licensePlate, compilator.MVC.vehicleExtensions._data.branchId, false);\r\n    }\r\n  }\r\n};\r\n\r\ncompilator.MVC.compTextBox = {\r\n  numericOnly: function (e) {\r\n    e.value = e.value.replace(/[^0-9]/g, \"\");\r\n  },\r\n\r\n  numericDecimalInputOnly: function (e) {\r\n    e.value = e.value.replace(/[^-{0,1}\\d\\.{0,1}\\d+$]/g, \"\");\r\n  },\r\n\r\n  formatValue: function (txtField) {\r\n    const format = $(txtField).data(\"comp-format\");\r\n    if (!format) {\r\n      return;\r\n    }\r\n    let decimalValue = kendo.parseFloat(txtField.value);\r\n    if (decimalValue === null || Number.isNaN(decimalValue)) {\r\n      decimalValue = undefined;\r\n    }\r\n    const value = kendo.format(format, decimalValue);\r\n    txtField.value = value || \"\";\r\n  }\r\n};\r\n\r\n$(function () {\r\n  $(\"body\").on(\"focusin focusout\", \".form-control.k-combobox\", function (e) {\r\n    const cmb = $(\"input:not(.k-input)\", this).data(\"kendoComboBox\");\r\n    if (e.type === \"focusin\") {\r\n      cmb.wrapper.addClass(\"isFocused\");\r\n    } else {\r\n      if (cmb && cmb.wrapper) {\r\n        cmb.wrapper.removeClass(\"isFocused\");\r\n      }\r\n    }\r\n  });\r\n});\r\n\r\nvar $mvc = compilator.MVC;"]}