2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
import{ad as D,C as P,P as H,b as K,a8 as O,r as W,e as p,o as q,d as G,w as u,M as J,f as a,g as Q,a2 as X,h as y,i as n,j as e,m as d,t as i,p as _,l as Y,F as Z,k as ee,n as F,H as se,B,$ as te}from"./app-dvJP63FL.js";import{F as oe}from"./Form-ZbAUhXmz.js";import{s as ne}from"./shareService-BU7jlLil.js";import{_ as ae}from"./TwofaccountMedia-DzLyeBxh.js";import{a as re}from"./helpers-B2oe4lHy.js";import{U as ie}from"./index-BJsmINgd.js";const ce={class:"block is-size-7-mobile"},le={class:"block is-size-7-mobile"},ue={class:"mb-2"},he={__name:"TransferOwnership",props:{twofaccountId:[Number,String]},setup(I){const{t:c}=D(),$=P(),w=H(),V=J("2fauth"),h=Q(),x=X(),g=te(),m=K(),b=O(V.prefix+"returnTo","accountSharing"),t=W(new oe({new_owner_id:"",confirm_password:""})),l=I,f=p(m.items.find(s=>s.id==l.twofaccountId)),S=p(!1),k=p([]),C=B(()=>b.value=="accountSharing"?{name:"accountSharing",params:{twofaccountId:x.params.twofaccountId}}:{name:b.value}),M=B(()=>f.value.is_shared?c("message.shared_with_specific_users"):w.enableAllUsersSharingScope&&f.value.is_shared_with_all?c("message.shared_with_all"):c("message.not_shared"));q(()=>{N()});function R(){g.clear(),confirm(c("confirmation.you_will_loose_ownership"))&&t.patch(`/api/v1/twofaccounts/${l.twofaccountId}/owner`,{returnError:!0}).then(s=>{m.items.splice(m.items.findIndex(o=>o.id==l.twofaccountId),1),h.push({name:"accounts"})}).catch(s=>{s.response?.status===401?g.alert({text:c("notification.authentication_failed"),duration:1e4}):s.response?.status===422?(t.clear(),t.errors.set(t.extractErrors(s.response))):$.show(s)})}function N(){S.value=!0,ne.getRecipients(l.twofaccountId,"").then(s=>{re(s.data).forEach(o=>{k.value.push({text:o.name,value:o.id})})}).finally(()=>{S.value=!1})}return(s,o)=>{const T=a("RouterLink"),U=a("i18n-t"),L=a("FormSelect"),z=a("FormPasswordField"),A=a("FormButtons"),E=a("FormWrapper"),j=a("StackLayout");return y(),G(j,null,{content:u(()=>[n(e(ie),null,{default:u(({mode:v})=>[n(E,{title:"heading.transfer_ownership"},{default:u(()=>[d("div",ce,i(s.$t("message.ownership_can_be_transferred_legend")),1),n(ae,{twofaccount:e(f)},null,8,["twofaccount"]),d("div",le,[d("p",ue,[_(i(s.$t("message.ownership_can_be_transferred_sharing_legend"))+" ",1),e(w).enableAllUsersSharingScope?(y(),Y(Z,{key:0},[_(i(s.$t("message.ownership_can_be_transferred_sharing_legend_if_with_all")),1)],64)):ee("",!0),_(" "+i(s.$t("message.ownership_can_be_transferred_sharing_legend_if_with_specific_users")),1)]),n(U,{keypath:"message.this_account_is_currently_x",tag:"p",class:F(v=="dark"?"has-text-grey":"has-text-black")},{sharing_status:u(()=>[n(T,{class:"is-link",to:{name:"accountSharing",params:{twofaccountId:l.twofaccountId}}},{default:u(()=>[_(i(e(M)),1)]),_:1},8,["to"])]),_:1},8,["class"])]),d("form",{onSubmit:se(R,["prevent"]),onKeydown:o[3]||(o[3]=r=>e(t).onKeydown(r)),class:"mb-6"},[n(L,{modelValue:e(t).new_owner_id,"onUpdate:modelValue":o[0]||(o[0]=r=>e(t).new_owner_id=r),options:e(k),fieldName:"new_owner_id",errorMessage:e(t).errors.get("new_owner_id"),"is-loading":"isFetchingRecipients",label:"field.new_owner",help:"field.new_owner.help"},null,8,["modelValue","options","errorMessage"]),d("div",{class:F(["is-size-7-mobile mb-3",v=="dark"?"has-text-grey":"has-text-black"])},i(s.$t("message.double_check_new_owner")),3),n(z,{modelValue:e(t).confirm_password,"onUpdate:modelValue":o[1]||(o[1]=r=>e(t).confirm_password=r),fieldName:"confirm_password",errorMessage:e(t).errors.get("confirm_password"),label:"field.current_password",help:"field.current_password.help",autocomplete:"off"},null,8,["modelValue","errorMessage"]),n(A,{isDisabled:!e(t).new_owner_id||!e(t).confirm_password,isBusy:e(t).isBusy,submitLabel:"label.transfer",showCancelButton:!0,onCancel:o[2]||(o[2]=r=>e(h).push(e(C)))},null,8,["isDisabled","isBusy"])],32)]),_:2},1024)]),_:1})]),_:1})}}};export{he as default};
|