text: (this.webpackJsonp=this.webpackJsonp||[]).push([[191],{1083:function(e,a,t){"use strict";t.r(a);var n=t(81);document.addEventListener("DOMContentLoaded",function(){return new n.a})},1084:function(e,a,t){t(31),e.exports=t(1083)},81:function(e,a,t){"use strict";var n=t(0),s=t.n(n),r=t(3),i=t.n(r),l=t(5),u=t(1),o=t(47),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function c(e,a){var t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.users=this.users.bind(this),this.user=this.user.bind(this),this.usersPath="/autocomplete/users.json",this.userPath="/autocomplete/users/:id.json",null!=e&&("object"===(void 0===e?"undefined":d(e))?this.currentUser=e:this.currentUser=JSON.parse(e));var r,c=n.handleClick;t=s()(a),a||(t=s()(".js-user-search")),t.each((r=this,function(e,a){var t,n,d,f,m,v,p,h,g,b,w,y,_,U,S,k,C,j,I,x={};d=s()(a),x.projectId=d.data("projectId"),x.groupId=d.data("groupId"),x.showCurrentUser=d.data("currentUser"),x.todoFilter=d.data("todoFilter"),x.todoStateFilter=d.data("todoStateFilter"),j=d.data("nullUser"),y=d.data("nullUserDefault"),I=d.data("showMenuAbove"),C=d.data("anyUser"),_=d.data("firstUser"),x.authorId=d.data("authorId"),w=d.data("defaultLabel"),U=d.data("issueUpdate"),m=d.closest(".selectbox"),t=m.closest(".block"),p=d.data("abilityName"),v=t.find(".value"),n=t.find(".sidebar-collapsed-user"),f=t.find(".block-loading").fadeOut(),k=y&&j?0:null,void 0===(S=d.data("selected"))&&(S=k);var D=function(){var e=d.closest(".selectbox").find("input[name='"+d.data("fieldName")+"'][value=0]");e&&e.remove();var a=document.createElement("input");a.type="hidden",a.name=d.data("fieldName");var t=d.data("currentUserInfo");t?(a.value=t.id,a.dataset.meta=i.a.escape(t.name)):r.currentUser&&(a.value=r.currentUser.id),m?d.parent().before(a):d.after(a)};t[0]&&t[0].addEventListener("assignYourself",D);var N=function(){return m.find('input[name="'+d.data("fieldName")+'"]')},A=function(){return N().map(function(e,a){return parseInt(a.value,10)}).get()},E=function(){var e=d.data("maxSelect");if(e){var a=A();if(a.length>e){var t=a[0];d.closest(".selectbox").find("input[name='"+d.data("fieldName")+"'][value="+t+"]").remove(),emitSidebarEvent("sidebar.removeAssignee",{id:t})}}},L=function(e,a){var t=A().filter(function(e){return 0!==e}),n=N().map(function(e,a){return{name:a.dataset.meta,value:parseInt(a.value,10)}}).filter(function(e){return 0!==e.id}).get(0);if(0===t.length)return"Unassigned";if(1===t.length)return n.name;if(a){var s=t.filter(function(a){return a!==e.id});return e.name+" + "+s.length+" more"}return n.name+" + "+(t.length-1)+" more"};return s()(".assign-to-me-link").on("click",function(e){if(e.preventDefault(),s()(e.currentTarget).hide(),d.data("multiSelect")){D(),E();var a=d.data("currentUserInfo");d.find(".dropdown-toggle-text").text(L(a)).removeClass("is-default")}else{var t=s()('input[name="'+d.data("fieldName")+'"]');t.val(gon.current_user_id),S=t.val(),d.find(".dropdown-toggle-text").text(gon.current_user_fullname).removeClass("is-default")}}),t.on("click",".js-assign-yourself",function(e){return e.preventDefault(),h(r.currentUser.id)}),h=function(e){var a;return(a={})[p]={},a[p].assignee_id=null!=e?e:null,f.removeClass("hidden").fadeIn(),d.trigger("loading.gl.dropdown"),l.a.put(U,a).then(function(e){var a,t,s=e.data;return d.trigger("loaded.gl.dropdown"),f.fadeOut(),s.assignee?(a={name:s.assignee.name,username:s.assignee.username,avatar:s.assignee.avatar_url},t=i.a.escape(a.name)):(a={name:"Unassigned",username:"",avatar:""},t=Object(u.a)("Assignee")),v.html(g(a)),n.attr("title",t).tooltip("_fixTitle"),n.html(b(a))})},b=i.a.template('<% if( avatar ) { %> <a class="author-link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>'),g=i.a.template('<% if (username) { %> <a class="author-link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself"> No assignee - <a href="#" class="js-assign-yourself"> assign yourself </a> </span> <% } %>'),d.glDropdown({showMenuAbove:I,data:function(e,a){return r.users(e,x,function(t){(this.instance||this.options.instance).options.processData(e,t,a)}.bind(this))},processData:function(e,a,t){var n=a;if(d.hasClass("js-multiselect")&&0===e.length){var s=N(),r=i.a.uniq(s,!1,function(e){return e.value}).filter(function(e){var a=parseInt(e.value,10);return!n.find(function(e){return e.id===a})&&0!==a}).map(function(e){var a=parseInt(e.value,10),t=e.dataset,n=t.avatarUrl,s=t.avatar_url,r=t.name,i=t.username;return{avatar_url:n||s,id:a,name:r,username:i}});n=a.concat(r)}var l=void 0,u=void 0,o=void 0,c=void 0,f=void 0,m=void 0;if(0===e.length){if(m=0,_)for(u=0,o=n.length;u<o;u+=1)if((f=n[u]).username===_){n.splice(u,1),n.unshift(f);break}if(j&&(m+=1,n.unshift({beforeDivider:!0,name:"Unassigned",id:0})),C&&(m+=1,!0===(c=C)&&(c="Any User"),l={beforeDivider:!0,name:c,id:null},n.unshift(l)),m&&n.splice(m,0,"divider"),d.hasClass("js-multiselect")){var v=A().filter(function(e){return 0!==e});if(v.length>0){d.data("dropdownHeader")&&(m+=1,n.splice(m,0,{header:d.data("dropdownHeader")}));var p=n.filter(function(e){return-1!==v.indexOf(e.id)}).sort(function(e,a){return e.name>a.name});n=n.filter(function(e){return-1===v.indexOf(e.id)}),p.forEach(function(e){m+=1,n.splice(m,0,e)}),n.splice(m+1,0,"divider")}}}t(n),I&&d.data("glDropdown").positionMenuAbove()},filterable:!0,filterRemote:!0,search:{fields:["name","username"]},selectable:!0,fieldName:d.data("fieldName"),toggleLabel:function(e,a,t){var n=t.filterInput.val();if(this.multiSelect&&""===n){var r=t.filteredFullData(),i=t.parseData.bind(t);this.processData(n,r,i)}return this.multiSelect?L(e,s()(a).hasClass("is-active")):e&&"id"in e&&s()(a).hasClass("is-active")?(d.find(".dropdown-toggle-text").removeClass("is-default"),e.text?e.text:e.name):(d.find(".dropdown-toggle-text").addClass("is-default"),w)},defaultLabel:w,hidden:function(e){d.hasClass("js-multiselect")&&emitSidebarEvent("sidebar.saveAssignees"),d.data("alwaysShowSelectbox")||(m.hide(),t=m.closest(".block"),(v=t.find(".value")).css("display",""))},multiSelect:d.hasClass("js-multiselect"),inputMeta:d.data("inputMeta"),clicked:function(e){var a,t,n,r,i=e.$el,l=e.e,u=e.isMarking,f=e.selectedObj;if(d.hasClass("js-multiselect")){var m=i.hasClass("is-active"),v=d.closest(".selectbox").find("input[name='"+d.data("fieldName")+"'][value!=0]");if(E(),f.beforeDivider&&"unassigned"===f.name.toLowerCase())v.each(function(e,a){parseInt(a.value,10),a.remove()}),emitSidebarEvent("sidebar.removeAllAssignees");else if(m){emitSidebarEvent("sidebar.addAssignee",f);var p=d.closest(".selectbox").find("input[name='"+d.data("fieldName")+"'][value=0]");p&&p.remove()}else 0===v.length&&this.addInput(d.data("fieldName"),0,{}),emitSidebarEvent("sidebar.removeAssignee",f);A().find(function(e){return e===gon.current_user_id})?s()(".assign-to-me-link").hide():s()(".assign-to-me-link").show()}if(a="projects:issues:index"===(n=s()("body").attr("data-page")),t=n==n&&"projects:merge_requests:index"===n,d.hasClass("js-filter-bulk-update")||d.hasClass("js-issuable-form-dropdown")){l.preventDefault();var g=f.id!==S;(S=g?f.id:k)===gon.current_user_id?s()(".assign-to-me-link").hide():s()(".assign-to-me-link").show()}else{if(i.closest(".add-issues-modal").length)o.a.store.filter[d.data("fieldName")]=f.id;else if(c)l.preventDefault(),c(f,u);else{if(d.hasClass("js-filter-submit")&&(a||t))return Issuable.filterResults(d.closest("form"));if(d.hasClass("js-filter-submit"))return d.closest("form").submit();if(!d.hasClass("js-multiselect"))return r=d.closest(".selectbox").find("input[name='"+d.data("fieldName")+"']").val(),h(r)}d.data("maxSelect")&&A().length===d.data("maxSelect")&&d.dropdown("toggle")}},id:function(e){return e.id},opened:function(e){var a=s()(e.currentTarget),t=A();function n(e){a.find('li[data-user-id="'+e+'"] .dropdown-menu-user-link').addClass("is-active")}d.hasClass("js-issue-board-sidebar")&&0===t.length&&this.addInput(d.data("fieldName"),0,{}),a.find(".is-active").removeClass("is-active"),t.length>0?A().forEach(function(e){return n(e)}):d.hasClass("js-issue-board-sidebar")?n(0):n(S)},updateLabel:d.data("dropdownTitle"),renderRow:function(e){var a,t,n;n=e.username?"@"+e.username:"",a=e.avatar_url?e.avatar_url:gon.default_avatar_url;var s=!1;if(this.multiSelect){s=A().find(function(a){return e.id===a});var r=this.fieldName;d.closest(".selectbox").find("input[name='"+r+"'][value='"+e.id+"']").length&&(s=!0)}else s=e.id===S;return t="",null!=e.beforeDivider?i.a.escape(e.name):t="<img src='"+a+"' class='avatar avatar-inline' width='32' />","\n            <li data-user-id="+e.id+">\n              <a href='#' class='dropdown-menu-user-link "+(!0===s?"is-active":"")+"'>\n                "+t+"\n                <strong class='dropdown-menu-user-full-name'>\n                  "+i.a.escape(e.name)+"\n                </strong>\n                "+(n?"<span class='dropdown-menu-user-username'>"+n+"</span>":"")+"\n              </a>\n            </li>\n          "}})})),s()(".ajax-users-select").each(function(e){return function(a,t){var n,r,i,l,u={};return u.skipLdap=s()(t).hasClass("skip_ldap"),u.projectId=s()(t).data("projectId"),u.groupId=s()(t).data("groupId"),u.showCurrentUser=s()(t).data("currentUser"),u.authorId=s()(t).data("authorId"),u.skipUsers=s()(t).data("skipUsers"),l=s()(t).data("nullUser"),r=s()(t).data("anyUser"),i=s()(t).data("emailUser"),n=s()(t).data("firstUser"),s()(t).select2({placeholder:"Search for a user",multiple:s()(t).hasClass("multiselect"),minimumInputLength:0,query:function(a){return e.users(a.term,u,function(e){var t,s,u,o,d,c,f,m,v;if(s={results:e},0===a.term.length){if(n)for(o=0,d=(v=s.results).length;o<d;o+=1)if((m=v[o]).username===n){s.results.splice(o,1),s.results.unshift(m);break}l&&(f={name:"Unassigned",id:0},s.results.unshift(f)),r&&(!0===(c=r)&&(c="Any User"),t={name:c,id:null},s.results.unshift(t))}if(i&&0===s.results.length&&a.term.match(/^[^@]+@[^@]+$/)){var p=a.term.trim();u={name:'Invite "'+a.term+'" by email',username:p,id:p,invite:!0},s.results.unshift(u)}return a.callback(s)})},initSelection:function(){var a;return a=1<=arguments.length?[].slice.call(arguments,0):[],e.initSelection.apply(e,a)},formatResult:function(){var a;return a=1<=arguments.length?[].slice.call(arguments,0):[],e.formatResult.apply(e,a)},formatSelection:function(){var a;return a=1<=arguments.length?[].slice.call(arguments,0):[],e.formatSelection.apply(e,a)},dropdownCssClass:"ajax-users-dropdown",escapeMarkup:function(e){return e}})}}(this))}window.emitSidebarEvent=window.emitSidebarEvent||s.a.noop,c.prototype.initSelection=function(e,a){var t;return"0"===(t=s()(e).val())?a({name:"Unassigned"}):""!==t?this.user(t,a):void 0},c.prototype.formatResult=function(e){var a;return a=e.avatar_url?e.avatar_url:gon.default_avatar_url,"<div class='user-result "+(e.username?void 0:"no-username")+"'> <div class='user-image'><img class='avatar avatar-inline s32' src='"+a+"'></div> <div class='user-name dropdown-menu-user-full-name'>"+i.a.escape(e.name)+"</div> <div class='user-username dropdown-menu-user-username'>"+(e.invite?"":"@"+i.a.escape(e.username))+"</div> </div>"},c.prototype.formatSelection=function(e){return i.a.escape(e.name)},c.prototype.user=function(e,a){return!!/^\d+$/.test(e)&&(t=(t=this.buildUrl(this.userPath)).replace(":id",e),l.a.get(t).then(function(e){var t=e.data;a(t)}));var t},c.prototype.users=function(e,a,t){var n=this.buildUrl(this.usersPath),s={search:e,active:!0,project_id:a.projectId||null,group_id:a.groupId||null,skip_ldap:a.skipLdap||null,todo_filter:a.todoFilter||null,todo_state_filter:a.todoStateFilter||null,current_user:a.showCurrentUser||null,author_id:a.authorId||null,skip_users:a.skipUsers||null};return l.a.get(n,{params:s}).then(function(e){var a=e.data;t(a)})},c.prototype.buildUrl=function(e){return null!=gon.relative_url_root&&(e=gon.relative_url_root.replace(/\/$/,"")+e),e},a.a=c}},[[1084,0,1]]]);
  //# sourceMappingURL=pages.import.fogbugz.new_user_map.fb9f2325.chunk.js.map