mirror of
https://github.com/nextcloud/server.git
synced 2026-04-23 15:21:00 -04:00
2 lines
5 KiB
JavaScript
2 lines
5 KiB
JavaScript
import{c as g}from"./index-D0gj0nne.chunk.mjs";import{g as b,b as y}from"./createElementId-DhjFt1I9-DmxdOxki.chunk.mjs";import{d as I}from"./index-Bndk0DrU.chunk.mjs";import{N as U}from"./autolink-U5pBzLgI-DPNCkNxB.chunk.mjs";import{N as R}from"./NcEmptyContent-B8-90BSI-1y2HcWGh.chunk.mjs";import{N as $}from"./NcSelect-DLheQ2yp-C6fHgfXd.chunk.mjs";import{A,l as w}from"./logger-4TYJd41C.chunk.mjs";import{a as k}from"./index-Ma7sfat2.chunk.mjs";import{o as c,c as d,b as a,t as f,e as C,m as L,i as n,h as u,w as p,j as P,g as x}from"./runtime-dom.esm-bundler-DIF-dmiV.chunk.mjs";import"./index-sH3U_332.chunk.mjs";import"./translation-DoG5ZELJ-Bni_xMHF.chunk.mjs";import"./NcModal-DHryP_87-DTKTujA6.chunk.mjs";import"./Web-D7kU0XCu.chunk.mjs";const O={name:"ArrowRightIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},B=["aria-hidden","aria-label"],T=["fill","width","height"],E={d:"M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"},Q={key:0};function z(e,i,r,l,o,s){return c(),d("span",L(e.$attrs,{"aria-hidden":r.title?null:"true","aria-label":r.title,class:"material-design-icon arrow-right-icon",role:"img",onClick:i[0]||(i[0]=h=>e.$emit("click",h))}),[(c(),d("svg",{fill:r.fillColor,class:"material-design-icon__svg",width:r.size,height:r.size,viewBox:"0 0 24 24"},[a("path",E,[r.title?(c(),d("title",Q,f(r.title),1)):C("",!0)])],8,T))],16,B)}const F=k(O,[["render",z]]),V={name:"ProfilesCustomPicker",components:{NcSelect:$,NcButton:U,NcEmptyContent:R,AccountOutline:A,ArrowRightIcon:F},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:I(function(...e){this.findProfiles(...e)},300),async findProfiles(e){const i=y("core/autocomplete/get?search={searchQuery}&itemType=%20&itemId=%20&shareTypes[]=0&limit=20",{searchQuery:e});try{const r=await g.get(i);this.profiles=r.data.ocs.data.map(l=>({user:l.id,displayName:l.label,icon:l.icon,subtitle:l.subline,isNoUser:l.source.startsWith("users")}))}catch(r){w.error("profile_picker: error while searching for users",{error:r})}finally{this.loading=!1}},submit(){this.resultUrl=window.location.origin+b(`/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+b(`/u/${this.selectedProfile.user.trim().toLowerCase()}`,null,{noRewrite:!0});try{const i=await g.get(y("references/resolve",2)+"?reference="+encodeURIComponent(this.resultUrl),{signal:this.abortController.signal});this.reference=i.data.ocs.data.references[this.resultUrl]}catch(i){w.error("profile_picker: error resolving the user profile link",{error:i})}finally{this.loading=!1}},clearSelection(){this.selectedProfile=null,this.resultUrl=null,this.reference=null}}},H={class:"profile-picker"},j={class:"profile-picker__heading"},M={class:"input-wrapper"},W={class:"profile-picker__footer"};function Z(e,i,r,l,o,s){const h=n("NcSelect"),v=n("AccountOutline"),N=n("NcEmptyContent"),S=n("ArrowRightIcon"),_=n("NcButton");return c(),d("div",H,[a("div",j,[a("h2",null,f(e.t("profile","Profile picker")),1),a("div",M,[u(h,{ref:"profiles-search-input",modelValue:o.selectedProfile,"onUpdate:modelValue":i[0]||(i[0]=m=>o.selectedProfile=m),inputId:"profiles-search",loading:o.loading,filterable:!1,placeholder:e.t("profile","Search for a user profile"),clearSearchOnBlur:()=>!1,multiple:!1,options:s.options,label:"displayName",onSearch:s.searchForProfile,"onOption:selecting":s.resolveResult},{"no-options":p(({search:m})=>[P(f(m?s.noResultText:e.t("profile","Search for a user profile. Start typing")),1)]),_:1},8,["modelValue","loading","placeholder","options","onSearch","onOption:selecting"])]),u(N,{class:"empty-content"},{icon:p(()=>[u(v,{size:20})]),_:1})]),a("div",W,[o.selectedProfile!==null?(c(),x(_,{key:0,variant:"primary","aria-label":e.t("profile","Insert selected user profile link"),disabled:o.loading||o.selectedProfile===null,onClick:s.submit},{icon:p(()=>[u(S)]),default:p(()=>[P(f(e.t("profile","Insert"))+" ",1)]),_:1},8,["aria-label","disabled","onClick"])):C("",!0)])])}const se=k(V,[["render",Z],["__scopeId","data-v-5dbe4c82"]]);export{se as default};
|
||
//# sourceMappingURL=ProfilesCustomPicker-eX7yk2bS.chunk.mjs.map
|