mirror of
https://github.com/nextcloud/server.git
synced 2026-04-26 00:27:49 -04:00
2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
import{c as d}from"./index-DqG-5vGV.chunk.mjs";import{b as h,c as m,d as C}from"./index-Bp9-GhMo.chunk.mjs";import{A as _,N as I}from"./ArrowRight-YxbwZNEK.chunk.mjs";import{N as S}from"./NcEmptyContent-CDgWCt_m-SjrDEqRZ.chunk.mjs";import{N as U}from"./NcSelect-B1uITk_3-B0TPRkMI.chunk.mjs";import{A as R,l as g}from"./logger-CHeKh3CN.chunk.mjs";import{_ as A}from"./public-CvthP4YJ.chunk.mjs";import{r as s,o as b,f as O,g as a,t as f,k as c,w as u,j as y,c as x,h as T}from"./preload-helper-D9xEqq8S.chunk.mjs";import"./util-Caafb9Jl.chunk.mjs";import"./Web-7MW_v0ET.chunk.mjs";import"./translation-DoG5ZELJ-8aobdbPK.chunk.mjs";import"./NcModal-kyWZ3UFC-DO8otox5.chunk.mjs";import"./TrashCanOutline-COIylzhj.chunk.mjs";const $={name:"ProfilesCustomPicker",components:{NcSelect:U,NcButton:I,NcEmptyContent:S,AccountOutline:R,ArrowRightIcon:_},props:{providerId:{type:String,required:!0},accessible:{type:Boolean,default:!1}},emits:["submit"],data(){return{searchQuery:"",loading:!1,resultUrl:null,reference:null,profiles:[],selectedProfile:null,abortController:null}},computed:{options(){return this.searchQuery!==""?this.profiles:[]},noResultText(){return this.loading?t("profile","Searching …"):t("profile","Not found")}},mounted(){this.focusOnInput()},methods:{focusOnInput(){this.$nextTick(()=>{this.$refs["profiles-search-input"].$el.getElementsByTagName("input")[0]?.focus()})},async searchForProfile(e){e.trim()===""||e.trim().length<3||(this.searchQuery=e.trim(),this.loading=!0,await this.debounceFindProfiles(e))},debounceFindProfiles:C(function(...e){this.findProfiles(...e)},300),async findProfiles(e){const r=m("core/autocomplete/get?search={searchQuery}&itemType=%20&itemId=%20&shareTypes[]=0&limit=20",{searchQuery:e});try{const n=await d.get(r);this.profiles=n.data.ocs.data.map(i=>({user:i.id,displayName:i.label,icon:i.icon,subtitle:i.subline,isNoUser:i.source.startsWith("users")}))}catch(n){g.error("profile_picker: error while searching for users",{error:n})}finally{this.loading=!1}},submit(){this.resultUrl=window.location.origin+h(`/u/${this.selectedProfile.user.trim().toLowerCase()}`,null,{noRewrite:!0}),this.$emit("submit",this.resultUrl),this.$el.dispatchEvent(new CustomEvent("submit",{detail:this.resultUrl,bubbles:!0}))},async resolveResult(e){this.loading=!0,this.abortController=new AbortController,this.selectedProfile=e,this.resultUrl=window.location.origin+h(`/u/${this.selectedProfile.user.trim().toLowerCase()}`,null,{noRewrite:!0});try{const r=await d.get(m("references/resolve",2)+"?reference="+encodeURIComponent(this.resultUrl),{signal:this.abortController.signal});this.reference=r.data.ocs.data.references[this.resultUrl]}catch(r){g.error("profile_picker: error resolving the user profile link",{error:r})}finally{this.loading=!1}},clearSelection(){this.selectedProfile=null,this.resultUrl=null,this.reference=null}}},B={class:"profile-picker"},E={class:"profile-picker__heading"},Q={class:"input-wrapper"},F={class:"profile-picker__footer"};function V(e,r,n,i,o,l){const w=s("NcSelect"),P=s("AccountOutline"),k=s("NcEmptyContent"),N=s("ArrowRightIcon"),v=s("NcButton");return b(),O("div",B,[a("div",E,[a("h2",null,f(e.t("profile","Profile picker")),1),a("div",Q,[c(w,{ref:"profiles-search-input",modelValue:o.selectedProfile,"onUpdate:modelValue":r[0]||(r[0]=p=>o.selectedProfile=p),inputId:"profiles-search",loading:o.loading,filterable:!1,placeholder:e.t("profile","Search for a user profile"),clearSearchOnBlur:()=>!1,multiple:!1,options:l.options,label:"displayName",onSearch:l.searchForProfile,"onOption:selecting":l.resolveResult},{"no-options":u(({search:p})=>[y(f(p?l.noResultText:e.t("profile","Search for a user profile. Start typing")),1)]),_:1},8,["modelValue","loading","placeholder","options","onSearch","onOption:selecting"])]),c(k,{class:"empty-content"},{icon:u(()=>[c(P,{size:20})]),_:1})]),a("div",F,[o.selectedProfile!==null?(b(),x(v,{key:0,variant:"primary","aria-label":e.t("profile","Insert selected user profile link"),disabled:o.loading||o.selectedProfile===null,onClick:l.submit},{icon:u(()=>[c(N)]),default:u(()=>[y(f(e.t("profile","Insert"))+" ",1)]),_:1},8,["aria-label","disabled","onClick"])):T("",!0)])])}const Z=A($,[["render",V],["__scopeId","data-v-5dbe4c82"]]);export{Z as default};
|
||
//# sourceMappingURL=ProfilesCustomPicker-D0VTmaly.chunk.mjs.map
|