(function(){"use strict";(function(){var optionTemplate=_.template('<div>\n<% if (useAvatars && avatarHTML) { %>\n <%= avatarHTML %>\n<% } %>\n<% if (fullname) { %>\n <span class="title"><%- fullname %></span>\n <span class="description">(<%- username %>)</span>\n<% } else { %>\n <span class="title"><%- username %></span>\n<% } %>\n</div>');RB.RelatedUserSelectorView=Djblets.RelatedObjectSelectorView.extend({searchPlaceholderText:gettext("Search for users..."),initialize:function initialize(options){Djblets.RelatedObjectSelectorView.prototype.initialize.call(this,_.defaults({selectizeOptions:{searchField:["fullname","username"],sortField:[{field:"fullname"},{field:"username"}],valueField:"username"}},options));this._localSitePrefix=options.localSitePrefix||"";this._useAvatars=!!options.useAvatars},renderOption:function renderOption(item){return optionTemplate(_.extend({useAvatars:this._useAvatars},item))},loadOptions:function loadOptions(query,callback){var params={fullname:1,"only-fields":"avatar_html,fullname,id,username","only-links":"","render-avatars-at":"20"};if(query.length!==0){params.q=query}$.ajax({type:"GET",url:""+SITE_ROOT+this._localSitePrefix+"api/users/",data:params,success:function success(results){callback(results.users.map(function(u){return{avatarHTML:u.avatar_html[20],fullname:u.fullname,id:u.id,username:u.username}}))},error:function error(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}console.error("User query failed",args);callback()}})}})})();"use strict";(function(){var optionTemplate=_.template('<div>\n <span class="title"><%- name %></span>\n</div>');RB.RelatedRepoSelectorView=Djblets.RelatedObjectSelectorView.extend({searchPlaceholderText:gettext("Search for repositories..."),initialize:function initialize(options){Djblets.RelatedObjectSelectorView.prototype.initialize.call(this,_.defaults({selectizeOptions:{searchField:["name"],sortField:[{field:"name"}],valueField:"name"}},options));this._localSitePrefix=options.localSitePrefix||""},renderOption:function renderOption(item){return optionTemplate(item)},loadOptions:function loadOptions(query,callback){var params={"only-fields":"name,id"};if(query.length!==0){params.q=query}$.ajax({type:"GET",url:""+SITE_ROOT+this._localSitePrefix+"api/repositories/",data:params,success:function success(results){callback(results.repositories.map(function(u){return{name:u.name,id:u.id}}))},error:function error(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}console.error("Repository query failed",args);callback()}})}})})();"use strict";(function(){var optionTemplate=_.template('<div>\n <span class="title"><%- name %> : <%- display_name %></span>\n</div>');RB.RelatedGroupSelectorView=Djblets.RelatedObjectSelectorView.extend({searchPlaceholderText:gettext("Search for groups..."),initialize:function initialize(options){Djblets.RelatedObjectSelectorView.prototype.initialize.call(this,_.defaults({selectizeOptions:{searchField:["name","display_name"],sortField:[{field:"name"},{field:"display_name"}],valueField:"name"}},options));this._localSitePrefix=options.localSitePrefix||"";this._inviteOnly=options.inviteOnly},renderOption:function renderOption(item){return optionTemplate(item)},loadOptions:function loadOptions(query,callback){var _this=this;var params={"only-fields":"invite_only,name,display_name,id",displayname:1};if(query.length!==0){params.q=query}$.ajax({type:"GET",url:""+SITE_ROOT+this._localSitePrefix+"api/groups/",data:params,success:function success(results){if(_this._inviteOnly===true){results.groups=results.groups.filter(function(obj){return obj.invite_only})}callback(results.groups.map(function(u){return{name:u.name,display_name:u.display_name,id:u.id,invite_only:u.invite_only}}))},error:function error(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}console.error("Group query failed",args);callback()}})}})})()}).call(this);
