"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/database/assign-to-subscription"],{1700:(t,s,e)=>{e.r(s),e.d(s,{default:()=>a});var i=e(90);class n extends i.PopupForm{_initConfiguration(t){super._initConfiguration({locale:i.Locale.getSection("smb.components.lists.databases"),fullHeight:!0,...t}),this._ids=this._getConfigParam("ids",[]),this._handlerUrl=this._getConfigParam("handlerUrl","/database/assign-to-subscription"),this._sendButtonId=this._getConfigParam("sendButtonId","btn-send"),this._cancelButtonId=this._getConfigParam("cancelButtonId","btn-cancel")}render(){super.render(),this.setBoxType("form-box"),this.setTitle(this.lmsg("assignToSubscriptionPopupTitle")),document.getElementById(this._contentAreaId).innerHTML=`<p>${this.lmsg("assignToSubscriptionPopupDesc")}</p><form method="post" id="${this._id}-form"><div class="form-row"><div class="field-name"><label for="${this._id}-domain-name">${this.lmsg("assignToSubscription")}</label></div><div class="field-value" id="${this._id}-container"></div></form>`,this.initSearch(),this.initOnSubmitEvent(),this.addOkButton(),this.addCancelButton()}initSearch(){this._searchComponent=new i.LookUp({id:`${this._id}-domain-name`,name:`${this._id}-domain-name`,renderTo:`${this._id}-container`,locale:this.getLocale(),dataUrl:"/database/subscription-list/",copyTitleValue:!0})}onSubmitEvent(t){return this.handler(),t.preventDefault(),!1}initOnSubmitEvent(){const t=document.getElementById(`${this._id}-form`);t._formSubmit=t.submit,t.submit=this.onOkClick.bind(this),t.addEventListener("submit",this.onSubmitEvent.bind(this))}addOkButton(){this.addRightButton(i.Locale.getSection("components.buttons").lmsg("ok"),this.onOkClick,!0,!0,{id:this._sendButtonId})}addCancelButton(){this.addRightButton(i.Locale.getSection("components.buttons").lmsg("cancel"),this.onCancelClick,!1,!1,{id:this._cancelButtonId})}onOkClick(){this.handler()}onCancelClick(){this.hide()}disable(){const t=document.getElementById(this._sendButtonId);t&&(t.disabled=!0,t.classList.add("disabled"),this._sendButtonTitle||(this._sendButtonTitle=t.innerHTML),t.innerHTML=`<span class="wait">${this.lmsg("loading")}</span>`);const s=document.getElementById(this._cancelButtonId);s&&(s.disabled=!0,s.classList.add("disabled"))}enable(){const t=document.getElementById(this._sendButtonId);t&&(t.disabled=!1,t.innerHTML=this._sendButtonTitle,t.classList.remove("disabled"));const s=document.getElementById(this._cancelButtonId);s&&(s.disabled=!1,s.classList.remove("disabled"))}onException(t){this._addErrorMessage(`Internal error: ${t}`),this.enable()}onSuccess(t){(0,i.clearStatusMessages)(),this.processForm(t)}processForm(t){t.status&&"error"===t.status?($A(t.statusMessages).each((function(t){(0,i.addStatusMessage)(t.status,t.content,{title:t.title})})),this.hide()):document.location.reload()}handler(){const t=this._searchComponent.getDisplayValue();t&&i.api.post((0,i.prepareUrl)(this._handlerUrl),{domainName:t,ids:this._ids}).then(this.onSuccess.bind(this)).catch(this.onException.bind(this))}}const a=n}}]);
//# sourceMappingURL=assign-to-subscription.js.map?615ef886c6adfc515b66