"use strict";App.Pages.Services=function(){function filter(keyword){var selectId=1"))}),0===response.length?$filterServices.find(".results").append($("",{text:lang("no_records_found")})):response.length===filterLimit&&$("",{type:"button",class:"btn btn-outline-secondary w-100 load-more text-center",text:lang("load_more"),click:function click(){filterLimit+=20,App.Pages.Services.filter(keyword,selectId,show)}}).appendTo("#filter-services .results"),selectId&&App.Pages.Services.select(selectId,show)})}function select(id){var show=!!(1",{class:"service-row entry","data-id":service.id,html:[$("",{text:name}),$("
"),$("",{class:"text-muted",text:info}),$("
")]})},resetForm:function resetForm(){$filterServices.find(".selected").removeClass("selected"),$filterServices.find("button").prop("disabled",!1),$filterServices.find(".results").css("color",""),$services.find(".record-details").find("input, select, textarea").val("").prop("disabled",!0),$services.find(".record-details .form-label span").prop("hidden",!0),$services.find(".record-details #is-private").prop("checked",!1),$services.find(".record-details h4 a").remove(),$services.find(".add-edit-delete-group").show(),$services.find(".save-cancel-group").hide(),$("#edit-service, #delete-service").prop("disabled",!0),$services.find(".record-details .is-invalid").removeClass("is-invalid"),$services.find(".record-details .form-message").hide(),App.Components.ColorSelection.disable($color)},display:function display(service){$id.val(service.id),$name.val(service.name),$duration.val(service.duration),$price.val(service.price),$currency.val(service.currency),$description.val(service.description),$location.val(service.location),$availabilitiesType.val(service.availabilities_type),$attendantsNumber.val(service.attendants_number),$isPrivate.prop("checked",service.is_private),App.Components.ColorSelection.setColor($color,service.color);var serviceCategoryId=null===service.id_service_categories?"":service.id_service_categories;$serviceCategoryId.val(serviceCategoryId)},select:select,addEventListeners:function addEventListeners(){$services.on("submit","#filter-services form",function(event){event.preventDefault();var key=$filterServices.find(".key").val();$filterServices.find(".selected").removeClass("selected"),App.Pages.Services.resetForm(),App.Pages.Services.filter(key)}),$services.on("click",".service-row",function(event){if($filterServices.find(".filter").prop("disabled"))return void $filterServices.find(".results").css("color","#AAA");var serviceId=$(event.currentTarget).attr("data-id"),service=filterResults.find(function(filterResult){return+filterResult.id===+serviceId}),dedicatedUrl=App.Utils.Url.siteUrl("?service="+encodeURIComponent(service.id)),$link=$("",{href:dedicatedUrl,target:"_blank",html:[$("",{class:"fas fa-link me-2"}),$("",{text:lang("booking_link")})]});$services.find(".record-details h4").find("a").remove().end().append($link),App.Pages.Services.display(service),$filterServices.find(".selected").removeClass("selected"),$(event.currentTarget).addClass("selected"),$("#edit-service, #delete-service").prop("disabled",!1)}),$services.on("click","#add-service",function(){App.Pages.Services.resetForm(),$services.find(".add-edit-delete-group").hide(),$services.find(".save-cancel-group").show(),$services.find(".record-details").find("input, select, textarea").prop("disabled",!1),$services.find(".record-details .form-label span").prop("hidden",!1),$filterServices.find("button").prop("disabled",!0),$filterServices.find(".results").css("color","#AAA"),App.Components.ColorSelection.enable($color),$name.val("Service"),$duration.val("30"),$price.val("0"),$currency.val(""),$serviceCategoryId.val(""),$availabilitiesType.val("flexible"),$attendantsNumber.val("1")}),$services.on("click","#cancel-service",function(){var id=$id.val();App.Pages.Services.resetForm(),""!==id&&App.Pages.Services.select(id,!0)}),$services.on("click","#save-service",function(){var service={name:$name.val(),duration:$duration.val(),price:$price.val(),currency:$currency.val(),description:$description.val(),location:$location.val(),color:App.Components.ColorSelection.getColor($color),availabilities_type:$availabilitiesType.val(),attendants_number:$attendantsNumber.val(),is_private:+$isPrivate.prop("checked"),id_service_categories:$serviceCategoryId.val()||void 0};""!==$id.val()&&(service.id=$id.val()),App.Pages.Services.validate()&&App.Pages.Services.save(service)}),$services.on("click","#edit-service",function(){$services.find(".add-edit-delete-group").hide(),$services.find(".save-cancel-group").show(),$services.find(".record-details").find("input, select, textarea").prop("disabled",!1),$services.find(".record-details .form-label span").prop("hidden",!1),$filterServices.find("button").prop("disabled",!0),$filterServices.find(".results").css("color","#AAA"),App.Components.ColorSelection.enable($color)}),$services.on("click","#delete-service",function(){var serviceId=$id.val(),buttons=[{text:lang("cancel"),click:function click(event,messageModal){messageModal.hide()}},{text:lang("delete"),click:function click(event,messageModal){App.Pages.Services.remove(serviceId),messageModal.hide()}}];App.Utils.Message.show(lang("delete_service"),lang("delete_record_prompt"),buttons)})}}}();