diff --git a/dist/index.html b/dist/index.html index e2a99b0..3775d87 100644 --- a/dist/index.html +++ b/dist/index.html @@ -9,8 +9,8 @@ - - + + - - + + + \ No newline at end of file diff --git a/dist/v-1454069705160/js/app.js b/dist/v-1454069705160/js/app.js deleted file mode 100644 index 7c7a4d0..0000000 --- a/dist/v-1454069705160/js/app.js +++ /dev/null @@ -1,23 +0,0 @@ -(function(){var configure,i18nInit,init,module,modules,pluginsWithModule,taiga;this.taiga=taiga={},this.taigaContribPlugins=this.taigaContribPlugins||window.taigaContribPlugins||[],taiga.generateHash=function(components){return null==components&&(components=[]),components=_.map(components,function(x){return JSON.stringify(x)}),hex_sha1(components.join(":"))},taiga.generateUniqueSessionIdentifier=function(){var date,randomNumber;return date=(new Date).getTime(),randomNumber=Math.floor(150994944*Math.random()),taiga.generateHash([date,randomNumber])},taiga.sessionId=taiga.generateUniqueSessionIdentifier(),configure=function($routeProvider,$locationProvider,$httpProvider,$provide,$tgEventsProvider,$compileProvider,$translateProvider,$translatePartialLoaderProvider,$animateProvider){var authHttpIntercept,decorators,defaultHeaders,loaderIntercept,originalWhen,preferedLangCode,userInfo,versionCheckHttpIntercept;return $animateProvider.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/),originalWhen=$routeProvider.when,$routeProvider.when=function(path,route){return route.resolve||(route.resolve={}),angular.extend(route.resolve,{languageLoad:["$q","$translate",function($q,$translate){var deferred;return deferred=$q.defer(),$translate().then(function(){return deferred.resolve()}),deferred.promise}]}),originalWhen.call($routeProvider,path,route)},$routeProvider.when("/",{templateUrl:"home/home.html",controller:"Home",controllerAs:"vm",loader:!0,title:"HOME.PAGE_TITLE",loader:!0,description:"HOME.PAGE_DESCRIPTION",joyride:"dashboard"}),$routeProvider.when("/discover",{templateUrl:"discover/discover-home/discover-home.html",controller:"DiscoverHome",controllerAs:"vm",title:"PROJECT.NAVIGATION.DISCOVER",loader:!0}),$routeProvider.when("/discover/search",{templateUrl:"discover/discover-search/discover-search.html",title:"PROJECT.NAVIGATION.DISCOVER",loader:!0,controller:"DiscoverSearch",controllerAs:"vm",reloadOnSearch:!1}),$routeProvider.when("/projects/",{templateUrl:"projects/listing/projects-listing.html",access:{requiresLogin:!0},title:"PROJECTS.PAGE_TITLE",description:"PROJECTS.PAGE_DESCRIPTION",loader:!0,controller:"ProjectsListing",controllerAs:"vm"}),$routeProvider.when("/project/:pslug/",{templateUrl:"projects/project/project.html",loader:!0,controller:"Project",controllerAs:"vm",section:"project-timeline"}),$routeProvider.when("/project/:pslug/search",{templateUrl:"search/search.html",reloadOnSearch:!1,section:"search",loader:!0}),$routeProvider.when("/project/:pslug/backlog",{templateUrl:"backlog/backlog.html",loader:!0,section:"backlog",joyride:"backlog"}),$routeProvider.when("/project/:pslug/kanban",{templateUrl:"kanban/kanban.html",loader:!0,section:"kanban",joyride:"kanban"}),$routeProvider.when("/project/:pslug/taskboard/:sslug",{templateUrl:"taskboard/taskboard.html",loader:!0,section:"backlog"}),$routeProvider.when("/project/:pslug/us/:usref",{templateUrl:"us/us-detail.html",loader:!0,section:"backlog-kanban"}),$routeProvider.when("/project/:pslug/task/:taskref",{templateUrl:"task/task-detail.html",loader:!0,section:"backlog-kanban"}),$routeProvider.when("/project/:pslug/wiki",{redirectTo:function(params){return"/project/"+params.pslug+"/wiki/home"}}),$routeProvider.when("/project/:pslug/wiki/:slug",{templateUrl:"wiki/wiki.html",loader:!0,section:"wiki"}),$routeProvider.when("/project/:pslug/team",{templateUrl:"team/team.html",loader:!0,section:"team"}),$routeProvider.when("/project/:pslug/issues",{templateUrl:"issue/issues.html",loader:!0,section:"issues"}),$routeProvider.when("/project/:pslug/issue/:issueref",{templateUrl:"issue/issues-detail.html",loader:!0,section:"issues"}),$routeProvider.when("/project/:pslug/admin/project-profile/details",{templateUrl:"admin/admin-project-profile.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/default-values",{templateUrl:"admin/admin-project-default-values.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/modules",{templateUrl:"admin/admin-project-modules.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/export",{templateUrl:"admin/admin-project-export.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/reports",{templateUrl:"admin/admin-project-reports.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/status",{templateUrl:"admin/admin-project-values-status.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/points",{templateUrl:"admin/admin-project-values-points.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/priorities",{templateUrl:"admin/admin-project-values-priorities.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/severities",{templateUrl:"admin/admin-project-values-severities.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/types",{templateUrl:"admin/admin-project-values-types.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/custom-fields",{templateUrl:"admin/admin-project-values-custom-fields.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/memberships",{templateUrl:"admin/admin-memberships.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/roles",{templateUrl:"admin/admin-roles.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/webhooks",{templateUrl:"admin/admin-third-parties-webhooks.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/github",{templateUrl:"admin/admin-third-parties-github.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/gitlab",{templateUrl:"admin/admin-third-parties-gitlab.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/bitbucket",{templateUrl:"admin/admin-third-parties-bitbucket.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/contrib/:plugin",{templateUrl:"contrib/main.html"}),$routeProvider.when("/user-settings/user-profile",{templateUrl:"user/user-profile.html"}),$routeProvider.when("/user-settings/user-change-password",{templateUrl:"user/user-change-password.html"}),$routeProvider.when("/user-settings/mail-notifications",{templateUrl:"user/mail-notifications.html"}),$routeProvider.when("/change-email/:email_token",{templateUrl:"user/change-email.html"}),$routeProvider.when("/cancel-account/:cancel_token",{templateUrl:"user/cancel-account.html"}),$routeProvider.when("/profile",{templateUrl:"profile/profile.html",loader:!0,access:{requiresLogin:!0},controller:"Profile",controllerAs:"vm"}),$routeProvider.when("/profile/:slug",{templateUrl:"profile/profile.html",loader:!0,controller:"Profile",controllerAs:"vm"}),$routeProvider.when("/login",{templateUrl:"auth/login.html",title:"LOGIN.PAGE_TITLE",description:"LOGIN.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/register",{templateUrl:"auth/register.html",title:"REGISTER.PAGE_TITLE",description:"REGISTER.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/forgot-password",{templateUrl:"auth/forgot-password.html",title:"FORGOT_PASSWORD.PAGE_TITLE",description:"FORGOT_PASSWORD.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/change-password/:token",{templateUrl:"auth/change-password-from-recovery.html",title:"CHANGE_PASSWORD.PAGE_TITLE",description:"CHANGE_PASSWORD.PAGE_TITLE",disableHeader:!0}),$routeProvider.when("/invitation/:token",{templateUrl:"auth/invitation.html",title:"INVITATION.PAGE_TITLE",description:"INVITATION.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/external-apps",{templateUrl:"external-apps/external-app.html",title:"EXTERNAL_APP.PAGE_TITLE",description:"EXTERNAL_APP.PAGE_DESCRIPTION",controller:"ExternalApp",controllerAs:"vm",disableHeader:!0,mobileViewport:!0}),$routeProvider.when("/error",{templateUrl:"error/error.html"}),$routeProvider.when("/not-found",{templateUrl:"error/not-found.html"}),$routeProvider.when("/permission-denied",{templateUrl:"error/permission-denied.html"}),$routeProvider.otherwise({redirectTo:"/not-found"}),$locationProvider.html5Mode({enabled:!0,requireBase:!1}),defaultHeaders={"Content-Type":"application/json","Accept-Language":window.taigaConfig.defaultLanguage||"en","X-Session-Id":taiga.sessionId},$httpProvider.defaults.headers["delete"]=defaultHeaders,$httpProvider.defaults.headers.patch=defaultHeaders,$httpProvider.defaults.headers.post=defaultHeaders,$httpProvider.defaults.headers.put=defaultHeaders,$httpProvider.defaults.headers.get={"X-Session-Id":taiga.sessionId},$httpProvider.useApplyAsync(!0),$tgEventsProvider.setSessionId(taiga.sessionId),authHttpIntercept=function($q,$location,$navUrls,$lightboxService){var httpResponseError;return httpResponseError=function(response){var nextUrl;return 0===response.status||-1===response.status&&!response.config.cancelable?($lightboxService.closeAll(),$location.path($navUrls.resolve("error")),$location.replace()):401===response.status&&-1===$location.url().indexOf("/login")&&(nextUrl=encodeURIComponent($location.url()),$location.url($navUrls.resolve("login")).search("next="+nextUrl)),$q.reject(response)},{responseError:httpResponseError}},$provide.factory("authHttpIntercept",["$q","$location","$tgNavUrls","lightboxService",authHttpIntercept]),$httpProvider.interceptors.push("authHttpIntercept"),loaderIntercept=function($q,loaderService){return{request:function(config){return loaderService.logRequest(),config},requestError:function(rejection){return loaderService.logResponse(),$q.reject(rejection)},responseError:function(rejection){return loaderService.logResponse(),$q.reject(rejection)},response:function(response){return loaderService.logResponse(),response}}},$provide.factory("loaderIntercept",["$q","tgLoader",loaderIntercept]),$httpProvider.interceptors.push("loaderIntercept"),versionCheckHttpIntercept=function($q){var httpResponseError;return httpResponseError=function(response){var $injector;return 400===response.status&&response.data.version&&($injector=angular.element("body").injector(),$injector.invoke(["$tgConfirm","$translate",function(_this){return function($confirm,$translate){var versionErrorMsg;return versionErrorMsg=$translate.instant("ERROR.VERSION_ERROR"),$confirm.notify("error",versionErrorMsg,null,1e4)}}(this)])),$q.reject(response)},{responseError:httpResponseError}},$provide.factory("versionCheckHttpIntercept",["$q",versionCheckHttpIntercept]),$httpProvider.interceptors.push("versionCheckHttpIntercept"),window.checksley.updateValidators({linewidth:function(val,width){var lines,valid;return lines=taiga.nl2br(val).split("
"),valid=_.every(lines,function(line){return line.lengthi;i++)if(i in this&&this[i]===item)return i;return-1},slice=[].slice,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;nl2br=function(_this){return function(str){var breakTag;return breakTag="
",(str+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")}}(this),bindMethods=function(_this){return function(object){var dependencies,methods;return dependencies=_.keys(object),methods=[],_.forIn(object,function(value,key){return indexOf.call(dependencies,key)<0?methods.push(key):void 0}),_.bindAll(object,methods)}}(this),bindOnce=function(_this){return function(scope,attr,continuation){var delBind,val;return val=scope.$eval(attr),void 0!==val?continuation(val):(delBind=null,delBind=scope.$watch(attr,function(val){return void 0!==val?(continuation(val),delBind?delBind():void 0):void 0}))}}(this),mixOf=function(){var Mixed,base,i,method,mixin,mixins,name,ref;for(base=arguments[0],mixins=2<=arguments.length?slice.call(arguments,1):[],Mixed=function(superClass){function Mixed(){return Mixed.__super__.constructor.apply(this,arguments)}return extend(Mixed,superClass),Mixed}(base),i=mixins.length-1;i>=0;i+=-1){mixin=mixins[i],ref=mixin.prototype;for(name in ref)method=ref[name],Mixed.prototype[name]=method}return Mixed},trim=function(data,char){return _.str.trim(data,char)},slugify=function(data){return _.str.slugify(data)},unslugify=function(data){return data?_.str.capitalize(data.replace(/-/g," ")):data},toggleText=function(element,texts){var nextTextPosition,text;return nextTextPosition=element.data("nextTextPosition"),(null==nextTextPosition||nextTextPosition>=texts.length)&&(nextTextPosition=0),text=texts[nextTextPosition],element.data("nextTextPosition",nextTextPosition+1),element.text(text)},groupBy=function(coll,pred){var i,item,len,result;for(result={},i=0,len=coll.length;len>i;i++)item=coll[i],result[pred(item)]=item;return result},timeout=function(wait,continuation){return window.setTimeout(continuation,wait)},cancelTimeout=function(timeoutVar){return window.clearTimeout(timeoutVar)},scopeDefer=function(scope,func){return _.defer(function(_this){return function(){return scope.$apply(func)}}(this))},toString=function(value){return _.isNumber(value)?value+"":_.isString(value)?value:_.isPlainObject(value)?JSON.stringify(value):_.isUndefined(value)?"":value.toString()},joinStr=function(str,coll){return _.str.join(str,coll)},debounce=function(wait,func){return _.debounce(func,wait,{leading:!0,trailing:!1})},debounceLeading=function(wait,func){return _.debounce(func,wait,{leading:!1,trailing:!0})},startswith=function(str1,str2){return _.str.startsWith(str1,str2)},truncate=function(str,maxLength,suffix){var out;return null==suffix&&(suffix="..."),"string"==typeof str||str instanceof String?(out=str.slice(0),out.length>maxLength&&(out=out.substring(0,maxLength+1),out=out.substring(0,Math.min(out.length,out.lastIndexOf(" "))),out+=suffix),out):str},sizeFormat=function(input,precision){var number,size,units;return null==precision&&(precision=1),isNaN(parseFloat(input))||!isFinite(input)?"-":0===input?"0 bytes":(units=["bytes","KB","MB","GB","TB","PB"],number=Math.floor(Math.log(input)/Math.log(1024)),number>5&&(number=5),size=(input/Math.pow(1024,number)).toFixed(precision),size+" "+units[number])},stripTags=function(str,exception){var pattern;return exception?(pattern=new RegExp("<(?!"+exception+"s*/?)[^>]+>","gi"),String(str).replace(pattern,"")):String(str).replace(/<\/?[^>]+>/g,"")},replaceTags=function(str,tags,replace){var pattern;return pattern=new RegExp("<("+tags+")>","gi"),str=str.replace(pattern,"<"+replace+">"),pattern=new RegExp("","gi"),str=str.replace(pattern,"")},defineImmutableProperty=function(_this){return function(obj,name,fn){return Object.defineProperty(obj,name,{get:function(){var fn_result;if(!_.isFunction(fn))throw"defineImmutableProperty third param must be a function";if(fn_result=fn(),fn_result&&_.isObject(fn_result)&&void 0===fn_result.size)throw"defineImmutableProperty must return immutable data";return fn_result}})}}(this),_.mixin({removeKeys:function(obj,keys){return _.chain([keys]).flatten().reduce(function(obj,key){return delete obj[key],obj},obj).value()},cartesianProduct:function(){return _.reduceRight(arguments,function(a,b){return _.flatten(_.map(a,function(x){return _.map(b,function(y){return[y].concat(x)})}),!0)},[[]])}}),isImage=function(name){return null!==name.match(/\.(jpe?g|png|gif|gifv|webm)/i)},patch=function(oldImmutable,newImmutable){var pathObj;return pathObj={},newImmutable.forEach(function(newValue,key){return newValue!==oldImmutable.get(key)?newValue.toJS?pathObj[key]=newValue.toJS():pathObj[key]=newValue:void 0}),pathObj},taiga=this.taiga,taiga.nl2br=nl2br,taiga.bindMethods=bindMethods,taiga.bindOnce=bindOnce,taiga.mixOf=mixOf,taiga.trim=trim,taiga.slugify=slugify,taiga.unslugify=unslugify,taiga.toggleText=toggleText,taiga.groupBy=groupBy,taiga.timeout=timeout,taiga.cancelTimeout=cancelTimeout,taiga.scopeDefer=scopeDefer,taiga.toString=toString,taiga.joinStr=joinStr,taiga.truncate=truncate,taiga.debounce=debounce,taiga.debounceLeading=debounceLeading,taiga.startswith=startswith,taiga.sizeFormat=sizeFormat,taiga.stripTags=stripTags,taiga.replaceTags=replaceTags,taiga.defineImmutableProperty=defineImmutableProperty,taiga.isImage=isImage,taiga.patch=patch}.call(this),function(){var FiltersMixin,PageMixin,groupBy,joinStr,taiga,toString,trim;taiga=this.taiga,groupBy=this.taiga.groupBy,joinStr=this.taiga.joinStr,trim=this.taiga.trim,toString=this.taiga.toString,PageMixin=function(){function PageMixin(){}return PageMixin.prototype.fillUsersAndRoles=function(users,roles){var activeUsers,computableRoles;return activeUsers=_.filter(users,function(_this){return function(user){return user.is_active}}(this)),this.scope.activeUsers=_.sortBy(activeUsers,"full_name_display"),this.scope.activeUsersById=groupBy(this.scope.activeUsers,function(e){return e.id}),this.scope.users=_.sortBy(users,"full_name_display"),this.scope.usersById=groupBy(this.scope.users,function(e){return e.id}),this.scope.roles=_.sortBy(roles,"order"),computableRoles=_(this.scope.project.members).map("role").uniq().value(),this.scope.computableRoles=_(roles).filter("computable").filter(function(x){return _.contains(computableRoles,x.id)}).value()},PageMixin.prototype.loadUsersAndRoles=function(){var promise;return promise=this.q.all([this.rs.projects.usersList(this.scope.projectId),this.rs.projects.rolesList(this.scope.projectId)]),promise.then(function(_this){return function(results){var roles,users;return users=results[0],roles=results[1],_this.fillUsersAndRoles(users,roles),results}}(this))},PageMixin}(),taiga.PageMixin=PageMixin,FiltersMixin=function(){function FiltersMixin(){}return FiltersMixin.prototype.selectFilter=function(name,value,load){var existing,location,params;return null==load&&(load=!1),params=this.location.search(),void 0!==params[name]&&"page"!==name&&(existing=_.map(taiga.toString(params[name]).split(","),function(x){return trim(x)}),existing.push(taiga.toString(value)),existing=_.compact(existing),value=joinStr(",",_.uniq(existing))),this.location.isInCurrentRouteParams(name,value)?void 0:(location=load?this.location:this.location.noreload(this.scope),location.search(name,value))},FiltersMixin.prototype.replaceFilter=function(name,value,load){var location;return null==load&&(load=!1),this.location.isInCurrentRouteParams(name,value)?void 0:(location=load?this.location:this.location.noreload(this.scope),location.search(name,value))},FiltersMixin.prototype.replaceAllFilters=function(filters,load){var location;return null==load&&(load=!1),location=load?this.location:this.location.noreload(this.scope),location.search(filters)},FiltersMixin.prototype.unselectFilter=function(name,value,load){var location,newValues,params,parsedValues;return null==load&&(load=!1),params=this.location.search(),void 0!==params[name]?((void 0===value||null===value)&&delete params[name],parsedValues=_.map(taiga.toString(params[name]).split(","),function(x){return trim(x)}),newValues=_.reject(parsedValues,function(x){return x===taiga.toString(value)}),newValues=_.compact(newValues),value=_.isEmpty(newValues)?null:joinStr(",",_.uniq(newValues)),location=load?this.location:this.location.noreload(this.scope),location.search(name,value)):void 0},FiltersMixin}(),taiga.FiltersMixin=FiltersMixin}.call(this),function(){var module;module=angular.module("taigaAdmin",[])}.call(this),function(){var AuthService,CancelAccountDirective,ChangeEmailDirective,ChangePasswordFromRecoveryDirective,ForgotPasswordDirective,InvitationDirective,LoginDirective,PublicRegisterMessageDirective,RegisterDirective,debounce,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,debounce=this.taiga.debounce,module=angular.module("taigaAuth",["taigaResources"]),AuthService=function(superClass){function AuthService(rootscope,storage,model,rs,http,urls,config,translate,currentUserService,themeService){var userModel;this.rootscope=rootscope,this.storage=storage,this.model=model,this.rs=rs,this.http=http,this.urls=urls,this.config=config,this.translate=translate,this.currentUserService=currentUserService,this.themeService=themeService,AuthService.__super__.constructor.call(this),userModel=this.getUser(),this._currentTheme=this._getUserTheme(),this.setUserdata(userModel)}return extend(AuthService,superClass),AuthService.$inject=["$rootScope","$tgStorage","$tgModel","$tgResources","$tgHttp","$tgUrls","$tgConfig","$translate","tgCurrentUserService","tgThemeService"],AuthService.prototype.setUserdata=function(userModel){return userModel?(this.userData=Immutable.fromJS(userModel.getAttrs()),this.currentUserService.setUser(this.userData)):this.userData=null},AuthService.prototype._getUserTheme=function(){var ref;return(null!=(ref=this.rootscope.user)?ref.theme:void 0)||this.config.get("defaultTheme")||"taiga"},AuthService.prototype._setTheme=function(){var newTheme;return newTheme=this._getUserTheme(),this._currentTheme!==newTheme?(this._currentTheme=newTheme,this.themeService.use(this._currentTheme)):void 0},AuthService.prototype._setLocales=function(){var lang,ref;return lang=(null!=(ref=this.rootscope.user)?ref.lang:void 0)||this.config.get("defaultLanguage")||"en",this.translate.preferredLanguage(lang),this.translate.use(lang)},AuthService.prototype.getUser=function(){var user,userData;return this.rootscope.user?this.rootscope.user:(userData=this.storage.get("userInfo"))?(user=this.model.make_model("users",userData),this.rootscope.user=user,this._setLocales(),this._setTheme(),user):(this._setTheme(),null)},AuthService.prototype.setUser=function(user){return this.rootscope.auth=user,this.storage.set("userInfo",user.getAttrs()),this.rootscope.user=user,this.setUserdata(user),this._setLocales(),this._setTheme()},AuthService.prototype.clear=function(){return this.rootscope.auth=null,this.rootscope.user=null,this.storage.remove("userInfo")},AuthService.prototype.setToken=function(token){return this.storage.set("token",token)},AuthService.prototype.getToken=function(){return this.storage.get("token")},AuthService.prototype.removeToken=function(){return this.storage.remove("token")},AuthService.prototype.isAuthenticated=function(){return null!==this.getUser()?!0:!1},AuthService.prototype.login=function(data,type){var url;return url=this.urls.resolve("auth"),data=_.clone(data,!1),data.type=type?type:"normal",this.removeToken(),this.http.post(url,data).then(function(_this){return function(data,status){var user;return user=_this.model.make_model("users",data.data),_this.setToken(user.auth_token),_this.setUser(user),user}}(this))},AuthService.prototype.logout=function(){return this.removeToken(),this.clear(),this.currentUserService.removeUser(),this._setTheme(),this._setLocales()},AuthService.prototype.register=function(data,type,existing){var url;return url=this.urls.resolve("auth-register"),data=_.clone(data,!1),data.type=type?type:"public","private"===type&&(data.existing=existing?existing:!1),this.removeToken(),this.http.post(url,data).then(function(_this){return function(response){var user;return user=_this.model.make_model("users",response.data),_this.setToken(user.auth_token),_this.setUser(user),user}}(this))},AuthService.prototype.getInvitation=function(token){return this.rs.invitations.get(token)},AuthService.prototype.acceptInvitiationWithNewUser=function(data){return this.register(data,"private",!1)},AuthService.prototype.acceptInvitiationWithExistingUser=function(data){return this.register(data,"private",!0)},AuthService.prototype.forgotPassword=function(data){var url;return url=this.urls.resolve("users-password-recovery"),data=_.clone(data,!1),this.removeToken(),this.http.post(url,data)},AuthService.prototype.changePasswordFromRecovery=function(data){var url;return url=this.urls.resolve("users-change-password-from-recovery"),data=_.clone(data,!1),this.removeToken(),this.http.post(url,data)},AuthService.prototype.changeEmail=function(data){var url;return url=this.urls.resolve("users-change-email"),data=_.clone(data,!1),this.http.post(url,data)},AuthService.prototype.cancelAccount=function(data){var url;return url=this.urls.resolve("users-cancel-account"),data=_.clone(data,!1),this.http.post(url,data)},AuthService}(taiga.Service),module.service("$tgAuth",AuthService),PublicRegisterMessageDirective=function($config,$navUrls,$routeParams,templates){var template,templateFn;return template=templates.get("auth/login-text.html",!0),templateFn=function(){var nextUrl,publicRegisterEnabled,url;return(publicRegisterEnabled=$config.get("publicRegisterEnabled"))?(url=$navUrls.resolve("register"),$routeParams.next&&$routeParams.next!==$navUrls.resolve("register")&&(nextUrl=encodeURIComponent($routeParams.next),console.log("-----",nextUrl),url+="?next="+nextUrl),template({url:url})):""},{restrict:"AE",scope:{},template:templateFn}},module.directive("tgPublicRegisterMessage",["$tgConfig","$tgNavUrls","$routeParams","$tgTemplate",PublicRegisterMessageDirective]),LoginDirective=function($auth,$confirm,$location,$config,$routeParams,$navUrls,$events,$translate){var link;return link=function($scope,$el,$attrs){ -var form,onError,onSuccess,submit;return form=new checksley.Form($el.find("form.login-form")),$routeParams.next&&$routeParams.next!==$navUrls.resolve("login")?$scope.nextUrl=decodeURIComponent($routeParams.next):$scope.nextUrl=$navUrls.resolve("home"),onSuccess=function(response){return $events.setupConnection(),$location.url($scope.nextUrl)},onError=function(response){return $confirm.notify("light-error",$translate.instant("LOGIN_FORM.ERROR_AUTH_INCORRECT"))},submit=debounce(2e3,function(_this){return function(event){var data,loginFormType,promise;return event.preventDefault(),form.validate()?(data={username:$el.find("form.login-form input[name=username]").val(),password:$el.find("form.login-form input[name=password]").val()},loginFormType=$config.get("loginFormType","normal"),promise=$auth.login(data,loginFormType),promise.then(onSuccess,onError)):void 0}}(this)),$el.on("submit","form",submit),window.prerenderReady=!0,$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLogin",["$tgAuth","$tgConfirm","$tgLocation","$tgConfig","$routeParams","$tgNavUrls","$tgEvents","$translate",LoginDirective]),RegisterDirective=function($auth,$confirm,$location,$navUrls,$config,$routeParams,$analytics,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $config.get("publicRegisterEnabled")||($location.path($navUrls.resolve("not-found")),$location.replace()),$scope.data={},form=$el.find("form").checksley({onlyOneErrorElement:!0}),$routeParams.next&&$routeParams.next!==$navUrls.resolve("register")?$scope.nextUrl=decodeURIComponent($routeParams.next):$scope.nextUrl=$navUrls.resolve("home"),onSuccessSubmit=function(response){return $analytics.trackEvent("auth","register","user registration",1),$confirm.notify("success",$translate.instant("LOGIN_FORM.SUCCESS")),$location.url($scope.nextUrl)},onErrorSubmit=function(response){var text;return response.data._error_message&&(text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)),form.setErrors(response.data)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.register($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()}),window.prerenderReady=!0},{link:link}},module.directive("tgRegister",["$tgAuth","$tgConfirm","$tgLocation","$tgNavUrls","$tgConfig","$routeParams","$tgAnalytics","$translate",RegisterDirective]),ForgotPasswordDirective=function($auth,$confirm,$location,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $location.path($navUrls.resolve("login")),text=$translate.instant("FORGOT_PASSWORD_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("FORGOT_PASSWORD_FORM.ERROR"),$confirm.notify("light-error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.forgotPassword($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()}),window.prerenderReady=!0},{link:link}},module.directive("tgForgotPassword",["$tgAuth","$tgConfirm","$tgLocation","$tgNavUrls","$translate",ForgotPasswordDirective]),ChangePasswordFromRecoveryDirective=function($auth,$confirm,$location,$params,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit,text;return $scope.data={},null!=$params.token?($scope.tokenInParams=!0,$scope.data.token=$params.token):($location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.ERROR"),$confirm.notify("light-error",text)),form=$el.find("form").checksley(),onSuccessSubmit=function(response){return $location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){return text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.ERROR"),$confirm.notify("light-error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.changePasswordFromRecovery($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgChangePasswordFromRecovery",["$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$translate",ChangePasswordFromRecoveryDirective]),InvitationDirective=function($auth,$confirm,$location,$params,$navUrls,$analytics,$translate){var link;return link=function($scope,$el,$attrs){var loginForm,onErrorSubmitLogin,onErrorSubmitRegister,onSuccessSubmitLogin,onSuccessSubmitRegister,promise,registerForm,submitLogin,submitRegister,token;return token=$params.token,promise=$auth.getInvitation(token),promise.then(function(invitation){return $scope.invitation=invitation}),promise.then(null,function(response){var text;return $location.path($navUrls.resolve("login")),text=$translate.instant("INVITATION_LOGIN_FORM.NOT_FOUND"),$confirm.notify("light-error",text)}),$scope.dataLogin={token:token},loginForm=$el.find("form.login-form").checksley({onlyOneErrorElement:!0}),onSuccessSubmitLogin=function(response){var text;return $analytics.trackEvent("auth","invitationAccept","invitation accept with existing user",1),$location.path($navUrls.resolve("project",{project:$scope.invitation.project_slug})),text=$translate.instant("INVITATION_LOGIN_FORM.SUCCESS",{project_name:$scope.invitation.project_name}),$confirm.notify("success",text)},onErrorSubmitLogin=function(response){return $confirm.notify("light-error",response.data._error_message)},submitLogin=debounce(2e3,function(_this){return function(event){return event.preventDefault(),loginForm.validate()?(promise=$auth.acceptInvitiationWithExistingUser($scope.dataLogin),promise.then(onSuccessSubmitLogin,onErrorSubmitLogin)):void 0}}(this)),$el.on("submit","form.login-form",submitLogin),$el.on("click",".button-login",submitLogin),$scope.dataRegister={token:token},registerForm=$el.find("form.register-form").checksley({onlyOneErrorElement:!0}),onSuccessSubmitRegister=function(response){return $analytics.trackEvent("auth","invitationAccept","invitation accept with new user",1),$location.path($navUrls.resolve("project",{project:$scope.invitation.project_slug})),$confirm.notify("success","You've successfully joined this project","Welcome to "+_.escape($scope.invitation.project_name))},onErrorSubmitRegister=function(response){var text;return response.data._error_message&&(text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)),registerForm.setErrors(response.data)},submitRegister=debounce(2e3,function(_this){return function(event){return event.preventDefault(),registerForm.validate()?(promise=$auth.acceptInvitiationWithNewUser($scope.dataRegister),promise.then(onSuccessSubmitRegister,onErrorSubmitRegister)):void 0}}(this)),$el.on("submit","form.register-form",submitRegister),$el.on("click",".button-register",submitRegister),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgInvitation",["$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$tgAnalytics","$translate",InvitationDirective]),ChangeEmailDirective=function($repo,$model,$auth,$confirm,$location,$params,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},$scope.data.email_token=$params.email_token,form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $auth.isAuthenticated()?$repo.queryOne("users",$auth.getUser().id).then(function(_this){return function(data){return $auth.setUser(data),$location.path($navUrls.resolve("home"))}}(this)):$location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_EMAIL_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)},submit=function(){var promise;if(form.validate())return promise=$auth.changeEmail($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)},$el.on("submit",function(event){return event.preventDefault(),submit()}),$el.on("click","a.button-change-email",function(event){return event.preventDefault(),submit()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgChangeEmail",["$tgRepo","$tgModel","$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$translate",ChangeEmailDirective]),CancelAccountDirective=function($repo,$model,$auth,$confirm,$location,$params,$navUrls){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},$scope.data.cancel_token=$params.cancel_token,form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $auth.logout(),$location.path($navUrls.resolve("home")),text=$translate.instant("CANCEL_ACCOUNT.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.cancelAccount($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgCancelAccount",["$tgRepo","$tgModel","$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls",CancelAccountDirective])}.call(this),function(){var module;module=angular.module("taigaBacklog",[])}.call(this),function(){var TaigaMainDirective,bindOnce,groupBy,init,module,taiga,urls;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,module=angular.module("taigaBase",[]),TaigaMainDirective=function($rootscope,$window){var link;return link=function($scope,$el,$attrs){return $window.onresize=function(){return $rootscope.$broadcast("resize")}},{link:link}},module.directive("tgMain",["$rootScope","$window",TaigaMainDirective]),urls={home:"/",projects:"/projects",error:"/error","not-found":"/not-found","permission-denied":"/permission-denied",discover:"/discover","discover-search":"/discover/search",login:"/login","forgot-password":"/forgot-password","change-password":"/change-password/:token","change-email":"/change-email/:token","cancel-account":"/cancel-account/:token",register:"/register",invitation:"/invitation/:token","create-project":"/create-project",profile:"/profile","user-profile":"/profile/:username",project:"/project/:project","project-backlog":"/project/:project/backlog","project-taskboard":"/project/:project/taskboard/:sprint","project-kanban":"/project/:project/kanban","project-issues":"/project/:project/issues","project-search":"/project/:project/search","project-userstories-detail":"/project/:project/us/:ref","project-tasks-detail":"/project/:project/task/:ref","project-issues-detail":"/project/:project/issue/:ref","project-wiki":"/project/:project/wiki","project-wiki-page":"/project/:project/wiki/:slug","project-team":"/project/:project/team","project-admin-home":"/project/:project/admin/project-profile/details","project-admin-project-profile-details":"/project/:project/admin/project-profile/details","project-admin-project-profile-default-values":"/project/:project/admin/project-profile/default-values","project-admin-project-profile-modules":"/project/:project/admin/project-profile/modules","project-admin-project-profile-export":"/project/:project/admin/project-profile/export","project-admin-project-profile-reports":"/project/:project/admin/project-profile/reports","project-admin-project-values-status":"/project/:project/admin/project-values/status","project-admin-project-values-points":"/project/:project/admin/project-values/points","project-admin-project-values-priorities":"/project/:project/admin/project-values/priorities","project-admin-project-values-severities":"/project/:project/admin/project-values/severities","project-admin-project-values-types":"/project/:project/admin/project-values/types","project-admin-project-values-custom-fields":"/project/:project/admin/project-values/custom-fields","project-admin-memberships":"/project/:project/admin/memberships","project-admin-roles":"/project/:project/admin/roles","project-admin-third-parties-webhooks":"/project/:project/admin/third-parties/webhooks","project-admin-third-parties-github":"/project/:project/admin/third-parties/github","project-admin-third-parties-gitlab":"/project/:project/admin/third-parties/gitlab","project-admin-third-parties-bitbucket":"/project/:project/admin/third-parties/bitbucket","project-admin-contrib":"/project/:project/admin/contrib/:plugin","user-settings-user-profile":"/user-settings/user-profile","user-settings-user-change-password":"/user-settings/user-change-password","user-settings-user-avatar":"/user-settings/user-avatar","user-settings-mail-notifications":"/user-settings/mail-notifications"},init=function($log,$navurls){return $log.debug("Initialize navigation urls"),$navurls.update(urls)},module.run(["$log","$tgNavUrls",init])}.call(this),function(){var AnimationFrame,Capslock,CheckPermissionDirective,ClassPermissionDirective,DataPickerConfig,LimitLineLengthDirective,ProjectUrl,Qqueue,SelectedText,Template,ToggleCommentDirective,module,taiga,slice=[].slice;taiga=this.taiga,module=angular.module("taigaCommon",[]),DataPickerConfig=function($translate){return{get:function(){return{i18n:{previousMonth:$translate.instant("COMMON.PICKERDATE.PREV_MONTH"),nextMonth:$translate.instant("COMMON.PICKERDATE.NEXT_MONTH"),months:[$translate.instant("COMMON.PICKERDATE.MONTHS.JAN"),$translate.instant("COMMON.PICKERDATE.MONTHS.FEB"),$translate.instant("COMMON.PICKERDATE.MONTHS.MAR"),$translate.instant("COMMON.PICKERDATE.MONTHS.APR"),$translate.instant("COMMON.PICKERDATE.MONTHS.MAY"),$translate.instant("COMMON.PICKERDATE.MONTHS.JUN"),$translate.instant("COMMON.PICKERDATE.MONTHS.JUL"),$translate.instant("COMMON.PICKERDATE.MONTHS.AUG"),$translate.instant("COMMON.PICKERDATE.MONTHS.SEP"),$translate.instant("COMMON.PICKERDATE.MONTHS.OCT"),$translate.instant("COMMON.PICKERDATE.MONTHS.NOV"),$translate.instant("COMMON.PICKERDATE.MONTHS.DEC")],weekdays:[$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.SUN"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.MON"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.TUE"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.WED"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.THU"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.FRI"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.SAT")],weekdaysShort:[$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.SUN"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.MON"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.TUE"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.WED"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.THU"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.FRI"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.SAT")]},isRTL:"true"===$translate.instant("COMMON.PICKERDATE.IS_RTL"),firstDay:parseInt($translate.instant("COMMON.PICKERDATE.FIRST_DAY_OF_WEEK"),10),format:$translate.instant("COMMON.PICKERDATE.FORMAT")}}}},module.factory("tgDatePickerConfigService",["$translate",DataPickerConfig]),SelectedText=function($window,$document){var get;return get=function(){return $window.getSelection?$window.getSelection().toString():$document.selection?$document.selection.createRange().text:""},{get:get}},module.factory("$selectedText",["$window","$document",SelectedText]),CheckPermissionDirective=function(projectService){var link,render;return render=function($el,project,permission){return project&&permission&&project.get("my_permissions").indexOf(permission)>-1?$el.removeClass("hidden"):void 0},link=function($scope,$el,$attrs){var permission,unObserve,unwatch;return $el.addClass("hidden"),permission=$attrs.tgCheckPermission,unwatch=$scope.$watch(function(){return projectService.project},function(){return projectService.project?(render($el,projectService.project,permission),unwatch()):void 0}),unObserve=$attrs.$observe("tgCheckPermission",function(permission){return permission?(render($el,projectService.project,permission),unObserve()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},CheckPermissionDirective.$inject=["tgProjectService"],module.directive("tgCheckPermission",CheckPermissionDirective),ClassPermissionDirective=function(){var link,name;return name="tgClassPermission",link=function($scope,$el,$attrs){var checkPermissions,tgClassPermissionWatchAction,unbindWatcher;return checkPermissions=function(project,className,permission){var negation;return negation="!"===permission[0],negation&&(permission=permission.slice(1)),negation&&-1===project.my_permissions.indexOf(permission)?$el.addClass(className):negation||-1===project.my_permissions.indexOf(permission)?$el.removeClass(className):$el.addClass(className)},tgClassPermissionWatchAction=function(project){var className,classes,permission,results;if(project){unbindWatcher(),classes=$scope.$eval($attrs[name]),results=[];for(className in classes)permission=classes[className],results.push(checkPermissions(project,className,permission));return results}},unbindWatcher=$scope.$watch("project",tgClassPermissionWatchAction)},{link:link}},module.directive("tgClassPermission",ClassPermissionDirective),AnimationFrame=function(){var add,animationFrame,performAnimation,tail;return animationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,performAnimation=function(_this){return function(time){var fn;return fn=tail.shift(),fn(),tail.length?animationFrame(performAnimation):void 0}}(this),tail=[],add=function(){var fn,i,len,results;for(results=[],i=0,len=arguments.length;len>i;i++)fn=arguments[i],tail.push(fn),1===tail.length?results.push(animationFrame(performAnimation)):results.push(void 0);return results},{add:add}},module.factory("animationFrame",AnimationFrame),ToggleCommentDirective=function(){var link;return link=function($scope,$el,$attrs){return $el.find("textarea").on("focus",function(){return $el.addClass("active")})},{link:link}},module.directive("tgToggleComment",ToggleCommentDirective),ProjectUrl=function($navurls){var get;return get=function(project){var ctx;return ctx={project:project.slug},project.is_backlog_activated&&project.my_permissions.indexOf("view_us")>-1?$navurls.resolve("project-backlog",ctx):project.is_kanban_activated&&project.my_permissions.indexOf("view_us")>-1?$navurls.resolve("project-kanban",ctx):project.is_wiki_activated&&project.my_permissions.indexOf("view_wiki_pages")>-1?$navurls.resolve("project-wiki",ctx):project.is_issues_activated&&project.my_permissions.indexOf("view_issues")>-1?$navurls.resolve("project-issues",ctx):$navurls.resolve("project",ctx)},{get:get}},module.factory("$projectUrl",["$tgNavUrls",ProjectUrl]),LimitLineLengthDirective=function(){var link;return link=function($scope,$el,$attrs){var maxColsPerLine;return maxColsPerLine=parseInt($el.attr("cols")),$el.on("keyup",function(event){var code,lines;return code=event.keyCode,lines=$el.val().split("\n"),_.each(lines,function(line,index){return lines[index]=line.substring(0,maxColsPerLine-2)}),$el.val(lines.join("\n"))})},{link:link}},module.directive("tgLimitLineLength",LimitLineLengthDirective),Qqueue=function($q){var deferred,lastPromise,qqueue;return deferred=$q.defer(),deferred.resolve(),lastPromise=deferred.promise,qqueue={bindAdd:function(_this){return function(fn){return function(){var args;return args=1<=arguments.length?slice.call(arguments,0):[],lastPromise=lastPromise.then(function(){return fn.apply(_this,args)})}}}(this),add:function(_this){return function(fn){return lastPromise=lastPromise?lastPromise.then(fn):fn(),qqueue}}(this)}},module.factory("$tgQqueue",["$q",Qqueue]),Template=function($templateCache){return{get:function(_this){return function(name,lodash){var tmp;return null==lodash&&(lodash=!1),tmp=$templateCache.get(name),lodash&&(tmp=_.template(tmp)),tmp}}(this)}},module.factory("$tgTemplate",["$templateCache",Template]),Capslock=function($translate){var link;return link=function($scope,$el,$attrs){var hideIcon,open,showIcon,warningIcon;return open=!1,warningIcon=$("
").addClass("icon").addClass("icon-capslock").attr("title",$translate.instant("COMMON.CAPSLOCK_WARNING")),hideIcon=function(){return warningIcon.fadeOut(function(){return open=!1,$(this).remove()})},showIcon=function(e){var element;if(!open)return element=e.currentTarget,$(element).parent().append(warningIcon),$(".icon-capslock").fadeIn(),open=!0},$el.on("blur",function(e){return hideIcon()}),$el.on("keyup.capslock, focus",function(e){return $el.val()===$el.val().toLowerCase()?hideIcon(e):showIcon(e)}),$scope.$on("$destroy",function(){return $el.off(".capslock")})},{link:link}},module.directive("tgCapslock",["$translate",Capslock])}.call(this),function(){var EventsProvider,EventsService,bindMethods,module,startswith,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,startswith=this.taiga.startswith,bindMethods=this.taiga.bindMethods,module=angular.module("taigaEvents",[]),EventsService=function(){function EventsService(win,log,config,auth,liveAnnouncementService1,rootScope){this.win=win,this.log=log,this.config=config,this.auth=auth,this.liveAnnouncementService=liveAnnouncementService1,this.rootScope=rootScope,this.processMessage=bind(this.processMessage,this),bindMethods(this)}return EventsService.prototype.initialize=function(sessionId){return this.sessionId=sessionId,this.subscriptions={},this.connected=!1,this.error=!1,this.pendingMessages=[],this.missedHeartbeats=0,this.heartbeatInterval=null,void 0===this.win.WebSocket?this.log.info("WebSockets not supported on your browser"):void 0},EventsService.prototype.setupConnection=function(){var loc,path,scheme,url;return this.stopExistingConnection(),(url=this.config.get("eventsUrl"))?(startswith(url,"ws:")||startswith(url,"wss:")||(loc=this.win.location,scheme="https:"===loc.protocol?"wss:":"ws:",path=_.str.ltrim(url,"/"),url=scheme+"//"+loc.host+"/"+path),this.ws=new this.win.WebSocket(url),this.ws.addEventListener("open",this.onOpen),this.ws.addEventListener("message",this.onMessage),this.ws.addEventListener("error",this.onError),this.ws.addEventListener("close",this.onClose)):void 0},EventsService.prototype.stopExistingConnection=function(){return void 0!==this.ws?(this.ws.removeEventListener("open",this.onOpen),this.ws.removeEventListener("close",this.onClose),this.ws.removeEventListener("error",this.onError),this.ws.removeEventListener("message",this.onMessage),this.stopHeartBeatMessages(),this.ws.close(),delete this.ws):void 0},EventsService.prototype.notifications=function(){return this.subscribe(null,"notifications",function(_this){return function(data){return _this.liveAnnouncementService.show(data.title,data.desc),_this.rootScope.$digest()}}(this))},EventsService.prototype.startHeartBeatMessages=function(){var heartbeatIntervalTime,maxMissedHeartbeats;if(!this.heartbeatInterval)return maxMissedHeartbeats=this.config.get("eventsMaxMissedHeartbeats",5),heartbeatIntervalTime=this.config.get("eventsHeartbeatIntervalTime",6e4),this.missedHeartbeats=0,this.heartbeatInterval=setInterval(function(_this){return function(){var e,error1;try{if(_this.missedHeartbeats>=maxMissedHeartbeats)throw new Error("Too many missed heartbeats PINGs.");return _this.missedHeartbeats++,_this.sendMessage({cmd:"ping"}),_this.log.debug("HeartBeat send PING")}catch(error1){return e=error1,_this.log.error("HeartBeat error: "+e.message),_this.stopHeartBeatMessages()}}}(this),heartbeatIntervalTime),this.log.debug("HeartBeat enabled")},EventsService.prototype.stopHeartBeatMessages=function(){return this.heartbeatInterval?(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null,this.log.debug("HeartBeat disabled")):void 0},EventsService.prototype.processHeartBeatPongMessage=function(data){return this.missedHeartbeats=0,this.log.debug("HeartBeat recived PONG")},EventsService.prototype.serialize=function(message){return _.isObject(message)?JSON.stringify(message):message},EventsService.prototype.sendMessage=function(message){var i,len,messages,msg,results;if(this.pendingMessages.push(message),this.connected){for(messages=_.map(this.pendingMessages,this.serialize),this.pendingMessages=[],results=[],i=0,len=messages.length;len>i;i++)msg=messages[i],results.push(this.ws.send(msg));return results}},EventsService.prototype.processMessage=function(data){var routingKey,subscription;return routingKey=data.routing_key,null!=this.subscriptions[routingKey]?(subscription=this.subscriptions[routingKey],subscription.scope?subscription.scope.$apply(function(){return subscription.callback(data.data)}):subscription.callback(data.data)):void 0},EventsService.prototype.subscribe=function(scope,routingKey,callback){var message,subscription;if(!this.error)return this.log.debug("Subscribe to: "+routingKey),subscription={scope:scope,routingKey:routingKey,callback:_.debounce(callback,500,{leading:!0,trailing:!1})},message={cmd:"subscribe",routing_key:routingKey},this.subscriptions[routingKey]=subscription,this.sendMessage(message),scope?scope.$on("$destroy",function(_this){return function(){return _this.unsubscribe(routingKey)}}(this)):void 0},EventsService.prototype.unsubscribe=function(routingKey){var message;if(!this.error)return this.log.debug("Unsubscribe from: "+routingKey),message={cmd:"unsubscribe",routing_key:routingKey},this.sendMessage(message)},EventsService.prototype.onOpen=function(){var message,token;return this.connected=!0,this.startHeartBeatMessages(),this.notifications(),this.log.debug("WebSocket connection opened"),token=this.auth.getToken(),message={cmd:"auth",data:{token:token,sessionId:this.sessionId}},this.sendMessage(message)},EventsService.prototype.onMessage=function(event){var data;return this.log.debug("WebSocket message received: "+event.data),data=JSON.parse(event.data),"pong"===data.cmd?this.processHeartBeatPongMessage(data):this.processMessage(data)},EventsService.prototype.onError=function(error){return this.log.error("WebSocket error: "+error),this.error=!0},EventsService.prototype.onClose=function(){return this.log.debug("WebSocket closed."),this.connected=!1,this.stopHeartBeatMessages()},EventsService}(),EventsProvider=function(){function EventsProvider(){}return EventsProvider.prototype.setSessionId=function(sessionId){return this.sessionId=sessionId},EventsProvider.prototype.$get=function($win,$log,$conf,$auth,liveAnnouncementService,$rootScope){var service;return service=new EventsService($win,$log,$conf,$auth,liveAnnouncementService,$rootScope),service.initialize(this.sessionId),service},EventsProvider.prototype.$get.$inject=["$window","$log","$tgConfig","$tgAuth","tgLiveAnnouncementService","$rootScope"],EventsProvider}(),module.provider("$tgEvents",EventsProvider)}.call(this),function(){var FeedbackDirective,bindOnce,debounce,groupBy,mixOf,module,taiga,trim;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,mixOf=this.taiga.mixOf,debounce=this.taiga.debounce,trim=this.taiga.trim,module=angular.module("taigaFeedback",[]),FeedbackDirective=function($lightboxService,$repo,$confirm,$loading,feedbackService){var directive,link;return link=function($scope,$el,$attrs){var form,openLightbox,submit,submitButton;return form=$el.find("form").checksley(),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("feedback",$scope.feedback),promise.then(function(data){return currentLoading.finish(),$lightboxService.close($el),$confirm.notify("success","\\o/ we'll be happy to read your")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),openLightbox=function(){return $scope.feedback={},$lightboxService.open($el),$el.find("textarea").focus()},$scope.$on("$destroy",function(){return $el.off()}),openLightbox()},directive={link:link,templateUrl:"common/lightbox-feedback.html",scope:{}}},module.directive("tgLbFeedback",["lightboxService","$tgRepo","$tgConfirm","$tgLoading","tgFeedbackService",FeedbackDirective])}.call(this),function(){var module;module=angular.module("taigaIntegrations",[])}.call(this),function(){var module;module=angular.module("taigaIssues",[])}.call(this),function(){var module;module=angular.module("taigaKanban",[])}.call(this),function(){var module;module=angular.module("taigaPlugins",["ngRoute"])}.call(this),function(){var module;module=angular.module("taigaProject",[])}.call(this),function(){var RelatedTaskAssignedToInlineEditionDirective,RelatedTaskCreateButtonDirective,RelatedTaskCreateFormDirective,RelatedTaskRowDirective,RelatedTasksDirective,debounce,module,taiga,trim;taiga=this.taiga,trim=this.taiga.trim,debounce=this.taiga.debounce,module=angular.module("taigaRelatedTasks",[]),RelatedTaskRowDirective=function($repo,$compile,$confirm,$rootscope,$loading,$template,$translate){var link,templateEdit,templateView;return templateView=$template.get("task/related-task-row.html",!0),templateEdit=$template.get("task/related-task-row-edit.html",!0),link=function($scope,$el,$attrs,$model){var renderEdit,renderView,saveTask;return saveTask=debounce(2e3,function(task){var currentLoading,promise;return task.subject=$el.find("input").val(),currentLoading=$loading().target($el.find(".task-name")).start(),promise=$repo.save(task),promise.then(function(_this){return function(){return currentLoading.finish(),$rootscope.$broadcast("related-tasks:update")}}(this)),promise.then(null,function(_this){return function(){return currentLoading.finish(),$el.find("input").val(task.subject),$confirm.notify("error")}}(this)),promise}),renderEdit=function(task){return $el.html($compile(templateEdit({task:task}))($scope)),$el.on("keyup","input",function(event){return 13===event.keyCode?saveTask($model.$modelValue).then(function(){return renderView($model.$modelValue)}):27===event.keyCode?renderView($model.$modelValue):void 0}),$el.on("click",".icon-floppy",function(event){return saveTask($model.$modelValue).then(function(){return renderView($model.$modelValue)})}),$el.on("click",".cancel-edit",function(event){return renderView($model.$modelValue)})},renderView=function(task){var perms;return $el.off(),perms={modify_task:-1!==$scope.project.my_permissions.indexOf("modify_task"),delete_task:-1!==$scope.project.my_permissions.indexOf("delete_task")},$el.html($compile(templateView({task:task,perms:perms}))($scope)),$el.on("click",".icon-edit",function(){return renderEdit($model.$modelValue),$el.find("input").focus().select()}),$el.on("click",".delete-task",function(event){var message,title;return title=$translate.instant("TASK.TITLE_DELETE_ACTION"),task=$model.$modelValue,message=task.subject,$confirm.askOnDelete(title,message).then(function(askResponse){var promise;return promise=$repo.remove(task),promise.then(function(){return askResponse.finish(),$scope.$emit("related-tasks:delete")}),promise.then(null,function(){ -return askResponse.finish(!1),$confirm.notify("error")})})})},$scope.$watch($attrs.ngModel,function(val){return val?renderView(val):void 0}),$scope.$on("related-tasks:assigned-to-changed",function(){return $rootscope.$broadcast("related-tasks:update")}),$scope.$on("related-tasks:status-changed",function(){return $rootscope.$broadcast("related-tasks:update")}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgRelatedTaskRow",["$tgRepo","$compile","$tgConfirm","$rootScope","$tgLoading","$tgTemplate","$translate",RelatedTaskRowDirective]),RelatedTaskCreateFormDirective=function($repo,$compile,$confirm,$tgmodel,$loading,$analytics,$template){var link,newTask,template;return template=$template.get("task/related-task-create-form.html",!0),newTask={subject:"",assigned_to:null},link=function($scope,$el,$attrs){var close,createTask,render;return createTask=debounce(2e3,function(task){var currentLoading,promise;return task.subject=$el.find("input").val(),task.assigned_to=$scope.newTask.assigned_to,task.status=$scope.newTask.status,$scope.newTask.status=$scope.project.default_task_status,$scope.newTask.assigned_to=null,currentLoading=$loading().target($el.find(".task-name")).start(),promise=$repo.create("tasks",task),promise.then(function(){return $analytics.trackEvent("task","create","create task on userstory",1),currentLoading.finish(),$scope.$emit("related-tasks:add")}),promise.then(null,function(){return $el.find("input").val(task.subject),currentLoading.finish(),$confirm.notify("error")}),promise}),close=function(){return $el.off(),$el.html(""),$scope.newRelatedTaskFormOpen=!1},render=function(){return $scope.newRelatedTaskFormOpen=!0,$el.html($compile(template())($scope)),$el.find("input").focus().select(),$el.addClass("active"),$el.on("keyup","input",function(event){return 13===event.keyCode?createTask(newTask).then(function(){return render()}):27===event.keyCode?$scope.$apply(function(){return close()}):void 0}),$el.on("click",".icon-delete",function(event){return $scope.$apply(function(){return close()})}),$el.on("click",".icon-floppy",function(event){return createTask(newTask).then(function(){return close()})})},taiga.bindOnce($scope,"us",function(val){return newTask.status=$scope.project.default_task_status,newTask.project=$scope.project.id,newTask.user_story=$scope.us.id,$scope.newTask=$tgmodel.make_model("tasks",newTask),$el.html("")}),$scope.$on("related-tasks:show-form",function(){return render()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskCreateForm",["$tgRepo","$compile","$tgConfirm","$tgModel","$tgLoading","$tgAnalytics","$tgTemplate",RelatedTaskCreateFormDirective]),RelatedTaskCreateButtonDirective=function($repo,$compile,$confirm,$tgmodel,$template){var link,template;return template=$template.get("common/components/add-button.html",!0),link=function($scope,$el,$attrs){return $scope.$watch("project",function(val){return val?($el.off(),-1!==$scope.project.my_permissions.indexOf("add_task")?$el.html($compile(template())($scope)):$el.html(""),$el.on("click",".add-button",function(event){return $scope.$emit("related-tasks:add-new-clicked")})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskCreateButton",["$tgRepo","$compile","$tgConfirm","$tgModel","$tgTemplate",RelatedTaskCreateButtonDirective]),RelatedTasksDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){var loadTasks;return loadTasks=function(){return $rs.tasks.list($scope.projectId,null,$scope.usId).then(function(_this){return function(tasks){return $scope.tasks=_.sortBy(tasks,"ref"),tasks}}(this))},$scope.$on("related-tasks:add",function(){return loadTasks().then(function(){return $rootscope.$broadcast("related-tasks:update")})}),$scope.$on("related-tasks:delete",function(){return loadTasks().then(function(){return $rootscope.$broadcast("related-tasks:update")})}),$scope.$on("related-tasks:add-new-clicked",function(){return $scope.$broadcast("related-tasks:show-form")}),taiga.bindOnce($scope,"us",function(val){return loadTasks()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTasks",["$tgRepo","$tgResources","$rootScope",RelatedTasksDirective]),RelatedTaskAssignedToInlineEditionDirective=function($repo,$rootscope,$translate){var link,template;return template=_.template('<%- name %>\n
<%- name %>
'),link=function($scope,$el,$attrs){var $ctrl,autoSave,notAutoSave,task,updateRelatedTask;return updateRelatedTask=function(task){var ctx,member;return ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=$scope.usersById[task.assigned_to],member&&(ctx.imgurl=member.photo,ctx.name=member.full_name_display),$el.find(".avatar").html(template(ctx)),$el.find(".task-assignedto").attr("title",ctx.name)},$ctrl=$el.controller(),task=$scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition),notAutoSave=$scope.$eval($attrs.notAutoSave),autoSave=!notAutoSave,updateRelatedTask(task),$el.on("click",".task-assignedto",function(event){return $rootscope.$broadcast("assigned-to:add",task)}),taiga.bindOnce($scope,"project",function(project){return-1===project.my_permissions.indexOf("modify_task")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("assigned-to:added",debounce(2e3,function(_this){return function(ctx,userId,updatedRelatedTask){return updatedRelatedTask.id===task.id?(updatedRelatedTask.assigned_to=userId,autoSave&&$repo.save(updatedRelatedTask).then(function(){return $scope.$emit("related-tasks:assigned-to-changed")}),updateRelatedTask(updatedRelatedTask)):void 0}}(this))),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskAssignedToInlineEdition",["$tgRepo","$rootScope","$translate",RelatedTaskAssignedToInlineEditionDirective])}.call(this),function(){var ResourcesService,initResources,initUrls,module,taiga,urls,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ResourcesService=function(superClass){function ResourcesService(){return ResourcesService.__super__.constructor.apply(this,arguments)}return extend(ResourcesService,superClass),ResourcesService}(taiga.Service),urls={auth:"/auth","auth-register":"/auth/register",invitations:"/invitations",users:"/users",by_username:"/users/by_username","users-password-recovery":"/users/password_recovery","users-change-password-from-recovery":"/users/change_password_from_recovery","users-change-password":"/users/change_password","users-change-email":"/users/change_email","users-cancel-account":"/users/cancel","user-stats":"/users/%s/stats","user-liked":"/users/%s/liked","user-voted":"/users/%s/voted","user-watched":"/users/%s/watched","user-contacts":"/users/%s/contacts",permissions:"/permissions","notify-policies":"/notify-policies","user-storage":"/user-storage",memberships:"/memberships","bulk-create-memberships":"/memberships/bulk_create",roles:"/roles",permissions:"/permissions",resolver:"/resolver",projects:"/projects","project-templates":"/project-templates","project-modules":"/projects/%s/modules","bulk-update-projects-order":"/projects/bulk_update_order","project-like":"/projects/%s/like","project-unlike":"/projects/%s/unlike","project-watch":"/projects/%s/watch","project-unwatch":"/projects/%s/unwatch","userstory-statuses":"/userstory-statuses",points:"/points","task-statuses":"/task-statuses","issue-statuses":"/issue-statuses","issue-types":"/issue-types",priorities:"/priorities",severities:"/severities",milestones:"/milestones",userstories:"/userstories","bulk-create-us":"/userstories/bulk_create","bulk-update-us-backlog-order":"/userstories/bulk_update_backlog_order","bulk-update-us-sprint-order":"/userstories/bulk_update_sprint_order","bulk-update-us-kanban-order":"/userstories/bulk_update_kanban_order","userstories-filters":"/userstories/filters_data","userstory-upvote":"/userstories/%s/upvote","userstory-downvote":"/userstories/%s/downvote","userstory-watch":"/userstories/%s/watch","userstory-unwatch":"/userstories/%s/unwatch",tasks:"/tasks","bulk-create-tasks":"/tasks/bulk_create","bulk-update-task-taskboard-order":"/tasks/bulk_update_taskboard_order","task-upvote":"/tasks/%s/upvote","task-downvote":"/tasks/%s/downvote","task-watch":"/tasks/%s/watch","task-unwatch":"/tasks/%s/unwatch",issues:"/issues","bulk-create-issues":"/issues/bulk_create","issues-filters":"/issues/filters_data","issue-upvote":"/issues/%s/upvote","issue-downvote":"/issues/%s/downvote","issue-watch":"/issues/%s/watch","issue-unwatch":"/issues/%s/unwatch",wiki:"/wiki","wiki-restore":"/wiki/%s/restore","wiki-links":"/wiki-links","history/us":"/history/userstory","history/issue":"/history/issue","history/task":"/history/task","history/wiki":"/history/wiki","attachments/us":"/userstories/attachments","attachments/issue":"/issues/attachments","attachments/task":"/tasks/attachments","attachments/wiki_page":"/wiki/attachments","custom-attributes/userstory":"/userstory-custom-attributes","custom-attributes/issue":"/issue-custom-attributes","custom-attributes/task":"/task-custom-attributes","custom-attributes-values/userstory":"/userstories/custom-attributes-values","custom-attributes-values/issue":"/issues/custom-attributes-values","custom-attributes-values/task":"/tasks/custom-attributes-values",webhooks:"/webhooks","webhooks-test":"/webhooks/%s/test",webhooklogs:"/webhooklogs","webhooklogs-resend":"/webhooklogs/%s/resend","userstories-csv":"/userstories/csv?uuid=%s","tasks-csv":"/tasks/csv?uuid=%s","issues-csv":"/issues/csv?uuid=%s","timeline-profile":"/timeline/profile","timeline-user":"/timeline/user","timeline-project":"/timeline/project",search:"/search",exporter:"/exporter",importer:"/importer/load_dump",feedback:"/feedback",locales:"/locales",applications:"/applications","application-tokens":"/application-tokens","stats-discover":"/stats/discover"},initUrls=function($log,$urls){return $log.debug("Initialize api urls"),$urls.update(urls)},initResources=function($log,$rs){var i,len,provider,providers,results;for($log.debug("Initialize resources"),providers=_.toArray(arguments).slice(2),results=[],i=0,len=providers.length;len>i;i++)provider=providers[i],results.push(provider($rs));return results},module=angular.module("taigaResources",["taigaBase"]),module.service("$tgResources",ResourcesService),module.run(["$log","$tgUrls",initUrls]),module.run(["$log","$tgResources","$tgProjectsResourcesProvider","$tgCustomAttributesResourcesProvider","$tgCustomAttributesValuesResourcesProvider","$tgMembershipsResourcesProvider","$tgNotifyPoliciesResourcesProvider","$tgInvitationsResourcesProvider","$tgRolesResourcesProvider","$tgUserSettingsResourcesProvider","$tgSprintsResourcesProvider","$tgUserstoriesResourcesProvider","$tgTasksResourcesProvider","$tgIssuesResourcesProvider","$tgWikiResourcesProvider","$tgSearchResourcesProvider","$tgMdRenderResourcesProvider","$tgHistoryResourcesProvider","$tgKanbanResourcesProvider","$tgModulesResourcesProvider","$tgWebhooksResourcesProvider","$tgWebhookLogsResourcesProvider","$tgLocalesResourcesProvider","$tgUsersResourcesProvider",initResources])}.call(this),function(){var SearchBoxDirective,SearchController,SearchDirective,bindOnce,debounce,debounceLeading,groupBy,mixOf,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,mixOf=this.taiga.mixOf,debounceLeading=this.taiga.debounceLeading,trim=this.taiga.trim,debounce=this.taiga.debounce,module=angular.module("taigaSearch",[]),SearchController=function(superClass){function SearchController(scope1,repo,rs,params,q,location,appMetaService,navUrls,translate){var loadSearchData,promise;this.scope=scope1,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.translate=translate,this.scope.sectionName="Search",promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("SEARCH.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("SEARCH.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.searchTerm=null,loadSearchData=debounceLeading(100,function(_this){return function(t){return _this.loadSearchData(t)}}(this)),bindOnce(this.scope,"projectId",function(_this){return function(projectId){return!_this.scope.searchResults&&_this.scope.searchTerm?_this.loadSearchData():void 0}}(this)),this.scope.$watch("searchTerm",function(_this){return function(term){return void 0!==term&&_this.scope.projectId?_this.loadSearchData(term):void 0}}(this))}return extend(SearchController,superClass),SearchController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$translate"],SearchController.prototype.loadFilters=function(){var defered;return defered=this.q.defer(),defered.resolve(),defered.promise},SearchController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issueStatusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.taskStatusById=groupBy(project.task_statuses,function(x){return x.id}),_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),project}}(this))},SearchController.prototype.loadSearchData=function(term){return null==term&&(term=""),this.scope.loading=!0,this._loadSearchData(term).then(function(_this){return function(data){return _this.scope.searchResults=data,_this.scope.loading=!1}}(this))},SearchController.prototype._loadSearchData=function(term){return null==term&&(term=""),this._promise&&this._promise.abort(),this._promise=this.rs.search["do"](this.scope.projectId,term),this._promise},SearchController.prototype.loadInitialData=function(){return this.loadProject().then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.fillUsersAndRoles(project.members,project.roles)}}(this))},SearchController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("SearchController",SearchController),SearchBoxDirective=function(projectService,$lightboxService,$navurls,$location,$route){var link;return link=function($scope,$el,$attrs){var openLightbox,project,submit;return project=null,submit=debounce(2e3,function(_this){return function(event){var form,text,url;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(text=$el.find("#search-text").val(),url=$navurls.resolve("project-search",{project:project.get("slug")}),$scope.$apply(function(){return $lightboxService.close($el),$location.path(url),$location.search("text",text).path(url),$route.reload()})):void 0}}(this)),openLightbox=function(){return project=projectService.project,$lightboxService.open($el).then(function(){return $el.find("#search-text").focus()})},$el.on("submit","form",submit),openLightbox()},{templateUrl:"search/lightbox-search.html",link:link}},SearchBoxDirective.$inject=["tgProjectService","lightboxService","$tgNavUrls","$tgLocation","$route"],module.directive("tgSearchBox",SearchBoxDirective),SearchDirective=function($log,$compile,$templatecache,$routeparams,$location){var link,linkTable;return linkTable=function($scope,$el,$attrs,$ctrl){var activeSectionName,applyAutoTab,getActiveSection,lastSearchResults,markSectionTabActive,renderFilterTabs,renderTableContent,tabsDom,templates;return applyAutoTab=!0,activeSectionName="userstories",tabsDom=$el.find(".search-filter"),lastSearchResults=null,getActiveSection=function(data){var i,len,maxVal,name,ref,selectedSection,value;if(maxVal=0,selectedSection={},selectedSection.name="userstories",selectedSection.value=[],!applyAutoTab)return selectedSection.name=activeSectionName,selectedSection.value=data[activeSectionName],selectedSection;if(data)for(ref=["userstories","issues","tasks","wikipages"],i=0,len=ref.length;len>i;i++)if(name=ref[i],value=data[name],value.length>maxVal){maxVal=value.length,selectedSection.name=name,selectedSection.value=value;break}return 0===maxVal?selectedSection:selectedSection},renderFilterTabs=function(data){var name,results,value;results=[];for(name in data)value=data[name],tabsDom.find("li."+name).show(),results.push(tabsDom.find("li."+name+" .num").html(value.length));return results},markSectionTabActive=function(section){return tabsDom.find("a.active").removeClass("active"),tabsDom.find("li."+section.name+" a").addClass("active"),applyAutoTab=!1,activeSectionName=section.name},templates={issues:$templatecache.get("search-issues"),tasks:$templatecache.get("search-tasks"),userstories:$templatecache.get("search-userstories"),wikipages:$templatecache.get("search-wikipages")},renderTableContent=function(section){var element,oldElements,oldScope,scope,template;return oldElements=$el.find(".search-result-table").children(),oldScope=oldElements.scope(),oldScope&&(oldScope.$destroy(),oldElements.remove()),scope=$scope.$new(),scope[section.name]=section.value,template=angular.element.parseHTML(trim(templates[section.name])),element=$compile(template)(scope),$el.find(".search-result-table").html(element)},$scope.$watch("searchResults",function(data){var activeSection;return(lastSearchResults=data)?(activeSection=getActiveSection(data),renderFilterTabs(data),renderTableContent(activeSection),markSectionTabActive(activeSection)):void 0}),$scope.$watch("searchTerm",function(searchTerm){return void 0!==searchTerm?$location.search("text",searchTerm):void 0}),$el.on("click",".search-filter li > a",function(event){var section,sectionData,sectionName,target;return event.preventDefault(),target=angular.element(event.currentTarget),sectionName=target.parent().data("name"),sectionData=lastSearchResults?lastSearchResults[sectionName]:[],section={name:sectionName,value:sectionData},$scope.$apply(function(){return renderTableContent(section),markSectionTabActive(section)})})},link=function($scope,$el,$attrs){var $ctrl,searchText;return $ctrl=$el.controller(),linkTable($scope,$el,$attrs,$ctrl),searchText=$routeparams.text,$scope.$watch("projectId",function(projectId){return null!=projectId?$scope.searchTerm=searchText:void 0})},{link:link}},module.directive("tgSearch",["$log","$compile","$templateCache","$routeParams","$tgLocation",SearchDirective])}.call(this),function(){var module;module=angular.module("taigaTaskboard",[])}.call(this),function(){var module;module=angular.module("taigaTasks",[])}.call(this),function(){var module;module=angular.module("taigaTeam",[])}.call(this),function(){var module;module=angular.module("taigaUserSettings",[])}.call(this),function(){var module;module=angular.module("taigaUserStories",[])}.call(this),function(){var module;module=angular.module("taigaWiki",[])}.call(this),function(){var AnalyticsService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,module=angular.module("taigaCommon"),AnalyticsService=function(superClass){function AnalyticsService(rootscope,log,config,win,doc,location){var conf;this.rootscope=rootscope,this.log=log,this.config=config,this.win=win,this.doc=doc,this.location=location,this.initialized=!1,conf=this.config.get("analytics",{}),this.accountId=conf.accountId,this.pageEvent=conf.pageEvent||"$routeChangeSuccess",this.trackRoutes=conf.trackRoutes||!0,this.ignoreFirstPageLoad=conf.ignoreFirstPageLoad||!1}return extend(AnalyticsService,superClass),AnalyticsService.$inject=["$rootScope","$log","$tgConfig","$window","$document","$location"],AnalyticsService.prototype.initialize=function(){return this.accountId?(this.injectAnalytics(),this.win.ga("create",this.accountId,"auto"),this.win.ga("require","displayfeatures"),this.trackRoutes&&!this.ignoreFirstPageLoad&&this.win.ga("send","pageview",this.getUrl()),this.trackRoutes&&this.rootscope.$on(this.pageEvent,function(_this){return function(){return _this.trackPage(_this.getUrl(),"Taiga")}}(this)),this.initialized=!0):void this.log.debug("Analytics: no acount id provided. Disabling.")},AnalyticsService.prototype.getUrl=function(){return this.location.path()},AnalyticsService.prototype.injectAnalytics=function(){var fn;return(fn=function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r,i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date,a=s.createElement(o),m=s.getElementsByTagName(o)[0],a.async=1,a.src=g,m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga")},AnalyticsService.prototype.trackPage=function(url,title){return this.initialized&&this.win.ga?(title=title||this.doc[0].title,this.win.ga("send","pageview",{page:url,title:title})):void 0},AnalyticsService.prototype.trackEvent=function(category,action,label,value){return this.initialized&&this.win.ga?this.win.ga("send","event",category,action,label,value):void 0},AnalyticsService}(taiga.Service),module.service("$tgAnalytics",AnalyticsService)}.call(this),function(){var BindScope,module;module=angular.module("taigaCommon"),BindScope=function(config){var link;return config.debugInfo||(jQuery.fn.scope=function(){return this.data("scope")}),link=function($scope,$el){return config.debugInfo?void 0:$el.data("scope",$scope).addClass("tg-scope")},{link:link}},module.directive("tgBindScope",["$tgConfig",BindScope])}.call(this),function(){var CompileHtmlDirective;CompileHtmlDirective=function($compile){var link;return link=function(scope,element,attrs){return scope.$watch(attrs.tgCompileHtml,function(newValue,oldValue){return element.html(newValue),$compile(element.contents())(scope)})},{link:link}},CompileHtmlDirective.$inject=["$compile"],angular.module("taigaCommon").directive("tgCompileHtml",CompileHtmlDirective)}.call(this),function(){var AssignedToDirective,BlockButtonDirective,CreatedByDisplayDirective,DateRangeDirective,DateSelectorDirective,DeleteButtonDirective,EditableDescriptionDirective,EditableSubjectDirective,EditableWysiwyg,ListItemAssignedtoDirective,ListItemIssueStatusDirective,ListItemPriorityDirective,ListItemSeverityDirective,ListItemTaskStatusDirective,ListItemTypeDirective,ListItemUsStatusDirective,SprintProgressBarDirective,TgMainTitleDirective,TgProgressBarDirective,WatchersDirective,bindOnce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),DateRangeDirective=function($translate){var link,renderRange;return renderRange=function($el,first,second){var endDate,initDate,prettyDate;return prettyDate=$translate.instant("BACKLOG.SPRINTS.DATE"),initDate=moment(first).format(prettyDate),endDate=moment(second).format(prettyDate),$el.html(initDate+"-"+endDate)},link=function($scope,$el,$attrs){var first,ref,second;return ref=$attrs.tgDateRange.split(","),first=ref[0],second=ref[1],bindOnce($scope,first,function(valFirst){return bindOnce($scope,second,function(valSecond){return renderRange($el,valFirst,valSecond)})})},{link:link}},module.directive("tgDateRange",["$translate",DateRangeDirective]),DateSelectorDirective=function($rootscope,datePickerConfigService){var link;return link=function($scope,$el,$attrs,$model){var initialize,selectedDate,unbind;return selectedDate=null,initialize=function(){var datePickerConfig;return datePickerConfig=datePickerConfigService.get(),_.merge(datePickerConfig,{field:$el[0],onSelect:function(_this){return function(date){return selectedDate=date}}(this),onOpen:function(_this){return function(){return null!=selectedDate?$el.picker.setDate(selectedDate):void 0}}(this)}),$el.picker=new Pikaday(datePickerConfig)},unbind=$rootscope.$on("$translateChangeEnd",function(_this){return function(ctx){return initialize()}}(this)),$scope.$watch($attrs.ngModel,function(val){return null==val||$el.picker||initialize(),null!=val?$el.picker.setDate(val):void 0}),$scope.$on("$destroy",function(){return $el.off(),unbind()})},{link:link,require:"ngModel"}},module.directive("tgDateSelector",["$rootScope","tgDatePickerConfigService",DateSelectorDirective]),SprintProgressBarDirective=function(){var link,renderProgress;return renderProgress=function($el,percentage,visual_percentage){return $el.hasClass(".current-progress")?$el.css("width",percentage+"%"):($el.find(".current-progress").css("width",visual_percentage+"%"),$el.find(".number").html(percentage+" %"))},link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgSprintProgressbar,function(sprint){var closedPoints,percentage,totalPoints,visual_percentage;return closedPoints=sprint.closed_points,totalPoints=sprint.total_points,percentage=0,0!==totalPoints&&(percentage=Math.round(100*(closedPoints/totalPoints))),visual_percentage=0,0!==totalPoints&&(visual_percentage=Math.round(98*(closedPoints/totalPoints))),renderProgress($el,percentage,visual_percentage)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgSprintProgressbar",SprintProgressBarDirective),CreatedByDisplayDirective=function($template,$compile,$translate,$navUrls){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.ngModel,function(model){var ref;return null!=model?($scope.owner=model.owner_extra_info||{full_name_display:$translate.instant("COMMON.EXTERNAL_USER"),photo:"/"+window._version+"/images/user-noimage.png"},$scope.url=(null!=(ref=$scope.owner)?ref.is_active:void 0)?$navUrls.resolve("user-profile",{username:$scope.owner.username}):"",$scope.date=moment(model.created_date).format($translate.instant("COMMON.DATETIME"))):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",scope:!0,templateUrl:"common/components/created-by.html"}},module.directive("tgCreatedByDisplay",["$tgTemplate","$compile","$translate","$tgNavUrls",CreatedByDisplayDirective]),WatchersDirective=function($rootscope,$confirm,$repo,$qqueue,$template,$compile,$translate){var link,template;return template=$template.get("common/components/watchers.html",!0),link=function($scope,$el,$attrs,$model){var deleteWatcher,isEditable,renderWatchers,save;return isEditable=function(){var ref,ref1;return-1!==(null!=(ref=$scope.project)&&null!=(ref1=ref.my_permissions)?ref1.indexOf($attrs.requiredPerm):void 0)},save=$qqueue.bindAdd(function(_this){return function(watchers){var item,promise;return item=$model.$modelValue.clone(),item.watchers=watchers,$model.$setViewValue(item),promise=$repo.save($model.$modelValue),promise.then(function(){return watchers=_.map(watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $model.$modelValue.revert(),$confirm.notify("error")})}}(this)),deleteWatcher=$qqueue.bindAdd(function(_this){return function(watcherIds){var item,promise;return item=$model.$modelValue.clone(),item.watchers=watcherIds,$model.$setViewValue(item),promise=$repo.save($model.$modelValue),promise.then(function(){var watchers;return watchers=_.map(item.watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return item.revert(),$confirm.notify("error")})}}(this)),renderWatchers=function(watchers){var ctx,html;return ctx={watchers:watchers,isEditable:isEditable()},html=$compile(template(ctx))($scope),$el.html(html)},$el.on("click",".js-delete-watcher",function(event){var message,target,title,watcherId;return event.preventDefault(),isEditable()?(target=angular.element(event.currentTarget),watcherId=target.data("watcher-id"),title=$translate.instant("COMMON.WATCHERS.TITLE_LIGHTBOX_DELETE_WARTCHER"),message=$scope.usersById[watcherId].full_name_display,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var watcherIds;return askResponse.finish(),watcherIds=_.clone($model.$modelValue.watchers,!1),watcherIds=_.pull(watcherIds,watcherId),deleteWatcher(watcherIds)}}(this))):void 0}),$scope.$on("watcher:added",function(ctx,watcherId){var watchers;return watchers=_.clone($model.$modelValue.watchers,!1),watchers.push(watcherId),watchers=_.uniq(watchers),save(watchers)}),$scope.$watch($attrs.ngModel,function(item){var watchers;if(null!=item)return watchers=_.map(item.watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgWatchers",["$rootScope","$tgConfirm","$tgRepo","$tgQqueue","$tgTemplate","$compile","$translate",WatchersDirective]),AssignedToDirective=function($rootscope,$confirm,$repo,$loading,$qqueue,$template,$translate,$compile,$currentUserService){var link,template;return template=$template.get("common/components/assigned-to.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,renderAssignedTo,save;return isEditable=function(){var ref,ref1;return-1!==(null!=(ref=$scope.project)&&null!=(ref1=ref.my_permissions)?ref1.indexOf($attrs.requiredPerm):void 0)},save=$qqueue.bindAdd(function(_this){return function(userId){var currentLoading,promise;return $model.$modelValue.assigned_to=userId,currentLoading=$loading().target($el).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return currentLoading.finish(),renderAssignedTo($model.$modelValue),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $model.$modelValue.revert(),$confirm.notify("error"),currentLoading.finish()}),promise}}(this)),renderAssignedTo=function(assignedObject){var ctx,fullName,html,isIocaine,isUnassigned,photo;return null!=(null!=assignedObject?assignedObject.assigned_to:void 0)?(fullName=assignedObject.assigned_to_extra_info.full_name_display,photo=assignedObject.assigned_to_extra_info.photo,isUnassigned=!1):(fullName=$translate.instant("COMMON.ASSIGNED_TO.ASSIGN"),photo="/"+window._version+"/images/unnamed.png",isUnassigned=!0),isIocaine=null!=assignedObject?assignedObject.is_iocaine:void 0,ctx={fullName:fullName,photo:photo,isUnassigned:isUnassigned,isEditable:isEditable(),isIocaine:isIocaine},html=$compile(template(ctx))($scope),$el.html(html)},$el.on("click",".user-assigned",function(event){return event.preventDefault(),isEditable()?$scope.$apply(function(){return $rootscope.$broadcast("assigned-to:add",$model.$modelValue)}):void 0}),$el.on("click",".assign-to-me",function(event){return event.preventDefault(),isEditable()?($model.$modelValue.assigned_to=$currentUserService.getUser().get("id"),save($currentUserService.getUser().get("id"))):void 0}),$el.on("click",".icon-delete",function(event){var title;return event.preventDefault(),isEditable()?(title=$translate.instant("COMMON.ASSIGNED_TO.CONFIRM_UNASSIGNED"),$confirm.ask(title).then(function(_this){return function(response){ -return response.finish(),$model.$modelValue.assigned_to=null,save(null)}}(this))):void 0}),$scope.$on("assigned-to:added",function(ctx,userId,item){return item.id===$model.$modelValue.id?save(userId):void 0}),$scope.$watch($attrs.ngModel,function(instance){return renderAssignedTo(instance)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgAssignedTo",["$rootScope","$tgConfirm","$tgRepo","$tgLoading","$tgQqueue","$tgTemplate","$translate","$compile","tgCurrentUserService",AssignedToDirective]),BlockButtonDirective=function($rootscope,$loading,$template){var link,template;return template=$template.get("common/components/block-button.html"),link=function($scope,$el,$attrs,$model){var isEditable;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},$scope.$watch($attrs.ngModel,function(item){return item?(isEditable()&&$el.find(".item-block").addClass("editable"),item.is_blocked?($el.find(".item-block").removeClass("is-active"),$el.find(".item-unblock").addClass("is-active")):($el.find(".item-block").addClass("is-active"),$el.find(".item-unblock").removeClass("is-active"))):void 0}),$el.on("click",".item-block",function(event){return event.preventDefault(),$rootscope.$broadcast("block",$model.$modelValue)}),$el.on("click",".item-unblock",function(event){var currentLoading,finish;return event.preventDefault(),currentLoading=$loading().target($el.find(".item-unblock")).start(),finish=function(){return currentLoading.finish()},$rootscope.$broadcast("unblock",$model.$modelValue,finish)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgBlockButton",["$rootScope","$tgLoading","$tgTemplate",BlockButtonDirective]),DeleteButtonDirective=function($log,$repo,$confirm,$location,$template){var link,template;return template=$template.get("common/components/delete-button.html"),link=function($scope,$el,$attrs,$model){return $attrs.onDeleteGoToUrl?$attrs.onDeleteTitle?($el.on("click",".button-delete",function(event){var subtitle,title;return title=$attrs.onDeleteTitle,subtitle=$model.$modelValue.subject,$confirm.askOnDelete(title,subtitle).then(function(_this){return function(askResponse){var promise;return promise=$repo.remove($model.$modelValue),promise.then(function(){var url;return askResponse.finish(),url=$scope.$eval($attrs.onDeleteGoToUrl),$location.path(url)}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})}}(this))}),$scope.$on("$destroy",function(){return $el.off()})):$log.error("DeleteButtonDirective requires on-delete-title set in scope."):$log.error("DeleteButtonDirective requires on-delete-go-to-url set in scope.")},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgDeleteButton",["$log","$tgRepo","$tgConfirm","$tgLocation","$tgTemplate",DeleteButtonDirective]),EditableSubjectDirective=function($rootscope,$repo,$confirm,$loading,$qqueue,$template){var link,template;return template=$template.get("common/components/editable-subject.html"),link=function($scope,$el,$attrs,$model){var isEditable,save;return $scope.$on("object:updated",function(){return $el.find(".edit-subject").hide(),$el.find(".view-subject").show()}),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm)},save=$qqueue.bindAdd(function(_this){return function(subject){var currentLoading,promise;return $model.$modelValue.subject=subject,currentLoading=$loading().target($el.find(".save-container")).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$el.find(".edit-subject").hide(),$el.find(".view-subject").show()}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()}),promise}}(this)),$el.click(function(){return isEditable()?($el.find(".edit-subject").show(),$el.find(".view-subject").hide(),$el.find("input").focus()):void 0}),$el.on("click",".save",function(e){var subject;return e.preventDefault(),subject=$scope.item.subject,save(subject)}),$el.on("keyup","input",function(event){var subject;return 13===event.keyCode?(subject=$scope.item.subject,save(subject)):27===event.keyCode?($scope.$apply(function(_this){return function(){return $model.$modelValue.revert()}}(this)),$el.find("div.edit-subject").hide(),$el.find("div.view-subject").show()):void 0}),$el.find("div.edit-subject").hide(),$el.find("div.view-subject span.edit").hide(),$scope.$watch($attrs.ngModel,function(value){return value?($scope.item=value,isEditable()?void 0:$el.find(".view-subject .edit").remove()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgEditableSubject",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate",EditableSubjectDirective]),EditableDescriptionDirective=function($rootscope,$repo,$confirm,$compile,$loading,$selectedText,$qqueue,$template){var link,noDescriptionMegEditMode,noDescriptionMegReadMode,template;return template=$template.get("common/components/editable-description.html"),noDescriptionMegEditMode=$template.get("common/components/editable-description-msg-edit-mode.html"),noDescriptionMegReadMode=$template.get("common/components/editable-description-msg-read-mode.html"),link=function($scope,$el,$attrs,$model){var isEditable,save;return $el.find(".edit-description").hide(),$el.find(".view-description .edit").hide(),$scope.$on("object:updated",function(){return $el.find(".edit-description").hide(),$el.find(".view-description").show()}),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm)},save=$qqueue.bindAdd(function(_this){return function(description){var currentLoading,promise;return $model.$modelValue.description=description,currentLoading=$loading().target($el.find(".save-container")).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$el.find(".edit-description").hide(),$el.find(".view-description").show()}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()})}}(this)),$el.on("mouseup",".view-description",function(event){var target;return target=angular.element(event.target),!isEditable()||target.is("a")||$selectedText.get().length?void 0:($el.find(".edit-description").show(),$el.find(".view-description").hide(),$el.find("textarea").focus())}),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("click",".save",function(e){var description;return e.preventDefault(),description=$scope.item.description,save(description)}),$el.on("keydown","textarea",function(event){return 27===event.keyCode?($scope.$apply(function(_this){return function(){return $scope.item.revert()}}(this)),$el.find(".edit-description").hide(),$el.find(".view-description").show()):void 0}),$scope.$watch($attrs.ngModel,function(value){return value?($scope.item=value,isEditable()?($el.find(".view-description .edit").show(),$el.find(".view-description .us-content").addClass("editable"),$scope.noDescriptionMsg=$compile(noDescriptionMegEditMode)($scope)):$scope.noDescriptionMsg=$compile(noDescriptionMegReadMode)($scope)):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgEditableDescription",["$rootScope","$tgRepo","$tgConfirm","$compile","$tgLoading","$selectedText","$tgQqueue","$tgTemplate",EditableDescriptionDirective]),EditableWysiwyg=function(attachmentsService,attachmentsFullService){var link;return link=function($scope,$el,$attrs,$model){var isInEditMode,uploadFile;return isInEditMode=function(){return $el.find("textarea").is(":visible")},uploadFile=function(file,type){return attachmentsService.validate(file)?attachmentsFullService.addAttachment($model.$modelValue.project,$model.$modelValue.id,type,file).then(function(result){return taiga.isImage(result.getIn(["file","name"]))?"!["+result.getIn(["file","name"])+"]("+result.getIn(["file","url"])+")":"["+result.getIn(["file","name"])+"]("+result.getIn(["file","url"])+")"}):void 0},$el.on("dragover",function(e){var textarea;return textarea=$el.find("textarea").focus(),!1}),$el.on("drop",function(e){var dataTransfer,promises,textarea,type;return e.stopPropagation(),e.preventDefault(),isInEditMode()?(dataTransfer=e.dataTransfer||e.originalEvent&&e.originalEvent.dataTransfer,textarea=$el.find("textarea"),textarea.addClass("in-progress"),type=$model.$modelValue._name,"userstories"===type?type="us":"tasks"===type?type="task":"issues"===type?type="issue":"wiki"===type&&(type="wiki_page"),promises=_.map(dataTransfer.files,function(file){return uploadFile(file,type)}),Promise.all(promises).then(function(result){return textarea=$el.find("textarea"),$.markItUp({replaceWith:result.join(" ")}),textarea.removeClass("in-progress")})):void 0})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgEditableWysiwyg",["tgAttachmentsService","tgAttachmentsFullService",EditableWysiwyg]),ListItemUsStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var us;return us=$scope.$eval($attrs.tgListitemUsStatus),bindOnce($scope,"usStatusById",function(usStatusById){return $el.html(usStatusById[us.status].name)})},{link:link}},module.directive("tgListitemUsStatus",ListItemUsStatusDirective),ListItemTaskStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var task;return task=$scope.$eval($attrs.tgListitemTaskStatus),bindOnce($scope,"taskStatusById",function(taskStatusById){return $el.html(taskStatusById[task.status].name)})},{link:link}},module.directive("tgListitemTaskStatus",ListItemTaskStatusDirective),ListItemAssignedtoDirective=function($template,$translate){var link,template;return template=$template.get("common/components/list-item-assigned-to-avatar.html",!0),link=function($scope,$el,$attrs){return bindOnce($scope,"usersById",function(usersById){var ctx,item,member;return item=$scope.$eval($attrs.tgListitemAssignedto),ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=usersById[item.assigned_to],member&&(ctx.imgurl=member.photo,ctx.name=member.full_name_display),$el.html(template(ctx))})},{link:link}},module.directive("tgListitemAssignedto",["$tgTemplate","$translate",ListItemAssignedtoDirective]),ListItemIssueStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var issue;return issue=$scope.$eval($attrs.tgListitemIssueStatus),bindOnce($scope,"issueStatusById",function(issueStatusById){return $el.html(issueStatusById[issue.status].name)})},{link:link}},module.directive("tgListitemIssueStatus",ListItemIssueStatusDirective),ListItemTypeDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(issueTypeById,issue){var domNode,type;return type=issueTypeById[issue.type],domNode=$el.find(".level"),domNode.css("background-color",type.color),domNode.attr("title",type.name)},bindOnce($scope,"issueTypeById",function(issueTypeById){var issue;return issue=$scope.$eval($attrs.tgListitemType),render(issueTypeById,issue)}),$scope.$watch($attrs.tgListitemType,function(issue){return render($scope.issueTypeById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemType",ListItemTypeDirective),ListItemPriorityDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(priorityById,issue){var domNode,priority;return priority=priorityById[issue.priority],domNode=$el.find(".level"),domNode.css("background-color",priority.color),domNode.attr("title",priority.name)},bindOnce($scope,"priorityById",function(priorityById){var issue;return issue=$scope.$eval($attrs.tgListitemPriority),render(priorityById,issue)}),$scope.$watch($attrs.tgListitemPriority,function(issue){return render($scope.priorityById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemPriority",ListItemPriorityDirective),ListItemSeverityDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(severityById,issue){var domNode,severity;return severity=severityById[issue.severity],domNode=$el.find(".level"),domNode.css("background-color",severity.color),domNode.attr("title",severity.name)},bindOnce($scope,"severityById",function(severityById){var issue;return issue=$scope.$eval($attrs.tgListitemSeverity),render(severityById,issue)}),$scope.$watch($attrs.tgListitemSeverity,function(issue){return render($scope.severityById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemSeverity",ListItemSeverityDirective),TgProgressBarDirective=function($template){var link,render,template;return template=$template.get("common/components/progress-bar.html",!0),render=function(el,percentage){return el.html(template({percentage:percentage}))},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch($attrs.tgProgressBar,function(percentage){return percentage=_.max([0,percentage]),percentage=_.min([100,percentage]),render($el,percentage)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProgressBar",["$tgTemplate",TgProgressBarDirective]),TgMainTitleDirective=function($translate){var link;return link=function($scope,$el,$attrs){return $attrs.$observe("i18nSectionName",function(i18nSectionName){return $scope.sectionName=i18nSectionName}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,templateUrl:"common/components/main-title.html",scope:{projectName:"=projectName"}}},module.directive("tgMainTitle",["$translate",TgMainTitleDirective])}.call(this),function(){var ConfirmService,NOTIFICATION_MSG,bindMethods,cancelTimeout,debounce,module,taiga,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,timeout=this.taiga.timeout,cancelTimeout=this.taiga.cancelTimeout,debounce=this.taiga.debounce,bindMethods=this.taiga.bindMethods,NOTIFICATION_MSG={success:{title:"NOTIFICATION.OK",message:"NOTIFICATION.SAVED"},error:{title:"NOTIFICATION.WARNING",message:"NOTIFICATION.WARNING_TEXT"},"light-error":{title:"NOTIFICATION.WARNING",message:"NOTIFICATION.WARNING_TEXT"}},ConfirmService=function(superClass){function ConfirmService(q,lightboxService,loading,translate){this.q=q,this.lightboxService=lightboxService,this.loading=loading,this.translate=translate,bindMethods(this)}return extend(ConfirmService,superClass),ConfirmService.$inject=["$q","lightboxService","$tgLoading","$translate"],ConfirmService.prototype.hide=function(el){return el?(this.lightboxService.close(el),el.off(".confirm-dialog")):void 0},ConfirmService.prototype.ask=function(title,subtitle,message,lightboxSelector){var defered,el;return null==lightboxSelector&&(lightboxSelector=".lightbox-generic-ask"),defered=this.q.defer(),el=angular.element(lightboxSelector),el.find("h2.title").text(title),el.find("span.subtitle").text(subtitle),el.find("span.message").text(message),el.on("click.confirm-dialog","a.button-green",debounce(2e3,function(_this){return function(event){var currentLoading,target;return event.preventDefault(),target=angular.element(event.currentTarget),currentLoading=_this.loading().target(target).start(),defered.resolve({finish:function(ok){return null==ok&&(ok=!0),currentLoading.finish(),ok?_this.hide(el):void 0}})}}(this))),el.on("click.confirm-dialog","a.button-red",function(_this){return function(event){return event.preventDefault(),defered.reject(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.askOnDelete=function(title,message){return this.ask(title,this.translate.instant("NOTIFICATION.ASK_DELETE"),message)},ConfirmService.prototype.askChoice=function(title,subtitle,choices,replacement,warning,lightboxSelector){var choicesField,defered,el;return null==lightboxSelector&&(lightboxSelector=".lightbox-ask-choice"),defered=this.q.defer(),el=angular.element(lightboxSelector),el.find(".title").text(title),el.find(".subtitle").text(subtitle),replacement?el.find(".replacement").text(replacement):el.find(".replacement").remove(),warning?el.find(".warning").text(warning):el.find(".warning").remove(),choicesField=el.find(".choices"),choicesField.html(""),_.each(choices,function(value,key){return value=_.escape(value),choicesField.append(angular.element(""))}),el.on("click.confirm-dialog","a.button-green",debounce(2e3,function(_this){return function(event){var currentLoading,target;return event.preventDefault(),target=angular.element(event.currentTarget),currentLoading=_this.loading().target(target).start(),defered.resolve({selected:choicesField.val(),finish:function(ok){return null==ok&&(ok=!0),currentLoading.finish(),ok?_this.hide(el):void 0}})}}(this))),el.on("click.confirm-dialog","a.button-red",function(_this){return function(event){return event.preventDefault(),defered.reject(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.error=function(message){var defered,el;return defered=this.q.defer(),el=angular.element(".lightbox-generic-error"),el.find("h2.title").html(message),el.on("click.confirm-dialog","a.button-green",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),el.on("click.confirm-dialog","a.close",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.success=function(title,message){var defered,el;return defered=this.q.defer(),el=angular.element(".lightbox-generic-success"),title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),el.on("click.confirm-dialog","a.button-green",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),el.on("click.confirm-dialog","a.close",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.loader=function(title,message){var el;return el=angular.element(".lightbox-generic-loading"),title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),{start:function(_this){return function(){return _this.lightboxService.open(el)}}(this),stop:function(_this){return function(){return _this.lightboxService.close(el)}}(this),update:function(_this){return function(status,title,message,percent){return title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),percent?(el.find(".spin").addClass("hidden"),el.find(".progress-bar-wrapper").removeClass("hidden"),el.find(".progress-bar-wrapper > .bar").width(percent+"%"),el.find(".progress-bar-wrapper > span").html(percent+"%").css("left",percent-9+"%")):(el.find(".spin").removeClass("hidden"),el.find(".progress-bar-wrapper").addClass("hidden"))}}(this)}},ConfirmService.prototype.notify=function(type,message,title,time){var body,el,selector;return selector=".notification-message-"+type,el=angular.element(selector),el.hasClass("active")?void 0:(title?el.find("h4").html(title):el.find("h4").html(this.translate.instant(NOTIFICATION_MSG[type].title)),message?el.find("p").html(message):el.find("p").html(this.translate.instant(NOTIFICATION_MSG[type].message)),body=angular.element("body"),body.find(".notification-message .notification-light").removeClass("active").addClass("inactive"),body.find(selector).removeClass("inactive").addClass("active"),this.tsem&&cancelTimeout(this.tsem),time||(time="error"===type||"light-error"===type?3500:1500),this.tsem=timeout(time,function(_this){return function(){return body.find(selector).removeClass("active").addClass("inactive"),delete _this.tsem}}(this)),el.on("click",".icon-delete, .close",function(_this){return function(event){return body.find(selector).removeClass("active").addClass("inactive")}}(this)))},ConfirmService}(taiga.Service),module=angular.module("taigaCommon"),module.service("$tgConfirm",ConfirmService)}.call(this),function(){var CustomAttributeValueDirective,CustomAttributesValuesController,CustomAttributesValuesDirective,DATE_TYPE,MULTILINE_TYPE,TEXT_TYPE,TYPE_CHOICES,bindMethods,bindOnce,debounce,generateHash,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,bindMethods=this.taiga.bindMethods,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,generateHash=taiga.generateHash,module=angular.module("taigaCommon"),TEXT_TYPE="text",MULTILINE_TYPE="multiline",DATE_TYPE="date",TYPE_CHOICES=[{key:TEXT_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT"},{key:MULTILINE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI"},{key:DATE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE"}],CustomAttributesValuesController=function(superClass){function CustomAttributesValuesController(scope,rootscope,repo,rs,confirm,q){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.confirm=confirm,this.q=q,bindMethods(this),this.type=null,this.objectId=null,this.projectId=null,this.customAttributes=[],this.customAttributesValues=null}return extend(CustomAttributesValuesController,superClass),CustomAttributesValuesController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$tgConfirm","$q"],CustomAttributesValuesController.prototype.initialize=function(type,objectId){return this.project=this.scope.project,this.type=type,this.objectId=objectId,this.projectId=this.scope.projectId},CustomAttributesValuesController.prototype.loadCustomAttributesValues=function(){return this.objectId?this.rs.customAttributesValues[this.type].get(this.objectId).then(function(_this){return function(customAttributesValues){return _this.customAttributes=_this.project[_this.type+"_custom_attributes"],_this.customAttributesValues=customAttributesValues,customAttributesValues}}(this)):this.customAttributesValues},CustomAttributesValuesController.prototype.getAttributeValue=function(attribute){var attributeValue;return attributeValue=_.clone(attribute,!1),attributeValue.value=this.customAttributesValues.attributes_values[attribute.id],attributeValue},CustomAttributesValuesController.prototype.updateAttributeValue=function(attributeValue){var attributesValues,onError,onSuccess;return onSuccess=function(_this){return function(){return _this.rootscope.$broadcast("custom-attributes-values:edit")}}(this),onError=function(_this){return function(response){return _this.confirm.notify("error"),_this.q.reject()}}(this),attributesValues=_.clone(this.customAttributesValues.attributes_values,!0),attributesValues[attributeValue.id]=attributeValue.value,this.customAttributesValues.attributes_values=attributesValues,this.customAttributesValues.id=this.objectId,this.repo.save(this.customAttributesValues).then(onSuccess,onError)},CustomAttributesValuesController}(taiga.Controller),CustomAttributesValuesDirective=function($templates,$storage){var collapsedHash,link,template,templateFn;return template=$templates.get("custom-attributes/custom-attributes-values.html",!0),collapsedHash=function(type){return generateHash(["custom-attributes-collapsed",type])},link=function($scope,$el,$attrs,$ctrls){var $ctrl,$model;return $ctrl=$ctrls[0],$model=$ctrls[1],bindOnce($scope,$attrs.ngModel,function(value){return $ctrl.initialize($attrs.type,value.id),$ctrl.loadCustomAttributesValues()}),$el.on("click",".custom-fields-header a",function(){var collapsed,hash;return hash=collapsedHash($attrs.type),collapsed=!$storage.get(hash),$storage.set(hash,collapsed),collapsed?($el.find(".custom-fields-header a").removeClass("open"),$el.find(".custom-fields-body").removeClass("open")):($el.find(".custom-fields-header a").addClass("open"),$el.find(".custom-fields-body").addClass("open"))}),$scope.$on("$destroy",function(){return $el.off()})},templateFn=function($el,$attrs){var collapsed;return collapsed=$storage.get(collapsedHash($attrs.type))||!1,template({requiredEditionPerm:$attrs.requiredEditionPerm,collapsed:collapsed})},{require:["tgCustomAttributesValues","ngModel"],controller:CustomAttributesValuesController,controllerAs:"ctrl",restrict:"AE",scope:!0,link:link,template:templateFn}},module.directive("tgCustomAttributesValues",["$tgTemplate","$tgStorage","$translate",CustomAttributesValuesDirective]),CustomAttributeValueDirective=function($template,$selectedText,$compile,$translate,datePickerConfigService){var link,template,templateEdit;return template=$template.get("custom-attributes/custom-attribute-value.html",!0),templateEdit=$template.get("custom-attributes/custom-attribute-value-edit.html",!0),link=function($scope,$el,$attrs,$ctrl){var attributeValue,isEditable,prettyDate,render,setFocusAndSelectOnInputField,submit;return prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),render=function(attributeValue,edit){var ctx,datePickerConfig,editable,html,value;return null==edit&&(edit=!1),value=attributeValue.type===DATE_TYPE&&attributeValue.value?moment(attributeValue.value,"YYYY-MM-DD").format(prettyDate):attributeValue.value,editable=isEditable(),ctx={id:attributeValue.id,name:attributeValue.name,description:attributeValue.description,value:value,isEditable:editable,type:attributeValue.type},!editable||!edit&&value?(html=template(ctx),html=$compile(html)($scope),$el.html(html)):(html=templateEdit(ctx),html=$compile(html)($scope),$el.html(html),attributeValue.type===DATE_TYPE?(datePickerConfig=datePickerConfigService.get(),_.merge(datePickerConfig,{field:$el.find("input[name=value]")[0],onSelect:function(_this){return function(date){var selectedDate;return selectedDate=date}}(this),onOpen:function(_this){return function(){return"undefined"!=typeof selectedDate&&null!==selectedDate?$el.picker.setDate(selectedDate):void 0}}(this)}),$el.picker=new Pikaday(datePickerConfig)):void 0)},isEditable=function(){var permissions,requiredEditionPerm;return permissions=$scope.project.my_permissions,requiredEditionPerm=$attrs.requiredEditionPerm,permissions.indexOf(requiredEditionPerm)>-1},submit=debounce(2e3,function(_this){return function(event){return event.preventDefault(),attributeValue.value=$el.find("input[name=value], textarea[name='value']").val(),attributeValue.type===DATE_TYPE&&(moment(attributeValue.value,prettyDate).isValid()?attributeValue.value=moment(attributeValue.value,prettyDate).format("YYYY-MM-DD"):attributeValue.value=""),$scope.$apply(function(){return $ctrl.updateAttributeValue(attributeValue).then(function(){return render(attributeValue,!1)})})}}(this)),setFocusAndSelectOnInputField=function(){return $el.find("input[name='value'], textarea[name='value']").focus().select()},attributeValue=$scope.$eval($attrs.tgCustomAttributeValue),render(attributeValue),$el.on("click",".js-value-view-mode",function(){return isEditable()&&!$selectedText.get().length?(render(attributeValue,!0),setFocusAndSelectOnInputField()):void 0}),$el.on("click","a.icon-edit",function(event){return event.preventDefault(),render(attributeValue,!0),setFocusAndSelectOnInputField()}),$el.on("keyup","input[name=value], textarea[name='value']",function(event){return 13===event.keyCode&&"textarea"!==event.currentTarget.type?submit(event):27===event.keyCode?render(attributeValue,!1):void 0}),$el.on("submit","form",submit),$el.on("click","a.icon-floppy",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"^tgCustomAttributesValues",restrict:"AE"}},module.directive("tgCustomAttributeValue",["$tgTemplate","$selectedText","$compile","$translate","tgDatePickerConfigService",CustomAttributeValueDirective])}.call(this),function(){var EstimationsService,LbUsEstimationDirective,UsEstimationDirective,groupBy,module,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,groupBy=this.taiga.groupBy,module=angular.module("taigaCommon"),LbUsEstimationDirective=function($tgEstimationsService,$rootScope,$repo,$template,$compile){var link;return link=function($scope,$el,$attrs,$model){return $scope.$watch($attrs.ngModel,function(us){var estimationProcess;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return $scope.$apply(function(){return $model.$setViewValue(us)})},estimationProcess.render=function(){var ctx,html,mainTemplate,template;return ctx={totalPoints:this.calculateTotalPoints(),roles:this.calculateRoles(),editable:this.isEditable},mainTemplate="common/estimation/us-estimation-points-per-role.html",template=$template.get(mainTemplate,!0),html=template(ctx),html=$compile(html)($scope),this.$el.html(html)},estimationProcess.render()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgLbUsEstimation",["$tgEstimationsService","$rootScope","$tgRepo","$tgTemplate","$compile",LbUsEstimationDirective]),UsEstimationDirective=function($tgEstimationsService,$rootScope,$repo,$qqueue,$template,$compile){var link;return link=function($scope,$el,$attrs,$model){return $scope.$watch($attrs.ngModel,function(us){var estimationProcess;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return this.save(roleId,pointId).then(function(){return $rootScope.$broadcast("object:updated")})},estimationProcess.render=function(){var ctx,html,mainTemplate,template;return ctx={totalPoints:this.calculateTotalPoints(),roles:this.calculateRoles(),editable:this.isEditable},mainTemplate="common/estimation/us-estimation-points-per-role.html",template=$template.get(mainTemplate,!0),html=template(ctx),html=$compile(html)($scope),this.$el.html(html)},estimationProcess.render()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsEstimation",["$tgEstimationsService","$rootScope","$tgRepo","$tgQqueue","$tgTemplate","$compile",UsEstimationDirective]),EstimationsService=function($template,$qqueue,$repo,$confirm,$q){var EstimationProcess,create,pointsTemplate;return pointsTemplate=$template.get("common/estimation/us-estimation-points.html",!0),EstimationProcess=function(){function EstimationProcess($el1,us1,project1){this.$el=$el1,this.us=us1,this.project=project1,this.bindClickEvents=bind(this.bindClickEvents,this),this.isEditable=-1!==this.project.my_permissions.indexOf("modify_us"),this.roles=this.project.roles,this.points=this.project.points,this.pointsById=groupBy(this.points,function(x){return x.id}),this.onSelectedPointForRole=function(roleId,pointId){},this.render=function(){}}return EstimationProcess.prototype.save=function(roleId,pointId){var deferred;return deferred=$q.defer(),$qqueue.add(function(_this){return function(){var onError,onSuccess;return onSuccess=function(){return deferred.resolve()},onError=function(){return $confirm.notify("error"),_this.us.revert(),_this.render(),deferred.reject()},$repo.save(_this.us).then(onSuccess,onError); -}}(this)),deferred.promise},EstimationProcess.prototype.calculateTotalPoints=function(){var notNullValues,values;return values=_.map(this.us.points,function(_this){return function(v,k){var ref;return null!=(ref=_this.pointsById[v])?ref.value:void 0}}(this)),0===values.length?"0":(notNullValues=_.filter(values,function(v){return null!=v}),0===notNullValues.length?"?":_.reduce(notNullValues,function(acc,num){return acc+num}))},EstimationProcess.prototype.calculateRoles=function(){var computableRoles,roles;return computableRoles=_.filter(this.project.roles,"computable"),roles=_.map(computableRoles,function(_this){return function(role){var pointId,pointObj;return pointId=_this.us.points[role.id],pointObj=_this.pointsById[pointId],role=_.clone(role,!0),role.points=null!=pointObj&&null!=pointObj.name?pointObj.name:"?",role}}(this))},EstimationProcess.prototype.bindClickEvents=function(){return this.$el.on("click",".total.clickable",function(_this){return function(event){var roleId,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),roleId=target.data("role-id"),_this.renderPointsSelector(roleId,target),target.siblings().removeClass("active"),target.addClass("active")}}(this)),this.$el.on("click",".point",function(_this){return function(event){var pointId,points,roleId,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),roleId=target.data("role-id"),pointId=target.data("point-id"),_this.$el.find(".popover").popover().close(),points=_.clone(_this.us.points,!0),points[roleId]=pointId,_this.us.points=points,_this.render(),_this.onSelectedPointForRole(roleId,pointId)}}(this))},EstimationProcess.prototype.renderPointsSelector=function(roleId,target){var horizontalList,html,maxPointLength,points,pop;return points=_.map(this.points,function(_this){return function(point){return point=_.clone(point,!0),point.selected=_this.us.points[roleId]===point.id?!1:!0,point}}(this)),maxPointLength=5,horizontalList=_.some(points,function(_this){return function(point){return point.name.length>maxPointLength}}(this)),html=pointsTemplate({points:points,roleId:roleId,horizontal:horizontalList}),this.$el.find(".popover").popover().close(),this.$el.find(".pop-points-open").remove(),null!=target?this.$el.find(target).append(html):this.$el.append(html),this.$el.find(".pop-points-open").popover().open(function(){return $(this).removeClass("active").closest("li").removeClass("active")}),this.$el.find(".pop-points-open").show(),pop=this.$el.find(".pop-points-open"),pop.offset().top+pop.height()>document.body.clientHeight?pop.addClass("pop-bottom"):void 0},EstimationProcess}(),create=function($el,us,project){var estimationProcess;return $el.unbind("click"),estimationProcess=new EstimationProcess($el,us,project),estimationProcess.isEditable&&estimationProcess.bindClickEvents(),estimationProcess},{create:create}},module.factory("$tgEstimationsService",["$tgTemplate","$tgQqueue","$tgRepo","$tgConfirm","$q",EstimationsService])}.call(this),function(){var defaultFilter,module,momentFormat,momentFromNow,sizeFormat,taiga,unslugify,yesNoFilter;taiga=this.taiga,module=angular.module("taigaCommon"),defaultFilter=function(){return function(value,defaultValue){return value===[null,void 0]?defaultValue:value}},module.filter("default",defaultFilter),yesNoFilter=function($translate){return function(value){return value?$translate.instant("COMMON.YES"):$translate.instant("COMMON.NO")}},module.filter("yesNo",["$translate",yesNoFilter]),unslugify=function(){return taiga.unslugify},module.filter("unslugify",unslugify),momentFormat=function(){return function(input,format){return input?moment(input).format(format):""}},module.filter("momentFormat",momentFormat),momentFromNow=function(){return function(input,without_suffix){return input?moment(input).fromNow(without_suffix||!1):""}},module.filter("momentFromNow",momentFromNow),sizeFormat=function(_this){return function(){return _this.taiga.sizeFormat}}(this),module.filter("sizeFormat",sizeFormat)}.call(this),function(){var HistoryController,HistoryDirective,IGNORED_FIELDS,bindOnce,debounce,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaCommon"),IGNORED_FIELDS={"userstories.userstory":["watchers","kanban_order","backlog_order","sprint_order","finish_date","tribe_gig"],"tasks.task":["watchers","us_order","taskboard_order"],"issues.issue":["watchers"]},HistoryController=function(superClass){function HistoryController(scope,repo,rs){this.scope=scope,this.repo=repo,this.rs=rs}return extend(HistoryController,superClass),HistoryController.$inject=["$scope","$tgRepo","$tgResources"],HistoryController.prototype.initialize=function(type,objectId){return this.type=type,this.objectId=objectId},HistoryController.prototype.loadHistory=function(type,objectId){return this.rs.history.get(type,objectId).then(function(_this){return function(history){var changeModel,historyEntry,historyResult,i,j,len,len1;for(i=0,len=history.length;len>i;i++)historyResult=history[i],null!=historyResult.values_diff.description_diff&&(historyResult.values_diff.description=historyResult.values_diff.description_diff),delete historyResult.values_diff.description_html,delete historyResult.values_diff.description_diff,null!=historyResult.values_diff.blocked_note_diff&&(historyResult.values_diff.blocked_note=historyResult.values_diff.blocked_note_diff),delete historyResult.values_diff.blocked_note_html,delete historyResult.values_diff.blocked_note_diff;for(j=0,len1=history.length;len1>j;j++)historyEntry=history[j],changeModel=historyEntry.key.split(":")[0],null!=IGNORED_FIELDS[changeModel]&&(historyEntry.values_diff=_.removeKeys(historyEntry.values_diff,IGNORED_FIELDS[changeModel]));return _this.scope.history=_.filter(history,function(item){return Object.keys(item.values_diff).length>0}),_this.scope.comments=_.filter(history,function(item){return""!==item.comment})}}(this))},HistoryController.prototype.deleteComment=function(type,objectId,activityId){return this.rs.history.deleteComment(type,objectId,activityId).then(function(_this){return function(){return _this.loadHistory(type,objectId)}}(this))},HistoryController.prototype.undeleteComment=function(type,objectId,activityId){return this.rs.history.undeleteComment(type,objectId,activityId).then(function(_this){return function(){return _this.loadHistory(type,objectId)}}(this))},HistoryController}(taiga.Controller),HistoryDirective=function($log,$loading,$qqueue,$template,$confirm,$translate,$compile,$navUrls,$rootScope){var link,templateActivity,templateBase,templateBaseEntries,templateChangeAttachment,templateChangeDiff,templateChangeGeneric,templateChangeList,templateChangePoints,templateDeletedComment,templateFn;return templateChangeDiff=$template.get("common/history/history-change-diff.html",!0),templateChangePoints=$template.get("common/history/history-change-points.html",!0),templateChangeGeneric=$template.get("common/history/history-change-generic.html",!0),templateChangeAttachment=$template.get("common/history/history-change-attachment.html",!0),templateChangeList=$template.get("common/history/history-change-list.html",!0),templateDeletedComment=$template.get("common/history/history-deleted-comment.html",!0),templateActivity=$template.get("common/history/history-activity.html",!0),templateBaseEntries=$template.get("common/history/history-base-entries.html",!0),templateBase=$template.get("common/history/history-base.html",!0),link=function($scope,$el,$attrs,$ctrl){var countChanges,formatChange,getHumanizedFieldName,getPrettyDateFormat,objectId,renderActivity,renderAttachmentEntry,renderChange,renderChangeEntries,renderChangeEntry,renderChangesHelperText,renderComment,renderComments,renderCustomAttributesEntry,renderHistory,save,showAllActivity,showAllComments,type;return type=$attrs.type,objectId=null,showAllComments=!1,showAllActivity=!1,getPrettyDateFormat=function(){return $translate.instant("ACTIVITY.DATETIME")},bindOnce($scope,$attrs.ngModel,function(model){return type=$attrs.type,objectId=model.id,$ctrl.initialize(type,objectId),$ctrl.loadHistory(type,objectId)}),getHumanizedFieldName=function(field){var humanizedFieldNames;return humanizedFieldNames={subject:$translate.instant("ACTIVITY.FIELDS.SUBJECT"),name:$translate.instant("ACTIVITY.FIELDS.NAME"),description:$translate.instant("ACTIVITY.FIELDS.DESCRIPTION"),content:$translate.instant("ACTIVITY.FIELDS.CONTENT"),status:$translate.instant("ACTIVITY.FIELDS.STATUS"),is_closed:$translate.instant("ACTIVITY.FIELDS.IS_CLOSED"),finish_date:$translate.instant("ACTIVITY.FIELDS.FINISH_DATE"),type:$translate.instant("ACTIVITY.FIELDS.TYPE"),priority:$translate.instant("ACTIVITY.FIELDS.PRIORITY"),severity:$translate.instant("ACTIVITY.FIELDS.SEVERITY"),assigned_to:$translate.instant("ACTIVITY.FIELDS.ASSIGNED_TO"),watchers:$translate.instant("ACTIVITY.FIELDS.WATCHERS"),milestone:$translate.instant("ACTIVITY.FIELDS.MILESTONE"),user_story:$translate.instant("ACTIVITY.FIELDS.USER_STORY"),project:$translate.instant("ACTIVITY.FIELDS.PROJECT"),is_blocked:$translate.instant("ACTIVITY.FIELDS.IS_BLOCKED"),blocked_note:$translate.instant("ACTIVITY.FIELDS.BLOCKED_NOTE"),points:$translate.instant("ACTIVITY.FIELDS.POINTS"),client_requirement:$translate.instant("ACTIVITY.FIELDS.CLIENT_REQUIREMENT"),team_requirement:$translate.instant("ACTIVITY.FIELDS.TEAM_REQUIREMENT"),is_iocaine:$translate.instant("ACTIVITY.FIELDS.IS_IOCAINE"),tags:$translate.instant("ACTIVITY.FIELDS.TAGS"),attachments:$translate.instant("ACTIVITY.FIELDS.ATTACHMENTS"),is_deprecated:$translate.instant("ACTIVITY.FIELDS.IS_DEPRECATED"),blocked_note:$translate.instant("ACTIVITY.FIELDS.BLOCKED_NOTE"),is_blocked:$translate.instant("ACTIVITY.FIELDS.IS_BLOCKED"),order:$translate.instant("ACTIVITY.FIELDS.ORDER"),backlog_order:$translate.instant("ACTIVITY.FIELDS.BACKLOG_ORDER"),sprint_order:$translate.instant("ACTIVITY.FIELDS.SPRINT_ORDER"),kanban_order:$translate.instant("ACTIVITY.FIELDS.KANBAN_ORDER"),taskboard_order:$translate.instant("ACTIVITY.FIELDS.TASKBOARD_ORDER"),us_order:$translate.instant("ACTIVITY.FIELDS.US_ORDER")},humanizedFieldNames[field]||field},countChanges=function(comment){return _.keys(comment.values_diff).length},formatChange=function(change){return _.isArray(change)?0===change.length?$translate.instant("ACTIVITY.VALUES.EMPTY"):change.join(", "):""===change?$translate.instant("ACTIVITY.VALUES.EMPTY"):null==change||change===!1?$translate.instant("ACTIVITY.VALUES.NO"):change===!0?$translate.instant("ACTIVITY.VALUES.YES"):change},renderAttachmentEntry=function(value){var attachments;return attachments=_.map(value,function(changes,type){return"new"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.NEW_ATTACHMENT"),diff:change.filename})}):"deleted"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.DELETED_ATTACHMENT"),diff:change.filename})}):_.map(changes,function(change){var diff,name;return name=$translate.instant("ACTIVITY.UPDATED_ATTACHMENT",{filename:change.filename}),diff=_.map(change.changes,function(values,name){return{name:getHumanizedFieldName(name),from:formatChange(values[0]),to:formatChange(values[1])}}),templateChangeAttachment({name:name,diff:diff})})}),_.flatten(attachments).join("\n")},renderCustomAttributesEntry=function(value){var customAttributes;return customAttributes=_.map(value,function(changes,type){return"new"===type?_.map(changes,function(change){var html;return html=templateChangeGeneric({name:change.name,from:formatChange(""),to:formatChange(change.value)}),html=$compile(html)($scope),html[0].outerHTML}):"deleted"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.DELETED_CUSTOM_ATTRIBUTE"),diff:change.name})}):_.map(changes,function(change){var customAttrsChanges;return customAttrsChanges=_.map(change.changes,function(values){return templateChangeGeneric({name:change.name,from:formatChange(values[0]),to:formatChange(values[1])})}),_.flatten(customAttrsChanges).join("\n")})}),_.flatten(customAttributes).join("\n")},renderChangeEntry=function(field,value){var added,from,html,name,removed,to;return"description"===field?templateChangeDiff({name:getHumanizedFieldName("description"),diff:value[1]}):"blocked_note"===field?templateChangeDiff({name:getHumanizedFieldName("blocked_note"),diff:value[1]}):"points"===field?(html=templateChangePoints({points:value}),html=$compile(html)($scope),html[0].outerHTML):"attachments"===field?renderAttachmentEntry(value):"custom_attributes"===field?renderCustomAttributesEntry(value):"tags"===field||"watchers"===field?(name=getHumanizedFieldName(field),removed=_.difference(value[0],value[1]),added=_.difference(value[1],value[0]),html=templateChangeList({name:name,removed:removed,added:added}),html=$compile(html)($scope),html[0].outerHTML):"assigned_to"===field?(name=getHumanizedFieldName(field),from=formatChange(value[0]||$translate.instant("ACTIVITY.VALUES.UNASSIGNED")),to=formatChange(value[1]||$translate.instant("ACTIVITY.VALUES.UNASSIGNED")),templateChangeGeneric({name:name,from:from,to:to})):(name=getHumanizedFieldName(field),from=formatChange(value[0]),to=formatChange(value[1]),templateChangeGeneric({name:name,from:from,to:to}))},renderChangeEntries=function(change){return _.map(change.values_diff,function(value,field){return renderChangeEntry(field,value)})},renderChangesHelperText=function(change){var size;return size=countChanges(change),$translate.instant("ACTIVITY.SIZE_CHANGE",{size:size},"messageformat")},renderComment=function(comment){var html,ref,ref1,ref2;return comment.delete_comment_date||(null!=(ref=comment.delete_comment_user)?ref.name:void 0)?(html=templateDeletedComment({deleteCommentDate:comment.delete_comment_date?moment(comment.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:comment.delete_comment_user.name,deleteComment:comment.comment_html,activityId:comment.id,canRestoreComment:$scope.user&&(comment.delete_comment_user.pk===$scope.user.id||$scope.project.my_permissions.indexOf("modify_project")>-1)}),html=$compile(html)($scope),html[0].outerHTML):(html=templateActivity({avatar:comment.user.photo,userFullName:comment.user.name,userProfileUrl:comment.user.is_active?$navUrls.resolve("user-profile",{username:comment.user.username}):"",creationDate:moment(comment.created_at).format(getPrettyDateFormat()),comment:comment.comment_html,changesText:renderChangesHelperText(comment),changes:renderChangeEntries(comment),mode:"comment",deleteCommentActionTitle:$translate.instant("COMMENTS.DELETE"),deleteCommentDate:comment.delete_comment_date?moment(comment.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:(null!=(ref1=comment.delete_comment_user)?ref1.name:void 0)?comment.delete_comment_user.name:void 0,activityId:comment.id,canDeleteComment:comment.user.pk===(null!=(ref2=$scope.user)?ref2.id:void 0)||$scope.project.my_permissions.indexOf("modify_project")>-1}),html=$compile(html)($scope),html[0].outerHTML)},renderChange=function(change){var ref;return templateActivity({avatar:change.user.photo,userFullName:change.user.name,userProfileUrl:change.user.is_active?$navUrls.resolve("user-profile",{username:change.user.username}):"",creationDate:moment(change.created_at).format(getPrettyDateFormat()),comment:change.comment_html,changes:renderChangeEntries(change),changesText:"",mode:"activity",deleteCommentDate:change.delete_comment_date?moment(change.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:(null!=(ref=change.delete_comment_user)?ref.name:void 0)?change.delete_comment_user.name:void 0,activityId:change.id})},renderHistory=function(entries,totalEntries){var html,showMore;return showMore=entries.length===totalEntries?0:totalEntries-entries.length,html=templateBaseEntries({entries:entries,showMore:showMore}),html=$compile(html)($scope)},renderComments=function(){var comments,html,totalComments;return comments=$scope.comments||[],totalComments=comments.length,showAllComments||(comments=_.last(comments,4)),comments=_.map(comments,function(x){return renderComment(x)}),html=renderHistory(comments,totalComments),$el.find(".comments-list").html(html)},renderActivity=function(){var changes,html,totalChanges;return changes=$scope.history||[],totalChanges=changes.length,showAllActivity||(changes=_.last(changes,4)),changes=_.map(changes,function(x){return renderChange(x)}),html=renderHistory(changes,totalChanges),$el.find(".changes-list").html(html)},save=$qqueue.bindAdd(function(_this){return function(target){var currentLoading,model,onError,onSuccess;return $scope.$broadcast("markdown-editor:submit"),$el.find(".comment-list").addClass("activeanimation"),currentLoading=$loading().target(target).start(),onSuccess=function(){return $rootScope.$broadcast("comment:new"),$ctrl.loadHistory(type,objectId)["finally"](function(){return currentLoading.finish()})},onError=function(){return currentLoading.finish(),$confirm.notify("error")},model=$scope.$eval($attrs.ngModel),$ctrl.repo.save(model).then(onSuccess,onError)}}(this)),$scope.$watch("comments",renderComments),$scope.$watch("history",renderActivity),$scope.$on("object:updated",function(){return $ctrl.loadHistory(type,objectId)}),$el.on("click",".add-comment button.button-green",debounce(2e3,function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),save(target)})),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),href&&0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("click",".show-more",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parent().is(".changes-list")?(showAllActivity=!showAllActivity,renderActivity()):(showAllComments=!showAllComments,renderComments())}),$el.on("click",".show-deleted-comment",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parents(".activity-single").find(".hide-deleted-comment").show(),target.parents(".activity-single").find(".show-deleted-comment").hide(),target.parents(".activity-single").find(".comment-body").show()}),$el.on("click",".hide-deleted-comment",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parents(".activity-single").find(".hide-deleted-comment").hide(),target.parents(".activity-single").find(".show-deleted-comment").show(),target.parents(".activity-single").find(".comment-body").hide()}),$el.on("click",".changes-title",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parent().find(".change-entry").toggleClass("active")}),$el.on("focus",".add-comment textarea",function(event){return $(this).addClass("active")}),$el.on("click",".history-tabs li a",function(event){var target;return target=angular.element(event.currentTarget),$el.find(".history-tabs li a").removeClass("active"),target.addClass("active"),$el.find(".history section").addClass("hidden"),$el.find(".history section."+target.data("section-class")).removeClass("hidden")}),$el.on("click",".comment-delete",debounce(2e3,function(event){var activityId,target;return event.preventDefault(),target=angular.element(event.currentTarget),activityId=target.data("activity-id"),$ctrl.deleteComment(type,objectId,activityId)})),$el.on("click",".comment-restore",debounce(2e3,function(event){var activityId,target;return event.preventDefault(),target=angular.element(event.currentTarget),activityId=target.data("activity-id"),$ctrl.undeleteComment(type,objectId,activityId)})),$scope.$on("$destroy",function(){return $el.off()})},templateFn=function($el,$attrs){var html;return html=templateBase({ngmodel:$attrs.ngModel,type:$attrs.type,mode:$attrs.mode})},{controller:HistoryController,template:templateFn,restrict:"AE",link:link}},module.directive("tgHistory",["$log","$tgLoading","$tgQqueue","$tgTemplate","$tgConfirm","$translate","$compile","$tgNavUrls","$rootScope",HistoryDirective])}.call(this),function(){var ImportProjectButtonDirective,module;module=angular.module("taigaCommon"),ImportProjectButtonDirective=function($rs,$confirm,$location,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){return $el.on("click",".import-project-button",function(event){return event.preventDefault(),$el.find("input.import-file").val(""),$el.find("input.import-file").trigger("click")}),$el.on("change","input.import-file",function(event){var file,loader,onError,onSuccess;return event.preventDefault(),(file=event.target.files[0])?(loader=$confirm.loader($translate.instant("PROJECT.IMPORT.UPLOADING_FILE")),onSuccess=function(result){var ctx,message,msg,title;return loader.stop(),202===result.status?(title=$translate.instant("PROJECT.IMPORT.ASYNC_IN_PROGRESS_TITLE"),message=$translate.instant("PROJECT.IMPORT.ASYNC_IN_PROGRESS_MESSAGE"),$confirm.success(title,message)):(ctx={project:result.data.slug},$location.path($navUrls.resolve("project-admin-project-profile-details",ctx)),msg=$translate.instant("PROJECT.IMPORT.SYNC_SUCCESS"),$confirm.notify("success",msg))},onError=function(result){var errorMsg,ref;return loader.stop(),errorMsg=$translate.instant("PROJECT.IMPORT.ERROR"),429===result.status?errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST"):(null!=(ref=result.data)?ref._error_message:void 0)&&(errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_MESSAGE",{error_message:result.data._error_message})),$confirm.notify("error",errorMsg)},loader.start(),$rs.projects["import"](file,loader.update).then(onSuccess,onError)):void 0})},{link:link}},module.directive("tgImportProjectButton",["$tgResources","$tgConfirm","$location","$tgNavUrls","$translate",ImportProjectButtonDirective])}.call(this),function(){var AssignedToLightboxDirective,AttachmentPreviewLightboxDirective,BlockLightboxDirective,BlockingMessageInputDirective,CreateBulkUserstoriesDirective,CreateEditUserstoryDirective,LightboxDirective,LightboxKeyboardNavigationService,LightboxService,WatchersLightboxDirective,bindOnce,debounce,module,sizeFormat,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;module=angular.module("taigaCommon"),bindOnce=this.taiga.bindOnce,timeout=this.taiga.timeout,debounce=this.taiga.debounce,sizeFormat=this.taiga.sizeFormat,LightboxService=function(superClass){function LightboxService(animationFrame,q){this.animationFrame=animationFrame,this.q=q}return extend(LightboxService,superClass),LightboxService.prototype.open=function($el){var defered,docEl,lightboxContent;return defered=this.q.defer(),lightboxContent=$el.children().not(".close"),lightboxContent.hide(),this.animationFrame.add(function(){return $el.css("display","flex")}),this.animationFrame.add(function(){return $el.addClass("open"),$el.one("transitionend",function(_this){return function(){return $el.find("input,textarea").first().focus()}}(this))}),this.animationFrame.add(function(_this){return function(){return lightboxContent.show(),defered.resolve()}}(this)),docEl=angular.element(document),docEl.on("keydown.lightbox",function(_this){return function(e){var code;return code=e.keyCode?e.keyCode:e.which,27===code?_this.close($el):void 0}}(this)),defered.promise},LightboxService.prototype.close=function($el){var docEl,scope;return docEl=angular.element(document),docEl.off(".lightbox"),docEl.off(".keyboard-navigation"),$el.one("transitionend",function(_this){return function(){return $el.removeAttr("style"),$el.removeClass("open").removeClass("close")}}(this)),$el.addClass("close"),$el.hasClass("remove-on-close")?(scope=$el.data("scope"),scope.$destroy(),$el.remove()):void 0},LightboxService.prototype.closeAll=function(){var docEl,i,len,lightboxEl,ref,results;for(docEl=angular.element(document),ref=docEl.find(".lightbox.open"),results=[],i=0,len=ref.length;len>i;i++)lightboxEl=ref[i],results.push(this.close($(lightboxEl)));return results},LightboxService}(taiga.Service),module.service("lightboxService",["animationFrame","$q",LightboxService]),LightboxKeyboardNavigationService=function(superClass){function LightboxKeyboardNavigationService(){return LightboxKeyboardNavigationService.__super__.constructor.apply(this,arguments)}return extend(LightboxKeyboardNavigationService,superClass),LightboxKeyboardNavigationService.prototype.stop=function(){var docEl;return docEl=angular.element(document),docEl.off(".keyboard-navigation")},LightboxKeyboardNavigationService.prototype.dispatch=function($el,code){var activeElement,next,prev;if(activeElement=$el.find(".selected"),13===code)return 1===$el.find(".user-list-single").length?$el.find(".user-list-single:first").trigger("click"):activeElement.trigger("click");if(40===code){if(!activeElement.length)return $el.find('.user-list-single:not(".is-active"):first').addClass("selected");if(next=activeElement.next(".user-list-single"),next.length)return activeElement.removeClass("selected"),next.addClass("selected")}else if(38===code){if(!activeElement.length)return $el.find(".user-list-single:last").addClass("selected");if(prev=activeElement.prev('.user-list-single:not(".is-active")'),prev.length)return activeElement.removeClass("selected"),prev.addClass("selected")}},LightboxKeyboardNavigationService.prototype.init=function($el){var docEl;return this.stop(),docEl=angular.element(document),docEl.on("keydown.keyboard-navigation",function(_this){return function(event){var code;return code=event.keyCode?event.keyCode:event.which,40===code||38===code||13===code?(event.preventDefault(),_this.dispatch($el,code)):void 0}}(this))},LightboxKeyboardNavigationService}(taiga.Service),module.service("lightboxKeyboardNavigationService",LightboxKeyboardNavigationService),LightboxDirective=function(lightboxService){var link;return link=function($scope,$el,$attrs){return $el.on("click",".close",function(event){return event.preventDefault(),lightboxService.close($el)})},{restrict:"C",link:link}},module.directive("lightbox",["lightboxService",LightboxDirective]),BlockLightboxDirective=function($rootscope,$tgrepo,$confirm,lightboxService,$loading,$qqueue,$translate){var link;return link=function($scope,$el,$attrs,$model){var block,title,unblock;return title=$translate.instant($attrs.title),$el.find("h2.title").text(title),unblock=$qqueue.bindAdd(function(_this){return function(item,finishCallback){var promise;return promise=$tgrepo.save(item),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$model.$setViewValue(item),finishCallback()}),promise.then(null,function(){return $confirm.notify("error"),item.revert(),$model.$setViewValue(item)}),promise["finally"](function(){return finishCallback()}),promise}}(this)),block=$qqueue.bindAdd(function(_this){return function(item){var currentLoading,promise;return $model.$setViewValue(item),currentLoading=$loading().target($el.find(".button-green")).start(),promise=$tgrepo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error"),item.revert(),$model.$setViewValue(item)}),promise["finally"](function(){return currentLoading.finish(),lightboxService.close($el)})}}(this)),$scope.$on("block",function(){return $el.find(".reason").val($model.$modelValue.blocked_note),lightboxService.open($el)}),$scope.$on("unblock",function(_this){return function(event,model,finishCallback){var item;return item=$model.$modelValue.clone(),item.is_blocked=!1,item.blocked_note="",unblock(item,finishCallback)}}(this)),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click",".button-green",function(event){var item;return event.preventDefault(),item=$model.$modelValue.clone(),item.is_blocked=!0,item.blocked_note=$el.find(".reason").val(),block(item)})},{templateUrl:"common/lightbox/lightbox-block.html",link:link,require:"ngModel"}},module.directive("tgLbBlock",["$rootScope","$tgRepo","$tgConfirm","lightboxService","$tgLoading","$tgQqueue","$translate",BlockLightboxDirective]),BlockingMessageInputDirective=function($log,$template,$compile){var link,template,templateFn;return template=$template.get("common/lightbox/lightbox-blocking-message-input.html",!0),link=function($scope,$el,$attrs,$model){return $attrs.watch?$scope.$watch($attrs.watch,function(value){return value===!0&&value===!0?$el.find(".blocked-note").removeClass("hidden"):$el.find(".blocked-note").addClass("hidden")}):$log.error("No watch attribute on tg-blocking-message-input directive")},templateFn=function($el,$attrs){return template({ngmodel:$attrs.ngModel})},{template:templateFn,link:link,require:"ngModel",restrict:"EA"}},module.directive("tgBlockingMessageInput",["$log","$tgTemplate","$compile",BlockingMessageInputDirective]),CreateEditUserstoryDirective=function($repo,$model,$rs,$rootScope,lightboxService,$loading,$translate,$confirm,$q,attachmentsService){var link;return link=function($scope,$el,attrs){var attachmentsToAdd,attachmentsToDelete,createAttachments,deleteAttachments,resetAttachments,submit,submitButton;return $scope.createEditUs={},$scope.isNew=!0,attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},$scope.deleteAttachment=function(attachment){return attachmentsToDelete=attachmentsToDelete.push(attachment)},$scope.$on("usform:new",function(ctx,projectId,status,statusList){return $scope.isNew=!0,$scope.usStatusList=statusList,$scope.attachments=Immutable.List(),resetAttachments(),$scope.us=$model.make_model("userstories",{project:projectId,points:{},status:status,is_archived:!1,tags:[]}),$el.find(".button-green").html($translate.instant("COMMON.CREATE")),$el.find(".title").html($translate.instant("LIGHTBOX.CREATE_EDIT_US.NEW_US")),$el.find(".tag-input").val(""),$el.find(".blocked-note").addClass("hidden"),$el.find("label.blocked").removeClass("selected"),$el.find("label.team-requirement").removeClass("selected"),$el.find("label.client-requirement").removeClass("selected"),lightboxService.open($el)}),$scope.$on("usform:edit",function(ctx,us,attachments){return $scope.us=us,$scope.attachments=Immutable.fromJS(attachments),$scope.isNew=!1,resetAttachments(),$el.find(".button-green").html($translate.instant("COMMON.SAVE")),$el.find(".title").html($translate.instant("LIGHTBOX.CREATE_EDIT_US.EDIT_US")),$el.find(".tag-input").val(""),us.is_blocked?($el.find(".blocked-note").removeClass("hidden"),$el.find("label.blocked").addClass("selected")):($el.find(".blocked-note").addClass("hidden"),$el.find("label.blocked").removeClass("selected")),us.team_requirement?$el.find("label.team-requirement").addClass("selected"):$el.find("label.team-requirement").removeClass("selected"),us.client_requirement?$el.find("label.client-requirement").addClass("selected"):$el.find("label.client-requirement").removeClass("selected"),lightboxService.open($el)}),createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){return attachmentsService.upload(attachment.file,obj.id,$scope.us.project,"us")}), -$q.all(promises)},deleteAttachments=function(obj){var promises;return promises=_.map(attachmentsToDelete.toJS(),function(attachment){return attachmentsService["delete"]("us",attachment.id)}),$q.all(promises)},submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),$scope.isNew?(promise=$repo.create("userstories",$scope.us),broadcastEvent="usform:new:success"):(promise=$repo.save($scope.us),broadcastEvent="usform:edit:success"),promise.then(function(data){return deleteAttachments(data).then(function(_this){return function(){return createAttachments(data)}}(this)),data}),promise.then(function(data){return currentLoading.finish(),lightboxService.close($el),$rootScope.$broadcast(broadcastEvent,data)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$el.on("click",".close",function(event){return event.preventDefault(),$scope.$apply(function(){return $scope.us.revert()}),lightboxService.close($el)}),$el.keydown(function(event){var code;return code=event.keyCode?event.keyCode:event.which,27===code?(lightboxService.close($el),$scope.$apply(function(){return $scope.us.revert()})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateEditUserstory",["$tgRepo","$tgModel","$tgResources","$rootScope","lightboxService","$tgLoading","$translate","$tgConfirm","$q","tgAttachmentsService",CreateEditUserstoryDirective]),CreateBulkUserstoriesDirective=function($repo,$rs,$rootscope,lightboxService,$loading){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.$on("usform:bulk",function(ctx,projectId,status){return $scope["new"]={projectId:projectId,statusId:status,bulk:""},lightboxService.open($el)}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley({onlyOneErrorElement:!0}),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$rs.userstories.bulkCreate($scope["new"].projectId,$scope["new"].statusId,$scope["new"].bulk),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("usform:bulk:success",result),lightboxService.close($el)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateBulkUserstories",["$tgRepo","$tgResources","$rootScope","lightboxService","$tgLoading",CreateBulkUserstoriesDirective]),AssignedToLightboxDirective=function(lightboxService,lightboxKeyboardNavigationService,$template,$compile){var link;return link=function($scope,$el,$attrs){var closeLightbox,filterUsers,normalizeString,render,selectedItem,selectedUser,usersTemplate;return selectedUser=null,selectedItem=null,usersTemplate=$template.get("common/lightbox/lightbox-assigned-to-users.html",!0),normalizeString=function(string){var normalizedString;return normalizedString=string,normalizedString=normalizedString.replace("Á","A").replace("Ä","A").replace("À","A"),normalizedString=normalizedString.replace("É","E").replace("Ë","E").replace("È","E"),normalizedString=normalizedString.replace("Í","I").replace("Ï","I").replace("Ì","I"),normalizedString=normalizedString.replace("Ó","O").replace("Ö","O").replace("Ò","O"),normalizedString=normalizedString.replace("Ú","U").replace("Ü","U").replace("Ù","U")},filterUsers=function(text,user){var username;return username=user.full_name_display.toUpperCase(),username=normalizeString(username),text=text.toUpperCase(),text=normalizeString(text),_.contains(username,text)},render=function(selected,text){var ctx,html,users;return users=_.clone($scope.activeUsers,!0),null!=selected&&(users=_.reject(users,{id:selected.id})),null!=text&&(users=_.filter(users,_.partial(filterUsers,text))),ctx={selected:selected,users:_.first(users,5),showMore:users.length>5},html=usersTemplate(ctx),html=$compile(html)($scope),$el.find(".assigned-to-list").html(html)},closeLightbox=function(){return lightboxKeyboardNavigationService.stop(),lightboxService.close($el)},$scope.$on("assigned-to:add",function(ctx,item){var assignedToId;return selectedItem=item,assignedToId=item.assigned_to,selectedUser=$scope.usersById[assignedToId],render(selectedUser),lightboxService.open($el).then(function(){return $el.find("input").focus(),lightboxKeyboardNavigationService.init($el)})}),$scope.$watch("usersSearch",function(searchingText){return null!=searchingText?(render(selectedUser,searchingText),$el.find("input").focus()):void 0}),$el.on("click",".user-list-single",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),closeLightbox(),$scope.$apply(function(){return $scope.$broadcast("assigned-to:added",target.data("user-id"),selectedItem),$scope.usersSearch=null})}),$el.on("click",".remove-assigned-to",function(event){return event.preventDefault(),event.stopPropagation(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null,$scope.$broadcast("assigned-to:added",null,selectedItem)})}),$el.on("click",".close",function(event){return event.preventDefault(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null})}),$scope.$on("$destroy",function(){return $el.off()})},{templateUrl:"common/lightbox/lightbox-assigned-to.html",link:link}},module.directive("tgLbAssignedto",["lightboxService","lightboxKeyboardNavigationService","$tgTemplate","$compile",AssignedToLightboxDirective]),WatchersLightboxDirective=function($repo,lightboxService,lightboxKeyboardNavigationService,$template,$compile){var link;return link=function($scope,$el,$attrs){var closeLightbox,getFilteredUsers,render,selectedItem,usersTemplate;return selectedItem=null,usersTemplate=$template.get("common/lightbox/lightbox-assigned-to-users.html",!0),getFilteredUsers=function(text){var _filterUsers,users;return null==text&&(text=""),_filterUsers=function(text,user){var username;return selectedItem&&_.find(selectedItem.watchers,function(x){return x===user.id})?!1:(username=user.full_name_display.toUpperCase(),text=text.toUpperCase(),_.contains(username,text))},users=_.clone($scope.activeUsers,!0),users=_.filter(users,_.partial(_filterUsers,text))},render=function(users){var ctx,html;return ctx={selected:!1,users:_.first(users,5),showMore:users.length>5},html=usersTemplate(ctx),html=$compile(html)($scope),$el.find(".ticket-watchers").html(html)},closeLightbox=function(){return lightboxKeyboardNavigationService.stop(),lightboxService.close($el)},$scope.$on("watcher:add",function(ctx,item){var users;return selectedItem=item,users=getFilteredUsers(),render(users),lightboxService.open($el).then(function(){return $el.find("input").focus(),lightboxKeyboardNavigationService.init($el)})}),$scope.$watch("usersSearch",function(searchingText){var users;if(null!=searchingText)return users=getFilteredUsers(searchingText),render(users),$el.find("input").focus()}),$el.on("click",".user-list-single",debounce(2e3,function(event){var target;return closeLightbox(),event.preventDefault(),target=angular.element(event.currentTarget),$scope.$apply(function(){return $scope.usersSearch=null,$scope.$broadcast("watcher:added",target.data("user-id"))})})),$el.on("click",".close",function(event){return event.preventDefault(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null})}),$scope.$on("$destroy",function(){return $el.off()})},{templateUrl:"common/lightbox/lightbox-users.html",link:link}},module.directive("tgLbWatchers",["$tgRepo","lightboxService","lightboxKeyboardNavigationService","$tgTemplate","$compile",WatchersLightboxDirective]),AttachmentPreviewLightboxDirective=function(lightboxService,$template,$compile){var link;return link=function($scope,$el,attrs){return lightboxService.open($el)},{templateUrl:"common/lightbox/lightbox-attachment-preview.html",link:link,scope:!0}},module.directive("tgLbAttachmentPreview",["lightboxService","$tgTemplate","$compile",AttachmentPreviewLightboxDirective])}.call(this),function(){var Loader,LoaderDirective,module,sizeFormat,taiga,timeout;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,timeout=this.taiga.timeout,module=angular.module("taigaCommon"),LoaderDirective=function(tgLoader,$rootscope){var link;return link=function($scope,$el,$attrs){return tgLoader.onStart(function(){return $(document.body).addClass("loader-active"),$el.addClass("active")}),tgLoader.onEnd(function(){return $(document.body).removeClass("loader-active"),$el.removeClass("active")})},{link:link}},module.directive("tgLoader",["tgLoader","$rootScope",LoaderDirective]),Loader=function($rootscope){var autoClose,config,lastResponseDate,open,pageLoaded,requestCount,start,startLoadTime;return config={minTime:300},open=!1,startLoadTime=0,requestCount=0,lastResponseDate=0,pageLoaded=function(force){var diff,endTime,timeoutValue;return null==force&&(force=!1),startLoadTime&&(timeoutValue=0,force||(endTime=(new Date).getTime(),diff=endTime-startLoadTime,diff",function(){var service;return service={settings:{target:null,scope:null,classes:[],timeout:0,template:null},target:function(target){return service.settings.target=target,service},scope:function(scope){return service.settings.scope=scope,service},template:function(template){return service.settings.template=template,service},removeClasses:function(){var classess;return classess=1<=arguments.length?slice.call(arguments,0):[],service.settings.classes=classess,service},timeout:function(timeout){return service.settings.timeout=timeout,service},start:function(){var target,timeoutId;return target=service.settings.target,service.settings.classes.map(function(className){return target.removeClass(className)}),timeoutId=setTimeout(function(){return target.hasClass("loading")?void 0:(service.settings.template||(service.settings.template=target.html()),target.addClass("loading"),target.html(spinner))},service.settings.timeout),service.settings.timeoutId=timeoutId,service},finish:function(){var removeClasses,target,timeoutId;return target=service.settings.target,timeoutId=service.settings.timeoutId,timeoutId&&(clearTimeout(timeoutId),removeClasses=service.settings.classes,removeClasses.map(function(className){return service.settings.target.addClass(className)}),target.html(service.settings.template),target.removeClass("loading"),service.settings.scope&&$compile(target.contents())(service.settings.scope)),service}}}},TgLoadingService.$inject=["$compile"],module.factory("$tgLoading",TgLoadingService),LoadingDirective=function($loading){var link;return link=function($scope,$el,attr){var currentLoading,template;return currentLoading=null,template=$el.html(),$scope.$watch(attr.tgLoading,function(_this){return function(showLoading){return showLoading?currentLoading=$loading().target($el).timeout(100).template(template).scope($scope).start():currentLoading?currentLoading.finish():void 0}}(this))},{link:link}},module.directive("tgLoading",["$tgLoading",LoadingDirective])}.call(this),function(){var RelatedTaskStatusDirective,UsStatusDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaCommon"),UsStatusDirective=function($repo,$template){var link,template;return template=$template.get("common/popover/popover-us-status.html",!0),link=function($scope,$el,$attrs){var $ctrl,render,us;return $ctrl=$el.controller(),render=function(us){var usStatusById,usStatusDom,usStatusDomParent;return usStatusDomParent=$el.find(".us-status"),usStatusDom=$el.find(".us-status .us-status-bind"),usStatusById=$scope.usStatusById,usStatusById[us.status]?(usStatusDom.text(usStatusById[us.status].name),usStatusDomParent.css("color",usStatusById[us.status].color)):void 0},$el.on("click",".us-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",debounce(2e3,function(event){var target,us;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),us=$scope.$eval($attrs.tgUsStatus),us.status=target.data("status-id"),render(us),$el.find(".pop-status").popover().close(),$scope.$apply(function(){return $repo.save(us).then(function(){return $scope.$eval($attrs.onUpdate)})})})),$scope.$on("userstories:loaded",function(){return render($scope.$eval($attrs.tgUsStatus))}),$scope.$on("$destroy",function(){return $el.off()}),us=$scope.$eval($attrs.tgUsStatus),render(us),bindOnce($scope,"project",function(project){var html;return html=template({statuses:project.us_statuses}),$el.append(html),-1===$scope.project.my_permissions.indexOf("modify_us")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0})},{link:link}},module.directive("tgUsStatus",["$tgRepo","$tgTemplate",UsStatusDirective]),RelatedTaskStatusDirective=function($repo,$template){var link,selectionTemplate,updateTaskStatus;return selectionTemplate=$template.get("common/popover/popover-related-task-status.html",!0),updateTaskStatus=function($el,task,taskStatusById){var taskStatusDom,taskStatusDomParent;return taskStatusDomParent=$el.find(".us-status"),taskStatusDom=$el.find(".task-status .task-status-bind"),taskStatusById[task.status]?(taskStatusDom.text(taskStatusById[task.status].name),taskStatusDomParent.css("color",taskStatusById[task.status].color)):void 0},link=function($scope,$el,$attrs){var $ctrl,autoSave,notAutoSave,task;return $ctrl=$el.controller(),task=$scope.$eval($attrs.tgRelatedTaskStatus),notAutoSave=$scope.$eval($attrs.notAutoSave),autoSave=!notAutoSave,$el.on("click",".task-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",debounce(2e3,function(event){var target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),task.status=target.data("status-id"),$el.find(".pop-status").popover().close(),updateTaskStatus($el,task,$scope.taskStatusById),autoSave?$scope.$apply(function(){return $repo.save(task).then(function(){return $scope.$eval($attrs.onUpdate),$scope.$emit("related-tasks:status-changed")})}):void 0})),taiga.bindOnce($scope,"project",function(project){return $el.append(selectionTemplate({statuses:project.task_statuses})),updateTaskStatus($el,task,$scope.taskStatusById),-1===project.my_permissions.indexOf("modify_task")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskStatus",["$tgRepo","$tgTemplate",RelatedTaskStatusDirective]),$.fn.popover=function(){var $el,close,closeAll,closePopover,isVisible,open;return $el=this,isVisible=function(_this){return function(){var docViewBottom,docViewLeft,docViewRight,docViewTop,docViewWidth,elemBottom,elemLeft,elemRight,elemTop,elemWidth;return $el.css({display:"block",visibility:"hidden"}),docViewTop=$(window).scrollTop(),docViewBottom=docViewTop+$(window).height(),docViewWidth=$(window).width(),docViewRight=docViewWidth,docViewLeft=0,elemTop=$el.offset().top,elemBottom=elemTop+$el.height(),elemWidth=$el.width(),elemLeft=$el.offset().left,elemRight=$el.offset().left+elemWidth,$el.css({display:"none",visibility:"visible"}),docViewBottom>=elemBottom&&elemTop>=docViewTop&&elemLeft>=docViewLeft&&docViewRight>=elemRight}}(this),closePopover=function(_this){return function(onClose){return onClose&&onClose.call($el),$el.fadeOut(function(){return $el.removeClass("active").removeClass("fix")}),$el.off("popup:close")}}(this),closeAll=function(_this){return function(){return $(".popover.active").each(function(){return $(this).trigger("popup:close")})}}(this),open=function(_this){return function(onClose){return $el.hasClass("active")?close():(closeAll(),isVisible()||$el.addClass("fix"),$el.fadeIn(function(){return $el.addClass("active"),$(document.body).off("popover"),$(document.body).one("click.popover",function(){return closeAll()})}),$el.on("popup:close",function(e){return closePopover(onClose)}))}}(this),close=function(_this){return function(){return $el.trigger("popup:close")}}(this),{open:open,close:close,closeAll:closeAll}}}.call(this),function(){var ExceptionHandlerFactory,module,taiga;taiga=this.taiga,module=angular.module("taigaCommon"),ExceptionHandlerFactory=function($log,config){var ravenConfig;return this.config=config,ravenConfig=this.config.get("ravenConfig",null),ravenConfig?($log.debug("Using the RavenJS exception handler."),Raven.config(ravenConfig).install(),function(exception,cause){return $log.error.apply($log,arguments),Raven.captureException(exception)}):($log.debug("Using the default logging exception handler."),function(exception,cause){return $log.error.apply($log,arguments)})},module.factory("$exceptionHandler",["$log","$tgConfig",ExceptionHandlerFactory])}.call(this),function(){var ColorizeTagsDirective,LbTagLineDirective,TagLineDirective,TagsDirective,bindOnce,module,taiga,trim,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),TagsDirective=function(){var formatter,link,parser;return formatter=function(v){return _.isArray(v)?v.join(", "):""},parser=function(v){var result;return v?(result=_(v.split(",")).map(function(x){return _.str.trim(x)}),result.value()):[]},link=function($scope,$el,$attrs,$ctrl){return $ctrl.$formatters.push(formatter),$ctrl.$parsers.push(parser),$scope.$on("$destroy",function(){return $el.off()})},{require:"ngModel",link:link}},module.directive("tgTags",TagsDirective),ColorizeTagsDirective=function(){var link,templates;return templates={backlog:_.template('<% _.each(tags, function(tag) { %>\n <%- tag.name %>\n<% }) %>'),kanban:_.template('<% _.each(tags, function(tag) { %>\n \n<% }) %>'),taskboard:_.template('<% _.each(tags, function(tag) { %>\n \n<% }) %>')},link=function($scope,$el,$attrs,$ctrl){var render;return render=function(srcTags){var html,tags,template;return template=templates[$attrs.tgColorizeTagsType],srcTags.sort(),tags=_.map(srcTags,function(tag){var color;return color=$scope.project.tags_colors[tag],{name:tag,color:color}}),html=template({tags:tags}),$el.html(html)},$scope.$watch($attrs.tgColorizeTags,function(tags){return null!=tags?render(tags):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgColorizeTags",ColorizeTagsDirective),LbTagLineDirective=function($rs,$template,$compile){var COMMA_KEY,ENTER_KEY,link,templateTags;return ENTER_KEY=13,COMMA_KEY=188,templateTags=$template.get("common/tag/lb-tag-line-tags.html",!0),link=function($scope,$el,$attrs,$model){var addValue,deleteValue,hideSaveButton,renderTags,resetInput,saveInputTag,showSaveButton;return renderTags=function(tags,tagsColors){var ctx,html;return ctx={tags:_.map(tags,function(t){return{name:t,color:tagsColors[t]}})},_.map(ctx.tags,function(_this){return function(tag){return tag.color?tag.style="border-left: 5px solid "+tag.color:void 0}}(this)),html=$compile(templateTags(ctx))($scope),$el.find("div.tags-container").html(html)},showSaveButton=function(){return $el.find(".save").removeClass("hidden")},hideSaveButton=function(){return $el.find(".save").addClass("hidden")},resetInput=function(){return $el.find("input").val(""),$el.find("input").autocomplete("close")},addValue=function(value){var tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue,!1),null==tags&&(tags=[]),indexOf.call(tags,value)<0&&tags.push(value),$scope.$apply(function(){return $model.$setViewValue(tags)}),hideSaveButton()):void 0},deleteValue=function(value){var tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue,!1),tags=_.pull(tags,value),$scope.$apply(function(){return $model.$setViewValue(tags)})):void 0},saveInputTag=function(){var value;return value=$el.find("input").val(),addValue(value),resetInput()},$el.on("keypress","input",function(event){var target;return target=angular.element(event.currentTarget),event.keyCode===ENTER_KEY?(event.preventDefault(),saveInputTag()):","===String.fromCharCode(event.keyCode)?(event.preventDefault(),saveInputTag()):target.val().length?showSaveButton():hideSaveButton()}),$el.on("click",".save",function(event){return event.preventDefault(),saveInputTag()}),$el.on("click",".icon-delete",function(event){var target,value;return event.preventDefault(),target=angular.element(event.currentTarget),value=target.siblings(".tag-name").text(),deleteValue(value)}),bindOnce($scope,"project",function(project){var positioningFunction;return positioningFunction=function(position,elements){var menu;return menu=elements.element.element,menu.css("width",elements.target.width),menu.css("top",position.top),menu.css("left",position.left)},$el.find("input").autocomplete({source:_.keys(project.tags_colors),position:{my:"left top",using:positioningFunction},select:function(event,ui){return addValue(ui.item.value),ui.item.value=""}})}),$scope.$watch($attrs.ngModel,function(tags){var ref,tagsColors;return tagsColors=(null!=(ref=$scope.project)?ref.tags_colors:void 0)||[],renderTags(tags,tagsColors)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel",templateUrl:"common/tag/lb-tag-line.html"}},module.directive("tgLbTagLine",["$tgResources","$tgTemplate","$compile",LbTagLineDirective]),TagLineDirective=function($rootScope,$repo,$rs,$confirm,$qqueue,$template,$compile){var COMMA_KEY,ENTER_KEY,ESC_KEY,link,templateTags;return ENTER_KEY=13,ESC_KEY=27,COMMA_KEY=188,templateTags=$template.get("common/tag/tags-line-tags.html",!0),link=function($scope,$el,$attrs,$model){var addValue,deleteValue,hideAddTagButton,hideAddTagButtonText,hideInput,hideSaveButton,isEditable,renderInReadModeOnly,renderTags,resetInput,saveInputTag,showAddTagButton,showAddTagButtonText,showInput,showSaveButton;return isEditable=function(){return null!=$attrs.requiredPerm?-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm):!0},renderTags=function(tags,tagsColors){var ctx,html;return ctx={tags:_.map(tags,function(t){return{name:t,color:tagsColors[t]}}),isEditable:isEditable()},html=$compile(templateTags(ctx))($scope),$el.find("div.tags-container").html(html)},renderInReadModeOnly=function(){return $el.find(".add-tag").remove(),$el.find("input").remove(),$el.find(".save").remove()},showAddTagButton=function(){return $el.find(".add-tag").removeClass("hidden")},hideAddTagButton=function(){return $el.find(".add-tag").addClass("hidden")},showAddTagButtonText=function(){return $el.find(".add-tag-text").removeClass("hidden")},hideAddTagButtonText=function(){return $el.find(".add-tag-text").addClass("hidden")},showSaveButton=function(){return $el.find(".save").removeClass("hidden")},hideSaveButton=function(){return $el.find(".save").addClass("hidden")},showInput=function(){return $el.find("input").removeClass("hidden").focus()},hideInput=function(){return $el.find("input").addClass("hidden").blur()},resetInput=function(){return $el.find("input").val(""),$el.find("input").autocomplete("close")},addValue=$qqueue.bindAdd(function(value){var model,onError,onSuccess,tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue.tags,!1),null==tags&&(tags=[]),indexOf.call(tags,value)<0&&tags.push(value),model=$model.$modelValue.clone(),model.tags=tags,$model.$setViewValue(model),onSuccess=function(){return $rootScope.$broadcast("object:updated")},onError=function(){return $confirm.notify("error"),model.revert(),$model.$setViewValue(model)},hideSaveButton(),$repo.save(model).then(onSuccess,onError)):void 0}),deleteValue=$qqueue.bindAdd(function(value){var model,onError,onSuccess,tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue.tags,!1),tags=_.pull(tags,value),model=$model.$modelValue.clone(),model.tags=tags,$model.$setViewValue(model),onSuccess=function(){return $rootScope.$broadcast("object:updated")},onError=function(){return $confirm.notify("error"),model.revert(),$model.$setViewValue(model)},$repo.save(model).then(onSuccess,onError)):void 0}),saveInputTag=function(){var value;return value=$el.find("input").val(),addValue(value),resetInput()},$el.on("keypress","input",function(event){var target;return target=angular.element(event.currentTarget),event.keyCode===ENTER_KEY?saveInputTag():","===String.fromCharCode(event.keyCode)?(event.preventDefault(),saveInputTag()):target.val().length?showSaveButton():hideSaveButton()}),$el.on("keyup","input",function(event){return event.keyCode===ESC_KEY?(resetInput(),hideInput(),hideSaveButton(),showAddTagButton()):void 0}),$el.on("click",".save",function(event){return event.preventDefault(),saveInputTag()}),$el.on("click",".add-tag",function(event){return event.preventDefault(),hideAddTagButton(),showInput()}),$el.on("click",".icon-delete",function(event){var target,value;return event.preventDefault(),target=angular.element(event.currentTarget),value=target.siblings(".tag-name").text(),deleteValue(value)}),bindOnce($scope,"project.tags_colors",function(tags_colors){var positioningFunction;return isEditable()?(showAddTagButton(),positioningFunction=function(position,elements){var menu;return menu=elements.element.element,menu.css("width",elements.target.width),menu.css("top",position.top),menu.css("left",position.left)},$el.find("input").autocomplete({source:_.keys(tags_colors),position:{my:"left top",using:positioningFunction},select:function(event,ui){return addValue(ui.item.value),ui.item.value=""}})):void renderInReadModeOnly()}),$scope.$watch($attrs.ngModel,function(model){var ref,ref1,tagsColors;if(model)return(null!=(ref=model.tags)?ref.length:void 0)?hideAddTagButtonText():showAddTagButtonText(),tagsColors=(null!=(ref1=$scope.project)?ref1.tags_colors:void 0)||[],renderTags(model.tags,tagsColors)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel",templateUrl:"common/tag/tag-line.html"}},module.directive("tgTagLine",["$rootScope","$tgRepo","$tgResources","$tgConfirm","$tgQqueue","$tgTemplate","$compile",TagLineDirective])}.call(this),function(){var MarkitupDirective,bindOnce,module,taiga,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),MarkitupDirective=function($rootscope,$rs,$selectedText,$template,$compile,$translate){var link,previewTemplate;return previewTemplate=$template.get("common/wysiwyg/wysiwyg-markitup-preview.html",!0),link=function($scope,$el,$attrs,$model){var addLine,cancelablePromise,closePreviewMode,element,markdownTitle,prepareUrlFormatting,preview,previewDomNode,renderMarkItUp,setCaretPosition,unbind,urlFormatting;return element=angular.element($el),previewDomNode=$("
",{"class":"preview"}),closePreviewMode=function(){return element.parents(".markdown").find(".preview").remove(),element.parents(".markItUp").show()},$scope.$on("markdown-editor:submit",function(){return closePreviewMode()}),cancelablePromise=null,preview=function(){var markItUpDomNode,markdownDomNode;return markdownDomNode=element.parents(".markdown"),markItUpDomNode=element.parents(".markItUp"),$rs.mdrender.render($scope.projectId,$model.$modelValue).then(function(data){var html,markdown;return html=previewTemplate({data:data.data}),html=$compile(html)($scope),markdownDomNode.append(html),markItUpDomNode.hide(),markdown=element.closest(".markdown"),markdown.on("mouseup.preview",".preview",function(event){var target;return event.preventDefault(),target=angular.element(event.target),target.is("a")||!$selectedText.get().length?(markdown.off(".preview"),closePreviewMode()):void 0})})},setCaretPosition=function(textarea,caretPosition){var line,range,scrollRelation,totalLines;return textarea.createTextRange?(range=textarea.createTextRange(),range.move("character",caretPosition),range.select()):textarea.selectionStart&&(textarea.focus(),textarea.setSelectionRange(caretPosition,caretPosition)),totalLines=textarea.value.split("\n").length,line=textarea.value.slice(0,+(caretPosition-1)+1||9e9).split("\n").length,scrollRelation=line/totalLines,$el.scrollTop(scrollRelation*$el[0].scrollHeight-$el.height()/2)},addLine=function(textarea,nline,replace){var cursorPosition,j,key,len,line,lines;for(lines=textarea.value.split("\n"),replace?lines[nline]=replace+lines[nline]:lines[nline]="",cursorPosition=0,key=j=0,len=lines.length;len>j&&(line=lines[key],cursorPosition+=line.length+1||1,key!==nline);key=++j);return textarea.value=lines.join("\n"),replace?cursorPosition-lines[nline].length+replace.length-1:cursorPosition},prepareUrlFormatting=function(markItUp){var indices,regex,result;for(regex=/(<<<|>>>)/gi,result=0,indices=[];result=regex.exec(markItUp.textarea.value);)indices.push(result.index);return markItUp.donotparse=indices},urlFormatting=function(markItUp){var endIndex,ref,ref1,regex,result,startIndex,url,value;for(regex=/<<>>/gi,endIndex=0;;){if(result=regex.exec(markItUp.textarea.value),!result)break;if(ref1=result.index,indexOf.call(markItUp.donotparse,ref1)<0){endIndex=result.index;break}}return value=markItUp.textarea.value,url=value.substring(startIndex,endIndex).replace("<<<","").replace(">>>",""),url=url.replace("(","%28").replace(")","%29"),url=url.replace("[","%5B").replace("]","%5D"),value=value.substring(0,startIndex)+url+value.substring(endIndex+3,value.length),markItUp.textarea.value=value,markItUp.donotparse=void 0}},markdownTitle=function(markItUp,char){var heading,i,j,n,ref;for(heading="",n=$.trim(markItUp.selection||markItUp.placeHolder).length,i=j=0,ref=n-1;ref>=0?ref>=j:j>=ref;i=ref>=0?++j:--j)heading+=char; -return"\n"+heading+"\n"},renderMarkItUp=function(){var markdownSettings;return markdownSettings={nameSpace:"markdown",onShiftEnter:{keepDefault:!1,openWith:"\n\n"},onEnter:{keepDefault:!1,replaceWith:function(){return $(".textcomplete-dropdown").is(":visible")?void 0:"\n"},afterInsert:function(data){var cursorLine,emptyListItem,lastLine,lines,markdownCaretPositon,match,newLineContent,nline,replace;return lines=data.textarea.value.split("\n"),cursorLine=data.caretPosition>0?data.textarea.value.slice(0,+(data.caretPosition-1)+1||9e9).split("\n").length:1,newLineContent=data.textarea.value.slice(data.caretPosition).split("\n")[0],lastLine=lines[cursorLine-1],match=lastLine.match(/^(\s*- ).*/),match&&(emptyListItem=lastLine.match(/^(\s*)\-\s$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=""+match[1]),markdownCaretPositon=addLine(data.textarea,nline,replace)),match=lastLine.match(/^(\s*\* ).*/),match&&(emptyListItem=lastLine.match(/^(\s*\* )$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=""+match[1]),markdownCaretPositon=addLine(data.textarea,nline,replace)),match=lastLine.match(/^(\s*)(\d+)\.\s/),match&&(emptyListItem=lastLine.match(/^(\s*)(\d+)\.\s$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=match[1]+(parseInt(match[2],10)+1)+". "),markdownCaretPositon=addLine(data.textarea,nline,replace)),markdownCaretPositon?setCaretPosition(data.textarea,markdownCaretPositon):void 0}},markupSet:[{name:$translate.instant("COMMON.WYSIWYG.H1_BUTTON"),key:"1",placeHolder:$translate.instant("COMMON.WYSIWYG.H1_SAMPLE_TEXT"),closeWith:function(markItUp){return markdownTitle(markItUp,"=")}},{name:$translate.instant("COMMON.WYSIWYG.H2_BUTTON"),key:"2",placeHolder:$translate.instant("COMMON.WYSIWYG.H2_SAMPLE_TEXT"),closeWith:function(markItUp){return markdownTitle(markItUp,"-")}},{name:$translate.instant("COMMON.WYSIWYG.H3_BUTTON"),key:"3",openWith:"### ",placeHolder:$translate.instant("COMMON.WYSIWYG.H3_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.BOLD_BUTTON"),key:"B",openWith:"**",closeWith:"**",placeHolder:$translate.instant("COMMON.WYSIWYG.BOLD_BUTTON_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT"),key:"I",openWith:"_",closeWith:"_",placeHolder:$translate.instant("COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.STRIKE_BUTTON"),key:"S",openWith:"~~",closeWith:"~~",placeHolder:$translate.instant("COMMON.WYSIWYG.STRIKE_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.BULLETED_LIST_BUTTON"),openWith:"- ",placeHolder:$translate.instant("COMMON.WYSIWYG.BULLETED_LIST_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.NUMERIC_LIST_BUTTON"),openWith:function(markItUp){return markItUp.line+". "},placeHolder:$translate.instant("COMMON.WYSIWYG.NUMERIC_LIST_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.PICTURE_BUTTON"),key:"P",openWith:"![",closeWith:'](<<<[![Url:!:http://]!]>>> "[![Title]!]")',placeHolder:$translate.instant("COMMON.WYSIWYG.PICTURE_SAMPLE_TEXT"),beforeInsert:function(markItUp){return prepareUrlFormatting(markItUp)},afterInsert:function(markItUp){return urlFormatting(markItUp)}},{name:$translate.instant("COMMON.WYSIWYG.LINK_BUTTON"),key:"L",openWith:"[",closeWith:'](<<<[![Url:!:http://]!]>>> "[![Title]!]")',placeHolder:$translate.instant("COMMON.WYSIWYG.LINK_SAMPLE_TEXT"),beforeInsert:function(markItUp){return prepareUrlFormatting(markItUp)},afterInsert:function(markItUp){return urlFormatting(markItUp)}},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.QUOTE_BLOCK_BUTTON"),openWith:"> ",placeHolder:$translate.instant("COMMON.WYSIWYG.QUOTE_BLOCK_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.CODE_BLOCK_BUTTON"),openWith:"```\n",placeHolder:$translate.instant("COMMON.WYSIWYG.CODE_BLOCK_SAMPLE_TEXT"),closeWith:"\n```"},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.PREVIEW_BUTTON"),call:preview,className:"preview-icon"}],afterInsert:function(event){var target;return target=angular.element(event.textarea),$model.$setViewValue(target.val())}},element.markItUpRemove().markItUp(markdownSettings).textcomplete([{cache:!0,match:/(^|\s)#([a-z0-9]+)$/i,search:function(term,callback){var filter,searchProps,searchTypes;return term=taiga.slugify(term),searchTypes=["issues","tasks","userstories"],searchProps=["ref","subject"],filter=function(_this){return function(item){var j,len,prop;for(j=0,len=searchProps.length;len>j;j++)if(prop=searchProps[j],taiga.slugify(item[prop]).indexOf(term)>=0)return!0;return!1}}(this),cancelablePromise&&cancelablePromise.abort(),cancelablePromise=$rs.search["do"]($scope.projectId,term),cancelablePromise.then(function(_this){return function(res){var j,len,results,type;if(res.count<1||res.count===res.wikipages.length)return callback([]);for(results=[],j=0,len=searchTypes.length;len>j;j++)type=searchTypes[j],res[type]&&res[type].length>0?results.push(callback(res[type].filter(filter),!0)):results.push(void 0);return results}}(this)),callback([])},replace:function(res){return"$1#"+res.ref+" "},template:function(res,term){return"#"+res.ref+" - "+res.subject}},{cache:!0,match:/(^|\s)@([a-z0-9\-\._]{2,})$/i,search:function(term,callback){var searchProps,username;return username=taiga.slugify(term),searchProps=["username","full_name","full_name_display"],callback($scope.project.members.length<1?[]:$scope.project.members.filter(function(_this){return function(user){var j,len,prop;for(j=0,len=searchProps.length;len>j;j++)if(prop=searchProps[j],taiga.slugify(user[prop]).indexOf(username)>=0)return!0;return!1}}(this)))},replace:function(user){return"$1@"+user.username+" "},template:function(user){return user.username+" - "+user.full_name_display}},{cache:!0,match:/(^|\s)\[\[([a-z0-9\-]+)$/i,search:function(term,callback){return term=taiga.slugify(term),$rs.search["do"]($scope.projectId,term).then(function(_this){return function(res){return res.count<1&&callback([]),res.count<1||!res.wikipages||res.wikipages.length<=0?callback([]):callback(res.wikipages.filter(function(page){return taiga.slugify(page.slug).indexOf(term)>=0}),!0),callback([])}}(this))},replace:function(res){return"$1[["+res.slug+"]]"},template:function(res,term){return res.slug}}],{debounce:200})},renderMarkItUp(),unbind=$rootscope.$on("$translateChangeEnd",renderMarkItUp),element.on("keypress",function(event){return $scope.$apply()}),$scope.$on("$destroy",function(){return $el.off(),unbind()})},{link:link,require:"ngModel"}},module.directive("tgMarkitup",["$rootScope","$tgResources","$selectedText","$tgTemplate","$compile","$translate",MarkitupDirective])}.call(this),function(){var BacklogFiltersDirective,bindOnce,debounceLeading,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,debounceLeading=this.taiga.debounceLeading,module=angular.module("taigaBacklog"),BacklogFiltersDirective=function($q,$log,$location,$templates){var link,template,templateSelected;return template=$templates.get("backlog/filters.html",!0),templateSelected=$templates.get("backlog/filter-selected.html",!0),link=function($scope,$el,$attrs){var $ctrl,currentFiltersType,getFiltersType,initializeSelectedFilters,reloadUserstories,renderFilters,renderSelectedFilters,selectQFilter,selectedFilters,showCategories,showFilters,toggleFilterSelection;return currentFiltersType="",$ctrl=$el.closest(".wrapper").controller(),selectedFilters=[],showFilters=function(title,type){return $el.find(".filters-cats").hide(),$el.find(".filter-list").removeClass("hidden"),$el.find("h2.breadcrumb").removeClass("hidden"),$el.find("h2 a.subfilter span.title").html(title),$el.find("h2 a.subfilter span.title").prop("data-type",type),currentFiltersType=getFiltersType()},showCategories=function(){return $el.find(".filters-cats").show(),$el.find(".filter-list").addClass("hidden"),$el.find("h2.breadcrumb").addClass("hidden")},initializeSelectedFilters=function(){var i,len,name,ref,val,values;showCategories(),selectedFilters=[],ref=$scope.filters;for(name in ref)for(values=ref[name],i=0,len=values.length;len>i;i++)val=values[i],val.selected&&selectedFilters.push(val);return renderSelectedFilters()},renderSelectedFilters=function(){var html;return _.map(selectedFilters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=templateSelected({filters:selectedFilters}),$el.find(".filters-applied").html(html)},renderFilters=function(filters){var html;return _.map(filters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=template({filters:filters}),$el.find(".filter-list").html(html)},getFiltersType=function(){return $el.find("h2 a.subfilter span.title").prop("data-type")},reloadUserstories=function(){return currentFiltersType=getFiltersType(),$q.all([$ctrl.loadUserstories(),$ctrl.generateFilters()]).then(function(){var currentFilters;return currentFilters=$scope.filters[currentFiltersType],renderFilters(_.reject(currentFilters,"selected"))})},toggleFilterSelection=function(type,id){var filter,filters;return currentFiltersType=getFiltersType(),filters=$scope.filters[type],filter=_.find(filters,{id:id}),filter.selected=!filter.selected,filter.selected?(selectedFilters.push(filter),$scope.$apply(function(){return $ctrl.selectFilter(type,id)})):(selectedFilters=_.reject(selectedFilters,function(selected){return filter.type===selected.type&&filter.id===selected.id}),$ctrl.unselectFilter(type,id)),renderSelectedFilters(selectedFilters),type===currentFiltersType&&renderFilters(_.reject(filters,"selected")),reloadUserstories()},selectQFilter=debounceLeading(100,function(value){return void 0!==value?(0===value.length?$ctrl.replaceFilter("q",null):$ctrl.replaceFilter("q",value),reloadUserstories()):void 0}),$scope.$watch("filtersQ",selectQFilter),$scope.$on("backlog:loaded",function(ctx){return initializeSelectedFilters()}),$scope.$on("filters:update",function(ctx){return $ctrl.generateFilters().then(function(){var filters;return filters=$scope.filters[currentFiltersType],currentFiltersType?renderFilters(_.reject(filters,"selected")):void 0})}),$el.on("click",".filters-cats > ul > li > a",function(event){var tags,target;return event.preventDefault(),target=angular.element(event.currentTarget),tags=$scope.filters[target.data("type")],renderFilters(_.reject(tags,"selected")),showFilters(target.attr("title"),target.data("type"))}),$el.on("click",".filters-inner > .filters-step-cat > .breadcrumb > .back",function(event){return event.preventDefault(),showCategories()}),$el.on("click",".filters-applied a",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),id=target.data("id"),type=target.data("type"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),target.hasClass("active")?target.removeClass("active"):target.addClass("active"),id=target.data("id"),type=target.data("type"),toggleFilterSelection(type,id)})},{link:link}},module.directive("tgBacklogFilters",["$q","$log","$tgLocation","$tgTemplate",BacklogFiltersDirective])}.call(this),function(){var CreateEditSprint,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaBacklog"),CreateEditSprint=function($repo,$confirm,$rs,$rootscope,lightboxService,$loading,$translate){var link;return link=function($scope,$el,attrs){var createSprint,getLastSprint,hasErrors,remove,resetSprint,submit;return hasErrors=!1,createSprint=!0,resetSprint=function(){return $scope.sprint={project:null,name:null,estimated_start:null,estimated_finish:null}},submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,newSprint,prettyDate,promise,submitButton,target;return event.preventDefault(),target=angular.element(event.currentTarget),prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),submitButton=$el.find(".submit-button"),form=$el.find("form").checksley(),form.validate()?(hasErrors=!1,newSprint=angular.copy($scope.sprint),broadcastEvent=null,createSprint?(newSprint.estimated_start=moment(newSprint.estimated_start,prettyDate).format("YYYY-MM-DD"),newSprint.estimated_finish=moment(newSprint.estimated_finish,prettyDate).format("YYYY-MM-DD"),promise=$repo.create("milestones",newSprint),broadcastEvent="sprintform:create:success"):(newSprint.setAttr("estimated_start",moment(newSprint.estimated_start,prettyDate).format("YYYY-MM-DD")),newSprint.setAttr("estimated_finish",moment(newSprint.estimated_finish,prettyDate).format("YYYY-MM-DD")),promise=$repo.save(newSprint),broadcastEvent="sprintform:edit:success"),currentLoading=$loading().target(submitButton).start(),promise.then(function(data){return currentLoading.finish(),createSprint&&($scope.sprintsCounter+=1),$rootscope.$broadcast(broadcastEvent,data),lightboxService.close($el)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("light-error",data._error_message):data.__all__?$confirm.notify("light-error",data.__all__[0]):void 0})):(hasErrors=!0,void $el.find(".last-sprint-name").addClass("disappear"))}}(this)),remove=function(){var message,title;return title=$translate.instant("LIGHTBOX.DELETE_SPRINT.TITLE"),message=$scope.sprint.name,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onSuccess=function(){return askResponse.finish(),$scope.milestonesCounter-=1,lightboxService.close($el),$rootscope.$broadcast("sprintform:remove:success",$scope.sprint)},onError=function(){return askResponse.finish(!1),$confirm.notify("error")},$repo.remove($scope.sprint).then(onSuccess,onError)}}(this))},getLastSprint=function(){var openSprints,sortedSprints;return openSprints=_.filter($scope.sprints,function(sprint){return!sprint.closed}),sortedSprints=_.sortBy(openSprints,function(sprint){return moment(sprint.estimated_finish,"YYYY-MM-DD").format("X")}),sortedSprints[sortedSprints.length-1]},$scope.$on("sprintform:create",function(event,projectId){var estimatedFinish,estimatedStart,form,lastSprint,lastSprintNameDom,prettyDate,text;return resetSprint(),form=$el.find("form").checksley(),form.reset(),createSprint=!0,prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),$scope.sprint.project=projectId,$scope.sprint.name=null,$scope.sprint.slug=null,lastSprint=getLastSprint(),estimatedStart=moment(),lastSprint?estimatedStart=moment(lastSprint.estimated_finish):$scope.sprint.estimated_start&&(estimatedStart=moment($scope.sprint.estimated_start)),$scope.sprint.estimated_start=estimatedStart.format(prettyDate),estimatedFinish=moment().add(2,"weeks"),lastSprint?estimatedFinish=moment(lastSprint.estimated_finish).add(2,"weeks"):$scope.sprint.estimated_finish&&(estimatedFinish=moment($scope.sprint.estimated_finish)),$scope.sprint.estimated_finish=estimatedFinish.format(prettyDate),lastSprintNameDom=$el.find(".last-sprint-name"),null!=(null!=lastSprint?lastSprint.name:void 0)&&(text=$translate.instant("LIGHTBOX.ADD_EDIT_SPRINT.LAST_SPRINT_NAME",{lastSprint:lastSprint.name}),lastSprintNameDom.html(text)),$el.find(".delete-sprint").addClass("hidden"),text=$translate.instant("LIGHTBOX.ADD_EDIT_SPRINT.TITLE"),$el.find(".title").text(text),text=$translate.instant("COMMON.CREATE"),$el.find(".button-green").text(text),lightboxService.open($el),$el.find(".sprint-name").focus(),$el.find(".last-sprint-name").removeClass("disappear")}),$scope.$on("sprintform:edit",function(ctx,sprint){var editSprint,prettyDate,save;return resetSprint(),createSprint=!1,prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),$scope.$apply(function(){return $scope.sprint=sprint,$scope.sprint.estimated_start=moment($scope.sprint.estimated_start).format(prettyDate),$scope.sprint.estimated_finish=moment($scope.sprint.estimated_finish).format(prettyDate)}),$el.find(".delete-sprint").removeClass("hidden"),editSprint=$translate.instant("BACKLOG.EDIT_SPRINT"),$el.find(".title").text(editSprint),save=$translate.instant("COMMON.SAVE"),$el.find(".button-green").text(save),lightboxService.open($el),$el.find(".sprint-name").focus().select(),$el.find(".last-sprint-name").addClass("disappear")}),$el.on("keyup",".sprint-name",function(event){return $el.find(".sprint-name").val().length>0||hasErrors?$el.find(".last-sprint-name").addClass("disappear"):$el.find(".last-sprint-name").removeClass("disappear")}),$el.on("submit","form",submit),$el.on("click",".delete-sprint .icon-delete",function(event){return event.preventDefault(),remove()}),$scope.$on("$destroy",function(){return $el.off()}),resetSprint()},{link:link}},module.directive("tgLbCreateEditSprint",["$tgRepo","$tgConfirm","$tgResources","$rootScope","lightboxService","$tgLoading","$translate",CreateEditSprint])}.call(this),function(){var BacklogController,BacklogDirective,BurndownBacklogGraphDirective,TgBacklogProgressBarDirective,ToggleBurndownVisibility,UsPointsDirective,UsRolePointsSelectorDirective,bindMethods,bindOnce,generateHash,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,generateHash=this.taiga.generateHash,module=angular.module("taigaBacklog"),BacklogController=function(superClass){function BacklogController(scope1,rootscope,repo,confirm,rs,params1,q,location,appMetaService,navUrls,events,analytics,translate,loading,rs2){var promise;this.scope=scope1,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params1,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,this.loading=loading,this.rs2=rs2,bindMethods(this),this.scope.sectionName=this.translate.instant("BACKLOG.SECTION_NAME"),this.showTags=!1,this.activeFilters=!1,this.scope.showGraphPlaceholder=null,this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("BACKLOG.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("BACKLOG.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description),_this.rs.userstories.getShowTags(_this.scope.projectId)?(_this.showTags=!0,_this.scope.$broadcast("showTags",_this.showTags)):void 0}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(BacklogController,superClass),BacklogController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate","$tgLoading","tgResources"],BacklogController.prototype.initializeEventHandlers=function(){return this.scope.$on("usform:bulk:success",function(_this){return function(){return _this.loadUserstories(),_this.loadProjectStats(),_this.analytics.trackEvent("userstory","create","bulk create userstory on backlog",1)}}(this)),this.scope.$on("sprintform:create:success",function(_this){return function(){return _this.loadSprints(),_this.loadProjectStats(),_this.analytics.trackEvent("sprint","create","create sprint on backlog",1)}}(this)),this.scope.$on("usform:new:success",function(_this){return function(){return _this.loadUserstories(),_this.loadProjectStats(),_this.rootscope.$broadcast("filters:update"),_this.analytics.trackEvent("userstory","create","create userstory on backlog",1)}}(this)),this.scope.$on("sprintform:edit:success",function(_this){return function(){return _this.loadProjectStats()}}(this)),this.scope.$on("sprintform:remove:success",function(_this){return function(event,sprint){return _this.loadSprints(),_this.loadProjectStats(),_this.loadUserstories(),sprint.closed&&_this.loadClosedSprints(),_this.rootscope.$broadcast("filters:update")}}(this)),this.scope.$on("usform:edit:success",function(_this){return function(){return _this.loadUserstories(),_this.rootscope.$broadcast("filters:update")}}(this)),this.scope.$on("sprint:us:move",this.moveUs),this.scope.$on("sprint:us:moved",this.loadSprints),this.scope.$on("sprint:us:moved",this.loadProjectStats),this.scope.$on("backlog:load-closed-sprints",this.loadClosedSprints),this.scope.$on("backlog:unload-closed-sprints",this.unloadClosedSprints)},BacklogController.prototype.initializeSubscription=function(){var routingKey1,routingKey2;return routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.loadUserstories(),_this.loadSprints()}}(this)),routingKey2="changes.project."+this.scope.projectId+".milestones",this.events.subscribe(this.scope,routingKey2,function(_this){return function(message){return _this.loadSprints()}}(this))},BacklogController.prototype.toggleShowTags=function(){return this.scope.$apply(function(_this){return function(){return _this.showTags=!_this.showTags,_this.rs.userstories.storeShowTags(_this.scope.projectId,_this.showTags)}}(this))},BacklogController.prototype.toggleActiveFilters=function(){return this.activeFilters=!this.activeFilters},BacklogController.prototype.loadProjectStats=function(){return this.rs.projects.stats(this.scope.projectId).then(function(_this){return function(stats){var totalPoints;return _this.scope.stats=stats,totalPoints=stats.total_points?stats.total_points:stats.defined_points,totalPoints?_this.scope.stats.completedPercentage=Math.round(100*stats.closed_points/totalPoints):_this.scope.stats.completedPercentage=0,_this.scope.showGraphPlaceholder=!(null!=stats.total_points&&null!=stats.total_milestones),stats}}(this))},BacklogController.prototype.unloadClosedSprints=function(){return this.scope.$apply(function(_this){return function(){return _this.scope.closedSprints=[],_this.rootscope.$broadcast("closed-sprints:reloaded",[])}}(this))},BacklogController.prototype.loadClosedSprints=function(){var params;return params={closed:!0},this.rs.sprints.list(this.scope.projectId,params).then(function(_this){return function(result){var j,len,sprint,sprints;for(sprints=result.milestones,_this.scope.totalClosedMilestones=result.closed,j=0,len=sprints.length;len>j;j++)sprint=sprints[j],sprint.user_stories=_.sortBy(sprint.user_stories,"sprint_order");return _this.scope.closedSprints=sprints,_this.scope.closedSprintsById=groupBy(sprints,function(x){return x.id}),_this.rootscope.$broadcast("closed-sprints:reloaded",sprints),sprints}}(this))},BacklogController.prototype.loadSprints=function(){var params;return params={closed:!1},this.rs.sprints.list(this.scope.projectId,params).then(function(_this){return function(result){var j,len,sprint,sprints;for(sprints=result.milestones,_this.scope.totalMilestones=sprints,_this.scope.totalClosedMilestones=result.closed,_this.scope.totalOpenMilestones=result.open,_this.scope.totalMilestones=_this.scope.totalOpenMilestones+_this.scope.totalClosedMilestones,j=0,len=sprints.length;len>j;j++)sprint=sprints[j],sprint.user_stories=_.sortBy(sprint.user_stories,"sprint_order");return _this.scope.sprints=sprints,_this.scope.openSprints=_.filter(sprints,function(sprint){return!sprint.closed}).reverse(),_this.scope.closedSprints||(_this.scope.closedSprints=[]),_this.scope.sprintsCounter=sprints.length,_this.scope.sprintsById=groupBy(sprints,function(x){return x.id}),_this.rootscope.$broadcast("sprints:loaded",sprints),_this.scope.currentSprint=_this.findCurrentSprint(),sprints}}(this))},BacklogController.prototype.restoreFilters=function(){var selectedStatuses,selectedTags;return selectedTags=this.scope.oldSelectedTags,selectedStatuses=this.scope.oldSelectedStatuses,selectedStatuses||selectedStatuses?(this.scope.filtersQ=this.scope.filtersQOld,this.replaceFilter("q",this.scope.filtersQ),_.each([selectedTags,selectedStatuses],function(_this){return function(filterGrp){return _.each(filterGrp,function(item){var filter,filters;return filters=_this.scope.filters[item.type],filter=_.find(filters,{id:item.id}),filter.selected=!0,_this.selectFilter(item.type,item.id)})}}(this)),this.loadUserstories()):void 0},BacklogController.prototype.resetFilters=function(){var selectedStatuses,selectedTags;return selectedTags=_.filter(this.scope.filters.tags,"selected"),selectedStatuses=_.filter(this.scope.filters.status,"selected"),this.scope.oldSelectedTags=selectedTags,this.scope.oldSelectedStatuses=selectedStatuses,this.scope.filtersQOld=this.scope.filtersQ,this.scope.filtersQ=void 0,this.replaceFilter("q",this.scope.filtersQ),_.each([selectedTags,selectedStatuses],function(_this){return function(filterGrp){return _.each(filterGrp,function(item){var filter,filters;return filters=_this.scope.filters[item.type],filter=_.find(filters,{id:item.id}),filter.selected=!1,_this.unselectFilter(item.type,item.id)})}}(this)),this.loadUserstories()},BacklogController.prototype.loadUserstories=function(){var promise;return this.scope.httpParams=this.getUrlFilters(),this.rs.userstories.storeQueryParams(this.scope.projectId,this.scope.httpParams),promise=this.rs.userstories.listUnassigned(this.scope.projectId,this.scope.httpParams),promise.then(function(_this){return function(userstories){return _this.scope.userstories=_.sortBy(userstories,"backlog_order"),_this.setSearchDataFilters(),scopeDefer(_this.scope,function(){return _this.scope.$broadcast("userstories:loaded")}),userstories}}(this))},BacklogController.prototype.loadBacklog=function(){return this.q.all([this.loadProjectStats(),this.loadSprints(),this.loadUserstories()])},BacklogController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_backlog_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.closedMilestones=!!project.total_closed_milestones,_this.scope.$emit("project:loaded",project),_this.scope.points=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.usStatusList=_.sortBy(project.us_statuses,"id"),project}}(this))},BacklogController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription()}}(this)),promise.then(function(_this){return function(){return _this.loadBacklog()}}(this)).then(function(_this){return function(){return _this.generateFilters()}}(this)).then(function(_this){return function(){return _this.scope.$emit("backlog:loaded")}}(this))},BacklogController.prototype.prepareBulkUpdateData=function(uses,field){return null==field&&(field="backlog_order"),_.map(uses,function(x){return{us_id:x.id,order:x[field]}})},BacklogController.prototype.resortUserStories=function(uses,field){var index,item,items,j,len;for(null==field&&(field="backlog_order"),items=[],index=j=0,len=uses.length;len>j;index=++j)item=uses[index],item[field]=index,item.isModified()&&items.push(item);return items},BacklogController.prototype.moveUs=function(ctx,usList,newUsIndex,newSprintId){var data,items,j,l,len,len1,len2,m,movedFromClosedSprint,movedToClosedSprint,newSprint,oldSprintId,project,promise,promises,sprint,us,userstories;if(oldSprintId=usList[0].milestone,project=usList[0].project,movedFromClosedSprint=!1,movedToClosedSprint=!1,sprint=this.scope.sprintsById[oldSprintId],!sprint&&this.scope.closedSprintsById&&(sprint=this.scope.closedSprintsById[oldSprintId],sprint&&(movedFromClosedSprint=!0)),newSprint=this.scope.sprintsById[newSprintId],!newSprint&&newSprintId&&(newSprint=this.scope.closedSprintsById[newSprintId],newSprint&&(movedToClosedSprint=!0)),newSprintId===oldSprintId)return items=null,userstories=null,userstories=null===newSprintId?this.scope.userstories:newSprint.user_stories,this.scope.$apply(function(){var args,j,key,len,r,us;for(key=j=0,len=usList.length;len>j;key=++j)us=usList[key],r=userstories.indexOf(us),userstories.splice(r,1);return args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(userstories,args)}),null===newSprintId?(items=this.resortUserStories(userstories,"backlog_order"),data=this.prepareBulkUpdateData(items,"backlog_order"),this.rs.userstories.bulkUpdateBacklogOrder(project,data).then(function(_this){return function(){var j,len,results,us;for(results=[],j=0,len=usList.length;len>j;j++)us=usList[j],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}}(this))):(items=this.resortUserStories(userstories,"sprint_order"),data=this.prepareBulkUpdateData(items,"sprint_order"),this.rs.userstories.bulkUpdateSprintOrder(project,data).then(function(_this){return function(){var j,len,results,us;for(results=[],j=0,len=usList.length;len>j;j++)us=usList[j],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}}(this))),promise;if(null===newSprintId){for(j=0,len=usList.length;len>j;j++)us=usList[j],us.milestone=null;return this.scope.$apply(function(_this){return function(){var args,key,l,len1,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(_this.scope.userstories,args),results=[],key=l=0,len1=usList.length;len1>l;key=++l)us=usList[key],r=sprint.user_stories.indexOf(us),results.push(sprint.user_stories.splice(r,1));return results}}(this)),promise=this.repo.save(us),promise=promise.then(function(_this){return function(){return items=_this.resortUserStories(_this.scope.userstories,"backlog_order"),data=_this.prepareBulkUpdateData(items,"backlog_order"),_this.rs.userstories.bulkUpdateBacklogOrder(us.project,data).then(function(){return _this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId),movedFromClosedSprint?_this.rootscope.$broadcast("backlog:load-closed-sprints"):void 0})}}(this)),promise.then(null,function(){return console.log("FAIL")}),promise}if(null===oldSprintId){for(l=0,len1=usList.length;len1>l;l++)us=usList[l],us.milestone=newSprintId;this.scope.$apply(function(_this){return function(){var args,key,len2,m,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(newSprint.user_stories,args),results=[],key=m=0,len2=usList.length;len2>m;key=++m)us=usList[key],r=_this.scope.userstories.indexOf(us),results.push(_this.scope.userstories.splice(r,1));return results}}(this))}else{for(m=0,len2=usList.length;len2>m;m++)us=usList[m],us.milestone=newSprintId;this.scope.$apply(function(_this){return function(){var args,len3,n,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(newSprint.user_stories,args),results=[],n=0,len3=usList.length;len3>n;n++)us=usList[n],r=sprint.user_stories.indexOf(us),results.push(sprint.user_stories.splice(r,1));return results}}(this))}return promises=_.map(usList,function(_this){return function(us){return _this.repo.save(us)}}(this)),promise=this.q.all(promises).then(function(_this){return function(){return items=_this.resortUserStories(newSprint.user_stories,"sprint_order"), -data=_this.prepareBulkUpdateData(items,"sprint_order"),_this.rs.userstories.bulkUpdateSprintOrder(project,data).then(function(result){return _this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId)}),_this.rs.userstories.bulkUpdateBacklogOrder(project,data).then(function(){var len3,n,results;for(results=[],n=0,len3=usList.length;len3>n;n++)us=usList[n],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}),movedToClosedSprint||movedFromClosedSprint?_this.scope.$broadcast("backlog:load-closed-sprints"):void 0}}(this)),promise.then(null,function(){return console.log("FAIL")}),promise},BacklogController.prototype.isFilterSelected=function(type,id){return null!=this.searchdata[type]&&this.searchdata[type][id]?!0:!1},BacklogController.prototype.setSearchDataFilters=function(){var name,results,urlfilters,val,value;urlfilters=this.getUrlFilters(),urlfilters.q&&(this.scope.filtersQ=this.scope.filtersQ||urlfilters.q),this.searchdata={},results=[];for(name in urlfilters)value=urlfilters[name],null==this.searchdata[name]&&(this.searchdata[name]={}),results.push(function(){var j,len,ref1,results1;for(ref1=taiga.toString(value).split(","),results1=[],j=0,len=ref1.length;len>j;j++)val=ref1[j],results1.push(this.searchdata[name][val]=!0);return results1}.call(this));return results},BacklogController.prototype.getUrlFilters=function(){return _.pick(this.location.search(),"status","tags","q")},BacklogController.prototype.generateFilters=function(){var loadFilters,urlfilters;return urlfilters=this.getUrlFilters(),this.scope.filters={},loadFilters={},loadFilters.project=this.scope.projectId,loadFilters.tags=urlfilters.tags,loadFilters.status=urlfilters.status,loadFilters.q=urlfilters.q,loadFilters.milestone="null",this.rs.userstories.filtersData(loadFilters).then(function(_this){return function(data){var choicesFiltersFormat,selectedStatuses,selectedTags,tagsFilterFormat;return choicesFiltersFormat=function(choices,type,byIdObject){return _.map(choices,function(t){return t.type=type,t})},tagsFilterFormat=function(tags){return _.map(tags,function(t){return t.id=t.name,t.type="tags",t})},_this.scope.filters.status=choicesFiltersFormat(data.statuses,"status",_this.scope.usStatusById),_this.scope.filters.tags=tagsFilterFormat(data.tags),selectedTags=_.filter(_this.scope.filters.tags,"selected"),selectedTags=_.map(selectedTags,"id"),selectedStatuses=_.filter(_this.scope.filters.status,"selected"),selectedStatuses=_.map(selectedStatuses,"id"),_this.markSelectedFilters(_this.scope.filters,urlfilters),_this.rs.userstories.storeQueryParams(_this.scope.projectId,{status:selectedStatuses,tags:selectedTags,project:_this.scope.projectId,milestone:null})}}(this))},BacklogController.prototype.markSelectedFilters=function(filters,urlfilters){var isSelected,j,key,len,name,obj,ref1,ref2,results,searchdata,val,value;searchdata={},ref1=_.omit(urlfilters,"page","orderBy");for(name in ref1)for(value=ref1[name],null==searchdata[name]&&(searchdata[name]={}),ref2=(""+value).split(","),j=0,len=ref2.length;len>j;j++)val=ref2[j],searchdata[name][val]=!0;isSelected=function(type,id){return null!=searchdata[type]&&searchdata[type][id]?!0:!1},results=[];for(key in filters)value=filters[key],results.push(function(){var l,len1,results1;for(results1=[],l=0,len1=value.length;len1>l;l++)obj=value[l],results1.push(obj.selected=isSelected(obj.type,obj.id)?!0:void 0);return results1}());return results},BacklogController.prototype.updateUserStoryStatus=function(){return this.setSearchDataFilters(),this.generateFilters().then(function(_this){return function(){return _this.rootscope.$broadcast("filters:update"),_this.loadProjectStats()}}(this))},BacklogController.prototype.editUserStory=function(projectId,ref,$event){var currentLoading,target;return target=$($event.target),currentLoading=this.loading().target(target).removeClasses("icon-edit").timeout(200).start(),this.rs.userstories.getByRef(projectId,ref).then(function(_this){return function(us){return _this.rs2.attachments.list("us",us.id,projectId).then(function(attachments){return _this.rootscope.$broadcast("usform:edit",us,attachments.toJS()),currentLoading.finish()})}}(this))},BacklogController.prototype.deleteUserStory=function(us){var message,title;return title=this.translate.instant("US.TITLE_DELETE_ACTION"),message=us.subject,this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var promise;return _this.scope.userstories=_.without(_this.scope.userstories,us),promise=_this.repo.remove(us),promise.then(function(){return askResponse.finish(),_this.loadBacklog()}),promise.then(null,function(){return askResponse.finish(!1),_this.confirm.notify("error")})}}(this))},BacklogController.prototype.addNewUs=function(type){switch(type){case"standard":return this.rootscope.$broadcast("usform:new",this.scope.projectId,this.scope.project.default_us_status,this.scope.usStatusList);case"bulk":return this.rootscope.$broadcast("usform:bulk",this.scope.projectId,this.scope.project.default_us_status)}},BacklogController.prototype.addNewSprint=function(){return this.rootscope.$broadcast("sprintform:create",this.scope.projectId)},BacklogController.prototype.findCurrentSprint=function(){var currentDate;return currentDate=(new Date).getTime(),_.find(this.scope.sprints,function(sprint){var end,start;return start=moment(sprint.estimated_start,"YYYY-MM-DD").format("x"),end=moment(sprint.estimated_finish,"YYYY-MM-DD").format("x"),currentDate>=start&&end>=currentDate})},BacklogController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("BacklogController",BacklogController),BacklogDirective=function($repo,$rootscope,$translate){var doomLineTemplate,link,linkDoomLine,linkFilters,linkToolbar,showHideFilter,showHideTags;return doomLineTemplate=_.template('
<%- text %>
'),linkDoomLine=function($scope,$el,$attrs,$ctrl){var addDoomLineDom,getUsItems,reloadDoomLine,removeDoomlineDom;return reloadDoomLine=function(){var current_sum,domElement,i,j,len,ref1,results,stats,total_points,us;if(null!=$scope.stats&&null!=$scope.stats.total_points&&0!==$scope.stats.total_points){if(removeDoomlineDom(),stats=$scope.stats,total_points=stats.total_points,current_sum=stats.assigned_points,!$scope.userstories)return;for(ref1=$scope.userstories,results=[],i=j=0,len=ref1.length;len>j;i=++j){if(us=ref1[i],current_sum+=us.total_points,current_sum>total_points){domElement=$el.find(".backlog-table-body .us-item-row")[i],addDoomLineDom(domElement);break}results.push(void 0)}return results}},removeDoomlineDom=function(){return $el.find(".doom-line").remove()},addDoomLineDom=function(element){var text;return text=$translate.instant("BACKLOG.DOOMLINE"),$(element).before(doomLineTemplate({text:text}))},getUsItems=function(){var rowElements;return rowElements=$el.find(".backlog-table-body .us-item-row"),_.map(rowElements,function(x){return angular.element(x)})},$scope.$on("userstories:loaded",reloadDoomLine),$scope.$watch("stats",reloadDoomLine)},linkToolbar=function($scope,$el,$attrs,$ctrl){var checkSelected,getUsToMove,lastChecked,moveToCurrentSprint,moveToLatestSprint,moveUssToSprint,shiftPressed;return getUsToMove=function(){var ussDom;return ussDom=$el.find(".backlog-table-body input:checkbox:checked"),_.map(ussDom,function(item){var itemScope;return item=$(item).closest(".tg-scope"),itemScope=item.scope(),itemScope.us.milestone=$scope.sprints[0].id,itemScope.us})},moveUssToSprint=function(selectedUss,sprint){var extraPoints,totalExtraPoints,ussCurrent;return ussCurrent=_($scope.userstories),$scope.userstories=ussCurrent.without.apply(ussCurrent,selectedUss).value(),extraPoints=_.map(selectedUss,function(v,k){return v.total_points}),totalExtraPoints=_.reduce(extraPoints,function(acc,num){return acc+num}),sprint.user_stories=_.union(sprint.user_stories,selectedUss),sprint.total_points+=totalExtraPoints,$repo.saveAll(selectedUss).then(function(){return $ctrl.loadSprints(),$ctrl.loadProjectStats()}),$el.find(".move-to-sprint").hide()},moveToCurrentSprint=function(selectedUss){return moveUssToSprint(selectedUss,$scope.currentSprint)},moveToLatestSprint=function(selectedUss){return moveUssToSprint(selectedUss,$scope.sprints[0])},shiftPressed=!1,lastChecked=null,checkSelected=function(target){var moveToSprintDom,selectedUsDom;return lastChecked=target.closest(".us-item-row"),target.closest(".us-item-row").toggleClass("ui-multisortable-multiple"),moveToSprintDom=$el.find(".move-to-sprint"),selectedUsDom=$el.find(".backlog-table-body input:checkbox:checked"),selectedUsDom.length>0&&$scope.sprints.length>0?moveToSprintDom.show():moveToSprintDom.hide()},$(window).on("keydown.shift-pressed keyup.shift-pressed",function(event){return shiftPressed=!!event.shiftKey,!0}),$el.on("change",".backlog-table-body input:checkbox",function(event){var current,elements,nextAll,prevAll,target;return lastChecked&&shiftPressed&&(elements=[],current=$(event.currentTarget).closest(".us-item-row"),nextAll=lastChecked.nextAll(),prevAll=lastChecked.prevAll(),_.some(nextAll,function(next){return next===current[0]})?elements=lastChecked.nextUntil(current):_.some(prevAll,function(prev){return prev===current[0]})&&(elements=lastChecked.prevUntil(current)),_.map(elements,function(elm){var input;return input=$(elm).find("input:checkbox"),input.prop("checked",!0),checkSelected(input)})),target=angular.element(event.currentTarget),target.closest(".us-item-row").toggleClass("is-checked"),checkSelected(target)}),$el.on("click","#move-to-latest-sprint",function(_this){return function(event){var ussToMove;return ussToMove=getUsToMove(),$scope.$apply(_.partial(moveToLatestSprint,ussToMove))}}(this)),$el.on("click","#move-to-current-sprint",function(_this){return function(event){var ussToMove;return ussToMove=getUsToMove(),$scope.$apply(_.partial(moveToCurrentSprint,ussToMove))}}(this)),$el.on("click","#show-tags",function(event){return event.preventDefault(),$ctrl.toggleShowTags(),showHideTags($ctrl)})},showHideTags=function($ctrl){var elm,text;return elm=angular.element("#show-tags"),$ctrl.showTags?(elm.addClass("active"),text=$translate.instant("BACKLOG.TAGS.HIDE"),elm.text(text)):(elm.removeClass("active"),text=$translate.instant("BACKLOG.TAGS.SHOW"),elm.text(text))},showHideFilter=function($scope,$el,$ctrl){var hideText,showText,sidebar,target;return sidebar=$el.find("sidebar.filters-bar"),sidebar.one("transitionend",function(){return timeout(150,function(){return $rootscope.$broadcast("resize"),$(".burndown").css("visibility","visible")})}),target=angular.element("#show-filters-button"),$(".burndown").css("visibility","hidden"),sidebar.toggleClass("active"),target.toggleClass("active"),hideText=$translate.instant("BACKLOG.FILTERS.HIDE"),showText=$translate.instant("BACKLOG.FILTERS.SHOW"),toggleText(target,[hideText,showText]),sidebar.hasClass("active")?$ctrl.restoreFilters():$ctrl.resetFilters(),$ctrl.toggleActiveFilters()},linkFilters=function($scope,$el,$attrs,$ctrl){return $scope.filtersSearch={},$el.on("click","#show-filters-button",function(event){return event.preventDefault(),$scope.$apply(function(){return showHideFilter($scope,$el,$ctrl)})})},link=function($scope,$el,$attrs,$rootscope){var $ctrl,filters;return $ctrl=$el.controller(),linkToolbar($scope,$el,$attrs,$ctrl),linkFilters($scope,$el,$attrs,$ctrl),linkDoomLine($scope,$el,$attrs,$ctrl),$el.find(".backlog-table-body").disableSelection(),filters=$ctrl.getUrlFilters(),(filters.status||filters.tags||filters.q)&&showHideFilter($scope,$el,$ctrl),$scope.$on("showTags",function(){return showHideTags($ctrl)}),$scope.$on("$destroy",function(){return $el.off(),$(window).off(".shift-pressed")})},{link:link}},module.directive("tgBacklog",["$tgRepo","$rootScope","$translate",BacklogDirective]),UsRolePointsSelectorDirective=function($rootscope,$template,$compile,$translate){var link,selectionTemplate;return selectionTemplate=$template.get("backlog/us-role-points-popover.html",!0),link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var numberOfRoles,roles;return roles=_.filter(project.roles,"computable"),numberOfRoles=_.size(roles),numberOfRoles>1?$el.append($compile(selectionTemplate({roles:roles}))($scope)):($el.find(".icon-arrow-bottom").remove(),$el.find(".header-points").addClass("not-clickable"))}),$scope.$on("uspoints:select",function(ctx,roleId,roleName){return $el.find(".popover").popover().close(),$el.find(".header-points").html(roleName+"/Total")}),$scope.$on("uspoints:clear-selection",function(ctx,roleId){var text;return $el.find(".popover").popover().close(),text=$translate.instant("COMMON.FIELDS.POINTS"),$el.find(".header-points").text(text)}),$el.on("click",function(event){var target;return target=angular.element(event.target),(target.is("span")||target.is("div"))&&event.stopPropagation(),$el.find(".popover").popover().open()}),$el.on("click",".clear-selection",function(event){return event.preventDefault(),event.stopPropagation(),$rootscope.$broadcast("uspoints:clear-selection")}),$el.on("click",".role",function(event){var rolScope,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),rolScope=target.scope(),$rootscope.$broadcast("uspoints:select",target.data("role-id"),target.text())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUsRolePointsSelector",["$rootScope","$tgTemplate","$compile",UsRolePointsSelectorDirective]),UsPointsDirective=function($tgEstimationsService,$repo,$tgTemplate){var link,rolesTemplate;return rolesTemplate=$tgTemplate.get("common/estimation/us-points-roles-popover.html",!0),link=function($scope,$el,$attrs){var $ctrl,bindClickElements,estimationProcess,filteringRoleId,renderRolesSelector,selectedRoleId,updatingSelectedRoleId;return $ctrl=$el.controller(),updatingSelectedRoleId=null,selectedRoleId=null,filteringRoleId=null,estimationProcess=null,$scope.$on("uspoints:select",function(ctx,roleId,roleName){var us;return us=$scope.$eval($attrs.tgBacklogUsPoints),selectedRoleId=roleId,estimationProcess.render()}),$scope.$on("uspoints:clear-selection",function(ctx){var us;return us=$scope.$eval($attrs.tgBacklogUsPoints),selectedRoleId=null,estimationProcess.render()}),$scope.$watch($attrs.tgBacklogUsPoints,function(us){var roles;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),roles=estimationProcess.calculateRoles(),0===roles.length?($el.find(".icon-arrow-bottom").remove(),$el.find("a.us-points").addClass("not-clickable")):1===roles.length&&(selectedRoleId=_.keys(us.points)[0]),estimationProcess.isEditable&&bindClickElements(),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return this.save(roleId,pointId).then(function(){return $ctrl.loadProjectStats()})},estimationProcess.render=function(){var ctx,html,mainTemplate,pointId,pointObj,template,text,title,totalPoints;return totalPoints=this.calculateTotalPoints(),null==selectedRoleId||1===roles.length?(text=totalPoints,title=totalPoints):(pointId=this.us.points[selectedRoleId],pointObj=this.pointsById[pointId],text=pointObj.name+" / "+totalPoints+"",title=pointObj.name+" / "+totalPoints),ctx={totalPoints:totalPoints,roles:this.calculateRoles(),editable:this.isEditable,text:text,title:title},mainTemplate="common/estimation/us-estimation-total.html",template=$tgTemplate.get(mainTemplate,!0),html=template(ctx),this.$el.html(html)},estimationProcess.render()):void 0}),renderRolesSelector=function(){var html,roles;return roles=estimationProcess.calculateRoles(),html=rolesTemplate({roles:roles}),$el.append(html),$el.find(".pop-role").popover().open(function(){return $(this).remove()})},bindClickElements=function(){return $el.on("click","a.us-points span",function(event){var us;return event.preventDefault(),event.stopPropagation(),us=$scope.$eval($attrs.tgBacklogUsPoints),updatingSelectedRoleId=selectedRoleId,null!=selectedRoleId?estimationProcess.renderPointsSelector(selectedRoleId):renderRolesSelector()}),$el.on("click",".role",function(event){var popRolesDom,target,us;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),us=$scope.$eval($attrs.tgBacklogUsPoints),updatingSelectedRoleId=target.data("role-id"),popRolesDom=$el.find(".pop-role"),popRolesDom.find("a").removeClass("active"),popRolesDom.find("a[data-role-id='"+updatingSelectedRoleId+"']").addClass("active"),estimationProcess.renderPointsSelector(updatingSelectedRoleId)})},$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogUsPoints",["$tgEstimationsService","$tgRepo","$tgTemplate",UsPointsDirective]),ToggleBurndownVisibility=function($storage){var hide,link,show;return hide=function(){return $(".js-burndown-graph").removeClass("shown"),$(".js-toggle-burndown-visibility-button").removeClass("active"),$(".js-burndown-graph").removeClass("open")},show=function(firstLoad){return $(".js-toggle-burndown-visibility-button").addClass("active"),firstLoad?$(".js-burndown-graph").addClass("shown"):$(".js-burndown-graph").addClass("open")},link=function($scope,$el,$attrs){var firstLoad,hash,toggleGraph;return firstLoad=!0,hash=generateHash(["is-burndown-grpahs-collapsed"]),$scope.isBurndownGraphCollapsed=$storage.get(hash)||!1,toggleGraph=function(){return $scope.isBurndownGraphCollapsed?hide(firstLoad):show(firstLoad),firstLoad=!1},$scope.$watch("showGraphPlaceholder",function(){return null!=$scope.showGraphPlaceholder?($scope.isBurndownGraphCollapsed=$scope.isBurndownGraphCollapsed||$scope.showGraphPlaceholder,toggleGraph()):void 0}),$el.on("click",".js-toggle-burndown-visibility-button",function(){return $scope.isBurndownGraphCollapsed=!$scope.isBurndownGraphCollapsed,$storage.set(hash,$scope.isBurndownGraphCollapsed),toggleGraph()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgToggleBurndownVisibility",["$tgStorage",ToggleBurndownVisibility]),BurndownBacklogGraphDirective=function($translate){var link,redrawChart;return redrawChart=function(element,dataToDraw){var client_increment_line,colors,data,evolution_line,milestonesRange,optimal_line,options,results,team_increment_line,width,zero_line;return width=element.width(),element.height(width/6),milestonesRange=function(){results=[];for(var j=0,ref1=dataToDraw.milestones.length-1;ref1>=0?ref1>=j:j>=ref1;ref1>=0?j++:j--)results.push(j);return results}.apply(this),data=[],zero_line=_.map(dataToDraw.milestones,function(ml){return 0}),data.push({data:_.zip(milestonesRange,zero_line),lines:{fillColor:"rgba(0,0,0,0)"},points:{show:!1}}),optimal_line=_.map(dataToDraw.milestones,function(ml){return ml.optimal}),data.push({data:_.zip(milestonesRange,optimal_line),lines:{fillColor:"rgba(120,120,120,0.2)"}}),evolution_line=_.filter(_.map(dataToDraw.milestones,function(ml){return ml.evolution}),function(evolution){return null!=evolution}),data.push({data:_.zip(milestonesRange,evolution_line),lines:{fillColor:"rgba(102,153,51,0.3)"}}),client_increment_line=_.map(dataToDraw.milestones,function(ml){return-ml["team-increment"]-ml["client-increment"]}),data.push({data:_.zip(milestonesRange,client_increment_line),lines:{fillColor:"rgba(255,51,51,0.3)"}}),team_increment_line=_.map(dataToDraw.milestones,function(ml){return-ml["team-increment"]}),data.push({data:_.zip(milestonesRange,team_increment_line),lines:{fillColor:"rgba(153,51,51,0.3)"}}),colors=["rgba(0,0,0,1)","rgba(120,120,120,0.2)","rgba(102,153,51,1)","rgba(153,51,51,1)","rgba(255,51,51,1)"],options={grid:{borderWidth:{top:0,right:1,left:0,bottom:0},borderColor:"#ccc",hoverable:!0},xaxis:{ticks:dataToDraw.milestones.length,axisLabel:$translate.instant("BACKLOG.CHART.XAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5,tickFormatter:function(val,axis){return""}},yaxis:{axisLabel:$translate.instant("BACKLOG.CHART.YAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},series:{shadowSize:0,lines:{show:!0,fill:!0},points:{show:!0,fill:!0,radius:4,lineWidth:2}},colors:colors,tooltip:!0,tooltipOpts:{content:function(label,xval,yval,flotItem){var ctx;return 1===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.OPTIMAL",ctx)):2===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.REAL",ctx)):3===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.INCREMENT_CLIENT",ctx)):(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.INCREMENT_TEAM",ctx))}}},element.empty(),element.plot(data,options).data("plot")},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch("stats",function(value){return null!=$scope.stats?(redrawChart(element,$scope.stats),$scope.$on("resize",function(){return redrawChart(element,$scope.stats)})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBurndownBacklogGraph",["$translate",BurndownBacklogGraphDirective]),TgBacklogProgressBarDirective=function($template,$compile){var adjustPercentaje,link,render,template;return template=$template.get("backlog/progress-bar.html",!0),render=function(scope,el,projectPointsPercentaje,closedPointsPercentaje){var html;return html=template({projectPointsPercentaje:projectPointsPercentaje,closedPointsPercentaje:closedPointsPercentaje}),html=$compile(html)(scope),el.html(html)},adjustPercentaje=function(percentage){var adjusted;return adjusted=_.max([0,percentage]),adjusted=_.min([100,adjusted]),Math.round(adjusted)},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch($attrs.tgBacklogProgressBar,function(stats){var closedPoints,closedPointsPercentaje,definedPoints,projectPointsPercentaje,totalPoints;return null!=stats?(totalPoints=stats.total_points?stats.total_points:stats.defined_points,definedPoints=stats.defined_points,closedPoints=stats.closed_points,definedPoints>totalPoints?(projectPointsPercentaje=100*totalPoints/definedPoints,closedPointsPercentaje=100*closedPoints/definedPoints):(projectPointsPercentaje=100,closedPointsPercentaje=100*closedPoints/totalPoints),projectPointsPercentaje=adjustPercentaje(projectPointsPercentaje-3),closedPointsPercentaje=adjustPercentaje(closedPointsPercentaje-3),render($scope,$el,projectPointsPercentaje,closedPointsPercentaje)):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogProgressBar",["$tgTemplate","$compile",TgBacklogProgressBarDirective])}.call(this),function(){var BacklogEmptySortableDirective,BacklogSortableDirective,SprintSortableDirective,bindOnce,deleteElement,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,module=angular.module("taigaBacklog"),deleteElement=function(el){return el.scope().$destroy(),el.off(),el.remove()},BacklogSortableDirective=function($repo,$rs,$rootscope,$tgConfirm,$translate){var link;return link=function($scope,$el,$attrs){var getUsIndex;return getUsIndex=function(_this){return function(us){return $(us).index(".backlog-table-body .row")}}(this),bindOnce($scope,"project",function(project){var filterError;if(project.my_permissions.indexOf("modify_us")>-1)return filterError=function(){var text;return text=$translate.instant("BACKLOG.SORTABLE_FILTER_ERROR"),$tgConfirm.notify("error",text)},$el.sortable({items:".us-item-row",cancel:".popover",connectWith:".sprint",dropOnEmpty:!0,placeholder:"row us-item-row us-item-drag sortable-placeholder",scroll:!0,disableHorizontalScroll:!0,tolerance:"pointer",revert:!1,start:function(){return $(document.body).addClass("drag-active")},stop:function(){return $(document.body).removeClass("drag-active"),$el.hasClass("active-filters")?($el.sortable("cancel"),filterError()):void 0}}),$el.on("multiplesortreceive",function(event,ui){var itemIndex,itemUs;return $el.hasClass("active-filters")?(ui.source.sortable("cancel"),void filterError()):(itemUs=ui.item.scope().us,itemIndex=getUsIndex(ui.item),deleteElement(ui.item),$scope.$emit("sprint:us:move",[itemUs],itemIndex,null),ui.item.find("a").removeClass("noclick"))}),$el.on("multiplesortstop",function(event,ui){var index,items,us;if(0!==$(ui.items[0]).parent().length&&!$el.hasClass("active-filters"))return items=_.sortBy(ui.items,function(item){return $(item).index()}),index=_.min(_.map(items,function(item){return getUsIndex(item)})),us=_.map(items,function(item){var itemUs;return item=$(item),itemUs=item.scope().us,setTimeout(function(_this){return function(){return item.find("a").removeClass("noclick")}}(this),300),itemUs}),$scope.$emit("sprint:us:move",us,index,null)}),$el.on("sortstart",function(event,ui){return ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},BacklogEmptySortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?($el.sortable({items:".us-item-row",dropOnEmpty:!0}),$el.on("sortreceive",function(event,ui){var itemIndex,itemUs;return itemUs=ui.item.scope().us,itemIndex=ui.item.index(),deleteElement(ui.item),$scope.$emit("sprint:us:move",[itemUs],itemIndex,null),ui.item.find("a").removeClass("noclick")})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},SprintSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?($el.sortable({scroll:!0,dropOnEmpty:!0,items:".sprint-table .milestone-us-item-row",disableHorizontalScroll:!0,connectWith:".sprint,.backlog-table-body,.empty-backlog",placeholder:"row us-item-row sortable-placeholder",forcePlaceholderSize:!0}),$el.on("multiplesortreceive",function(event,ui){var index,items,us;return items=_.sortBy(ui.items,function(item){return $(item).index()}),index=_.min(_.map(items,function(item){return $(item).index()})),us=_.map(items,function(item){var itemUs;return item=$(item),itemUs=item.scope().us,deleteElement(item),itemUs}),$scope.$emit("sprint:us:move",us,index,$scope.sprint.id)}),$el.on("multiplesortstop",function(event,ui){var itemIndex,itemUs;if(0!==ui.item.parent().length)return itemUs=ui.item.scope().us,itemIndex=ui.item.index(),setTimeout(function(_this){return function(){return ui.item.find("a").removeClass("noclick")}}(this),300),$scope.$emit("sprint:us:move",[itemUs],itemIndex,$scope.sprint.id)}),$el.on("sortstart",function(event,ui){return ui.item.find("a").addClass("noclick")})):void 0})},{link:link}},module.directive("tgBacklogSortable",["$tgRepo","$tgResources","$rootScope","$tgConfirm","$translate",BacklogSortableDirective]),module.directive("tgBacklogEmptySortable",["$tgRepo","$tgResources","$rootScope",BacklogEmptySortableDirective]),module.directive("tgSprintSortable",["$tgRepo","$tgResources","$rootScope",SprintSortableDirective])}.call(this),function(){var BacklogSprintDirective,BacklogSprintHeaderDirective,ToggleExcludeClosedSprintsVisualization,module,taiga;taiga=this.taiga,module=angular.module("taigaBacklog"),BacklogSprintDirective=function($repo,$rootscope){var link,slideOptions,sprintTableMinHeight,toggleSprint;return sprintTableMinHeight=50,slideOptions={duration:500,easing:"linear"},toggleSprint=function(_this){return function($el){var sprintArrow,sprintTable;return sprintTable=$el.find(".sprint-table"),sprintArrow=$el.find(".icon-arrow-up"),sprintArrow.toggleClass("active"),sprintTable.toggleClass("open")}}(this),link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgBacklogSprint,function(sprint){return sprint=$scope.$eval($attrs.tgBacklogSprint),sprint.closed?$el.addClass("sprint-closed"):toggleSprint($el)}),$el.on("click",".sprint-name > .icon-arrow-up",function(event){return event.preventDefault(),toggleSprint($el),$el.find(".sprint-table").slideToggle(slideOptions)}),$el.on("click",".sprint-name > .icon-edit",function(event){var sprint;return event.preventDefault(),sprint=$scope.$eval($attrs.tgBacklogSprint),$rootscope.$broadcast("sprintform:edit",sprint)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogSprint",["$tgRepo","$rootScope",BacklogSprintDirective]),BacklogSprintHeaderDirective=function($navUrls,$template,$compile,$translate){var link,template;return template=$template.get("backlog/sprint-header.html"),link=function($scope,$el,$attrs,$model){var isEditable,isVisible,prettyDate,render;return prettyDate=$translate.instant("BACKLOG.SPRINTS.DATE"),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_milestone")},isVisible=function(){return-1!==$scope.project.my_permissions.indexOf("view_milestones")},render=function(sprint){var compiledTemplate,ctx,estimatedDateRange,finish,start,taskboardUrl,templateScope;return taskboardUrl=$navUrls.resolve("project-taskboard",{project:$scope.project.slug,sprint:sprint.slug}),start=moment(sprint.estimated_start).format(prettyDate),finish=moment(sprint.estimated_finish).format(prettyDate),estimatedDateRange=start+"-"+finish,ctx={name:sprint.name,taskboardUrl:taskboardUrl,estimatedDateRange:estimatedDateRange,closedPoints:sprint.closed_points||0,totalPoints:sprint.total_points||0,isVisible:isVisible(),isEditable:isEditable()},templateScope=$scope.$new(),_.assign(templateScope,ctx),compiledTemplate=$compile(template)(templateScope),$el.html(compiledTemplate)},$scope.$watch($attrs.ngModel,function(sprint){return render(sprint)}),$scope.$on("sprintform:edit:success",function(){return render($model.$modelValue)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgBacklogSprintHeader",["$tgNavUrls","$tgTemplate","$compile","$translate",BacklogSprintHeaderDirective]),ToggleExcludeClosedSprintsVisualization=function($rootscope,$loading,$translate){var excludeClosedSprints,link;return excludeClosedSprints=!0,link=function($scope,$el,$attrs){var currentLoading,loadingElm;return loadingElm=$("
"),$el.after(loadingElm),currentLoading=null,$el.on("click",function(event){return event.preventDefault(),excludeClosedSprints=!excludeClosedSprints,currentLoading=$loading().target(loadingElm).start(),excludeClosedSprints?$rootscope.$broadcast("backlog:unload-closed-sprints"):$rootscope.$broadcast("backlog:load-closed-sprints")}),$scope.$on("$destroy",function(){return $el.off()}),$scope.$on("closed-sprints:reloaded",function(_this){return function(ctx,sprints){var key,text;return currentLoading.finish(),key=sprints.length>0?"BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS":"BACKLOG.SPRINTS.ACTION_SHOW_CLOSED_SPRINTS",text=$translate.instant(key),$el.find(".text").text(text)}}(this))},{link:link}},module.directive("tgBacklogToggleClosedSprintsVisualization",["$rootScope","$tgLoading","$translate",ToggleExcludeClosedSprintsVisualization])}.call(this),function(){var SprintGraphDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,module=angular.module("taigaTaskboard"),SprintGraphDirective=function($translate){var link,redrawChart;return redrawChart=function(element,dataToDraw){var data,days,options,width;return width=element.width(), -element.height(240),days=_.map(dataToDraw,function(x){return moment(x.day)}),data=[],data.unshift({data:_.zip(days,_.map(dataToDraw,function(d){return d.optimal_points})),lines:{fillColor:"rgba(120,120,120,0.2)"}}),data.unshift({data:_.zip(days,_.map(dataToDraw,function(d){return d.open_points})),lines:{fillColor:"rgba(102,153,51,0.3)"}}),options={grid:{borderWidth:{top:0,right:1,left:0,bottom:0},borderColor:"#ccc",hoverable:!0},xaxis:{tickSize:[1,"day"],min:days[0],max:_.last(days),mode:"time",daysNames:days,axisLabel:$translate.instant("TASKBOARD.CHARTS.XAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},yaxis:{min:0,axisLabel:$translate.instant("TASKBOARD.CHARTS.YAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},series:{shadowSize:0,lines:{show:!0,fill:!0},points:{show:!0,fill:!0,radius:4,lineWidth:2}},colors:["rgba(102,153,51,1)","rgba(120,120,120,0.2)"],tooltip:!0,tooltipOpts:{content:function(label,xval,yval,flotItem){var formattedDate,roundedValue;return formattedDate=moment(xval).format($translate.instant("TASKBOARD.CHARTS.DATE")),roundedValue=Math.round(yval),1===flotItem.seriesIndex?$translate.instant("TASKBOARD.CHARTS.OPTIMAL",{formattedDate:formattedDate,roundedValue:roundedValue}):$translate.instant("TASKBOARD.CHARTS.REAL",{formattedDate:formattedDate,roundedValue:roundedValue})}}},element.empty(),element.plot(data,options).data("plot")},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$on("resize",function(){return $scope.stats?redrawChart(element,$scope.stats.days):void 0}),$scope.$on("taskboard:graph:toggle-visibility",function(){return $el.parent().toggleClass("open"),timeout(100,function(){return $scope.stats?redrawChart(element,$scope.stats.days):void 0})}),$scope.$watch("stats",function(value){return null!=$scope.stats?redrawChart(element,$scope.stats.days):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgSprintGraph",["$translate",SprintGraphDirective])}.call(this),function(){var CreateBulkTasksDirective,CreateEditTaskDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,CreateEditTaskDirective=function($repo,$model,$rs,$rootscope,$loading,lightboxService,$translate,$q,attachmentsService){var link;return link=function($scope,$el,attrs){var attachmentsToAdd,attachmentsToDelete,createAttachments,deleteAttachments,resetAttachments,submit,submitButton;return $scope.isNew=!0,attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},$scope.deleteAttachment=function(attachment){return attachmentsToDelete=attachmentsToDelete.push(attachment)},createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){return attachmentsService.upload(attachment.file,obj.id,$scope.task.project,"task")}),$q.all(promises)},deleteAttachments=function(obj){var promises;return console.log(attachmentsToDelete.toJS()),promises=_.map(attachmentsToDelete.toJS(),function(attachment){return attachmentsService["delete"]("task",attachment.id)}),$q.all(promises)},$scope.$on("taskform:new",function(ctx,sprintId,usId){var create,newTask;return $scope.task={project:$scope.projectId,milestone:sprintId,user_story:usId,is_archived:!1,status:$scope.project.default_task_status,assigned_to:null,tags:[]},$scope.isNew=!0,$scope.attachments=Immutable.List(),resetAttachments(),create=$translate.instant("COMMON.CREATE"),$el.find(".button-green").html(create),newTask=$translate.instant("LIGHTBOX.CREATE_EDIT_TASK.TITLE"),$el.find(".title").html(newTask+" "),$el.find(".tag-input").val(""),lightboxService.open($el)}),$scope.$on("taskform:edit",function(ctx,task,attachments){var edit,save;return $scope.task=task,$scope.isNew=!1,$scope.attachments=Immutable.fromJS(attachments),resetAttachments(),save=$translate.instant("COMMON.SAVE"),edit=$translate.instant("LIGHTBOX.CREATE_EDIT_TASK.ACTION_EDIT"),$el.find(".button-green").html(save),$el.find(".title").html(edit+" "),$el.find(".tag-input").val(""),lightboxService.open($el)}),submitButton=$el.find(".submit-button"),submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?($scope.isNew?(promise=$repo.create("tasks",$scope.task),broadcastEvent="taskform:new:success"):(promise=$repo.save($scope.task),broadcastEvent="taskform:edit:success"),promise.then(function(data){return createAttachments(data),deleteAttachments(data),data}),currentLoading=$loading().target(submitButton).start(),promise.then(function(data){return currentLoading.finish(),lightboxService.close($el),$rootscope.$broadcast(broadcastEvent,data)})):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},CreateBulkTasksDirective=function($repo,$rs,$rootscope,$loading,lightboxService){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.form={data:"",usId:null},submit=debounce(2e3,function(_this){return function(event){var currentLoading,data,form,projectId,promise,sprintId,usId;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),data=$scope.form.data,projectId=$scope.projectId,sprintId=$scope.form.sprintId,usId=$scope.form.usId,promise=$rs.tasks.bulkCreate(projectId,sprintId,usId,data),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("taskform:bulk:success",result),lightboxService.close($el)}),promise.then(null,function(){return currentLoading.finish(),console.log("FAIL")})):void 0}}(this)),$scope.$on("taskform:bulk",function(ctx,sprintId,usId){return lightboxService.open($el),$scope.form={data:"",sprintId:sprintId,usId:usId}}),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaTaskboard"),module.directive("tgLbCreateEditTask",["$tgRepo","$tgModel","$tgResources","$rootScope","$tgLoading","lightboxService","$translate","$q","tgAttachmentsService",CreateEditTaskDirective]),module.directive("tgLbCreateBulkTasks",["$tgRepo","$tgResources","$rootScope","$tgLoading","lightboxService",CreateBulkTasksDirective])}.call(this),function(){var TaskboardController,TaskboardDirective,TaskboardSquishColumnDirective,TaskboardTaskDirective,TaskboardUserDirective,bindMethods,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,toggleText=this.taiga.toggleText,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,scopeDefer=this.taiga.scopeDefer,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,module=angular.module("taigaTaskboard"),TaskboardController=function(superClass){function TaskboardController(scope,rootscope,repo,confirm,rs1,params1,q,appMetaService,location,navUrls,events,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs1,this.params=params1,this.q=q,this.appMetaService=appMetaService,this.location=location,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("TASKBOARD.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TaskboardController,superClass),TaskboardController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","tgAppMetaService","$tgLocation","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],TaskboardController.prototype._setMeta=function(){var description,prettyDate,title;return prettyDate=this.translate.instant("BACKLOG.SPRINTS.DATE"),title=this.translate.instant("TASKBOARD.PAGE_TITLE",{projectName:this.scope.project.name,sprintName:this.scope.sprint.name}),description=this.translate.instant("TASKBOARD.PAGE_DESCRIPTION",{projectName:this.scope.project.name,sprintName:this.scope.sprint.name,startDate:moment(this.scope.sprint.estimated_start).format(prettyDate),endDate:moment(this.scope.sprint.estimated_finish).format(prettyDate),completedPercentage:this.scope.stats.completedPercentage||"0",completedPoints:this.scope.stats.completedPointsSum||"--",totalPoints:this.scope.stats.totalPointsSum||"--",openTasks:this.scope.stats.openTasks||"--",totalTasks:this.scope.stats.total_tasks||"--"}),this.appMetaService.setAll(title,description)},TaskboardController.prototype.initializeEventHandlers=function(){return this.scope.$on("taskform:bulk:success",function(_this){return function(){return _this.loadTaskboard(),_this.analytics.trackEvent("task","create","bulk create task on taskboard",1)}}(this)),this.scope.$on("taskform:new:success",function(_this){return function(){return _this.loadTaskboard(),_this.analytics.trackEvent("task","create","create task on taskboard",1)}}(this)),this.scope.$on("taskform:edit:success",function(_this){return function(){return _this.loadTaskboard()}}(this)),this.scope.$on("taskboard:task:move",this.taskMove),this.scope.$on("assigned-to:added",function(_this){return function(ctx,userId,task){var promise;return task.assigned_to=userId,promise=_this.repo.save(task),promise.then(null,function(){return console.log("FAIL")})}}(this))},TaskboardController.prototype.initializeSubscription=function(){var routingKey,routingKey1;return routingKey="changes.project."+this.scope.projectId+".tasks",this.events.subscribe(this.scope,routingKey,function(_this){return function(message){return _this.loadTaskboard()}}(this)),routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.refreshTagsColors(),_this.loadSprintStats(),_this.loadSprint()}}(this))},TaskboardController.prototype.loadProject=function(){return this.rs.projects.get(this.scope.projectId).then(function(_this){return function(project){return project.is_backlog_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.project=project,_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(e){return e.id}),_this.scope.roleById=groupBy(project.roles,function(e){return e.id}),_this.scope.taskStatusList=_.sortBy(project.task_statuses,"order"),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.scope.usStatusById=groupBy(project.us_statuses,function(e){return e.id}),_this.scope.$emit("project:loaded",project),_this.fillUsersAndRoles(project.members,project.roles),project}}(this))},TaskboardController.prototype.loadSprintStats=function(){return this.rs.sprints.stats(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(stats){var completedPointsSum,remainingPointsSum,remainingTasks,totalPointsSum;return totalPointsSum=_.reduce(_.values(stats.total_points),function(res,n){return res+n},0),completedPointsSum=_.reduce(_.values(stats.completed_points),function(res,n){return res+n},0),remainingPointsSum=totalPointsSum-completedPointsSum,remainingTasks=stats.total_tasks-stats.completed_tasks,_this.scope.stats=stats,_this.scope.stats.totalPointsSum=totalPointsSum,_this.scope.stats.completedPointsSum=completedPointsSum,_this.scope.stats.remainingPointsSum=remainingPointsSum,_this.scope.stats.remainingTasks=remainingTasks,stats.totalPointsSum?_this.scope.stats.completedPercentage=Math.round(100*stats.completedPointsSum/stats.totalPointsSum):_this.scope.stats.completedPercentage=0,_this.scope.stats.openTasks=stats.total_tasks-stats.completed_tasks,stats}}(this))},TaskboardController.prototype.refreshTagsColors=function(){return this.rs.projects.tagsColors(this.scope.projectId).then(function(_this){return function(tags_colors){return _this.scope.project.tags_colors=tags_colors}}(this))},TaskboardController.prototype.loadSprint=function(){return this.rs.sprints.get(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,_this.scope.userstories=_.sortBy(sprint.user_stories,"sprint_order"),sprint}}(this))},TaskboardController.prototype.loadTasks=function(){return this.rs.tasks.list(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(tasks){var i,j,k,len,len1,len2,ref,ref1,ref2,status,task,us,usId;for(_this.scope.tasks=_.sortBy(tasks,"taskboard_order"),_this.scope.usTasks={},ref=_.union(_this.scope.userstories,[{id:null}]),i=0,len=ref.length;len>i;i++)for(us=ref[i],_this.scope.usTasks[us.id]={},ref1=_this.scope.taskStatusList,j=0,len1=ref1.length;len1>j;j++)status=ref1[j],_this.scope.usTasks[us.id][status.id]=[];for(ref2=_this.scope.tasks,k=0,len2=ref2.length;len2>k;k++)task=ref2[k],null!=_this.scope.usTasks[task.user_story]&&null!=_this.scope.usTasks[task.user_story][task.status]&&_this.scope.usTasks[task.user_story][task.status].push(task);return 0===tasks.length&&(usId=_this.scope.userstories.length>0?_this.scope.userstories[0].id:null,_this.scope.usTasks[usId][_this.scope.taskStatusList[0].id].push({isPlaceholder:!0})),tasks}}(this))},TaskboardController.prototype.loadTaskboard=function(){return this.q.all([this.refreshTagsColors(),this.loadSprintStats(),this.loadSprint().then(function(_this){return function(){return _this.loadTasks()}}(this))])},TaskboardController.prototype.loadInitialData=function(){var params,promise;return params={pslug:this.params.pslug,sslug:this.params.sslug},promise=this.repo.resolve(params).then(function(_this){return function(data){return _this.scope.projectId=data.project,_this.scope.sprintId=data.milestone,_this.initializeSubscription(),data}}(this)),promise.then(function(_this){return function(){return _this.loadProject()}}(this)).then(function(_this){return function(){return _this.loadTaskboard()}}(this))},TaskboardController.prototype.refreshTasksOrder=function(tasks){var data,items;return items=this.resortTasks(tasks),data=this.prepareBulkUpdateData(items),this.rs.tasks.bulkUpdateTaskTaskboardOrder(this.scope.project.id,data)},TaskboardController.prototype.resortTasks=function(tasks){var i,index,item,items,len;for(items=[],index=i=0,len=tasks.length;len>i;index=++i)item=tasks[index],item.taskboard_order=index,item.isModified()&&items.push(item);return items},TaskboardController.prototype.prepareBulkUpdateData=function(uses){return _.map(uses,function(x){return{task_id:x.id,order:x.taskboard_order}})},TaskboardController.prototype.taskMove=function(ctx,task,usId,statusId,order){var promise,r,tasks;return r=this.scope.usTasks[task.user_story][task.status].indexOf(task),this.scope.usTasks[task.user_story][task.status].splice(r,1),tasks=this.scope.usTasks[usId][statusId],tasks.splice(order,0,task),task.user_story=usId,task.status=statusId,task.taskboard_order=order,promise=this.repo.save(task),this.rootscope.$broadcast("sprint:task:moved",task),promise.then(function(_this){return function(){return _this.refreshTasksOrder(tasks),_this.loadSprintStats()}}(this)),promise.then(null,function(_this){return function(){return console.log("FAIL TASK SAVE")}}(this))},TaskboardController.prototype.addNewTask=function(type,us){switch(type){case"standard":return this.rootscope.$broadcast("taskform:new",this.scope.sprintId,null!=us?us.id:void 0);case"bulk":return this.rootscope.$broadcast("taskform:bulk",this.scope.sprintId,null!=us?us.id:void 0)}},TaskboardController.prototype.editTaskAssignedTo=function(task){return this.rootscope.$broadcast("assigned-to:add",task)},TaskboardController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TaskboardController",TaskboardController),TaskboardDirective=function($rootscope){var link;return link=function($scope,$el,$attrs){var $ctrl,tableBodyDom;return $ctrl=$el.controller(),$el.on("click",".toggle-analytics-visibility",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.toggleClass("active"),$rootscope.$broadcast("taskboard:graph:toggle-visibility")}),tableBodyDom=$el.find(".taskboard-table-body"),tableBodyDom.on("scroll",function(event){var tableHeaderDom,target;return target=angular.element(event.currentTarget),tableHeaderDom=$el.find(".taskboard-table-header .taskboard-table-inner"),tableHeaderDom.css("left",-1*target.scrollLeft())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgTaskboard",["$rootScope",TaskboardDirective]),TaskboardTaskDirective=function($rootscope,$loading,$rs,$rs2){var link;return link=function($scope,$el,$attrs,$model){return $el.disableSelection(),$scope.$watch("task",function(task){return task.is_blocked&&!$el.hasClass("blocked")?$el.addClass("blocked"):!task.is_blocked&&$el.hasClass("blocked")?$el.removeClass("blocked"):void 0}),$el.find(".icon-edit").on("click",function(event){return $el.find(".icon-edit").hasClass("noclick")?void 0:$scope.$apply(function(){var currentLoading,target,task;return target=$(event.target),currentLoading=$loading().target(target).timeout(200).removeClasses("icon-edit").start(),task=$scope.task,$rs.tasks.getByRef(task.project,task.ref).then(function(_this){return function(editingTask){return $rs2.attachments.list("task",editingTask.id,editingTask.project).then(function(attachments){return $rootscope.$broadcast("taskform:edit",editingTask,attachments.toJS()),currentLoading.finish()})}}(this))})})},{link:link}},module.directive("tgTaskboardTask",["$rootScope","$tgLoading","$tgResources","tgResources",TaskboardTaskDirective]),TaskboardSquishColumnDirective=function(rs){var avatarWidth,link,maxColumnWidth;return avatarWidth=40,maxColumnWidth=300,link=function($scope,$el,$attrs){var getCeilWidth,recalculateStatusColumnWidth,recalculateTaskboardWidth,refreshTaskboardTableWidth,setStatusColumnWidth;return $scope.$on("sprint:task:moved",function(_this){return function(){return recalculateTaskboardWidth()}}(this)),bindOnce($scope,"usTasks",function(project){return $scope.statusesFolded=rs.tasks.getStatusColumnModes($scope.project.id),$scope.usFolded=rs.tasks.getUsRowModes($scope.project.id,$scope.sprintId),recalculateTaskboardWidth()}),$scope.foldStatus=function(status){return $scope.statusesFolded[status.id]=!$scope.statusesFolded[status.id],rs.tasks.storeStatusColumnModes($scope.projectId,$scope.statusesFolded),recalculateTaskboardWidth()},$scope.foldUs=function(us){return us?$scope.usFolded[us.id]=!$scope.usFolded[us.id]:$scope.usFolded[null]=!$scope.usFolded[null],rs.tasks.storeUsRowModes($scope.projectId,$scope.sprintId,$scope.usFolded),recalculateTaskboardWidth()},getCeilWidth=function(_this){return function(usId,statusId){var tasks,tasksMatrixSize,width;return tasks=$scope.usTasks[usId][statusId].length,$scope.statusesFolded[statusId]?(tasks&&$scope.usFolded[usId]?(tasksMatrixSize=Math.round(Math.sqrt(tasks)),width=avatarWidth*tasksMatrixSize):width=avatarWidth,width):0}}(this),setStatusColumnWidth=function(_this){return function(statusId,width){var column;return column=$el.find(".squish-status-"+statusId),width?column.css("max-width",width):column.css("max-width",maxColumnWidth)}}(this),refreshTaskboardTableWidth=function(_this){return function(){var columnWidths,columns,totalWidth;return columnWidths=[],columns=$el.find(".task-colum-name"),columnWidths=_.map(columns,function(column){return $(column).outerWidth(!0)}),totalWidth=_.reduce(columnWidths,function(total,width){return total+width}),$el.find(".taskboard-table-inner").css("width",totalWidth)}}(this),recalculateStatusColumnWidth=function(_this){return function(statusId){var statusFoldedWidth;return statusFoldedWidth=getCeilWidth(null,statusId),_.forEach($scope.userstories,function(us){var width;return width=getCeilWidth(us.id,statusId),width>statusFoldedWidth?statusFoldedWidth=width:void 0}),setStatusColumnWidth(statusId,statusFoldedWidth)}}(this),recalculateTaskboardWidth=function(_this){return function(){_.forEach($scope.taskStatusList,function(status){return recalculateStatusColumnWidth(status.id)}),refreshTaskboardTableWidth()}}(this)},{link:link}},module.directive("tgTaskboardSquishColumn",["$tgResources",TaskboardSquishColumnDirective]),TaskboardUserDirective=function($log,$translate){var clickable,link;return clickable=!1,link=function($scope,$el,$attrs){var username_label;return username_label=$el.parent().find("a.task-assigned"),username_label.addClass("not-clickable"),$scope.$watch("task.assigned_to",function(assigned_to){var user;return user=$scope.usersById[assigned_to],void 0===user?_.assign($scope,{name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png",clickable:clickable}):_.assign($scope,{name:user.full_name_display,imgurl:user.photo,clickable:clickable}),username_label.text($scope.name)}),bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_task")>-1?(clickable=!0,$el.find(".avatar-assigned-to").on("click",function(_this){return function(event){var $ctrl;if(!$el.find("a").hasClass("noclick"))return $ctrl=$el.controller(),$ctrl.editTaskAssignedTo($scope.task)}}(this)),username_label.removeClass("not-clickable"),username_label.on("click",function(event){var $ctrl;if(!$el.find("a").hasClass("noclick"))return $ctrl=$el.controller(),$ctrl.editTaskAssignedTo($scope.task)})):void 0})},{link:link,templateUrl:"taskboard/taskboard-user.html",scope:{usersById:"=users",project:"=",task:"="}}},module.directive("tgTaskboardUserAvatar",["$log","$translate",TaskboardUserDirective])}.call(this),function(){var TaskboardSortableDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,module=angular.module("taigaBacklog"),TaskboardSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var deleteElement,itemEl,newParentScope,oldParentScope,tdom;if(project.my_permissions.indexOf("modify_us")>-1)return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el,deleteElement=function(itemEl){return itemEl.scope().$destroy(),itemEl.off(),itemEl.remove()},tdom.sortable({handle:".taskboard-task-inner",dropOnEmpty:!0,connectWith:".taskboard-tasks-box",revert:400}),tdom.on("sortstop",function(event,ui){var itemIndex,itemTask,newStatusId,newUsId,oldStatusId,oldUsId,parentEl;return parentEl=ui.item.parent(),itemEl=ui.item,itemTask=itemEl.scope().task,itemIndex=itemEl.index(),newParentScope=parentEl.scope(),oldUsId=oldParentScope.us?oldParentScope.us.id:null,oldStatusId=oldParentScope.st.id,newUsId=newParentScope.us?newParentScope.us.id:null,newStatusId=newParentScope.st.id,(newStatusId!==oldStatusId||newUsId!==oldUsId)&&deleteElement(itemEl),$scope.$apply(function(){return $rootscope.$broadcast("taskboard:task:move",itemTask,newUsId,newStatusId,itemIndex)}),ui.item.find("a").removeClass("noclick")}),tdom.on("sortstart",function(event,ui){return oldParentScope=ui.item.parent().scope(),ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgTaskboardSortable",["$tgRepo","$tgResources","$rootScope",TaskboardSortableDirective])}.call(this),function(){var KanbanArchivedStatusHeaderDirective,KanbanArchivedStatusIntroDirective,KanbanController,KanbanDirective,KanbanSquishColumnDirective,KanbanUserDirective,KanbanUserstoryDirective,KanbanWipLimitDirective,bindMethods,bindOnce,defaultViewMode,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,viewModes,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,module=angular.module("taigaKanban"),defaultViewMode="maximized",viewModes=["maximized","minimized"],KanbanController=function(superClass){function KanbanController(scope,rootscope,repo,confirm,rs1,params1,q,location,appMetaService,navUrls,events,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs1,this.params=params1,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("KANBAN.SECTION_NAME"),this.scope.statusViewModes={},this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("KANBAN.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("KANBAN.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(KanbanController,superClass),KanbanController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],KanbanController.prototype.initializeEventHandlers=function(){return this.scope.$on("usform:new:success",function(_this){return function(){return _this.loadUserstories(),_this.refreshTagsColors(),_this.analytics.trackEvent("userstory","create","create userstory on kanban",1)}}(this)),this.scope.$on("usform:bulk:success",function(_this){return function(){return _this.loadUserstories(),_this.analytics.trackEvent("userstory","create","bulk create userstory on kanban",1)}}(this)),this.scope.$on("usform:edit:success",function(_this){return function(){return _this.loadUserstories(),_this.refreshTagsColors()}}(this)),this.scope.$on("assigned-to:added",this.onAssignedToChanged),this.scope.$on("kanban:us:move",this.moveUs),this.scope.$on("kanban:show-userstories-for-status",this.loadUserStoriesForStatus),this.scope.$on("kanban:hide-userstories-for-status",this.hideUserStoriesForStatus)},KanbanController.prototype.addNewUs=function(type,statusId){switch(type){case"standard":return this.rootscope.$broadcast("usform:new",this.scope.projectId,statusId,this.scope.usStatusList);case"bulk":return this.rootscope.$broadcast("usform:bulk",this.scope.projectId,statusId)}},KanbanController.prototype.changeUsAssignedTo=function(us){return this.rootscope.$broadcast("assigned-to:add",us)},KanbanController.prototype.onAssignedToChanged=function(ctx,userid,us){var promise;return us.assigned_to=userid,promise=this.repo.save(us),promise.then(null,function(){return console.log("FAIL")})},KanbanController.prototype.refreshTagsColors=function(){return this.rs.projects.tagsColors(this.scope.projectId).then(function(_this){return function(tags_colors){return _this.scope.project.tags_colors=tags_colors}}(this))},KanbanController.prototype.loadUserstories=function(){var params,promise;return params={status__is_archived:!1},promise=this.rs.userstories.listAll(this.scope.projectId,params).then(function(_this){return function(userstories){var i,j,k,len,len1,len2,ref,ref1,ref2,status,us,usByStatus,us_archived;for(_this.scope.userstories=userstories,usByStatus=_.groupBy(userstories,"status"),us_archived=[],ref=_this.scope.usStatusList,i=0,len=ref.length;len>i;i++){if(status=ref[i],null==usByStatus[status.id]&&(usByStatus[status.id]=[]),null!=_this.scope.usByStatus)for(ref1=_this.scope.usByStatus[status.id],j=0,len1=ref1.length;len1>j;j++)us=ref1[j],us.status!==status.id&&us_archived.push(us);if(status.is_archived&&null!=_this.scope.usByStatus&&0!==_this.scope.usByStatus[status.id].length)for(ref2=_this.scope.usByStatus[status.id].concat(us_archived),k=0,len2=ref2.length;len2>k;k++)us=ref2[k],us.status===status.id&&usByStatus[status.id].push(us);usByStatus[status.id]=_.sortBy(usByStatus[status.id],"kanban_order")}return 0===userstories.length&&(status=_this.scope.usStatusList[0],usByStatus[status.id].push({isPlaceholder:!0})),_this.scope.usByStatus=usByStatus,scopeDefer(_this.scope,function(){return _this.scope.$broadcast("userstories:loaded",userstories)}),userstories}}(this)),promise.then(function(_this){return function(){return _this.scope.$broadcast("redraw:wip")}}(this)),promise},KanbanController.prototype.loadUserStoriesForStatus=function(ctx,statusId){var params;return params={status:statusId},this.rs.userstories.listAll(this.scope.projectId,params).then(function(_this){return function(userstories){return _this.scope.usByStatus[statusId]=_.sortBy(userstories,"kanban_order"),_this.scope.$broadcast("kanban:shown-userstories-for-status",statusId,userstories),userstories}}(this))},KanbanController.prototype.hideUserStoriesForStatus=function(ctx,statusId){return this.scope.usByStatus[statusId]=[],this.scope.$broadcast("kanban:hidden-userstories-for-status",statusId)},KanbanController.prototype.loadKanban=function(){return this.q.all([this.refreshTagsColors(),this.loadUserstories()])},KanbanController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_kanban_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.projectId=project.id,_this.scope.points=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.generateStatusViewModes(),_this.scope.$emit("project:loaded",project),project}}(this))},KanbanController.prototype.initializeSubscription=function(){var routingKey1;return routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.loadUserstories()}}(this))},KanbanController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription(),_this.loadKanban()}}(this))},KanbanController.prototype.generateStatusViewModes=function(){var i,len,mode,ref,status,storedStatusViewModes;for(storedStatusViewModes=this.rs.kanban.getStatusViewModes(this.scope.projectId),this.scope.statusViewModes={},ref=this.scope.usStatusList,i=0,len=ref.length;len>i;i++)status=ref[i],mode=storedStatusViewModes[status.id]||defaultViewMode,this.scope.statusViewModes[status.id]=mode;return this.storeStatusViewModes()},KanbanController.prototype.storeStatusViewModes=function(){return this.rs.kanban.storeStatusViewModes(this.scope.projectId,this.scope.statusViewModes); -},KanbanController.prototype.updateStatusViewMode=function(statusId,newViewMode){return this.scope.statusViewModes[statusId]=newViewMode,this.storeStatusViewModes()},KanbanController.prototype.isMaximized=function(statusId){var mode;return mode=this.scope.statusViewModes[statusId]||defaultViewMode,"maximized"===mode},KanbanController.prototype.isMinimized=function(statusId){var mode;return mode=this.scope.statusViewModes[statusId]||defaultViewMode,"minimized"===mode},KanbanController.prototype.prepareBulkUpdateData=function(uses,field){return null==field&&(field="kanban_order"),_.map(uses,function(x){return{us_id:x.id,order:x[field]}})},KanbanController.prototype.resortUserStories=function(uses){var i,index,item,items,len;for(items=[],index=i=0,len=uses.length;len>i;index=++i)item=uses[index],item.kanban_order=index,item.isModified()&&items.push(item);return items},KanbanController.prototype.moveUs=function(ctx,us,oldStatusId,newStatusId,index){var itemsToSave,promise,r;return oldStatusId!==newStatusId?(r=this.scope.usByStatus[oldStatusId].indexOf(us),this.scope.usByStatus[oldStatusId].splice(r,1),this.scope.usByStatus[newStatusId].splice(index,0,us),us.status=newStatusId):(r=this.scope.usByStatus[newStatusId].indexOf(us),this.scope.usByStatus[newStatusId].splice(r,1),this.scope.usByStatus[newStatusId].splice(index,0,us)),itemsToSave=this.resortUserStories(this.scope.usByStatus[newStatusId]),this.scope.usByStatus[newStatusId]=_.sortBy(this.scope.usByStatus[newStatusId],"kanban_order"),promise=this.repo.save(us),promise=promise.then(function(_this){return function(){var data;return itemsToSave=_.reject(itemsToSave,{id:us.id}),data=_this.prepareBulkUpdateData(itemsToSave),_this.rs.userstories.bulkUpdateKanbanOrder(us.project,data).then(function(){return itemsToSave})}}(this))},KanbanController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("KanbanController",KanbanController),KanbanDirective=function($repo,$rootscope){var link;return link=function($scope,$el,$attrs){var tableBodyDom;return tableBodyDom=$el.find(".kanban-table-body"),tableBodyDom.on("scroll",function(event){var tableHeaderDom,target;return target=angular.element(event.currentTarget),tableHeaderDom=$el.find(".kanban-table-header .kanban-table-inner"),tableHeaderDom.css("left",-1*target.scrollLeft())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanban",["$tgRepo","$rootScope",KanbanDirective]),KanbanArchivedStatusHeaderDirective=function($rootscope,$translate){var hideArchivedText,link,showArchivedText;return showArchivedText=$translate.instant("KANBAN.ACTION_SHOW_ARCHIVED"),hideArchivedText=$translate.instant("KANBAN.ACTION_HIDE_ARCHIVED"),link=function($scope,$el,$attrs){var hidden,status;return status=$scope.$eval($attrs.tgKanbanArchivedStatusHeader),hidden=!0,$scope["class"]="icon-open-eye",$scope.title=showArchivedText,$el.on("click",function(event){return hidden=!hidden,$scope.$apply(function(){return hidden?($scope["class"]="icon-open-eye",$scope.title=showArchivedText,$rootscope.$broadcast("kanban:hide-userstories-for-status",status.id)):($scope["class"]="icon-closed-eye",$scope.title=hideArchivedText,$rootscope.$broadcast("kanban:show-userstories-for-status",status.id))})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanArchivedStatusHeader",["$rootScope","$translate",KanbanArchivedStatusHeaderDirective]),KanbanArchivedStatusIntroDirective=function($translate){var link,userStories;return userStories=[],link=function($scope,$el,$attrs){var hiddenUserStoriexText,status,updateIntroText;return hiddenUserStoriexText=$translate.instant("KANBAN.HIDDEN_USER_STORIES"),status=$scope.$eval($attrs.tgKanbanArchivedStatusIntro),$el.text(hiddenUserStoriexText),updateIntroText=function(){return userStories.length>0?$el.text(""):$el.text(hiddenUserStoriexText)},$scope.$on("kanban:us:move",function(ctx,itemUs,oldStatusId,newStatusId,itemIndex){var r;return status.id===newStatusId?status.id===oldStatusId?(r=userStories.indexOf(itemUs),userStories.splice(r,1),userStories.splice(itemIndex,0,itemUs)):(itemUs.isArchived=!0,userStories.splice(itemIndex,0,itemUs)):status.id===oldStatusId&&(itemUs.isArchived=!1,r=userStories.indexOf(itemUs),userStories.splice(r,1)),updateIntroText()}),$scope.$on("kanban:shown-userstories-for-status",function(ctx,statusId,userStoriesLoaded){return statusId===status.id?(userStories=_.filter(userStoriesLoaded,function(us){return us.status===status.id}),updateIntroText()):void 0}),$scope.$on("kanban:hidden-userstories-for-status",function(ctx,statusId){return statusId===status.id?(userStories=[],updateIntroText()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanArchivedStatusIntro",["$translate",KanbanArchivedStatusIntroDirective]),KanbanUserstoryDirective=function($rootscope,$loading,$rs,$rs2){var link;return link=function($scope,$el,$attrs,$model){return $el.disableSelection(),$scope.$watch("us",function(us){return us.is_blocked&&!$el.hasClass("blocked")?$el.addClass("blocked"):!us.is_blocked&&$el.hasClass("blocked")?$el.removeClass("blocked"):void 0}),$el.on("click",".icon-edit",function(event){var currentLoading,target,us;if(!$el.find(".icon-edit").hasClass("noclick"))return target=$(event.target),currentLoading=$loading().target(target).timeout(200).removeClasses("icon-edit").start(),us=$model.$modelValue,$rs.userstories.getByRef(us.project,us.ref).then(function(_this){return function(editingUserStory){return $rs2.attachments.list("us",us.id,us.project).then(function(attachments){return $rootscope.$broadcast("usform:edit",editingUserStory,attachments.toJS()),currentLoading.finish()})}}(this))}),$scope.getTemplateUrl=function(){return $scope.us.isPlaceholder?"common/components/kanban-placeholder.html":"kanban/kanban-task.html"},$scope.$on("$destroy",function(){return $el.off()})},{template:'',link:link,require:"ngModel"}},module.directive("tgKanbanUserstory",["$rootScope","$tgLoading","$tgResources","tgResources",KanbanUserstoryDirective]),KanbanSquishColumnDirective=function(rs){var link;return link=function($scope,$el,$attrs){var updateTableWidth;return $scope.$on("project:loaded",function(event,project){return $scope.folds=rs.kanban.getStatusColumnModes(project.id),updateTableWidth()}),$scope.foldStatus=function(status){$scope.folds[status.id]=!$scope.folds[status.id],rs.kanban.storeStatusColumnModes($scope.projectId,$scope.folds),updateTableWidth()},updateTableWidth=function(){var columnWidths,totalWidth;return columnWidths=_.map($scope.usStatusList,function(status){return $scope.folds[status.id]?40:310}),totalWidth=_.reduce(columnWidths,function(total,width){return total+width}),$el.find(".kanban-table-inner").css("width",totalWidth)}},{link:link}},module.directive("tgKanbanSquishColumn",["$tgResources",KanbanSquishColumnDirective]),KanbanWipLimitDirective=function(){var link;return link=function($scope,$el,$attrs){var redrawWipLimit,status;return $el.disableSelection(),status=$scope.$eval($attrs.tgKanbanWipLimit),redrawWipLimit=function(_this){return function(){return $el.find(".kanban-wip-limit").remove(),timeout(200,function(){var element;return element=$el.find(".kanban-task")[status.wip_limit],element?angular.element(element).before("
"):void 0})}}(this),status&&!status.is_archived&&($scope.$on("redraw:wip",redrawWipLimit),$scope.$on("kanban:us:move",redrawWipLimit),$scope.$on("usform:new:success",redrawWipLimit),$scope.$on("usform:bulk:success",redrawWipLimit)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanWipLimit",KanbanWipLimitDirective),KanbanUserDirective=function($log,$compile,$translate){var clickable,link,template;return template=_.template('
\n class="not-clickable"<% } %>>\n <%- name %>\n \n
'),clickable=!1,link=function($scope,$el,$attrs,$model){var render,username_label,wtid;return username_label=$el.parent().find("a.task-assigned"),username_label.addClass("not-clickable"),$attrs.tgKanbanUserAvatar?(wtid=$scope.$watch($attrs.tgKanbanUserAvatar,function(v){var user;return null==$scope.usersById?($log.error("KanbanUserDirective requires userById set in scope."),wtid()):(user=$scope.usersById[v],render(user))}),render=function(user){var ctx,html;return ctx=void 0===user?{name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png",clickable:clickable}:{name:user.full_name_display,imgurl:user.photo,clickable:clickable},html=$compile(template(ctx))($scope),$el.html(html),username_label.text(ctx.name)},bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?(clickable=!0,$el.on("click",function(_this){return function(event){var $ctrl,us;if(!$el.find("a").hasClass("noclick"))return us=$model.$modelValue,$ctrl=$el.controller(),$ctrl.changeUsAssignedTo(us)}}(this)),username_label.removeClass("not-clickable"),username_label.on("click",function(event){var $ctrl,us;if(!$el.find("a").hasClass("noclick"))return us=$model.$modelValue,$ctrl=$el.controller(),$ctrl.changeUsAssignedTo(us)})):void 0}),$scope.$on("$destroy",function(){return $el.off()})):$log.error("KanbanUserDirective: no attr is defined")},{link:link,require:"ngModel"}},module.directive("tgKanbanUserAvatar",["$log","$compile","$translate",KanbanUserDirective])}.call(this),function(){var KanbanSortableDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,module=angular.module("taigaKanban"),KanbanSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var deleteElement,itemEl,newParentScope,oldParentScope,tdom;if(project.my_permissions.indexOf("modify_us")>-1)return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el,deleteElement=function(itemEl){return itemEl.scope().$destroy(),itemEl.off(),itemEl.remove()},tdom.sortable({handle:".kanban-task-inner",dropOnEmpty:!0,connectWith:".kanban-uses-box",revert:400}),tdom.on("sortstop",function(event,ui){var itemIndex,itemUs,newStatusId,oldStatusId,parentEl;return parentEl=ui.item.parent(),itemEl=ui.item,itemUs=itemEl.scope().us,itemIndex=itemEl.index(),newParentScope=parentEl.scope(),newStatusId=newParentScope.s.id,oldStatusId=oldParentScope.s.id,newStatusId!==oldStatusId&&deleteElement(itemEl),$scope.$apply(function(){return $rootscope.$broadcast("kanban:us:move",itemUs,itemUs.status,newStatusId,itemIndex)}),ui.item.find("a").removeClass("noclick")}),tdom.on("sortstart",function(event,ui){return oldParentScope=ui.item.parent().scope(),ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanSortable",["$tgRepo","$tgResources","$rootScope",KanbanSortableDirective])}.call(this),function(){var IssueDetailController,IssuePriorityButtonDirective,IssueSeverityButtonDirective,IssueStatusButtonDirective,IssueStatusDisplayDirective,IssueTypeButtonDirective,PromoteIssueToUsButtonDirective,bindMethods,bindOnce,groupBy,joinStr,mixOf,module,taiga,toString,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaIssues"),IssueDetailController=function(superClass){function IssueDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,analytics,navUrls,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.analytics=analytics,this.navUrls=navUrls,this.translate=translate,bindMethods(this),this.scope.issueRef=this.params.issueref,this.scope.sectionName=this.translate.instant("ISSUES.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(IssueDetailController,superClass),IssueDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgAnalytics","$tgNavUrls","$translate"],IssueDetailController.prototype._setMeta=function(){var description,ref,ref1,ref2,ref3,title;return title=this.translate.instant("ISSUE.PAGE_TITLE",{issueRef:"#"+this.scope.issue.ref,issueSubject:this.scope.issue.subject,projectName:this.scope.project.name}),description=this.translate.instant("ISSUE.PAGE_DESCRIPTION",{issueStatus:(null!=(ref=this.scope.statusById[this.scope.issue.status])?ref.name:void 0)||"--",issueType:(null!=(ref1=this.scope.typeById[this.scope.issue.type])?ref1.name:void 0)||"--",issueSeverity:(null!=(ref2=this.scope.severityById[this.scope.issue.severity])?ref2.name:void 0)||"--",issuePriority:(null!=(ref3=this.scope.priorityById[this.scope.issue.priority])?ref3.name:void 0)||"--",issueDescription:angular.element(this.scope.issue.description_html||"").text()}),this.appMetaService.setAll(title,description)},IssueDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on issue",1)}}(this)),this.scope.$on("promote-issue-to-us:success",function(_this){return function(){return _this.analytics.trackEvent("issue","promoteToUserstory","promote issue to userstory",1),_this.rootscope.$broadcast("object:updated"),_this.loadIssue()}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadIssue()}}(this)),this.scope.$on("custom-attributes-values:edit",function(_this){return function(){return _this.rootscope.$broadcast("object:updated")}}(this))},IssueDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;return ctx={project:this.scope.project.slug},this.scope.project.is_issues_activated?this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-issues",ctx):this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx)},IssueDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.issue_statuses,_this.scope.statusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.typeById=groupBy(project.issue_types,function(x){return x.id}),_this.scope.typeList=_.sortBy(project.issue_types,"order"),_this.scope.severityList=project.severities,_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.priorityList=project.priorities,_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),project}}(this))},IssueDetailController.prototype.loadIssue=function(){return this.rs.issues.getByRef(this.scope.projectId,this.params.issueref).then(function(_this){return function(issue){var ctx,ref,ref1;return _this.scope.issue=issue,_this.scope.issueId=issue.id,_this.scope.commentModel=issue,null!=(null!=(ref=_this.scope.issue.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.issue.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-issues-detail",ctx)),null!=(null!=(ref1=_this.scope.issue.neighbors.next)?ref1.ref:void 0)?(ctx={project:_this.scope.project.slug,ref:_this.scope.issue.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-issues-detail",ctx)):void 0}}(this))},IssueDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadIssue()}}(this))},IssueDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.upvote(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.downvote(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onWatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.watch(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.unwatch(this.scope.issueId).then(onSuccess,onError)},IssueDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("IssueDetailController",IssueDetailController),IssueStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(issue){var html,status;return status=$scope.statusById[issue.status],html=template({is_closed:status.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(issue){return null!=issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueStatusDisplay",["$tgTemplate","$compile",IssueStatusDisplayDirective]),IssueStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issues-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,status;return status=$scope.statusById[issue.status],html=template({status:status,statuses:$scope.statusList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(statusId){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.status=statusId,currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),save(target.data("status-id"))):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueStatusButtonDirective]),IssueTypeButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-type-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,type;return type=$scope.typeById[issue.type],html=template({type:type,typees:$scope.typeList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(type){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.type=type,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".type-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-type").popover().open():void 0}),$el.on("click",".type",function(event){var target,type;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),type=target.data("type-id"),save(type)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueTypeButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueTypeButtonDirective]),IssueSeverityButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-severity-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,severity;return severity=$scope.severityById[issue.severity],html=template({severity:severity,severityes:$scope.severityList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(severity){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.severity=severity,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".severity-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-severity").popover().open():void 0}),$el.on("click",".severity",function(event){var severity,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),severity=target.data("severity-id"),save(severity)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueSeverityButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueSeverityButtonDirective]),IssuePriorityButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-priority-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,priority;return priority=$scope.priorityById[issue.priority],html=template({priority:priority,priorityes:$scope.priorityList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(priority){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.priority=priority,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".priority-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-priority").popover().open():void 0}),$el.on("click",".priority",function(event){var priority,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),priority=target.data("priority-id"),save(priority)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssuePriorityButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssuePriorityButtonDirective]),PromoteIssueToUsButtonDirective=function($rootScope,$repo,$confirm,$qqueue,$translate){var link;return link=function($scope,$el,$attrs,$model){var save;return save=$qqueue.bindAdd(function(_this){return function(issue,askResponse){var data,onError,onSuccess;return data={generated_from_issue:issue.id,project:issue.project,subject:issue.subject,description:issue.description,tags:issue.tags,is_blocked:issue.is_blocked,blocked_note:issue.blocked_note},onSuccess=function(){return askResponse.finish(),$confirm.notify("success"),$rootScope.$broadcast("promote-issue-to-us:success")},onError=function(){return askResponse.finish(),$confirm.notify("error")},$repo.create("userstories",data).then(onSuccess,onError)}}(this)),$el.on("click","a",function(event){var issue,message,subtitle,title;return event.preventDefault(),issue=$model.$modelValue,title=$translate.instant("ISSUES.CONFIRM_PROMOTE.TITLE"),message=$translate.instant("ISSUES.CONFIRM_PROMOTE.MESSAGE"),subtitle=issue.subject,$confirm.ask(title,subtitle,message).then(function(_this){return function(response){return save(issue,response)}}(this))}),$scope.$on("$destroy",function(){return $el.off()})},{restrict:"AE",require:"ngModel",templateUrl:"issue/promote-issue-to-us-button.html",link:link}},module.directive("tgPromoteIssueToUsButton",["$rootScope","$tgRepo","$tgConfirm","$tgQqueue","$translate",PromoteIssueToUsButtonDirective])}.call(this),function(){var CreateBulkIssuesDirective,CreateIssueDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaIssues"),CreateIssueDirective=function($repo,$confirm,$rootscope,lightboxService,$loading,$q,attachmentsService){var link;return link=function($scope,$el,$attrs){var attachmentsToAdd,createAttachments,form,resetAttachments,submit,submitButton;return form=$el.find("form").checksley(),$scope.issue={},$scope.attachments=Immutable.List(),$scope.$on("issueform:new",function(ctx,project){var attachmentsToAdd;return attachmentsToAdd=Immutable.List(),$el.find(".tag-input").val(""),lightboxService.open($el),$scope.issue={project:project.id,subject:"",status:project.default_issue_status,type:project.default_issue_type,priority:project.default_priority,severity:project.default_severity,tags:[]}}),$scope.$on("$destroy",function(){return $el.off()}),createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){return attachmentsService.upload(attachment.file,obj.id,$scope.issue.project,"issue")}),$q.all(promises)},attachmentsToAdd=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("issues",$scope.issue),promise.then(function(data){return createAttachments(data)}),promise.then(function(data){return currentLoading.finish(),$rootscope.$broadcast("issueform:new:success",data),lightboxService.close($el),$confirm.notify("success")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgLbCreateIssue",["$tgRepo","$tgConfirm","$rootScope","lightboxService","$tgLoading","$q","tgAttachmentsService",CreateIssueDirective]),CreateBulkIssuesDirective=function($repo,$rs,$confirm,$rootscope,$loading,lightboxService){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.$on("issueform:bulk",function(ctx,projectId,status){return lightboxService.open($el),$scope["new"]={projectId:projectId,bulk:""}}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,data,form,projectId,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),data=$scope["new"].bulk,projectId=$scope["new"].projectId,promise=$rs.issues.bulkCreate(projectId,data),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("issueform:new:success",result),lightboxService.close($el),$confirm.notify("success")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateBulkIssues",["$tgRepo","$tgResources","$tgConfirm","$rootScope","$tgLoading","lightboxService",CreateBulkIssuesDirective])}.call(this),function(){var IssueAssignedToInlineEditionDirective,IssueStatusInlineEditionDirective,IssuesController,IssuesDirective,IssuesFiltersDirective,bindOnce,debounceLeading,groupBy,joinStr,mixOf,module,startswith,taiga,toString,trim,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounceLeading=this.taiga.debounceLeading, -startswith=this.taiga.startswith,module=angular.module("taigaIssues"),IssuesController=function(superClass){function IssuesController(scope,rootscope,repo,confirm,rs,urls,params,q,location,appMetaService,navUrls,events,analytics,translate){var filters,promise;return this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.urls=urls,this.params=params,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,this.loadIssues=bind(this.loadIssues,this),this.scope.sectionName="Issues",this.scope.filters={},_.isEmpty(this.location.search())?(filters=this.rs.issues.getFilters(this.params.pslug),filters.page=1,this.location.search(filters),void this.location.replace()):(promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ISSUES.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("ISSUES.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),void this.scope.$on("issueform:new:success",function(_this){return function(){return _this.analytics.trackEvent("issue","create","create issue on issues list",1),_this.loadIssues()}}(this)))}return extend(IssuesController,superClass),IssuesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$tgUrls","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],IssuesController.prototype.initializeSubscription=function(){var routingKey;return routingKey="changes.project."+this.scope.projectId+".issues",this.events.subscribe(this.scope,routingKey,function(_this){return function(message){return _this.loadIssues()}}(this))},IssuesController.prototype.storeFilters=function(){return this.rs.issues.storeFilters(this.params.pslug,this.location.search())},IssuesController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_issues_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issueStatusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.issueStatusList=_.sortBy(project.issue_statuses,"order"),_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.severityList=_.sortBy(project.severities,"order"),_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),_this.scope.priorityList=_.sortBy(project.priorities,"order"),_this.scope.issueTypes=_.sortBy(project.issue_types,"order"),_this.scope.issueTypeById=groupBy(project.issue_types,function(x){return x.id}),project}}(this))},IssuesController.prototype.getUrlFilters=function(){var filters;return filters=_.pick(this.location.search(),"page","tags","status","types","q","severities","priorities","assignedTo","createdBy","orderBy"),filters.page||(filters.page=1),filters},IssuesController.prototype.getUrlFilter=function(name){var filters;return filters=_.pick(this.location.search(),name),filters[name]},IssuesController.prototype.loadMyFilters=function(){return this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return _.map(filters,function(value,key){return{id:key,name:key,type:"myFilters",selected:!1}})}}(this))},IssuesController.prototype.removeNotExistingFiltersFromUrl=function(){var currentSearch,existingValues,filterName,filterValue,splittedValues,urlfilters;currentSearch=this.location.search(),urlfilters=this.getUrlFilters();for(filterName in urlfilters)filterValue=urlfilters[filterName],"page"!==filterName&&"orderBy"!==filterName&&"q"!==filterName&&(splittedValues="tags"===filterName?_.map((""+filterValue).split(",")):_.map((""+filterValue).split(","),function(x){return"null"===x?null:parseInt(x)}),existingValues=_.intersection(splittedValues,_.map(this.scope.filters[filterName],"id")),splittedValues.length!==existingValues.length&&this.location.search(filterName,existingValues.join()));return currentSearch!==this.location.search()?this.location.replace():void 0},IssuesController.prototype.markSelectedFilters=function(filters,urlfilters){var isSelected,j,key,len,name,obj,ref,ref1,results,searchdata,val,value;searchdata={},ref=_.omit(urlfilters,"page","orderBy");for(name in ref)for(value=ref[name],null==searchdata[name]&&(searchdata[name]={}),ref1=(""+value).split(","),j=0,len=ref1.length;len>j;j++)val=ref1[j],searchdata[name][val]=!0;isSelected=function(type,id){return null!=searchdata[type]&&searchdata[type][id]?!0:!1},results=[];for(key in filters)value=filters[key],results.push(function(){var k,len1,results1;for(results1=[],k=0,len1=value.length;len1>k;k++)obj=value[k],results1.push(obj.selected=isSelected(obj.type,obj.id)?!0:void 0);return results1}());return results},IssuesController.prototype.loadFilters=function(){var loadFilters,promise,urlfilters;return urlfilters=this.getUrlFilters(),urlfilters.q&&(this.scope.filtersQ=urlfilters.q),promise=this.loadMyFilters().then(function(_this){return function(myFilters){return _this.scope.filters.myFilters=myFilters,myFilters}}(this)),loadFilters={},loadFilters.project=this.scope.projectId,loadFilters.tags=urlfilters.tags,loadFilters.status=urlfilters.status,loadFilters.q=urlfilters.q,loadFilters.types=urlfilters.types,loadFilters.severities=urlfilters.severities,loadFilters.priorities=urlfilters.priorities,loadFilters.assigned_to=urlfilters.assignedTo,loadFilters.owner=urlfilters.createdBy,promise=promise.then(function(_this){return function(){return _this.rs.issues.filtersData(loadFilters)}}(this)),promise.then(function(_this){return function(data){var choicesFiltersFormat,tagsFilterFormat,usersFiltersFormat;return usersFiltersFormat=function(users,type,unknownOption){var reformatedUsers,unknownItem;return reformatedUsers=_.map(users,function(t){return t.type=type,t.name=t.full_name?t.full_name:unknownOption,t}),unknownItem=_.remove(reformatedUsers,function(u){return!u.id}),reformatedUsers=_.sortBy(reformatedUsers,function(u){return u.name.toUpperCase()}),unknownItem.length>0&&reformatedUsers.unshift(unknownItem[0]),reformatedUsers},choicesFiltersFormat=function(choices,type,byIdObject){return _.map(choices,function(t){return t.type=type,t})},tagsFilterFormat=function(tags){return _.map(tags,function(t){return t.id=t.name,t.type="tags",t})},_this.scope.filters.status=choicesFiltersFormat(data.statuses,"status",_this.scope.issueStatusById),_this.scope.filters.severities=choicesFiltersFormat(data.severities,"severities",_this.scope.severityById),_this.scope.filters.priorities=choicesFiltersFormat(data.priorities,"priorities",_this.scope.priorityById),_this.scope.filters.assignedTo=usersFiltersFormat(data.assigned_to,"assignedTo","Unassigned"),_this.scope.filters.createdBy=usersFiltersFormat(data.owners,"createdBy","Unknown"),_this.scope.filters.types=choicesFiltersFormat(data.types,"types",_this.scope.issueTypeById),_this.scope.filters.tags=tagsFilterFormat(data.tags),_this.removeNotExistingFiltersFromUrl(),_this.markSelectedFilters(_this.scope.filters,urlfilters),_this.rootscope.$broadcast("filters:loaded",_this.scope.filters)}}(this))},IssuesController.prototype.loadIssuesRequests=0,IssuesController.prototype.loadIssues=function(){var name,promise,ref,values;this.scope.urlFilters=this.getUrlFilters(),this.scope.httpParams={},ref=this.scope.urlFilters;for(name in ref)values=ref[name],"severities"===name?name="severity":"orderBy"===name?name="order_by":"priorities"===name?name="priority":"assignedTo"===name?name="assigned_to":"createdBy"===name?name="owner":"status"===name?name="status":"types"===name&&(name="type"),this.scope.httpParams[name]=values;return promise=this.rs.issues.list(this.scope.projectId,this.scope.httpParams),this.loadIssuesRequests+=1,promise.index=this.loadIssuesRequests,promise.then(function(_this){return function(data){return promise.index===_this.loadIssuesRequests&&(_this.scope.issues=data.models,_this.scope.page=data.current,_this.scope.count=data.count,_this.scope.paginatedBy=data.paginatedBy),data}}(this)),promise},IssuesController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription(),_this.loadFilters(),_this.loadIssues()}}(this))},IssuesController.prototype.saveCurrentFiltersTo=function(newFilter){var deferred;return deferred=this.q.defer(),this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return filters[newFilter]=_this.location.search(),_this.rs.issues.storeMyFilters(_this.scope.projectId,filters).then(function(){return deferred.resolve()})}}(this)),deferred.promise},IssuesController.prototype.deleteMyFilter=function(filter){var deferred;return deferred=this.q.defer(),this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return delete filters[filter],_this.rs.issues.storeMyFilters(_this.scope.projectId,filters).then(function(){return deferred.resolve()})}}(this)),deferred.promise},IssuesController.prototype.addNewIssue=function(){return this.rootscope.$broadcast("issueform:new",this.scope.project)},IssuesController.prototype.addIssuesInBulk=function(){return this.rootscope.$broadcast("issueform:bulk",this.scope.projectId)},IssuesController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("IssuesController",IssuesController),IssuesDirective=function($log,$location,$template,$compile){var link,linkOrdering,linkPagination,template;return template=$template.get("issue/issue-paginator.html",!0),linkPagination=function($scope,$el,$attrs,$ctrl){var $pagEl,afterCurrent,atBegin,atEnd,beforeCurrent,getNumPages,renderPagination;return afterCurrent=2,beforeCurrent=4,atBegin=2,atEnd=2,$pagEl=$el.find(".issues-paginator"),getNumPages=function(){var numPages;return numPages=$scope.count/$scope.paginatedBy,numPages=parseInt(numPages,10)=numPages)return void $pagEl.hide();for($pagEl.show(),pages=[],options={},options.pages=pages,options.showPrevious=$scope.page>1,options.showNext=!($scope.page===numPages),cpage=$scope.page,i=j=1,ref=numPages;ref>=1?ref>=j:j>=ref;i=ref>=1?++j:--j)i===cpage+afterCurrent&&numPages>cpage+afterCurrent+atEnd?pages.push({classes:"dots",type:"dots"}):i===cpage-beforeCurrent&&cpage>atBegin+beforeCurrent?pages.push({classes:"dots",type:"dots"}):i>cpage+afterCurrent&&numPages-atEnd>=i||cpage-beforeCurrent>i&&i>atBegin||(i===cpage?pages.push({classes:"active",num:i,type:"page-active"}):pages.push({classes:"page",num:i,type:"page"}));return html=template(options),html=$compile(html)($scope),$pagEl.html(html)},$scope.$watch("issues",function(value){return value?renderPagination():void 0}),$el.on("click",".issues-paginator a.next",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page+1),$ctrl.loadIssues()})}),$el.on("click",".issues-paginator a.previous",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page-1),$ctrl.loadIssues()})}),$el.on("click",".issues-paginator li.page > a",function(event){var pagenum,target;return event.preventDefault(),target=angular.element(event.currentTarget),pagenum=target.data("pagenum"),$scope.$apply(function(){return $ctrl.selectFilter("page",pagenum),$ctrl.loadIssues()})})},linkOrdering=function($scope,$el,$attrs,$ctrl){var colHeadElement,currentOrder,icon;return currentOrder=$ctrl.getUrlFilter("orderBy")||"created_date",currentOrder&&(icon=startswith(currentOrder,"-")?"icon-arrow-up":"icon-arrow-bottom",colHeadElement=$el.find(".row.title > div[data-fieldname='"+trim(currentOrder,"-")+"']"),colHeadElement.html(colHeadElement.html()+"")),$el.on("click",".row.title > div",function(event){var finalOrder,newOrder,target;return target=angular.element(event.currentTarget),currentOrder=$ctrl.getUrlFilter("orderBy"),newOrder=target.data("fieldname"),finalOrder=currentOrder===newOrder?"-"+newOrder:newOrder,$scope.$apply(function(){return $ctrl.replaceFilter("orderBy",finalOrder),$ctrl.storeFilters(),$ctrl.loadIssues().then(function(){return $el.find(".row.title > div > span.icon").remove(),icon=startswith(finalOrder,"-")?"icon-arrow-up":"icon-arrow-bottom",target.html(target.html()+"")})})})},link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),linkOrdering($scope,$el,$attrs,$ctrl),linkPagination($scope,$el,$attrs,$ctrl),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssues",["$log","$tgLocation","$tgTemplate","$compile",IssuesDirective]),IssuesFiltersDirective=function($q,$log,$location,$rs,$confirm,$loading,$template,$translate,$compile,$auth){var link,template,templateSelected;return template=$template.get("issue/issues-filters.html",!0),templateSelected=$template.get("issue/issues-filters-selected.html",!0),link=function($scope,$el,$attrs){var $ctrl,getFiltersType,initializeSelectedFilters,reloadIssues,renderFilters,renderSelectedFilters,selectQFilter,selectedFilters,showCategories,showFilters,toggleFilterSelection,unwatchIssues;return $ctrl=$el.closest(".wrapper").controller(),selectedFilters=[],showFilters=function(title,type){return $el.find(".filters-cats").hide(),$el.find(".filter-list").removeClass("hidden"),$el.find("h2.breadcrumb").removeClass("hidden"),$el.find("h2 a.subfilter span.title").html(title),$el.find("h2 a.subfilter span.title").prop("data-type",type)},showCategories=function(){return $el.find(".filters-cats").show(),$el.find(".filter-list").addClass("hidden"),$el.find("h2.breadcrumb").addClass("hidden")},initializeSelectedFilters=function(filters){var j,len,name,val,values;selectedFilters=[];for(name in filters)for(values=filters[name],j=0,len=values.length;len>j;j++)val=values[j],val.selected&&selectedFilters.push(val);return renderSelectedFilters(selectedFilters)},renderSelectedFilters=function(selectedFilters){var html;return _.filter(selectedFilters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=templateSelected({filters:selectedFilters}),html=$compile(html)($scope),$el.find(".filters-applied").html(html),$auth.isAuthenticated()&&selectedFilters.length>0?$el.find(".save-filters").show():$el.find(".save-filters").hide()},renderFilters=function(filters){var html;return _.filter(filters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=template({filters:filters}),html=$compile(html)($scope),$el.find(".filter-list").html(html)},getFiltersType=function(){return $el.find("h2 a.subfilter span.title").prop("data-type")},reloadIssues=function(){var currentFiltersType;return currentFiltersType=getFiltersType(),$q.all([$ctrl.loadIssues(),$ctrl.loadFilters()]).then(function(){var filters;return filters=$scope.filters[currentFiltersType],renderFilters(_.reject(filters,"selected"))})},toggleFilterSelection=function(type,id){var currentFiltersType,filter,filterId,filters;return"myFilters"===type?($rs.issues.getMyFilters($scope.projectId).then(function(data){var filters,myFilters;return myFilters=data,filters=myFilters[id],filters.page=1,$ctrl.replaceAllFilters(filters),$ctrl.storeFilters(),$ctrl.loadIssues(),$ctrl.markSelectedFilters($scope.filters,filters),initializeSelectedFilters($scope.filters)}),null):(filters=$scope.filters[type],filterId="tags"===type?taiga.toString(id):id,filter=_.find(filters,{id:filterId}),filter.selected=!filter.selected,null===id&&(id="null"),filter.selected?(selectedFilters.push(filter),$ctrl.selectFilter(type,id),$ctrl.selectFilter("page",1),$ctrl.storeFilters()):(selectedFilters=_.reject(selectedFilters,function(f){return f.id===filter.id&&f.type===filter.type}),$ctrl.unselectFilter(type,id),$ctrl.selectFilter("page",1),$ctrl.storeFilters()),reloadIssues(),renderSelectedFilters(selectedFilters),currentFiltersType=getFiltersType(),type===currentFiltersType?renderFilters(_.reject(filters,"selected")):void 0)},$scope.$on("filters:loaded",function(ctx,filters){return initializeSelectedFilters(filters)}),$scope.$on("filters:issueupdate",function(ctx,filters){var html;return html=template({filters:filters.status}),html=$compile(html)($scope),$el.find(".filter-list").html(html)}),selectQFilter=debounceLeading(100,function(value,oldValue){return void 0!==value&&value!==oldValue?($ctrl.replaceFilter("page",null,!0),0===value.length?($ctrl.replaceFilter("q",null),$ctrl.storeFilters()):($ctrl.replaceFilter("q",value),$ctrl.storeFilters()),reloadIssues()):void 0}),unwatchIssues=$scope.$watch("issues",function(newValue){return _.isUndefined(newValue)?void 0:($scope.$watch("filtersQ",selectQFilter),unwatchIssues())}),$el.on("click",".filters-cats > ul > li > a",function(event){var tags,target;return event.preventDefault(),target=angular.element(event.currentTarget),tags=$scope.filters[target.data("type")],renderFilters(_.reject(tags,"selected")),showFilters(target.attr("title"),target.data("type"))}),$el.on("click",".filters-inner > .filters-step-cat > .breadcrumb > .back",function(event){return event.preventDefault(),showCategories($el)}),$el.on("click",".filters-applied a",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),id=target.data("id")||null,type=target.data("type"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),target.toggleClass("active"),id=target.data("id")||null,type=target.data("type"),"myFilters"===type&&target.removeClass("active"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter .icon-delete",function(event){var customFilterName,message,target,title;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),customFilterName=target.parent().data("id"),title=$translate.instant("ISSUES.FILTERS.CONFIRM_DELETE.TITLE"),message=$translate.instant("ISSUES.FILTERS.CONFIRM_DELETE.MESSAGE",{customFilterName:customFilterName}),$confirm.askOnDelete(title,message).then(function(askResponse){var promise;return promise=$ctrl.deleteMyFilter(customFilterName),promise.then(function(){return promise=$ctrl.loadMyFilters(),promise.then(function(filters){return askResponse.finish(),$scope.filters.myFilters=filters,renderFilters($scope.filters.myFilters)}),promise.then(null,function(){return askResponse.finish()})}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})})}),$el.on("click",".save-filters",function(event){return event.preventDefault(),renderFilters($scope.filters.myFilters),showFilters("My filters","myFilters"),$el.find(".save-filters").hide(),$el.find(".my-filter-name").removeClass("hidden"),$el.find(".my-filter-name").focus(),$scope.$apply()}),$el.on("keyup",".my-filter-name",function(event){var currentLoading,newFilter,promise,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newFilter=target.val(),currentLoading=$loading().target($el.find(".new")).start(),promise=$ctrl.saveCurrentFiltersTo(newFilter),promise.then(function(){var loadPromise;return loadPromise=$ctrl.loadMyFilters(),loadPromise.then(function(filters){var currentfilterstype;return currentLoading.finish(),$scope.filters.myFilters=filters,currentfilterstype=$el.find("h2 a.subfilter span.title").prop("data-type"),"myFilters"===currentfilterstype&&renderFilters($scope.filters.myFilters),$el.find(".my-filter-name").addClass("hidden"),$el.find(".save-filters").show()}),loadPromise.then(null,function(){return currentLoading.finish(),$confirm.notify("error","Error loading custom filters")})}),promise.then(null,function(){return currentLoading.finish(),$el.find(".my-filter-name").val(newFilter).focus().select(),$confirm.notify("error","Filter not saved")})):27===event.keyCode?($el.find(".my-filter-name").val(""),$el.find(".my-filter-name").addClass("hidden"),$el.find(".save-filters").show()):void 0})},{link:link}},module.directive("tgIssuesFilters",["$q","$log","$tgLocation","$tgResources","$tgConfirm","$tgLoading","$tgTemplate","$translate","$compile","$tgAuth",IssuesFiltersDirective]),IssueStatusInlineEditionDirective=function($repo,$template,$rootscope){var link,selectionTemplate,updateIssueStatus;return selectionTemplate=$template.get("issue/issue-status-inline-edition-selection.html",!0),updateIssueStatus=function($el,issue,issueStatusById){var issueStatusDom,issueStatusDomParent,status;return issueStatusDomParent=$el.find(".issue-status"),issueStatusDom=$el.find(".issue-status .issue-status-bind"),status=issueStatusById[issue.status],status?(issueStatusDom.text(status.name),issueStatusDom.prop("title",status.name),issueStatusDomParent.css("color",status.color)):void 0},link=function($scope,$el,$attrs){var $ctrl,issue;return $ctrl=$el.controller(),issue=$scope.$eval($attrs.tgIssueStatusInlineEdition),$el.on("click",".issue-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",function(event){var filter,j,len,ref,target;for(event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),ref=$scope.filters.status,j=0,len=ref.length;len>j;j++)filter=ref[j],filter.id===issue.status&&filter.count--;return issue.status=target.data("status-id"),$el.find(".pop-status").popover().close(),updateIssueStatus($el,issue,$scope.issueStatusById),$scope.$apply(function(){var k,len1,ref1;for($repo.save(issue).then(function(){return $ctrl.loadIssues()}),ref1=$scope.filters.status,k=0,len1=ref1.length;len1>k;k++)filter=ref1[k],filter.id===issue.status&&filter.count++;return $rootscope.$broadcast("filters:issueupdate",$scope.filters)})}),taiga.bindOnce($scope,"project",function(project){return $el.append(selectionTemplate({statuses:project.issue_statuses})),updateIssueStatus($el,issue,$scope.issueStatusById),-1===project.my_permissions.indexOf("modify_issue")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$watch($attrs.tgIssueStatusInlineEdition,function(_this){return function(val){return updateIssueStatus($el,val,$scope.issueStatusById)}}(this)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssueStatusInlineEdition",["$tgRepo","$tgTemplate","$rootScope",IssueStatusInlineEditionDirective]),IssueAssignedToInlineEditionDirective=function($repo,$rootscope,$translate){var link,template;return template=_.template('<%- name %>\n
<%- name %>
'),link=function($scope,$el,$attrs){var $ctrl,issue,updateIssue;return updateIssue=function(issue){var ctx,member;return ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=$scope.usersById[issue.assigned_to],member&&(ctx.name=member.full_name_display,ctx.imgurl=member.photo),$el.find(".avatar").html(template(ctx)),$el.find(".issue-assignedto").attr("title",ctx.name)},$ctrl=$el.controller(),issue=$scope.$eval($attrs.tgIssueAssignedToInlineEdition),updateIssue(issue),$el.on("click",".issue-assignedto",function(event){return $rootscope.$broadcast("assigned-to:add",issue)}),taiga.bindOnce($scope,"project",function(project){return-1===project.my_permissions.indexOf("modify_issue")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("assigned-to:added",function(_this){return function(ctx,userId,updatedIssue){return updatedIssue.id===issue.id?(updatedIssue.assigned_to=userId,$repo.save(updatedIssue),updateIssue(updatedIssue)):void 0}}(this)),$scope.$watch($attrs.tgIssueAssignedToInlineEdition,function(_this){return function(val){return updateIssue(val)}}(this)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssueAssignedToInlineEdition",["$tgRepo","$rootScope","$translate",IssueAssignedToInlineEditionDirective])}.call(this),function(){var UsClientRequirementButtonDirective,UsStatusButtonDirective,UsStatusDisplayDirective,UsTeamRequirementButtonDirective,UserStoryDetailController,bindMethods,bindOnce,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaUserStories"),UserStoryDetailController=function(superClass){function UserStoryDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.usRef=this.params.usref,this.scope.sectionName=this.translate.instant("US.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserStoryDetailController,superClass),UserStoryDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],UserStoryDetailController.prototype._setMeta=function(){var closedTasks,description,progressPercentage,ref,title,totalTasks;return totalTasks=this.scope.tasks.length,closedTasks=_.filter(this.scope.tasks,function(_this){return function(t){return _this.scope.taskStatusById[t.status].is_closed}}(this)).length,progressPercentage=totalTasks>0?Math.round(100*closedTasks/totalTasks):0,title=this.translate.instant("US.PAGE_TITLE",{userStoryRef:"#"+this.scope.us.ref,userStorySubject:this.scope.us.subject,projectName:this.scope.project.name}),description=this.translate.instant("US.PAGE_DESCRIPTION",{userStoryStatus:(null!=(ref=this.scope.statusById[this.scope.us.status])?ref.name:void 0)||"--",userStoryPoints:this.scope.us.total_points,userStoryDescription:angular.element(this.scope.us.description_html||"").text(),userStoryClosedTasks:closedTasks,userStoryTotalTasks:totalTasks,userStoryProgressPercentage:progressPercentage}),this.appMetaService.setAll(title,description)},UserStoryDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("related-tasks:update",function(_this){return function(){return _this.scope.tasks=_.clone(_this.scope.tasks,!1)}}(this)),this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on userstory",1)}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadUs()}}(this))},UserStoryDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;return ctx={project:this.scope.project.slug},this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx),this.scope.project.is_backlog_activated?this.scope.us.milestone?(ctx.sprint=this.scope.sprint.slug,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-taskboard",ctx)):this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-backlog",ctx):this.scope.project.is_kanban_activated?this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-kanban",ctx):void 0},UserStoryDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.us_statuses,_this.scope.statusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.taskStatusById=groupBy(project.task_statuses,function(x){return x.id}),_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(_this.scope.pointsList,function(e){return e.id}),project}}(this))},UserStoryDetailController.prototype.loadUs=function(){var httpParams,kanbanStaus,milestone,noMilestone;return httpParams=_.pick(this.location.search(),"milestone","no-milestone","kanban-status"),milestone=httpParams.milestone,milestone&&this.rs.userstories.storeQueryParams(this.scope.projectId,{milestone:milestone,order_by:"sprint_order"}),noMilestone=httpParams["no-milestone"],noMilestone&&this.rs.userstories.storeQueryParams(this.scope.projectId,{milestone:"null",order_by:"backlog_order"}),kanbanStaus=httpParams["kanban-status"],kanbanStaus&&this.rs.userstories.storeQueryParams(this.scope.projectId,{status:kanbanStaus,order_by:"kanban_order"}),this.rs.userstories.getByRef(this.scope.projectId,this.params.usref).then(function(_this){return function(us){var ctx,ref,ref1;return _this.scope.us=us,_this.scope.usId=us.id,_this.scope.commentModel=us,null!=(null!=(ref=_this.scope.us.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.us.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-userstories-detail",ctx)),null!=(null!=(ref1=_this.scope.us.neighbors.next)?ref1.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.us.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-userstories-detail",ctx)),us}}(this))},UserStoryDetailController.prototype.loadSprint=function(){return this.scope.us.milestone?this.rs.sprints.get(this.scope.us.project,this.scope.us.milestone).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,sprint}}(this)):void 0},UserStoryDetailController.prototype.loadTasks=function(){return this.rs.tasks.list(this.scope.projectId,null,this.scope.usId).then(function(_this){return function(tasks){return _this.scope.tasks=tasks,tasks}}(this))},UserStoryDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadUs().then(function(){return _this.q.all([_this.loadSprint(),_this.loadTasks()])})}}(this))},UserStoryDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.upvote(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.downvote(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onWatch=function(){ -var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.watch(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.unwatch(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserStoryDetailController",UserStoryDetailController),UsStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(us){var html,status;return status=$scope.statusById[us.status],html=template({is_closed:us.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(us){return null!=us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsStatusDisplay",["$tgTemplate","$compile",UsStatusDisplayDirective]),UsStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template){var link,template;return template=$template.get("us/us-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(_this){return function(us){var html,status;return status=$scope.statusById[us.status],html=template({status:status,statuses:$scope.statusList,editable:isEditable()}),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(status){var currentLoading,onError,onSuccess,us;return us=$model.$modelValue.clone(),us.status=status,$.fn.popover().closeAll(),currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(us),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),currentLoading.finish()},$repo.save(us).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var status,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),status=target.data("status-id"),save(status)):void 0}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate",UsStatusButtonDirective]),UsTeamRequirementButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("us/us-team-requirement-button.html",!0),link=function($scope,$el,$attrs,$model){var canEdit,render,save;return canEdit=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(us){var ctx,html;return ctx={canEdit:canEdit(),isRequired:us.team_requirement},html=template(ctx),html=$compile(html)($scope),$el.html(html)},save=$qqueue.bindAdd(function(_this){return function(team_requirement){var currentLoading,promise,us;return us=$model.$modelValue.clone(),us.team_requirement=team_requirement,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(us),promise.then(function(){return $model.$setViewValue(us),currentLoading.finish(),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})}}(this)),$el.on("click",".team-requirement",function(event){var team_requirement;if(canEdit())return team_requirement=!$model.$modelValue.team_requirement,save(team_requirement)}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsTeamRequirementButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",UsTeamRequirementButtonDirective]),UsClientRequirementButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("us/us-client-requirement-button.html",!0),link=function($scope,$el,$attrs,$model){var canEdit,render,save;return canEdit=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(us){var ctx,html;return ctx={canEdit:canEdit(),isRequired:us.client_requirement},html=$compile(template(ctx))($scope),$el.html(html)},save=$qqueue.bindAdd(function(_this){return function(client_requirement){var currentLoading,promise,us;return us=$model.$modelValue.clone(),us.client_requirement=client_requirement,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(us),promise.then(function(){return $model.$setViewValue(us),currentLoading.finish(),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error")})}}(this)),$el.on("click",".client-requirement",function(event){var client_requirement;if(canEdit())return client_requirement=!$model.$modelValue.client_requirement,save(client_requirement)}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsClientRequirementButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",UsClientRequirementButtonDirective])}.call(this),function(){var TaskDetailController,TaskIsIocaineButtonDirective,TaskStatusButtonDirective,TaskStatusDisplayDirective,bindMethods,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindMethods=this.taiga.bindMethods,module=angular.module("taigaTasks"),TaskDetailController=function(superClass){function TaskDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.taskRef=this.params.taskref,this.scope.sectionName=this.translate.instant("TASK.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TaskDetailController,superClass),TaskDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],TaskDetailController.prototype._setMeta=function(){var description,ref,title;return title=this.translate.instant("TASK.PAGE_TITLE",{taskRef:"#"+this.scope.task.ref,taskSubject:this.scope.task.subject,projectName:this.scope.project.name}),description=this.translate.instant("TASK.PAGE_DESCRIPTION",{taskStatus:(null!=(ref=this.scope.statusById[this.scope.task.status])?ref.name:void 0)||"--",taskDescription:angular.element(this.scope.task.description_html||"").text()}),this.appMetaService.setAll(title,description)},TaskDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on task",1)}}(this)),this.scope.$on("custom-attributes-values:edit",function(_this){return function(){return _this.rootscope.$broadcast("object:updated")}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadTask()}}(this))},TaskDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;if(ctx={project:this.scope.project.slug},this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx),this.scope.project.is_backlog_activated){if(this.scope.task.milestone)return ctx.sprint=this.scope.sprint.slug,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-taskboard",ctx);if(this.scope.task.us)return ctx.ref=this.scope.us.ref,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-userstories-detail",ctx)}else if(this.scope.project.is_kanban_activated&&this.scope.us)return ctx.ref=this.scope.us.ref,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-userstories-detail",ctx)},TaskDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.task_statuses,_this.scope.statusById=groupBy(project.task_statuses,function(x){return x.id}),project}}(this))},TaskDetailController.prototype.loadTask=function(){return this.rs.tasks.getByRef(this.scope.projectId,this.params.taskref).then(function(_this){return function(task){var ctx,ref,ref1;return _this.scope.task=task,_this.scope.taskId=task.id,_this.scope.commentModel=task,null!=(null!=(ref=_this.scope.task.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.task.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-tasks-detail",ctx)),null!=(null!=(ref1=_this.scope.task.neighbors.next)?ref1.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.task.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-tasks-detail",ctx)),task}}(this))},TaskDetailController.prototype.loadSprint=function(){return this.scope.task.milestone?this.rs.sprints.get(this.scope.task.project,this.scope.task.milestone).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,sprint}}(this)):void 0},TaskDetailController.prototype.loadUserStory=function(){return this.scope.task.user_story?this.rs.userstories.get(this.scope.task.project,this.scope.task.user_story).then(function(_this){return function(us){return _this.scope.us=us,us}}(this)):void 0},TaskDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadTask().then(function(){return _this.q.all([_this.loadSprint(),_this.loadUserStory()])})}}(this))},TaskDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.upvote(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.downvote(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onWatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.watch(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.unwatch(this.scope.taskId).then(onSuccess,onError)},TaskDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TaskDetailController",TaskDetailController),TaskStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(task){var html,status;return status=$scope.statusById[task.status],html=template({is_closed:status.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(task){return null!=task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskStatusDisplay",["$tgTemplate","$compile",TaskStatusDisplayDirective]),TaskStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$compile,$translate,$template){var link,template;return template=$template.get("us/us-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_task")},render=function(_this){return function(task){var html,status;return status=$scope.statusById[task.status],html=$compile(template({status:status,statuses:$scope.statusList,editable:isEditable()}))($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(status){var currentLoading,onError,onSuccess,task;return task=$model.$modelValue.clone(),task.status=status,currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(task),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),currentLoading.finish()},$repo.save(task).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),$.fn.popover().closeAll(),save(target.data("status-id"))):void 0}),$scope.$watch($attrs.ngModel,function(task){return task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$compile","$translate","$tgTemplate",TaskStatusButtonDirective]),TaskIsIocaineButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$compile,$template){var link,template;return template=$template.get("issue/iocaine-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_task")},render=function(task){var ctx,html;return isEditable()||task.is_iocaine?(ctx={isIocaine:task.is_iocaine,isEditable:isEditable()},html=$compile(template(ctx))($scope),$el.html(html)):void $el.html("")},save=$qqueue.bindAdd(function(_this){return function(is_iocaine){var currentLoading,promise,task;return task=$model.$modelValue.clone(),task.is_iocaine=is_iocaine,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(task),promise.then(function(){return $model.$setViewValue(task),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()})}}(this)),$el.on("click",".is-iocaine",function(event){var is_iocaine;if(isEditable())return is_iocaine=!$model.$modelValue.is_iocaine,save(is_iocaine)}),$scope.$watch($attrs.ngModel,function(task){return task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskIsIocaineButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$compile","$tgTemplate",TaskIsIocaineButtonDirective])}.call(this),function(){var LeaveProjectDirective,TeamController,TeamFiltersDirective,TeamMemberCurrentUserDirective,TeamMemberStatsDirective,TeamMembersDirective,membersFilter,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,module=angular.module("taigaTeam"),TeamController=function(superClass){function TeamController(scope,rootscope,repo,rs,params,q,location,navUrls,appMetaService,auth,translate,projectService){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.auth=auth,this.translate=translate,this.projectService=projectService,this.scope.sectionName="TEAM.SECTION_NAME",promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("TEAM.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("TEAM.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TeamController,superClass),TeamController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$routeParams","$q","$location","$tgNavUrls","tgAppMetaService","$tgAuth","$translate","tgProjectService"],TeamController.prototype.setRole=function(role){return role?this.scope.filtersRole=role:this.scope.filtersRole=null},TeamController.prototype.loadMembers=function(){var i,len,member,ref,user;for(user=this.auth.getUser(),this.scope.totals={},ref=this.scope.activeUsers,i=0,len=ref.length;len>i;i++)member=ref[i],this.scope.totals[member.id]=0;return this.scope.currentUser=_.find(this.scope.activeUsers,{id:null!=user?user.id:void 0}),this.scope.memberships=_.reject(this.scope.activeUsers,{id:null!=user?user.id:void 0})},TeamController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issuesEnabled=project.is_issues_activated,_this.scope.tasksEnabled=project.is_kanban_activated||project.is_backlog_activated,_this.scope.wikiEnabled=project.is_wiki_activated,project}}(this))},TeamController.prototype.loadMemberStats=function(){return this.rs.projects.memberStats(this.scope.projectId).then(function(_this){return function(stats){var totals;return totals={},_.forEach(_this.scope.totals,function(total,userId){var vals;return vals=_.map(stats,function(memberStats,statsKey){return memberStats[userId]}),total=_.reduce(vals,function(sum,el){return sum+el}),_this.scope.totals[userId]=total}),_this.scope.stats=_this._processStats(stats),_this.scope.stats.totals=_this.scope.totals}}(this))},TeamController.prototype._processStat=function(stat){var max,min,singleStat;return max=_.max(stat),min=_.min(stat),singleStat=_.map(stat,function(value,key){return value===min?[key,.1]:value===max?[key,1]:[key,.5*value/max]}),singleStat=_.object(singleStat)},TeamController.prototype._processStats=function(stats){var key,value;for(key in stats)value=stats[key],stats[key]=this._processStat(value);return stats},TeamController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadMembers(),_this.loadMemberStats()}}(this))},TeamController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TeamController",TeamController),TeamFiltersDirective=function(){return{templateUrl:"team/team-filter.html"}},module.directive("tgTeamFilters",[TeamFiltersDirective]),TeamMemberStatsDirective=function(){return{templateUrl:"team/team-member-stats.html",scope:{stats:"=",userId:"=user",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamMemberStats",TeamMemberStatsDirective),TeamMemberCurrentUserDirective=function(){return{templateUrl:"team/team-member-current-user.html",scope:{projectId:"=projectid",currentUser:"=currentuser",stats:"=",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamCurrentUser",TeamMemberCurrentUserDirective),TeamMembersDirective=function(){var template;return template="team/team-members.html",{templateUrl:template,scope:{memberships:"=",filtersQ:"=filtersq",filtersRole:"=filtersrole",stats:"=",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamMembers",TeamMembersDirective),LeaveProjectDirective=function($repo,$confirm,$location,$rs,$navurls,$translate){var link;return link=function($scope,$el,$attrs){return $scope.leave=function(){var confirm_leave_project_text,leave_project_text;return leave_project_text=$translate.instant("TEAM.ACTION_LEAVE_PROJECT"),confirm_leave_project_text=$translate.instant("TEAM.CONFIRM_LEAVE_PROJECT"),$confirm.ask(leave_project_text,confirm_leave_project_text).then(function(_this){return function(response){var promise;return promise=$rs.projects.leave($attrs.projectid),promise.then(function(){return response.finish(),$confirm.notify("success"),$location.path($navurls.resolve("home"))}),promise.then(null,function(response){return response.finish(),$confirm.notify("error",response.data._error_message)})}}(this))}},{scope:{},templateUrl:"team/leave-project.html",link:link}},module.directive("tgLeaveProject",["$tgRepo","$tgConfirm","$tgLocation","$tgResources","$tgNavUrls","$translate",LeaveProjectDirective]),membersFilter=function(){return function(members,filtersQ,filtersRole){return _.filter(members,function(m){return(!filtersRole||m.role===filtersRole.id)&&(!filtersQ||m.full_name.search(new RegExp(filtersQ,"i"))>=0)})}},module.filter("membersFilter",membersFilter)}.call(this),function(){var EditableWikiContentDirective,WikiDetailController,WikiSummaryDirective,bindOnce,debounce,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaWiki"),WikiDetailController=function(superClass){function WikiDetailController(scope,rootscope,repo,model,confirm,rs,params,q,location,filter,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.model=model,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.filter=filter,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,this.scope.projectSlug=this.params.pslug,this.scope.wikiSlug=this.params.slug,this.scope.wikiTitle=this.scope.wikiSlug,this.scope.sectionName="Wiki",this.scope.linksVisible=!1,promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(WikiDetailController,superClass),WikiDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgModel","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$filter","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],WikiDetailController.prototype._setMeta=function(){var description,ref,ref1,ref2,title;return title=this.translate.instant("WIKI.PAGE_TITLE",{wikiPageName:this.scope.wikiTitle,projectName:this.scope.project.name}),description=this.translate.instant("WIKI.PAGE_DESCRIPTION",{wikiPageContent:angular.element((null!=(ref=this.scope.wiki)?ref.html:void 0)||"").text(),totalEditions:(null!=(ref1=this.scope.wiki)?ref1.editions:void 0)||0,lastModifiedDate:moment(null!=(ref2=this.scope.wiki)?ref2.modified_date:void 0).format(this.translate.instant("WIKI.DATETIME"))}),this.appMetaService.setAll(title,description)},WikiDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_wiki_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},WikiDetailController.prototype.loadWiki=function(){var promise;return promise=this.rs.wiki.getBySlug(this.scope.projectId,this.params.slug),promise.then(function(_this){return function(wiki){return _this.scope.wiki=wiki,_this.scope.wikiId=wiki.id,_this.scope.wiki}}(this)),promise.then(null,function(_this){return function(xhr){var data;return _this.scope.wikiId=null,-1===_this.scope.project.my_permissions.indexOf("add_wiki_page")?null:(data={project:_this.scope.projectId,slug:_this.scope.wikiSlug,content:""},_this.scope.wiki=_this.model.make_model("wiki",data),_this.scope.wiki)}}(this))},WikiDetailController.prototype.loadWikiLinks=function(){return this.rs.wiki.listLinks(this.scope.projectId).then(function(_this){return function(wikiLinks){var selectedWikiLink;return _this.scope.wikiLinks=wikiLinks,selectedWikiLink=_.find(wikiLinks,{href:_this.scope.wikiSlug}),null!=selectedWikiLink?_this.scope.wikiTitle=selectedWikiLink.title:void 0}}(this))},WikiDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.q.all([_this.loadWikiLinks(),_this.loadWiki()]).then(_this.checkLinksPerms.bind(_this))}}(this))},WikiDetailController.prototype.checkLinksPerms=function(){return-1!==this.scope.project.my_permissions.indexOf("modify_wiki_link")||-1!==this.scope.project.my_permissions.indexOf("view_wiki_links")&&this.scope.wikiLinks.length?this.scope.linksVisible=!0:void 0},WikiDetailController.prototype["delete"]=function(){var message,title;return title=this.translate.instant("WIKI.DELETE_LIGHTBOX_TITLE"),message=this.scope.wikiTitle,this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onSuccess=function(){var ctx;return askResponse.finish(),ctx={project:_this.scope.projectSlug},_this.location.path(_this.navUrls.resolve("project-wiki",ctx)),_this.confirm.notify("success")},onError=function(){return askResponse.finish(!1),_this.confirm.notify("error")},_this.repo.remove(_this.scope.wiki).then(onSuccess,onError)}}(this))},WikiDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("WikiDetailController",WikiDetailController),WikiSummaryDirective=function($log,$template,$compile,$translate){var link,template;return template=$template.get("wiki/wiki-summary.html",!0),link=function($scope,$el,$attrs,$model){var render;return render=function(wiki){var ctx,html,user;return null==$scope.usersById?$log.error("WikiSummaryDirective requires userById set in scope."):user=$scope.usersById[wiki.last_modifier],user=void 0===user?{name:"unknown",imgUrl:"/"+window._version+"/images/user-noimage.png"}:{name:user.full_name_display,imgUrl:user.photo},ctx={totalEditions:wiki.editions,lastModifiedDate:moment(wiki.modified_date).format($translate.instant("WIKI.DATETIME")),user:user},html=template(ctx),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(wikiPage){return wikiPage?render(wikiPage):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgWikiSummary",["$log","$tgTemplate","$compile","$translate",WikiSummaryDirective]),EditableWikiContentDirective=function($window,$document,$repo,$confirm,$loading,$analytics,$qqueue){var link;return link=function($scope,$el,$attrs,$model){var cancelEdition,disableEdition,getSelectedText,isEditable,save,switchToEditMode,switchToReadMode;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_wiki_page")},switchToEditMode=function(){return $el.find(".edit-wiki-content").show(),$el.find(".view-wiki-content").hide(),$el.find("textarea").focus()},switchToReadMode=function(){return $el.find(".edit-wiki-content").hide(),$el.find(".view-wiki-content").show()},disableEdition=function(){return $el.find(".view-wiki-content .edit").remove(),$el.find(".edit-wiki-content").remove()},cancelEdition=function(){return $model.$modelValue.id?($scope.$apply(function(_this){return function(){return $model.$modelValue.revert()}}(this)),switchToReadMode()):void 0},getSelectedText=function(){return $window.getSelection?$window.getSelection().toString():$document.selection?$document.selection.createRange().text:null},save=$qqueue.bindAdd(function(wiki){var currentLoading,onError,onSuccess,promise;return onSuccess=function(wikiPage){return null==wiki.id&&$analytics.trackEvent("wikipage","create","create wiki page",1),$model.$setViewValue(wikiPage.clone()),$confirm.notify("success"),switchToReadMode()},onError=function(){return $confirm.notify("error")},currentLoading=$loading().removeClasses("icon-floppy").target($el.find(".icon-floppy")).start(),promise=null!=wiki.id?$repo.save(wiki).then(onSuccess,onError):$repo.create("wiki",wiki).then(onSuccess,onError),promise["finally"](function(){return currentLoading.finish()})}),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("mousedown",".view-wiki-content",function(event){var target;target=angular.element(event.target),isEditable()&&2===event.button}),$el.on("mouseup",".view-wiki-content",function(event){var target;return target=angular.element(event.target),getSelectedText()||!isEditable()||target.is("a")||target.is("pre")?void 0:switchToEditMode()}),$el.on("click",".save",debounce(2e3,function(){return save($scope.wiki)})),$el.on("click",".cancel",function(){return cancelEdition()}),$el.on("keydown","textarea",function(event){return 27===event.keyCode?cancelEdition():void 0}),$scope.$watch($attrs.ngModel,function(wikiPage){return wikiPage?isEditable()?($el.addClass("editable"),null==wikiPage.id||0===$.trim(wikiPage.content).length?switchToEditMode():void 0):disableEdition():void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",templateUrl:"wiki/editable-wiki-content.html"}},module.directive("tgEditableWikiContent",["$window","$document","$tgRepo","$tgConfirm","$tgLoading","$tgAnalytics","$tgQqueue",EditableWikiContentDirective]); -}.call(this),function(){var WikiNavDirective,bindOnce,groupBy,mixOf,module,taiga;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,module=angular.module("taigaWiki"),WikiNavDirective=function($tgrepo,$log,$location,$confirm,$navUrls,$analytics,$loading,$template,$compile,$translate){var link,template;return template=$template.get("wiki/wiki-nav.html",!0),link=function($scope,$el,$attrs){var $ctrl,render;return $ctrl=$el.controller(),null==$attrs.ngModel?$log.error("WikiNavDirective: no ng-model attr is defined"):(render=function(wikiLinks){var addWikiLinkPermission,deleteWikiLinkPermission,html;return addWikiLinkPermission=$scope.project.my_permissions.indexOf("add_wiki_link")>-1,deleteWikiLinkPermission=$scope.project.my_permissions.indexOf("delete_wiki_link")>-1,html=template({wikiLinks:wikiLinks,projectSlug:$scope.projectSlug,addWikiLinkPermission:addWikiLinkPermission,deleteWikiLinkPermission:deleteWikiLinkPermission}),html=$compile(html)($scope),$el.off(),$el.html(html),$el.on("click",".wiki-link .link-title",function(event){var linkId,linkSlug,target;return event.preventDefault(),target=angular.element(event.currentTarget),linkId=target.parents(".wiki-link").data("id"),linkSlug=$scope.wikiLinks[linkId].href,$scope.$apply(function(){var ctx;return ctx={project:$scope.projectSlug,slug:linkSlug},$location.path($navUrls.resolve("project-wiki-page",ctx))})}),$el.on("click",".add-button",function(event){return event.preventDefault(),$el.find(".new").removeClass("hidden"),$el.find(".new input").focus(),$el.find(".add-button").hide()}),$el.on("click",".wiki-link .icon-delete",function(event){var linkId,message,target,title;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),linkId=target.parents(".wiki-link").data("id"),title=$translate.instant("WIKI.DELETE_LIGHTBOX_TITLE"),message=$scope.wikiLinks[linkId].title,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var promise;return promise=$tgrepo.remove($scope.wikiLinks[linkId]),promise.then(function(){return promise=$ctrl.loadWikiLinks(),promise.then(function(){return askResponse.finish(),render($scope.wikiLinks)}),promise.then(null,function(){return askResponse.finish()})}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})}}(this))}),$el.on("keyup",".new input",function(event){var currentLoading,newLink,promise,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newLink=target.val(),currentLoading=$loading().target($el.find(".new")).start(),promise=$tgrepo.create("wiki-links",{project:$scope.projectId,title:newLink}),promise.then(function(){var loadPromise;return $analytics.trackEvent("wikilink","create","create wiki link",1),loadPromise=$ctrl.loadWikiLinks(),loadPromise.then(function(){return currentLoading.finish(),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show(),render($scope.wikiLinks)}),loadPromise.then(null,function(){return currentLoading.finish(),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show(),$confirm.notify("error","Error loading wiki links")})}),promise.then(null,function(error){var ref;return currentLoading.finish(),$el.find(".new input").val(newLink),$el.find(".new input").focus().select(),null!=(null!=error&&null!=(ref=error.__all__)?ref[0]:void 0)?$confirm.notify("error","The link already exists"):$confirm.notify("error")})):27===event.keyCode?(target=angular.element(event.currentTarget),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show()):void 0})},bindOnce($scope,$attrs.ngModel,render))},{link:link}},module.directive("tgWikiNav",["$tgRepo","$log","$tgLocation","$tgConfirm","$tgNavUrls","$tgAnalytics","$tgLoading","$tgTemplate","$compile","$translate",WikiNavDirective])}.call(this),function(){var CreateMembersDirective,MAX_MEMBERSHIP_FIELDSETS,debounce,module,taiga;taiga=this.taiga,debounce=this.taiga.debounce,module=angular.module("taigaKanban"),MAX_MEMBERSHIP_FIELDSETS=4,CreateMembersDirective=function($rs,$rootScope,$confirm,$loading,lightboxService,$compile){var extraTextTemplate,link,template;return extraTextTemplate='
\n \n
',template=_.template('
\n
\n data-required="true" <% } %> data-type="email" />\n
\n
\n \n \n
\n
'),link=function($scope,$el,$attrs){var createFieldSet,resetForm,submit,submitButton;return createFieldSet=function(required){var ctx;return null==required&&(required=!0),ctx={roleList:$scope.project.roles,required:required},$compile(template(ctx))($scope)},resetForm=function(){var fieldSet,invitations;return $el.find("form textarea").remove(),$el.find("form .add-member-wrapper").remove(),invitations=$el.find(".add-member-forms"),invitations.html($compile(extraTextTemplate)($scope)),fieldSet=createFieldSet(),invitations.prepend(fieldSet)},$scope.$on("membersform:new",function(){return resetForm(),lightboxService.open($el)}),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click",".delete-fieldset",function(event){var fieldSet,lastActionButton,target;return event.preventDefault(),target=angular.element(event.currentTarget),fieldSet=target.closest(".add-member-wrapper"),fieldSet.remove(),lastActionButton=$el.find(".add-member-wrapper fieldset:last > a"),lastActionButton.hasClass("icon-delete delete-fieldset")?lastActionButton.removeClass("icon-delete delete-fieldset").addClass("icon-plus add-fieldset"):void 0}),$el.on("click",".add-fieldset",function(event){var fieldSet,newFieldSet,target;return event.preventDefault(),target=angular.element(event.currentTarget),fieldSet=target.closest(".add-member-wrapper"),target.removeClass("icon-plus add-fieldset").addClass("icon-delete delete-fieldset"),newFieldSet=createFieldSet(!1),fieldSet.after(newFieldSet),$scope.$digest(),$el.find(".add-member-wrapper").length===MAX_MEMBERSHIP_FIELDSETS?$el.find(".add-member-wrapper fieldset:last > a").removeClass("icon-plus add-fieldset").addClass("icon-delete delete-fieldset"):void 0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,form,invitation_extra_text,invitations,memberWrappers,onError,onSuccess,promise;return event.preventDefault(),currentLoading=$loading().target(submitButton).start(),onSuccess=function(data){return currentLoading.finish(),lightboxService.close($el),$confirm.notify("success"),$rootScope.$broadcast("membersform:new:success")},onError=function(data){return currentLoading.finish(),lightboxService.close($el),$confirm.notify("error"),$rootScope.$broadcast("membersform:new:error")},form=$el.find("form").checksley(),form.destroy(),form.initialize(),form.validate()?(memberWrappers=$el.find("form .add-member-wrapper"),memberWrappers=_.filter(memberWrappers,function(mw){return angular.element(mw).find("input").hasClass("checksley-ok")}),invitations=_.map(memberWrappers,function(mw){var email,memberWrapper,role;return memberWrapper=angular.element(mw),email=memberWrapper.find("input"),role=memberWrapper.find("select"),{email:email.val(),role_id:role.val()}}),invitations.length?(invitation_extra_text=$el.find("form textarea").val(),promise=$rs.memberships.bulkCreateMemberships($scope.project.id,invitations,invitation_extra_text),promise.then(onSuccess,onError)):void 0):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgLbCreateMembers",["$tgResources","$rootScope","$tgConfirm","$tgLoading","lightboxService","$compile",CreateMembersDirective])}.call(this),function(){var MembershipsController,MembershipsDirective,MembershipsRowActionsDirective,MembershipsRowAdminCheckboxDirective,MembershipsRowAvatarDirective,MembershipsRowRoleSelectorDirective,bindMethods,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindMethods=this.taiga.bindMethods,module=angular.module("taigaAdmin"),MembershipsController=function(superClass){function MembershipsController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,analytics,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.analytics=analytics,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.project={},this.scope.filters={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.MEMBERSHIPS.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("membersform:new:success",function(_this){return function(){return _this.loadMembers(),_this.analytics.trackEvent("membership","create","create memberships on admin",1)}}(this))}return extend(MembershipsController,superClass),MembershipsController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAnalytics","tgAppMetaService","$translate"],MembershipsController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},MembershipsController.prototype.loadMembers=function(){var httpFilters;return httpFilters=this.getUrlFilters(),this.rs.memberships.list(this.scope.projectId,httpFilters).then(function(_this){return function(data){return _this.scope.memberships=_.filter(data.models,function(membership){return null===membership.user||membership.is_user_active}),_this.scope.page=data.current,_this.scope.count=data.count,_this.scope.paginatedBy=data.paginatedBy,data}}(this))},MembershipsController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadMembers()}}(this)),promise},MembershipsController.prototype.getUrlFilters=function(){var filters;return filters=_.pick(this.location.search(),"page"),filters.page||(filters.page=1),filters},MembershipsController.prototype.addNewMembers=function(){return this.rootscope.$broadcast("membersform:new")},MembershipsController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("MembershipsController",MembershipsController),MembershipsDirective=function($template,$compile){var link,linkPagination,template;return template=$template.get("admin/admin-membership-paginator.html",!0),linkPagination=function($scope,$el,$attrs,$ctrl){var $pagEl,afterCurrent,atBegin,atEnd,beforeCurrent,getNumPages,renderPagination;return afterCurrent=2,beforeCurrent=4,atBegin=2,atEnd=2,$pagEl=$el.find(".memberships-paginator"),getNumPages=function(){var numPages;return numPages=$scope.count/$scope.paginatedBy,numPages=parseInt(numPages,10)=numPages)return void $pagEl.hide();for(pages=[],options={},options.pages=pages,options.showPrevious=$scope.page>1,options.showNext=!($scope.page===numPages),cpage=$scope.page,i=j=1,ref=numPages;ref>=1?ref>=j:j>=ref;i=ref>=1?++j:--j)i===cpage+afterCurrent&&numPages>cpage+afterCurrent+atEnd?pages.push({classes:"dots",type:"dots"}):i===cpage-beforeCurrent&&cpage>atBegin+beforeCurrent?pages.push({classes:"dots",type:"dots"}):i>cpage+afterCurrent&&numPages-atEnd>=i||cpage-beforeCurrent>i&&i>atBegin||(i===cpage?pages.push({classes:"active",num:i,type:"page-active"}):pages.push({classes:"page",num:i,type:"page"}));return html=template(options),html=$compile(html)($scope),$pagEl.html(html),$pagEl.show()},$scope.$watch("memberships",function(value){return value?renderPagination():void 0}),$el.on("click",".memberships-paginator a.next",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page+1),$ctrl.loadMembers()})}),$el.on("click",".memberships-paginator a.previous",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page-1),$ctrl.loadMembers()})}),$el.on("click",".memberships-paginator li.page > a",function(event){var pagenum,target;return event.preventDefault(),target=angular.element(event.currentTarget),pagenum=target.data("pagenum"),$scope.$apply(function(){return $ctrl.selectFilter("page",pagenum),$ctrl.loadMembers()})})},link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),linkPagination($scope,$el,$attrs,$ctrl),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgMemberships",["$tgTemplate","$compile",MembershipsDirective]),MembershipsRowAvatarDirective=function($log,$template,$translate){var link,template;return template=$template.get("admin/memberships-row-avatar.html",!0),link=function($scope,$el,$attrs){var member,pending,render;return pending=$translate.instant("ADMIN.MEMBERSHIP.STATUS_PENDING"),render=function(member){var ctx,html;return ctx={full_name:member.full_name?member.full_name:"",email:member.user_email?member.user_email:member.email,imgurl:member.photo?member.photo:"/"+window._version+"/images/unnamed.png",pending:member.is_user_active?"":pending},html=template(ctx),$el.html(html)},null==$attrs.tgMembershipsRowAvatar?$log.error("MembershipsRowAvatarDirective: the directive need a member"):(member=$scope.$eval($attrs.tgMembershipsRowAvatar),render(member),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowAvatar",["$log","$tgTemplate","$translate",MembershipsRowAvatarDirective]),MembershipsRowAdminCheckboxDirective=function($log,$repo,$confirm,$template,$compile){var link,template;return template=$template.get("admin/admin-memberships-row-checkbox.html",!0),link=function($scope,$el,$attrs){var html,member,render;return render=function(member){var ctx,html;return ctx={inputId:"is-admin-"+member.id},html=template(ctx),html=$compile(html)($scope),$el.html(html)},null==$attrs.tgMembershipsRowAdminCheckbox?$log.error("MembershipsRowAdminCheckboxDirective: the directive need a member"):(member=$scope.$eval($attrs.tgMembershipsRowAdminCheckbox),html=render(member),member.is_owner&&$el.find(":checkbox").prop("checked",!0),$el.on("click",":checkbox",function(_this){return function(event){var onError,onSuccess,target;return onSuccess=function(){return $confirm.notify("success")},onError=function(data){return member.revert(),$el.find(":checkbox").prop("checked",member.is_owner),$confirm.notify("error",data.is_owner[0])},target=angular.element(event.currentTarget),member.is_owner=target.prop("checked"),$repo.save(member).then(onSuccess,onError)}}(this)),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowAdminCheckbox",["$log","$tgRepo","$tgConfirm","$tgTemplate","$compile",MembershipsRowAdminCheckboxDirective]),MembershipsRowRoleSelectorDirective=function($log,$repo,$confirm){var link,template;return template=_.template(''),link=function($scope,$el,$attrs){var $ctrl,html,member,render;return render=function(member){var ctx,html;return ctx={roleList:$scope.project.roles,selectedRole:member.role},html=template(ctx),$el.html(html)},null==$attrs.tgMembershipsRowRoleSelector?$log.error("MembershipsRowRoleSelectorDirective: the directive need a member"):($ctrl=$el.controller(),member=$scope.$eval($attrs.tgMembershipsRowRoleSelector),html=render(member),$el.on("change","select",function(_this){return function(event){var newRole,onError,onSuccess,target;return onSuccess=function(){return $confirm.notify("success")},onError=function(){return $confirm.notify("error")},target=angular.element(event.currentTarget),newRole=parseInt(target.val(),10),member.role!==newRole?(member.role=newRole,$repo.save(member).then(onSuccess,onError)):void 0}}(this)),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowRoleSelector",["$log","$tgRepo","$tgConfirm",MembershipsRowRoleSelectorDirective]),MembershipsRowActionsDirective=function($log,$repo,$rs,$confirm,$compile,$translate){var activedTemplate,link,pendingTemplate;return activedTemplate='
\n
\n\n \n',pendingTemplate='\n\n\n \n',link=function($scope,$el,$attrs){var $ctrl,member,render;return render=function(member){var html;return html=member.user?$compile(activedTemplate)($scope):$compile(pendingTemplate)($scope),$el.html(html)},null==$attrs.tgMembershipsRowActions?$log.error("MembershipsRowActionsDirective: the directive need a member"):($ctrl=$el.controller(),member=$scope.$eval($attrs.tgMembershipsRowActions),render(member),$el.on("click",".js-resend",function(event){var onError,onSuccess;return event.preventDefault(),onSuccess=function(){var text;return text=$translate.instant("ADMIN.MEMBERSHIP.SUCCESS_SEND_INVITATION",{email:$scope.member.email}),$confirm.notify("success",text)},onError=function(){var text;return text=$translate.instant("ADMIM.MEMBERSHIP.ERROR_SEND_INVITATION"),$confirm.notify("error",text)},$rs.memberships.resendInvitation($scope.member.id).then(onSuccess,onError)}),$el.on("click",".delete",function(event){var defaultMsg,message,title;return event.preventDefault(),title=$translate.instant("ADMIN.MEMBERSHIP.DELETE_MEMBER"),defaultMsg=$translate.instant("ADMIN.MEMBERSHIP.DEFAULT_DELETE_MESSAGE",{email:member.email}),message=member.user?member.full_name:defaultMsg,$confirm.askOnDelete(title,message).then(function(askResponse){var onError,onSuccess;return onSuccess=function(_this){return function(){var text;return askResponse.finish(),$scope.page>1&&$scope.count-1<=$scope.paginatedBy&&$ctrl.selectFilter("page",$scope.page-1),$ctrl.loadMembers(),text=$translate.instant("ADMIN.MEMBERSHIP.SUCCESS_DELETE"),$confirm.notify("success",null,text)}}(this),onError=function(_this){return function(){var text;return askResponse.finish(!1),text=$translate.instant("ADMIN.MEMBERSHIP.ERROR_DELETE",{message:message}),$confirm.notify("error",null,text)}}(this),$repo.remove(member).then(onSuccess,onError)})}),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowActions",["$log","$tgRepo","$tgResources","$tgConfirm","$compile","$translate",MembershipsRowActionsDirective])}.call(this),function(){var AdminNavigationDirective,module;AdminNavigationDirective=function(){var link;return link=function($scope,$el,$attrs){var section;return section=$attrs.tgAdminNavigation,$el.find(".active").removeClass("active"),$el.find("#adminmenu-"+section+" a").addClass("active"),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaAdmin"),module.directive("tgAdminNavigation",AdminNavigationDirective)}.call(this),function(){var CsvExporterController,CsvExporterIssuesController,CsvExporterTasksController,CsvExporterUserstoriesController,CsvIssueDirective,CsvTaskDirective,CsvUsDirective,ProjectDefaultValuesDirective,ProjectExportDirective,ProjectLogoDirective,ProjectLogoModelDirective,ProjectModulesDirective,ProjectProfileController,ProjectProfileDirective,bindOnce,debounce,groupBy,joinStr,mixOf,module,taiga,toString,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaAdmin"),ProjectProfileController=function(superClass){function ProjectProfileController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_PROFILE.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:loaded",function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_PROFILE.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this))}return extend(ProjectProfileController,superClass),ProjectProfileController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectProfileController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.scope.taskStatusList=_.sortBy(project.task_statuses,"order"),_this.scope.prioritiesList=_.sortBy(project.priorities,"order"),_this.scope.severitiesList=_.sortBy(project.severities,"order"),_this.scope.issueTypesList=_.sortBy(project.issue_types,"order"),_this.scope.issueStatusList=_.sortBy(project.issue_statuses,"order"),_this.scope.$emit("project:loaded",project),project}}(this))},ProjectProfileController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject()},ProjectProfileController.prototype.openDeleteLightbox=function(){return this.rootscope.$broadcast("deletelightbox:new",this.scope.project)},ProjectProfileController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectProfileController",ProjectProfileController),ProjectProfileDirective=function($repo,$confirm,$loading,$navurls,$location,projectService,currentUserService){var link;return link=function($scope,$el,$attrs){var $ctrl,form,submit,submitButton;return $ctrl=$el.controller(),form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.save($scope.project),promise.then(function(){var newUrl;return currentLoading.finish(),$confirm.notify("success"),newUrl=$navurls.resolve("project-admin-project-profile-details",{project:$scope.project.slug}),$location.path(newUrl),$ctrl.loadInitialData(),projectService.fetchProject(),currentUserService.loadProjects()}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgProjectProfile",["$tgRepo","$tgConfirm","$tgLoading","$tgNavUrls","$tgLocation","tgProjectService","tgCurrentUserService",ProjectProfileDirective]),ProjectDefaultValuesDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.save($scope.project),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectDefaultValues",["$tgRepo","$tgConfirm","$tgLoading",ProjectDefaultValuesDirective]),ProjectModulesDirective=function($repo,$confirm,$loading,projectService){var link;return link=function($scope,$el,$attrs){var submit;return submit=function(_this){return function(){var currentLoading,form,promise,target;return form=$el.find("form").checksley(),form.validate()?(target=angular.element(".admin-functionalities .submit-button"),currentLoading=$loading().target(target).start(),promise=$repo.save($scope.project),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:loaded",$scope.project),projectService.fetchProject()}),promise.then(null,function(data){return currentLoading.finish(),$confirm.notify("error",data._error_message)})):void 0}}(this),$el.on("submit","form",function(event){return event.preventDefault(),submit()}),$el.on("click",".admin-functionalities a.button-green",function(event){return event.preventDefault(),submit()}),$scope.$watch("isVideoconferenceActivated",function(isVideoconferenceActivated){return isVideoconferenceActivated?$el.find(".videoconference-attributes").removeClass("hidden"):($el.find(".videoconference-attributes").addClass("hidden"),$scope.project.videoconferences=null,$scope.project.videoconferences_extra_data="")}),$scope.$watch("project",function(project){return null!=project.videoconferences?$scope.isVideoconferenceActivated=!0:$scope.isVideoconferenceActivated=!1})},{link:link}},module.directive("tgProjectModules",["$tgRepo","$tgConfirm","$tgLoading","tgProjectService",ProjectModulesDirective]),ProjectExportDirective=function($window,$rs,$confirm,$translate){var link;return link=function($scope,$el,$attrs){var asyn_message,buttonsEl,dump_ready_text,hideButtons,hideResult,hideSpinner,loading_msg,loading_title,resultEl,resultMessageEl,resultTitleEl,setAsyncMessage,setAsyncTitle,setLoadingMessage,setLoadingTitle,setSyncMessage,setSyncTitle,showButtons,showErrorMode,showExportResultAsyncMode,showExportResultSyncMode,showLoadingMode,showResult,showSpinner,spinnerEl,syn_message;return buttonsEl=$el.find(".admin-project-export-buttons"),showButtons=function(){return buttonsEl.removeClass("hidden")},hideButtons=function(){return buttonsEl.addClass("hidden")},resultEl=$el.find(".admin-project-export-result"),showResult=function(){return resultEl.removeClass("hidden")},hideResult=function(){return resultEl.addClass("hidden")},spinnerEl=$el.find(".spin"),showSpinner=function(){return spinnerEl.removeClass("hidden")},hideSpinner=function(){return spinnerEl.addClass("hidden")},resultTitleEl=$el.find(".result-title"),loading_title=$translate.instant("ADMIN.PROJECT_EXPORT.LOADING_TITLE"),loading_msg=$translate.instant("ADMIN.PROJECT_EXPORT.LOADING_MESSAGE"),dump_ready_text=function(){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.DUMP_READY"))},asyn_message=function(){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.ASYNC_MESSAGE"))},syn_message=function(url){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.SYNC_MESSAGE",{url:url}))},setLoadingTitle=function(){return resultTitleEl.html(loading_title)},setAsyncTitle=function(){return resultTitleEl.html(loading_msg)},setSyncTitle=function(){return resultTitleEl.html(dump_ready_text)},resultMessageEl=$el.find(".result-message "),setLoadingMessage=function(){return resultMessageEl.html(loading_msg)},setAsyncMessage=function(){return resultMessageEl.html(asyn_message)},setSyncMessage=function(url){return resultMessageEl.html(syn_message(url))},showLoadingMode=function(){return showSpinner(),setLoadingTitle(),setLoadingMessage(),hideButtons(),showResult()},showExportResultAsyncMode=function(){return hideSpinner(),setAsyncTitle(),setAsyncMessage()},showExportResultSyncMode=function(url){return hideSpinner(),setSyncTitle(),setSyncMessage(url)},showErrorMode=function(){return hideSpinner(),hideResult(),showButtons()},$el.on("click","a.button-export",debounce(2e3,function(_this){return function(event){var onError,onSuccess;return event.preventDefault(),onSuccess=function(result){var dumpUrl;return 202===result.status?showExportResultAsyncMode():(dumpUrl=result.data.url,showExportResultSyncMode(dumpUrl),$window.open(dumpUrl,"_blank"))},onError=function(result){var errorMsg,ref;return showErrorMode(),errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR"),429===result.status?errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR_BUSY"):(null!=(ref=result.data)?ref._error_message:void 0)&&(errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR_BUSY",{message:result.data._error_message})),$confirm.notify("error",errorMsg)},showLoadingMode(),$rs.projects["export"]($scope.projectId).then(onSuccess,onError)}}(this)))},{link:link}},module.directive("tgProjectExport",["$window","$tgResources","$tgConfirm","$translate",ProjectExportDirective]),CsvExporterController=function(superClass){function CsvExporterController(scope,rootscope,urls,confirm,rs,translate){this.scope=scope,this.rootscope=rootscope,this.urls=urls,this.confirm=confirm,this.rs=rs,this.translate=translate,this._generateUuid=bind(this._generateUuid,this),this.setCsvUuid=bind(this.setCsvUuid,this),this.rootscope.$on("project:loaded",this.setCsvUuid),this.scope.$watch("csvUuid",function(_this){return function(value){return value?_this.scope.csvUrl=_this.urls.resolveAbsolute(_this.type+"-csv",value):_this.scope.csvUrl=""; -}}(this))}return extend(CsvExporterController,superClass),CsvExporterController.$inject=["$scope","$rootScope","$tgUrls","$tgConfirm","$tgResources","$translate"],CsvExporterController.prototype.setCsvUuid=function(){return this.scope.csvUuid=this.scope.project[this.type+"_csv_uuid"]},CsvExporterController.prototype._generateUuid=function(response){var promise;return null==response&&(response=null),promise=this.rs.projects["regenerate_"+this.type+"_csv_uuid"](this.scope.projectId),promise.then(function(_this){return function(data){var ref;return _this.scope.csvUuid=null!=(ref=data.data)?ref.uuid:void 0}}(this)),promise.then(null,function(_this){return function(){return _this.confirm.notify("error")}}(this)),promise["finally"](function(){return response?response.finish():void 0}),promise},CsvExporterController.prototype.regenerateUuid=function(){var subtitle,title;return this.scope.csvUuid?(title=this.translate.instant("ADMIN.REPORTS.REGENERATE_TITLE"),subtitle=this.translate.instant("ADMIN.REPORTS.REGENERATE_SUBTITLE"),this.confirm.ask(title,subtitle).then(this._generateUuid)):this._generateUuid()},CsvExporterController}(taiga.Controller),CsvExporterUserstoriesController=function(superClass){function CsvExporterUserstoriesController(){return CsvExporterUserstoriesController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterUserstoriesController,superClass),CsvExporterUserstoriesController.prototype.type="userstories",CsvExporterUserstoriesController}(CsvExporterController),CsvExporterTasksController=function(superClass){function CsvExporterTasksController(){return CsvExporterTasksController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterTasksController,superClass),CsvExporterTasksController.prototype.type="tasks",CsvExporterTasksController}(CsvExporterController),CsvExporterIssuesController=function(superClass){function CsvExporterIssuesController(){return CsvExporterIssuesController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterIssuesController,superClass),CsvExporterIssuesController.prototype.type="issues",CsvExporterIssuesController}(CsvExporterController),module.controller("CsvExporterUserstoriesController",CsvExporterUserstoriesController),module.controller("CsvExporterTasksController",CsvExporterTasksController),module.controller("CsvExporterIssuesController",CsvExporterIssuesController),CsvUsDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_US"},{controller:"CsvExporterUserstoriesController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvUs",["$translate",CsvUsDirective]),CsvTaskDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_TASK"},{controller:"CsvExporterTasksController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvTask",["$translate",CsvTaskDirective]),CsvIssueDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_ISSUE"},{controller:"CsvExporterIssuesController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvIssue",["$translate",CsvIssueDirective]),ProjectLogoDirective=function($auth,$model,$rs,$confirm){var link;return link=function($scope,$el,$attrs){var onError,onSuccess,showSizeInfo;return showSizeInfo=function(){return $el.find(".size-info").addClass("active")},onSuccess=function(response){var project;return project=$model.make_model("projects",response.data),$scope.project=project,$el.find(".loading-overlay").removeClass("active"),$confirm.notify("success")},onError=function(response){return 413===response.status&&showSizeInfo(),$el.find(".loading-overlay").removeClass("active"),$confirm.notify("error",response.data._error_message)},$el.on("click",".js-change-logo",function(){return $el.find("#logo-field").click()}),$el.on("change","#logo-field",function(event){return $scope.logoAttachment?($el.find(".loading-overlay").addClass("active"),$rs.projects.changeLogo($scope.project.id,$scope.logoAttachment).then(onSuccess,onError)):void 0}),$el.on("click","a.js-use-default-logo",function(event){return $el.find(".loading-overlay").addClass("active"),$rs.projects.removeLogo($scope.project.id).then(onSuccess,onError)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectLogo",["$tgAuth","$tgModel","$tgResources","$tgConfirm",ProjectLogoDirective]),ProjectLogoModelDirective=function($parse){var link;return link=function($scope,$el,$attrs){var model,modelSetter;return model=$parse($attrs.tgProjectLogoModel),modelSetter=model.assign,$el.bind("change",function(){return $scope.$apply(function(){return modelSetter($scope,$el[0].files[0])})})},{link:link}},module.directive("tgProjectLogoModel",["$parse",ProjectLogoModelDirective])}.call(this),function(){var ColorSelectionDirective,DATE_TYPE,MULTILINE_TYPE,ProjectCustomAttributesController,ProjectCustomAttributesDirective,ProjectValuesController,ProjectValuesDirective,ProjectValuesSectionController,TEXT_TYPE,TYPE_CHOICES,bindOnce,debounce,groupBy,joinStr,mixOf,module,taiga,toString,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaAdmin"),ProjectValuesSectionController=function(superClass){function ProjectValuesSectionController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_VALUES.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(ProjectValuesSectionController,superClass),ProjectValuesSectionController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectValuesSectionController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},ProjectValuesSectionController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject()},ProjectValuesSectionController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectValuesSectionController",ProjectValuesSectionController),ProjectValuesController=function(superClass){function ProjectValuesController(scope,rootscope,repo,confirm,rs){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.moveValue=bind(this.moveValue,this),this.loadValues=bind(this.loadValues,this),this.scope.$on("admin:project-values:move",this.moveValue),this.rootscope.$on("project:loaded",this.loadValues)}return extend(ProjectValuesController,superClass),ProjectValuesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources"],ProjectValuesController.prototype.loadValues=function(){return this.rs[this.scope.resource].listValues(this.scope.projectId,this.scope.type).then(function(_this){return function(values){return _this.scope.values=values,_this.scope.maxValueOrder=_.max(values,"order").order,values}}(this))},ProjectValuesController.prototype.moveValue=function(ctx,itemValue,itemIndex){var r,values;return values=this.scope.values,r=values.indexOf(itemValue),values.splice(r,1),values.splice(itemIndex,0,itemValue),_.each(values,function(value,index){return value.order=index}),this.repo.saveAll(values)},ProjectValuesController}(taiga.Controller),module.controller("ProjectValuesController",ProjectValuesController),ProjectValuesDirective=function($log,$repo,$confirm,$location,animationFrame,$translate,$rootscope){var link,linkDragAndDrop,linkValue;return linkDragAndDrop=function($scope,$el,$attrs){var itemEl,newParentScope,oldParentScope,tdom;return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el.find(".sortable"),tdom.sortable({handle:".row.table-main.visualization",dropOnEmpty:!0,connectWith:".project-values-body",revert:400,axis:"y"}),tdom.on("sortstop",function(event,ui){var itemIndex,itemValue;return itemEl=ui.item,itemValue=itemEl.scope().value,itemIndex=itemEl.index(),$scope.$broadcast("admin:project-values:move",itemValue,itemIndex)}),$scope.$on("$destroy",function(){return $el.off()})},linkValue=function($scope,$el,$attrs){var $ctrl,cancel,goToBottomList,initializeNewValue,initializeTextTranslations,objName,saveNewValue,saveValue,valueType;return $ctrl=$el.controller(),valueType=$attrs.type,objName=$attrs.objname,initializeNewValue=function(){return $scope.newValue={name:"",is_closed:!1,is_archived:!1}},initializeTextTranslations=function(){return $scope.addNewElementText=$translate.instant("ADMIN.PROJECT_VALUES_"+objName.toUpperCase()+".ACTION_ADD")},initializeNewValue(),initializeTextTranslations(),$rootscope.$on("$translateChangeEnd",function(){return $scope.$evalAsync(initializeTextTranslations)}),goToBottomList=function(_this){return function(focus){var table;return null==focus&&(focus=!1),table=$el.find(".table-main"),$(document.body).scrollTop(table.offset().top+table.height()),focus?$el.find(".new-value input:visible").first().focus():void 0}}(this),saveValue=function(target){var form,formEl,promise,value;return formEl=target.parents("form"),form=formEl.checksley(),form.validate()?(value=formEl.scope().value,promise=$repo.save(value),promise.then(function(_this){return function(){var row;return row=target.parents(".row.table-main"),row.addClass("hidden"),row.siblings(".visualization").removeClass("hidden")}}(this)),promise.then(null,function(data){return form.setErrors(data)})):void 0},saveNewValue=function(target){var form,formEl,promise;return formEl=target.parents("form"),form=formEl.checksley(),form.validate()?($scope.newValue.project=$scope.project.id,$scope.newValue.order=$scope.maxValueOrder?$scope.maxValueOrder+1:1,promise=$repo.create(valueType,$scope.newValue),promise.then(function(_this){return function(data){return target.addClass("hidden"),$scope.values.push(data),$scope.maxValueOrder=data.order,initializeNewValue()}}(this)),promise.then(null,function(data){return form.setErrors(data)})):void 0},cancel=function(target){var formEl,row,value;return row=target.parents(".row.table-main"),formEl=target.parents("form"),value=formEl.scope().value,$scope.$apply(function(){return row.addClass("hidden"),value.revert(),row.siblings(".visualization").removeClass("hidden")})},$el.on("click",".show-add-new",function(event){return event.preventDefault(),$el.find(".new-value").removeClass("hidden"),goToBottomList(!0)}),$el.on("click",".add-new",debounce(2e3,function(event){var target;return event.preventDefault(),target=$el.find(".new-value"),saveNewValue(target)})),$el.on("click",".delete-new",function(event){return event.preventDefault(),$el.find(".new-value").addClass("hidden"),initializeNewValue()}),$el.on("click",".edit-value",function(event){var editionRow,row,target;return event.preventDefault(),target=angular.element(event.currentTarget),row=target.parents(".row.table-main"),row.addClass("hidden"),editionRow=row.siblings(".edition"),editionRow.removeClass("hidden"),editionRow.find("input:visible").first().focus().select()}),$el.on("keyup",".edition input",function(event){var target;return 13===event.keyCode?(target=angular.element(event.currentTarget),saveValue(target)):27===event.keyCode?(target=angular.element(event.currentTarget),cancel(target)):void 0}),$el.on("keyup",".new-value input",function(event){var target;return 13===event.keyCode?(target=$el.find(".new-value"),saveNewValue(target)):27===event.keyCode?($el.find(".new-value").addClass("hidden"),initializeNewValue()):void 0}),$el.on("click",".save",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),saveValue(target)}),$el.on("click",".cancel",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),cancel(target)}),$el.on("click",".delete-value",function(event){var choices,formEl,subtitle,target,text,title,value;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.parents("form"),value=formEl.scope().value,choices={},_.each($scope.values,function(option){return value.id!==option.id?choices[option.id]=option.name:void 0}),subtitle=value.name,0===_.keys(choices).length?$confirm.error($translate.instant("ADMIN.PROJECT_VALUES.ERROR_DELETE_ALL")):(title=$translate.instant("ADMIN.COMMON.TITLE_ACTION_DELETE_VALUE"),text=$translate.instant("ADMIN.PROJECT_VALUES.REPLACEMENT"),$confirm.askChoice(title,subtitle,choices,text).then(function(response){var onError,onSucces;return onSucces=function(){return $ctrl.loadValues()["finally"](function(){return response.finish()})},onError=function(){return $confirm.notify("error")},$repo.remove(value,{moveTo:response.selected}).then(onSucces,onError)}))})},link=function($scope,$el,$attrs){return linkDragAndDrop($scope,$el,$attrs),linkValue($scope,$el,$attrs),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectValues",["$log","$tgRepo","$tgConfirm","$tgLocation","animationFrame","$translate","$rootScope",ProjectValuesDirective]),ColorSelectionDirective=function(){var link;return link=function($scope,$el,$attrs,$model){var $ctrl;return $ctrl=$el.controller(),$scope.$watch($attrs.ngModel,function(element){return $scope.color=element.color}),$el.on("click",".current-color",function(event){var body,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),$el.find(".select-color").hide(),target.siblings(".select-color").show(),body=angular.element("body"),body.on("click",function(_this){return function(event){return 0===angular.element(event.target).parent(".select-color").length?($el.find(".select-color").hide(),body.unbind("click")):void 0}}(this))}),$el.on("click",".select-color .color",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),$scope.$apply(function(){return $model.$modelValue.color=target.data("color")}),$el.find(".select-color").hide()}),$el.on("click",".select-color .selected-color",function(event){return event.preventDefault(),$scope.$apply(function(){return $model.$modelValue.color=$scope.color}),$el.find(".select-color").hide()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgColorSelection",ColorSelectionDirective),TEXT_TYPE="text",MULTILINE_TYPE="multiline",DATE_TYPE="date",TYPE_CHOICES=[{key:TEXT_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT"},{key:MULTILINE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI"},{key:DATE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE"}],ProjectCustomAttributesController=function(superClass){function ProjectCustomAttributesController(scope,rootscope,repo,rs,params,q,location,navUrls,appMetaService,translate){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.moveCustomAttributes=bind(this.moveCustomAttributes,this),this.deleteCustomAttribute=bind(this.deleteCustomAttribute,this),this.saveCustomAttribute=bind(this.saveCustomAttribute,this),this.createCustomAttribute=bind(this.createCustomAttribute,this),this.loadCustomAttributes=bind(this.loadCustomAttributes,this),this.scope.TYPE_CHOICES=TYPE_CHOICES,this.scope.project={},this.rootscope.$on("project:loaded",function(_this){return function(){var description,sectionName,title;return _this.loadCustomAttributes(),sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.CUSTOM_ATTRIBUTES.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this))}return extend(ProjectCustomAttributesController,superClass),ProjectCustomAttributesController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectCustomAttributesController.prototype.loadCustomAttributes=function(){return this.rs.customAttributes[this.scope.type].list(this.scope.projectId).then(function(_this){return function(customAttributes){return _this.scope.customAttributes=customAttributes,_this.scope.maxOrder=_.max(customAttributes,"order").order,customAttributes}}(this))},ProjectCustomAttributesController.prototype.createCustomAttribute=function(attrValues){return this.repo.create("custom-attributes/"+this.scope.type,attrValues)},ProjectCustomAttributesController.prototype.saveCustomAttribute=function(attrModel){return this.repo.save(attrModel)},ProjectCustomAttributesController.prototype.deleteCustomAttribute=function(attrModel){return this.repo.remove(attrModel)},ProjectCustomAttributesController.prototype.moveCustomAttributes=function(attrModel,newIndex){var customAttributes,r;return customAttributes=this.scope.customAttributes,r=customAttributes.indexOf(attrModel),customAttributes.splice(r,1),customAttributes.splice(newIndex,0,attrModel),_.each(customAttributes,function(val,idx){return val.order=idx}),this.repo.saveAll(customAttributes)},ProjectCustomAttributesController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectCustomAttributesController",ProjectCustomAttributesController),ProjectCustomAttributesDirective=function($log,$confirm,animationFrame,$translate){var link;return link=function($scope,$el,$attrs){var $ctrl,cancelCreate,cancelUpdate,create,deleteCustomAttribute,hideAddButton,hideCancelButton,hideCreateForm,hideEditForm,resetNewAttr,revertChangesInCustomAttribute,showAddButton,showCancelButton,showCreateForm,showEditForm,sortableEl,update;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()}),sortableEl=$el.find(".js-sortable"),sortableEl.sortable({handle:".js-view-custom-field",dropOnEmpty:!0,revert:400,axis:"y"}),sortableEl.on("sortstop",function(event,ui){var itemAttr,itemEl,itemIndex;return itemEl=ui.item,itemAttr=itemEl.scope().attr,itemIndex=itemEl.index(),$ctrl.moveCustomAttributes(itemAttr,itemIndex)}),showCreateForm=function(){return $el.find(".js-new-custom-field").removeClass("hidden"),$el.find(".js-new-custom-field input:visible").first().focus()},hideCreateForm=function(){return $el.find(".js-new-custom-field").addClass("hidden")},showAddButton=function(){return $el.find(".js-add-custom-field-button").removeClass("hidden")},hideAddButton=function(){return $el.find(".js-add-custom-field-button").addClass("hidden")},showCancelButton=function(){return $el.find(".js-cancel-new-custom-field-button").removeClass("hidden")},hideCancelButton=function(){return $el.find(".js-cancel-new-custom-field-button").addClass("hidden")},resetNewAttr=function(){return $scope.newAttr={}},create=function(formEl){var attr,form,onError,onSucces;return form=formEl.checksley(),form.validate()?(onSucces=function(_this){return function(){return $ctrl.loadCustomAttributes(),hideCreateForm(),resetNewAttr(),$confirm.notify("success")}}(this),onError=function(_this){return function(data){return form.setErrors(data)}}(this),attr=$scope.newAttr,attr.project=$scope.projectId,attr.order=$scope.maxOrder?$scope.maxOrder+1:1,$ctrl.createCustomAttribute(attr).then(onSucces,onError)):void 0},cancelCreate=function(){return hideCreateForm(),resetNewAttr()},$scope.$watch("customAttributes",function(customAttributes){return customAttributes?0===customAttributes.length?(hideCancelButton(),hideAddButton(),showCreateForm()):(hideCreateForm(),showAddButton(),showCancelButton()):void 0}),$el.on("click",".js-add-custom-field-button",function(event){return event.preventDefault(),showCreateForm()}),$el.on("click",".js-create-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),create(formEl)})),$el.on("click",".js-cancel-new-custom-field-button",function(event){return event.preventDefault(),cancelCreate()}),$el.on("keyup",".js-new-custom-field input",function(event){var formEl,target;return 13===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),create(formEl)):27===event.keyCode?cancelCreate():void 0}),showEditForm=function(formEl){return formEl.find(".js-view-custom-field").addClass("hidden"),formEl.find(".js-edit-custom-field").removeClass("hidden"),formEl.find(".js-edit-custom-field input:visible").first().focus().select()},hideEditForm=function(formEl){return formEl.find(".js-edit-custom-field").addClass("hidden"),formEl.find(".js-view-custom-field").removeClass("hidden")},revertChangesInCustomAttribute=function(formEl){return $scope.$apply(function(){return formEl.scope().attr.revert()})},update=function(formEl){var attr,form,onError,onSucces;return form=formEl.checksley(),form.validate()?(onSucces=function(_this){return function(){return $ctrl.loadCustomAttributes(),hideEditForm(formEl),$confirm.notify("success")}}(this),onError=function(_this){return function(data){return form.setErrors(data)}}(this),attr=formEl.scope().attr,$ctrl.saveCustomAttribute(attr).then(onSucces,onError)):void 0},cancelUpdate=function(formEl){return hideEditForm(formEl),revertChangesInCustomAttribute(formEl)},$el.on("click",".js-edit-custom-field-button",function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),showEditForm(formEl)}),$el.on("click",".js-update-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),update(formEl)})),$el.on("click",".js-cancel-edit-custom-field-button",function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),cancelUpdate(formEl)}),$el.on("keyup",".js-edit-custom-field input",function(event){var formEl,target;return 13===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),update(formEl)):27===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),cancelUpdate(formEl)):void 0}),deleteCustomAttribute=function(formEl){var attr,message,text,title;return attr=formEl.scope().attr,message=attr.name,title=$translate.instant("COMMON.CUSTOM_ATTRIBUTES.DELETE"),text=$translate.instant("COMMON.CUSTOM_ATTRIBUTES.CONFIRM_DELETE"),$confirm.ask(title,text,message).then(function(response){var onError,onSucces;return onSucces=function(){return $ctrl.loadCustomAttributes()["finally"](function(){return response.finish()})},onError=function(){return $confirm.notify("error",null,"We have not been able to delete '"+message+"'.")},$ctrl.deleteCustomAttribute(attr).then(onSucces,onError)})},$el.on("click",".js-delete-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),deleteCustomAttribute(formEl)}))},{link:link}},module.directive("tgProjectCustomAttributes",["$log","$tgConfirm","animationFrame","$translate",ProjectCustomAttributesDirective])}.call(this),function(){var EditRoleDirective,NewRoleDirective,RolePermissionsDirective,RolesController,RolesDirective,bindMethods,bindOnce,debounce,mixOf,module,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,mixOf=this.taiga.mixOf,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaAdmin"),RolesController=function(superClass){function RolesController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this._disableComputable=bind(this._disableComputable,this),this._enableComputable=bind(this._enableComputable,this),bindMethods(this),this.scope.sectionName="ADMIN.MENU.PERMISSIONS",this.scope.project={},this.scope.anyComputableRole=!0,promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.ROLES.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(RolesController,superClass),RolesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],RolesController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.anyComputableRole=_.some(_.map(project.roles,function(point){return point.computable})),project}}(this))},RolesController.prototype.loadRoles=function(){return this.rs.roles.list(this.scope.projectId).then(function(_this){return function(roles){var public_permission;return roles=roles.map(function(role){return role.external_user=!1,role}),public_permission={name:_this.translate.instant("ADMIN.ROLES.EXTERNAL_USER"),permissions:_this.scope.project.public_permissions,external_user:!0},roles.push(public_permission),_this.scope.roles=roles,_this.scope.role=_this.scope.roles[0],roles}}(this))},RolesController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadRoles()}}(this)),promise},RolesController.prototype.setRole=function(role){return this.scope.role=role,this.scope.$broadcast("role:changed",this.scope.role)},RolesController.prototype["delete"]=function(){var choices,i,len,ref,replacement,role,subtitle,title,warning;for(choices={},ref=this.scope.roles,i=0,len=ref.length;len>i;i++)role=ref[i],role.id!==this.scope.role.id&&(choices[role.id]=role.name);return 0===_.keys(choices).length?this.confirm.error(this.translate.instant("ADMIN.ROLES.ERROR_DELETE_ALL")):(title=this.translate.instant("ADMIN.ROLES.TITLE_DELETE_ROLE"),subtitle=this.scope.role.name,replacement=this.translate.instant("ADMIN.ROLES.REPLACEMENT_ROLE"),warning=this.translate.instant("ADMIN.ROLES.WARNING_DELETE_ROLE"),this.confirm.askChoice(title,subtitle,choices,replacement,warning).then(function(_this){return function(response){var onError,onSuccess;return onSuccess=function(){return _this.loadProject(),_this.loadRoles()["finally"](function(){return response.finish()})},onError=function(){return _this.confirm.notify("error")},_this.repo.remove(_this.scope.role,{moveTo:response.selected}).then(onSuccess,onError)}}(this)))},RolesController.prototype._enableComputable=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.confirm.notify("success"),_this.loadProject()}}(this),onError=function(_this){return function(){return _this.confirm.notify("error"),_this.scope.role.revert()}}(this),this.repo.save(this.scope.role).then(onSuccess,onError)},RolesController.prototype._disableComputable=function(){var askOnError,askOnSuccess,message,subtitle,title;return askOnSuccess=function(_this){return function(response){var onError,onSuccess;return onSuccess=function(){return response.finish(),_this.confirm.notify("success"),_this.loadProject()},onError=function(){return response.finish(),_this.confirm.notify("error"),_this.scope.role.revert()},_this.repo.save(_this.scope.role).then(onSuccess,onError)}}(this),askOnError=function(_this){return function(response){return _this.scope.role.revert()}}(this),title=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_TITLE"),subtitle=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_SUBTITLE",{roleName:this.scope.role.name}),message=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_MESSAGE"),this.confirm.ask(title,subtitle,message).then(askOnSuccess,askOnError)},RolesController.prototype.toggleComputable=debounce(2e3,function(){return this.scope.role.computable?this._enableComputable():this._disableComputable()}),RolesController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("RolesController",RolesController),EditRoleDirective=function($repo,$confirm){var link;return link=function($scope,$el,$attrs){var submit,toggleView;return toggleView=function(){return $el.find(".total").toggle(),$el.find(".edit-role").toggle()},submit=function(){var promise;return $scope.role.name=$el.find("input").val(),promise=$repo.save($scope.role),promise.then(function(){return $confirm.notify("success")}),promise.then(null,function(data){return $confirm.notify("error")}),toggleView()},$el.on("click","a.icon-edit",function(){return toggleView(),$el.find("input").focus(),$el.find("input").val($scope.role.name)}),$el.on("click","a.save",submit),$el.on("keyup","input",function(event){return 13===event.keyCode?submit():27===event.keyCode?toggleView():void 0}),$scope.$on("role:changed",function(){return $el.find(".edit-role").is(":visible")?toggleView():void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgEditRole",["$tgRepo","$tgConfirm",EditRoleDirective]),RolesDirective=function(){var link;return link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRoles",RolesDirective),NewRoleDirective=function($tgrepo,$confirm){var DEFAULT_PERMISSIONS,link;return DEFAULT_PERMISSIONS=["view_project","view_milestones","view_us","view_tasks","view_issues"],link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click","a.add-button",function(event){return event.preventDefault(), -$el.find(".new").removeClass("hidden"),$el.find(".new").focus(),$el.find(".add-button").hide()}),$el.on("keyup",".new",function(event){var newRole,onError,onSuccess,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newRole={project:$scope.projectId,name:target.val(),permissions:DEFAULT_PERMISSIONS,order:_.max($scope.roles,function(r){return r.order}).order+1,computable:!1},$el.find(".new").addClass("hidden"),$el.find(".new").val(""),onSuccess=function(role){var insertPosition;return insertPosition=$scope.roles.length-1,$scope.roles.splice(insertPosition,0,role),$ctrl.setRole(role),$el.find(".add-button").show(),$ctrl.loadProject()},onError=function(){return $confirm.notify("error")},$tgrepo.create("roles",newRole).then(onSuccess,onError)):27===event.keyCode?(target=angular.element(event.currentTarget),$el.find(".new").addClass("hidden"),$el.find(".new").val(""),$el.find(".add-button").show()):void 0})},{link:link}},module.directive("tgNewRole",["$tgRepo","$tgConfirm",NewRoleDirective]),RolePermissionsDirective=function($rootscope,$repo,$confirm,$compile){var baseTemplate,categoryTemplate,link,resumeTemplate;return resumeTemplate=_.template('
\n
\n
<%- category.activePermissions %>/<%- category.permissions.length %>
\n <% _.each(category.permissions, function(permission) { %>\n
\n <% }) %>\n
\n
'),categoryTemplate=_.template('
\n
\n
\n
\n
\n <% _.each(category.permissions, function(permission) { %>\n
\n \n
\n disabled="disabled" <% } %>\n <% if(permission.active) { %> checked="checked" <% } %>/>\n
\n \n \n
\n
\n <% }) %>\n
\n
\n
'),baseTemplate=_.template('
'),link=function($scope,$el,$attrs){var $ctrl,generateCategoriesFromRole,renderCategory,renderPermissions,renderResume;return $ctrl=$el.controller(),generateCategoriesFromRole=function(role){var categories,isPermissionEditable,issuePermissions,milestonePermissions,setActivePermissions,setActivePermissionsPerCategory,taskPermissions,userStoryPermissions,wikiPermissions;return setActivePermissions=function(permissions){return _.map(permissions,function(x){var ref;return _.extend({},x,{active:(ref=x.key,indexOf.call(role.permissions,ref)>=0)})})},isPermissionEditable=function(permission,role,project){return role.external_user&&!project.is_private&&0===permission.key.indexOf("view_")?!1:!0},setActivePermissionsPerCategory=function(category){return _.map(category,function(cat){return cat.permissions=cat.permissions.map(function(permission){return permission.editable=isPermissionEditable(permission,role,$scope.project),permission}),_.extend({},cat,{activePermissions:_.filter(cat.permissions,"active").length})})},categories=[],milestonePermissions=[{key:"view_milestones",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.VIEW_SPRINTS"},{key:"add_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.ADD_SPRINTS"},{key:"modify_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.MODIFY_SPRINTS"},{key:"delete_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.DELETE_SPRINTS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.NAME",permissions:setActivePermissions(milestonePermissions)}),userStoryPermissions=[{key:"view_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.VIEW_USER_STORIES"},{key:"add_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.ADD_USER_STORIES"},{key:"modify_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.MODIFY_USER_STORIES"},{key:"delete_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.DELETE_USER_STORIES"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.NAME",permissions:setActivePermissions(userStoryPermissions)}),taskPermissions=[{key:"view_tasks",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.VIEW_TASKS"},{key:"add_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.ADD_TASKS"},{key:"modify_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.MODIFY_TASKS"},{key:"delete_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.DELETE_TASKS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.TASKS.NAME",permissions:setActivePermissions(taskPermissions)}),issuePermissions=[{key:"view_issues",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.VIEW_ISSUES"},{key:"add_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.ADD_ISSUES"},{key:"modify_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.MODIFY_ISSUES"},{key:"delete_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.DELETE_ISSUES"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.NAME",permissions:setActivePermissions(issuePermissions)}),wikiPermissions=[{key:"view_wiki_pages",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_PAGES"},{key:"add_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_PAGES"},{key:"modify_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.MODIFY_WIKI_PAGES"},{key:"delete_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_PAGES"},{key:"view_wiki_links",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_LINKS"},{key:"add_wiki_link",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_LINKS"},{key:"delete_wiki_link",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_LINKS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.WIKI.NAME",permissions:setActivePermissions(wikiPermissions)}),setActivePermissionsPerCategory(categories)},renderResume=function(element,category){return element.find(".resume").html($compile(resumeTemplate({category:category}))($scope))},renderCategory=function(category,index){var html;return html=categoryTemplate({category:category,index:index}),html=angular.element(html),renderResume(html,category),$compile(html)($scope)},renderPermissions=function(){var html;return $el.off(),html=baseTemplate(),_.each(generateCategoriesFromRole($scope.role),function(category,index){return html=angular.element(html).append(renderCategory(category,index))}),$el.html(html),$el.on("click",".resume",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.next().toggleClass("open")}),$el.on("change",".category-item input",function(event){var getActivePermissions,onError,onSuccess,target;return getActivePermissions=function(){var activePermissions;return activePermissions=_.filter($el.find(".category-item input"),function(t){return angular.element(t).is(":checked")}),activePermissions=_.sortBy(_.map(activePermissions,function(t){var permission;return permission=angular.element(t).parents(".category-item").data("id")})),activePermissions.length&&activePermissions.push("view_project"),activePermissions},target=angular.element(event.currentTarget),$scope.role.permissions=getActivePermissions(),onSuccess=function(){var categories,categoryId;return categories=generateCategoriesFromRole($scope.role),categoryId=target.parents(".category-config").data("id"),renderResume(target.parents(".category-config"),categories[categoryId]),$rootscope.$broadcast("projects:reload"),$confirm.notify("success"),$ctrl.loadProject()},onError=function(){return $confirm.notify("error"),target.prop("checked",!target.prop("checked")),$scope.role.permissions=getActivePermissions()},$scope.role.external_user?($scope.project.public_permissions=$scope.role.permissions,$scope.project.anon_permissions=$scope.role.permissions.filter(function(permission){return 0===permission.indexOf("view_")}),$repo.save($scope.project).then(onSuccess,onError)):$repo.save($scope.role).then(onSuccess,onError)})},$scope.$on("$destroy",function(){return $el.off()}),$scope.$on("role:changed",function(){return renderPermissions()}),bindOnce($scope,$attrs.ngModel,renderPermissions)},{link:link}},module.directive("tgRolePermissions",["$rootScope","$tgRepo","$tgConfirm","$compile",RolePermissionsDirective])}.call(this),function(){var BitbucketController,BitbucketWebhooksDirective,GithubController,GithubWebhooksDirective,GitlabController,GitlabWebhooksDirective,NewWebhookDirective,SelectInputText,ValidOriginIpsDirective,WebhookDirective,WebhooksController,bindMethods,debounce,mixOf,module,taiga,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindMethods=this.taiga.bindMethods,debounce=this.taiga.debounce,timeout=this.taiga.timeout,module=angular.module("taigaAdmin"),WebhooksController=function(superClass){function WebhooksController(scope,repo,rs,params,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName="ADMIN.WEBHOOKS.SECTION_NAME",this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.WEBHOOKS.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("webhooks:reload",this.loadWebhooks)}return extend(WebhooksController,superClass),WebhooksController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],WebhooksController.prototype.loadWebhooks=function(){return this.rs.webhooks.list(this.scope.projectId).then(function(_this){return function(webhooks){return _this.scope.webhooks=webhooks}}(this))},WebhooksController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},WebhooksController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadWebhooks()}}(this)),promise},WebhooksController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("WebhooksController",WebhooksController),WebhookDirective=function($rs,$repo,$confirm,$loading,$translate){var link;return link=function($scope,$el,$attrs){var cancel,openHistory,save,showEditMode,showVisualizationMode,updateLogs,updateShowHideHistoryText,webhook;return webhook=$scope.$eval($attrs.tgWebhook),updateLogs=function(){var prettyDate;return prettyDate=$translate.instant("ADMIN.WEBHOOKS.DATE"),$rs.webhooklogs.list(webhook.id).then(function(_this){return function(webhooklogs){var i,len,log,ref;for(i=0,len=webhooklogs.length;len>i;i++)log=webhooklogs[i],log.validStatus=200<=(ref=log.status)&&300>ref,log.prettySentHeaders=_.map(_.pairs(log.request_headers),function(arg){var header,value;return header=arg[0],value=arg[1],header+": "+value}).join("\n"),log.prettySentData=JSON.stringify(log.request_data),log.prettyDate=moment(log.created).format(prettyDate);return webhook.logs_counter=webhooklogs.length,webhook.logs=webhooklogs,updateShowHideHistoryText()}}(this))},updateShowHideHistoryText=function(){var historyElement,text,textElement,title;return textElement=$el.find(".toggle-history"),historyElement=textElement.parents(".single-webhook-wrapper").find(".webhooks-history"),historyElement.hasClass("open")?(text=$translate.instant("ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY"),title=$translate.instant("ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY_TITLE")):(text=$translate.instant("ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY"),title=$translate.instant("ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY_TITLE")),textElement.text(text),textElement.prop("title",title)},showVisualizationMode=function(){return $el.find(".edition-mode").addClass("hidden"),$el.find(".visualization-mode").removeClass("hidden")},showEditMode=function(){return $el.find(".visualization-mode").addClass("hidden"),$el.find(".edition-mode").removeClass("hidden")},openHistory=function(){return $el.find(".webhooks-history").addClass("open")},cancel=function(){return showVisualizationMode(),$scope.$apply(function(){return webhook.revert()})},save=debounce(2e3,function(target){var form,promise;return form=target.parents("form").checksley(),form.validate()?(promise=$repo.save(webhook),promise.then(function(_this){return function(){return showVisualizationMode()}}(this)),promise.then(null,function(data){return $confirm.notify("error"),form.setErrors(data)})):void 0}),$el.on("click",".test-webhook",function(){return openHistory(),$rs.webhooks.test(webhook.id).then(function(_this){return function(){return updateLogs()}}(this))}),$el.on("click",".edit-webhook",function(){return showEditMode()}),$el.on("click",".cancel-existing",function(){return cancel()}),$el.on("click",".edit-existing",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),save(target)}),$el.on("keyup",".edition-mode input",function(event){var target;return 13===event.keyCode?(target=angular.element(event.currentTarget),save(target)):27===event.keyCode?(target=angular.element(event.currentTarget),cancel(target)):void 0}),$el.on("click",".delete-webhook",function(){var message,title;return title=$translate.instant("ADMIN.WEBHOOKS.DELETE"),message=$translate.instant("ADMIN.WEBHOOKS.WEBHOOK_NAME",{name:webhook.name}),$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSucces;return onSucces=function(){return askResponse.finish(),$scope.$emit("webhooks:reload")},onError=function(){return askResponse.finish(!1),$confirm.notify("error")},$repo.remove(webhook).then(onSucces,onError)}}(this))}),$el.on("click",".toggle-history",function(event){var target;return target=angular.element(event.currentTarget),null==webhook.logs||0===webhook.logs.length?updateLogs().then(function(){return timeout(0,function(){return $el.find(".webhooks-history").toggleClass("open"),updateShowHideHistoryText()})}):($el.find(".webhooks-history").toggleClass("open"),$scope.$apply(function(){return updateShowHideHistoryText()}))}),$el.on("click",".history-single",function(event){var target;return target=angular.element(event.currentTarget),target.toggleClass("history-single-open"),target.siblings(".history-single-response").toggleClass("open")}),$el.on("click",".resend-request",function(event){var log,target;return target=angular.element(event.currentTarget),log=target.data("log"),$rs.webhooklogs.resend(log).then(function(_this){return function(){return updateLogs()}}(this))})},{link:link}},module.directive("tgWebhook",["$tgResources","$tgRepo","$tgConfirm","$tgLoading","$translate",WebhookDirective]),NewWebhookDirective=function($rs,$repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var addWebhookDOMNode,formDOMNode,initializeNewValue,save,webhook;return webhook=$scope.$eval($attrs.tgWebhook),formDOMNode=$el.find(".new-webhook-form"),addWebhookDOMNode=$el.find(".add-webhook"),initializeNewValue=function(){return $scope.newValue={name:"",url:"",key:""}},initializeNewValue(),$scope.$watch("webhooks",function(webhooks){return null!=webhooks?0===webhooks.length?(formDOMNode.removeClass("hidden"),addWebhookDOMNode.addClass("hidden"),formDOMNode.find("input")[0].focus()):(formDOMNode.addClass("hidden"),addWebhookDOMNode.removeClass("hidden")):void 0}),save=debounce(2e3,function(){var form,promise;return form=formDOMNode.checksley(),form.validate()?($scope.newValue.project=$scope.project.id,promise=$repo.create("webhooks",$scope.newValue),promise.then(function(_this){return function(){return $scope.$emit("webhooks:reload"),initializeNewValue()}}(this)),promise.then(null,function(data){return $confirm.notify("error"),form.setErrors(data)})):void 0}),formDOMNode.on("click",".add-new",function(event){return event.preventDefault(),save()}),formDOMNode.on("keyup","input",function(event){return 13===event.keyCode?save():void 0}),formDOMNode.on("click",".cancel-new",function(event){return $scope.$apply(function(){return initializeNewValue()})}),addWebhookDOMNode.on("click",function(event){return formDOMNode.removeClass("hidden"),formDOMNode.find("input")[0].focus()})},{link:link}},module.directive("tgNewWebhook",["$tgResources","$tgRepo","$tgConfirm","$tgLoading",NewWebhookDirective]),GithubController=function(superClass){function GithubController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.GITHUB.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.GITHUB.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(GithubController,superClass),GithubController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],GithubController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"github").then(function(_this){return function(github){return _this.scope.github=github}}(this))},GithubController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},GithubController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},GithubController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("GithubController",GithubController),GitlabController=function(superClass){function GitlabController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.GITLAB.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.GITLAB.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:modules:reload",function(_this){return function(){return _this.loadModules()}}(this))}return extend(GitlabController,superClass),GitlabController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],GitlabController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"gitlab").then(function(_this){return function(gitlab){return _this.scope.gitlab=gitlab}}(this))},GitlabController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},GitlabController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},GitlabController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("GitlabController",GitlabController),BitbucketController=function(superClass){function BitbucketController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.BITBUCKET.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.BITBUCKET.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:modules:reload",function(_this){return function(){return _this.loadModules()}}(this))}return extend(BitbucketController,superClass),BitbucketController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],BitbucketController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"bitbucket").then(function(_this){return function(bitbucket){return _this.scope.bitbucket=bitbucket}}(this))},BitbucketController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},BitbucketController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},BitbucketController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("BitbucketController",BitbucketController),SelectInputText=function(){var link;return link=function($scope,$el,$attrs){return $el.on("click",".select-input-content",function(){return $el.find("input").select(),$el.find(".help-copy").addClass("visible")})},{link:link}},module.directive("tgSelectInputText",SelectInputText),GithubWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.github,"github"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgGithubWebhooks",["$tgRepo","$tgConfirm","$tgLoading",GithubWebhooksDirective]),GitlabWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.gitlab,"gitlab"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:modules:reload")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgGitlabWebhooks",["$tgRepo","$tgConfirm","$tgLoading",GitlabWebhooksDirective]),BitbucketWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.bitbucket,"bitbucket"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:modules:reload")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgBitbucketWebhooks",["$tgRepo","$tgConfirm","$tgLoading",BitbucketWebhooksDirective]),ValidOriginIpsDirective=function(){var link;return link=function($scope,$el,$attrs,$ngModel){return $ngModel.$parsers.push(function(value){return value=$.trim(value),""===value?[]:value.split(",")})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgValidOriginIps",ValidOriginIpsDirective)}.call(this),function(){var CreateProject,DeleteProjectDirective,bindOnce,debounce,module,taiga,timeout;taiga=this.taiga,bindOnce=this.taiga.bindOnce,timeout=this.taiga.timeout,debounce=this.taiga.debounce,module=angular.module("taigaProject"),CreateProject=function($rootscope,$repo,$confirm,$location,$navurls,$rs,$projectUrl,$loading,lightboxService,$cacheFactory,$translate,currentUserService){var directive,link;return link=function($scope,$el,attrs){var currentLoading,form,onErrorSubmit,onSuccessSubmit,openLightbox,submit,submitButton;return $scope.data={},$scope.templates=[],currentLoading=null,form=$el.find("form").checksley({onlyOneErrorElement:!0}),onSuccessSubmit=function(response){return $cacheFactory.get("$http").removeAll(),currentLoading.finish(),$rootscope.$broadcast("projects:reload"),$confirm.notify("success",$translate.instant("COMMON.SAVE")),$location.url($projectUrl.get(response)),lightboxService.close($el),currentUserService.loadProjects()},onErrorSubmit=function(response){var error_field,error_step,i,len,ref,selectors;for(currentLoading.finish(),form.setErrors(response),selectors=[],ref=_.keys(response),i=0,len=ref.length;len>i;i++)error_field=ref[i],selectors.push("[name="+error_field+"]");return $el.find(".active").removeClass("active"),error_step=$el.find(selectors.join(",")).first().parents(".wizard-step"),error_step.addClass("active"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(error_step.data("step"))},submit=function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("projects",$scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this),openLightbox=function(){return $scope.data={},$scope.templates.length?$scope.data.creation_template=_.head(_.filter($scope.templates,function(x){return"scrum"===x.slug})).id:$rs.projects.templates().then(function(_this){return function(result){return $scope.templates=result,$scope.data.creation_template=_.head(_.filter($scope.templates,function(x){return"scrum"===x.slug})).id}}(this)),$el.find(".active").removeClass("active"),$el.find(".create-step1").addClass("active"),lightboxService.open($el),timeout(600,function(){return $el.find(".progress-bar").addClass("step1")})},$el.on("click",".button-next",function(event){var current,field,i,len,next,ref,step,valid;for(event.preventDefault(),current=$el.find(".active"),valid=!0,ref=form.fields,i=0,len=ref.length;len>i;i++)field=ref[i],current.find("[name="+field.element.attr("name")+"]").length&&(valid=field.validate()!==!1&&valid);return valid?(next=current.next(),current.toggleClass("active"),next.toggleClass("active"),step=next.data("step"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(step)):void 0}),$el.on("click",".button-prev",function(event){var current,prev,step;return event.preventDefault(),current=$el.find(".active"),prev=current.prev(),current.toggleClass("active"),prev.toggleClass("active"),step=prev.data("step"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(step)}),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$el.on("click",".close",function(event){return event.preventDefault(),lightboxService.close($el)}),$scope.$on("$destroy",function(){return $el.off()}),openLightbox()},directive={link:link,templateUrl:"project/wizard-create-project.html",scope:{}}},module.directive("tgLbCreateProject",["$rootScope","$tgRepo","$tgConfirm","$location","$tgNavUrls","$tgResources","$projectUrl","$tgLoading","lightboxService","$cacheFactory","$translate","tgCurrentUserService",CreateProject]),DeleteProjectDirective=function($repo,$rootscope,$auth,$location,$navUrls,$confirm,lightboxService,tgLoader,currentUserService){var link;return link=function($scope,$el,$attrs){var projectToDelete,submit;return projectToDelete=null,$scope.$on("deletelightbox:new",function(ctx,project){return lightboxService.open($el),projectToDelete=project}),$scope.$on("$destroy",function(){return $el.off()}),submit=function(){var promise;return tgLoader.start(),lightboxService.close($el),promise=$repo.remove(projectToDelete),promise.then(function(data){return tgLoader.pageLoaded(),$rootscope.$broadcast("projects:reload"),$location.path($navUrls.resolve("home")),$confirm.notify("success"),currentUserService.loadProjects()}),promise.then(null,function(){return $confirm.notify("error"),lightboxService.close($el)})},$el.on("click",".button-red",function(event){return event.preventDefault(),lightboxService.close($el)}),$el.on("click",".button-green",function(event){return event.preventDefault(),submit()})},{link:link}},module.directive("tgLbDeleteProject",["$tgRepo","$rootScope","$tgAuth","$tgLocation","$tgNavUrls","$tgConfirm","lightboxService","tgLoader","tgCurrentUserService",DeleteProjectDirective])}.call(this),function(){var BindHtmlDirective,BindOnceAltDirective,BindOnceBindDirective,BindOnceHrefDirective,BindOnceHtmlDirective,BindOnceRefDirective,BindOnceSrcDirective,BindOnceTitleDirective,BindTitleDirective,bindOnce,module;bindOnce=this.taiga.bindOnce,BindOnceBindDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoBind,function(val){return $el.text(val)})},{link:link}},BindOnceHtmlDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoHtml,function(val){return $el.html(val)})},{link:link}},BindOnceRefDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoRef,function(val){return $el.html("#"+val+" ")})},{link:link}},BindOnceSrcDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoSrc,function(val){return $el.attr("src",val)})},{link:link}},BindOnceHrefDirective=function(){var link;return link=function($scope,$el,$attrs){ -return bindOnce($scope,$attrs.tgBoHref,function(val){return $el.attr("href",val)})},{link:link}},BindOnceAltDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoAlt,function(val){return $el.attr("alt",val)})},{link:link}},BindOnceTitleDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoTitle,function(val){return $el.attr("title",val)})},{link:link}},BindTitleDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgTitleHtml,function(val){return null!=val?$el.attr("title",val):void 0})},{link:link}},BindHtmlDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgBindHtml,function(val){return null!=val?$el.html(val):void 0})},{link:link}},module=angular.module("taigaBase"),module.directive("tgBoBind",BindOnceBindDirective),module.directive("tgBoHtml",BindOnceHtmlDirective),module.directive("tgBoRef",BindOnceRefDirective),module.directive("tgBoSrc",BindOnceSrcDirective),module.directive("tgBoHref",BindOnceHrefDirective),module.directive("tgBoAlt",BindOnceAltDirective),module.directive("tgBoTitle",BindOnceTitleDirective),module.directive("tgBindTitle",BindTitleDirective),module.directive("tgBindHtml",BindHtmlDirective)}.call(this),function(){var ConfigurationService,module;ConfigurationService=function(){function ConfigurationService(){this.config=window.taigaConfig}return ConfigurationService.prototype.get=function(key,defaultValue){return null==defaultValue&&(defaultValue=null),_.has(this.config,key)?this.config[key]:defaultValue},ConfigurationService}(),module=angular.module("taigaBase"),module.service("$tgConfig",ConfigurationService)}.call(this),function(){var ContribController,module,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;module=angular.module("taigaBase"),ContribController=function(superClass){function ContribController(rootScope,scope,params,repo,rs,confirm){var promise;this.rootScope=rootScope,this.scope=scope,this.params=params,this.repo=repo,this.rs=rs,this.confirm=confirm,this.scope.currentPlugin=_.first(_.where(this.rootScope.adminPlugins,{slug:this.params.plugin})),this.scope.projectSlug=this.params.pslug,promise=this.loadInitialData(),promise.then(null,function(_this){return function(){return _this.confirm.notify("error")}}(this))}return extend(ContribController,superClass),ContribController.$inject=["$rootScope","$scope","$routeParams","$tgRepo","$tgResources","$tgConfirm"],ContribController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.$broadcast("project:loaded",project),project}}(this))},ContribController.prototype.loadInitialData=function(){return this.loadProject()},ContribController}(taiga.Controller),module.controller("ContribController",ContribController)}.call(this),function(){var FiltersStorageService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,FiltersStorageService=function(superClass){function FiltersStorageService(storage,params){this.storage=storage,this.params=params}return extend(FiltersStorageService,superClass),FiltersStorageService.$inject=["$tgStorage","$routeParams"],FiltersStorageService.prototype.generateHash=function(components){return null==components&&(components=[]),components=_.map(components,function(x){return JSON.stringify(x)}),hex_sha1(components.join(":"))},FiltersStorageService}(taiga.Service)}.call(this),function(){var HttpService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,HttpService=function(superClass){function HttpService(http,q,storage,rootScope,cacheFactory,translate){this.http=http,this.q=q,this.storage=storage,this.rootScope=rootScope,this.cacheFactory=cacheFactory,this.translate=translate,HttpService.__super__.constructor.call(this),this.cache=this.cacheFactory("httpget")}return extend(HttpService,superClass),HttpService.$inject=["$http","$q","$tgStorage","$rootScope","$cacheFactory","$translate"],HttpService.prototype.headers=function(){var headers,lang,token;return headers={},token=this.storage.get("token"),token&&(headers.Authorization="Bearer "+token),lang=this.translate.preferredLanguage(),lang&&(headers["Accept-Language"]=lang),headers},HttpService.prototype.request=function(options){return options.headers=_.merge({},options.headers||{},this.headers()),this.http(options)},HttpService.prototype.get=function(url,params,options){return options=_.merge({method:"GET",url:url},options),params&&(options.params=params),options.cache=this.cache,this.request(options)["finally"](function(_this){return function(data){return _this.cache.removeAll()}}(this))},HttpService.prototype.post=function(url,data,params,options){return options=_.merge({method:"POST",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype.put=function(url,data,params,options){return options=_.merge({method:"PUT",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype.patch=function(url,data,params,options){return options=_.merge({method:"PATCH",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype["delete"]=function(url,data,params,options){return options=_.merge({method:"DELETE",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgHttp",HttpService)}.call(this),function(){var locationFactory,module;locationFactory=function($location,$route,$rootscope){return $location.noreload=function(scope){var lastRoute,un;return lastRoute=$route.current,un=scope.$on("$locationChangeSuccess",function(){return $route.current=lastRoute,un()}),$location},$location.isInCurrentRouteParams=function(name,value){var params;return params=$location.search()||{},params[name]===value},$location},module=angular.module("taigaBase"),module.factory("$tgLocation",["$location","$route","$rootScope",locationFactory])}.call(this),function(){var Model,ModelService,module,provider,taiga,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;Model=function(){function Model(name,data,dataTypes){this._attrs=data,this._name=name,this._dataTypes=dataTypes,this.setAttrs(data),this.initialize()}return Model.prototype.clone=function(){var instance;return instance=new Model(this._name,this._attrs,this._dataTypes),instance._modifiedAttrs=this._modifiedAttrs,instance._isModified=this._isModified,instance},Model.prototype.applyCasts=function(){var attrName,castMethod,castName,ref,results;ref=this._dataTypes,results=[];for(attrName in ref)castName=ref[attrName],castMethod=service.casts[castName],castMethod&&results.push(this._attrs[attrName]=castMethod(this._attrs[attrName]));return results},Model.prototype.getIdAttrName=function(){return"id"},Model.prototype.getName=function(){return this._name},Model.prototype.getAttrs=function(patch){return null==patch&&(patch=!1),null!=this._attrs.version&&(this._modifiedAttrs.version=this._attrs.version),patch?_.extend({},this._modifiedAttrs):_.extend({},this._attrs,this._modifiedAttrs)},Model.prototype.setAttrs=function(attrs){return this._attrs=attrs,this._modifiedAttrs={},this.applyCasts(),this._isModified=!1},Model.prototype.setAttr=function(name,value){return this._modifiedAttrs[name]=value,this._isModified=!0},Model.prototype.initialize=function(){var getter,self,setter;return self=this,getter=function(name){return function(){return"string"==typeof name&&"__"===name.substr(0,2)?self[name]:indexOf.call(_.keys(self._modifiedAttrs),name)<0?self._attrs[name]:self._modifiedAttrs[name]}},setter=function(name){return function(value){return"string"==typeof name&&"__"===name.substr(0,2)?void(self[name]=value):void(self._attrs[name]!==value?(self._modifiedAttrs[name]=value,self._isModified=!0):delete self._modifiedAttrs[name])}},_.each(this._attrs,function(value,name){var options;return options={get:getter(name),set:setter(name),enumerable:!0,configurable:!0},Object.defineProperty(self,name,options)})},Model.prototype.serialize=function(){var data;return data={data:_.clone(this._attrs),name:this._name},JSON.stringify(data)},Model.prototype.isModified=function(){return this._isModified},Model.prototype.isAttributeModified=function(attribute){return null!=this._modifiedAttrs[attribute]},Model.prototype.markSaved=function(){return this._isModified=!1,this._attrs=this.getAttrs(),this._modifiedAttrs={}},Model.prototype.revert=function(){return this._modifiedAttrs={},this._isModified=!1},Model.desSerialize=function(sdata){var ddata,model;return ddata=JSON.parse(sdata),model=new Model(ddata.url,ddata.data)},Model}(),taiga=this.taiga,ModelService=function(superClass){function ModelService(q,urls,storage,http){this.q=q,this.urls=urls,this.storage=storage,this.http=http,ModelService.__super__.constructor.call(this)}return extend(ModelService,superClass),ModelService.$inject=["$q","$tgUrls","$tgStorage","$tgHttp"],ModelService}(taiga.Service),provider=function($q,$http,$gmUrls,$gmStorage){var service;return service={},service.make_model=function(name,data,cls,dataTypes){return null==cls&&(cls=Model),null==dataTypes&&(dataTypes={}),new cls(name,data,dataTypes)},service.cls=Model,service.casts={"int":function(value){return parseInt(value,10)},"float":function(value){return parseFloat(value,10)}},service},module=angular.module("taigaBase"),module.factory("$tgModel",["$q","$http","$tgUrls","$tgStorage",provider])}.call(this),function(){var NavigationUrlsDirective,NavigationUrlsService,bindOnce,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,module=angular.module("taigaBase"),NavigationUrlsService=function(superClass){function NavigationUrlsService(){this.urls={}}return extend(NavigationUrlsService,superClass),NavigationUrlsService.prototype.update=function(urls){return this.urls=_.merge({},this.urls,urls||{})},NavigationUrlsService.prototype.formatUrl=function(url,ctx){var replacer;return null==ctx&&(ctx={}),replacer=function(match){return match=trim(match,":"),ctx[match]||"undefined"},url.replace(/(:\w+)/g,replacer)},NavigationUrlsService.prototype.resolve=function(name,ctx){var url;return url=this.urls[name],url?ctx?this.formatUrl(url,ctx):url:""},NavigationUrlsService}(taiga.Service),module.service("$tgNavUrls",NavigationUrlsService),NavigationUrlsDirective=function($navurls,$auth,$q,$location){var bindOnceP,link,parseNav;return bindOnceP=function($scope,attr){var defered;return defered=$q.defer(),bindOnce($scope,attr,function(v){return defered.resolve(v)}),defered.promise},parseNav=function(data,$scope){var index,name,obj,params,promises,ref,result,values;if(ref=_.map(data.split(":"),trim),name=ref[0],params=ref[1],params)for(result=params.split(/(\w+)=/),result=_.filter(result,function(str){return str.length}),result=_.map(result,function(str){return trim(str.replace(/,$/g,""))}),params=[],index=0;indexi;i++)param=params[i],key=Object.keys(param)[0],value=param[key],options[key]=$scope.$eval(value);return[name,options]})},link=function($scope,$el,$attrs){return $el.is("a")&&$el.attr("href","#"),$el.on("mouseenter",function(event){var target;return target=$(event.currentTarget),target.data("fullUrl")&&$attrs.tgNavGetParams===target.data("params")?void 0:parseNav($attrs.tgNav,$scope).then(function(result){var fullUrl,getURLParams,getURLParamsStr,name,options,url,user;return name=result[0],options=result[1],user=$auth.getUser(),user&&(options.user=user.username),url=$navurls.resolve(name),fullUrl=$navurls.formatUrl(url,options),$attrs.tgNavGetParams&&(getURLParams=JSON.parse($attrs.tgNavGetParams),getURLParamsStr=$.param(getURLParams),fullUrl=fullUrl+"?"+getURLParamsStr,target.data("params",$attrs.tgNavGetParams)),target.data("fullUrl",fullUrl),target.is("a")&&target.attr("href",fullUrl),$el.on("click",function(event){if(!event.metaKey&&!event.ctrlKey&&(event.preventDefault(),target=$(event.currentTarget),!target.hasClass("noclick")))switch(fullUrl=target.data("fullUrl"),event.which){case 1:return $location.url(fullUrl),$scope.$apply();case 2:return window.open(fullUrl)}})})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgNav",["$tgNavUrls","$tgAuth","$q","$tgLocation",NavigationUrlsDirective])}.call(this),function(){var RepositoryService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,RepositoryService=function(superClass){function RepositoryService(q,model1,storage,http,urls){this.q=q,this.model=model1,this.storage=storage,this.http=http,this.urls=urls,RepositoryService.__super__.constructor.call(this)}return extend(RepositoryService,superClass),RepositoryService.$inject=["$q","$tgModel","$tgStorage","$tgHttp","$tgUrls"],RepositoryService.prototype.resolveUrlForModel=function(model){var idAttrName;return idAttrName=model.getIdAttrName(),this.urls.resolve(model.getName())+"/"+model[idAttrName]},RepositoryService.prototype.resolveUrlForAttributeModel=function(model){return this.urls.resolve(model.getName(),model.parent)},RepositoryService.prototype.create=function(name,data,dataTypes,extraParams){var defered,promise,url;return null==dataTypes&&(dataTypes={}),null==extraParams&&(extraParams={}),defered=this.q.defer(),url=this.urls.resolve(name),promise=this.http.post(url,JSON.stringify(data)),promise.success(function(_this){return function(_data,_status){return defered.resolve(_this.model.make_model(name,_data,null,dataTypes))}}(this)),promise.error(function(_this){return function(data,status){return defered.reject(data)}}(this)),defered.promise},RepositoryService.prototype.remove=function(model,params){var defered,promise,url;return null==params&&(params={}),defered=this.q.defer(),url=this.resolveUrlForModel(model),promise=this.http["delete"](url,{},params),promise.success(function(data,status){return defered.resolve(model)}),promise.error(function(data,status){return defered.reject(model)}),defered.promise},RepositoryService.prototype.saveAll=function(models,patch){var promises;return null==patch&&(patch=!0),promises=_.map(models,function(_this){return function(x){return _this.save(x,!0)}}(this)),this.q.all(promises)},RepositoryService.prototype.save=function(model,patch){var data,defered,promise,url;return null==patch&&(patch=!0),defered=this.q.defer(),!model.isModified()&&patch?(defered.resolve(model),defered.promise):(url=this.resolveUrlForModel(model),data=JSON.stringify(model.getAttrs(patch)),promise=patch?this.http.patch(url,data):this.http.put(url,data),promise.success(function(_this){return function(data,status){return model._isModified=!1,model._attrs=_.extend(model.getAttrs(),data),model._modifiedAttrs={},model.applyCasts(),defered.resolve(model)}}(this)),promise.error(function(data,status){return defered.reject(data)}),defered.promise)},RepositoryService.prototype.saveAttribute=function(model,attribute,patch){var data,defered,promise,url;return null==patch&&(patch=!0),defered=this.q.defer(),!model.isModified()&&patch?(defered.resolve(model),defered.promise):(url=this.resolveUrlForAttributeModel(model),data={},data[attribute]=model.getAttrs(),promise=patch?this.http.patch(url,data):this.http.put(url,data),promise.success(function(_this){return function(data,status){return model._isModified=!1,model._attrs=_.extend(model.getAttrs(),data),model._modifiedAttrs={},model.applyCasts(),defered.resolve(model)}}(this)),promise.error(function(data,status){return defered.reject(data)}),defered.promise)},RepositoryService.prototype.refresh=function(model){var defered,promise,url;return defered=this.q.defer(),url=this.resolveUrlForModel(model),promise=this.http.get(url),promise.success(function(data,status){return model._modifiedAttrs={},model._attrs=data,model._isModified=!1,model.applyCasts(),defered.resolve(model)}),promise.error(function(data,status){return defered.reject(data)}),defered.promise},RepositoryService.prototype.queryMany=function(name,params,options,headers){var httpOptions,url;return null==options&&(options={}),null==headers&&(headers=!1),url=this.urls.resolve(name),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var result;return result=_.map(data.data,function(x){return _this.model.make_model(name,x)}),headers?[result,data.headers]:result}}(this))},RepositoryService.prototype.queryOneAttribute=function(name,id,attribute,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name,id),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var model;return model=_this.model.make_model(name,data.data[attribute]),model.parent=id,model}}(this))},RepositoryService.prototype.queryOne=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){return _this.model.make_model(name,data.data)}}(this))},RepositoryService.prototype.queryOneRaw=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions=_.merge({headers:{}},options),options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){return data.data}}(this))},RepositoryService.prototype.queryPaginated=function(name,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),httpOptions=_.merge({headers:{}},options),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var headers,result;return headers=data.headers(),result={},result.models=_.map(data.data,function(x){return _this.model.make_model(name,x)}),result.count=parseInt(headers["x-pagination-count"],10),result.current=parseInt(headers["x-pagination-current"]||1,10),result.paginatedBy=parseInt(headers["x-paginated-by"],10),result}}(this))},RepositoryService.prototype.queryOnePaginatedRaw=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions=_.merge({headers:{}},options),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var headers,result;return headers=data.headers(),result={},result.data=data.data,result.count=parseInt(headers["x-pagination-count"],10),result.current=parseInt(headers["x-pagination-current"]||1,10),result.paginatedBy=parseInt(headers["x-paginated-by"],10),result}}(this))},RepositoryService.prototype.resolve=function(options){var cache,params;return params={},null!=options.pslug&&(params.project=options.pslug),null!=options.usref&&(params.us=options.usref),null!=options.taskref&&(params.task=options.taskref),null!=options.issueref&&(params.issue=options.issueref),null!=options.sslug&&(params.milestone=options.sslug),null!=options.wikipage&&(params.wikipage=options.wikipage),cache=!(options.wikipage||options.sslug),this.queryOneRaw("resolver",null,params,{cache:cache})},RepositoryService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgRepo",RepositoryService)}.call(this),function(){var StorageService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,StorageService=function(superClass){function StorageService($rootScope){StorageService.__super__.constructor.call(this)}return extend(StorageService,superClass),StorageService.$inject=["$rootScope"],StorageService.prototype.get=function(key,_default){var serializedValue;return serializedValue=localStorage.getItem(key),null===serializedValue?_default||null:JSON.parse(serializedValue)},StorageService.prototype.set=function(key,val){return _.isObject(key)?_.each(key,function(_this){return function(val,key){return _this.set(key,val)}}(this)):localStorage.setItem(key,JSON.stringify(val))},StorageService.prototype.contains=function(key){var value;return value=this.get(key),null!==value},StorageService.prototype.remove=function(key){return localStorage.removeItem(key)},StorageService.prototype.clear=function(){return localStorage.clear()},StorageService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgStorage",StorageService)}.call(this),function(){var UrlsService,format,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;format=function(fmt,obj){return obj=_.clone(obj),fmt.replace(/%s/g,function(match){return String(obj.shift())})},taiga=this.taiga,UrlsService=function(superClass){function UrlsService(config){this.config=config,this.urls={},this.mainUrl=this.config.get("api")}return extend(UrlsService,superClass),UrlsService.$inject=["$tgConfig"],UrlsService.prototype.update=function(urls){return this.urls=_.merge(this.urls,urls)},UrlsService.prototype.resolve=function(){var args,name,url;if(args=_.toArray(arguments),0===args.length)throw Error("wrong arguments to setUrls");return name=args.slice(0,1)[0],url=format(this.urls[name],args.slice(1)),format("%s/%s",[_.str.rtrim(this.mainUrl,"/"),_.str.ltrim(url,"/")])},UrlsService.prototype.resolveAbsolute=function(){var url;return url=this.resolve.apply(this,arguments),/^https?:\/\//i.test(url)?url:/^\//.test(url)?window.location.protocol+"//"+window.location.host+url:window.location.protocol+"//"+window.location.host+"/"+url},UrlsService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgUrls",UrlsService)}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo){var _get,service;return _get=function(objectId,resource){return $repo.queryOne(resource,objectId)},service={userstory:{get:function(objectId){return _get(objectId,"custom-attributes-values/userstory")}},task:{get:function(objectId){return _get(objectId,"custom-attributes-values/task")}},issue:{get:function(objectId){return _get(objectId,"custom-attributes-values/issue")}}},function(instance){return instance.customAttributesValues=service}},module=angular.module("taigaResources"),module.factory("$tgCustomAttributesValuesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($repo){var _list,service;return _list=function(projectId,resource){return $repo.queryMany(resource,{project:projectId})},service={userstory:{list:function(projectId){return _list(projectId,"custom-attributes/userstory")}},task:{list:function(projectId){return _list(projectId,"custom-attributes/task")}},issue:{list:function(projectId){return _list(projectId,"custom-attributes/issue")}}},function(instance){return instance.customAttributes=service}},module=angular.module("taigaResources"),module.factory("$tgCustomAttributesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(type,objectId){return $repo.queryOneRaw("history/"+type,objectId)},service.deleteComment=function(type,objectId,activityId){var params,url;return url=$urls.resolve("history/"+type),url=url+"/"+objectId+"/delete_comment",params={id:activityId},$http.post(url,null,params).then(function(_this){return function(data){return data.data}}(this))},service.undeleteComment=function(type,objectId,activityId){var params,url;return url=$urls.resolve("history/"+type),url=url+"/"+objectId+"/undelete_comment",params={id:activityId},$http.post(url,null,params).then(function(_this){return function(data){return data.data}}(this))},function(instance){return instance.history=service}},module=angular.module("taigaResources"),module.factory("$tgHistoryResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo){var service;return service={},service.get=function(token){return $repo.queryOne("invitations",token)},function(instance){return instance.invitations=service}},module=angular.module("taigaResources"),module.factory("$tgInvitationsResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage,$q){var filtersHashSuffix,hashSuffix,myFiltersHashSuffix,service;return service={},hashSuffix="issues-queryparams",filtersHashSuffix="issues-filters",myFiltersHashSuffix="issues-my-filters",service.get=function(projectId,issueId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("issues",issueId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("issues","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("issues",filters)},service.list=function(projectId,filters,options){var params;return params={project:projectId},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryPaginated("issues",params,options)},service.bulkCreate=function(projectId,data){var params,url;return url=$urls.resolve("bulk-create-issues"),params={project_id:projectId,bulk_issues:data},$http.post(url,params)},service.upvote=function(issueId){var url;return url=$urls.resolve("issue-upvote",issueId),$http.post(url)},service.downvote=function(issueId){var url;return url=$urls.resolve("issue-downvote",issueId),$http.post(url)},service.watch=function(issueId){var url;return url=$urls.resolve("issue-watch",issueId),$http.post(url)},service.unwatch=function(issueId){var url;return url=$urls.resolve("issue-unwatch",issueId),$http.post(url)},service.stats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/issues_stats")},service.filtersData=function(params){return $repo.queryOneRaw("issues-filters",null,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},service.storeQueryParams(projectId,params),$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeFilters=function(projectSlug,params){var hash,ns;return ns=projectSlug+":"+filtersHashSuffix,hash=generateHash([projectSlug,ns]),$storage.set(hash,params)},service.getFilters=function(projectSlug){var hash,ns;return ns=projectSlug+":"+filtersHashSuffix,hash=generateHash([projectSlug,ns]),$storage.get(hash)||{}},service.storeMyFilters=function(projectId,myFilters){var deferred,hash,ns,promise,url;return deferred=$q.defer(),url=$urls.resolve("user-storage"),ns=projectId+":"+myFiltersHashSuffix,hash=generateHash([projectId,ns]),_.isEmpty(myFilters)?(promise=$http["delete"](url+"/"+hash,{key:hash,value:myFilters}),promise.then(function(){return deferred.resolve()}),promise.then(null,function(){return deferred.reject()})):(promise=$http.put(url+"/"+hash,{key:hash,value:myFilters}),promise.then(function(data){return deferred.resolve()}),promise.then(null,function(data){var innerPromise;return innerPromise=$http.post(""+url,{key:hash,value:myFilters}),innerPromise.then(function(){return deferred.resolve()}),innerPromise.then(null,function(){return deferred.reject()})})),deferred.promise},service.getMyFilters=function(projectId){var deferred,hash,ns,promise,url;return deferred=$q.defer(),url=$urls.resolve("user-storage"),ns=projectId+":"+myFiltersHashSuffix,hash=generateHash([projectId,ns]),promise=$http.get(url+"/"+hash),promise.then(function(data){return deferred.resolve(data.data.value)}),promise.then(null,function(data){return deferred.resolve({})}),deferred.promise},function(instance){return instance.issues=service}},module=angular.module("taigaResources"),module.factory("$tgIssuesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($storage){var hashSuffixStatusColumnModes,hashSuffixStatusViewModes,service;return service={},hashSuffixStatusViewModes="kanban-statusviewmodels",hashSuffixStatusColumnModes="kanban-statuscolumnmodels",service.storeStatusViewModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusViewModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusViewModes=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffixStatusViewModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeStatusColumnModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusColumnModes=function(projectId){ -var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},function(instance){return instance.kanban=service}},module=angular.module("taigaResources"),module.factory("$tgKanbanResourcesProvider",["$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($repo){var service;return service={list:function(){return $repo.queryMany("locales")}},function(instance){return instance.locales=service}},module=angular.module("taigaResources"),module.factory("$tgLocalesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$urls,$http){var service;return service={},service.render=function(projectId,content){var params,url;return(null==content||""===content)&&(content=" "),params={project_id:projectId,content:content},url=$urls.resolve("wiki"),$http.post(url+"/render",params).then(function(_this){return function(data){return data.data}}(this))},function(instance){return instance.mdrender=service}},module=angular.module("taigaResources"),module.factory("$tgMdRenderResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("memberships",id)},service.list=function(projectId,filters,enablePagination){var options,params;return null==enablePagination&&(enablePagination=!0),params={project:projectId},params=_.extend({},params,filters||{}),enablePagination?$repo.queryPaginated("memberships",params):$repo.queryMany("memberships",params,options={enablePagination:enablePagination})},service.listByUser=function(userId,filters){var params;return params={user:userId},params=_.extend({},params,filters||{}),$repo.queryPaginated("memberships",params)},service.resendInvitation=function(id){var url;return url=$urls.resolve("memberships"),$http.post(url+"/"+id+"/resend_invitation",{})},service.bulkCreateMemberships=function(projectId,data,invitation_extra_text){var params,url;return url=$urls.resolve("bulk-create-memberships"),params={project_id:projectId,bulk_memberships:data,invitation_extra_text:invitation_extra_text},$http.post(url,params)},function(instance){return instance.memberships=service}},module=angular.module("taigaResources"),module.factory("$tgMembershipsResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo){var service;return service={},service.list=function(projectId,module){return $repo.queryOneAttribute("project-modules",projectId,module)},function(instance){return instance.modules=service}},module=angular.module("taigaResources"),module.factory("$tgModulesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("notify-policies",id)},service.list=function(filters){var params;return params=_.extend({},params,filters||{}),$repo.queryMany("notify-policies",params)},function(instance){return instance.notifyPolicies=service}},module=angular.module("taigaResources"),module.factory("$tgNotifyPoliciesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($config,$repo,$http,$urls,$auth,$q,$translate){var service;return service={},service.get=function(projectId){return $repo.queryOne("projects",projectId)},service.getBySlug=function(projectSlug){return $repo.queryOne("projects","by_slug?slug="+projectSlug)},service.list=function(){return $repo.queryMany("projects")},service.listByMember=function(memberId){var params;return params={member:memberId,order_by:"memberships__user_order"},$repo.queryMany("projects",params)},service.templates=function(){return $repo.queryMany("project-templates")},service.usersList=function(projectId){var params;return params={project:projectId},$repo.queryMany("users",params)},service.rolesList=function(projectId){var params;return params={project:projectId},$repo.queryMany("roles",params)},service.stats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/stats")},service.bulkUpdateOrder=function(bulkData){var url;return url=$urls.resolve("bulk-update-projects-order"),$http.post(url,bulkData)},service.regenerate_userstories_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_userstories_csv_uuid",$http.post(url)},service.regenerate_issues_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_issues_csv_uuid",$http.post(url)},service.regenerate_tasks_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_tasks_csv_uuid",$http.post(url)},service.leave=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/leave",$http.post(url)},service.memberStats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/member_stats")},service.tagsColors=function(projectId){return $repo.queryOne("projects",projectId+"/tags_colors")},service["export"]=function(projectId){var url;return url=$urls.resolve("exporter")+"/"+projectId,$http.get(url)},service["import"]=function(file,statusUpdater){var complete,data,defered,errorMsg,failed,maxFileSize,response,uploadComplete,uploadFailed,uploadProgress,xhr;return defered=$q.defer(),maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_MAX_SIZE_EXCEEDED",{fileName:file.name,fileSize:sizeFormat(file.size),maxFileSize:sizeFormat(maxFileSize)}),response={status:413,data:{_error_message:errorMsg}},defered.reject(response),defered.promise):(uploadProgress=function(_this){return function(evt){var message,percent;return percent=Math.round(evt.loaded/evt.total*100),message=$translate.instant("PROJECT.IMPORT.UPLOAD_IN_PROGRESS_MESSAGE",{uploadedSize:sizeFormat(evt.loaded),totalSize:sizeFormat(evt.total)}),statusUpdater("in-progress",null,message,percent)}}(this),uploadComplete=function(_this){return function(evt){return statusUpdater("done",$translate.instant("PROJECT.IMPORT.TITLE"),$translate.instant("PROJECT.IMPORT.DESCRIPTION"))}}(this),uploadFailed=function(_this){return function(evt){return statusUpdater("error")}}(this),complete=function(_this){return function(evt){var ref;response={};try{response.data=JSON.parse(evt.target.responseText)}catch(error){response.data={}}return response.status=evt.target.status,(201===(ref=response.status)||202===ref)&&defered.resolve(response),defered.reject(response)}}(this),failed=function(_this){return function(evt){return defered.reject("fail")}}(this),data=new FormData,data.append("dump",file),xhr=new XMLHttpRequest,xhr.upload.addEventListener("progress",uploadProgress,!1),xhr.upload.addEventListener("load",uploadComplete,!1),xhr.upload.addEventListener("error",uploadFailed,!1),xhr.upload.addEventListener("abort",uploadFailed,!1),xhr.addEventListener("load",complete,!1),xhr.addEventListener("error",failed,!1),xhr.open("POST",$urls.resolve("importer")),xhr.setRequestHeader("Authorization","Bearer "+$auth.getToken()),xhr.setRequestHeader("Accept","application/json"),xhr.send(data),defered.promise)},service.changeLogo=function(projectId,file){var data,defered,maxFileSize,options,response,url;return maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered=$q.defer(),defered.reject(response),defered.promise):(data=new FormData,data.append("logo",file),options={transformRequest:angular.identity,headers:{"Content-Type":void 0}},url=$urls.resolve("projects")+"/"+projectId+"/change_logo",$http.post(url,data,{},options))},service.removeLogo=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/remove_logo",$http.post(url)},function(instance){return instance.projects=service}},module=angular.module("taigaResources"),module.factory("$tgProjectsResourcesProvider",["$tgConfig","$tgRepo","$tgHttp","$tgUrls","$tgAuth","$q","$translate",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("roles",id)},service.list=function(projectId){return $repo.queryMany("roles",{project:projectId})},function(instance){return instance.roles=service}},module=angular.module("taigaResources"),module.factory("$tgRolesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$urls,$http,$q){var service;return service={},service["do"]=function(projectId,term){var deferredAbort,params,request,url;return deferredAbort=$q.defer(),url=$urls.resolve("search"),params={url:url,method:"GET",timeout:deferredAbort.promise,cancelable:!0,params:{project:projectId,text:term,get_all:!1}},request=$http.request(params).then(function(data){return data.data}),request.abort=function(){return deferredAbort.resolve()},request["finally"]=function(){return request.abort=angular.noop,deferredAbort=request=null},request},function(instance){return instance.search=service}},module=angular.module("taigaResources"),module.factory("$tgSearchResourcesProvider",["$tgRepo","$tgUrls","$tgHttp","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$model,$storage){var service;return service={},service.get=function(projectId,sprintId){return $repo.queryOne("milestones",sprintId).then(function(sprint){var uses;return uses=sprint.user_stories,uses=_.map(uses,function(u){return $model.make_model("userstories",u)}),sprint._attrs.user_stories=uses,sprint})},service.stats=function(projectId,sprintId){return $repo.queryOneRaw("milestones",sprintId+"/stats")},service.list=function(projectId,filters){var params;return params={project:projectId},params=_.extend({},params,filters||{}),$repo.queryMany("milestones",params,{},!0).then(function(_this){return function(result){var headers,i,len,m,milestones,uses;for(milestones=result[0],headers=result[1],i=0,len=milestones.length;len>i;i++)m=milestones[i],uses=m.user_stories,uses=_.map(uses,function(u){return $model.make_model("userstories",u)}),m._attrs.user_stories=uses;return{milestones:milestones,closed:parseInt(headers("Taiga-Info-Total-Closed-Milestones"),10),open:parseInt(headers("Taiga-Info-Total-Opened-Milestones"),10)}}}(this))},function(instance){return instance.sprints=service}},module=angular.module("taigaResources"),module.factory("$tgSprintsResourcesProvider",["$tgRepo","$tgModel","$tgStorage",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage){var hashSuffix,hashSuffixStatusColumnModes,hashSuffixUsRowModes,service;return service={},hashSuffix="tasks-queryparams",hashSuffixStatusColumnModes="tasks-statuscolumnmodels",hashSuffixUsRowModes="tasks-usrowmodels",service.get=function(projectId,taskId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("tasks",taskId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("tasks","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("tasks",filters)},service.list=function(projectId,sprintId,userStoryId){var params;return null==sprintId&&(sprintId=null),null==userStoryId&&(userStoryId=null),params={project:projectId},sprintId&&(params.milestone=sprintId),userStoryId&&(params.user_story=userStoryId),service.storeQueryParams(projectId,params),$repo.queryMany("tasks",params)},service.bulkCreate=function(projectId,sprintId,usId,data){var params,url;return url=$urls.resolve("bulk-create-tasks"),params={project_id:projectId,sprint_id:sprintId,us_id:usId,bulk_tasks:data},$http.post(url,params).then(function(result){return result.data})},service.upvote=function(taskId){var url;return url=$urls.resolve("task-upvote",taskId),$http.post(url)},service.downvote=function(taskId){var url;return url=$urls.resolve("task-downvote",taskId),$http.post(url)},service.watch=function(taskId){var url;return url=$urls.resolve("task-watch",taskId),$http.post(url)},service.unwatch=function(taskId){var url;return url=$urls.resolve("task-unwatch",taskId),$http.post(url)},service.bulkUpdateTaskTaskboardOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-task-taskboard-order"),params={project_id:projectId,bulk_tasks:data},$http.post(url,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeStatusColumnModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusColumnModes=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeUsRowModes=function(projectId,sprintId,params){var hash,ns;return ns=projectId+":"+hashSuffixUsRowModes,hash=generateHash([projectId,sprintId,ns]),$storage.set(hash,params)},service.getUsRowModes=function(projectId,sprintId){var hash,ns;return ns=projectId+":"+hashSuffixUsRowModes,hash=generateHash([projectId,sprintId,ns]),$storage.get(hash)||{}},function(instance){return instance.tasks=service}},module=angular.module("taigaResources"),module.factory("$tgTasksResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($config,$repo,$http,$urls,$q){var service;return service={},service.changeAvatar=function(file){var data,defered,maxFileSize,options,response,url;return maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered=$q.defer(),defered.reject(response),defered.promise):(data=new FormData,data.append("avatar",file),options={transformRequest:angular.identity,headers:{"Content-Type":void 0}},url=$urls.resolve("users")+"/change_avatar",$http.post(url,data,{},options))},service.removeAvatar=function(){var url;return url=$urls.resolve("users")+"/remove_avatar",$http.post(url)},service.changePassword=function(currentPassword,newPassword){var data,url;return url=$urls.resolve("users")+"/change_password",data={current_password:currentPassword,password:newPassword},$http.post(url,data)},function(instance){return instance.userSettings=service}},module=angular.module("taigaResources"),module.factory("$tgUserSettingsResourcesProvider",["$tgConfig","$tgRepo","$tgHttp","$tgUrls","$q",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($http,$urls){var service;return service={},service.contacts=function(userId,options){var httpOptions,url;return null==options&&(options={}),url=$urls.resolve("user-contacts",userId),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),$http.get(url,{},httpOptions).then(function(result){return result.data})},function(instance){return instance.users=service}},module=angular.module("taigaResources"),module.factory("$tgUsersResourcesProvider",["$tgHttp","$tgUrls","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage){var hashSuffix,service;return service={},hashSuffix="userstories-queryparams",service.get=function(projectId,usId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("userstories",usId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("userstories","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("userstories",filters)},service.filtersData=function(params){return $repo.queryOneRaw("userstories-filters",null,params)},service.listUnassigned=function(projectId,filters){var params;return params={project:projectId,milestone:"null"},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryMany("userstories",params)},service.listAll=function(projectId,filters){var params;return params={project:projectId},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryMany("userstories",params)},service.bulkCreate=function(projectId,status,bulk){var data,url;return data={project_id:projectId,status_id:status,bulk_stories:bulk},url=$urls.resolve("bulk-create-us"),$http.post(url,data)},service.upvote=function(userStoryId){var url;return url=$urls.resolve("userstory-upvote",userStoryId),$http.post(url)},service.downvote=function(userStoryId){var url;return url=$urls.resolve("userstory-downvote",userStoryId),$http.post(url)},service.watch=function(userStoryId){var url;return url=$urls.resolve("userstory-watch",userStoryId),$http.post(url)},service.unwatch=function(userStoryId){var url;return url=$urls.resolve("userstory-unwatch",userStoryId),$http.post(url)},service.bulkUpdateBacklogOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-backlog-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.bulkUpdateSprintOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-sprint-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.bulkUpdateKanbanOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-kanban-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},service.storeQueryParams(projectId,params),$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeShowTags=function(projectId,showTags){var hash;return hash=generateHash([projectId,"showTags"]),$storage.set(hash,showTags)},service.getShowTags=function(projectId){var hash;return hash=generateHash([projectId,"showTags"]),$storage.get(hash)||null},function(instance){return instance.userstories=service}},module=angular.module("taigaResources"),module.factory("$tgUserstoriesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo,$urls,$http){var service;return service={},service.list=function(webhookId){var params;return params={webhook:webhookId},$repo.queryMany("webhooklogs",params)},service.resend=function(webhooklogId){var url;return url=$urls.resolve("webhooklogs-resend",webhooklogId),$http.post(url)},function(instance){return instance.webhooklogs=service}},module=angular.module("taigaResources"),module.factory("$tgWebhookLogsResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo,$urls,$http){var service;return service={},service.list=function(projectId){var params;return params={project:projectId},$repo.queryMany("webhooks",params)},service.test=function(webhookId){var url;return url=$urls.resolve("webhooks-test",webhookId),$http.post(url)},function(instance){return instance.webhooks=service}},module=angular.module("taigaResources"),module.factory("$tgWebhooksResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(wikiId){return $repo.queryOne("wiki",wikiId)},service.getBySlug=function(projectId,slug){return $repo.queryOne("wiki","by_slug?project="+projectId+"&slug="+slug)},service.listLinks=function(projectId){return $repo.queryMany("wiki-links",{project:projectId})},function(instance){return instance.wiki=service}},module=angular.module("taigaResources"),module.factory("$tgWikiResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var UserChangePasswordController,UserChangePasswordDirective,debounce,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,debounce=this.taiga.debounce,module=angular.module("taigaUserSettings"),UserChangePasswordController=function(superClass){function UserChangePasswordController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,auth,translate){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.translate=translate,this.scope.sectionName=this.translate.instant("CHANGE_PASSWORD.SECTION_NAME"),this.scope.user=this.auth.getUser()}return extend(UserChangePasswordController,superClass),UserChangePasswordController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth","$translate"],UserChangePasswordController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserChangePasswordController",UserChangePasswordController),UserChangePasswordDirective=function($rs,$confirm,$loading,$translate){var link;return link=function($scope,$el,$attrs,ctrl){var submit,submitButton;return submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),$scope.newPassword1!==$scope.newPassword2?void $confirm.notify("error",$translate.instant("CHANGE_PASSWORD.ERROR_PASSWORD_MATCH")):(currentLoading=$loading().target(submitButton).start(),promise=$rs.userSettings.changePassword($scope.currentPassword,$scope.newPassword1),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(response){return currentLoading.finish(),$confirm.notify("error",response.data._error_message)}))}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserChangePassword",["$tgResources","$tgConfirm","$tgLoading","$translate",UserChangePasswordDirective])}.call(this),function(){var DeleteUserDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaUserSettings"),DeleteUserDirective=function($repo,$rootscope,$auth,$location,$navUrls,lightboxService){var link;return link=function($scope,$el,$attrs){var submit;return $scope.$on("deletelightbox:new",function(ctx,user){return lightboxService.open($el)}),$scope.$on("$destroy",function(){return $el.off()}),submit=function(){var promise;return promise=$repo.remove($scope.user),promise.then(function(data){return lightboxService.close($el),$auth.logout(),$location.path($navUrls.resolve("login"))}),promise.then(null,function(){return console.log("FAIL")})},$el.on("click",".button-red",function(event){return event.preventDefault(),lightboxService.close($el)}),$el.on("click",".button-green",debounce(2e3,function(event){return event.preventDefault(),submit()}))},{link:link,templateUrl:"user/lightbox/lightbox-delete-account.html"}},module.directive("tgLbDeleteUser",["$tgRepo","$rootScope","$tgAuth","$tgLocation","$tgNavUrls","lightboxService",DeleteUserDirective])}.call(this),function(){var TaigaAvatarModelDirective,UserAvatarDirective,UserProfileDirective,UserSettingsController,debounce,mixOf,module,sizeFormat,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,sizeFormat=this.taiga.sizeFormat,module=angular.module("taigaUserSettings"),debounce=this.taiga.debounce,UserSettingsController=function(superClass){function UserSettingsController(scope,rootscope,config,repo,confirm,rs,params,q,location,navUrls,auth,translate){var maxFileSize,promise,text;this.scope=scope,this.rootscope=rootscope,this.config=config,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.translate=translate,this.scope.sectionName="USER_SETTINGS.MENU.SECTION_TITLE",this.scope.project={},this.scope.user=this.auth.getUser(),this.scope.user||(this.location.path(this.navUrls.resolve("permission-denied")),this.location.replace()),this.scope.lang=this.getLan(),this.scope.theme=this.getTheme(),maxFileSize=this.config.get("maxUploadFileSize",null),maxFileSize&&(text=this.translate.instant("USER_SETTINGS.AVATAR_MAX_SIZE",{maxFileSize:sizeFormat(maxFileSize)}),this.scope.maxFileSizeMsg=text),promise=this.loadInitialData(),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserSettingsController,superClass),UserSettingsController.$inject=["$scope","$rootScope","$tgConfig","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth","$translate"],UserSettingsController.prototype.loadInitialData=function(){return this.scope.availableThemes=this.config.get("themes",[]),this.rs.locales.list().then(function(_this){return function(locales){return _this.scope.locales=locales,locales}}(this))},UserSettingsController.prototype.openDeleteLightbox=function(){return this.rootscope.$broadcast("deletelightbox:new",this.scope.user)},UserSettingsController.prototype.getLan=function(){return this.scope.user.lang||this.translate.preferredLanguage()},UserSettingsController.prototype.getTheme=function(){return this.scope.user.theme||this.config.get("defaultTheme")||"taiga"},UserSettingsController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserSettingsController",UserSettingsController),UserProfileDirective=function($confirm,$auth,$repo,$translate){var link;return link=function($scope,$el,$attrs){var submit;return submit=debounce(2e3,function(_this){return function(event){var changeEmail,form,onError,onSuccess;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(changeEmail=$scope.user.isAttributeModified("email"),$scope.user.lang=$scope.lang,$scope.user.theme=$scope.theme,onSuccess=function(data){var text;return $auth.setUser(data),changeEmail?(text=$translate.instant("USER_PROFILE.CHANGE_EMAIL_SUCCESS"),$confirm.success(text)):$confirm.notify("success")},onError=function(data){return form.setErrors(data),$confirm.notify("error",data._error_message)},$repo.save($scope.user).then(onSuccess,onError)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserProfile",["$tgConfirm","$tgAuth","$tgRepo","$translate",UserProfileDirective]),UserAvatarDirective=function($auth,$model,$rs,$confirm){var link;return link=function($scope,$el,$attrs){var onError,onSuccess,showSizeInfo;return showSizeInfo=function(){return $el.find(".size-info").removeClass("hidden")},onSuccess=function(response){var user;return user=$model.make_model("users",response.data),$auth.setUser(user),$scope.user=user,$el.find(".loading-overlay").removeClass("active"),$confirm.notify("success")},onError=function(response){return 413===response.status&&showSizeInfo(),$el.find(".loading-overlay").removeClass("active"),$confirm.notify("error",response.data._error_message)},$el.on("click",".js-change-avatar",function(){return $el.find("#avatar-field").click()}),$el.on("change","#avatar-field",function(event){return $scope.avatarAttachment?($el.find(".loading-overlay").addClass("active"),$rs.userSettings.changeAvatar($scope.avatarAttachment).then(onSuccess,onError)):void 0}),$el.on("click","a.js-use-gravatar",function(event){return $el.find(".loading-overlay").addClass("active"),$rs.userSettings.removeAvatar().then(onSuccess,onError)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserAvatar",["$tgAuth","$tgModel","$tgResources","$tgConfirm",UserAvatarDirective]),TaigaAvatarModelDirective=function($parse){var link;return link=function($scope,$el,$attrs){var model,modelSetter;return model=$parse($attrs.tgAvatarModel),modelSetter=model.assign,$el.bind("change",function(){return $scope.$apply(function(){return modelSetter($scope,$el[0].files[0])})})},{link:link}},module.directive("tgAvatarModel",["$parse",TaigaAvatarModelDirective])}.call(this),function(){var UserSettingsNavigationDirective,module;UserSettingsNavigationDirective=function(){var link;return link=function($scope,$el,$attrs){var section;return section=$attrs.tgUserSettingsNavigation,$el.find(".active").removeClass("active"),$el.find("#usersettingsmenu-"+section+" a").addClass("active"),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaUserSettings"),module.directive("tgUserSettingsNavigation",UserSettingsNavigationDirective)}.call(this),function(){var UserNotificationsController,UserNotificationsDirective,UserNotificationsListDirective,bindOnce,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindOnce=this.taiga.bindOnce,module=angular.module("taigaUserSettings"),UserNotificationsController=function(superClass){function UserNotificationsController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,auth){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.scope.sectionName="USER_SETTINGS.NOTIFICATIONS.SECTION_NAME", -this.scope.user=this.auth.getUser(),promise=this.loadInitialData(),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserNotificationsController,superClass),UserNotificationsController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth"],UserNotificationsController.prototype.loadInitialData=function(){return this.rs.notifyPolicies.list().then(function(_this){return function(notifyPolicies){return _this.scope.notifyPolicies=notifyPolicies,notifyPolicies}}(this))},UserNotificationsController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserNotificationsController",UserNotificationsController),UserNotificationsDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserNotifications",UserNotificationsDirective),UserNotificationsListDirective=function($repo,$confirm,$compile){var link,template;return template=_.template('<% _.each(notifyPolicies, function (notifyPolicy, index) { %>\n
\n
<%- notifyPolicy.project_name %>
\n
\n
\n checked="checked"<% } %>/>\n \n
\n
\n
\n
\n checked="checked"<% } %> />\n \n
\n
\n
\n
\n checked="checked"<% } %> />\n \n
\n
\n
\n<% }) %>'),link=function($scope,$el,$attrs){var render;return render=function(){var ctx,html;return $el.off(),ctx={notifyPolicies:$scope.notifyPolicies},html=template(ctx),$el.html($compile(html)($scope)),$el.on("change","input[type=radio]",function(event){var onError,onSuccess,policy,policyIndex,prev_level,target;return target=angular.element(event.currentTarget),policyIndex=target.parents(".policy-table-row").data("index"),policy=$scope.notifyPolicies[policyIndex],prev_level=policy.notify_level,policy.notify_level=parseInt(target.val(),10),onSuccess=function(){return $confirm.notify("success")},onError=function(){return $confirm.notify("error"),target.parents(".policy-table-row").find("input[value="+prev_level+"]").prop("checked",!0)},$repo.save(policy).then(onSuccess,onError)})},$scope.$on("$destroy",function(){return $el.off()}),bindOnce($scope,$attrs.ngModel,render)},{link:link}},module.directive("tgUserNotificationsList",["$tgRepo","$tgConfirm","$compile",UserNotificationsListDirective])}.call(this),function(){angular.module("taigaComponents",[])}.call(this),function(){var module;module=angular.module("taigaDiscover",[])}.call(this),function(){var module;module=angular.module("taigaExternalApps",[])}.call(this),function(){var module;module=angular.module("taigaHome",[])}.call(this),function(){angular.module("taigaNavigationBar",[])}.call(this),function(){var module;module=angular.module("taigaProfile",[])}.call(this),function(){angular.module("taigaProjects",[])}.call(this),function(){angular.module("taigaResources2",[])}.call(this),function(){angular.module("taigaUserTimeline",[])}.call(this),function(){var AttachmentLinkDirective;AttachmentLinkDirective=function($parse,lightboxFactory){var link;return link=function(scope,el,attrs){var attachment;return attachment=$parse(attrs.tgAttachmentLink)(scope),el.on("click",function(event){return taiga.isImage(attachment.getIn(["file","name"]))?(event.preventDefault(),scope.$apply(function(){return lightboxFactory.create("tg-lb-attachment-preview",{"class":"lightbox lightbox-block"},{file:attachment.get("file")})})):void 0}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentLinkDirective.$inject=["$parse","tgLightboxFactory"],angular.module("taigaComponents").directive("tgAttachmentLink",AttachmentLinkDirective)}.call(this),function(){var AttachmentGalleryDirective;AttachmentGalleryDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachment:"=",onDelete:"&",onUpdate:"&",type:"="},controller:"Attachment",controllerAs:"vm",templateUrl:"components/attachment/attachment-gallery.html",link:link}},AttachmentGalleryDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentGallery",AttachmentGalleryDirective)}.call(this),function(){var AttachmentController;AttachmentController=function(){function AttachmentController(attachmentsService,translate){this.attachmentsService=attachmentsService,this.translate=translate,this.form={},this.form.description=this.attachment.getIn(["file","description"]),this.form.is_deprecated=this.attachment.get(["file","is_deprecated"]),this.title=this.translate.instant("ATTACHMENT.TITLE",{fileName:this.attachment.get("name"),date:moment(this.attachment.get("created_date")).format(this.translate.instant("ATTACHMENT.DATE"))})}return AttachmentController.$inject=["tgAttachmentsService","$translate"],AttachmentController.prototype.editMode=function(mode){var attachment;return attachment=this.attachment.set("editable",mode),this.onUpdate({attachment:attachment})},AttachmentController.prototype["delete"]=function(){return this.onDelete({attachment:this.attachment})},AttachmentController.prototype.save=function(){var attachment;return attachment=this.attachment.set("loading",!0),this.onUpdate({attachment:attachment}),attachment=this.attachment.merge({editable:!1,loading:!1}),attachment=attachment.mergeIn(["file"],{description:this.form.description,is_deprecated:!!this.form.is_deprecated}),this.onUpdate({attachment:attachment})},AttachmentController}(),angular.module("taigaComponents").controller("Attachment",AttachmentController)}.call(this),function(){var AttachmentDirective;AttachmentDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachment:"=",onDelete:"&",onUpdate:"&",type:"="},controller:"Attachment",controllerAs:"vm",templateUrl:"components/attachment/attachment.html",link:link}},AttachmentDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachment",AttachmentDirective)}.call(this),function(){var AttachmentsDropDirective;AttachmentsDropDirective=function($parse){var link;return link=function(scope,el,attrs){var eventAttr;return eventAttr=$parse(attrs.tgAttachmentsDrop),el.on("dragover",function(e){return e.preventDefault(),!1}),el.on("drop",function(e){var dataTransfer;return e.stopPropagation(),e.preventDefault(),dataTransfer=e.dataTransfer||e.originalEvent&&e.originalEvent.dataTransfer,scope.$apply(function(){return eventAttr(scope,{files:dataTransfer.files})})}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentsDropDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgAttachmentsDrop",AttachmentsDropDirective)}.call(this),function(){var AttachmentsFullController,sizeFormat;sizeFormat=this.taiga.sizeFormat,AttachmentsFullController=function(){function AttachmentsFullController(translate,confirm,config,storage,attachmentsFullService){this.translate=translate,this.confirm=confirm,this.config=config,this.storage=storage,this.attachmentsFullService=attachmentsFullService,this.mode=this.storage.get("attachment-mode","list"),this.maxFileSize=this.config.get("maxUploadFileSize",null),this.maxFileSize&&(this.maxFileSize=sizeFormat(this.maxFileSize)),this.maxFileSizeMsg=this.maxFileSize?this.translate.instant("ATTACHMENT.MAX_UPLOAD_SIZE",{maxFileSize:this.maxFileSize}):"",taiga.defineImmutableProperty(this,"attachments",function(_this){return function(){return _this.attachmentsFullService.attachments}}(this)),taiga.defineImmutableProperty(this,"deprecatedsCount",function(_this){return function(){return _this.attachmentsFullService.deprecatedsCount}}(this)),taiga.defineImmutableProperty(this,"attachmentsVisible",function(_this){return function(){return _this.attachmentsFullService.attachmentsVisible}}(this)),taiga.defineImmutableProperty(this,"deprecatedsVisible",function(_this){return function(){return _this.attachmentsFullService.deprecatedsVisible}}(this))}return AttachmentsFullController.$inject=["$translate","$tgConfirm","$tgConfig","$tgStorage","tgAttachmentsFullService"],AttachmentsFullController.prototype.uploadingAttachments=function(){return this.attachmentsFullService.uploadingAttachments},AttachmentsFullController.prototype.addAttachment=function(file){var editable;return editable="list"===this.mode,this.attachmentsFullService.addAttachment(this.projectId,this.objId,this.type,file,editable)},AttachmentsFullController.prototype.setMode=function(mode){return this.mode=mode,this.storage.set("attachment-mode",mode)},AttachmentsFullController.prototype.toggleDeprecatedsVisible=function(){return this.attachmentsFullService.toggleDeprecatedsVisible()},AttachmentsFullController.prototype.addAttachments=function(files){return _.forEach(files,function(_this){return function(file){return _this.addAttachment(file)}}(this))},AttachmentsFullController.prototype.loadAttachments=function(){return this.attachmentsFullService.loadAttachments(this.type,this.objId,this.projectId)},AttachmentsFullController.prototype.deleteAttachment=function(toDeleteAttachment){var message,title;return title=this.translate.instant("ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT"),message=this.translate.instant("ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT",{fileName:toDeleteAttachment.getIn(["file","name"])}),this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onError=function(){return message=_this.translate.instant("ATTACHMENT.ERROR_DELETE_ATTACHMENT",{errorMessage:message}),_this.confirm.notify("error",null,message),askResponse.finish(!1)},onSuccess=function(){return askResponse.finish()},_this.attachmentsFullService.deleteAttachment(toDeleteAttachment,_this.type).then(onSuccess,onError)}}(this))},AttachmentsFullController.prototype.reorderAttachment=function(attachment,newIndex){return this.attachmentsFullService.reorderAttachment(this.type,attachment,newIndex)},AttachmentsFullController.prototype.updateAttachment=function(toUpdateAttachment){return this.attachmentsFullService.updateAttachment(toUpdateAttachment,this.type)},AttachmentsFullController}(),angular.module("taigaComponents").controller("AttachmentsFull",AttachmentsFullController)}.call(this),function(){var AttachmentsFullDirective,bindOnce;bindOnce=this.taiga.bindOnce,AttachmentsFullDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return bindOnce(scope,"vm.objId",function(value){return ctrl.loadAttachments()})},{scope:{},bindToController:{type:"@",objId:"=",projectId:"="},controller:"AttachmentsFull",controllerAs:"vm",templateUrl:"components/attachments-full/attachments-full.html",link:link}},AttachmentsFullDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentsFull",AttachmentsFullDirective)}.call(this),function(){var AttachmentsFullService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;AttachmentsFullService=function(superClass){function AttachmentsFullService(attachmentsService,rootScope){this.attachmentsService=attachmentsService,this.rootScope=rootScope,this._attachments=Immutable.List(),this._deprecatedsCount=0,this._attachmentsVisible=Immutable.List(),this._deprecatedsVisible=!1,this.uploadingAttachments=[],taiga.defineImmutableProperty(this,"attachments",function(_this){return function(){return _this._attachments}}(this)),taiga.defineImmutableProperty(this,"deprecatedsCount",function(_this){return function(){return _this._deprecatedsCount}}(this)),taiga.defineImmutableProperty(this,"attachmentsVisible",function(_this){return function(){return _this._attachmentsVisible}}(this)),taiga.defineImmutableProperty(this,"deprecatedsVisible",function(_this){return function(){return _this._deprecatedsVisible}}(this))}return extend(AttachmentsFullService,superClass),AttachmentsFullService.$inject=["tgAttachmentsService","$rootScope"],AttachmentsFullService.prototype.toggleDeprecatedsVisible=function(){return this._deprecatedsVisible=!this._deprecatedsVisible,this.regenerate()},AttachmentsFullService.prototype.regenerate=function(){return this._deprecatedsCount=this._attachments.count(function(it){return it.getIn(["file","is_deprecated"])}),this._deprecatedsVisible?this._attachmentsVisible=this._attachments:this._attachmentsVisible=this._attachments.filter(function(it){return!it.getIn(["file","is_deprecated"])})},AttachmentsFullService.prototype.addAttachment=function(projectId,objId,type,file,editable){return null==editable&&(editable=!0),new Promise(function(_this){return function(resolve,reject){var promise;return _this.attachmentsService.validate(file)?(_this.uploadingAttachments.push(file),promise=_this.attachmentsService.upload(file,objId,projectId,type),promise.then(function(file){var attachment;return _this.uploadingAttachments=_this.uploadingAttachments.filter(function(uploading){return uploading.name!==file.get("name")}),attachment=Immutable.Map(),attachment=attachment.merge({file:file,editable:editable,loading:!1}),_this._attachments=_this._attachments.push(attachment),_this.regenerate(),_this.rootScope.$broadcast("attachment:create"),resolve(attachment)})):reject(file)}}(this))},AttachmentsFullService.prototype.loadAttachments=function(type,objId,projectId){return this.attachmentsService.list(type,objId,projectId).then(function(_this){return function(files){return _this._attachments=files.map(function(file){var attachment;return attachment=Immutable.Map(),attachment.merge({loading:!1,editable:!1,file:file})}),_this.regenerate()}}(this))},AttachmentsFullService.prototype.deleteAttachment=function(toDeleteAttachment,type){var onSuccess;return onSuccess=function(_this){return function(){return _this._attachments=_this._attachments.filter(function(attachment){return attachment!==toDeleteAttachment}),_this.regenerate()}}(this),this.attachmentsService["delete"](type,toDeleteAttachment.getIn(["file","id"])).then(onSuccess)},AttachmentsFullService.prototype.reorderAttachment=function(type,attachment,newIndex){var attachments,oldIndex,promises;return oldIndex=this.attachments.findIndex(function(it){return it===attachment}),oldIndex!==newIndex?(attachments=this.attachments.remove(oldIndex),attachments=attachments.splice(newIndex,0,attachment),attachments=attachments.map(function(x,i){return x.setIn(["file","order"],i+1)}),promises=[],attachments.forEach(function(_this){return function(attachment){var patch;return patch={order:attachment.getIn(["file","order"])},promises.push(_this.attachmentsService.patch(attachment.getIn(["file","id"]),type,patch))}}(this)),Promise.all(promises).then(function(_this){return function(){return _this._attachments=attachments,_this.regenerate()}}(this))):void 0},AttachmentsFullService.prototype.updateAttachment=function(toUpdateAttachment,type){var index,oldAttachment,patch;return index=this._attachments.findIndex(function(attachment){return attachment.getIn(["file","id"])===toUpdateAttachment.getIn(["file","id"])}),oldAttachment=this._attachments.get(index),patch=taiga.patch(oldAttachment.get("file"),toUpdateAttachment.get("file")),toUpdateAttachment.get("loading")?(this._attachments=this._attachments.set(index,toUpdateAttachment),this.regenerate()):this.attachmentsService.patch(toUpdateAttachment.getIn(["file","id"]),type,patch).then(function(_this){return function(){return _this._attachments=_this._attachments.set(index,toUpdateAttachment),_this.regenerate()}}(this))},AttachmentsFullService}(taiga.Service),angular.module("taigaComponents").service("tgAttachmentsFullService",AttachmentsFullService)}.call(this),function(){var AttachmentsSimpleController;AttachmentsSimpleController=function(){function AttachmentsSimpleController(attachmentsService){this.attachmentsService=attachmentsService}return AttachmentsSimpleController.$inject=["tgAttachmentsService"],AttachmentsSimpleController.prototype.addAttachment=function(file){var attachment;return attachment=Immutable.fromJS({file:file,name:file.name,size:file.size}),this.attachmentsService.validate(file)&&(this.attachments=this.attachments.push(attachment),this.onAdd)?this.onAdd({attachment:attachment}):void 0},AttachmentsSimpleController.prototype.addAttachments=function(files){return _.forEach(files,this.addAttachment.bind(this))},AttachmentsSimpleController.prototype.deleteAttachment=function(toDeleteAttachment){return this.attachments=this.attachments.filter(function(attachment){return attachment!==toDeleteAttachment}),this.onDelete?this.onDelete({attachment:toDeleteAttachment}):void 0},AttachmentsSimpleController}(),angular.module("taigaComponents").controller("AttachmentsSimple",AttachmentsSimpleController)}.call(this),function(){var AttachmentsSimpleDirective;AttachmentsSimpleDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachments:"=",onAdd:"&",onDelete:"&"},controller:"AttachmentsSimple",controllerAs:"vm",templateUrl:"components/attachments-simple/attachments-simple.html",link:link}},AttachmentsSimpleDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentsSimple",AttachmentsSimpleDirective)}.call(this),function(){var AttachmentSortableDirective;AttachmentSortableDirective=function($parse){var link;return link=function(scope,el,attrs){var callback;return callback=$parse(attrs.tgAttachmentsSortable),el.sortable({items:"div[tg-bind-scope]",handle:"a.settings.icon.icon-drag-v",containment:".attachments",dropOnEmpty:!0,helper:"clone",scroll:!1,tolerance:"pointer",placeholder:"sortable-placeholder single-attachment"}),el.on("sortstop",function(event,ui){var attachment,newIndex;return attachment=ui.item.scope().attachment,newIndex=ui.item.index(),scope.$apply(function(){return callback(scope,{attachment:attachment,index:newIndex})})}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentSortableDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgAttachmentsSortable",AttachmentSortableDirective)}.call(this),function(){var AutoSelectDirective;AutoSelectDirective=function($timeout){return{link:function(scope,elm){return $timeout(function(){return elm[0].select()})}}},AutoSelectDirective.$inject=["$timeout"],angular.module("taigaComponents").directive("tgAutoSelect",AutoSelectDirective)}.call(this),function(){var FileChangeDirective;FileChangeDirective=function($parse){var link;return link=function(scope,el,attrs,ctrl){var eventAttr;return eventAttr=$parse(attrs.tgFileChange),el.on("change",function(event){return scope.$apply(function(){return eventAttr(scope,{files:event.currentTarget.files})})}),scope.$on("$destroy",function(){return el.off()})},{require:"ngModel",restrict:"A",link:link}},FileChangeDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgFileChange",FileChangeDirective)}.call(this),function(){var JoyRideDirective,taiga;taiga=this.taiga,JoyRideDirective=function($rootScope,currentUserService,joyRideService,$location,$translate){var link;return link=function(scope,el,attrs,ctrl){var initJoyrRide,intro,unsuscribe;return unsuscribe=null,intro=introJs(),intro.oncomplete(function(){return $("html,body").scrollTop(0)}),intro.onexit(function(){return currentUserService.disableJoyRide()}),initJoyrRide=function(next,config){return config[next.joyride]?(intro.setOptions({exitOnEsc:!1,exitOnOverlayClick:!1,showStepNumbers:!1,nextLabel:$translate.instant("JOYRIDE.NAV.NEXT")+" →",prevLabel:"← "+$translate.instant("JOYRIDE.NAV.BACK"),skipLabel:$translate.instant("JOYRIDE.NAV.SKIP"),doneLabel:$translate.instant("JOYRIDE.NAV.DONE"),disableInteraction:!0}),intro.setOption("steps",joyRideService.get(next.joyride)),intro.start()):void 0},$rootScope.$on("$routeChangeSuccess",function(event,next){return next.joyride&¤tUserService.isAuthenticated()?(intro.oncomplete(function(){return currentUserService.disableJoyRide(next.joyride)}),next.loader?unsuscribe=$rootScope.$on("loader:end",function(){return currentUserService.loadJoyRideConfig().then(function(config){return initJoyrRide(next,config)}),unsuscribe()}):currentUserService.loadJoyRideConfig().then(function(config){return initJoyrRide(next,config)})):(intro.exit(),void(unsuscribe&&unsuscribe()))})},{scope:{},link:link}},JoyRideDirective.$inject=["$rootScope","tgCurrentUserService","tgJoyRideService","$location","$translate"],angular.module("taigaComponents").directive("tgJoyRide",JoyRideDirective)}.call(this),function(){var JoyRideService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;JoyRideService=function(superClass){function JoyRideService(translate,checkPermissionsService){this.translate=translate,this.checkPermissionsService=checkPermissionsService}return extend(JoyRideService,superClass),JoyRideService.$inject=["$translate","tgCheckPermissionsService"],JoyRideService.prototype.getConfig=function(){return{dashboard:function(_this){return function(){var steps;return steps=[{element:".project-list > section:not(.ng-hide)",position:"left",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP1.TITLE"),text:_this.translate.instant("JOYRIDE.DASHBOARD.STEP1.TEXT")}},{element:".working-on-container",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.DASHBOARD.STEP2.TEXT")}},{element:".watching-container",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TITLE"),text:[_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TEXT1"),_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TEXT2")]}}],$(".project-list .create-project-button").is(":hidden")||steps.push({element:".project-list .create-project-button",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TITLE"),text:[_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TEXT1"),_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TEXT2")]}}),steps}}(this),backlog:function(_this){return function(){var steps;return steps=[{element:".summary",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TITLE"),text:[_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TEXT1"),_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TEXT2")]}},{element:".backlog-table-empty",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP2.TEXT")}},{element:".sprints",position:"left",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP3.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP3.TEXT")}}],_this.checkPermissionsService.check("add_us")&&steps.push({element:".new-us",position:"rigth",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP4.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP4.TEXT")}}),steps}}(this),kanban:function(_this){return function(){var steps;return steps=[{element:".kanban-table-inner",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP1.TITLE"),text:_this.translate.instant("JOYRIDE.KANBAN.STEP1.TEXT")}},{element:".card-placeholder",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.KANBAN.STEP2.TEXT")}}],_this.checkPermissionsService.check("add_us")&&steps.push({element:".icon-plus",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP3.TITLE"),text:[_this.translate.instant("JOYRIDE.KANBAN.STEP3.TEXT1"),_this.translate.instant("JOYRIDE.KANBAN.STEP3.TEXT2")]}}),steps}}(this)}},JoyRideService.prototype.get=function(name){var joyRide,joyRides;return joyRides=this.getConfig(),joyRide=joyRides[name].call(this),_.map(joyRide,function(item){var html;return html="",item.joyride.title&&(html+="

"+item.joyride.title+"

"),_.isArray(item.joyride.text)?_.forEach(item.joyride.text,function(text){return html+="

"+text+"

"}):html+="

"+item.joyride.text+"

",item.intro=html,item})},JoyRideService}(taiga.Service),angular.module("taigaComponents").service("tgJoyRideService",JoyRideService)}.call(this),function(){var LiveAnnouncementDirective;LiveAnnouncementDirective=function(liveAnnouncementService){var link;return link=function(scope,el,attrs){},{restrict:"AE",scope:{},controllerAs:"vm",controller:function(){return this.close=function(){return liveAnnouncementService.open=!1},Object.defineProperties(this,{open:{get:function(){return liveAnnouncementService.open}},title:{get:function(){return liveAnnouncementService.title}},desc:{get:function(){return liveAnnouncementService.desc}}})},link:link,templateUrl:"components/live-announcement/live-announcement.html"}},LiveAnnouncementDirective.$inject=["tgLiveAnnouncementService"],angular.module("taigaComponents").directive("tgLiveAnnouncement",LiveAnnouncementDirective)}.call(this),function(){var LiveAnnouncementService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;LiveAnnouncementService=function(superClass){function LiveAnnouncementService(){this.open=!1,this.title="",this.desc=""}return extend(LiveAnnouncementService,superClass),LiveAnnouncementService.prototype.show=function(title,desc){return this.open=!0,this.title=title,this.desc=desc},LiveAnnouncementService}(taiga.Service),angular.module("taigaComponents").service("tgLiveAnnouncementService",LiveAnnouncementService)}.call(this),function(){var COLORS,IMAGES,LOGOS,ProjectLogoSrcDirective,modulo=function(a,b){return(+a%(b=+b)+b)%b};IMAGES=["/"+window._version+"/images/project-logos/project-logo-01.png","/"+window._version+"/images/project-logos/project-logo-02.png","/"+window._version+"/images/project-logos/project-logo-03.png","/"+window._version+"/images/project-logos/project-logo-04.png","/"+window._version+"/images/project-logos/project-logo-05.png"],COLORS=["rgba( 153, 214, 220, 1 )","rgba( 213, 156, 156, 1 )","rgba( 214, 161, 212, 1 )","rgba( 164, 162, 219, 1 )","rgba( 152, 224, 168, 1 )"],LOGOS=_.cartesianProduct(IMAGES,COLORS),ProjectLogoSrcDirective=function($parse){var _getDefaultProjectLogo,link;return _getDefaultProjectLogo=function(project){var idx,key,logo;return key=project.get("slug")+"-"+project.get("id"),idx=modulo(murmurhash3_32_gc(key,42),LOGOS.length),logo=LOGOS[idx],{src:logo[0],color:logo[1]}},link=function(scope,el,attrs){return scope.$watch("project",function(project){var logo,projectLogo;return(project=Immutable.fromJS(project))?(projectLogo=project.get("logo_small_url"),projectLogo?(el.attr("src",projectLogo),el.css("background","")):(logo=_getDefaultProjectLogo(project),el.attr("src",logo.src),el.css("background",logo.color))):void 0}),scope.$on("$destroy",function(){return el.off()})},{link:link,scope:{project:"=tgProjectLogoSrc"}}},ProjectLogoSrcDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgProjectLogoSrc",ProjectLogoSrcDirective)}.call(this),function(){var ProjectMenuController;ProjectMenuController=function(){function ProjectMenuController(projectService,lightboxFactory){this.projectService=projectService,this.lightboxFactory=lightboxFactory,this.project=null,this.menu=Immutable.Map()}return ProjectMenuController.$inject=["tgProjectService","tgLightboxFactory"],ProjectMenuController.prototype.show=function(){return this.project=this.projectService.project,this.active=this._getActiveSection(),this._setVideoConference(),this._setMenuPermissions()},ProjectMenuController.prototype.hide=function(){return this.project=null,this.menu={}},ProjectMenuController.prototype.search=function(){return this.lightboxFactory.create("tg-search-box",{"class":"lightbox lightbox-search"})},ProjectMenuController.prototype._setVideoConference=function(){var videoconferenceUrl;return videoconferenceUrl=this._videoConferenceUrl(),videoconferenceUrl?this.project=this.project.set("videoconferenceUrl",videoconferenceUrl):void 0},ProjectMenuController.prototype._setMenuPermissions=function(){return this.menu=Immutable.Map({backlog:!1,kanban:!1,issues:!1,wiki:!1}),this.project.get("is_backlog_activated")&&-1!==this.project.get("my_permissions").indexOf("view_us")&&(this.menu=this.menu.set("backlog",!0)),this.project.get("is_kanban_activated")&&-1!==this.project.get("my_permissions").indexOf("view_us")&&(this.menu=this.menu.set("kanban",!0)),this.project.get("is_issues_activated")&&-1!==this.project.get("my_permissions").indexOf("view_issues")&&(this.menu=this.menu.set("issues",!0)),this.project.get("is_wiki_activated")&&-1!==this.project.get("my_permissions").indexOf("view_wiki_pages")?this.menu=this.menu.set("wiki",!0):void 0},ProjectMenuController.prototype._getActiveSection=function(){var indexBacklog,indexKanban,oldSectionName,sectionName,sectionsBreadcrumb;return sectionName=this.projectService.section,sectionsBreadcrumb=this.projectService.sectionsBreadcrumb,indexBacklog=sectionsBreadcrumb.lastIndexOf("backlog"),indexKanban=sectionsBreadcrumb.lastIndexOf("kanban"),(-1!==indexBacklog||-1!==indexKanban)&&(oldSectionName=-1===indexKanban||indexBacklog>indexKanban?"backlog":"kanban"),"backlog-kanban"===sectionName&&("backlog"===oldSectionName||"kanban"===oldSectionName?sectionName=oldSectionName:this.project.get("is_backlog_activated")&&!this.project.get("is_kanban_activated")?sectionName="backlog":!this.project.get("is_backlog_activated")&&this.project.get("is_kanban_activated")&&(sectionName="kanban")),sectionName},ProjectMenuController.prototype._videoConferenceUrl=function(){var baseUrl,url;if("appear-in"===this.project.get("videoconferences"))baseUrl="https://appear.in/";else{if("talky"!==this.project.get("videoconferences"))return"jitsi"===this.project.get("videoconferences")?(baseUrl="https://meet.jit.si/",url=this.project.get("slug")+"-"+taiga.slugify(this.project.get("videoconferences_extra_data")),url=url.replace(/-/g,""),baseUrl+url):"custom"===this.project.get("videoconferences")?this.project.get("videoconferences_extra_data"):"";baseUrl="https://talky.io/"}return url=this.project.get("videoconferences_extra_data")?this.project.get("slug")+"-"+this.project.get("videoconferences_extra_data"):this.project.get("slug"),baseUrl+url},ProjectMenuController}(),angular.module("taigaComponents").controller("ProjectMenu",ProjectMenuController)}.call(this),function(){var ProjectMenuDirective,taiga;taiga=this.taiga,ProjectMenuDirective=function(projectService,lightboxFactory){ -var link;return link=function(scope,el,attrs,ctrl){var projectChange;return projectChange=function(){return projectService.project?ctrl.show():ctrl.hide()},scope.$watch(function(){return projectService.project},projectChange),scope.vm.fixed=!1,$(window).on("scroll",function(){var position;return position=$(window).scrollTop(),position>100&&scope.vm.fixed===!1?(scope.vm.fixed=!0,scope.$digest()):100>position&&scope.vm.fixed===!0?(scope.vm.fixed=!1,scope.$digest()):void 0})},{scope:{},controller:"ProjectMenu",controllerAs:"vm",templateUrl:"components/project-menu/project-menu.html",link:link}},ProjectMenuDirective.$inject=["tgProjectService","tgLightboxFactory"],angular.module("taigaComponents").directive("tgProjectMenu",ProjectMenuDirective)}.call(this),function(){var TermsOfServiceAndPrivacyPolicyNoticeDirective;TermsOfServiceAndPrivacyPolicyNoticeDirective=function($config){var link;return link=function(scope,el,attrs){return scope.privacyPolicyUrl=$config.get("privacyPolicyUrl"),scope.termsOfServiceUrl=$config.get("termsOfServiceUrl")},{restrict:"AE",scope:{},link:link,templateUrl:"components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html"}},angular.module("taigaComponents").directive("tgTermsOfServiceAndPrivacyPolicyNotice",["$tgConfig",TermsOfServiceAndPrivacyPolicyNoticeDirective])}.call(this),function(){var VoteButtonController;VoteButtonController=function(){function VoteButtonController(currentUserService){this.currentUserService=currentUserService,this.user=this.currentUserService.getUser(),this.isMouseOver=!1,this.loading=!1}return VoteButtonController.$inject=["tgCurrentUserService"],VoteButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},VoteButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},VoteButtonController.prototype.toggleVote=function(){var promise;return this.loading=!0,promise=this.item.is_voter?this._downvote():this._upvote(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},VoteButtonController.prototype._upvote=function(){return this.onUpvote().then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))},VoteButtonController.prototype._downvote=function(){return this.onDownvote()},VoteButtonController}(),angular.module("taigaComponents").controller("VoteButton",VoteButtonController)}.call(this),function(){var VoteButtonDirective;VoteButtonDirective=function(){return{scope:{},controller:"VoteButton",bindToController:{item:"=",onUpvote:"=",onDownvote:"="},controllerAs:"vm",templateUrl:"components/vote-button/vote-button.html"}},angular.module("taigaComponents").directive("tgVoteButton",VoteButtonDirective)}.call(this),function(){var WatchButtonController;WatchButtonController=function(){function WatchButtonController(currentUserService,rootScope){this.currentUserService=currentUserService,this.rootScope=rootScope,this.user=this.currentUserService.getUser(),this.isMouseOver=!1,this.loading=!1}return WatchButtonController.$inject=["tgCurrentUserService","$rootScope"],WatchButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},WatchButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},WatchButtonController.prototype.openWatchers=function(){return this.rootScope.$broadcast("watcher:add",this.item)},WatchButtonController.prototype.getPerms=function(){var name,perms;return this.item?(name=this.item._name,perms={userstories:"modify_us",issues:"modify_issue",tasks:"modify_task"},perms[name]):""},WatchButtonController.prototype.toggleWatch=function(){var promise;return this.loading=!0,promise=this.item.is_watcher?this._unwatch():this._watch(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},WatchButtonController.prototype._watch=function(){return this.onWatch().then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))},WatchButtonController.prototype._unwatch=function(){return this.onUnwatch()},WatchButtonController}(),angular.module("taigaComponents").controller("WatchButton",WatchButtonController)}.call(this),function(){var WatchButtonDirective;WatchButtonDirective=function(){return{scope:{},controller:"WatchButton",bindToController:{item:"=",onWatch:"=",onUnwatch:"="},controllerAs:"vm",templateUrl:function(item,attributes){return"components/watch-button/watch-button-"+attributes.environment+".html"}}},angular.module("taigaComponents").directive("tgWatchButton",WatchButtonDirective)}.call(this),function(){var DiscoverHomeOrderByController;DiscoverHomeOrderByController=function(){function DiscoverHomeOrderByController(translate){this.translate=translate,this.is_open=!1,this.texts={week:this.translate.instant("DISCOVER.FILTERS.WEEK"),month:this.translate.instant("DISCOVER.FILTERS.MONTH"),year:this.translate.instant("DISCOVER.FILTERS.YEAR"),all:this.translate.instant("DISCOVER.FILTERS.ALL_TIME")}}return DiscoverHomeOrderByController.$inject=["$translate"],DiscoverHomeOrderByController.prototype.currentText=function(){return this.texts[this.currentOrderBy]},DiscoverHomeOrderByController.prototype.open=function(){return this.is_open=!0},DiscoverHomeOrderByController.prototype.close=function(){return this.is_open=!1},DiscoverHomeOrderByController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.is_open=!1,this.onChange({orderBy:this.currentOrderBy})},DiscoverHomeOrderByController}(),angular.module("taigaDiscover").controller("DiscoverHomeOrderBy",DiscoverHomeOrderByController)}.call(this),function(){var DiscoverHomeOrderByDirective;DiscoverHomeOrderByDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"DiscoverHomeOrderBy",controllerAs:"vm",bindToController:!0,templateUrl:"discover/components/discover-home-order-by/discover-home-order-by.html",scope:{currentOrderBy:"=orderBy",onChange:"&"},link:link}},DiscoverHomeOrderByDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverHomeOrderBy",DiscoverHomeOrderByDirective)}.call(this),function(){var DiscoverSearchBarController;DiscoverSearchBarController=function(){function DiscoverSearchBarController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this.discoverProjectsService.projectsCount}}(this)),this.discoverProjectsService.fetchStats()}return DiscoverSearchBarController.$inject=["tgDiscoverProjectsService"],DiscoverSearchBarController.prototype.selectFilter=function(filter){return this.onChange({filter:filter,q:this.q})},DiscoverSearchBarController.prototype.submitFilter=function(){return this.onChange({filter:this.filter,q:this.q})},DiscoverSearchBarController}(),angular.module("taigaDiscover").controller("DiscoverSearchBar",DiscoverSearchBarController)}.call(this),function(){var DiscoverSearchBarDirective;DiscoverSearchBarDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{controller:"DiscoverSearchBar",controllerAs:"vm",templateUrl:"discover/components/discover-search-bar/discover-search-bar.html",bindToController:!0,scope:{q:"=",filter:"=",onChange:"&"},link:link}},DiscoverSearchBarDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearchBar",DiscoverSearchBarDirective)}.call(this),function(){var DiscoverSearchListHeaderController;DiscoverSearchListHeaderController=function(){function DiscoverSearchListHeaderController(){this.like_is_open=0===this.orderBy.indexOf("-total_fans"),this.activity_is_open=0===this.orderBy.indexOf("-total_activity")}return DiscoverSearchListHeaderController.$inject=[],DiscoverSearchListHeaderController.prototype.openLike=function(){return this.like_is_open=!0,this.activity_is_open=!1,this.setOrderBy("-total_fans_last_week")},DiscoverSearchListHeaderController.prototype.openActivity=function(){return this.activity_is_open=!0,this.like_is_open=!1,this.setOrderBy("-total_activity_last_week")},DiscoverSearchListHeaderController.prototype.setOrderBy=function(type){return null==type&&(type=""),type||(this.like_is_open=!1,this.activity_is_open=!1),this.onChange({orderBy:type})},DiscoverSearchListHeaderController}(),angular.module("taigaDiscover").controller("DiscoverSearchListHeader",DiscoverSearchListHeaderController)}.call(this),function(){var DiscoverSearchListHeaderDirective;DiscoverSearchListHeaderDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"DiscoverSearchListHeader",controllerAs:"vm",bindToController:!0,templateUrl:"discover/components/discover-search-list-header/discover-search-list-header.html",scope:{onChange:"&",orderBy:"="},link:link}},DiscoverSearchListHeaderDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearchListHeader",DiscoverSearchListHeaderDirective)}.call(this),function(){var FeaturedProjectsController;FeaturedProjectsController=function(){function FeaturedProjectsController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"featured",function(_this){return function(){return _this.discoverProjectsService.featured}}(this)),this.discoverProjectsService.fetchFeatured()}return FeaturedProjectsController.$inject=["tgDiscoverProjectsService"],FeaturedProjectsController}(),angular.module("taigaDiscover").controller("FeaturedProjects",FeaturedProjectsController)}.call(this),function(){var FeaturedProjectsDirective;FeaturedProjectsDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"FeaturedProjects",controllerAs:"vm",templateUrl:"discover/components/featured-projects/featured-projects.html",scope:{},link:link}},FeaturedProjectsDirective.$inject=[],angular.module("taigaDiscover").directive("tgFeaturedProjects",FeaturedProjectsDirective)}.call(this),function(){var HighlightedDirective;HighlightedDirective=function(){return{templateUrl:"discover/components/highlighted/highlighted.html",scope:{loading:"=",highlighted:"=",orderBy:"="}}},HighlightedDirective.$inject=[],angular.module("taigaDiscover").directive("tgHighlighted",HighlightedDirective)}.call(this),function(){var MostActiveController;MostActiveController=function(){function MostActiveController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"highlighted",function(_this){return function(){return _this.discoverProjectsService.mostActive}}(this)),this.currentOrderBy="week",this.order_by=this.getOrderBy()}return MostActiveController.$inject=["tgDiscoverProjectsService"],MostActiveController.prototype.fetch=function(){return this.loading=!0,this.order_by=this.getOrderBy(),this.discoverProjectsService.fetchMostActive({order_by:this.order_by}).then(function(_this){return function(){return _this.loading=!1}}(this))},MostActiveController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.fetch()},MostActiveController.prototype.getOrderBy=function(type){return"all"===this.currentOrderBy?"-total_activity":"-total_activity_last_"+this.currentOrderBy},MostActiveController}(),angular.module("taigaDiscover").controller("MostActive",MostActiveController)}.call(this),function(){var MostActiveDirective;MostActiveDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return ctrl.fetch()},{controller:"MostActive",controllerAs:"vm",templateUrl:"discover/components/most-active/most-active.html",scope:{},link:link}},MostActiveDirective.$inject=[],angular.module("taigaDiscover").directive("tgMostActive",MostActiveDirective)}.call(this),function(){var MostLikedController;MostLikedController=function(){function MostLikedController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"highlighted",function(_this){return function(){return _this.discoverProjectsService.mostLiked}}(this)),this.currentOrderBy="week",this.order_by=this.getOrderBy()}return MostLikedController.$inject=["tgDiscoverProjectsService"],MostLikedController.prototype.fetch=function(){return this.loading=!0,this.order_by=this.getOrderBy(),this.discoverProjectsService.fetchMostLiked({order_by:this.order_by}).then(function(_this){return function(){return _this.loading=!1}}(this))},MostLikedController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.fetch()},MostLikedController.prototype.getOrderBy=function(){return"all"===this.currentOrderBy?"-total_fans":"-total_fans_last_"+this.currentOrderBy},MostLikedController}(),angular.module("taigaDiscover").controller("MostLiked",MostLikedController)}.call(this),function(){var MostLikedDirective;MostLikedDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return ctrl.fetch()},{controller:"MostLiked",controllerAs:"vm",templateUrl:"discover/components/most-liked/most-liked.html",scope:{},link:link}},MostLikedDirective.$inject=[],angular.module("taigaDiscover").directive("tgMostLiked",MostLikedDirective)}.call(this),function(){var DiscoverHomeController;DiscoverHomeController=function(){function DiscoverHomeController(location,navUrls){this.location=location,this.navUrls=navUrls}return DiscoverHomeController.$inject=["$tgLocation","$tgNavUrls"],DiscoverHomeController.prototype.onSubmit=function(q){var url;return url=this.navUrls.resolve("discover-search"),this.location.search("text",q).path(url)},DiscoverHomeController}(),angular.module("taigaDiscover").controller("DiscoverHome",DiscoverHomeController)}.call(this),function(){var DiscoverSearchController;DiscoverSearchController=function(){function DiscoverSearchController(routeParams,discoverProjectsService,route){this.routeParams=routeParams,this.discoverProjectsService=discoverProjectsService,this.route=route,this.page=1,taiga.defineImmutableProperty(this,"searchResult",function(_this){return function(){return _this.discoverProjectsService.searchResult}}(this)),taiga.defineImmutableProperty(this,"nextSearchPage",function(_this){return function(){return _this.discoverProjectsService.nextSearchPage}}(this)),this.q=this.routeParams.text,this.filter=this.routeParams.filter||"all",this.orderBy=this.routeParams.order_by||"",this.loadingGlobal=!1,this.loadingList=!1,this.loadingPagination=!1}return DiscoverSearchController.$inject=["$routeParams","tgDiscoverProjectsService","$route"],DiscoverSearchController.prototype.fetch=function(){return this.page=1,this.discoverProjectsService.resetSearchList(),this.search()},DiscoverSearchController.prototype.fetchByGlobalSearch=function(){return this.loadingGlobal?void 0:(this.loadingGlobal=!0,this.fetch().then(function(_this){return function(){return _this.loadingGlobal=!1}}(this)))},DiscoverSearchController.prototype.fetchByOrderBy=function(){return this.loadingList?void 0:(this.loadingList=!0,this.fetch().then(function(_this){return function(){return _this.loadingList=!1}}(this)))},DiscoverSearchController.prototype.showMore=function(){return this.loadingPagination?void 0:(this.loadingPagination=!0,this.page++,this.search().then(function(_this){return function(){return _this.loadingPagination=!1}}(this)))},DiscoverSearchController.prototype.search=function(){var filter,params;return filter=this.getFilter(),params={page:this.page,q:this.q,order_by:this.orderBy},_.assign(params,filter),this.discoverProjectsService.fetchSearch(params)},DiscoverSearchController.prototype.getFilter=function(){return"people"===this.filter?{is_looking_for_people:!0}:"scrum"===this.filter?{is_backlog_activated:!0}:"kanban"===this.filter?{is_kanban_activated:!0}:{}},DiscoverSearchController.prototype.onChangeFilter=function(filter,q){return this.filter=filter,this.q=q,this.route.updateParams({filter:this.filter,text:this.q}),this.fetchByGlobalSearch()},DiscoverSearchController.prototype.onChangeOrder=function(orderBy){return this.orderBy=orderBy,this.route.updateParams({order_by:orderBy}),this.fetchByOrderBy()},DiscoverSearchController}(),angular.module("taigaDiscover").controller("DiscoverSearch",DiscoverSearchController)}.call(this),function(){var DiscoverSearchDirective;DiscoverSearchDirective=function(){var link;return link=function(scope,element,attrs,ctrl){return ctrl.fetch()},{controller:"DiscoverSearch",controllerAs:"vm",link:link}},DiscoverSearchDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearch",DiscoverSearchDirective)}.call(this),function(){var DiscoverProjectsService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,DiscoverProjectsService=function(superClass){function DiscoverProjectsService(rs,projectsService){this.rs=rs,this.projectsService=projectsService,this._mostLiked=Immutable.List(),this._mostActive=Immutable.List(),this._featured=Immutable.List(),this._searchResult=Immutable.List(),this._projectsCount=0,this.decorate=this.projectsService._decorate.bind(this.projectsService),taiga.defineImmutableProperty(this,"mostLiked",function(_this){return function(){return _this._mostLiked}}(this)),taiga.defineImmutableProperty(this,"mostActive",function(_this){return function(){return _this._mostActive}}(this)),taiga.defineImmutableProperty(this,"featured",function(_this){return function(){return _this._featured}}(this)),taiga.defineImmutableProperty(this,"searchResult",function(_this){return function(){return _this._searchResult}}(this)),taiga.defineImmutableProperty(this,"nextSearchPage",function(_this){return function(){return _this._nextSearchPage}}(this)),taiga.defineImmutableProperty(this,"projectsCount",function(_this){return function(){return _this._projectsCount}}(this))}return extend(DiscoverProjectsService,superClass),DiscoverProjectsService.$inject=["tgResources","tgProjectsService"],DiscoverProjectsService.prototype.fetchMostLiked=function(params){return this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,5),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._mostLiked=projects}}(this))},DiscoverProjectsService.prototype.fetchMostActive=function(params){return this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,5),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._mostActive=projects}}(this))},DiscoverProjectsService.prototype.fetchFeatured=function(){var params;return params={is_featured:!0},this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,4),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._featured=projects}}(this))},DiscoverProjectsService.prototype.resetSearchList=function(){return this._searchResult=Immutable.List()},DiscoverProjectsService.prototype.fetchStats=function(){return this.rs.stats.discover().then(function(_this){return function(discover){return _this._projectsCount=discover.getIn(["projects","total"])}}(this))},DiscoverProjectsService.prototype.fetchSearch=function(params){return this.rs.projects.getProjects(params).then(function(_this){return function(result){var projects;return _this._nextSearchPage=!!result.headers("X-Pagination-Next"),projects=Immutable.fromJS(result.data),projects=projects.map(_this.decorate),_this._searchResult=_this._searchResult.concat(projects)}}(this))},DiscoverProjectsService}(taiga.Service),angular.module("taigaDiscover").service("tgDiscoverProjectsService",DiscoverProjectsService)}.call(this),function(){var ExternalAppController,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ExternalAppController=function(superClass){function ExternalAppController(routeParams,externalAppsService,window,currentUserService,location,navUrls,xhrError,loader){var loginUrl,nextUrl;this.routeParams=routeParams,this.externalAppsService=externalAppsService,this.window=window,this.currentUserService=currentUserService,this.location=location,this.navUrls=navUrls,this.xhrError=xhrError,this.loader=loader,this.createApplicationToken=bind(this.createApplicationToken,this),this._getApplicationToken=bind(this._getApplicationToken,this),this._redirect=bind(this._redirect,this),this.loader.start(!1),this._applicationId=this.routeParams.application,this._state=this.routeParams.state,this._getApplicationToken(),this._user=this.currentUserService.getUser(),this._application=null,nextUrl=encodeURIComponent(this.location.url()),loginUrl=this.navUrls.resolve("login"),this.loginWithAnotherUserUrl=loginUrl+"?next="+nextUrl,taiga.defineImmutableProperty(this,"user",function(_this){return function(){return _this._user}}(this)),taiga.defineImmutableProperty(this,"application",function(_this){return function(){return _this._application}}(this))}return extend(ExternalAppController,superClass),ExternalAppController.$inject=["$routeParams","tgExternalAppsService","$window","tgCurrentUserService","$location","$tgNavUrls","tgXhrErrorService","tgLoader"],ExternalAppController.prototype._redirect=function(applicationToken){var nextUrl;return nextUrl=applicationToken.get("next_url"),this.window.open(nextUrl,"_self")},ExternalAppController.prototype._getApplicationToken=function(){return this.externalAppsService.getApplicationToken(this._applicationId,this._state).then(function(_this){return function(data){return _this._application=data.get("application"),data.get("auth_code")?_this._redirect(data):_this.loader.pageLoaded()}}(this))["catch"](function(_this){return function(xhr){return _this.loader.pageLoaded(),_this.xhrError.response(xhr)}}(this))},ExternalAppController.prototype.cancel=function(){return this.window.history.back()},ExternalAppController.prototype.createApplicationToken=function(){return this.externalAppsService.authorizeApplicationToken(this._applicationId,this._state).then(function(_this){return function(data){return _this._redirect(data)}}(this))["catch"](function(_this){return function(xhr){return _this.xhrError.response(xhr)}}(this))},ExternalAppController}(taiga.Controller),angular.module("taigaExternalApps").controller("ExternalApp",ExternalAppController)}.call(this),function(){var ExternalAppsService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;ExternalAppsService=function(superClass){function ExternalAppsService(rs){this.rs=rs}return extend(ExternalAppsService,superClass),ExternalAppsService.$inject=["tgResources"],ExternalAppsService.prototype.getApplicationToken=function(applicationId,state){return this.rs.externalapps.getApplicationToken(applicationId,state)},ExternalAppsService.prototype.authorizeApplicationToken=function(applicationId,state){return this.rs.externalapps.authorizeApplicationToken(applicationId,state)},ExternalAppsService}(taiga.Service),angular.module("taigaExternalApps").service("tgExternalAppsService",ExternalAppsService)}.call(this),function(){var FeedbackService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;FeedbackService=function(superClass){function FeedbackService(lightboxFactory){this.lightboxFactory=lightboxFactory}return extend(FeedbackService,superClass),FeedbackService.$inject=["tgLightboxFactory"],FeedbackService.prototype.sendFeedback=function(){return this.lightboxFactory.create("tg-lb-feedback",{"class":"lightbox lightbox-feedback lightbox-generic-form"})},FeedbackService}(taiga.Service),angular.module("taigaFeedback").service("tgFeedbackService",FeedbackService)}.call(this),function(){var DutyDirective;DutyDirective=function(navurls,$translate){var link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.vm.duty=scope.duty,scope.vm.getDutyType=function(){if(scope.vm.duty){if("userstories"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.USER_STORY");if("tasks"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.TASK");if("issues"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.ISSUE")}}},{templateUrl:"home/duties/duty.html",scope:{duty:"=tgDuty"},link:link}},DutyDirective.$inject=["$tgNavUrls","$translate"],angular.module("taigaHome").directive("tgDuty",DutyDirective)}.call(this),function(){var HomeController;HomeController=function(){function HomeController(currentUserService,location,navUrls){this.currentUserService=currentUserService,this.location=location,this.navUrls=navUrls,this.currentUserService.getUser()||this.location.path(this.navUrls.resolve("discover"))}return HomeController.$inject=["tgCurrentUserService","$location","$tgNavUrls"],HomeController}(),angular.module("taigaHome").controller("Home",HomeController)}.call(this),function(){var HomeService,groupBy,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;groupBy=this.taiga.groupBy,HomeService=function(superClass){function HomeService(navurls,rs,projectsService){this.navurls=navurls,this.rs=rs,this.projectsService=projectsService}return extend(HomeService,superClass),HomeService.$inject=["$tgNavUrls","tgResources","tgProjectsService"],HomeService.prototype._attachProjectInfoToWorkInProgress=function(workInProgress,projectsById){var _attachProjectInfoToDuty,_duties,assignedTo,watching;return _attachProjectInfoToDuty=function(_this){return function(duty,objType){var ctx,project,url;return project=projectsById.get(String(duty.get("project"))),ctx={project:project.get("slug"),ref:duty.get("ref")},url=_this.navurls.resolve("project-"+objType+"-detail",ctx),duty=duty.set("url",url),duty=duty.set("projectName",project.get("name")),duty=duty.set("_name",objType)}}(this),assignedTo=workInProgress.get("assignedTo"),assignedTo.get("userStories")&&(_duties=assignedTo.get("userStories").map(function(duty){return _attachProjectInfoToDuty(duty,"userstories")}),assignedTo=assignedTo.set("userStories",_duties)),assignedTo.get("tasks")&&(_duties=assignedTo.get("tasks").map(function(duty){return _attachProjectInfoToDuty(duty,"tasks")}),assignedTo=assignedTo.set("tasks",_duties)),assignedTo.get("issues")&&(_duties=assignedTo.get("issues").map(function(duty){return _attachProjectInfoToDuty(duty,"issues")}),assignedTo=assignedTo.set("issues",_duties)),watching=workInProgress.get("watching"),watching.get("userStories")&&(_duties=watching.get("userStories").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"userstories")}),watching=watching.set("userStories",_duties)),watching.get("tasks")&&(_duties=watching.get("tasks").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"tasks")}),watching=watching.set("tasks",_duties)),watching.get("issues")&&(_duties=watching.get("issues").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"issues")}),watching=watching.set("issues",_duties)),workInProgress=workInProgress.set("assignedTo",assignedTo),workInProgress=workInProgress.set("watching",watching)},HomeService.prototype.getWorkInProgress=function(userId){var assignedIssuesPromise,assignedTasksPromise,assignedTo,assignedUserStoriesPromise,params,params_us,projectsById,projectsPromise,watching,watchingIssuesPromise,watchingTasksPromise,watchingUserStoriesPromise,workInProgress;return projectsById=Immutable.Map(),projectsPromise=this.projectsService.getProjectsByUserId(userId).then(function(projects){return projectsById=Immutable.fromJS(groupBy(projects.toJS(),function(p){return p.id}))}),assignedTo=Immutable.Map(),params={status__is_closed:!1,assigned_to:userId},params_us={is_closed:!1,assigned_to:userId},assignedUserStoriesPromise=this.rs.userstories.listInAllProjects(params_us).then(function(userstories){return assignedTo=assignedTo.set("userStories",userstories)}),assignedTasksPromise=this.rs.tasks.listInAllProjects(params).then(function(tasks){return assignedTo=assignedTo.set("tasks",tasks)}),assignedIssuesPromise=this.rs.issues.listInAllProjects(params).then(function(issues){return assignedTo=assignedTo.set("issues",issues)}),params={status__is_closed:!1,watchers:userId},params_us={is_closed:!1,watchers:userId},watching=Immutable.Map(),watchingUserStoriesPromise=this.rs.userstories.listInAllProjects(params_us).then(function(userstories){return watching=watching.set("userStories",userstories)}),watchingTasksPromise=this.rs.tasks.listInAllProjects(params).then(function(tasks){return watching=watching.set("tasks",tasks)}),watchingIssuesPromise=this.rs.issues.listInAllProjects(params).then(function(issues){return watching=watching.set("issues",issues)}),workInProgress=Immutable.Map(),Promise.all([projectsPromise,assignedUserStoriesPromise,assignedTasksPromise,assignedIssuesPromise,watchingUserStoriesPromise,watchingTasksPromise,watchingIssuesPromise]).then(function(_this){return function(){return workInProgress=workInProgress.set("assignedTo",assignedTo),workInProgress=workInProgress.set("watching",watching),workInProgress=_this._attachProjectInfoToWorkInProgress(workInProgress,projectsById)}}(this))},HomeService}(taiga.Service),angular.module("taigaHome").service("tgHomeService",HomeService)}.call(this),function(){var HomeProjectListDirective;HomeProjectListDirective=function(currentUserService,projectsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),scope.vm.newProject=function(){return projectsService.newProject()}},directive={templateUrl:"home/projects/home-project-list.html",scope:{},link:link}},HomeProjectListDirective.$inject=["tgCurrentUserService","tgProjectsService"],angular.module("taigaHome").directive("tgHomeProjectList",HomeProjectListDirective)}.call(this),function(){var WorkingOnController;WorkingOnController=function(){function WorkingOnController(homeService){this.homeService=homeService,this.assignedTo=Immutable.Map(),this.watching=Immutable.Map()}return WorkingOnController.$inject=["tgHomeService"],WorkingOnController.prototype._setAssignedTo=function(workInProgress){var issues,tasks,userStories;return userStories=workInProgress.get("assignedTo").get("userStories"),tasks=workInProgress.get("assignedTo").get("tasks"),issues=workInProgress.get("assignedTo").get("issues"),this.assignedTo=userStories.concat(tasks).concat(issues),this.assignedTo.size>0?this.assignedTo=this.assignedTo.sortBy(function(elem){return elem.get("modified_date")}).reverse():void 0},WorkingOnController.prototype._setWatching=function(workInProgress){var issues,tasks,userStories;return userStories=workInProgress.get("watching").get("userStories"),tasks=workInProgress.get("watching").get("tasks"),issues=workInProgress.get("watching").get("issues"), -this.watching=userStories.concat(tasks).concat(issues),this.watching.size>0?this.watching=this.watching.sortBy(function(elem){return elem.get("modified_date")}).reverse():void 0},WorkingOnController.prototype.getWorkInProgress=function(userId){return this.homeService.getWorkInProgress(userId).then(function(_this){return function(workInProgress){return _this._setAssignedTo(workInProgress),_this._setWatching(workInProgress)}}(this))},WorkingOnController}(),angular.module("taigaHome").controller("WorkingOn",WorkingOnController)}.call(this),function(){var WorkingOnDirective;WorkingOnDirective=function(homeService,currentUserService){var link;return link=function(scope,el,attrs,ctrl){var user,userId;return user=currentUserService.getUser(),user?(userId=user.get("id"),ctrl.getWorkInProgress(userId)):void 0},{controller:"WorkingOn",controllerAs:"vm",templateUrl:"home/working-on/working-on.html",scope:{},link:link}},WorkingOnDirective.$inject=["tgHomeService","tgCurrentUserService"],angular.module("taigaHome").directive("tgWorkingOn",WorkingOnDirective)}.call(this),function(){var DropdownProjectListDirective;DropdownProjectListDirective=function(currentUserService,projectsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),scope.vm.newProject=function(){return projectsService.newProject()}},directive={templateUrl:"navigation-bar/dropdown-project-list/dropdown-project-list.html",scope:{},link:link}},DropdownProjectListDirective.$inject=["tgCurrentUserService","tgProjectsService"],angular.module("taigaNavigationBar").directive("tgDropdownProjectList",DropdownProjectListDirective)}.call(this),function(){var DropdownUserDirective;DropdownUserDirective=function(authService,configService,locationService,navUrlsService,feedbackService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.vm.isFeedbackEnabled=configService.get("feedbackEnabled"),taiga.defineImmutableProperty(scope.vm,"user",function(){return authService.userData}),scope.vm.logout=function(){return authService.logout(),locationService.url(navUrlsService.resolve("discover")),locationService.search({})},scope.vm.sendFeedback=function(){return feedbackService.sendFeedback()}},directive={templateUrl:"navigation-bar/dropdown-user/dropdown-user.html",scope:{},link:link}},DropdownUserDirective.$inject=["$tgAuth","$tgConfig","$tgLocation","$tgNavUrls","tgFeedbackService"],angular.module("taigaNavigationBar").directive("tgDropdownUser",DropdownUserDirective)}.call(this),function(){var NavigationBarDirective;NavigationBarDirective=function(currentUserService,navigationBarService,locationService,navUrlsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.$on("$routeChangeSuccess",function(){return"/"===locationService.path()?scope.vm.active=!0:scope.vm.active=!1}),taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),taiga.defineImmutableProperty(scope.vm,"isAuthenticated",function(){return currentUserService.isAuthenticated()}),taiga.defineImmutableProperty(scope.vm,"isEnabledHeader",function(){return navigationBarService.isEnabledHeader()}),scope.vm.login=function(){var nextUrl;return nextUrl=encodeURIComponent(locationService.url()),locationService.url(navUrlsService.resolve("login")),locationService.search({next:nextUrl})},scope.vm.register=function(){var nextUrl;return nextUrl=encodeURIComponent(locationService.url()),locationService.url(navUrlsService.resolve("register")),locationService.search({next:nextUrl})}},directive={templateUrl:"navigation-bar/navigation-bar.html",scope:{},link:link}},NavigationBarDirective.$inject=["tgCurrentUserService","tgNavigationBarService","$tgLocation","$tgNavUrls"],angular.module("taigaNavigationBar").directive("tgNavigationBar",NavigationBarDirective)}.call(this),function(){var NavigationBarService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;NavigationBarService=function(superClass){function NavigationBarService(){this.disableHeader()}return extend(NavigationBarService,superClass),NavigationBarService.prototype.enableHeader=function(){return this.enabledHeader=!0},NavigationBarService.prototype.disableHeader=function(){return this.enabledHeader=!1},NavigationBarService.prototype.isEnabledHeader=function(){return this.enabledHeader},NavigationBarService}(taiga.Service),angular.module("taigaNavigationBar").service("tgNavigationBarService",NavigationBarService)}.call(this),function(){var ProfileBarController;ProfileBarController=function(){function ProfileBarController(userService){this.userService=userService,this.loadStats()}return ProfileBarController.$inject=["tgUserService"],ProfileBarController.prototype.loadStats=function(){return this.userService.getStats(this.user.get("id")).then(function(_this){return function(stats){return _this.stats=stats}}(this))},ProfileBarController}(),angular.module("taigaProfile").controller("ProfileBar",ProfileBarController)}.call(this),function(){var ProfileBarDirective;ProfileBarDirective=function(){return{templateUrl:"profile/profile-bar/profile-bar.html",controller:"ProfileBar",controllerAs:"vm",scope:{user:"=user",isCurrentUser:"=iscurrentuser"},bindToController:!0}},angular.module("taigaProfile").directive("tgProfileBar",ProfileBarDirective)}.call(this),function(){var ProfileContactsController;ProfileContactsController=function(){function ProfileContactsController(userService,currentUserService){this.userService=userService,this.currentUserService=currentUserService,this.currentUser=this.currentUserService.getUser(),this.isCurrentUser=!1,this.currentUser&&this.currentUser.get("id")===this.user.get("id")&&(this.isCurrentUser=!0)}return ProfileContactsController.$inject=["tgUserService","tgCurrentUserService"],ProfileContactsController.prototype.loadContacts=function(){return this.userService.getContacts(this.user.get("id")).then(function(_this){return function(contacts){return _this.contacts=contacts}}(this))},ProfileContactsController}(),angular.module("taigaProfile").controller("ProfileContacts",ProfileContactsController)}.call(this),function(){var ProfileContactsDirective;ProfileContactsDirective=function(){var link;return link=function(scope,elm,attrs,ctrl){return ctrl.loadContacts()},{templateUrl:"profile/profile-contacts/profile-contacts.html",scope:{user:"="},controllerAs:"vm",controller:"ProfileContacts",link:link,bindToController:!0}},angular.module("taigaProfile").directive("tgProfileContacts",ProfileContactsDirective)}.call(this),function(){var FavItemDirective;FavItemDirective=function(){var link,templateUrl;return link=function(scope,el,attrs,ctrl){return scope.vm={item:scope.item}},templateUrl=function(el,attrs){return"project"===attrs.itemType?"profile/profile-favs/items/project.html":"profile/profile-favs/items/ticket.html"},{scope:{item:"=tgFavItem"},link:link,templateUrl:templateUrl}},angular.module("taigaProfile").directive("tgFavItem",FavItemDirective)}.call(this),function(){var FavsBaseController,ProfileLikedController,ProfileVotedController,ProfileWatchedController,debounceLeading,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;debounceLeading=this.taiga.debounceLeading,FavsBaseController=function(){function FavsBaseController(){this._init()}return FavsBaseController.prototype._init=function(){return this.enableFilterByAll=!0,this.enableFilterByProjects=!0,this.enableFilterByUserStories=!0,this.enableFilterByTasks=!0,this.enableFilterByIssues=!0,this.enableFilterByTextQuery=!0,this._resetList(),this.q=null,this.type=null},FavsBaseController.prototype._resetList=function(){return this.items=Immutable.List(),this.scrollDisabled=!1,this._page=1},FavsBaseController.prototype._enableLoadingSpinner=function(){return this.isLoading=!0},FavsBaseController.prototype._disableLoadingSpinner=function(){return this.isLoading=!1},FavsBaseController.prototype._enableScroll=function(){return this.scrollDisabled=!1},FavsBaseController.prototype._disableScroll=function(){return this.scrollDisabled=!0},FavsBaseController.prototype._checkIfHasMorePages=function(hasNext){return hasNext?(this._page+=1,this._enableScroll()):this._disableScroll()},FavsBaseController.prototype._checkIfHasNoResults=function(){return this.hasNoResults=0===this.items.size},FavsBaseController.prototype.loadItems=function(){return this._enableLoadingSpinner(),this._disableScroll(),this._getItems(this.user.get("id"),this._page,this.type,this.q).then(function(_this){return function(response){return _this.items=_this.items.concat(response.get("data")),_this._checkIfHasMorePages(response.get("next")),_this._checkIfHasNoResults(),_this._disableLoadingSpinner(),_this.items}}(this))["catch"](function(_this){return function(){return _this._disableLoadingSpinner(),_this.items}}(this))},FavsBaseController.prototype.filterByTextQuery=debounceLeading(500,function(){return this._resetList(),this.loadItems()}),FavsBaseController.prototype.showAll=function(){return null!==this.type?(this.type=null,this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showProjectsOnly=function(){return"project"!==this.type?(this.type="project",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showUserStoriesOnly=function(){return"userstory"!==this.type?(this.type="userstory",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showTasksOnly=function(){return"task"!==this.type?(this.type="task",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showIssuesOnly=function(){return"issue"!==this.type?(this.type="issue",this._resetList(),this.loadItems()):void 0},FavsBaseController}(),ProfileLikedController=function(superClass){function ProfileLikedController(userService){this.userService=userService,ProfileLikedController.__super__.constructor.call(this),this.enableFilterByAll=!1,this.enableFilterByProjects=!1,this.enableFilterByUserStories=!1,this.enableFilterByTasks=!1,this.enableFilterByIssues=!1,this.enableFilterByTextQuery=!0,this._getItems=this.userService.getLiked}return extend(ProfileLikedController,superClass),ProfileLikedController.$inject=["tgUserService"],ProfileLikedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileLiked",ProfileLikedController),ProfileVotedController=function(superClass){function ProfileVotedController(userService){this.userService=userService,ProfileVotedController.__super__.constructor.call(this),this.enableFilterByAll=!0,this.enableFilterByProjects=!1,this.enableFilterByUserStories=!0,this.enableFilterByTasks=!0,this.enableFilterByIssues=!0,this.enableFilterByTextQuery=!0,this._getItems=this.userService.getVoted}return extend(ProfileVotedController,superClass),ProfileVotedController.$inject=["tgUserService"],ProfileVotedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileVoted",ProfileVotedController),ProfileWatchedController=function(superClass){function ProfileWatchedController(userService){this.userService=userService,ProfileWatchedController.__super__.constructor.call(this),this._getItems=this.userService.getWatched}return extend(ProfileWatchedController,superClass),ProfileWatchedController.$inject=["tgUserService"],ProfileWatchedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileWatched",ProfileWatchedController)}.call(this),function(){var ProfileLikedDirective,ProfileVotedDirective,ProfileWatchedDirective,base;base={scope:{},bindToController:{user:"=",type:"@",q:"@",scrollDisabled:"@",isLoading:"@",hasNoResults:"@"},controller:null,controllerAs:"vm",templateUrl:"profile/profile-favs/profile-favs.html"},ProfileLikedDirective=function(){return _.extend({},base,{controller:"ProfileLiked"})},angular.module("taigaProfile").directive("tgProfileLiked",ProfileLikedDirective),ProfileVotedDirective=function(){return _.extend({},base,{controller:"ProfileVoted"})},angular.module("taigaProfile").directive("tgProfileVoted",ProfileVotedDirective),ProfileWatchedDirective=function(){return _.extend({},base,{controller:"ProfileWatched"})},angular.module("taigaProfile").directive("tgProfileWatched",ProfileWatchedDirective)}.call(this),function(){var ProfileHints;ProfileHints=function(){function ProfileHints(translate){var hintKey;this.translate=translate,hintKey=Math.floor(Math.random()*this.HINTS.length)+1,this.hint=this.HINTS[hintKey-1],this.hint.linkText=this.hint.linkText||"HINTS.LINK",this.hint.title=this.translate.instant("HINTS.HINT"+hintKey+"_TITLE"),this.hint.text=this.translate.instant("HINTS.HINT"+hintKey+"_TEXT")}return ProfileHints.prototype.HINTS=[{url:"https://taiga.io/support/import-export-projects/"},{url:"https://taiga.io/support/custom-fields/"},{},{}],ProfileHints}(),ProfileHints.$inject=["$translate"],angular.module("taigaProfile").controller("ProfileHints",ProfileHints)}.call(this),function(){var ProfileHints;ProfileHints=function($translate){return{scope:{},controller:"ProfileHints",controllerAs:"vm",templateUrl:"profile/profile-hints/profile-hints.html"}},ProfileHints.$inject=["$translate"],angular.module("taigaProfile").directive("tgProfileHints",ProfileHints)}.call(this),function(){var ProfileProjectsController;ProfileProjectsController=function(){function ProfileProjectsController(projectsService,userService){this.projectsService=projectsService,this.userService=userService}return ProfileProjectsController.$inject=["tgProjectsService","tgUserService"],ProfileProjectsController.prototype.loadProjects=function(){return this.projectsService.getProjectsByUserId(this.user.get("id")).then(function(_this){return function(projects){return _this.userService.attachUserContactsToProjects(_this.user.get("id"),projects)}}(this)).then(function(_this){return function(projects){return _this.projects=projects}}(this))},ProfileProjectsController}(),angular.module("taigaProfile").controller("ProfileProjects",ProfileProjectsController)}.call(this),function(){var ProfileProjectsDirective;ProfileProjectsDirective=function(){var link;return link=function(scope,elm,attr,ctrl){return ctrl.loadProjects()},{templateUrl:"profile/profile-projects/profile-projects.html",scope:{user:"="},link:link,bindToController:!0,controllerAs:"vm",controller:"ProfileProjects"}},angular.module("taigaProfile").directive("tgProfileProjects",ProfileProjectsDirective)}.call(this),function(){var ProfileTabDirective;ProfileTabDirective=function(){var link;return link=function(scope,element,attrs,ctrl,transclude){return scope.tab={},attrs.$observe("tgProfileTab",function(name){return scope.tab.name=name}),attrs.$observe("tabTitle",function(title){return scope.tab.title=title}),scope.tab.icon=attrs.tabIcon,scope.tab.active=!!attrs.tabActive,scope.$eval(attrs.tabDisabled)!==!0?ctrl.addTab(scope.tab):void 0},{templateUrl:"profile/profile-tab/profile-tab.html",scope:{},require:"^tgProfileTabs",link:link,transclude:!0}},angular.module("taigaProfile").directive("tgProfileTab",ProfileTabDirective)}.call(this),function(){var ProfileTabsController;ProfileTabsController=function(){function ProfileTabsController(){this.tabs=[]}return ProfileTabsController.prototype.addTab=function(tab){return this.tabs.push(tab)},ProfileTabsController.prototype.toggleTab=function(tab){return _.map(this.tabs,function(tab){return tab.active=!1}),tab.active=!0},ProfileTabsController}(),angular.module("taigaProfile").controller("ProfileTabs",ProfileTabsController)}.call(this),function(){var ProfileTabsDirective;ProfileTabsDirective=function(){return{scope:{},controller:"ProfileTabs",controllerAs:"vm",templateUrl:"profile/profile-tabs/profile-tabs.html",transclude:!0}},angular.module("taigaProfile").directive("tgProfileTabs",ProfileTabsDirective)}.call(this),function(){var ProfileController;ProfileController=function(){function ProfileController(appMetaService,currentUserService,routeParams,userService,xhrError,translate){this.appMetaService=appMetaService,this.currentUserService=currentUserService,this.routeParams=routeParams,this.userService=userService,this.xhrError=xhrError,this.translate=translate,this.isCurrentUser=!1,this.routeParams.slug?this.userService.getUserByUserName(this.routeParams.slug).then(function(_this){return function(user){return user.get("is_active")?(_this.user=user,_this.isCurrentUser=!1,_this._setMeta(_this.user),user):_this.xhrError.notFound()}}(this))["catch"](function(_this){return function(xhr){return _this.xhrError.response(xhr)}}(this)):(this.user=this.currentUserService.getUser(),this.isCurrentUser=!0,this._setMeta(this.user))}return ProfileController.$inject=["tgAppMetaService","tgCurrentUserService","$routeParams","tgUserService","tgXhrErrorService","$translate"],ProfileController.prototype._setMeta=function(user){var ctx,description,title;return ctx={userFullName:user.get("full_name_display"),userUsername:user.get("username")},title=this.translate.instant("USER.PROFILE.PAGE_TITLE",ctx),description=user.get("bio"),this.appMetaService.setAll(title,description)},ProfileController}(),angular.module("taigaProfile").controller("Profile",ProfileController)}.call(this),function(){var LikeProjectButtonController;LikeProjectButtonController=function(){function LikeProjectButtonController(confirm,likeButtonService){this.confirm=confirm,this.likeButtonService=likeButtonService,this.isMouseOver=!1,this.loading=!1}return LikeProjectButtonController.$inject=["$tgConfirm","tgLikeProjectButtonService"],LikeProjectButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},LikeProjectButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},LikeProjectButtonController.prototype.toggleLike=function(){var promise;return this.loading=!0,promise=this.project.get("is_fan")?this._unlike():this._like(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},LikeProjectButtonController.prototype._like=function(){return this.likeButtonService.like(this.project.get("id")).then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))},LikeProjectButtonController.prototype._unlike=function(){return this.likeButtonService.unlike(this.project.get("id"))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))},LikeProjectButtonController}(),angular.module("taigaProjects").controller("LikeProjectButton",LikeProjectButtonController)}.call(this),function(){var LikeProjectButtonDirective;LikeProjectButtonDirective=function(){return{scope:{},controller:"LikeProjectButton",bindToController:{project:"="},controllerAs:"vm",templateUrl:"projects/components/like-project-button/like-project-button.html"}},angular.module("taigaProjects").directive("tgLikeProjectButton",LikeProjectButtonDirective)}.call(this),function(){var LikeProjectButtonService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,LikeProjectButtonService=function(superClass){function LikeProjectButtonService(rs,currentUserService,projectService){this.rs=rs,this.currentUserService=currentUserService,this.projectService=projectService}return extend(LikeProjectButtonService,superClass),LikeProjectButtonService.$inject=["tgResources","tgCurrentUserService","tgProjectService"],LikeProjectButtonService.prototype._getProjectIndex=function(projectId){return this.currentUserService.projects.get("all").findIndex(function(project){return project.get("id")===projectId})},LikeProjectButtonService.prototype._updateProjects=function(projectId,isFan){var projectIndex,projects;return projectIndex=this._getProjectIndex(projectId),-1!==projectIndex?(projects=this.currentUserService.projects.get("all").update(projectIndex,function(project){var totalFans;return totalFans=project.get("total_fans"),isFan?totalFans++:totalFans--,project.merge({is_fan:isFan,total_fans:totalFans})}),this.currentUserService.setProjects(projects)):void 0},LikeProjectButtonService.prototype._updateCurrentProject=function(isFan){var project,totalFans;return totalFans=this.projectService.project.get("total_fans"),isFan?totalFans++:totalFans--,project=this.projectService.project.merge({is_fan:isFan,total_fans:totalFans}),this.projectService.setProject(project)},LikeProjectButtonService.prototype.like=function(projectId){return this.rs.projects.likeProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,!0),_this._updateCurrentProject(!0)}}(this))},LikeProjectButtonService.prototype.unlike=function(projectId){return this.rs.projects.unlikeProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,!1),_this._updateCurrentProject(!1)}}(this))},LikeProjectButtonService}(taiga.Service),angular.module("taigaProjects").service("tgLikeProjectButtonService",LikeProjectButtonService)}.call(this),function(){var SortProjectsDirective;SortProjectsDirective=function(currentUserService){var directive,link;return link=function(scope,el,attrs,ctrl){var itemEl;return itemEl=null,el.sortable({dropOnEmpty:!0,revert:200,axis:"y",opacity:.95,placeholder:"placeholder",cancel:".project-name"}),el.on("sortstop",function(event,ui){var i,index,len,project,sortData,sorted_project_ids,value;for(itemEl=ui.item,project=itemEl.scope().project,index=itemEl.index(),sorted_project_ids=_.map(scope.projects.toJS(),function(p){return p.id}),sorted_project_ids=_.without(sorted_project_ids,project.get("id")),sorted_project_ids.splice(index,0,project.get("id")),sortData=[],index=i=0,len=sorted_project_ids.length;len>i;index=++i)value=sorted_project_ids[index],sortData.push({project_id:value,order:index});return currentUserService.bulkUpdateProjectsOrder(sortData)})},directive={scope:{projects:"=tgSortProjects"},link:link}},angular.module("taigaProjects").directive("tgSortProjects",["tgCurrentUserService",SortProjectsDirective])}.call(this),function(){var WatchProjectButtonController;WatchProjectButtonController=function(){function WatchProjectButtonController(confirm,watchButtonService){this.confirm=confirm,this.watchButtonService=watchButtonService,this.showWatchOptions=!1,this.loading=!1}return WatchProjectButtonController.$inject=["$tgConfirm","tgWatchProjectButtonService"],WatchProjectButtonController.prototype.toggleWatcherOptions=function(){return this.showWatchOptions=!this.showWatchOptions},WatchProjectButtonController.prototype.closeWatcherOptions=function(){return this.showWatchOptions=!1},WatchProjectButtonController.prototype.watch=function(notifyLevel){return notifyLevel!==this.project.get("notify_level")?(this.loading=!0,this.closeWatcherOptions(),this.watchButtonService.watch(this.project.get("id"),notifyLevel)["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))["finally"](function(_this){return function(){return _this.loading=!1}}(this))):void 0},WatchProjectButtonController.prototype.unwatch=function(){return this.loading=!0,this.closeWatcherOptions(),this.watchButtonService.unwatch(this.project.get("id"))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))["finally"](function(_this){return function(){return _this.loading=!1}}(this))},WatchProjectButtonController}(),angular.module("taigaProjects").controller("WatchProjectButton",WatchProjectButtonController)}.call(this),function(){var WatchProjectButtonDirective;WatchProjectButtonDirective=function(){return{scope:{},controller:"WatchProjectButton",bindToController:{project:"="},controllerAs:"vm",templateUrl:"projects/components/watch-project-button/watch-project-button.html"}},angular.module("taigaProjects").directive("tgWatchProjectButton",WatchProjectButtonDirective)}.call(this),function(){var WatchProjectButtonService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,WatchProjectButtonService=function(superClass){function WatchProjectButtonService(rs,currentUserService,projectService){this.rs=rs,this.currentUserService=currentUserService,this.projectService=projectService}return extend(WatchProjectButtonService,superClass),WatchProjectButtonService.$inject=["tgResources","tgCurrentUserService","tgProjectService"],WatchProjectButtonService.prototype._getProjectIndex=function(projectId){return this.currentUserService.projects.get("all").findIndex(function(project){return project.get("id")===projectId})},WatchProjectButtonService.prototype._updateProjects=function(projectId,notifyLevel,isWatcher){var projectIndex,projects;return projectIndex=this._getProjectIndex(projectId),-1!==projectIndex?(projects=this.currentUserService.projects.get("all").update(projectIndex,function(_this){return function(project){var totalWatchers;return totalWatchers=project.get("total_watchers"),!_this.projectService.project.get("is_watcher")&&isWatcher?totalWatchers++:_this.projectService.project.get("is_watcher")&&!isWatcher&&totalWatchers--,project.merge({is_watcher:isWatcher,total_watchers:totalWatchers,notify_level:notifyLevel})}}(this)),this.currentUserService.setProjects(projects)):void 0},WatchProjectButtonService.prototype._updateCurrentProject=function(notifyLevel,isWatcher){var project,totalWatchers;return totalWatchers=this.projectService.project.get("total_watchers"),!this.projectService.project.get("is_watcher")&&isWatcher?totalWatchers++:this.projectService.project.get("is_watcher")&&!isWatcher&&totalWatchers--,project=this.projectService.project.merge({is_watcher:isWatcher,notify_level:notifyLevel,total_watchers:totalWatchers}),this.projectService.setProject(project)},WatchProjectButtonService.prototype.watch=function(projectId,notifyLevel){return this.rs.projects.watchProject(projectId,notifyLevel).then(function(_this){return function(){return _this._updateProjects(projectId,notifyLevel,!0),_this._updateCurrentProject(notifyLevel,!0)}}(this))},WatchProjectButtonService.prototype.unwatch=function(projectId){return this.rs.projects.unwatchProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,null,!1),_this._updateCurrentProject(null,!1)}}(this))},WatchProjectButtonService}(taiga.Service),angular.module("taigaProjects").service("tgWatchProjectButtonService",WatchProjectButtonService)}.call(this),function(){var ProjectsListingController;ProjectsListingController=function(){function ProjectsListingController(currentUserService,projectsService){this.currentUserService=currentUserService,this.projectsService=projectsService,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this.currentUserService.projects.get("all")}}(this))}return ProjectsListingController.$inject=["tgCurrentUserService","tgProjectsService"],ProjectsListingController.prototype.newProject=function(){return this.projectsService.newProject()},ProjectsListingController}(),angular.module("taigaProjects").controller("ProjectsListing",ProjectsListingController)}.call(this),function(){var ProjectController;ProjectController=function(){function ProjectController(routeParams,appMetaService,auth,translate,projectService){var projectSlug;this.routeParams=routeParams,this.appMetaService=appMetaService,this.auth=auth,this.translate=translate,this.projectService=projectService,projectSlug=this.routeParams.pslug,this.user=this.auth.userData,taiga.defineImmutableProperty(this,"project",function(_this){return function(){return _this.projectService.project}}(this)),taiga.defineImmutableProperty(this,"members",function(_this){return function(){return _this.projectService.activeMembers}}(this)),this.appMetaService.setfn(this._setMeta.bind(this))}return ProjectController.$inject=["$routeParams","tgAppMetaService","$tgAuth","$translate","tgProjectService"],ProjectController.prototype._setMeta=function(project){var ctx,metas;return this.project?(metas={},ctx={projectName:this.project.get("name")},metas.title=this.translate.instant("PROJECT.PAGE_TITLE",ctx),metas.description=this.project.get("description"),metas):null},ProjectController}(),angular.module("taigaProjects").controller("Project",ProjectController)}.call(this),function(){var ProjectsService,groupBy,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,groupBy=this.taiga.groupBy,ProjectsService=function(superClass){function ProjectsService(rs,projectUrl,lightboxFactory){this.rs=rs,this.projectUrl=projectUrl,this.lightboxFactory=lightboxFactory}return extend(ProjectsService,superClass),ProjectsService.$inject=["tgResources","$projectUrl","tgLightboxFactory"],ProjectsService.prototype.getProjectBySlug=function(projectSlug){return this.rs.projects.getProjectBySlug(projectSlug).then(function(_this){return function(project){return _this._decorate(project)}}(this))},ProjectsService.prototype.getProjectStats=function(projectId){return this.rs.projects.getProjectStats(projectId)},ProjectsService.prototype.getProjectsByUserId=function(userId,paginate){return this.rs.projects.getProjectsByUserId(userId,paginate).then(function(_this){return function(projects){return projects.map(_this._decorate.bind(_this))}}(this))},ProjectsService.prototype._decorate=function(project){var colorized_tags,tags,url;return url=this.projectUrl.get(project.toJS()),project=project.set("url",url),colorized_tags=[],project.get("tags")&&(tags=project.get("tags").sort(),colorized_tags=tags.map(function(tag){var color;return color=project.get("tags_colors").get(tag),Immutable.fromJS({name:tag,color:color})}),project=project.set("colorized_tags",colorized_tags)),project},ProjectsService.prototype.newProject=function(){return this.lightboxFactory.create("tg-lb-create-project",{"class":"wizard-create-project"})},ProjectsService.prototype.bulkUpdateProjectsOrder=function(sortData){return this.rs.projects.bulkUpdateOrder(sortData)},ProjectsService}(taiga.Service),angular.module("taigaProjects").service("tgProjectsService",ProjectsService)}.call(this),function(){var Resource,module,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,Resource=function(urlsService,http,config,$rootScope,$q,storage){var service;return service={},service.list=function(type,objectId,projectId){var httpOptions,params,url,urlname;return urlname="attachments/"+type,params={object_id:objectId,project:projectId},httpOptions={headers:{"x-disable-pagination":"1"}},url=urlsService.resolve(urlname),http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service["delete"]=function(type,id){var url,urlname;return urlname="attachments/"+type,url=urlsService.resolve(urlname)+("/"+id),http["delete"](url)},service.patch=function(type,id,patch){var url,urlname;return urlname="attachments/"+type,url=urlsService.resolve(urlname)+("/"+id),http.patch(url,patch)},service.create=function(type,projectId,objectId,file){ -var data,defered,maxFileSize,response,token,uploadComplete,uploadFailed,uploadProgress,url,urlname,xhr;return urlname="attachments/"+type,url=urlsService.resolve(urlname),defered=$q.defer(),void 0===file?(defered.reject(null),defered.promise):(maxFileSize=config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered.reject(response),defered.promise):(uploadProgress=function(_this){return function(evt){return $rootScope.$apply(function(){return file.status="in-progress",file.size=sizeFormat(evt.total),file.progressMessage="upload "+sizeFormat(evt.loaded)+" of "+sizeFormat(evt.total),file.progressPercent=Math.round(evt.loaded/evt.total*100)+"%"})}}(this),uploadComplete=function(_this){return function(evt){return $rootScope.$apply(function(){var attachment,ref,status;file.status="done",status=evt.target.status;try{attachment=JSON.parse(evt.target.responseText)}catch(error){attachment={}}return status>=200&&400>status?(attachment=Immutable.fromJS(attachment),defered.resolve(attachment)):(response={status:status,data:{_error_message:null!=(ref=data.attached_file)?ref[0]:void 0}},defered.reject(response))})}}(this),uploadFailed=function(_this){return function(evt){return $rootScope.$apply(function(){return file.status="error",defered.reject("fail")})}}(this),data=new FormData,data.append("project",projectId),data.append("object_id",objectId),data.append("attached_file",file),xhr=new XMLHttpRequest,xhr.upload.addEventListener("progress",uploadProgress,!1),xhr.addEventListener("load",uploadComplete,!1),xhr.addEventListener("error",uploadFailed,!1),token=storage.get("token"),xhr.open("POST",url),xhr.setRequestHeader("Authorization","Bearer "+token),xhr.setRequestHeader("Accept","application/json"),xhr.send(data),defered.promise))},function(){return{attachments:service}}},Resource.$inject=["$tgUrls","$tgHttp","$tgConfig","$rootScope","$q","$tgStorage"],module=angular.module("taigaResources2"),module.factory("tgAttachmentsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.getApplicationToken=function(applicationId,state){var url;return url=urlsService.resolve("applications"),url=url+"/"+applicationId+"/token?state="+state,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.authorizeApplicationToken=function(applicationId,state){var data,url;return url=urlsService.resolve("application-tokens"),url+="/authorize",data={state:state,application:applicationId},http.post(url,data).then(function(result){return Immutable.fromJS(result.data)})},function(){return{externalapps:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgExternalAppsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("issues"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{issues:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgIssuesResource",Resource)}.call(this),function(){var Resource,module,pagination;pagination=function(){},Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getProjects=function(params,pagination){var httpOptions,url;return null==params&&(params={}),null==pagination&&(pagination=!0),url=urlsService.resolve("projects"),httpOptions={},pagination||(httpOptions={headers:{"x-lazy-pagination":!0}}),http.get(url,params,httpOptions)},service.getProjectBySlug=function(projectSlug){var url;return url=urlsService.resolve("projects"),url=url+"/by_slug?slug="+projectSlug,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.getProjectsByUserId=function(userId,paginate){var httpOptions,params,url;return null==paginate&&(paginate=!1),url=urlsService.resolve("projects"),httpOptions={},paginate||(httpOptions.headers={"x-disable-pagination":"1"}),params={member:userId,order_by:"memberships__user_order"},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getProjectStats=function(projectId){var url;return url=urlsService.resolve("projects"),url=url+"/"+projectId,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.bulkUpdateOrder=function(bulkData){var url;return url=urlsService.resolve("bulk-update-projects-order"),http.post(url,bulkData)},service.getTimeline=function(projectId,page){var params,url;return params={page:page,only_relevant:!0},url=urlsService.resolve("timeline-project"),url=url+"/"+projectId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.likeProject=function(projectId){var url;return url=urlsService.resolve("project-like",projectId),http.post(url)},service.unlikeProject=function(projectId){var url;return url=urlsService.resolve("project-unlike",projectId),http.post(url)},service.watchProject=function(projectId,notifyLevel){var data,url;return data={notify_level:notifyLevel},url=urlsService.resolve("project-watch",projectId),http.post(url,data)},service.unwatchProject=function(projectId){var url;return url=urlsService.resolve("project-unwatch",projectId),http.post(url)},function(){return{projects:service}}},Resource.$inject=["$tgUrls","$tgHttp","tgPaginateResponseService"],module=angular.module("taigaResources2"),module.factory("tgProjectsResources",Resource)}.call(this),function(){var Resources,services;services=["tgProjectsResources","tgUserResources","tgUsersResources","tgUserstoriesResource","tgTasksResource","tgIssuesResource","tgExternalAppsResource","tgAttachmentsResource","tgStatsResource"],Resources=function($injector){var i,j,len,len1,ref,service,serviceFn,serviceName,serviceProperty;for(i=0,len=services.length;len>i;i++)for(serviceName=services[i],serviceFn=$injector.get(serviceName),service=$injector.invoke(serviceFn),ref=Object.keys(service),j=0,len1=ref.length;len1>j;j++)serviceProperty=ref[j],this[serviceProperty]&&console.warm("repeated resource "+serviceProperty),this[serviceProperty]=service[serviceProperty];return this},Resources.$inject=["$injector"],angular.module("taigaResources2").service("tgResources",Resources)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.discover=function(applicationId,state){var url;return url=urlsService.resolve("stats-discover"),http.get(url).then(function(result){return Immutable.fromJS(result.data)})},function(){return{stats:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgStatsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("tasks"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{tasks:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgTasksResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getUserStorage=function(key){var httpOptions,url;return url=urlsService.resolve("user-storage"),key&&(url+="/"+key),httpOptions={},http.get(url,{}).then(function(response){return response.data.value})},service.setUserStorage=function(key,value){var params,url;return url=urlsService.resolve("user-storage")+"/"+key,params={key:key,value:value},http.put(url,params)},service.createUserStorage=function(key,value){var params,url;return url=urlsService.resolve("user-storage"),params={key:key,value:value},http.post(url,params)},function(){return{user:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgUserResources",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getUserByUsername=function(username){var httpOptions,params,url;return url=urlsService.resolve("by_username"),httpOptions={headers:{"x-disable-pagination":"1"}},params={username:username},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getStats=function(userId){var httpOptions,url;return url=urlsService.resolve("user-stats",userId),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,{},httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getContacts=function(userId){var httpOptions,url;return url=urlsService.resolve("user-contacts",userId),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,{},httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getLiked=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-liked",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),params.only_relevant=!0,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getVoted=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-voted",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getWatched=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-watched",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getProfileTimeline=function(userId,page){var params,url;return params={page:page},url=urlsService.resolve("timeline-profile"),url=url+"/"+userId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getUserTimeline=function(userId,page){var params,url;return params={page:page,only_relevant:!0},url=urlsService.resolve("timeline-user"),url=url+"/"+userId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},function(){return{users:service}}},Resource.$inject=["$tgUrls","$tgHttp","tgPaginateResponseService"],module=angular.module("taigaResources2"),module.factory("tgUsersResources",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("userstories"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{userstories:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgUserstoriesResource",Resource)}.call(this),function(){var AppMetaService,taiga,truncate;taiga=this.taiga,truncate=taiga.truncate,AppMetaService=function(){function AppMetaService(rootScope){this.rootScope=rootScope}return AppMetaService.$inject=["$rootScope"],AppMetaService.prototype._set=function(key,value){var meta;if(key)return"title"===key?(meta=$("title"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.text(value||"")):0===key.indexOf("og:")?(meta=$("meta[property='"+key+"']"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.attr("content",value||"")):(meta=$("meta[name='"+key+"']"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.attr("content",value||""))},AppMetaService.prototype.setTitle=function(title){return this._set("title",title)},AppMetaService.prototype.setDescription=function(description){return this._set("description",truncate(description,250))},AppMetaService.prototype.setTwitterMetas=function(title,description){return this._set("twitter:card","summary"),this._set("twitter:site","@taigaio"),this._set("twitter:title",title),this._set("twitter:description",truncate(description,300)),this._set("twitter:image",window.location.origin+"/"+window._version+"/images/logo-color.png")},AppMetaService.prototype.setOpenGraphMetas=function(title,description){return this._set("og:type","object"),this._set("og:site_name","Taiga - Love your projects"),this._set("og:title",title),this._set("og:description",truncate(description,300)),this._set("og:image",window.location.origin+"/"+window._version+"/images/logo-color.png"),this._set("og:url",window.location.href)},AppMetaService.prototype.setAll=function(title,description){return this.setTitle(title),this.setDescription(description),this.setTwitterMetas(title,description),this.setOpenGraphMetas(title,description)},AppMetaService.prototype.addMobileViewport=function(){return $("head").append('')},AppMetaService.prototype.removeMobileViewport=function(){return $('meta[name="viewport"]').remove()},AppMetaService.prototype.setfn=function(fn){return this.listener&&this._listener(),this._listener=this.rootScope.$watchCollection(fn,function(_this){return function(metas){return metas?(_this.setAll(metas.title,metas.description),_this._listener()):void 0}}(this))},AppMetaService}(),angular.module("taigaCommon").service("tgAppMetaService",AppMetaService)}.call(this),function(){var AttachmentsService,sizeFormat;sizeFormat=this.taiga.sizeFormat,AttachmentsService=function(){function AttachmentsService(confirm,config,translate,rs){this.confirm=confirm,this.config=config,this.translate=translate,this.rs=rs,this.maxFileSize=this.getMaxFileSize(),this.maxFileSize&&(this.maxFileSizeFormated=sizeFormat(this.maxFileSize))}return AttachmentsService.$inject=["$tgConfirm","$tgConfig","$translate","tgResources"],AttachmentsService.prototype.sizeError=function(file){var message;return message=this.translate.instant("ATTACHMENT.ERROR_MAX_SIZE_EXCEEDED",{fileName:file.name,fileSize:sizeFormat(file.size),maxFileSize:this.maxFileSizeFormated}),this.confirm.notify("error",message)},AttachmentsService.prototype.validate=function(file){return this.maxFileSize&&file.size>this.maxFileSize?(this.sizeError(file),!1):!0},AttachmentsService.prototype.getMaxFileSize=function(){return this.config.get("maxUploadFileSize",null)},AttachmentsService.prototype.list=function(type,objId,projectId){return this.rs.attachments.list(type,objId,projectId).then(function(_this){return function(attachments){return attachments.sortBy(function(attachment){return attachment.get("order")})}}(this))},AttachmentsService.prototype["delete"]=function(type,id){return this.rs.attachments["delete"](type,id)},AttachmentsService.prototype.saveError=function(file,data){var message;return message="",file&&(message=this.translate.instant("ATTACHMENT.ERROR_UPLOAD_ATTACHMENT",{fileName:file.name,errorMessage:data.data._error_message})),this.confirm.notify("error",message)},AttachmentsService.prototype.upload=function(file,objId,projectId,type){var promise;return promise=this.rs.attachments.create(type,projectId,objId,file),promise.then(null,this.saveError.bind(this,file)),promise},AttachmentsService.prototype.patch=function(id,type,patch){var promise;return promise=this.rs.attachments.patch(type,id,patch),promise.then(null,this.saveError.bind(this,null)),promise},AttachmentsService}(),angular.module("taigaCommon").service("tgAttachmentsService",AttachmentsService)}.call(this),function(){var ChekcPermissionsService,taiga;taiga=this.taiga,ChekcPermissionsService=function(){function ChekcPermissionsService(projectService){this.projectService=projectService}return ChekcPermissionsService.$inject=["tgProjectService"],ChekcPermissionsService.prototype.check=function(permission){return-1!==this.projectService.project.get("my_permissions").indexOf(permission)},ChekcPermissionsService}(),angular.module("taigaCommon").service("tgCheckPermissionsService",ChekcPermissionsService)}.call(this),function(){var CurrentUserService,groupBy,taiga;taiga=this.taiga,groupBy=this.taiga.groupBy,CurrentUserService=function(){function CurrentUserService(projectsService,storageService,rs){this.projectsService=projectsService,this.storageService=storageService,this.rs=rs,this._user=null,this._projects=Immutable.Map(),this._projectsById=Immutable.Map(),this._joyride=null,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this._projects}}(this)),taiga.defineImmutableProperty(this,"projectsById",function(_this){return function(){return _this._projectsById}}(this))}return CurrentUserService.$inject=["tgProjectsService","$tgStorage","tgResources"],CurrentUserService.prototype.isAuthenticated=function(){return null!==this.getUser()?!0:!1},CurrentUserService.prototype.getUser=function(){var userData;return this._user||(userData=this.storageService.get("userInfo"),userData&&(userData=Immutable.fromJS(userData),this.setUser(userData))),this._user},CurrentUserService.prototype.removeUser=function(){return this._user=null,this._projects=Immutable.Map(),this._projectsById=Immutable.Map(),this._joyride=null},CurrentUserService.prototype.setUser=function(user){return this._user=user,this._loadUserInfo()},CurrentUserService.prototype.bulkUpdateProjectsOrder=function(sortData){return this.projectsService.bulkUpdateProjectsOrder(sortData).then(function(_this){return function(){return _this.loadProjects()}}(this))},CurrentUserService.prototype.loadProjects=function(){return this.projectsService.getProjectsByUserId(this._user.get("id")).then(function(_this){return function(projects){return _this.setProjects(projects)}}(this))},CurrentUserService.prototype.disableJoyRide=function(section){return section?this._joyride[section]=!1:this._joyride={backlog:!1,kanban:!1,dashboard:!1},this.rs.user.setUserStorage("joyride",this._joyride)},CurrentUserService.prototype.loadJoyRideConfig=function(){return new Promise(function(_this){return function(resolve){return null!==_this._joyride?void resolve(_this._joyride):_this.rs.user.getUserStorage("joyride").then(function(config){return _this._joyride=config,resolve(_this._joyride)})["catch"](function(){return _this._joyride={backlog:!0,kanban:!0,dashboard:!0},_this.rs.user.createUserStorage("joyride",_this._joyride),resolve(_this._joyride)})}}(this))},CurrentUserService.prototype._loadUserInfo=function(){return Promise.all([this.loadProjects()])},CurrentUserService.prototype.setProjects=function(projects){return this._projects=this._projects.set("all",projects),this._projects=this._projects.set("recents",projects.slice(0,10)),this._projectsById=Immutable.fromJS(groupBy(projects.toJS(),function(p){return p.id})),this.projects},CurrentUserService}(),angular.module("taigaCommon").service("tgCurrentUserService",CurrentUserService)}.call(this),function(){var LightboxFactory;LightboxFactory=function(){function LightboxFactory(rootScope,compile){this.rootScope=rootScope,this.compile=compile}return LightboxFactory.$inject=["$rootScope","$compile"],LightboxFactory.prototype.create=function(name,attrs,scopeAttrs){var elm,html,scope;scope=this.rootScope.$new(),scope=_.merge(scope,scopeAttrs),elm=$("
").attr(name,!0).attr("tg-bind-scope",!0),attrs&&elm.attr(attrs),elm.addClass("remove-on-close"),html=this.compile(elm)(scope),$(document.body).append(html)},LightboxFactory}(),angular.module("taigaCommon").service("tgLightboxFactory",LightboxFactory)}.call(this),function(){var PaginateResponse;PaginateResponse=function(){return function(result){var paginateResponse;return paginateResponse=Immutable.Map({data:result.get("data"),next:!!result.get("headers")("x-pagination-next"),prev:!!result.get("headers")("x-pagination-prev"),current:result.get("headers")("x-pagination-current"),count:result.get("headers")("x-pagination-count")})}},angular.module("taigaCommon").factory("tgPaginateResponseService",PaginateResponse)}.call(this),function(){var ProjectService,taiga;taiga=this.taiga,ProjectService=function(){function ProjectService(projectsService,xhrError){this.projectsService=projectsService,this.xhrError=xhrError,this._project=null,this._section=null,this._sectionsBreadcrumb=Immutable.List(),this._activeMembers=Immutable.List(),taiga.defineImmutableProperty(this,"project",function(_this){return function(){return _this._project}}(this)),taiga.defineImmutableProperty(this,"section",function(_this){return function(){return _this._section}}(this)),taiga.defineImmutableProperty(this,"sectionsBreadcrumb",function(_this){return function(){return _this._sectionsBreadcrumb}}(this)),taiga.defineImmutableProperty(this,"activeMembers",function(_this){return function(){return _this._activeMembers}}(this))}return ProjectService.$inject=["tgProjectsService","tgXhrErrorService"],ProjectService.prototype.setSection=function(section){return this._section=section,section?this._sectionsBreadcrumb=this._sectionsBreadcrumb.push(this._section):this._sectionsBreadcrumb=Immutable.List()},ProjectService.prototype.setProjectBySlug=function(pslug){return new Promise(function(_this){return function(resolve,reject){return _this.project&&_this.project.get("slug")===pslug?resolve():_this.projectsService.getProjectBySlug(pslug).then(function(project){return _this.setProject(project),resolve()})["catch"](function(xhr){return _this.xhrError.response(xhr)})}}(this))},ProjectService.prototype.setProject=function(project){return this._project=project,this._activeMembers=this._project.get("members").filter(function(member){return member.get("is_active")})},ProjectService.prototype.cleanProject=function(){return this._project=null,this._activeMembers=Immutable.List(),this._section=null,this._sectionsBreadcrumb=Immutable.List()},ProjectService.prototype.hasPermission=function(permission){return-1!==this._project.get("my_permissions").indexOf(permission)},ProjectService.prototype.fetchProject=function(){var pslug;return pslug=this.project.get("slug"),this.projectsService.getProjectBySlug(pslug).then(function(_this){return function(project){return _this.setProject(project)}}(this))},ProjectService}(),angular.module("taigaCommon").service("tgProjectService",ProjectService)}.call(this),function(){var ScopeEvent;ScopeEvent=function(){function ScopeEvent(){}return ScopeEvent.prototype.scopes={},ScopeEvent.prototype._searchDuplicatedScopes=function(id){return _.find(Object.keys(this.scopes),function(_this){return function(key){return _this.scopes[key].$id===id}}(this))},ScopeEvent.prototype._create=function(name,scope){var duplicatedScopeName;if(duplicatedScopeName=this._searchDuplicatedScopes(scope.$id))throw new Error('scopeEvent: this scope is already register with the name "'+duplicatedScopeName+'"');if(this.scopes[name])throw new Error('scopeEvent: "'+name+'" already in use');return scope._tgEmitter=new EventEmitter2,scope.$on("$destroy",function(_this){return function(){return scope._tgEmitter.removeAllListeners(),delete _this.scopes[name]}}(this)),this.scopes[name]=scope},ScopeEvent.prototype.emitter=function(name,scope){if(scope)scope=this._create(name,scope);else{if(!this.scopes[name])throw new Error('scopeEvent: "'+name+"\" scope doesn't exist'");scope=this.scopes[name]}return scope._tgEmitter},ScopeEvent}(),angular.module("taigaCommon").service("tgScopeEvent",ScopeEvent)}.call(this),function(){var ThemeService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ThemeService=function(superClass){function ThemeService(){return ThemeService.__super__.constructor.apply(this,arguments)}return extend(ThemeService,superClass),ThemeService}(taiga.Service=function(){return{use:function(themeName){var stylesheetEl;return stylesheetEl=$("link[rel='stylesheet']:first"),0===stylesheetEl.length&&(stylesheetEl=$(""),$("head").append(stylesheetEl)),stylesheetEl.attr("href","/"+window._version+"/styles/theme-"+themeName+".css")}}}),angular.module("taigaCommon").service("tgThemeService",ThemeService)}.call(this),function(){var UserService,bindMethods,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,bindMethods=taiga.bindMethods,UserService=function(superClass){function UserService(rs){this.rs=rs,bindMethods(this)}return extend(UserService,superClass),UserService.$inject=["tgResources"],UserService.prototype.getUserByUserName=function(username){return this.rs.users.getUserByUsername(username)},UserService.prototype.getContacts=function(userId){return this.rs.users.getContacts(userId)},UserService.prototype.getLiked=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getLiked(userId,pageNumber,objectType,textQuery)},UserService.prototype.getVoted=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getVoted(userId,pageNumber,objectType,textQuery)},UserService.prototype.getWatched=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getWatched(userId,pageNumber,objectType,textQuery)},UserService.prototype.getStats=function(userId){return this.rs.users.getStats(userId)},UserService.prototype.attachUserContactsToProjects=function(userId,projects){return this.getContacts(userId).then(function(contacts){return projects=projects.map(function(project){var contactsFiltered;return contactsFiltered=contacts.filter(function(contact){var contactId;return contactId=contact.get("id"),-1!==project.get("members").indexOf(contactId)}),project=project.set("contacts",contactsFiltered)})})},UserService}(taiga.Service),angular.module("taigaCommon").service("tgUserService",UserService)}.call(this),function(){var xhrError,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;xhrError=function(superClass){function xhrError(q,location,navUrls){this.q=q,this.location=location,this.navUrls=navUrls}return extend(xhrError,superClass),xhrError.$inject=["$q","$location","$tgNavUrls"],xhrError.prototype.notFound=function(){return this.location.path(this.navUrls.resolve("not-found")),this.location.replace()},xhrError.prototype.permissionDenied=function(){return this.location.path(this.navUrls.resolve("permission-denied")),this.location.replace()},xhrError.prototype.response=function(xhr){return xhr&&(404===xhr.status?this.notFound():403===xhr.status&&this.permissionDenied()),this.q.reject(xhr)},xhrError}(taiga.Service),angular.module("taigaCommon").service("tgXhrErrorService",xhrError)}.call(this),function(){var UserTimelineAttachmentDirective;UserTimelineAttachmentDirective=function(template,$compile){var isImage,link,validFileExtensions;return validFileExtensions=[".jpg",".jpeg",".bmp",".gif",".png"],isImage=function(url){return url=url.toLowerCase(),_.some(validFileExtensions,function(extension){return-1!==url.indexOf(extension,url-extension.length)})},link=function(scope,el){var is_image,templateHtml;return is_image=isImage(scope.attachment.get("url")),templateHtml=is_image?template.get("user-timeline/user-timeline-attachment/user-timeline-attachment-image.html"):template.get("user-timeline/user-timeline-attachment/user-timeline-attachment.html"),el.html(templateHtml),$compile(el.contents())(scope),el.find("img").error(function(){return this.remove()})},{link:link,scope:{attachment:"=tgUserTimelineAttachment"}}},UserTimelineAttachmentDirective.$inject=["$tgTemplate","$compile"],angular.module("taigaUserTimeline").directive("tgUserTimelineAttachment",UserTimelineAttachmentDirective)}.call(this),function(){var UserTimelineItemTitle,unslugify;unslugify=this.taiga.unslugify,UserTimelineItemTitle=function(){function UserTimelineItemTitle(translate,sce){this.translate=translate,this.sce=sce}return UserTimelineItemTitle.$inject=["$translate","$sce"],UserTimelineItemTitle.prototype._fieldTranslationKey={status:"COMMON.FIELDS.STATUS",subject:"COMMON.FIELDS.SUBJECT",description_diff:"COMMON.FIELDS.DESCRIPTION",points:"COMMON.FIELDS.POINTS",assigned_to:"COMMON.FIELDS.ASSIGNED_TO",severity:"ISSUES.FIELDS.SEVERITY",priority:"ISSUES.FIELDS.PRIORITY",type:"ISSUES.FIELDS.TYPE",is_iocaine:"TASK.FIELDS.IS_IOCAINE",is_blocked:"COMMON.FIELDS.IS_BLOCKED"},UserTimelineItemTitle.prototype._params={username:function(timeline,event){var title_attr,url,user;return user=timeline.getIn(["data","user"]),user.get("is_profile_visible")?(title_attr=this.translate.instant("COMMON.SEE_USER_PROFILE",{username:user.get("username")}),url="user-profile:username=timeline.getIn(['data', 'user', 'username'])",this._getLink(url,user.get("name"),title_attr)):this._getUsernameSpan(user.get("name"))},field_name:function(timeline,event){var field_name;return field_name=timeline.getIn(["data","value_diff","key"]),this.translate.instant(this._fieldTranslationKey[field_name])},project_name:function(timeline,event){var url;return url="project:project=timeline.getIn(['data', 'project', 'slug'])",this._getLink(url,timeline.getIn(["data","project","name"]))},new_value:function(timeline,event){var new_value,value;return _.isArray(timeline.getIn(["data","value_diff","value"]).toJS())?(value=timeline.getIn(["data","value_diff","value"]).get(1),null===value&&"assigned_to"===timeline.getIn(["data","value_diff","key"])&&(value=this.translate.instant("ACTIVITY.VALUES.UNASSIGNED")),new_value=value):new_value=timeline.getIn(["data","value_diff","value"]).first().get(1),_.escape(new_value)},sprint_name:function(timeline,event){var url;return url="project-taskboard:project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['data', 'milestone', 'slug'])",this._getLink(url,timeline.getIn(["data","milestone","name"]))},us_name:function(timeline,event){var event_us,obj,text,url;return obj=this._getTimelineObj(timeline,event).get("userstory"),event_us={obj:"parent_userstory"},url=this._getDetailObjUrl(event_us),text="#"+obj.get("ref")+" "+obj.get("subject"),this._getLink(url,text)},obj_name:function(timeline,event){var obj,text,url;return obj=this._getTimelineObj(timeline,event),url=this._getDetailObjUrl(event),text="wikipage"===event.obj?unslugify(obj.get("slug")):"milestone"===event.obj?obj.get("name"):"#"+obj.get("ref")+" "+obj.get("subject"),this._getLink(url,text)},role_name:function(timeline,event){return _.escape(timeline.getIn(["data","value_diff","value"]).keySeq().first())}},UserTimelineItemTitle.prototype._translateTitleParams=function(param,timeline,event){return this._params[param].call(this,timeline,event)},UserTimelineItemTitle.prototype._getTimelineObj=function(timeline,event){ -return timeline.getIn(["data",event.obj])},UserTimelineItemTitle.prototype._getDetailObjUrl=function(event){var url;return url={issue:["project-issues-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],wikipage:["project-wiki-page",":project=timeline.getIn(['data', 'project', 'slug']),slug=timeline.getIn(['obj', 'slug'])"],task:["project-tasks-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],userstory:["project-userstories-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],parent_userstory:["project-userstories-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'userstory', 'ref'])"],milestone:["project-taskboard",":project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['obj', 'slug'])"]},url[event.obj][0]+url[event.obj][1]},UserTimelineItemTitle.prototype._getLink=function(url,text,title){return title=title||text,$("").attr("tg-nav",url).text(text).attr("title",title).prop("outerHTML")},UserTimelineItemTitle.prototype._getUsernameSpan=function(text){var title;return title=title||text,$("").addClass("username").text(text).prop("outerHTML")},UserTimelineItemTitle.prototype._getParams=function(timeline,event,timeline_type){var params;return params={},timeline_type.translate_params.forEach(function(_this){return function(param){return params[param]=_this._translateTitleParams(param,timeline,event)}}(this)),params},UserTimelineItemTitle.prototype.getTitle=function(timeline,event,type){var params,paramsKeys,translation;return params=this._getParams(timeline,event,type),paramsKeys={},Object.keys(params).forEach(function(key){return paramsKeys[key]="{{"+key+"}}"}),translation=this.translate.instant(type.key,paramsKeys),Object.keys(params).forEach(function(key){var find;return find="{{"+key+"}}",translation=translation.replace(new RegExp(find,"g"),params[key])}),translation},UserTimelineItemTitle}(),angular.module("taigaUserTimeline").service("tgUserTimelineItemTitle",UserTimelineItemTitle)}.call(this),function(){var UserTimelineType,timelineType;timelineType=function(timeline,event){var types;return types=[{check:function(timeline,event){return"membership"===event.obj},key:"TIMELINE.NEW_MEMBER",translate_params:["project_name"],member:function(timeline){return Immutable.Map({user:timeline.getIn(["data","user"]),role:timeline.getIn(["data","role"])})}},{check:function(timeline,event){return"project"===event.obj&&"create"===event.type},key:"TIMELINE.NEW_PROJECT",translate_params:["username","project_name"],description:function(timeline){return timeline.getIn(["data","project","description"])}},{check:function(timeline,event){return"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"attachments"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.UPLOAD_ATTACHMENT",translate_params:["username","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"create"===event.type},key:"TIMELINE.US_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"issue"===event.obj&&"create"===event.type},key:"TIMELINE.ISSUE_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"wikipage"===event.obj&&"create"===event.type},key:"TIMELINE.WIKI_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"create"===event.type&&!timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"create"===event.type&&timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_CREATED_WITH_US",translate_params:["username","project_name","obj_name","us_name"]},{check:function(timeline,event){return"milestone"===event.obj&&"create"===event.type},key:"TIMELINE.MILESTONE_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"userstory"===event.obj},key:"TIMELINE.NEW_COMMENT_US",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"issue"===event.obj},key:"TIMELINE.NEW_COMMENT_ISSUE",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"task"===event.obj},key:"TIMELINE.NEW_COMMENT_TASK",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&timeline.hasIn(["data","value_diff","value","backlog_order"])&&"change"===event.type},key:"TIMELINE.US_MOVED",translate_params:["username","obj_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type&&"userstory"===event.obj?null===timeline.getIn(["data","value_diff","value","milestone"]).get(1):!1},key:"TIMELINE.US_REMOVED_FROM_MILESTONE",translate_params:["username","obj_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type&&"userstory"===event.obj},key:"TIMELINE.US_ADDED_MILESTONE",translate_params:["username","obj_name","sprint_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"blocked"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type?timeline.getIn(["data","value_diff","value","is_blocked"]).get(1)===!0:!1},key:"TIMELINE.BLOCKED",translate_params:["username","obj_name"],description:function(timeline){var text;return timeline.hasIn(["data","value_diff","value","blocked_note_html"])?(text=timeline.getIn(["data","value_diff","value","blocked_note_html"]).get(1),$($.parseHTML(text)).text()):!1}},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"blocked"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type?timeline.getIn(["data","value_diff","value","is_blocked"]).get(1)===!1:!1},key:"TIMELINE.UNBLOCKED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"milestone"===event.obj&&"change"===event.type},key:"TIMELINE.MILESTONE_UPDATED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"wikipage"===event.obj&&"change"===event.type},key:"TIMELINE.WIKI_UPDATED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"points"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.US_UPDATED_POINTS",translate_params:["username","field_name","obj_name","new_value","role_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.US_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type},key:"TIMELINE.US_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"issue"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.ISSUE_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"issue"===event.obj&&"change"===event.type},key:"TIMELINE.ISSUE_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&!timeline.getIn(["data","task","userstory"])&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.TASK_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&timeline.getIn(["data","task","userstory"])&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.TASK_UPDATED_WITH_US",translate_params:["username","field_name","obj_name","us_name"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&!timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_UPDATED_WITH_US_NEW_VALUE",translate_params:["username","field_name","obj_name","us_name","new_value"]},{check:function(timeline,event){return"user"===event.obj&&"create"===event.type},key:"TIMELINE.NEW_USER",translate_params:["username"]}],_.find(types,function(obj){return obj.check(timeline,event)})},UserTimelineType=function(){function UserTimelineType(){}return UserTimelineType.prototype.getType=function(timeline,event){return timelineType(timeline,event)},UserTimelineType}(),angular.module("taigaUserTimeline").service("tgUserTimelineItemType",UserTimelineType)}.call(this),function(){var UserTimelineItemDirective;UserTimelineItemDirective=function(){return{templateUrl:"user-timeline/user-timeline-item/user-timeline-item.html",scope:{timeline:"=tgUserTimelineItem"}}},angular.module("taigaUserTimeline").directive("tgUserTimelineItem",UserTimelineItemDirective)}.call(this),function(){var UserTimelinePaginationSequence;UserTimelinePaginationSequence=function(){var obj;return obj={},obj.generate=function(config){var getContent,items,next,page;return page=1,items=Immutable.List(),config.minItems=config.minItems||20,next=function(){return items=Immutable.List(),getContent()},getContent=function(){return config.fetch(page).then(function(response){var data;return page++,data=response.get("data"),config.filter&&(data=config.filter(data)),config.map&&(data=data.map(config.map)),items=items.concat(data),items.size\n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: app.coffee\n */\n\n(function() {\n var configure, i18nInit, init, module, modules, pluginsWithModule, taiga;\n\n this.taiga = taiga = {};\n\n this.taigaContribPlugins = this.taigaContribPlugins || window.taigaContribPlugins || [];\n\n taiga.generateHash = function(components) {\n if (components == null) {\n components = [];\n }\n components = _.map(components, function(x) {\n return JSON.stringify(x);\n });\n return hex_sha1(components.join(\":\"));\n };\n\n taiga.generateUniqueSessionIdentifier = function() {\n var date, randomNumber;\n date = (new Date()).getTime();\n randomNumber = Math.floor(Math.random() * 0x9000000);\n return taiga.generateHash([date, randomNumber]);\n };\n\n taiga.sessionId = taiga.generateUniqueSessionIdentifier();\n\n configure = function($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider, $compileProvider, $translateProvider, $translatePartialLoaderProvider, $animateProvider) {\n var authHttpIntercept, decorators, defaultHeaders, loaderIntercept, originalWhen, preferedLangCode, userInfo, versionCheckHttpIntercept;\n $animateProvider.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/);\n originalWhen = $routeProvider.when;\n $routeProvider.when = function(path, route) {\n route.resolve || (route.resolve = {});\n angular.extend(route.resolve, {\n languageLoad: [\n \"$q\", \"$translate\", function($q, $translate) {\n var deferred;\n deferred = $q.defer();\n $translate().then(function() {\n return deferred.resolve();\n });\n return deferred.promise;\n }\n ]\n });\n return originalWhen.call($routeProvider, path, route);\n };\n $routeProvider.when(\"/\", {\n templateUrl: \"home/home.html\",\n controller: \"Home\",\n controllerAs: \"vm\",\n loader: true,\n title: \"HOME.PAGE_TITLE\",\n loader: true,\n description: \"HOME.PAGE_DESCRIPTION\",\n joyride: \"dashboard\"\n });\n $routeProvider.when(\"/discover\", {\n templateUrl: \"discover/discover-home/discover-home.html\",\n controller: \"DiscoverHome\",\n controllerAs: \"vm\",\n title: \"PROJECT.NAVIGATION.DISCOVER\",\n loader: true\n });\n $routeProvider.when(\"/discover/search\", {\n templateUrl: \"discover/discover-search/discover-search.html\",\n title: \"PROJECT.NAVIGATION.DISCOVER\",\n loader: true,\n controller: \"DiscoverSearch\",\n controllerAs: \"vm\",\n reloadOnSearch: false\n });\n $routeProvider.when(\"/projects/\", {\n templateUrl: \"projects/listing/projects-listing.html\",\n access: {\n requiresLogin: true\n },\n title: \"PROJECTS.PAGE_TITLE\",\n description: \"PROJECTS.PAGE_DESCRIPTION\",\n loader: true,\n controller: \"ProjectsListing\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/project/:pslug/\", {\n templateUrl: \"projects/project/project.html\",\n loader: true,\n controller: \"Project\",\n controllerAs: \"vm\",\n section: \"project-timeline\"\n });\n $routeProvider.when(\"/project/:pslug/search\", {\n templateUrl: \"search/search.html\",\n reloadOnSearch: false,\n section: \"search\",\n loader: true\n });\n $routeProvider.when(\"/project/:pslug/backlog\", {\n templateUrl: \"backlog/backlog.html\",\n loader: true,\n section: \"backlog\",\n joyride: \"backlog\"\n });\n $routeProvider.when(\"/project/:pslug/kanban\", {\n templateUrl: \"kanban/kanban.html\",\n loader: true,\n section: \"kanban\",\n joyride: \"kanban\"\n });\n $routeProvider.when(\"/project/:pslug/taskboard/:sslug\", {\n templateUrl: \"taskboard/taskboard.html\",\n loader: true,\n section: \"backlog\"\n });\n $routeProvider.when(\"/project/:pslug/us/:usref\", {\n templateUrl: \"us/us-detail.html\",\n loader: true,\n section: \"backlog-kanban\"\n });\n $routeProvider.when(\"/project/:pslug/task/:taskref\", {\n templateUrl: \"task/task-detail.html\",\n loader: true,\n section: \"backlog-kanban\"\n });\n $routeProvider.when(\"/project/:pslug/wiki\", {\n redirectTo: function(params) {\n return \"/project/\" + params.pslug + \"/wiki/home\";\n }\n });\n $routeProvider.when(\"/project/:pslug/wiki/:slug\", {\n templateUrl: \"wiki/wiki.html\",\n loader: true,\n section: \"wiki\"\n });\n $routeProvider.when(\"/project/:pslug/team\", {\n templateUrl: \"team/team.html\",\n loader: true,\n section: \"team\"\n });\n $routeProvider.when(\"/project/:pslug/issues\", {\n templateUrl: \"issue/issues.html\",\n loader: true,\n section: \"issues\"\n });\n $routeProvider.when(\"/project/:pslug/issue/:issueref\", {\n templateUrl: \"issue/issues-detail.html\",\n loader: true,\n section: \"issues\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/details\", {\n templateUrl: \"admin/admin-project-profile.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/default-values\", {\n templateUrl: \"admin/admin-project-default-values.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/modules\", {\n templateUrl: \"admin/admin-project-modules.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/export\", {\n templateUrl: \"admin/admin-project-export.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/reports\", {\n templateUrl: \"admin/admin-project-reports.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/status\", {\n templateUrl: \"admin/admin-project-values-status.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/points\", {\n templateUrl: \"admin/admin-project-values-points.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/priorities\", {\n templateUrl: \"admin/admin-project-values-priorities.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/severities\", {\n templateUrl: \"admin/admin-project-values-severities.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/types\", {\n templateUrl: \"admin/admin-project-values-types.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/custom-fields\", {\n templateUrl: \"admin/admin-project-values-custom-fields.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/memberships\", {\n templateUrl: \"admin/admin-memberships.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/roles\", {\n templateUrl: \"admin/admin-roles.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/webhooks\", {\n templateUrl: \"admin/admin-third-parties-webhooks.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/github\", {\n templateUrl: \"admin/admin-third-parties-github.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/gitlab\", {\n templateUrl: \"admin/admin-third-parties-gitlab.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/bitbucket\", {\n templateUrl: \"admin/admin-third-parties-bitbucket.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/contrib/:plugin\", {\n templateUrl: \"contrib/main.html\"\n });\n $routeProvider.when(\"/user-settings/user-profile\", {\n templateUrl: \"user/user-profile.html\"\n });\n $routeProvider.when(\"/user-settings/user-change-password\", {\n templateUrl: \"user/user-change-password.html\"\n });\n $routeProvider.when(\"/user-settings/mail-notifications\", {\n templateUrl: \"user/mail-notifications.html\"\n });\n $routeProvider.when(\"/change-email/:email_token\", {\n templateUrl: \"user/change-email.html\"\n });\n $routeProvider.when(\"/cancel-account/:cancel_token\", {\n templateUrl: \"user/cancel-account.html\"\n });\n $routeProvider.when(\"/profile\", {\n templateUrl: \"profile/profile.html\",\n loader: true,\n access: {\n requiresLogin: true\n },\n controller: \"Profile\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/profile/:slug\", {\n templateUrl: \"profile/profile.html\",\n loader: true,\n controller: \"Profile\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/login\", {\n templateUrl: \"auth/login.html\",\n title: \"LOGIN.PAGE_TITLE\",\n description: \"LOGIN.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/register\", {\n templateUrl: \"auth/register.html\",\n title: \"REGISTER.PAGE_TITLE\",\n description: \"REGISTER.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/forgot-password\", {\n templateUrl: \"auth/forgot-password.html\",\n title: \"FORGOT_PASSWORD.PAGE_TITLE\",\n description: \"FORGOT_PASSWORD.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/change-password/:token\", {\n templateUrl: \"auth/change-password-from-recovery.html\",\n title: \"CHANGE_PASSWORD.PAGE_TITLE\",\n description: \"CHANGE_PASSWORD.PAGE_TITLE\",\n disableHeader: true\n });\n $routeProvider.when(\"/invitation/:token\", {\n templateUrl: \"auth/invitation.html\",\n title: \"INVITATION.PAGE_TITLE\",\n description: \"INVITATION.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/external-apps\", {\n templateUrl: \"external-apps/external-app.html\",\n title: \"EXTERNAL_APP.PAGE_TITLE\",\n description: \"EXTERNAL_APP.PAGE_DESCRIPTION\",\n controller: \"ExternalApp\",\n controllerAs: \"vm\",\n disableHeader: true,\n mobileViewport: true\n });\n $routeProvider.when(\"/error\", {\n templateUrl: \"error/error.html\"\n });\n $routeProvider.when(\"/not-found\", {\n templateUrl: \"error/not-found.html\"\n });\n $routeProvider.when(\"/permission-denied\", {\n templateUrl: \"error/permission-denied.html\"\n });\n $routeProvider.otherwise({\n redirectTo: \"/not-found\"\n });\n $locationProvider.html5Mode({\n enabled: true,\n requireBase: false\n });\n defaultHeaders = {\n \"Content-Type\": \"application/json\",\n \"Accept-Language\": window.taigaConfig.defaultLanguage || \"en\",\n \"X-Session-Id\": taiga.sessionId\n };\n $httpProvider.defaults.headers[\"delete\"] = defaultHeaders;\n $httpProvider.defaults.headers.patch = defaultHeaders;\n $httpProvider.defaults.headers.post = defaultHeaders;\n $httpProvider.defaults.headers.put = defaultHeaders;\n $httpProvider.defaults.headers.get = {\n \"X-Session-Id\": taiga.sessionId\n };\n $httpProvider.useApplyAsync(true);\n $tgEventsProvider.setSessionId(taiga.sessionId);\n authHttpIntercept = function($q, $location, $navUrls, $lightboxService) {\n var httpResponseError;\n httpResponseError = function(response) {\n var nextUrl;\n if (response.status === 0 || (response.status === -1 && !response.config.cancelable)) {\n $lightboxService.closeAll();\n $location.path($navUrls.resolve(\"error\"));\n $location.replace();\n } else if (response.status === 401 && $location.url().indexOf('/login') === -1) {\n nextUrl = encodeURIComponent($location.url());\n $location.url($navUrls.resolve(\"login\")).search(\"next=\" + nextUrl);\n }\n return $q.reject(response);\n };\n return {\n responseError: httpResponseError\n };\n };\n $provide.factory(\"authHttpIntercept\", [\"$q\", \"$location\", \"$tgNavUrls\", \"lightboxService\", authHttpIntercept]);\n $httpProvider.interceptors.push(\"authHttpIntercept\");\n loaderIntercept = function($q, loaderService) {\n return {\n request: function(config) {\n loaderService.logRequest();\n return config;\n },\n requestError: function(rejection) {\n loaderService.logResponse();\n return $q.reject(rejection);\n },\n responseError: function(rejection) {\n loaderService.logResponse();\n return $q.reject(rejection);\n },\n response: function(response) {\n loaderService.logResponse();\n return response;\n }\n };\n };\n $provide.factory(\"loaderIntercept\", [\"$q\", \"tgLoader\", loaderIntercept]);\n $httpProvider.interceptors.push(\"loaderIntercept\");\n versionCheckHttpIntercept = function($q) {\n var httpResponseError;\n httpResponseError = function(response) {\n var $injector;\n if (response.status === 400 && response.data.version) {\n $injector = angular.element(\"body\").injector();\n $injector.invoke([\n \"$tgConfirm\", \"$translate\", (function(_this) {\n return function($confirm, $translate) {\n var versionErrorMsg;\n versionErrorMsg = $translate.instant(\"ERROR.VERSION_ERROR\");\n return $confirm.notify(\"error\", versionErrorMsg, null, 10000);\n };\n })(this)\n ]);\n }\n return $q.reject(response);\n };\n return {\n responseError: httpResponseError\n };\n };\n $provide.factory(\"versionCheckHttpIntercept\", [\"$q\", versionCheckHttpIntercept]);\n $httpProvider.interceptors.push(\"versionCheckHttpIntercept\");\n window.checksley.updateValidators({\n linewidth: function(val, width) {\n var lines, valid;\n lines = taiga.nl2br(val).split(\"
\");\n valid = _.every(lines, function(line) {\n return line.length < width;\n });\n return valid;\n }\n });\n $compileProvider.debugInfoEnabled(window.taigaConfig.debugInfo || false);\n if (localStorage.userInfo) {\n userInfo = JSON.parse(localStorage.userInfo);\n }\n preferedLangCode = (userInfo != null ? userInfo.lang : void 0) || window.taigaConfig.defaultLanguage || \"en\";\n $translatePartialLoaderProvider.addPart('taiga');\n $translateProvider.useLoader('$translatePartialLoader', {\n urlTemplate: '/' + window._version + '/locales/{part}/locale-{lang}.json'\n }).useSanitizeValueStrategy('escapeParameters').addInterpolation('$translateMessageFormatInterpolation').preferredLanguage(preferedLangCode);\n $translateProvider.fallbackLanguage(preferedLangCode);\n decorators = window.getDecorators();\n return _.each(decorators, function(decorator) {\n return $provide.decorator(decorator.provider, decorator.decorator);\n });\n };\n\n i18nInit = function(lang, $translate) {\n var messages;\n moment.locale(lang);\n messages = {\n defaultMessage: $translate.instant(\"COMMON.FORM_ERRORS.DEFAULT_MESSAGE\"),\n type: {\n email: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_EMAIL\"),\n url: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_URL\"),\n urlstrict: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_URLSTRICT\"),\n number: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_NUMBER\"),\n digits: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_DIGITS\"),\n dateIso: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_DATEISO\"),\n alphanum: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_ALPHANUM\"),\n phone: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_PHONE\")\n },\n notnull: $translate.instant(\"COMMON.FORM_ERRORS.NOTNULL\"),\n notblank: $translate.instant(\"COMMON.FORM_ERRORS.NOT_BLANK\"),\n required: $translate.instant(\"COMMON.FORM_ERRORS.REQUIRED\"),\n regexp: $translate.instant(\"COMMON.FORM_ERRORS.REGEXP\"),\n min: $translate.instant(\"COMMON.FORM_ERRORS.MIN\"),\n max: $translate.instant(\"COMMON.FORM_ERRORS.MAX\"),\n range: $translate.instant(\"COMMON.FORM_ERRORS.RANGE\"),\n minlength: $translate.instant(\"COMMON.FORM_ERRORS.MIN_LENGTH\"),\n maxlength: $translate.instant(\"COMMON.FORM_ERRORS.MAX_LENGTH\"),\n rangelength: $translate.instant(\"COMMON.FORM_ERRORS.RANGE_LENGTH\"),\n mincheck: $translate.instant(\"COMMON.FORM_ERRORS.MIN_CHECK\"),\n maxcheck: $translate.instant(\"COMMON.FORM_ERRORS.MAX_CHECK\"),\n rangecheck: $translate.instant(\"COMMON.FORM_ERRORS.RANGE_CHECK\"),\n equalto: $translate.instant(\"COMMON.FORM_ERRORS.EQUAL_TO\")\n };\n return checksley.updateMessages('default', messages);\n };\n\n init = function($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService, projectService, loaderService, navigationBarService) {\n var un, user;\n $log.debug(\"Initialize application\");\n $rootscope.contribPlugins = this.taigaContribPlugins;\n $rootscope.adminPlugins = _.where(this.taigaContribPlugins, {\n \"type\": \"admin\"\n });\n $rootscope.$on(\"$translateChangeEnd\", function(e, ctx) {\n var lang;\n lang = ctx.language;\n return i18nInit(lang, $translate);\n });\n Promise.setScheduler(function(cb) {\n return $rootscope.$evalAsync(cb);\n });\n $events.setupConnection();\n if ($auth.isAuthenticated()) {\n user = $auth.getUser();\n }\n $analytics.initialize();\n un = $rootscope.$on('$routeChangeStart', function(event, next) {\n if (next.loader) {\n loaderService.start(true);\n }\n return un();\n });\n return $rootscope.$on('$routeChangeSuccess', function(event, next) {\n var description, title;\n if (next.loader) {\n loaderService.start(true);\n }\n if (next.access && next.access.requiresLogin) {\n if (!$auth.isAuthenticated()) {\n $location.path($navUrls.resolve(\"login\"));\n }\n }\n projectService.setSection(next.section);\n if (next.params.pslug) {\n projectService.setProjectBySlug(next.params.pslug);\n } else {\n projectService.cleanProject();\n }\n if (next.title || next.description) {\n title = $translate.instant(next.title || \"\");\n description = $translate.instant(next.description || \"\");\n appMetaService.setAll(title, description);\n }\n if (next.mobileViewport) {\n appMetaService.addMobileViewport();\n } else {\n appMetaService.removeMobileViewport();\n }\n if (next.disableHeader) {\n return navigationBarService.disableHeader();\n } else {\n return navigationBarService.enableHeader();\n }\n });\n };\n\n pluginsWithModule = _.filter(this.taigaContribPlugins, function(plugin) {\n return plugin.module;\n });\n\n angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 500);\n\n modules = [\"taigaBase\", \"taigaCommon\", \"taigaResources\", \"taigaResources2\", \"taigaAuth\", \"taigaEvents\", \"taigaHome\", \"taigaNavigationBar\", \"taigaProjects\", \"taigaRelatedTasks\", \"taigaBacklog\", \"taigaTaskboard\", \"taigaKanban\", \"taigaIssues\", \"taigaUserStories\", \"taigaTasks\", \"taigaTeam\", \"taigaWiki\", \"taigaSearch\", \"taigaAdmin\", \"taigaProject\", \"taigaUserSettings\", \"taigaFeedback\", \"taigaPlugins\", \"taigaIntegrations\", \"taigaComponents\", \"taigaProfile\", \"taigaHome\", \"taigaUserTimeline\", \"taigaExternalApps\", \"taigaDiscover\", \"templates\", \"ngSanitize\", \"ngRoute\", \"ngAnimate\", \"ngAria\", \"pascalprecht.translate\", \"infinite-scroll\", \"tgRepeat\"].concat(_.map(pluginsWithModule, function(plugin) {\n return plugin.module;\n }));\n\n module = angular.module(\"taiga\", modules);\n\n module.config([\"$routeProvider\", \"$locationProvider\", \"$httpProvider\", \"$provide\", \"$tgEventsProvider\", \"$compileProvider\", \"$translateProvider\", \"$translatePartialLoaderProvider\", \"$animateProvider\", configure]);\n\n module.run([\"$log\", \"$rootScope\", \"$tgAuth\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"tgProjectService\", \"tgLoader\", \"tgNavigationBarService\", \"$route\", init]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: classes.coffee\n */\n\n(function() {\n var TaigaBase, TaigaController, TaigaService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n TaigaBase = (function() {\n function TaigaBase() {}\n\n return TaigaBase;\n\n })();\n\n TaigaService = (function(superClass) {\n extend(TaigaService, superClass);\n\n function TaigaService() {\n return TaigaService.__super__.constructor.apply(this, arguments);\n }\n\n return TaigaService;\n\n })(TaigaBase);\n\n TaigaController = (function(superClass) {\n extend(TaigaController, superClass);\n\n function TaigaController() {\n this.onInitialDataError = bind(this.onInitialDataError, this);\n return TaigaController.__super__.constructor.apply(this, arguments);\n }\n\n TaigaController.prototype.onInitialDataError = function(xhr) {\n if (xhr) {\n if (xhr.status === 404) {\n this.location.path(this.navUrls.resolve(\"not-found\"));\n this.location.replace();\n } else if (xhr.status === 403) {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n this.location.replace();\n }\n }\n return this.q.reject(xhr);\n };\n\n return TaigaController;\n\n })(TaigaBase);\n\n this.taiga.Base = TaigaBase;\n\n this.taiga.Service = TaigaService;\n\n this.taiga.Controller = TaigaController;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: utils.coffee\n */\n\n(function() {\n var bindMethods, bindOnce, cancelTimeout, debounce, debounceLeading, defineImmutableProperty, groupBy, isImage, joinStr, mixOf, nl2br, patch, replaceTags, scopeDefer, sizeFormat, slugify, startswith, stripTags, taiga, timeout, toString, toggleText, trim, truncate, unslugify,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },\n slice = [].slice,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n nl2br = (function(_this) {\n return function(str) {\n var breakTag;\n breakTag = '
';\n return (str + '').replace(/([^>\\r\\n]?)(\\r\\n|\\n\\r|\\r|\\n)/g, '$1' + breakTag + '$2');\n };\n })(this);\n\n bindMethods = (function(_this) {\n return function(object) {\n var dependencies, methods;\n dependencies = _.keys(object);\n methods = [];\n _.forIn(object, function(value, key) {\n if (indexOf.call(dependencies, key) < 0) {\n return methods.push(key);\n }\n });\n return _.bindAll(object, methods);\n };\n })(this);\n\n bindOnce = (function(_this) {\n return function(scope, attr, continuation) {\n var delBind, val;\n val = scope.$eval(attr);\n if (val !== void 0) {\n return continuation(val);\n }\n delBind = null;\n return delBind = scope.$watch(attr, function(val) {\n if (val === void 0) {\n return;\n }\n continuation(val);\n if (delBind) {\n return delBind();\n }\n });\n };\n })(this);\n\n mixOf = function() {\n var Mixed, base, i, method, mixin, mixins, name, ref;\n base = arguments[0], mixins = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n Mixed = (function(superClass) {\n extend(Mixed, superClass);\n\n function Mixed() {\n return Mixed.__super__.constructor.apply(this, arguments);\n }\n\n return Mixed;\n\n })(base);\n for (i = mixins.length - 1; i >= 0; i += -1) {\n mixin = mixins[i];\n ref = mixin.prototype;\n for (name in ref) {\n method = ref[name];\n Mixed.prototype[name] = method;\n }\n }\n return Mixed;\n };\n\n trim = function(data, char) {\n return _.str.trim(data, char);\n };\n\n slugify = function(data) {\n return _.str.slugify(data);\n };\n\n unslugify = function(data) {\n if (data) {\n return _.str.capitalize(data.replace(/-/g, ' '));\n }\n return data;\n };\n\n toggleText = function(element, texts) {\n var nextTextPosition, text;\n nextTextPosition = element.data('nextTextPosition');\n if ((nextTextPosition == null) || nextTextPosition >= texts.length) {\n nextTextPosition = 0;\n }\n text = texts[nextTextPosition];\n element.data('nextTextPosition', nextTextPosition + 1);\n return element.text(text);\n };\n\n groupBy = function(coll, pred) {\n var i, item, len, result;\n result = {};\n for (i = 0, len = coll.length; i < len; i++) {\n item = coll[i];\n result[pred(item)] = item;\n }\n return result;\n };\n\n timeout = function(wait, continuation) {\n return window.setTimeout(continuation, wait);\n };\n\n cancelTimeout = function(timeoutVar) {\n return window.clearTimeout(timeoutVar);\n };\n\n scopeDefer = function(scope, func) {\n return _.defer((function(_this) {\n return function() {\n return scope.$apply(func);\n };\n })(this));\n };\n\n toString = function(value) {\n if (_.isNumber(value)) {\n return value + \"\";\n } else if (_.isString(value)) {\n return value;\n } else if (_.isPlainObject(value)) {\n return JSON.stringify(value);\n } else if (_.isUndefined(value)) {\n return \"\";\n }\n return value.toString();\n };\n\n joinStr = function(str, coll) {\n return _.str.join(str, coll);\n };\n\n debounce = function(wait, func) {\n return _.debounce(func, wait, {\n leading: true,\n trailing: false\n });\n };\n\n debounceLeading = function(wait, func) {\n return _.debounce(func, wait, {\n leading: false,\n trailing: true\n });\n };\n\n startswith = function(str1, str2) {\n return _.str.startsWith(str1, str2);\n };\n\n truncate = function(str, maxLength, suffix) {\n var out;\n if (suffix == null) {\n suffix = \"...\";\n }\n if ((typeof str !== \"string\") && !(str instanceof String)) {\n return str;\n }\n out = str.slice(0);\n if (out.length > maxLength) {\n out = out.substring(0, maxLength + 1);\n out = out.substring(0, Math.min(out.length, out.lastIndexOf(\" \")));\n out = out + suffix;\n }\n return out;\n };\n\n sizeFormat = function(input, precision) {\n var number, size, units;\n if (precision == null) {\n precision = 1;\n }\n if (isNaN(parseFloat(input)) || !isFinite(input)) {\n return \"-\";\n }\n if (input === 0) {\n return \"0 bytes\";\n }\n units = [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"];\n number = Math.floor(Math.log(input) / Math.log(1024));\n if (number > 5) {\n number = 5;\n }\n size = (input / Math.pow(1024, number)).toFixed(precision);\n return size + \" \" + units[number];\n };\n\n stripTags = function(str, exception) {\n var pattern;\n if (exception) {\n pattern = new RegExp('<(?!' + exception + '\\s*\\/?)[^>]+>', 'gi');\n return String(str).replace(pattern, '');\n } else {\n return String(str).replace(/<\\/?[^>]+>/g, '');\n }\n };\n\n replaceTags = function(str, tags, replace) {\n var pattern;\n pattern = new RegExp('<(' + tags + ')>', 'gi');\n str = str.replace(pattern, '<' + replace + '>');\n pattern = new RegExp('<\\/(' + tags + ')>', 'gi');\n str = str.replace(pattern, '');\n return str;\n };\n\n defineImmutableProperty = (function(_this) {\n return function(obj, name, fn) {\n return Object.defineProperty(obj, name, {\n get: function() {\n var fn_result;\n if (!_.isFunction(fn)) {\n throw \"defineImmutableProperty third param must be a function\";\n }\n fn_result = fn();\n if (fn_result && _.isObject(fn_result)) {\n if (fn_result.size === void 0) {\n throw \"defineImmutableProperty must return immutable data\";\n }\n }\n return fn_result;\n }\n });\n };\n })(this);\n\n _.mixin({\n removeKeys: function(obj, keys) {\n return _.chain([keys]).flatten().reduce(function(obj, key) {\n delete obj[key];\n return obj;\n }, obj).value();\n },\n cartesianProduct: function() {\n return _.reduceRight(arguments, function(a, b) {\n return _.flatten(_.map(a, function(x) {\n return _.map(b, function(y) {\n return [y].concat(x);\n });\n }), true);\n }, [[]]);\n }\n });\n\n isImage = function(name) {\n return name.match(/\\.(jpe?g|png|gif|gifv|webm)/i) !== null;\n };\n\n patch = function(oldImmutable, newImmutable) {\n var pathObj;\n pathObj = {};\n newImmutable.forEach(function(newValue, key) {\n if (newValue !== oldImmutable.get(key)) {\n if (newValue.toJS) {\n return pathObj[key] = newValue.toJS();\n } else {\n return pathObj[key] = newValue;\n }\n }\n });\n return pathObj;\n };\n\n taiga = this.taiga;\n\n taiga.nl2br = nl2br;\n\n taiga.bindMethods = bindMethods;\n\n taiga.bindOnce = bindOnce;\n\n taiga.mixOf = mixOf;\n\n taiga.trim = trim;\n\n taiga.slugify = slugify;\n\n taiga.unslugify = unslugify;\n\n taiga.toggleText = toggleText;\n\n taiga.groupBy = groupBy;\n\n taiga.timeout = timeout;\n\n taiga.cancelTimeout = cancelTimeout;\n\n taiga.scopeDefer = scopeDefer;\n\n taiga.toString = toString;\n\n taiga.joinStr = joinStr;\n\n taiga.truncate = truncate;\n\n taiga.debounce = debounce;\n\n taiga.debounceLeading = debounceLeading;\n\n taiga.startswith = startswith;\n\n taiga.sizeFormat = sizeFormat;\n\n taiga.stripTags = stripTags;\n\n taiga.replaceTags = replaceTags;\n\n taiga.defineImmutableProperty = defineImmutableProperty;\n\n taiga.isImage = isImage;\n\n taiga.patch = patch;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/controllerMixins.coffee\n */\n\n(function() {\n var FiltersMixin, PageMixin, groupBy, joinStr, taiga, toString, trim;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n joinStr = this.taiga.joinStr;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n PageMixin = (function() {\n function PageMixin() {}\n\n PageMixin.prototype.fillUsersAndRoles = function(users, roles) {\n var activeUsers, computableRoles;\n activeUsers = _.filter(users, (function(_this) {\n return function(user) {\n return user.is_active;\n };\n })(this));\n this.scope.activeUsers = _.sortBy(activeUsers, \"full_name_display\");\n this.scope.activeUsersById = groupBy(this.scope.activeUsers, function(e) {\n return e.id;\n });\n this.scope.users = _.sortBy(users, \"full_name_display\");\n this.scope.usersById = groupBy(this.scope.users, function(e) {\n return e.id;\n });\n this.scope.roles = _.sortBy(roles, \"order\");\n computableRoles = _(this.scope.project.members).map(\"role\").uniq().value();\n return this.scope.computableRoles = _(roles).filter(\"computable\").filter(function(x) {\n return _.contains(computableRoles, x.id);\n }).value();\n };\n\n PageMixin.prototype.loadUsersAndRoles = function() {\n var promise;\n promise = this.q.all([this.rs.projects.usersList(this.scope.projectId), this.rs.projects.rolesList(this.scope.projectId)]);\n return promise.then((function(_this) {\n return function(results) {\n var roles, users;\n users = results[0], roles = results[1];\n _this.fillUsersAndRoles(users, roles);\n return results;\n };\n })(this));\n };\n\n return PageMixin;\n\n })();\n\n taiga.PageMixin = PageMixin;\n\n FiltersMixin = (function() {\n function FiltersMixin() {}\n\n FiltersMixin.prototype.selectFilter = function(name, value, load) {\n var existing, location, params;\n if (load == null) {\n load = false;\n }\n params = this.location.search();\n if (params[name] !== void 0 && name !== \"page\") {\n existing = _.map(taiga.toString(params[name]).split(\",\"), function(x) {\n return trim(x);\n });\n existing.push(taiga.toString(value));\n existing = _.compact(existing);\n value = joinStr(\",\", _.uniq(existing));\n }\n if (!this.location.isInCurrentRouteParams(name, value)) {\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n }\n };\n\n FiltersMixin.prototype.replaceFilter = function(name, value, load) {\n var location;\n if (load == null) {\n load = false;\n }\n if (!this.location.isInCurrentRouteParams(name, value)) {\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n }\n };\n\n FiltersMixin.prototype.replaceAllFilters = function(filters, load) {\n var location;\n if (load == null) {\n load = false;\n }\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(filters);\n };\n\n FiltersMixin.prototype.unselectFilter = function(name, value, load) {\n var location, newValues, params, parsedValues;\n if (load == null) {\n load = false;\n }\n params = this.location.search();\n if (params[name] === void 0) {\n return;\n }\n if (value === void 0 || value === null) {\n delete params[name];\n }\n parsedValues = _.map(taiga.toString(params[name]).split(\",\"), function(x) {\n return trim(x);\n });\n newValues = _.reject(parsedValues, function(x) {\n return x === taiga.toString(value);\n });\n newValues = _.compact(newValues);\n if (_.isEmpty(newValues)) {\n value = null;\n } else {\n value = joinStr(\",\", _.uniq(newValues));\n }\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n };\n\n return FiltersMixin;\n\n })();\n\n taiga.FiltersMixin = FiltersMixin;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaAdmin\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/auth.coffee\n */\n\n(function() {\n var AuthService, CancelAccountDirective, ChangeEmailDirective, ChangePasswordFromRecoveryDirective, ForgotPasswordDirective, InvitationDirective, LoginDirective, PublicRegisterMessageDirective, RegisterDirective, debounce, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAuth\", [\"taigaResources\"]);\n\n AuthService = (function(superClass) {\n extend(AuthService, superClass);\n\n AuthService.$inject = [\"$rootScope\", \"$tgStorage\", \"$tgModel\", \"$tgResources\", \"$tgHttp\", \"$tgUrls\", \"$tgConfig\", \"$translate\", \"tgCurrentUserService\", \"tgThemeService\"];\n\n function AuthService(rootscope, storage, model, rs, http, urls, config, translate, currentUserService, themeService) {\n var userModel;\n this.rootscope = rootscope;\n this.storage = storage;\n this.model = model;\n this.rs = rs;\n this.http = http;\n this.urls = urls;\n this.config = config;\n this.translate = translate;\n this.currentUserService = currentUserService;\n this.themeService = themeService;\n AuthService.__super__.constructor.call(this);\n userModel = this.getUser();\n this._currentTheme = this._getUserTheme();\n this.setUserdata(userModel);\n }\n\n AuthService.prototype.setUserdata = function(userModel) {\n if (userModel) {\n this.userData = Immutable.fromJS(userModel.getAttrs());\n return this.currentUserService.setUser(this.userData);\n } else {\n return this.userData = null;\n }\n };\n\n AuthService.prototype._getUserTheme = function() {\n var ref;\n return ((ref = this.rootscope.user) != null ? ref.theme : void 0) || this.config.get(\"defaultTheme\") || \"taiga\";\n };\n\n AuthService.prototype._setTheme = function() {\n var newTheme;\n newTheme = this._getUserTheme();\n if (this._currentTheme !== newTheme) {\n this._currentTheme = newTheme;\n return this.themeService.use(this._currentTheme);\n }\n };\n\n AuthService.prototype._setLocales = function() {\n var lang, ref;\n lang = ((ref = this.rootscope.user) != null ? ref.lang : void 0) || this.config.get(\"defaultLanguage\") || \"en\";\n this.translate.preferredLanguage(lang);\n return this.translate.use(lang);\n };\n\n AuthService.prototype.getUser = function() {\n var user, userData;\n if (this.rootscope.user) {\n return this.rootscope.user;\n }\n userData = this.storage.get(\"userInfo\");\n if (userData) {\n user = this.model.make_model(\"users\", userData);\n this.rootscope.user = user;\n this._setLocales();\n this._setTheme();\n return user;\n } else {\n this._setTheme();\n }\n return null;\n };\n\n AuthService.prototype.setUser = function(user) {\n this.rootscope.auth = user;\n this.storage.set(\"userInfo\", user.getAttrs());\n this.rootscope.user = user;\n this.setUserdata(user);\n this._setLocales();\n return this._setTheme();\n };\n\n AuthService.prototype.clear = function() {\n this.rootscope.auth = null;\n this.rootscope.user = null;\n return this.storage.remove(\"userInfo\");\n };\n\n AuthService.prototype.setToken = function(token) {\n return this.storage.set(\"token\", token);\n };\n\n AuthService.prototype.getToken = function() {\n return this.storage.get(\"token\");\n };\n\n AuthService.prototype.removeToken = function() {\n return this.storage.remove(\"token\");\n };\n\n AuthService.prototype.isAuthenticated = function() {\n if (this.getUser() !== null) {\n return true;\n }\n return false;\n };\n\n AuthService.prototype.login = function(data, type) {\n var url;\n url = this.urls.resolve(\"auth\");\n data = _.clone(data, false);\n data.type = type ? type : \"normal\";\n this.removeToken();\n return this.http.post(url, data).then((function(_this) {\n return function(data, status) {\n var user;\n user = _this.model.make_model(\"users\", data.data);\n _this.setToken(user.auth_token);\n _this.setUser(user);\n return user;\n };\n })(this));\n };\n\n AuthService.prototype.logout = function() {\n this.removeToken();\n this.clear();\n this.currentUserService.removeUser();\n this._setTheme();\n return this._setLocales();\n };\n\n AuthService.prototype.register = function(data, type, existing) {\n var url;\n url = this.urls.resolve(\"auth-register\");\n data = _.clone(data, false);\n data.type = type ? type : \"public\";\n if (type === \"private\") {\n data.existing = existing ? existing : false;\n }\n this.removeToken();\n return this.http.post(url, data).then((function(_this) {\n return function(response) {\n var user;\n user = _this.model.make_model(\"users\", response.data);\n _this.setToken(user.auth_token);\n _this.setUser(user);\n return user;\n };\n })(this));\n };\n\n AuthService.prototype.getInvitation = function(token) {\n return this.rs.invitations.get(token);\n };\n\n AuthService.prototype.acceptInvitiationWithNewUser = function(data) {\n return this.register(data, \"private\", false);\n };\n\n AuthService.prototype.acceptInvitiationWithExistingUser = function(data) {\n return this.register(data, \"private\", true);\n };\n\n AuthService.prototype.forgotPassword = function(data) {\n var url;\n url = this.urls.resolve(\"users-password-recovery\");\n data = _.clone(data, false);\n this.removeToken();\n return this.http.post(url, data);\n };\n\n AuthService.prototype.changePasswordFromRecovery = function(data) {\n var url;\n url = this.urls.resolve(\"users-change-password-from-recovery\");\n data = _.clone(data, false);\n this.removeToken();\n return this.http.post(url, data);\n };\n\n AuthService.prototype.changeEmail = function(data) {\n var url;\n url = this.urls.resolve(\"users-change-email\");\n data = _.clone(data, false);\n return this.http.post(url, data);\n };\n\n AuthService.prototype.cancelAccount = function(data) {\n var url;\n url = this.urls.resolve(\"users-cancel-account\");\n data = _.clone(data, false);\n return this.http.post(url, data);\n };\n\n return AuthService;\n\n })(taiga.Service);\n\n module.service(\"$tgAuth\", AuthService);\n\n PublicRegisterMessageDirective = function($config, $navUrls, $routeParams, templates) {\n var template, templateFn;\n template = templates.get(\"auth/login-text.html\", true);\n templateFn = function() {\n var nextUrl, publicRegisterEnabled, url;\n publicRegisterEnabled = $config.get(\"publicRegisterEnabled\");\n if (!publicRegisterEnabled) {\n return \"\";\n }\n url = $navUrls.resolve(\"register\");\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"register\")) {\n nextUrl = encodeURIComponent($routeParams['next']);\n console.log(\"-----\", nextUrl);\n url += \"?next=\" + nextUrl;\n }\n return template({\n url: url\n });\n };\n return {\n restrict: \"AE\",\n scope: {},\n template: templateFn\n };\n };\n\n module.directive(\"tgPublicRegisterMessage\", [\"$tgConfig\", \"$tgNavUrls\", \"$routeParams\", \"$tgTemplate\", PublicRegisterMessageDirective]);\n\n LoginDirective = function($auth, $confirm, $location, $config, $routeParams, $navUrls, $events, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onError, onSuccess, submit;\n form = new checksley.Form($el.find(\"form.login-form\"));\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"login\")) {\n $scope.nextUrl = decodeURIComponent($routeParams['next']);\n } else {\n $scope.nextUrl = $navUrls.resolve(\"home\");\n }\n onSuccess = function(response) {\n $events.setupConnection();\n return $location.url($scope.nextUrl);\n };\n onError = function(response) {\n return $confirm.notify(\"light-error\", $translate.instant(\"LOGIN_FORM.ERROR_AUTH_INCORRECT\"));\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var data, loginFormType, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n data = {\n \"username\": $el.find(\"form.login-form input[name=username]\").val(),\n \"password\": $el.find(\"form.login-form input[name=password]\").val()\n };\n loginFormType = $config.get(\"loginFormType\", \"normal\");\n promise = $auth.login(data, loginFormType);\n return promise.then(onSuccess, onError);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n window.prerenderReady = true;\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLogin\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgConfig\", \"$routeParams\", \"$tgNavUrls\", \"$tgEvents\", \"$translate\", LoginDirective]);\n\n RegisterDirective = function($auth, $confirm, $location, $navUrls, $config, $routeParams, $analytics, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n if (!$config.get(\"publicRegisterEnabled\")) {\n $location.path($navUrls.resolve(\"not-found\"));\n $location.replace();\n }\n $scope.data = {};\n form = $el.find(\"form\").checksley({\n onlyOneErrorElement: true\n });\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"register\")) {\n $scope.nextUrl = decodeURIComponent($routeParams['next']);\n } else {\n $scope.nextUrl = $navUrls.resolve(\"home\");\n }\n onSuccessSubmit = function(response) {\n $analytics.trackEvent(\"auth\", \"register\", \"user registration\", 1);\n $confirm.notify(\"success\", $translate.instant(\"LOGIN_FORM.SUCCESS\"));\n return $location.url($scope.nextUrl);\n };\n onErrorSubmit = function(response) {\n var text;\n if (response.data._error_message) {\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n $confirm.notify(\"light-error\", text);\n }\n return form.setErrors(response.data);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.register($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return window.prerenderReady = true;\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRegister\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfig\", \"$routeParams\", \"$tgAnalytics\", \"$translate\", RegisterDirective]);\n\n ForgotPasswordDirective = function($auth, $confirm, $location, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"FORGOT_PASSWORD_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"FORGOT_PASSWORD_FORM.ERROR\");\n return $confirm.notify(\"light-error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.forgotPassword($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return window.prerenderReady = true;\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgForgotPassword\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", \"$translate\", ForgotPasswordDirective]);\n\n ChangePasswordFromRecoveryDirective = function($auth, $confirm, $location, $params, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit, text;\n $scope.data = {};\n if ($params.token != null) {\n $scope.tokenInParams = true;\n $scope.data.token = $params.token;\n } else {\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.ERROR\");\n $confirm.notify(\"light-error\", text);\n }\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.ERROR\");\n return $confirm.notify(\"light-error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.changePasswordFromRecovery($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangePasswordFromRecovery\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$translate\", ChangePasswordFromRecoveryDirective]);\n\n InvitationDirective = function($auth, $confirm, $location, $params, $navUrls, $analytics, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var loginForm, onErrorSubmitLogin, onErrorSubmitRegister, onSuccessSubmitLogin, onSuccessSubmitRegister, promise, registerForm, submitLogin, submitRegister, token;\n token = $params.token;\n promise = $auth.getInvitation(token);\n promise.then(function(invitation) {\n return $scope.invitation = invitation;\n });\n promise.then(null, function(response) {\n var text;\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"INVITATION_LOGIN_FORM.NOT_FOUND\");\n return $confirm.notify(\"light-error\", text);\n });\n $scope.dataLogin = {\n token: token\n };\n loginForm = $el.find(\"form.login-form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmitLogin = function(response) {\n var text;\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with existing user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n text = $translate.instant(\"INVITATION_LOGIN_FORM.SUCCESS\", {\n \"project_name\": $scope.invitation.project_name\n });\n return $confirm.notify(\"success\", text);\n };\n onErrorSubmitLogin = function(response) {\n return $confirm.notify(\"light-error\", response.data._error_message);\n };\n submitLogin = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!loginForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithExistingUser($scope.dataLogin);\n return promise.then(onSuccessSubmitLogin, onErrorSubmitLogin);\n };\n })(this));\n $el.on(\"submit\", \"form.login-form\", submitLogin);\n $el.on(\"click\", \".button-login\", submitLogin);\n $scope.dataRegister = {\n token: token\n };\n registerForm = $el.find(\"form.register-form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmitRegister = function(response) {\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with new user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n return $confirm.notify(\"success\", \"You've successfully joined this project\", \"Welcome to \" + (_.escape($scope.invitation.project_name)));\n };\n onErrorSubmitRegister = function(response) {\n var text;\n if (response.data._error_message) {\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n $confirm.notify(\"light-error\", text);\n }\n return registerForm.setErrors(response.data);\n };\n submitRegister = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!registerForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithNewUser($scope.dataRegister);\n return promise.then(onSuccessSubmitRegister, onErrorSubmitRegister);\n };\n })(this));\n $el.on(\"submit\", \"form.register-form\", submitRegister);\n $el.on(\"click\", \".button-register\", submitRegister);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgInvitation\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\", InvitationDirective]);\n\n ChangeEmailDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.email_token = $params.email_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n if ($auth.isAuthenticated()) {\n $repo.queryOne(\"users\", $auth.getUser().id).then((function(_this) {\n return function(data) {\n $auth.setUser(data);\n return $location.path($navUrls.resolve(\"home\"));\n };\n })(this));\n } else {\n $location.path($navUrls.resolve(\"login\"));\n }\n text = $translate.instant(\"CHANGE_EMAIL_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n return $confirm.notify(\"light-error\", text);\n };\n submit = function() {\n var promise;\n if (!form.validate()) {\n return;\n }\n promise = $auth.changeEmail($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n $el.on(\"submit\", function(event) {\n event.preventDefault();\n return submit();\n });\n $el.on(\"click\", \"a.button-change-email\", function(event) {\n event.preventDefault();\n return submit();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangeEmail\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$translate\", ChangeEmailDirective]);\n\n CancelAccountDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.cancel_token = $params.cancel_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n $auth.logout();\n $location.path($navUrls.resolve(\"home\"));\n text = $translate.instant(\"CANCEL_ACCOUNT.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n return $confirm.notify(\"error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.cancelAccount($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCancelAccount\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", CancelAccountDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaBacklog\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base.coffee\n */\n\n(function() {\n var TaigaMainDirective, bindOnce, groupBy, init, module, taiga, urls;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\", []);\n\n TaigaMainDirective = function($rootscope, $window) {\n var link;\n link = function($scope, $el, $attrs) {\n return $window.onresize = function() {\n return $rootscope.$broadcast(\"resize\");\n };\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMain\", [\"$rootScope\", \"$window\", TaigaMainDirective]);\n\n urls = {\n \"home\": \"/\",\n \"projects\": \"/projects\",\n \"error\": \"/error\",\n \"not-found\": \"/not-found\",\n \"permission-denied\": \"/permission-denied\",\n \"discover\": \"/discover\",\n \"discover-search\": \"/discover/search\",\n \"login\": \"/login\",\n \"forgot-password\": \"/forgot-password\",\n \"change-password\": \"/change-password/:token\",\n \"change-email\": \"/change-email/:token\",\n \"cancel-account\": \"/cancel-account/:token\",\n \"register\": \"/register\",\n \"invitation\": \"/invitation/:token\",\n \"create-project\": \"/create-project\",\n \"profile\": \"/profile\",\n \"user-profile\": \"/profile/:username\",\n \"project\": \"/project/:project\",\n \"project-backlog\": \"/project/:project/backlog\",\n \"project-taskboard\": \"/project/:project/taskboard/:sprint\",\n \"project-kanban\": \"/project/:project/kanban\",\n \"project-issues\": \"/project/:project/issues\",\n \"project-search\": \"/project/:project/search\",\n \"project-userstories-detail\": \"/project/:project/us/:ref\",\n \"project-tasks-detail\": \"/project/:project/task/:ref\",\n \"project-issues-detail\": \"/project/:project/issue/:ref\",\n \"project-wiki\": \"/project/:project/wiki\",\n \"project-wiki-page\": \"/project/:project/wiki/:slug\",\n \"project-team\": \"/project/:project/team\",\n \"project-admin-home\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-details\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-default-values\": \"/project/:project/admin/project-profile/default-values\",\n \"project-admin-project-profile-modules\": \"/project/:project/admin/project-profile/modules\",\n \"project-admin-project-profile-export\": \"/project/:project/admin/project-profile/export\",\n \"project-admin-project-profile-reports\": \"/project/:project/admin/project-profile/reports\",\n \"project-admin-project-values-status\": \"/project/:project/admin/project-values/status\",\n \"project-admin-project-values-points\": \"/project/:project/admin/project-values/points\",\n \"project-admin-project-values-priorities\": \"/project/:project/admin/project-values/priorities\",\n \"project-admin-project-values-severities\": \"/project/:project/admin/project-values/severities\",\n \"project-admin-project-values-types\": \"/project/:project/admin/project-values/types\",\n \"project-admin-project-values-custom-fields\": \"/project/:project/admin/project-values/custom-fields\",\n \"project-admin-memberships\": \"/project/:project/admin/memberships\",\n \"project-admin-roles\": \"/project/:project/admin/roles\",\n \"project-admin-third-parties-webhooks\": \"/project/:project/admin/third-parties/webhooks\",\n \"project-admin-third-parties-github\": \"/project/:project/admin/third-parties/github\",\n \"project-admin-third-parties-gitlab\": \"/project/:project/admin/third-parties/gitlab\",\n \"project-admin-third-parties-bitbucket\": \"/project/:project/admin/third-parties/bitbucket\",\n \"project-admin-contrib\": \"/project/:project/admin/contrib/:plugin\",\n \"user-settings-user-profile\": \"/user-settings/user-profile\",\n \"user-settings-user-change-password\": \"/user-settings/user-change-password\",\n \"user-settings-user-avatar\": \"/user-settings/user-avatar\",\n \"user-settings-mail-notifications\": \"/user-settings/mail-notifications\"\n };\n\n init = function($log, $navurls) {\n $log.debug(\"Initialize navigation urls\");\n return $navurls.update(urls);\n };\n\n module.run([\"$log\", \"$tgNavUrls\", init]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common.coffee\n */\n\n(function() {\n var AnimationFrame, Capslock, CheckPermissionDirective, ClassPermissionDirective, DataPickerConfig, LimitLineLengthDirective, ProjectUrl, Qqueue, SelectedText, Template, ToggleCommentDirective, module, taiga,\n slice = [].slice;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\", []);\n\n DataPickerConfig = function($translate) {\n return {\n get: function() {\n return {\n i18n: {\n previousMonth: $translate.instant(\"COMMON.PICKERDATE.PREV_MONTH\"),\n nextMonth: $translate.instant(\"COMMON.PICKERDATE.NEXT_MONTH\"),\n months: [$translate.instant(\"COMMON.PICKERDATE.MONTHS.JAN\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.FEB\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.MAR\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.APR\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.MAY\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.JUN\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.JUL\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.AUG\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.SEP\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.OCT\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.NOV\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.DEC\")],\n weekdays: [$translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.SUN\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.MON\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.TUE\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.WED\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.THU\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.FRI\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.SAT\")],\n weekdaysShort: [$translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.SUN\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.MON\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.TUE\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.WED\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.THU\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.FRI\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.SAT\")]\n },\n isRTL: $translate.instant(\"COMMON.PICKERDATE.IS_RTL\") === \"true\",\n firstDay: parseInt($translate.instant(\"COMMON.PICKERDATE.FIRST_DAY_OF_WEEK\"), 10),\n format: $translate.instant(\"COMMON.PICKERDATE.FORMAT\")\n };\n }\n };\n };\n\n module.factory(\"tgDatePickerConfigService\", [\"$translate\", DataPickerConfig]);\n\n SelectedText = function($window, $document) {\n var get;\n get = function() {\n if ($window.getSelection) {\n return $window.getSelection().toString();\n } else if ($document.selection) {\n return $document.selection.createRange().text;\n }\n return \"\";\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$selectedText\", [\"$window\", \"$document\", SelectedText]);\n\n CheckPermissionDirective = function(projectService) {\n var link, render;\n render = function($el, project, permission) {\n if (project && permission) {\n if (project.get('my_permissions').indexOf(permission) > -1) {\n return $el.removeClass('hidden');\n }\n }\n };\n link = function($scope, $el, $attrs) {\n var permission, unObserve, unwatch;\n $el.addClass('hidden');\n permission = $attrs.tgCheckPermission;\n unwatch = $scope.$watch(function() {\n return projectService.project;\n }, function() {\n if (!projectService.project) {\n return;\n }\n render($el, projectService.project, permission);\n return unwatch();\n });\n unObserve = $attrs.$observe(\"tgCheckPermission\", function(permission) {\n if (!permission) {\n return;\n }\n render($el, projectService.project, permission);\n return unObserve();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n CheckPermissionDirective.$inject = [\"tgProjectService\"];\n\n module.directive(\"tgCheckPermission\", CheckPermissionDirective);\n\n ClassPermissionDirective = function() {\n var link, name;\n name = \"tgClassPermission\";\n link = function($scope, $el, $attrs) {\n var checkPermissions, tgClassPermissionWatchAction, unbindWatcher;\n checkPermissions = function(project, className, permission) {\n var negation;\n negation = permission[0] === \"!\";\n if (negation) {\n permission = permission.slice(1);\n }\n if (negation && project.my_permissions.indexOf(permission) === -1) {\n return $el.addClass(className);\n } else if (!negation && project.my_permissions.indexOf(permission) !== -1) {\n return $el.addClass(className);\n } else {\n return $el.removeClass(className);\n }\n };\n tgClassPermissionWatchAction = function(project) {\n var className, classes, permission, results;\n if (project) {\n unbindWatcher();\n classes = $scope.$eval($attrs[name]);\n results = [];\n for (className in classes) {\n permission = classes[className];\n results.push(checkPermissions(project, className, permission));\n }\n return results;\n }\n };\n return unbindWatcher = $scope.$watch(\"project\", tgClassPermissionWatchAction);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgClassPermission\", ClassPermissionDirective);\n\n AnimationFrame = function() {\n var add, animationFrame, performAnimation, tail;\n animationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;\n performAnimation = (function(_this) {\n return function(time) {\n var fn;\n fn = tail.shift();\n fn();\n if (tail.length) {\n return animationFrame(performAnimation);\n }\n };\n })(this);\n tail = [];\n add = function() {\n var fn, i, len, results;\n results = [];\n for (i = 0, len = arguments.length; i < len; i++) {\n fn = arguments[i];\n tail.push(fn);\n if (tail.length === 1) {\n results.push(animationFrame(performAnimation));\n } else {\n results.push(void 0);\n }\n }\n return results;\n };\n return {\n add: add\n };\n };\n\n module.factory(\"animationFrame\", AnimationFrame);\n\n ToggleCommentDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.find(\"textarea\").on(\"focus\", function() {\n return $el.addClass(\"active\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgToggleComment\", ToggleCommentDirective);\n\n ProjectUrl = function($navurls) {\n var get;\n get = function(project) {\n var ctx;\n ctx = {\n project: project.slug\n };\n if (project.is_backlog_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-backlog\", ctx);\n }\n if (project.is_kanban_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-kanban\", ctx);\n }\n if (project.is_wiki_activated && project.my_permissions.indexOf(\"view_wiki_pages\") > -1) {\n return $navurls.resolve(\"project-wiki\", ctx);\n }\n if (project.is_issues_activated && project.my_permissions.indexOf(\"view_issues\") > -1) {\n return $navurls.resolve(\"project-issues\", ctx);\n }\n return $navurls.resolve(\"project\", ctx);\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$projectUrl\", [\"$tgNavUrls\", ProjectUrl]);\n\n LimitLineLengthDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var maxColsPerLine;\n maxColsPerLine = parseInt($el.attr(\"cols\"));\n return $el.on(\"keyup\", function(event) {\n var code, lines;\n code = event.keyCode;\n lines = $el.val().split(\"\\n\");\n _.each(lines, function(line, index) {\n return lines[index] = line.substring(0, maxColsPerLine - 2);\n });\n return $el.val(lines.join(\"\\n\"));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLimitLineLength\", LimitLineLengthDirective);\n\n Qqueue = function($q) {\n var deferred, lastPromise, qqueue;\n deferred = $q.defer();\n deferred.resolve();\n lastPromise = deferred.promise;\n qqueue = {\n bindAdd: (function(_this) {\n return function(fn) {\n return function() {\n var args;\n args = 1 <= arguments.length ? slice.call(arguments, 0) : [];\n return lastPromise = lastPromise.then(function() {\n return fn.apply(_this, args);\n });\n };\n return qqueue;\n };\n })(this),\n add: (function(_this) {\n return function(fn) {\n if (!lastPromise) {\n lastPromise = fn();\n } else {\n lastPromise = lastPromise.then(fn);\n }\n return qqueue;\n };\n })(this)\n };\n return qqueue;\n };\n\n module.factory(\"$tgQqueue\", [\"$q\", Qqueue]);\n\n Template = function($templateCache) {\n return {\n get: (function(_this) {\n return function(name, lodash) {\n var tmp;\n if (lodash == null) {\n lodash = false;\n }\n tmp = $templateCache.get(name);\n if (lodash) {\n tmp = _.template(tmp);\n }\n return tmp;\n };\n })(this)\n };\n };\n\n module.factory(\"$tgTemplate\", [\"$templateCache\", Template]);\n\n Capslock = function($translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var hideIcon, open, showIcon, warningIcon;\n open = false;\n warningIcon = $('
').addClass('icon').addClass('icon-capslock').attr('title', $translate.instant('COMMON.CAPSLOCK_WARNING'));\n hideIcon = function() {\n return warningIcon.fadeOut(function() {\n open = false;\n return $(this).remove();\n });\n };\n showIcon = function(e) {\n var element;\n if (open) {\n return;\n }\n element = e.currentTarget;\n $(element).parent().append(warningIcon);\n $('.icon-capslock').fadeIn();\n return open = true;\n };\n $el.on('blur', function(e) {\n return hideIcon();\n });\n $el.on('keyup.capslock, focus', function(e) {\n if ($el.val() === $el.val().toLowerCase()) {\n return hideIcon(e);\n } else {\n return showIcon(e);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off('.capslock');\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCapslock\", [\"$translate\", Capslock]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/events.coffee\n */\n\n(function() {\n var EventsProvider, EventsService, bindMethods, module, startswith, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n startswith = this.taiga.startswith;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaEvents\", []);\n\n EventsService = (function() {\n function EventsService(win, log, config, auth, liveAnnouncementService1, rootScope) {\n this.win = win;\n this.log = log;\n this.config = config;\n this.auth = auth;\n this.liveAnnouncementService = liveAnnouncementService1;\n this.rootScope = rootScope;\n this.processMessage = bind(this.processMessage, this);\n bindMethods(this);\n }\n\n EventsService.prototype.initialize = function(sessionId) {\n this.sessionId = sessionId;\n this.subscriptions = {};\n this.connected = false;\n this.error = false;\n this.pendingMessages = [];\n this.missedHeartbeats = 0;\n this.heartbeatInterval = null;\n if (this.win.WebSocket === void 0) {\n return this.log.info(\"WebSockets not supported on your browser\");\n }\n };\n\n EventsService.prototype.setupConnection = function() {\n var loc, path, scheme, url;\n this.stopExistingConnection();\n url = this.config.get(\"eventsUrl\");\n if (!url) {\n return;\n }\n if (!startswith(url, \"ws:\") && !startswith(url, \"wss:\")) {\n loc = this.win.location;\n scheme = loc.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n path = _.str.ltrim(url, \"/\");\n url = scheme + \"//\" + loc.host + \"/\" + path;\n }\n this.ws = new this.win.WebSocket(url);\n this.ws.addEventListener(\"open\", this.onOpen);\n this.ws.addEventListener(\"message\", this.onMessage);\n this.ws.addEventListener(\"error\", this.onError);\n return this.ws.addEventListener(\"close\", this.onClose);\n };\n\n EventsService.prototype.stopExistingConnection = function() {\n if (this.ws === void 0) {\n return;\n }\n this.ws.removeEventListener(\"open\", this.onOpen);\n this.ws.removeEventListener(\"close\", this.onClose);\n this.ws.removeEventListener(\"error\", this.onError);\n this.ws.removeEventListener(\"message\", this.onMessage);\n this.stopHeartBeatMessages();\n this.ws.close();\n return delete this.ws;\n };\n\n EventsService.prototype.notifications = function() {\n return this.subscribe(null, 'notifications', (function(_this) {\n return function(data) {\n _this.liveAnnouncementService.show(data.title, data.desc);\n return _this.rootScope.$digest();\n };\n })(this));\n };\n\n EventsService.prototype.startHeartBeatMessages = function() {\n var heartbeatIntervalTime, maxMissedHeartbeats;\n if (this.heartbeatInterval) {\n return;\n }\n maxMissedHeartbeats = this.config.get(\"eventsMaxMissedHeartbeats\", 5);\n heartbeatIntervalTime = this.config.get(\"eventsHeartbeatIntervalTime\", 60000);\n this.missedHeartbeats = 0;\n this.heartbeatInterval = setInterval((function(_this) {\n return function() {\n var e, error1;\n try {\n if (_this.missedHeartbeats >= maxMissedHeartbeats) {\n throw new Error(\"Too many missed heartbeats PINGs.\");\n }\n _this.missedHeartbeats++;\n _this.sendMessage({\n cmd: \"ping\"\n });\n return _this.log.debug(\"HeartBeat send PING\");\n } catch (error1) {\n e = error1;\n _this.log.error(\"HeartBeat error: \" + e.message);\n return _this.stopHeartBeatMessages();\n }\n };\n })(this), heartbeatIntervalTime);\n return this.log.debug(\"HeartBeat enabled\");\n };\n\n EventsService.prototype.stopHeartBeatMessages = function() {\n if (!this.heartbeatInterval) {\n return;\n }\n clearInterval(this.heartbeatInterval);\n this.heartbeatInterval = null;\n return this.log.debug(\"HeartBeat disabled\");\n };\n\n EventsService.prototype.processHeartBeatPongMessage = function(data) {\n this.missedHeartbeats = 0;\n return this.log.debug(\"HeartBeat recived PONG\");\n };\n\n EventsService.prototype.serialize = function(message) {\n if (_.isObject(message)) {\n return JSON.stringify(message);\n }\n return message;\n };\n\n EventsService.prototype.sendMessage = function(message) {\n var i, len, messages, msg, results;\n this.pendingMessages.push(message);\n if (!this.connected) {\n return;\n }\n messages = _.map(this.pendingMessages, this.serialize);\n this.pendingMessages = [];\n results = [];\n for (i = 0, len = messages.length; i < len; i++) {\n msg = messages[i];\n results.push(this.ws.send(msg));\n }\n return results;\n };\n\n EventsService.prototype.processMessage = function(data) {\n var routingKey, subscription;\n routingKey = data.routing_key;\n if (this.subscriptions[routingKey] == null) {\n return;\n }\n subscription = this.subscriptions[routingKey];\n if (subscription.scope) {\n return subscription.scope.$apply(function() {\n return subscription.callback(data.data);\n });\n } else {\n return subscription.callback(data.data);\n }\n };\n\n EventsService.prototype.subscribe = function(scope, routingKey, callback) {\n var message, subscription;\n if (this.error) {\n return;\n }\n this.log.debug(\"Subscribe to: \" + routingKey);\n subscription = {\n scope: scope,\n routingKey: routingKey,\n callback: _.debounce(callback, 500, {\n \"leading\": true,\n \"trailing\": false\n })\n };\n message = {\n \"cmd\": \"subscribe\",\n \"routing_key\": routingKey\n };\n this.subscriptions[routingKey] = subscription;\n this.sendMessage(message);\n if (scope) {\n return scope.$on(\"$destroy\", (function(_this) {\n return function() {\n return _this.unsubscribe(routingKey);\n };\n })(this));\n }\n };\n\n EventsService.prototype.unsubscribe = function(routingKey) {\n var message;\n if (this.error) {\n return;\n }\n this.log.debug(\"Unsubscribe from: \" + routingKey);\n message = {\n \"cmd\": \"unsubscribe\",\n \"routing_key\": routingKey\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onOpen = function() {\n var message, token;\n this.connected = true;\n this.startHeartBeatMessages();\n this.notifications();\n this.log.debug(\"WebSocket connection opened\");\n token = this.auth.getToken();\n message = {\n cmd: \"auth\",\n data: {\n token: token,\n sessionId: this.sessionId\n }\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onMessage = function(event) {\n var data;\n this.log.debug(\"WebSocket message received: \" + event.data);\n data = JSON.parse(event.data);\n if (data.cmd === \"pong\") {\n return this.processHeartBeatPongMessage(data);\n } else {\n return this.processMessage(data);\n }\n };\n\n EventsService.prototype.onError = function(error) {\n this.log.error(\"WebSocket error: \" + error);\n return this.error = true;\n };\n\n EventsService.prototype.onClose = function() {\n this.log.debug(\"WebSocket closed.\");\n this.connected = false;\n return this.stopHeartBeatMessages();\n };\n\n return EventsService;\n\n })();\n\n EventsProvider = (function() {\n function EventsProvider() {}\n\n EventsProvider.prototype.setSessionId = function(sessionId) {\n return this.sessionId = sessionId;\n };\n\n EventsProvider.prototype.$get = function($win, $log, $conf, $auth, liveAnnouncementService, $rootScope) {\n var service;\n service = new EventsService($win, $log, $conf, $auth, liveAnnouncementService, $rootScope);\n service.initialize(this.sessionId);\n return service;\n };\n\n EventsProvider.prototype.$get.$inject = [\"$window\", \"$log\", \"$tgConfig\", \"$tgAuth\", \"tgLiveAnnouncementService\", \"$rootScope\"];\n\n return EventsProvider;\n\n })();\n\n module.provider(\"$tgEvents\", EventsProvider);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/feedback.coffee\n */\n\n(function() {\n var FeedbackDirective, bindOnce, debounce, groupBy, mixOf, module, taiga, trim;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounce = this.taiga.debounce;\n\n trim = this.taiga.trim;\n\n module = angular.module(\"taigaFeedback\", []);\n\n FeedbackDirective = function($lightboxService, $repo, $confirm, $loading, feedbackService) {\n var directive, link;\n link = function($scope, $el, $attrs) {\n var form, openLightbox, submit, submitButton;\n form = $el.find(\"form\").checksley();\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"feedback\", $scope.feedback);\n promise.then(function(data) {\n currentLoading.finish();\n $lightboxService.close($el);\n return $confirm.notify(\"success\", \"\\\\o/ we'll be happy to read your\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n openLightbox = function() {\n $scope.feedback = {};\n $lightboxService.open($el);\n return $el.find(\"textarea\").focus();\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return openLightbox();\n };\n directive = {\n link: link,\n templateUrl: \"common/lightbox-feedback.html\",\n scope: {}\n };\n return directive;\n };\n\n module.directive(\"tgLbFeedback\", [\"lightboxService\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"tgFeedbackService\", FeedbackDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/integrations.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIntegrations\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIssues\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaKanban\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaPlugins\", [\"ngRoute\"]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/projects.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaProject\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/related-tasks.coffee\n */\n\n(function() {\n var RelatedTaskAssignedToInlineEditionDirective, RelatedTaskCreateButtonDirective, RelatedTaskCreateFormDirective, RelatedTaskRowDirective, RelatedTasksDirective, debounce, module, taiga, trim;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaRelatedTasks\", []);\n\n RelatedTaskRowDirective = function($repo, $compile, $confirm, $rootscope, $loading, $template, $translate) {\n var link, templateEdit, templateView;\n templateView = $template.get(\"task/related-task-row.html\", true);\n templateEdit = $template.get(\"task/related-task-row-edit.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var renderEdit, renderView, saveTask;\n saveTask = debounce(2000, function(task) {\n var currentLoading, promise;\n task.subject = $el.find('input').val();\n currentLoading = $loading().target($el.find('.task-name')).start();\n promise = $repo.save(task);\n promise.then((function(_this) {\n return function() {\n currentLoading.finish();\n return $rootscope.$broadcast(\"related-tasks:update\");\n };\n })(this));\n promise.then(null, (function(_this) {\n return function() {\n currentLoading.finish();\n $el.find('input').val(task.subject);\n return $confirm.notify(\"error\");\n };\n })(this));\n return promise;\n });\n renderEdit = function(task) {\n $el.html($compile(templateEdit({\n task: task\n }))($scope));\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return saveTask($model.$modelValue).then(function() {\n return renderView($model.$modelValue);\n });\n } else if (event.keyCode === 27) {\n return renderView($model.$modelValue);\n }\n });\n $el.on(\"click\", \".icon-floppy\", function(event) {\n return saveTask($model.$modelValue).then(function() {\n return renderView($model.$modelValue);\n });\n });\n return $el.on(\"click\", \".cancel-edit\", function(event) {\n return renderView($model.$modelValue);\n });\n };\n renderView = function(task) {\n var perms;\n $el.off();\n perms = {\n modify_task: $scope.project.my_permissions.indexOf(\"modify_task\") !== -1,\n delete_task: $scope.project.my_permissions.indexOf(\"delete_task\") !== -1\n };\n $el.html($compile(templateView({\n task: task,\n perms: perms\n }))($scope));\n $el.on(\"click\", \".icon-edit\", function() {\n renderEdit($model.$modelValue);\n return $el.find('input').focus().select();\n });\n return $el.on(\"click\", \".delete-task\", function(event) {\n var message, title;\n title = $translate.instant(\"TASK.TITLE_DELETE_ACTION\");\n task = $model.$modelValue;\n message = task.subject;\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var promise;\n promise = $repo.remove(task);\n promise.then(function() {\n askResponse.finish();\n return $scope.$emit(\"related-tasks:delete\");\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n });\n });\n };\n $scope.$watch($attrs.ngModel, function(val) {\n if (!val) {\n return;\n }\n return renderView(val);\n });\n $scope.$on(\"related-tasks:assigned-to-changed\", function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n $scope.$on(\"related-tasks:status-changed\", function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgRelatedTaskRow\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$rootScope\", \"$tgLoading\", \"$tgTemplate\", \"$translate\", RelatedTaskRowDirective]);\n\n RelatedTaskCreateFormDirective = function($repo, $compile, $confirm, $tgmodel, $loading, $analytics, $template) {\n var link, newTask, template;\n template = $template.get(\"task/related-task-create-form.html\", true);\n newTask = {\n subject: \"\",\n assigned_to: null\n };\n link = function($scope, $el, $attrs) {\n var close, createTask, render;\n createTask = debounce(2000, function(task) {\n var currentLoading, promise;\n task.subject = $el.find('input').val();\n task.assigned_to = $scope.newTask.assigned_to;\n task.status = $scope.newTask.status;\n $scope.newTask.status = $scope.project.default_task_status;\n $scope.newTask.assigned_to = null;\n currentLoading = $loading().target($el.find('.task-name')).start();\n promise = $repo.create(\"tasks\", task);\n promise.then(function() {\n $analytics.trackEvent(\"task\", \"create\", \"create task on userstory\", 1);\n currentLoading.finish();\n return $scope.$emit(\"related-tasks:add\");\n });\n promise.then(null, function() {\n $el.find('input').val(task.subject);\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n return promise;\n });\n close = function() {\n $el.off();\n $el.html(\"\");\n return $scope.newRelatedTaskFormOpen = false;\n };\n render = function() {\n $scope.newRelatedTaskFormOpen = true;\n $el.html($compile(template())($scope));\n $el.find('input').focus().select();\n $el.addClass('active');\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return createTask(newTask).then(function() {\n return render();\n });\n } else if (event.keyCode === 27) {\n return $scope.$apply(function() {\n return close();\n });\n }\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n return $scope.$apply(function() {\n return close();\n });\n });\n return $el.on(\"click\", \".icon-floppy\", function(event) {\n return createTask(newTask).then(function() {\n return close();\n });\n });\n };\n taiga.bindOnce($scope, \"us\", function(val) {\n newTask[\"status\"] = $scope.project.default_task_status;\n newTask[\"project\"] = $scope.project.id;\n newTask[\"user_story\"] = $scope.us.id;\n $scope.newTask = $tgmodel.make_model(\"tasks\", newTask);\n return $el.html(\"\");\n });\n $scope.$on(\"related-tasks:show-form\", function() {\n return render();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateForm\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", \"$tgLoading\", \"$tgAnalytics\", \"$tgTemplate\", RelatedTaskCreateFormDirective]);\n\n RelatedTaskCreateButtonDirective = function($repo, $compile, $confirm, $tgmodel, $template) {\n var link, template;\n template = $template.get(\"common/components/add-button.html\", true);\n link = function($scope, $el, $attrs) {\n $scope.$watch(\"project\", function(val) {\n if (!val) {\n return;\n }\n $el.off();\n if ($scope.project.my_permissions.indexOf(\"add_task\") !== -1) {\n $el.html($compile(template())($scope));\n } else {\n $el.html(\"\");\n }\n return $el.on(\"click\", \".add-button\", function(event) {\n return $scope.$emit(\"related-tasks:add-new-clicked\");\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateButton\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", \"$tgTemplate\", RelatedTaskCreateButtonDirective]);\n\n RelatedTasksDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var loadTasks;\n loadTasks = function() {\n return $rs.tasks.list($scope.projectId, null, $scope.usId).then((function(_this) {\n return function(tasks) {\n $scope.tasks = _.sortBy(tasks, 'ref');\n return tasks;\n };\n })(this));\n };\n $scope.$on(\"related-tasks:add\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:delete\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:add-new-clicked\", function() {\n return $scope.$broadcast(\"related-tasks:show-form\");\n });\n taiga.bindOnce($scope, \"us\", function(val) {\n return loadTasks();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTasks\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", RelatedTasksDirective]);\n\n RelatedTaskAssignedToInlineEditionDirective = function($repo, $rootscope, $translate) {\n var link, template;\n template = _.template(\"\\\" alt=\\\"<%- name %>\\\"/>\\n
<%- name %>
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, autoSave, notAutoSave, task, updateRelatedTask;\n updateRelatedTask = function(task) {\n var ctx, member;\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = $scope.usersById[task.assigned_to];\n if (member) {\n ctx.imgurl = member.photo;\n ctx.name = member.full_name_display;\n }\n $el.find(\".avatar\").html(template(ctx));\n return $el.find(\".task-assignedto\").attr('title', ctx.name);\n };\n $ctrl = $el.controller();\n task = $scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition);\n notAutoSave = $scope.$eval($attrs.notAutoSave);\n autoSave = !notAutoSave;\n updateRelatedTask(task);\n $el.on(\"click\", \".task-assignedto\", function(event) {\n return $rootscope.$broadcast(\"assigned-to:add\", task);\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_task\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"assigned-to:added\", debounce(2000, (function(_this) {\n return function(ctx, userId, updatedRelatedTask) {\n if (updatedRelatedTask.id === task.id) {\n updatedRelatedTask.assigned_to = userId;\n if (autoSave) {\n $repo.save(updatedRelatedTask).then(function() {\n return $scope.$emit(\"related-tasks:assigned-to-changed\");\n });\n }\n return updateRelatedTask(updatedRelatedTask);\n }\n };\n })(this)));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskAssignedToInlineEdition\", [\"$tgRepo\", \"$rootScope\", \"$translate\", RelatedTaskAssignedToInlineEditionDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources.coffee\n */\n\n(function() {\n var ResourcesService, initResources, initUrls, module, taiga, urls,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ResourcesService = (function(superClass) {\n extend(ResourcesService, superClass);\n\n function ResourcesService() {\n return ResourcesService.__super__.constructor.apply(this, arguments);\n }\n\n return ResourcesService;\n\n })(taiga.Service);\n\n urls = {\n \"auth\": \"/auth\",\n \"auth-register\": \"/auth/register\",\n \"invitations\": \"/invitations\",\n \"users\": \"/users\",\n \"by_username\": \"/users/by_username\",\n \"users-password-recovery\": \"/users/password_recovery\",\n \"users-change-password-from-recovery\": \"/users/change_password_from_recovery\",\n \"users-change-password\": \"/users/change_password\",\n \"users-change-email\": \"/users/change_email\",\n \"users-cancel-account\": \"/users/cancel\",\n \"user-stats\": \"/users/%s/stats\",\n \"user-liked\": \"/users/%s/liked\",\n \"user-voted\": \"/users/%s/voted\",\n \"user-watched\": \"/users/%s/watched\",\n \"user-contacts\": \"/users/%s/contacts\",\n \"permissions\": \"/permissions\",\n \"notify-policies\": \"/notify-policies\",\n \"user-storage\": \"/user-storage\",\n \"memberships\": \"/memberships\",\n \"bulk-create-memberships\": \"/memberships/bulk_create\",\n \"roles\": \"/roles\",\n \"permissions\": \"/permissions\",\n \"resolver\": \"/resolver\",\n \"projects\": \"/projects\",\n \"project-templates\": \"/project-templates\",\n \"project-modules\": \"/projects/%s/modules\",\n \"bulk-update-projects-order\": \"/projects/bulk_update_order\",\n \"project-like\": \"/projects/%s/like\",\n \"project-unlike\": \"/projects/%s/unlike\",\n \"project-watch\": \"/projects/%s/watch\",\n \"project-unwatch\": \"/projects/%s/unwatch\",\n \"userstory-statuses\": \"/userstory-statuses\",\n \"points\": \"/points\",\n \"task-statuses\": \"/task-statuses\",\n \"issue-statuses\": \"/issue-statuses\",\n \"issue-types\": \"/issue-types\",\n \"priorities\": \"/priorities\",\n \"severities\": \"/severities\",\n \"milestones\": \"/milestones\",\n \"userstories\": \"/userstories\",\n \"bulk-create-us\": \"/userstories/bulk_create\",\n \"bulk-update-us-backlog-order\": \"/userstories/bulk_update_backlog_order\",\n \"bulk-update-us-sprint-order\": \"/userstories/bulk_update_sprint_order\",\n \"bulk-update-us-kanban-order\": \"/userstories/bulk_update_kanban_order\",\n \"userstories-filters\": \"/userstories/filters_data\",\n \"userstory-upvote\": \"/userstories/%s/upvote\",\n \"userstory-downvote\": \"/userstories/%s/downvote\",\n \"userstory-watch\": \"/userstories/%s/watch\",\n \"userstory-unwatch\": \"/userstories/%s/unwatch\",\n \"tasks\": \"/tasks\",\n \"bulk-create-tasks\": \"/tasks/bulk_create\",\n \"bulk-update-task-taskboard-order\": \"/tasks/bulk_update_taskboard_order\",\n \"task-upvote\": \"/tasks/%s/upvote\",\n \"task-downvote\": \"/tasks/%s/downvote\",\n \"task-watch\": \"/tasks/%s/watch\",\n \"task-unwatch\": \"/tasks/%s/unwatch\",\n \"issues\": \"/issues\",\n \"bulk-create-issues\": \"/issues/bulk_create\",\n \"issues-filters\": \"/issues/filters_data\",\n \"issue-upvote\": \"/issues/%s/upvote\",\n \"issue-downvote\": \"/issues/%s/downvote\",\n \"issue-watch\": \"/issues/%s/watch\",\n \"issue-unwatch\": \"/issues/%s/unwatch\",\n \"wiki\": \"/wiki\",\n \"wiki-restore\": \"/wiki/%s/restore\",\n \"wiki-links\": \"/wiki-links\",\n \"history/us\": \"/history/userstory\",\n \"history/issue\": \"/history/issue\",\n \"history/task\": \"/history/task\",\n \"history/wiki\": \"/history/wiki\",\n \"attachments/us\": \"/userstories/attachments\",\n \"attachments/issue\": \"/issues/attachments\",\n \"attachments/task\": \"/tasks/attachments\",\n \"attachments/wiki_page\": \"/wiki/attachments\",\n \"custom-attributes/userstory\": \"/userstory-custom-attributes\",\n \"custom-attributes/issue\": \"/issue-custom-attributes\",\n \"custom-attributes/task\": \"/task-custom-attributes\",\n \"custom-attributes-values/userstory\": \"/userstories/custom-attributes-values\",\n \"custom-attributes-values/issue\": \"/issues/custom-attributes-values\",\n \"custom-attributes-values/task\": \"/tasks/custom-attributes-values\",\n \"webhooks\": \"/webhooks\",\n \"webhooks-test\": \"/webhooks/%s/test\",\n \"webhooklogs\": \"/webhooklogs\",\n \"webhooklogs-resend\": \"/webhooklogs/%s/resend\",\n \"userstories-csv\": \"/userstories/csv?uuid=%s\",\n \"tasks-csv\": \"/tasks/csv?uuid=%s\",\n \"issues-csv\": \"/issues/csv?uuid=%s\",\n \"timeline-profile\": \"/timeline/profile\",\n \"timeline-user\": \"/timeline/user\",\n \"timeline-project\": \"/timeline/project\",\n \"search\": \"/search\",\n \"exporter\": \"/exporter\",\n \"importer\": \"/importer/load_dump\",\n \"feedback\": \"/feedback\",\n \"locales\": \"/locales\",\n \"applications\": \"/applications\",\n \"application-tokens\": \"/application-tokens\",\n \"stats-discover\": \"/stats/discover\"\n };\n\n initUrls = function($log, $urls) {\n $log.debug(\"Initialize api urls\");\n return $urls.update(urls);\n };\n\n initResources = function($log, $rs) {\n var i, len, provider, providers, results;\n $log.debug(\"Initialize resources\");\n providers = _.toArray(arguments).slice(2);\n results = [];\n for (i = 0, len = providers.length; i < len; i++) {\n provider = providers[i];\n results.push(provider($rs));\n }\n return results;\n };\n\n module = angular.module(\"taigaResources\", [\"taigaBase\"]);\n\n module.service(\"$tgResources\", ResourcesService);\n\n module.run([\"$log\", \"$tgUrls\", initUrls]);\n\n module.run([\"$log\", \"$tgResources\", \"$tgProjectsResourcesProvider\", \"$tgCustomAttributesResourcesProvider\", \"$tgCustomAttributesValuesResourcesProvider\", \"$tgMembershipsResourcesProvider\", \"$tgNotifyPoliciesResourcesProvider\", \"$tgInvitationsResourcesProvider\", \"$tgRolesResourcesProvider\", \"$tgUserSettingsResourcesProvider\", \"$tgSprintsResourcesProvider\", \"$tgUserstoriesResourcesProvider\", \"$tgTasksResourcesProvider\", \"$tgIssuesResourcesProvider\", \"$tgWikiResourcesProvider\", \"$tgSearchResourcesProvider\", \"$tgMdRenderResourcesProvider\", \"$tgHistoryResourcesProvider\", \"$tgKanbanResourcesProvider\", \"$tgModulesResourcesProvider\", \"$tgWebhooksResourcesProvider\", \"$tgWebhookLogsResourcesProvider\", \"$tgLocalesResourcesProvider\", \"$tgUsersResourcesProvider\", initResources]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/search.coffee\n */\n\n(function() {\n var SearchBoxDirective, SearchController, SearchDirective, bindOnce, debounce, debounceLeading, groupBy, mixOf, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounceLeading = this.taiga.debounceLeading;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaSearch\", []);\n\n SearchController = (function(superClass) {\n extend(SearchController, superClass);\n\n SearchController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$translate\"];\n\n function SearchController(scope1, repo, rs, params, q, location, appMetaService, navUrls, translate) {\n var loadSearchData, promise;\n this.scope = scope1;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.translate = translate;\n this.scope.sectionName = \"Search\";\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"SEARCH.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"SEARCH.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.searchTerm = null;\n loadSearchData = debounceLeading(100, (function(_this) {\n return function(t) {\n return _this.loadSearchData(t);\n };\n })(this));\n bindOnce(this.scope, \"projectId\", (function(_this) {\n return function(projectId) {\n if (!_this.scope.searchResults && _this.scope.searchTerm) {\n return _this.loadSearchData();\n }\n };\n })(this));\n this.scope.$watch(\"searchTerm\", (function(_this) {\n return function(term) {\n if (term !== void 0 && _this.scope.projectId) {\n return _this.loadSearchData(term);\n }\n };\n })(this));\n }\n\n SearchController.prototype.loadFilters = function() {\n var defered;\n defered = this.q.defer();\n defered.resolve();\n return defered.promise;\n };\n\n SearchController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issueStatusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.taskStatusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n SearchController.prototype.loadSearchData = function(term) {\n if (term == null) {\n term = \"\";\n }\n this.scope.loading = true;\n return this._loadSearchData(term).then((function(_this) {\n return function(data) {\n _this.scope.searchResults = data;\n return _this.scope.loading = false;\n };\n })(this));\n };\n\n SearchController.prototype._loadSearchData = function(term) {\n if (term == null) {\n term = \"\";\n }\n if (this._promise) {\n this._promise.abort();\n }\n this._promise = this.rs.search[\"do\"](this.scope.projectId, term);\n return this._promise;\n };\n\n SearchController.prototype.loadInitialData = function() {\n return this.loadProject().then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n return _this.fillUsersAndRoles(project.members, project.roles);\n };\n })(this));\n };\n\n return SearchController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"SearchController\", SearchController);\n\n SearchBoxDirective = function(projectService, $lightboxService, $navurls, $location, $route) {\n var link;\n link = function($scope, $el, $attrs) {\n var openLightbox, project, submit;\n project = null;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var form, text, url;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n text = $el.find(\"#search-text\").val();\n url = $navurls.resolve(\"project-search\", {\n project: project.get(\"slug\")\n });\n return $scope.$apply(function() {\n $lightboxService.close($el);\n $location.path(url);\n $location.search(\"text\", text).path(url);\n return $route.reload();\n });\n };\n })(this));\n openLightbox = function() {\n project = projectService.project;\n return $lightboxService.open($el).then(function() {\n return $el.find(\"#search-text\").focus();\n });\n };\n $el.on(\"submit\", \"form\", submit);\n return openLightbox();\n };\n return {\n templateUrl: \"search/lightbox-search.html\",\n link: link\n };\n };\n\n SearchBoxDirective.$inject = [\"tgProjectService\", \"lightboxService\", \"$tgNavUrls\", \"$tgLocation\", \"$route\"];\n\n module.directive(\"tgSearchBox\", SearchBoxDirective);\n\n SearchDirective = function($log, $compile, $templatecache, $routeparams, $location) {\n var link, linkTable;\n linkTable = function($scope, $el, $attrs, $ctrl) {\n var activeSectionName, applyAutoTab, getActiveSection, lastSearchResults, markSectionTabActive, renderFilterTabs, renderTableContent, tabsDom, templates;\n applyAutoTab = true;\n activeSectionName = \"userstories\";\n tabsDom = $el.find(\".search-filter\");\n lastSearchResults = null;\n getActiveSection = function(data) {\n var i, len, maxVal, name, ref, selectedSection, value;\n maxVal = 0;\n selectedSection = {};\n selectedSection.name = \"userstories\";\n selectedSection.value = [];\n if (!applyAutoTab) {\n selectedSection.name = activeSectionName;\n selectedSection.value = data[activeSectionName];\n return selectedSection;\n }\n if (data) {\n ref = [\"userstories\", \"issues\", \"tasks\", \"wikipages\"];\n for (i = 0, len = ref.length; i < len; i++) {\n name = ref[i];\n value = data[name];\n if (value.length > maxVal) {\n maxVal = value.length;\n selectedSection.name = name;\n selectedSection.value = value;\n break;\n }\n }\n }\n if (maxVal === 0) {\n return selectedSection;\n }\n return selectedSection;\n };\n renderFilterTabs = function(data) {\n var name, results, value;\n results = [];\n for (name in data) {\n value = data[name];\n tabsDom.find(\"li.\" + name).show();\n results.push(tabsDom.find(\"li.\" + name + \" .num\").html(value.length));\n }\n return results;\n };\n markSectionTabActive = function(section) {\n tabsDom.find(\"a.active\").removeClass(\"active\");\n tabsDom.find(\"li.\" + section.name + \" a\").addClass(\"active\");\n applyAutoTab = false;\n return activeSectionName = section.name;\n };\n templates = {\n issues: $templatecache.get(\"search-issues\"),\n tasks: $templatecache.get(\"search-tasks\"),\n userstories: $templatecache.get(\"search-userstories\"),\n wikipages: $templatecache.get(\"search-wikipages\")\n };\n renderTableContent = function(section) {\n var element, oldElements, oldScope, scope, template;\n oldElements = $el.find(\".search-result-table\").children();\n oldScope = oldElements.scope();\n if (oldScope) {\n oldScope.$destroy();\n oldElements.remove();\n }\n scope = $scope.$new();\n scope[section.name] = section.value;\n template = angular.element.parseHTML(trim(templates[section.name]));\n element = $compile(template)(scope);\n return $el.find(\".search-result-table\").html(element);\n };\n $scope.$watch(\"searchResults\", function(data) {\n var activeSection;\n lastSearchResults = data;\n if (!lastSearchResults) {\n return;\n }\n activeSection = getActiveSection(data);\n renderFilterTabs(data);\n renderTableContent(activeSection);\n return markSectionTabActive(activeSection);\n });\n $scope.$watch(\"searchTerm\", function(searchTerm) {\n if (searchTerm !== void 0) {\n return $location.search(\"text\", searchTerm);\n }\n });\n return $el.on(\"click\", \".search-filter li > a\", function(event) {\n var section, sectionData, sectionName, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n sectionName = target.parent().data(\"name\");\n sectionData = !lastSearchResults ? [] : lastSearchResults[sectionName];\n section = {\n name: sectionName,\n value: sectionData\n };\n return $scope.$apply(function() {\n renderTableContent(section);\n return markSectionTabActive(section);\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, searchText;\n $ctrl = $el.controller();\n linkTable($scope, $el, $attrs, $ctrl);\n searchText = $routeparams.text;\n return $scope.$watch(\"projectId\", function(projectId) {\n if (projectId != null) {\n return $scope.searchTerm = searchText;\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSearch\", [\"$log\", \"$compile\", \"$templateCache\", \"$routeParams\", \"$tgLocation\", SearchDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTaskboard\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/tasks.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTasks\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/team.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTeam\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserSettings\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/userstories.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserStories\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaWiki\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/analytics.coffee\n */\n\n(function() {\n var AnalyticsService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n AnalyticsService = (function(superClass) {\n extend(AnalyticsService, superClass);\n\n AnalyticsService.$inject = [\"$rootScope\", \"$log\", \"$tgConfig\", \"$window\", \"$document\", \"$location\"];\n\n function AnalyticsService(rootscope, log, config, win, doc, location) {\n var conf;\n this.rootscope = rootscope;\n this.log = log;\n this.config = config;\n this.win = win;\n this.doc = doc;\n this.location = location;\n this.initialized = false;\n conf = this.config.get(\"analytics\", {});\n this.accountId = conf.accountId;\n this.pageEvent = conf.pageEvent || \"$routeChangeSuccess\";\n this.trackRoutes = conf.trackRoutes || true;\n this.ignoreFirstPageLoad = conf.ignoreFirstPageLoad || false;\n }\n\n AnalyticsService.prototype.initialize = function() {\n if (!this.accountId) {\n this.log.debug(\"Analytics: no acount id provided. Disabling.\");\n return;\n }\n this.injectAnalytics();\n this.win.ga(\"create\", this.accountId, \"auto\");\n this.win.ga(\"require\", \"displayfeatures\");\n if (this.trackRoutes && (!this.ignoreFirstPageLoad)) {\n this.win.ga(\"send\", \"pageview\", this.getUrl());\n }\n if (this.trackRoutes) {\n this.rootscope.$on(this.pageEvent, (function(_this) {\n return function() {\n return _this.trackPage(_this.getUrl(), \"Taiga\");\n };\n })(this));\n }\n return this.initialized = true;\n };\n\n AnalyticsService.prototype.getUrl = function() {\n return this.location.path();\n };\n\n AnalyticsService.prototype.injectAnalytics = function() {\n var fn;\n fn = (function(i,s,o,g,r,a,m){i[\"GoogleAnalyticsObject\"]=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);});\n return fn(window, document, \"script\", \"//www.google-analytics.com/analytics.js\", \"ga\");\n };\n\n AnalyticsService.prototype.trackPage = function(url, title) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n title = title || this.doc[0].title;\n return this.win.ga(\"send\", \"pageview\", {\n \"page\": url,\n \"title\": title\n });\n };\n\n AnalyticsService.prototype.trackEvent = function(category, action, label, value) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n return this.win.ga(\"send\", \"event\", category, action, label, value);\n };\n\n return AnalyticsService;\n\n })(taiga.Service);\n\n module.service(\"$tgAnalytics\", AnalyticsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: bind-scope.coffee\n */\n\n(function() {\n var BindScope, module;\n\n module = angular.module(\"taigaCommon\");\n\n BindScope = function(config) {\n var link;\n if (!config.debugInfo) {\n jQuery.fn.scope = function() {\n return this.data('scope');\n };\n }\n link = function($scope, $el) {\n if (!config.debugInfo) {\n return $el.data('scope', $scope).addClass('tg-scope');\n }\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBindScope\", [\"$tgConfig\", BindScope]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: compile-html.directive.coffee\n */\n\n(function() {\n var CompileHtmlDirective;\n\n CompileHtmlDirective = function($compile) {\n var link;\n link = function(scope, element, attrs) {\n return scope.$watch(attrs.tgCompileHtml, function(newValue, oldValue) {\n element.html(newValue);\n return $compile(element.contents())(scope);\n });\n };\n return {\n link: link\n };\n };\n\n CompileHtmlDirective.$inject = [\"$compile\"];\n\n angular.module(\"taigaCommon\").directive(\"tgCompileHtml\", CompileHtmlDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/components.coffee\n */\n\n(function() {\n var AssignedToDirective, BlockButtonDirective, CreatedByDisplayDirective, DateRangeDirective, DateSelectorDirective, DeleteButtonDirective, EditableDescriptionDirective, EditableSubjectDirective, EditableWysiwyg, ListItemAssignedtoDirective, ListItemIssueStatusDirective, ListItemPriorityDirective, ListItemSeverityDirective, ListItemTaskStatusDirective, ListItemTypeDirective, ListItemUsStatusDirective, SprintProgressBarDirective, TgMainTitleDirective, TgProgressBarDirective, WatchersDirective, bindOnce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n DateRangeDirective = function($translate) {\n var link, renderRange;\n renderRange = function($el, first, second) {\n var endDate, initDate, prettyDate;\n prettyDate = $translate.instant(\"BACKLOG.SPRINTS.DATE\");\n initDate = moment(first).format(prettyDate);\n endDate = moment(second).format(prettyDate);\n return $el.html(initDate + \"-\" + endDate);\n };\n link = function($scope, $el, $attrs) {\n var first, ref, second;\n ref = $attrs.tgDateRange.split(\",\"), first = ref[0], second = ref[1];\n return bindOnce($scope, first, function(valFirst) {\n return bindOnce($scope, second, function(valSecond) {\n return renderRange($el, valFirst, valSecond);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgDateRange\", [\"$translate\", DateRangeDirective]);\n\n DateSelectorDirective = function($rootscope, datePickerConfigService) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var initialize, selectedDate, unbind;\n selectedDate = null;\n initialize = function() {\n var datePickerConfig;\n datePickerConfig = datePickerConfigService.get();\n _.merge(datePickerConfig, {\n field: $el[0],\n onSelect: (function(_this) {\n return function(date) {\n return selectedDate = date;\n };\n })(this),\n onOpen: (function(_this) {\n return function() {\n if (selectedDate != null) {\n return $el.picker.setDate(selectedDate);\n }\n };\n })(this)\n });\n return $el.picker = new Pikaday(datePickerConfig);\n };\n unbind = $rootscope.$on(\"$translateChangeEnd\", (function(_this) {\n return function(ctx) {\n return initialize();\n };\n })(this));\n $scope.$watch($attrs.ngModel, function(val) {\n if ((val != null) && !$el.picker) {\n initialize();\n }\n if (val != null) {\n return $el.picker.setDate(val);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return unbind();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgDateSelector\", [\"$rootScope\", \"tgDatePickerConfigService\", DateSelectorDirective]);\n\n SprintProgressBarDirective = function() {\n var link, renderProgress;\n renderProgress = function($el, percentage, visual_percentage) {\n if ($el.hasClass(\".current-progress\")) {\n return $el.css(\"width\", percentage + \"%\");\n } else {\n $el.find(\".current-progress\").css(\"width\", visual_percentage + \"%\");\n return $el.find(\".number\").html(percentage + \" %\");\n }\n };\n link = function($scope, $el, $attrs) {\n bindOnce($scope, $attrs.tgSprintProgressbar, function(sprint) {\n var closedPoints, percentage, totalPoints, visual_percentage;\n closedPoints = sprint.closed_points;\n totalPoints = sprint.total_points;\n percentage = 0;\n if (totalPoints !== 0) {\n percentage = Math.round(100 * (closedPoints / totalPoints));\n }\n visual_percentage = 0;\n if (totalPoints !== 0) {\n visual_percentage = Math.round(98 * (closedPoints / totalPoints));\n }\n return renderProgress($el, percentage, visual_percentage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSprintProgressbar\", SprintProgressBarDirective);\n\n CreatedByDisplayDirective = function($template, $compile, $translate, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, $attrs.ngModel, function(model) {\n var ref;\n if (model != null) {\n $scope.owner = model.owner_extra_info || {\n full_name_display: $translate.instant(\"COMMON.EXTERNAL_USER\"),\n photo: \"/\" + window._version + \"/images/user-noimage.png\"\n };\n $scope.url = ((ref = $scope.owner) != null ? ref.is_active : void 0) ? $navUrls.resolve(\"user-profile\", {\n username: $scope.owner.username\n }) : \"\";\n return $scope.date = moment(model.created_date).format($translate.instant(\"COMMON.DATETIME\"));\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n scope: true,\n templateUrl: \"common/components/created-by.html\"\n };\n };\n\n module.directive(\"tgCreatedByDisplay\", [\"$tgTemplate\", \"$compile\", \"$translate\", \"$tgNavUrls\", CreatedByDisplayDirective]);\n\n WatchersDirective = function($rootscope, $confirm, $repo, $qqueue, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"common/components/watchers.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var deleteWatcher, isEditable, renderWatchers, save;\n isEditable = function() {\n var ref, ref1;\n return ((ref = $scope.project) != null ? (ref1 = ref.my_permissions) != null ? ref1.indexOf($attrs.requiredPerm) : void 0 : void 0) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(watchers) {\n var item, promise;\n item = $model.$modelValue.clone();\n item.watchers = watchers;\n $model.$setViewValue(item);\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n watchers = _.map(watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n renderWatchers(watchers);\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n $model.$modelValue.revert();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n deleteWatcher = $qqueue.bindAdd((function(_this) {\n return function(watcherIds) {\n var item, promise;\n item = $model.$modelValue.clone();\n item.watchers = watcherIds;\n $model.$setViewValue(item);\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n var watchers;\n watchers = _.map(item.watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n renderWatchers(watchers);\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n item.revert();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n renderWatchers = function(watchers) {\n var ctx, html;\n ctx = {\n watchers: watchers,\n isEditable: isEditable()\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n $el.on(\"click\", \".js-delete-watcher\", function(event) {\n var message, target, title, watcherId;\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n watcherId = target.data(\"watcher-id\");\n title = $translate.instant(\"COMMON.WATCHERS.TITLE_LIGHTBOX_DELETE_WARTCHER\");\n message = $scope.usersById[watcherId].full_name_display;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var watcherIds;\n askResponse.finish();\n watcherIds = _.clone($model.$modelValue.watchers, false);\n watcherIds = _.pull(watcherIds, watcherId);\n return deleteWatcher(watcherIds);\n };\n })(this));\n });\n $scope.$on(\"watcher:added\", function(ctx, watcherId) {\n var watchers;\n watchers = _.clone($model.$modelValue.watchers, false);\n watchers.push(watcherId);\n watchers = _.uniq(watchers);\n return save(watchers);\n });\n $scope.$watch($attrs.ngModel, function(item) {\n var watchers;\n if (item == null) {\n return;\n }\n watchers = _.map(item.watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n return renderWatchers(watchers);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgWatchers\", [\"$rootScope\", \"$tgConfirm\", \"$tgRepo\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", \"$translate\", WatchersDirective]);\n\n AssignedToDirective = function($rootscope, $confirm, $repo, $loading, $qqueue, $template, $translate, $compile, $currentUserService) {\n var link, template;\n template = $template.get(\"common/components/assigned-to.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, renderAssignedTo, save;\n isEditable = function() {\n var ref, ref1;\n return ((ref = $scope.project) != null ? (ref1 = ref.my_permissions) != null ? ref1.indexOf($attrs.requiredPerm) : void 0 : void 0) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(userId) {\n var currentLoading, promise;\n $model.$modelValue.assigned_to = userId;\n currentLoading = $loading().target($el).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n currentLoading.finish();\n renderAssignedTo($model.$modelValue);\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n $model.$modelValue.revert();\n $confirm.notify(\"error\");\n return currentLoading.finish();\n });\n return promise;\n };\n })(this));\n renderAssignedTo = function(assignedObject) {\n var ctx, fullName, html, isIocaine, isUnassigned, photo;\n if ((assignedObject != null ? assignedObject.assigned_to : void 0) != null) {\n fullName = assignedObject.assigned_to_extra_info.full_name_display;\n photo = assignedObject.assigned_to_extra_info.photo;\n isUnassigned = false;\n } else {\n fullName = $translate.instant(\"COMMON.ASSIGNED_TO.ASSIGN\");\n photo = \"/\" + window._version + \"/images/unnamed.png\";\n isUnassigned = true;\n }\n isIocaine = assignedObject != null ? assignedObject.is_iocaine : void 0;\n ctx = {\n fullName: fullName,\n photo: photo,\n isUnassigned: isUnassigned,\n isEditable: isEditable(),\n isIocaine: isIocaine\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n $el.on(\"click\", \".user-assigned\", function(event) {\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n return $scope.$apply(function() {\n return $rootscope.$broadcast(\"assigned-to:add\", $model.$modelValue);\n });\n });\n $el.on(\"click\", \".assign-to-me\", function(event) {\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n $model.$modelValue.assigned_to = $currentUserService.getUser().get('id');\n return save($currentUserService.getUser().get('id'));\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var title;\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n title = $translate.instant(\"COMMON.ASSIGNED_TO.CONFIRM_UNASSIGNED\");\n return $confirm.ask(title).then((function(_this) {\n return function(response) {\n response.finish();\n $model.$modelValue.assigned_to = null;\n return save(null);\n };\n })(this));\n });\n $scope.$on(\"assigned-to:added\", function(ctx, userId, item) {\n if (item.id !== $model.$modelValue.id) {\n return;\n }\n return save(userId);\n });\n $scope.$watch($attrs.ngModel, function(instance) {\n return renderAssignedTo(instance);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgAssignedTo\", [\"$rootScope\", \"$tgConfirm\", \"$tgRepo\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$translate\", \"$compile\", \"tgCurrentUserService\", AssignedToDirective]);\n\n BlockButtonDirective = function($rootscope, $loading, $template) {\n var link, template;\n template = $template.get(\"common/components/block-button.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n $scope.$watch($attrs.ngModel, function(item) {\n if (!item) {\n return;\n }\n if (isEditable()) {\n $el.find('.item-block').addClass('editable');\n }\n if (item.is_blocked) {\n $el.find('.item-block').removeClass('is-active');\n return $el.find('.item-unblock').addClass('is-active');\n } else {\n $el.find('.item-block').addClass('is-active');\n return $el.find('.item-unblock').removeClass('is-active');\n }\n });\n $el.on(\"click\", \".item-block\", function(event) {\n event.preventDefault();\n return $rootscope.$broadcast(\"block\", $model.$modelValue);\n });\n $el.on(\"click\", \".item-unblock\", function(event) {\n var currentLoading, finish;\n event.preventDefault();\n currentLoading = $loading().target($el.find(\".item-unblock\")).start();\n finish = function() {\n return currentLoading.finish();\n };\n return $rootscope.$broadcast(\"unblock\", $model.$modelValue, finish);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgBlockButton\", [\"$rootScope\", \"$tgLoading\", \"$tgTemplate\", BlockButtonDirective]);\n\n DeleteButtonDirective = function($log, $repo, $confirm, $location, $template) {\n var link, template;\n template = $template.get(\"common/components/delete-button.html\");\n link = function($scope, $el, $attrs, $model) {\n if (!$attrs.onDeleteGoToUrl) {\n return $log.error(\"DeleteButtonDirective requires on-delete-go-to-url set in scope.\");\n }\n if (!$attrs.onDeleteTitle) {\n return $log.error(\"DeleteButtonDirective requires on-delete-title set in scope.\");\n }\n $el.on(\"click\", \".button-delete\", function(event) {\n var subtitle, title;\n title = $attrs.onDeleteTitle;\n subtitle = $model.$modelValue.subject;\n return $confirm.askOnDelete(title, subtitle).then((function(_this) {\n return function(askResponse) {\n var promise;\n promise = $repo.remove($model.$modelValue);\n promise.then(function() {\n var url;\n askResponse.finish();\n url = $scope.$eval($attrs.onDeleteGoToUrl);\n return $location.path(url);\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgDeleteButton\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"$tgTemplate\", DeleteButtonDirective]);\n\n EditableSubjectDirective = function($rootscope, $repo, $confirm, $loading, $qqueue, $template) {\n var link, template;\n template = $template.get(\"common/components/editable-subject.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, save;\n $scope.$on(\"object:updated\", function() {\n $el.find('.edit-subject').hide();\n return $el.find('.view-subject').show();\n });\n isEditable = function() {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(subject) {\n var currentLoading, promise;\n $model.$modelValue.subject = subject;\n currentLoading = $loading().target($el.find('.save-container')).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $el.find('.edit-subject').hide();\n return $el.find('.view-subject').show();\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n return promise;\n };\n })(this));\n $el.click(function() {\n if (!isEditable()) {\n return;\n }\n $el.find('.edit-subject').show();\n $el.find('.view-subject').hide();\n return $el.find('input').focus();\n });\n $el.on(\"click\", \".save\", function(e) {\n var subject;\n e.preventDefault();\n subject = $scope.item.subject;\n return save(subject);\n });\n $el.on(\"keyup\", \"input\", function(event) {\n var subject;\n if (event.keyCode === 13) {\n subject = $scope.item.subject;\n return save(subject);\n } else if (event.keyCode === 27) {\n $scope.$apply((function(_this) {\n return function() {\n return $model.$modelValue.revert();\n };\n })(this));\n $el.find('div.edit-subject').hide();\n return $el.find('div.view-subject').show();\n }\n });\n $el.find('div.edit-subject').hide();\n $el.find('div.view-subject span.edit').hide();\n $scope.$watch($attrs.ngModel, function(value) {\n if (!value) {\n return;\n }\n $scope.item = value;\n if (!isEditable()) {\n return $el.find('.view-subject .edit').remove();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgEditableSubject\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", EditableSubjectDirective]);\n\n EditableDescriptionDirective = function($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) {\n var link, noDescriptionMegEditMode, noDescriptionMegReadMode, template;\n template = $template.get(\"common/components/editable-description.html\");\n noDescriptionMegEditMode = $template.get(\"common/components/editable-description-msg-edit-mode.html\");\n noDescriptionMegReadMode = $template.get(\"common/components/editable-description-msg-read-mode.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, save;\n $el.find('.edit-description').hide();\n $el.find('.view-description .edit').hide();\n $scope.$on(\"object:updated\", function() {\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n });\n isEditable = function() {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(description) {\n var currentLoading, promise;\n $model.$modelValue.description = description;\n currentLoading = $loading().target($el.find('.save-container')).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n })(this));\n $el.on(\"mouseup\", \".view-description\", function(event) {\n var target;\n target = angular.element(event.target);\n if (!isEditable()) {\n return;\n }\n if (target.is('a')) {\n return;\n }\n if ($selectedText.get().length) {\n return;\n }\n $el.find('.edit-description').show();\n $el.find('.view-description').hide();\n return $el.find('textarea').focus();\n });\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"click\", \".save\", function(e) {\n var description;\n e.preventDefault();\n description = $scope.item.description;\n return save(description);\n });\n $el.on(\"keydown\", \"textarea\", function(event) {\n if (event.keyCode === 27) {\n $scope.$apply((function(_this) {\n return function() {\n return $scope.item.revert();\n };\n })(this));\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n }\n });\n $scope.$watch($attrs.ngModel, function(value) {\n if (!value) {\n return;\n }\n $scope.item = value;\n if (isEditable()) {\n $el.find('.view-description .edit').show();\n $el.find('.view-description .us-content').addClass('editable');\n return $scope.noDescriptionMsg = $compile(noDescriptionMegEditMode)($scope);\n } else {\n return $scope.noDescriptionMsg = $compile(noDescriptionMegReadMode)($scope);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgEditableDescription\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$compile\", \"$tgLoading\", \"$selectedText\", \"$tgQqueue\", \"$tgTemplate\", EditableDescriptionDirective]);\n\n EditableWysiwyg = function(attachmentsService, attachmentsFullService) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var isInEditMode, uploadFile;\n isInEditMode = function() {\n return $el.find('textarea').is(':visible');\n };\n uploadFile = function(file, type) {\n if (!attachmentsService.validate(file)) {\n return;\n }\n return attachmentsFullService.addAttachment($model.$modelValue.project, $model.$modelValue.id, type, file).then(function(result) {\n if (taiga.isImage(result.getIn(['file', 'name']))) {\n return '![' + result.getIn(['file', 'name']) + '](' + result.getIn(['file', 'url']) + ')';\n } else {\n return '[' + result.getIn(['file', 'name']) + '](' + result.getIn(['file', 'url']) + ')';\n }\n });\n };\n $el.on('dragover', function(e) {\n var textarea;\n textarea = $el.find('textarea').focus();\n return false;\n });\n return $el.on('drop', function(e) {\n var dataTransfer, promises, textarea, type;\n e.stopPropagation();\n e.preventDefault();\n if (isInEditMode()) {\n dataTransfer = e.dataTransfer || (e.originalEvent && e.originalEvent.dataTransfer);\n textarea = $el.find('textarea');\n textarea.addClass('in-progress');\n type = $model.$modelValue['_name'];\n if (type === \"userstories\") {\n type = \"us\";\n } else if (type === \"tasks\") {\n type = \"task\";\n } else if (type === \"issues\") {\n type = \"issue\";\n } else if (type === \"wiki\") {\n type = \"wiki_page\";\n }\n promises = _.map(dataTransfer.files, function(file) {\n return uploadFile(file, type);\n });\n return Promise.all(promises).then(function(result) {\n textarea = $el.find('textarea');\n $.markItUp({\n replaceWith: result.join(' ')\n });\n return textarea.removeClass('in-progress');\n });\n }\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgEditableWysiwyg\", [\"tgAttachmentsService\", \"tgAttachmentsFullService\", EditableWysiwyg]);\n\n ListItemUsStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var us;\n us = $scope.$eval($attrs.tgListitemUsStatus);\n return bindOnce($scope, \"usStatusById\", function(usStatusById) {\n return $el.html(usStatusById[us.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemUsStatus\", ListItemUsStatusDirective);\n\n ListItemTaskStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var task;\n task = $scope.$eval($attrs.tgListitemTaskStatus);\n return bindOnce($scope, \"taskStatusById\", function(taskStatusById) {\n return $el.html(taskStatusById[task.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemTaskStatus\", ListItemTaskStatusDirective);\n\n ListItemAssignedtoDirective = function($template, $translate) {\n var link, template;\n template = $template.get(\"common/components/list-item-assigned-to-avatar.html\", true);\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, \"usersById\", function(usersById) {\n var ctx, item, member;\n item = $scope.$eval($attrs.tgListitemAssignedto);\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = usersById[item.assigned_to];\n if (member) {\n ctx.imgurl = member.photo;\n ctx.name = member.full_name_display;\n }\n return $el.html(template(ctx));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemAssignedto\", [\"$tgTemplate\", \"$translate\", ListItemAssignedtoDirective]);\n\n ListItemIssueStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemIssueStatus);\n return bindOnce($scope, \"issueStatusById\", function(issueStatusById) {\n return $el.html(issueStatusById[issue.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemIssueStatus\", ListItemIssueStatusDirective);\n\n ListItemTypeDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(issueTypeById, issue) {\n var domNode, type;\n type = issueTypeById[issue.type];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", type.color);\n return domNode.attr(\"title\", type.name);\n };\n bindOnce($scope, \"issueTypeById\", function(issueTypeById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemType);\n return render(issueTypeById, issue);\n });\n return $scope.$watch($attrs.tgListitemType, function(issue) {\n return render($scope.issueTypeById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemType\", ListItemTypeDirective);\n\n ListItemPriorityDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(priorityById, issue) {\n var domNode, priority;\n priority = priorityById[issue.priority];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", priority.color);\n return domNode.attr(\"title\", priority.name);\n };\n bindOnce($scope, \"priorityById\", function(priorityById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemPriority);\n return render(priorityById, issue);\n });\n return $scope.$watch($attrs.tgListitemPriority, function(issue) {\n return render($scope.priorityById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemPriority\", ListItemPriorityDirective);\n\n ListItemSeverityDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(severityById, issue) {\n var domNode, severity;\n severity = severityById[issue.severity];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", severity.color);\n return domNode.attr(\"title\", severity.name);\n };\n bindOnce($scope, \"severityById\", function(severityById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemSeverity);\n return render(severityById, issue);\n });\n return $scope.$watch($attrs.tgListitemSeverity, function(issue) {\n return render($scope.severityById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemSeverity\", ListItemSeverityDirective);\n\n TgProgressBarDirective = function($template) {\n var link, render, template;\n template = $template.get(\"common/components/progress-bar.html\", true);\n render = function(el, percentage) {\n return el.html(template({\n percentage: percentage\n }));\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch($attrs.tgProgressBar, function(percentage) {\n percentage = _.max([0, percentage]);\n percentage = _.min([100, percentage]);\n return render($el, percentage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProgressBar\", [\"$tgTemplate\", TgProgressBarDirective]);\n\n TgMainTitleDirective = function($translate) {\n var link;\n link = function($scope, $el, $attrs) {\n $attrs.$observe(\"i18nSectionName\", function(i18nSectionName) {\n return $scope.sectionName = i18nSectionName;\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/main-title.html\",\n scope: {\n projectName: \"=projectName\"\n }\n };\n };\n\n module.directive(\"tgMainTitle\", [\"$translate\", TgMainTitleDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/confirm.coffee\n */\n\n(function() {\n var ConfirmService, NOTIFICATION_MSG, bindMethods, cancelTimeout, debounce, module, taiga, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n timeout = this.taiga.timeout;\n\n cancelTimeout = this.taiga.cancelTimeout;\n\n debounce = this.taiga.debounce;\n\n bindMethods = this.taiga.bindMethods;\n\n NOTIFICATION_MSG = {\n \"success\": {\n title: \"NOTIFICATION.OK\",\n message: \"NOTIFICATION.SAVED\"\n },\n \"error\": {\n title: \"NOTIFICATION.WARNING\",\n message: \"NOTIFICATION.WARNING_TEXT\"\n },\n \"light-error\": {\n title: \"NOTIFICATION.WARNING\",\n message: \"NOTIFICATION.WARNING_TEXT\"\n }\n };\n\n ConfirmService = (function(superClass) {\n extend(ConfirmService, superClass);\n\n ConfirmService.$inject = [\"$q\", \"lightboxService\", \"$tgLoading\", \"$translate\"];\n\n function ConfirmService(q, lightboxService, loading, translate) {\n this.q = q;\n this.lightboxService = lightboxService;\n this.loading = loading;\n this.translate = translate;\n bindMethods(this);\n }\n\n ConfirmService.prototype.hide = function(el) {\n if (el) {\n this.lightboxService.close(el);\n return el.off(\".confirm-dialog\");\n }\n };\n\n ConfirmService.prototype.ask = function(title, subtitle, message, lightboxSelector) {\n var defered, el;\n if (lightboxSelector == null) {\n lightboxSelector = \".lightbox-generic-ask\";\n }\n defered = this.q.defer();\n el = angular.element(lightboxSelector);\n el.find(\"h2.title\").text(title);\n el.find(\"span.subtitle\").text(subtitle);\n el.find(\"span.message\").text(message);\n el.on(\"click.confirm-dialog\", \"a.button-green\", debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n currentLoading = _this.loading().target(target).start();\n return defered.resolve({\n finish: function(ok) {\n if (ok == null) {\n ok = true;\n }\n currentLoading.finish();\n if (ok) {\n return _this.hide(el);\n }\n }\n });\n };\n })(this)));\n el.on(\"click.confirm-dialog\", \"a.button-red\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.reject();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.askOnDelete = function(title, message) {\n return this.ask(title, this.translate.instant(\"NOTIFICATION.ASK_DELETE\"), message);\n };\n\n ConfirmService.prototype.askChoice = function(title, subtitle, choices, replacement, warning, lightboxSelector) {\n var choicesField, defered, el;\n if (lightboxSelector == null) {\n lightboxSelector = \".lightbox-ask-choice\";\n }\n defered = this.q.defer();\n el = angular.element(lightboxSelector);\n el.find(\".title\").text(title);\n el.find(\".subtitle\").text(subtitle);\n if (replacement) {\n el.find(\".replacement\").text(replacement);\n } else {\n el.find(\".replacement\").remove();\n }\n if (warning) {\n el.find(\".warning\").text(warning);\n } else {\n el.find(\".warning\").remove();\n }\n choicesField = el.find(\".choices\");\n choicesField.html('');\n _.each(choices, function(value, key) {\n value = _.escape(value);\n return choicesField.append(angular.element(\"\"));\n });\n el.on(\"click.confirm-dialog\", \"a.button-green\", debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n currentLoading = _this.loading().target(target).start();\n return defered.resolve({\n selected: choicesField.val(),\n finish: function(ok) {\n if (ok == null) {\n ok = true;\n }\n currentLoading.finish();\n if (ok) {\n return _this.hide(el);\n }\n }\n });\n };\n })(this)));\n el.on(\"click.confirm-dialog\", \"a.button-red\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.reject();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.error = function(message) {\n var defered, el;\n defered = this.q.defer();\n el = angular.element(\".lightbox-generic-error\");\n el.find(\"h2.title\").html(message);\n el.on(\"click.confirm-dialog\", \"a.button-green\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n el.on(\"click.confirm-dialog\", \"a.close\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.success = function(title, message) {\n var defered, el;\n defered = this.q.defer();\n el = angular.element(\".lightbox-generic-success\");\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n el.on(\"click.confirm-dialog\", \"a.button-green\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n el.on(\"click.confirm-dialog\", \"a.close\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.loader = function(title, message) {\n var el;\n el = angular.element(\".lightbox-generic-loading\");\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n return {\n start: (function(_this) {\n return function() {\n return _this.lightboxService.open(el);\n };\n })(this),\n stop: (function(_this) {\n return function() {\n return _this.lightboxService.close(el);\n };\n })(this),\n update: (function(_this) {\n return function(status, title, message, percent) {\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n if (percent) {\n el.find(\".spin\").addClass(\"hidden\");\n el.find(\".progress-bar-wrapper\").removeClass(\"hidden\");\n el.find(\".progress-bar-wrapper > .bar\").width(percent + '%');\n return el.find(\".progress-bar-wrapper > span\").html(percent + '%').css('left', (percent - 9) + '%');\n } else {\n el.find(\".spin\").removeClass(\"hidden\");\n return el.find(\".progress-bar-wrapper\").addClass(\"hidden\");\n }\n };\n })(this)\n };\n };\n\n ConfirmService.prototype.notify = function(type, message, title, time) {\n var body, el, selector;\n selector = \".notification-message-\" + type;\n el = angular.element(selector);\n if (el.hasClass(\"active\")) {\n return;\n }\n if (title) {\n el.find(\"h4\").html(title);\n } else {\n el.find(\"h4\").html(this.translate.instant(NOTIFICATION_MSG[type].title));\n }\n if (message) {\n el.find(\"p\").html(message);\n } else {\n el.find(\"p\").html(this.translate.instant(NOTIFICATION_MSG[type].message));\n }\n body = angular.element(\"body\");\n body.find(\".notification-message .notification-light\").removeClass('active').addClass('inactive');\n body.find(selector).removeClass('inactive').addClass('active');\n if (this.tsem) {\n cancelTimeout(this.tsem);\n }\n if (!time) {\n time = type === 'error' || type === 'light-error' ? 3500 : 1500;\n }\n this.tsem = timeout(time, (function(_this) {\n return function() {\n body.find(selector).removeClass('active').addClass('inactive');\n return delete _this.tsem;\n };\n })(this));\n return el.on(\"click\", \".icon-delete, .close\", (function(_this) {\n return function(event) {\n return body.find(selector).removeClass('active').addClass('inactive');\n };\n })(this));\n };\n\n return ConfirmService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaCommon\");\n\n module.service(\"$tgConfirm\", ConfirmService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/custom-field-values.coffee\n */\n\n(function() {\n var CustomAttributeValueDirective, CustomAttributesValuesController, CustomAttributesValuesDirective, DATE_TYPE, MULTILINE_TYPE, TEXT_TYPE, TYPE_CHOICES, bindMethods, bindOnce, debounce, generateHash, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n bindMethods = this.taiga.bindMethods;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n generateHash = taiga.generateHash;\n\n module = angular.module(\"taigaCommon\");\n\n TEXT_TYPE = \"text\";\n\n MULTILINE_TYPE = \"multiline\";\n\n DATE_TYPE = \"date\";\n\n TYPE_CHOICES = [\n {\n key: TEXT_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT\"\n }, {\n key: MULTILINE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI\"\n }, {\n key: DATE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE\"\n }\n ];\n\n CustomAttributesValuesController = (function(superClass) {\n extend(CustomAttributesValuesController, superClass);\n\n CustomAttributesValuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$q\"];\n\n function CustomAttributesValuesController(scope, rootscope, repo, rs, confirm, q) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.confirm = confirm;\n this.q = q;\n bindMethods(this);\n this.type = null;\n this.objectId = null;\n this.projectId = null;\n this.customAttributes = [];\n this.customAttributesValues = null;\n }\n\n CustomAttributesValuesController.prototype.initialize = function(type, objectId) {\n this.project = this.scope.project;\n this.type = type;\n this.objectId = objectId;\n return this.projectId = this.scope.projectId;\n };\n\n CustomAttributesValuesController.prototype.loadCustomAttributesValues = function() {\n if (!this.objectId) {\n return this.customAttributesValues;\n }\n return this.rs.customAttributesValues[this.type].get(this.objectId).then((function(_this) {\n return function(customAttributesValues) {\n _this.customAttributes = _this.project[_this.type + \"_custom_attributes\"];\n _this.customAttributesValues = customAttributesValues;\n return customAttributesValues;\n };\n })(this));\n };\n\n CustomAttributesValuesController.prototype.getAttributeValue = function(attribute) {\n var attributeValue;\n attributeValue = _.clone(attribute, false);\n attributeValue.value = this.customAttributesValues.attributes_values[attribute.id];\n return attributeValue;\n };\n\n CustomAttributesValuesController.prototype.updateAttributeValue = function(attributeValue) {\n var attributesValues, onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"custom-attributes-values:edit\");\n };\n })(this);\n onError = (function(_this) {\n return function(response) {\n _this.confirm.notify(\"error\");\n return _this.q.reject();\n };\n })(this);\n attributesValues = _.clone(this.customAttributesValues.attributes_values, true);\n attributesValues[attributeValue.id] = attributeValue.value;\n this.customAttributesValues.attributes_values = attributesValues;\n this.customAttributesValues.id = this.objectId;\n return this.repo.save(this.customAttributesValues).then(onSuccess, onError);\n };\n\n return CustomAttributesValuesController;\n\n })(taiga.Controller);\n\n CustomAttributesValuesDirective = function($templates, $storage) {\n var collapsedHash, link, template, templateFn;\n template = $templates.get(\"custom-attributes/custom-attributes-values.html\", true);\n collapsedHash = function(type) {\n return generateHash([\"custom-attributes-collapsed\", type]);\n };\n link = function($scope, $el, $attrs, $ctrls) {\n var $ctrl, $model;\n $ctrl = $ctrls[0];\n $model = $ctrls[1];\n bindOnce($scope, $attrs.ngModel, function(value) {\n $ctrl.initialize($attrs.type, value.id);\n return $ctrl.loadCustomAttributesValues();\n });\n $el.on(\"click\", \".custom-fields-header a\", function() {\n var collapsed, hash;\n hash = collapsedHash($attrs.type);\n collapsed = !($storage.get(hash) || false);\n $storage.set(hash, collapsed);\n if (collapsed) {\n $el.find(\".custom-fields-header a\").removeClass(\"open\");\n return $el.find(\".custom-fields-body\").removeClass(\"open\");\n } else {\n $el.find(\".custom-fields-header a\").addClass(\"open\");\n return $el.find(\".custom-fields-body\").addClass(\"open\");\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n templateFn = function($el, $attrs) {\n var collapsed;\n collapsed = $storage.get(collapsedHash($attrs.type)) || false;\n return template({\n requiredEditionPerm: $attrs.requiredEditionPerm,\n collapsed: collapsed\n });\n };\n return {\n require: [\"tgCustomAttributesValues\", \"ngModel\"],\n controller: CustomAttributesValuesController,\n controllerAs: \"ctrl\",\n restrict: \"AE\",\n scope: true,\n link: link,\n template: templateFn\n };\n };\n\n module.directive(\"tgCustomAttributesValues\", [\"$tgTemplate\", \"$tgStorage\", \"$translate\", CustomAttributesValuesDirective]);\n\n CustomAttributeValueDirective = function($template, $selectedText, $compile, $translate, datePickerConfigService) {\n var link, template, templateEdit;\n template = $template.get(\"custom-attributes/custom-attribute-value.html\", true);\n templateEdit = $template.get(\"custom-attributes/custom-attribute-value-edit.html\", true);\n link = function($scope, $el, $attrs, $ctrl) {\n var attributeValue, isEditable, prettyDate, render, setFocusAndSelectOnInputField, submit;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n render = function(attributeValue, edit) {\n var ctx, datePickerConfig, editable, html, value;\n if (edit == null) {\n edit = false;\n }\n if (attributeValue.type === DATE_TYPE && attributeValue.value) {\n value = moment(attributeValue.value, \"YYYY-MM-DD\").format(prettyDate);\n } else {\n value = attributeValue.value;\n }\n editable = isEditable();\n ctx = {\n id: attributeValue.id,\n name: attributeValue.name,\n description: attributeValue.description,\n value: value,\n isEditable: editable,\n type: attributeValue.type\n };\n if (editable && (edit || !value)) {\n html = templateEdit(ctx);\n html = $compile(html)($scope);\n $el.html(html);\n if (attributeValue.type === DATE_TYPE) {\n datePickerConfig = datePickerConfigService.get();\n _.merge(datePickerConfig, {\n field: $el.find(\"input[name=value]\")[0],\n onSelect: (function(_this) {\n return function(date) {\n var selectedDate;\n return selectedDate = date;\n };\n })(this),\n onOpen: (function(_this) {\n return function() {\n if (typeof selectedDate !== \"undefined\" && selectedDate !== null) {\n return $el.picker.setDate(selectedDate);\n }\n };\n })(this)\n });\n return $el.picker = new Pikaday(datePickerConfig);\n }\n } else {\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n }\n };\n isEditable = function() {\n var permissions, requiredEditionPerm;\n permissions = $scope.project.my_permissions;\n requiredEditionPerm = $attrs.requiredEditionPerm;\n return permissions.indexOf(requiredEditionPerm) > -1;\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n attributeValue.value = $el.find(\"input[name=value], textarea[name='value']\").val();\n if (attributeValue.type === DATE_TYPE) {\n if (moment(attributeValue.value, prettyDate).isValid()) {\n attributeValue.value = moment(attributeValue.value, prettyDate).format(\"YYYY-MM-DD\");\n } else {\n attributeValue.value = \"\";\n }\n }\n return $scope.$apply(function() {\n return $ctrl.updateAttributeValue(attributeValue).then(function() {\n return render(attributeValue, false);\n });\n });\n };\n })(this));\n setFocusAndSelectOnInputField = function() {\n return $el.find(\"input[name='value'], textarea[name='value']\").focus().select();\n };\n attributeValue = $scope.$eval($attrs.tgCustomAttributeValue);\n render(attributeValue);\n $el.on(\"click\", \".js-value-view-mode\", function() {\n if (!isEditable()) {\n return;\n }\n if ($selectedText.get().length) {\n return;\n }\n render(attributeValue, true);\n return setFocusAndSelectOnInputField();\n });\n $el.on(\"click\", \"a.icon-edit\", function(event) {\n event.preventDefault();\n render(attributeValue, true);\n return setFocusAndSelectOnInputField();\n });\n $el.on(\"keyup\", \"input[name=value], textarea[name='value']\", function(event) {\n if (event.keyCode === 13 && event.currentTarget.type !== \"textarea\") {\n return submit(event);\n } else if (event.keyCode === 27) {\n return render(attributeValue, false);\n }\n });\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \"a.icon-floppy\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"^tgCustomAttributesValues\",\n restrict: \"AE\"\n };\n };\n\n module.directive(\"tgCustomAttributeValue\", [\"$tgTemplate\", \"$selectedText\", \"$compile\", \"$translate\", \"tgDatePickerConfigService\", CustomAttributeValueDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/estimation.coffee\n */\n\n(function() {\n var EstimationsService, LbUsEstimationDirective, UsEstimationDirective, groupBy, module, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaCommon\");\n\n LbUsEstimationDirective = function($tgEstimationsService, $rootScope, $repo, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $scope.$watch($attrs.ngModel, function(us) {\n var estimationProcess;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return $scope.$apply(function() {\n return $model.$setViewValue(us);\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, template;\n ctx = {\n totalPoints: this.calculateTotalPoints(),\n roles: this.calculateRoles(),\n editable: this.isEditable\n };\n mainTemplate = \"common/estimation/us-estimation-points-per-role.html\";\n template = $template.get(mainTemplate, true);\n html = template(ctx);\n html = $compile(html)($scope);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgLbUsEstimation\", [\"$tgEstimationsService\", \"$rootScope\", \"$tgRepo\", \"$tgTemplate\", \"$compile\", LbUsEstimationDirective]);\n\n UsEstimationDirective = function($tgEstimationsService, $rootScope, $repo, $qqueue, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $scope.$watch($attrs.ngModel, function(us) {\n var estimationProcess;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return this.save(roleId, pointId).then(function() {\n return $rootScope.$broadcast(\"object:updated\");\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, template;\n ctx = {\n totalPoints: this.calculateTotalPoints(),\n roles: this.calculateRoles(),\n editable: this.isEditable\n };\n mainTemplate = \"common/estimation/us-estimation-points-per-role.html\";\n template = $template.get(mainTemplate, true);\n html = template(ctx);\n html = $compile(html)($scope);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsEstimation\", [\"$tgEstimationsService\", \"$rootScope\", \"$tgRepo\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsEstimationDirective]);\n\n EstimationsService = function($template, $qqueue, $repo, $confirm, $q) {\n var EstimationProcess, create, pointsTemplate;\n pointsTemplate = $template.get(\"common/estimation/us-estimation-points.html\", true);\n EstimationProcess = (function() {\n function EstimationProcess($el1, us1, project1) {\n this.$el = $el1;\n this.us = us1;\n this.project = project1;\n this.bindClickEvents = bind(this.bindClickEvents, this);\n this.isEditable = this.project.my_permissions.indexOf(\"modify_us\") !== -1;\n this.roles = this.project.roles;\n this.points = this.project.points;\n this.pointsById = groupBy(this.points, function(x) {\n return x.id;\n });\n this.onSelectedPointForRole = function(roleId, pointId) {};\n this.render = function() {};\n }\n\n EstimationProcess.prototype.save = function(roleId, pointId) {\n var deferred;\n deferred = $q.defer();\n $qqueue.add((function(_this) {\n return function() {\n var onError, onSuccess;\n onSuccess = function() {\n return deferred.resolve();\n };\n onError = function() {\n $confirm.notify(\"error\");\n _this.us.revert();\n _this.render();\n return deferred.reject();\n };\n return $repo.save(_this.us).then(onSuccess, onError);\n };\n })(this));\n return deferred.promise;\n };\n\n EstimationProcess.prototype.calculateTotalPoints = function() {\n var notNullValues, values;\n values = _.map(this.us.points, (function(_this) {\n return function(v, k) {\n var ref;\n return (ref = _this.pointsById[v]) != null ? ref.value : void 0;\n };\n })(this));\n if (values.length === 0) {\n return \"0\";\n }\n notNullValues = _.filter(values, function(v) {\n return v != null;\n });\n if (notNullValues.length === 0) {\n return \"?\";\n }\n return _.reduce(notNullValues, function(acc, num) {\n return acc + num;\n });\n };\n\n EstimationProcess.prototype.calculateRoles = function() {\n var computableRoles, roles;\n computableRoles = _.filter(this.project.roles, \"computable\");\n roles = _.map(computableRoles, (function(_this) {\n return function(role) {\n var pointId, pointObj;\n pointId = _this.us.points[role.id];\n pointObj = _this.pointsById[pointId];\n role = _.clone(role, true);\n role.points = (pointObj != null) && (pointObj.name != null) ? pointObj.name : \"?\";\n return role;\n };\n })(this));\n return roles;\n };\n\n EstimationProcess.prototype.bindClickEvents = function() {\n this.$el.on(\"click\", \".total.clickable\", (function(_this) {\n return function(event) {\n var roleId, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n roleId = target.data(\"role-id\");\n _this.renderPointsSelector(roleId, target);\n target.siblings().removeClass('active');\n return target.addClass('active');\n };\n })(this));\n return this.$el.on(\"click\", \".point\", (function(_this) {\n return function(event) {\n var pointId, points, roleId, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n roleId = target.data(\"role-id\");\n pointId = target.data(\"point-id\");\n _this.$el.find(\".popover\").popover().close();\n points = _.clone(_this.us.points, true);\n points[roleId] = pointId;\n _this.us.points = points;\n _this.render();\n return _this.onSelectedPointForRole(roleId, pointId);\n };\n })(this));\n };\n\n EstimationProcess.prototype.renderPointsSelector = function(roleId, target) {\n var horizontalList, html, maxPointLength, points, pop;\n points = _.map(this.points, (function(_this) {\n return function(point) {\n point = _.clone(point, true);\n point.selected = _this.us.points[roleId] === point.id ? false : true;\n return point;\n };\n })(this));\n maxPointLength = 5;\n horizontalList = _.some(points, (function(_this) {\n return function(point) {\n return point.name.length > maxPointLength;\n };\n })(this));\n html = pointsTemplate({\n \"points\": points,\n roleId: roleId,\n horizontal: horizontalList\n });\n this.$el.find(\".popover\").popover().close();\n this.$el.find(\".pop-points-open\").remove();\n if (target != null) {\n this.$el.find(target).append(html);\n } else {\n this.$el.append(html);\n }\n this.$el.find(\".pop-points-open\").popover().open(function() {\n return $(this).removeClass(\"active\").closest(\"li\").removeClass(\"active\");\n });\n this.$el.find(\".pop-points-open\").show();\n pop = this.$el.find(\".pop-points-open\");\n if (pop.offset().top + pop.height() > document.body.clientHeight) {\n return pop.addClass('pop-bottom');\n }\n };\n\n return EstimationProcess;\n\n })();\n create = function($el, us, project) {\n var estimationProcess;\n $el.unbind(\"click\");\n estimationProcess = new EstimationProcess($el, us, project);\n if (estimationProcess.isEditable) {\n estimationProcess.bindClickEvents();\n }\n return estimationProcess;\n };\n return {\n create: create\n };\n };\n\n module.factory(\"$tgEstimationsService\", [\"$tgTemplate\", \"$tgQqueue\", \"$tgRepo\", \"$tgConfirm\", \"$q\", EstimationsService]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/filters.coffee\n */\n\n(function() {\n var defaultFilter, module, momentFormat, momentFromNow, sizeFormat, taiga, unslugify, yesNoFilter;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n defaultFilter = function() {\n return function(value, defaultValue) {\n if (value === [null, void 0]) {\n return defaultValue;\n }\n return value;\n };\n };\n\n module.filter(\"default\", defaultFilter);\n\n yesNoFilter = function($translate) {\n return function(value) {\n if (value) {\n return $translate.instant(\"COMMON.YES\");\n }\n return $translate.instant(\"COMMON.NO\");\n };\n };\n\n module.filter(\"yesNo\", [\"$translate\", yesNoFilter]);\n\n unslugify = function() {\n return taiga.unslugify;\n };\n\n module.filter(\"unslugify\", unslugify);\n\n momentFormat = function() {\n return function(input, format) {\n if (input) {\n return moment(input).format(format);\n }\n return \"\";\n };\n };\n\n module.filter(\"momentFormat\", momentFormat);\n\n momentFromNow = function() {\n return function(input, without_suffix) {\n if (input) {\n return moment(input).fromNow(without_suffix || false);\n }\n return \"\";\n };\n };\n\n module.filter(\"momentFromNow\", momentFromNow);\n\n sizeFormat = (function(_this) {\n return function() {\n return _this.taiga.sizeFormat;\n };\n })(this);\n\n module.filter(\"sizeFormat\", sizeFormat);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/history.coffee\n */\n\n(function() {\n var HistoryController, HistoryDirective, IGNORED_FIELDS, bindOnce, debounce, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaCommon\");\n\n IGNORED_FIELDS = {\n \"userstories.userstory\": [\"watchers\", \"kanban_order\", \"backlog_order\", \"sprint_order\", \"finish_date\", \"tribe_gig\"],\n \"tasks.task\": [\"watchers\", \"us_order\", \"taskboard_order\"],\n \"issues.issue\": [\"watchers\"]\n };\n\n HistoryController = (function(superClass) {\n extend(HistoryController, superClass);\n\n HistoryController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\"];\n\n function HistoryController(scope, repo, rs) {\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n }\n\n HistoryController.prototype.initialize = function(type, objectId) {\n this.type = type;\n return this.objectId = objectId;\n };\n\n HistoryController.prototype.loadHistory = function(type, objectId) {\n return this.rs.history.get(type, objectId).then((function(_this) {\n return function(history) {\n var changeModel, historyEntry, historyResult, i, j, len, len1;\n for (i = 0, len = history.length; i < len; i++) {\n historyResult = history[i];\n if (historyResult.values_diff.description_diff != null) {\n historyResult.values_diff.description = historyResult.values_diff.description_diff;\n }\n delete historyResult.values_diff.description_html;\n delete historyResult.values_diff.description_diff;\n if (historyResult.values_diff.blocked_note_diff != null) {\n historyResult.values_diff.blocked_note = historyResult.values_diff.blocked_note_diff;\n }\n delete historyResult.values_diff.blocked_note_html;\n delete historyResult.values_diff.blocked_note_diff;\n }\n for (j = 0, len1 = history.length; j < len1; j++) {\n historyEntry = history[j];\n changeModel = historyEntry.key.split(\":\")[0];\n if (IGNORED_FIELDS[changeModel] != null) {\n historyEntry.values_diff = _.removeKeys(historyEntry.values_diff, IGNORED_FIELDS[changeModel]);\n }\n }\n _this.scope.history = _.filter(history, function(item) {\n return Object.keys(item.values_diff).length > 0;\n });\n return _this.scope.comments = _.filter(history, function(item) {\n return item.comment !== \"\";\n });\n };\n })(this));\n };\n\n HistoryController.prototype.deleteComment = function(type, objectId, activityId) {\n return this.rs.history.deleteComment(type, objectId, activityId).then((function(_this) {\n return function() {\n return _this.loadHistory(type, objectId);\n };\n })(this));\n };\n\n HistoryController.prototype.undeleteComment = function(type, objectId, activityId) {\n return this.rs.history.undeleteComment(type, objectId, activityId).then((function(_this) {\n return function() {\n return _this.loadHistory(type, objectId);\n };\n })(this));\n };\n\n return HistoryController;\n\n })(taiga.Controller);\n\n HistoryDirective = function($log, $loading, $qqueue, $template, $confirm, $translate, $compile, $navUrls, $rootScope) {\n var link, templateActivity, templateBase, templateBaseEntries, templateChangeAttachment, templateChangeDiff, templateChangeGeneric, templateChangeList, templateChangePoints, templateDeletedComment, templateFn;\n templateChangeDiff = $template.get(\"common/history/history-change-diff.html\", true);\n templateChangePoints = $template.get(\"common/history/history-change-points.html\", true);\n templateChangeGeneric = $template.get(\"common/history/history-change-generic.html\", true);\n templateChangeAttachment = $template.get(\"common/history/history-change-attachment.html\", true);\n templateChangeList = $template.get(\"common/history/history-change-list.html\", true);\n templateDeletedComment = $template.get(\"common/history/history-deleted-comment.html\", true);\n templateActivity = $template.get(\"common/history/history-activity.html\", true);\n templateBaseEntries = $template.get(\"common/history/history-base-entries.html\", true);\n templateBase = $template.get(\"common/history/history-base.html\", true);\n link = function($scope, $el, $attrs, $ctrl) {\n var countChanges, formatChange, getHumanizedFieldName, getPrettyDateFormat, objectId, renderActivity, renderAttachmentEntry, renderChange, renderChangeEntries, renderChangeEntry, renderChangesHelperText, renderComment, renderComments, renderCustomAttributesEntry, renderHistory, save, showAllActivity, showAllComments, type;\n type = $attrs.type;\n objectId = null;\n showAllComments = false;\n showAllActivity = false;\n getPrettyDateFormat = function() {\n return $translate.instant(\"ACTIVITY.DATETIME\");\n };\n bindOnce($scope, $attrs.ngModel, function(model) {\n type = $attrs.type;\n objectId = model.id;\n $ctrl.initialize(type, objectId);\n return $ctrl.loadHistory(type, objectId);\n });\n getHumanizedFieldName = function(field) {\n var humanizedFieldNames;\n humanizedFieldNames = {\n subject: $translate.instant(\"ACTIVITY.FIELDS.SUBJECT\"),\n name: $translate.instant(\"ACTIVITY.FIELDS.NAME\"),\n description: $translate.instant(\"ACTIVITY.FIELDS.DESCRIPTION\"),\n content: $translate.instant(\"ACTIVITY.FIELDS.CONTENT\"),\n status: $translate.instant(\"ACTIVITY.FIELDS.STATUS\"),\n is_closed: $translate.instant(\"ACTIVITY.FIELDS.IS_CLOSED\"),\n finish_date: $translate.instant(\"ACTIVITY.FIELDS.FINISH_DATE\"),\n type: $translate.instant(\"ACTIVITY.FIELDS.TYPE\"),\n priority: $translate.instant(\"ACTIVITY.FIELDS.PRIORITY\"),\n severity: $translate.instant(\"ACTIVITY.FIELDS.SEVERITY\"),\n assigned_to: $translate.instant(\"ACTIVITY.FIELDS.ASSIGNED_TO\"),\n watchers: $translate.instant(\"ACTIVITY.FIELDS.WATCHERS\"),\n milestone: $translate.instant(\"ACTIVITY.FIELDS.MILESTONE\"),\n user_story: $translate.instant(\"ACTIVITY.FIELDS.USER_STORY\"),\n project: $translate.instant(\"ACTIVITY.FIELDS.PROJECT\"),\n is_blocked: $translate.instant(\"ACTIVITY.FIELDS.IS_BLOCKED\"),\n blocked_note: $translate.instant(\"ACTIVITY.FIELDS.BLOCKED_NOTE\"),\n points: $translate.instant(\"ACTIVITY.FIELDS.POINTS\"),\n client_requirement: $translate.instant(\"ACTIVITY.FIELDS.CLIENT_REQUIREMENT\"),\n team_requirement: $translate.instant(\"ACTIVITY.FIELDS.TEAM_REQUIREMENT\"),\n is_iocaine: $translate.instant(\"ACTIVITY.FIELDS.IS_IOCAINE\"),\n tags: $translate.instant(\"ACTIVITY.FIELDS.TAGS\"),\n attachments: $translate.instant(\"ACTIVITY.FIELDS.ATTACHMENTS\"),\n is_deprecated: $translate.instant(\"ACTIVITY.FIELDS.IS_DEPRECATED\"),\n blocked_note: $translate.instant(\"ACTIVITY.FIELDS.BLOCKED_NOTE\"),\n is_blocked: $translate.instant(\"ACTIVITY.FIELDS.IS_BLOCKED\"),\n order: $translate.instant(\"ACTIVITY.FIELDS.ORDER\"),\n backlog_order: $translate.instant(\"ACTIVITY.FIELDS.BACKLOG_ORDER\"),\n sprint_order: $translate.instant(\"ACTIVITY.FIELDS.SPRINT_ORDER\"),\n kanban_order: $translate.instant(\"ACTIVITY.FIELDS.KANBAN_ORDER\"),\n taskboard_order: $translate.instant(\"ACTIVITY.FIELDS.TASKBOARD_ORDER\"),\n us_order: $translate.instant(\"ACTIVITY.FIELDS.US_ORDER\")\n };\n return humanizedFieldNames[field] || field;\n };\n countChanges = function(comment) {\n return _.keys(comment.values_diff).length;\n };\n formatChange = function(change) {\n if (_.isArray(change)) {\n if (change.length === 0) {\n return $translate.instant(\"ACTIVITY.VALUES.EMPTY\");\n }\n return change.join(\", \");\n }\n if (change === \"\") {\n return $translate.instant(\"ACTIVITY.VALUES.EMPTY\");\n }\n if ((change == null) || change === false) {\n return $translate.instant(\"ACTIVITY.VALUES.NO\");\n }\n if (change === true) {\n return $translate.instant(\"ACTIVITY.VALUES.YES\");\n }\n return change;\n };\n renderAttachmentEntry = function(value) {\n var attachments;\n attachments = _.map(value, function(changes, type) {\n if (type === \"new\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.NEW_ATTACHMENT\"),\n diff: change.filename\n });\n });\n } else if (type === \"deleted\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.DELETED_ATTACHMENT\"),\n diff: change.filename\n });\n });\n } else {\n return _.map(changes, function(change) {\n var diff, name;\n name = $translate.instant(\"ACTIVITY.UPDATED_ATTACHMENT\", {\n filename: change.filename\n });\n diff = _.map(change.changes, function(values, name) {\n return {\n name: getHumanizedFieldName(name),\n from: formatChange(values[0]),\n to: formatChange(values[1])\n };\n });\n return templateChangeAttachment({\n name: name,\n diff: diff\n });\n });\n }\n });\n return _.flatten(attachments).join(\"\\n\");\n };\n renderCustomAttributesEntry = function(value) {\n var customAttributes;\n customAttributes = _.map(value, function(changes, type) {\n if (type === \"new\") {\n return _.map(changes, function(change) {\n var html;\n html = templateChangeGeneric({\n name: change.name,\n from: formatChange(\"\"),\n to: formatChange(change.value)\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n });\n } else if (type === \"deleted\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.DELETED_CUSTOM_ATTRIBUTE\"),\n diff: change.name\n });\n });\n } else {\n return _.map(changes, function(change) {\n var customAttrsChanges;\n customAttrsChanges = _.map(change.changes, function(values) {\n return templateChangeGeneric({\n name: change.name,\n from: formatChange(values[0]),\n to: formatChange(values[1])\n });\n });\n return _.flatten(customAttrsChanges).join(\"\\n\");\n });\n }\n });\n return _.flatten(customAttributes).join(\"\\n\");\n };\n renderChangeEntry = function(field, value) {\n var added, from, html, name, removed, to;\n if (field === \"description\") {\n return templateChangeDiff({\n name: getHumanizedFieldName(\"description\"),\n diff: value[1]\n });\n } else if (field === \"blocked_note\") {\n return templateChangeDiff({\n name: getHumanizedFieldName(\"blocked_note\"),\n diff: value[1]\n });\n } else if (field === \"points\") {\n html = templateChangePoints({\n points: value\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n } else if (field === \"attachments\") {\n return renderAttachmentEntry(value);\n } else if (field === \"custom_attributes\") {\n return renderCustomAttributesEntry(value);\n } else if (field === \"tags\" || field === \"watchers\") {\n name = getHumanizedFieldName(field);\n removed = _.difference(value[0], value[1]);\n added = _.difference(value[1], value[0]);\n html = templateChangeList({\n name: name,\n removed: removed,\n added: added\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n } else if (field === \"assigned_to\") {\n name = getHumanizedFieldName(field);\n from = formatChange(value[0] || $translate.instant(\"ACTIVITY.VALUES.UNASSIGNED\"));\n to = formatChange(value[1] || $translate.instant(\"ACTIVITY.VALUES.UNASSIGNED\"));\n return templateChangeGeneric({\n name: name,\n from: from,\n to: to\n });\n } else {\n name = getHumanizedFieldName(field);\n from = formatChange(value[0]);\n to = formatChange(value[1]);\n return templateChangeGeneric({\n name: name,\n from: from,\n to: to\n });\n }\n };\n renderChangeEntries = function(change) {\n return _.map(change.values_diff, function(value, field) {\n return renderChangeEntry(field, value);\n });\n };\n renderChangesHelperText = function(change) {\n var size;\n size = countChanges(change);\n return $translate.instant(\"ACTIVITY.SIZE_CHANGE\", {\n size: size\n }, 'messageformat');\n };\n renderComment = function(comment) {\n var html, ref, ref1, ref2;\n if (comment.delete_comment_date || ((ref = comment.delete_comment_user) != null ? ref.name : void 0)) {\n html = templateDeletedComment({\n deleteCommentDate: comment.delete_comment_date ? moment(comment.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: comment.delete_comment_user.name,\n deleteComment: comment.comment_html,\n activityId: comment.id,\n canRestoreComment: $scope.user && (comment.delete_comment_user.pk === $scope.user.id || $scope.project.my_permissions.indexOf(\"modify_project\") > -1)\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n }\n html = templateActivity({\n avatar: comment.user.photo,\n userFullName: comment.user.name,\n userProfileUrl: comment.user.is_active ? $navUrls.resolve(\"user-profile\", {\n username: comment.user.username\n }) : \"\",\n creationDate: moment(comment.created_at).format(getPrettyDateFormat()),\n comment: comment.comment_html,\n changesText: renderChangesHelperText(comment),\n changes: renderChangeEntries(comment),\n mode: \"comment\",\n deleteCommentActionTitle: $translate.instant(\"COMMENTS.DELETE\"),\n deleteCommentDate: comment.delete_comment_date ? moment(comment.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: ((ref1 = comment.delete_comment_user) != null ? ref1.name : void 0) ? comment.delete_comment_user.name : void 0,\n activityId: comment.id,\n canDeleteComment: comment.user.pk === ((ref2 = $scope.user) != null ? ref2.id : void 0) || $scope.project.my_permissions.indexOf(\"modify_project\") > -1\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n };\n renderChange = function(change) {\n var ref;\n return templateActivity({\n avatar: change.user.photo,\n userFullName: change.user.name,\n userProfileUrl: change.user.is_active ? $navUrls.resolve(\"user-profile\", {\n username: change.user.username\n }) : \"\",\n creationDate: moment(change.created_at).format(getPrettyDateFormat()),\n comment: change.comment_html,\n changes: renderChangeEntries(change),\n changesText: \"\",\n mode: \"activity\",\n deleteCommentDate: change.delete_comment_date ? moment(change.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: ((ref = change.delete_comment_user) != null ? ref.name : void 0) ? change.delete_comment_user.name : void 0,\n activityId: change.id\n });\n };\n renderHistory = function(entries, totalEntries) {\n var html, showMore;\n if (entries.length === totalEntries) {\n showMore = 0;\n } else {\n showMore = totalEntries - entries.length;\n }\n html = templateBaseEntries({\n entries: entries,\n showMore: showMore\n });\n html = $compile(html)($scope);\n return html;\n };\n renderComments = function() {\n var comments, html, totalComments;\n comments = $scope.comments || [];\n totalComments = comments.length;\n if (!showAllComments) {\n comments = _.last(comments, 4);\n }\n comments = _.map(comments, function(x) {\n return renderComment(x);\n });\n html = renderHistory(comments, totalComments);\n return $el.find(\".comments-list\").html(html);\n };\n renderActivity = function() {\n var changes, html, totalChanges;\n changes = $scope.history || [];\n totalChanges = changes.length;\n if (!showAllActivity) {\n changes = _.last(changes, 4);\n }\n changes = _.map(changes, function(x) {\n return renderChange(x);\n });\n html = renderHistory(changes, totalChanges);\n return $el.find(\".changes-list\").html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(target) {\n var currentLoading, model, onError, onSuccess;\n $scope.$broadcast(\"markdown-editor:submit\");\n $el.find(\".comment-list\").addClass(\"activeanimation\");\n currentLoading = $loading().target(target).start();\n onSuccess = function() {\n $rootScope.$broadcast(\"comment:new\");\n return $ctrl.loadHistory(type, objectId)[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n onError = function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n };\n model = $scope.$eval($attrs.ngModel);\n return $ctrl.repo.save(model).then(onSuccess, onError);\n };\n })(this));\n $scope.$watch(\"comments\", renderComments);\n $scope.$watch(\"history\", renderActivity);\n $scope.$on(\"object:updated\", function() {\n return $ctrl.loadHistory(type, objectId);\n });\n $el.on(\"click\", \".add-comment button.button-green\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return save(target);\n }));\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href && href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"click\", \".show-more\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n if (target.parent().is(\".changes-list\")) {\n showAllActivity = !showAllActivity;\n return renderActivity();\n } else {\n showAllComments = !showAllComments;\n return renderComments();\n }\n });\n $el.on(\"click\", \".show-deleted-comment\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.parents('.activity-single').find('.hide-deleted-comment').show();\n target.parents('.activity-single').find('.show-deleted-comment').hide();\n return target.parents('.activity-single').find('.comment-body').show();\n });\n $el.on(\"click\", \".hide-deleted-comment\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.parents('.activity-single').find('.hide-deleted-comment').hide();\n target.parents('.activity-single').find('.show-deleted-comment').show();\n return target.parents('.activity-single').find('.comment-body').hide();\n });\n $el.on(\"click\", \".changes-title\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return target.parent().find(\".change-entry\").toggleClass(\"active\");\n });\n $el.on(\"focus\", \".add-comment textarea\", function(event) {\n return $(this).addClass('active');\n });\n $el.on(\"click\", \".history-tabs li a\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n $el.find(\".history-tabs li a\").removeClass(\"active\");\n target.addClass(\"active\");\n $el.find(\".history section\").addClass(\"hidden\");\n return $el.find(\".history section.\" + (target.data('section-class'))).removeClass(\"hidden\");\n });\n $el.on(\"click\", \".comment-delete\", debounce(2000, function(event) {\n var activityId, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n activityId = target.data('activity-id');\n return $ctrl.deleteComment(type, objectId, activityId);\n }));\n $el.on(\"click\", \".comment-restore\", debounce(2000, function(event) {\n var activityId, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n activityId = target.data('activity-id');\n return $ctrl.undeleteComment(type, objectId, activityId);\n }));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n templateFn = function($el, $attrs) {\n var html;\n html = templateBase({\n ngmodel: $attrs.ngModel,\n type: $attrs.type,\n mode: $attrs.mode\n });\n return html;\n };\n return {\n controller: HistoryController,\n template: templateFn,\n restrict: \"AE\",\n link: link\n };\n };\n\n module.directive(\"tgHistory\", [\"$log\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$tgConfirm\", \"$translate\", \"$compile\", \"$tgNavUrls\", \"$rootScope\", HistoryDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/importer.coffee\n */\n\n(function() {\n var ImportProjectButtonDirective, module;\n\n module = angular.module(\"taigaCommon\");\n\n ImportProjectButtonDirective = function($rs, $confirm, $location, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n $el.on(\"click\", \".import-project-button\", function(event) {\n event.preventDefault();\n $el.find(\"input.import-file\").val(\"\");\n return $el.find(\"input.import-file\").trigger(\"click\");\n });\n return $el.on(\"change\", \"input.import-file\", function(event) {\n var file, loader, onError, onSuccess;\n event.preventDefault();\n file = event.target.files[0];\n if (!file) {\n return;\n }\n loader = $confirm.loader($translate.instant(\"PROJECT.IMPORT.UPLOADING_FILE\"));\n onSuccess = function(result) {\n var ctx, message, msg, title;\n loader.stop();\n if (result.status === 202) {\n title = $translate.instant(\"PROJECT.IMPORT.ASYNC_IN_PROGRESS_TITLE\");\n message = $translate.instant(\"PROJECT.IMPORT.ASYNC_IN_PROGRESS_MESSAGE\");\n return $confirm.success(title, message);\n } else {\n ctx = {\n project: result.data.slug\n };\n $location.path($navUrls.resolve(\"project-admin-project-profile-details\", ctx));\n msg = $translate.instant(\"PROJECT.IMPORT.SYNC_SUCCESS\");\n return $confirm.notify(\"success\", msg);\n }\n };\n onError = function(result) {\n var errorMsg, ref;\n loader.stop();\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR\");\n if (result.status === 429) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST\");\n } else if ((ref = result.data) != null ? ref._error_message : void 0) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_MESSAGE\", {\n error_message: result.data._error_message\n });\n }\n return $confirm.notify(\"error\", errorMsg);\n };\n loader.start();\n return $rs.projects[\"import\"](file, loader.update).then(onSuccess, onError);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgImportProjectButton\", [\"$tgResources\", \"$tgConfirm\", \"$location\", \"$tgNavUrls\", \"$translate\", ImportProjectButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/lightboxes.coffee\n */\n\n(function() {\n var AssignedToLightboxDirective, AttachmentPreviewLightboxDirective, BlockLightboxDirective, BlockingMessageInputDirective, CreateBulkUserstoriesDirective, CreateEditUserstoryDirective, LightboxDirective, LightboxKeyboardNavigationService, LightboxService, WatchersLightboxDirective, bindOnce, debounce, module, sizeFormat, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n module = angular.module(\"taigaCommon\");\n\n bindOnce = this.taiga.bindOnce;\n\n timeout = this.taiga.timeout;\n\n debounce = this.taiga.debounce;\n\n sizeFormat = this.taiga.sizeFormat;\n\n LightboxService = (function(superClass) {\n extend(LightboxService, superClass);\n\n function LightboxService(animationFrame, q) {\n this.animationFrame = animationFrame;\n this.q = q;\n }\n\n LightboxService.prototype.open = function($el) {\n var defered, docEl, lightboxContent;\n defered = this.q.defer();\n lightboxContent = $el.children().not(\".close\");\n lightboxContent.hide();\n this.animationFrame.add(function() {\n return $el.css('display', 'flex');\n });\n this.animationFrame.add(function() {\n $el.addClass(\"open\");\n return $el.one(\"transitionend\", (function(_this) {\n return function() {\n return $el.find('input,textarea').first().focus();\n };\n })(this));\n });\n this.animationFrame.add((function(_this) {\n return function() {\n lightboxContent.show();\n return defered.resolve();\n };\n })(this));\n docEl = angular.element(document);\n docEl.on(\"keydown.lightbox\", (function(_this) {\n return function(e) {\n var code;\n code = e.keyCode ? e.keyCode : e.which;\n if (code === 27) {\n return _this.close($el);\n }\n };\n })(this));\n return defered.promise;\n };\n\n LightboxService.prototype.close = function($el) {\n var docEl, scope;\n docEl = angular.element(document);\n docEl.off(\".lightbox\");\n docEl.off(\".keyboard-navigation\");\n $el.one(\"transitionend\", (function(_this) {\n return function() {\n $el.removeAttr('style');\n return $el.removeClass(\"open\").removeClass('close');\n };\n })(this));\n $el.addClass('close');\n if ($el.hasClass(\"remove-on-close\")) {\n scope = $el.data(\"scope\");\n scope.$destroy();\n return $el.remove();\n }\n };\n\n LightboxService.prototype.closeAll = function() {\n var docEl, i, len, lightboxEl, ref, results;\n docEl = angular.element(document);\n ref = docEl.find(\".lightbox.open\");\n results = [];\n for (i = 0, len = ref.length; i < len; i++) {\n lightboxEl = ref[i];\n results.push(this.close($(lightboxEl)));\n }\n return results;\n };\n\n return LightboxService;\n\n })(taiga.Service);\n\n module.service(\"lightboxService\", [\"animationFrame\", \"$q\", LightboxService]);\n\n LightboxKeyboardNavigationService = (function(superClass) {\n extend(LightboxKeyboardNavigationService, superClass);\n\n function LightboxKeyboardNavigationService() {\n return LightboxKeyboardNavigationService.__super__.constructor.apply(this, arguments);\n }\n\n LightboxKeyboardNavigationService.prototype.stop = function() {\n var docEl;\n docEl = angular.element(document);\n return docEl.off(\".keyboard-navigation\");\n };\n\n LightboxKeyboardNavigationService.prototype.dispatch = function($el, code) {\n var activeElement, next, prev;\n activeElement = $el.find(\".selected\");\n if (code === 13) {\n if ($el.find(\".user-list-single\").length === 1) {\n return $el.find('.user-list-single:first').trigger(\"click\");\n } else {\n return activeElement.trigger(\"click\");\n }\n } else if (code === 40) {\n if (!activeElement.length) {\n return $el.find('.user-list-single:not(\".is-active\"):first').addClass('selected');\n } else {\n next = activeElement.next('.user-list-single');\n if (next.length) {\n activeElement.removeClass('selected');\n return next.addClass('selected');\n }\n }\n } else if (code === 38) {\n if (!activeElement.length) {\n return $el.find('.user-list-single:last').addClass('selected');\n } else {\n prev = activeElement.prev('.user-list-single:not(\".is-active\")');\n if (prev.length) {\n activeElement.removeClass('selected');\n return prev.addClass('selected');\n }\n }\n }\n };\n\n LightboxKeyboardNavigationService.prototype.init = function($el) {\n var docEl;\n this.stop();\n docEl = angular.element(document);\n return docEl.on(\"keydown.keyboard-navigation\", (function(_this) {\n return function(event) {\n var code;\n code = event.keyCode ? event.keyCode : event.which;\n if (code === 40 || code === 38 || code === 13) {\n event.preventDefault();\n return _this.dispatch($el, code);\n }\n };\n })(this));\n };\n\n return LightboxKeyboardNavigationService;\n\n })(taiga.Service);\n\n module.service(\"lightboxKeyboardNavigationService\", LightboxKeyboardNavigationService);\n\n LightboxDirective = function(lightboxService) {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n };\n return {\n restrict: \"C\",\n link: link\n };\n };\n\n module.directive(\"lightbox\", [\"lightboxService\", LightboxDirective]);\n\n BlockLightboxDirective = function($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue, $translate) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var block, title, unblock;\n title = $translate.instant($attrs.title);\n $el.find(\"h2.title\").text(title);\n unblock = $qqueue.bindAdd((function(_this) {\n return function(item, finishCallback) {\n var promise;\n promise = $tgrepo.save(item);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $model.$setViewValue(item);\n return finishCallback();\n });\n promise.then(null, function() {\n $confirm.notify(\"error\");\n item.revert();\n return $model.$setViewValue(item);\n });\n promise[\"finally\"](function() {\n return finishCallback();\n });\n return promise;\n };\n })(this));\n block = $qqueue.bindAdd((function(_this) {\n return function(item) {\n var currentLoading, promise;\n $model.$setViewValue(item);\n currentLoading = $loading().target($el.find(\".button-green\")).start();\n promise = $tgrepo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n $confirm.notify(\"error\");\n item.revert();\n return $model.$setViewValue(item);\n });\n return promise[\"finally\"](function() {\n currentLoading.finish();\n return lightboxService.close($el);\n });\n };\n })(this));\n $scope.$on(\"block\", function() {\n $el.find(\".reason\").val($model.$modelValue.blocked_note);\n return lightboxService.open($el);\n });\n $scope.$on(\"unblock\", (function(_this) {\n return function(event, model, finishCallback) {\n var item;\n item = $model.$modelValue.clone();\n item.is_blocked = false;\n item.blocked_note = \"\";\n return unblock(item, finishCallback);\n };\n })(this));\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return $el.on(\"click\", \".button-green\", function(event) {\n var item;\n event.preventDefault();\n item = $model.$modelValue.clone();\n item.is_blocked = true;\n item.blocked_note = $el.find(\".reason\").val();\n return block(item);\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-block.html\",\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgLbBlock\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"lightboxService\", \"$tgLoading\", \"$tgQqueue\", \"$translate\", BlockLightboxDirective]);\n\n BlockingMessageInputDirective = function($log, $template, $compile) {\n var link, template, templateFn;\n template = $template.get(\"common/lightbox/lightbox-blocking-message-input.html\", true);\n link = function($scope, $el, $attrs, $model) {\n if (!$attrs.watch) {\n return $log.error(\"No watch attribute on tg-blocking-message-input directive\");\n }\n return $scope.$watch($attrs.watch, function(value) {\n if (value === !void 0 && value === true) {\n return $el.find(\".blocked-note\").removeClass(\"hidden\");\n } else {\n return $el.find(\".blocked-note\").addClass(\"hidden\");\n }\n });\n };\n templateFn = function($el, $attrs) {\n return template({\n ngmodel: $attrs.ngModel\n });\n };\n return {\n template: templateFn,\n link: link,\n require: \"ngModel\",\n restrict: \"EA\"\n };\n };\n\n module.directive(\"tgBlockingMessageInput\", [\"$log\", \"$tgTemplate\", \"$compile\", BlockingMessageInputDirective]);\n\n CreateEditUserstoryDirective = function($repo, $model, $rs, $rootScope, lightboxService, $loading, $translate, $confirm, $q, attachmentsService) {\n var link;\n link = function($scope, $el, attrs) {\n var attachmentsToAdd, attachmentsToDelete, createAttachments, deleteAttachments, resetAttachments, submit, submitButton;\n $scope.createEditUs = {};\n $scope.isNew = true;\n attachmentsToAdd = Immutable.List();\n attachmentsToDelete = Immutable.List();\n resetAttachments = function() {\n attachmentsToAdd = Immutable.List();\n return attachmentsToDelete = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n $scope.deleteAttachment = function(attachment) {\n return attachmentsToDelete = attachmentsToDelete.push(attachment);\n };\n $scope.$on(\"usform:new\", function(ctx, projectId, status, statusList) {\n $scope.isNew = true;\n $scope.usStatusList = statusList;\n $scope.attachments = Immutable.List();\n resetAttachments();\n $scope.us = $model.make_model(\"userstories\", {\n project: projectId,\n points: {},\n status: status,\n is_archived: false,\n tags: []\n });\n $el.find(\".button-green\").html($translate.instant(\"COMMON.CREATE\"));\n $el.find(\".title\").html($translate.instant(\"LIGHTBOX.CREATE_EDIT_US.NEW_US\"));\n $el.find(\".tag-input\").val(\"\");\n $el.find(\".blocked-note\").addClass(\"hidden\");\n $el.find(\"label.blocked\").removeClass(\"selected\");\n $el.find(\"label.team-requirement\").removeClass(\"selected\");\n $el.find(\"label.client-requirement\").removeClass(\"selected\");\n return lightboxService.open($el);\n });\n $scope.$on(\"usform:edit\", function(ctx, us, attachments) {\n $scope.us = us;\n $scope.attachments = Immutable.fromJS(attachments);\n $scope.isNew = false;\n resetAttachments();\n $el.find(\".button-green\").html($translate.instant(\"COMMON.SAVE\"));\n $el.find(\".title\").html($translate.instant(\"LIGHTBOX.CREATE_EDIT_US.EDIT_US\"));\n $el.find(\".tag-input\").val(\"\");\n if (us.is_blocked) {\n $el.find(\".blocked-note\").removeClass(\"hidden\");\n $el.find(\"label.blocked\").addClass(\"selected\");\n } else {\n $el.find(\".blocked-note\").addClass(\"hidden\");\n $el.find(\"label.blocked\").removeClass(\"selected\");\n }\n if (us.team_requirement) {\n $el.find(\"label.team-requirement\").addClass(\"selected\");\n } else {\n $el.find(\"label.team-requirement\").removeClass(\"selected\");\n }\n if (us.client_requirement) {\n $el.find(\"label.client-requirement\").addClass(\"selected\");\n } else {\n $el.find(\"label.client-requirement\").removeClass(\"selected\");\n }\n return lightboxService.open($el);\n });\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.us.project, 'us');\n });\n return $q.all(promises);\n };\n deleteAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToDelete.toJS(), function(attachment) {\n return attachmentsService[\"delete\"](\"us\", attachment.id);\n });\n return $q.all(promises);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n if ($scope.isNew) {\n promise = $repo.create(\"userstories\", $scope.us);\n broadcastEvent = \"usform:new:success\";\n } else {\n promise = $repo.save($scope.us);\n broadcastEvent = \"usform:edit:success\";\n }\n promise.then(function(data) {\n deleteAttachments(data).then((function(_this) {\n return function() {\n return createAttachments(data);\n };\n })(this));\n return data;\n });\n promise.then(function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n return $rootScope.$broadcast(broadcastEvent, data);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n $scope.$apply(function() {\n return $scope.us.revert();\n });\n return lightboxService.close($el);\n });\n $el.keydown(function(event) {\n var code;\n code = event.keyCode ? event.keyCode : event.which;\n if (code === 27) {\n lightboxService.close($el);\n return $scope.$apply(function() {\n return $scope.us.revert();\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateEditUserstory\", [\"$tgRepo\", \"$tgModel\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$translate\", \"$tgConfirm\", \"$q\", \"tgAttachmentsService\", CreateEditUserstoryDirective]);\n\n CreateBulkUserstoriesDirective = function($repo, $rs, $rootscope, lightboxService, $loading) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.$on(\"usform:bulk\", function(ctx, projectId, status) {\n $scope[\"new\"] = {\n projectId: projectId,\n statusId: status,\n bulk: \"\"\n };\n return lightboxService.open($el);\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley({\n onlyOneErrorElement: true\n });\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $rs.userstories.bulkCreate($scope[\"new\"].projectId, $scope[\"new\"].statusId, $scope[\"new\"].bulk);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"usform:bulk:success\", result);\n return lightboxService.close($el);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateBulkUserstories\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", CreateBulkUserstoriesDirective]);\n\n AssignedToLightboxDirective = function(lightboxService, lightboxKeyboardNavigationService, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs) {\n var closeLightbox, filterUsers, normalizeString, render, selectedItem, selectedUser, usersTemplate;\n selectedUser = null;\n selectedItem = null;\n usersTemplate = $template.get(\"common/lightbox/lightbox-assigned-to-users.html\", true);\n normalizeString = function(string) {\n var normalizedString;\n normalizedString = string;\n normalizedString = normalizedString.replace(\"Á\", \"A\").replace(\"Ä\", \"A\").replace(\"À\", \"A\");\n normalizedString = normalizedString.replace(\"É\", \"E\").replace(\"Ë\", \"E\").replace(\"È\", \"E\");\n normalizedString = normalizedString.replace(\"Í\", \"I\").replace(\"Ï\", \"I\").replace(\"Ì\", \"I\");\n normalizedString = normalizedString.replace(\"Ó\", \"O\").replace(\"Ö\", \"O\").replace(\"Ò\", \"O\");\n normalizedString = normalizedString.replace(\"Ú\", \"U\").replace(\"Ü\", \"U\").replace(\"Ù\", \"U\");\n return normalizedString;\n };\n filterUsers = function(text, user) {\n var username;\n username = user.full_name_display.toUpperCase();\n username = normalizeString(username);\n text = text.toUpperCase();\n text = normalizeString(text);\n return _.contains(username, text);\n };\n render = function(selected, text) {\n var ctx, html, users;\n users = _.clone($scope.activeUsers, true);\n if (selected != null) {\n users = _.reject(users, {\n \"id\": selected.id\n });\n }\n if (text != null) {\n users = _.filter(users, _.partial(filterUsers, text));\n }\n ctx = {\n selected: selected,\n users: _.first(users, 5),\n showMore: users.length > 5\n };\n html = usersTemplate(ctx);\n html = $compile(html)($scope);\n return $el.find(\".assigned-to-list\").html(html);\n };\n closeLightbox = function() {\n lightboxKeyboardNavigationService.stop();\n return lightboxService.close($el);\n };\n $scope.$on(\"assigned-to:add\", function(ctx, item) {\n var assignedToId;\n selectedItem = item;\n assignedToId = item.assigned_to;\n selectedUser = $scope.usersById[assignedToId];\n render(selectedUser);\n return lightboxService.open($el).then(function() {\n $el.find('input').focus();\n return lightboxKeyboardNavigationService.init($el);\n });\n });\n $scope.$watch(\"usersSearch\", function(searchingText) {\n if (searchingText != null) {\n render(selectedUser, searchingText);\n return $el.find('input').focus();\n }\n });\n $el.on(\"click\", \".user-list-single\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n closeLightbox();\n return $scope.$apply(function() {\n $scope.$broadcast(\"assigned-to:added\", target.data(\"user-id\"), selectedItem);\n return $scope.usersSearch = null;\n });\n });\n $el.on(\"click\", \".remove-assigned-to\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n closeLightbox();\n return $scope.$apply(function() {\n $scope.usersSearch = null;\n return $scope.$broadcast(\"assigned-to:added\", null, selectedItem);\n });\n });\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n closeLightbox();\n return $scope.$apply(function() {\n return $scope.usersSearch = null;\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-assigned-to.html\",\n link: link\n };\n };\n\n module.directive(\"tgLbAssignedto\", [\"lightboxService\", \"lightboxKeyboardNavigationService\", \"$tgTemplate\", \"$compile\", AssignedToLightboxDirective]);\n\n WatchersLightboxDirective = function($repo, lightboxService, lightboxKeyboardNavigationService, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs) {\n var closeLightbox, getFilteredUsers, render, selectedItem, usersTemplate;\n selectedItem = null;\n usersTemplate = $template.get(\"common/lightbox/lightbox-assigned-to-users.html\", true);\n getFilteredUsers = function(text) {\n var _filterUsers, users;\n if (text == null) {\n text = \"\";\n }\n _filterUsers = function(text, user) {\n var username;\n if (selectedItem && _.find(selectedItem.watchers, function(x) {\n return x === user.id;\n })) {\n return false;\n }\n username = user.full_name_display.toUpperCase();\n text = text.toUpperCase();\n return _.contains(username, text);\n };\n users = _.clone($scope.activeUsers, true);\n users = _.filter(users, _.partial(_filterUsers, text));\n return users;\n };\n render = function(users) {\n var ctx, html;\n ctx = {\n selected: false,\n users: _.first(users, 5),\n showMore: users.length > 5\n };\n html = usersTemplate(ctx);\n html = $compile(html)($scope);\n return $el.find(\".ticket-watchers\").html(html);\n };\n closeLightbox = function() {\n lightboxKeyboardNavigationService.stop();\n return lightboxService.close($el);\n };\n $scope.$on(\"watcher:add\", function(ctx, item) {\n var users;\n selectedItem = item;\n users = getFilteredUsers();\n render(users);\n return lightboxService.open($el).then(function() {\n $el.find(\"input\").focus();\n return lightboxKeyboardNavigationService.init($el);\n });\n });\n $scope.$watch(\"usersSearch\", function(searchingText) {\n var users;\n if (searchingText == null) {\n return;\n }\n users = getFilteredUsers(searchingText);\n render(users);\n return $el.find(\"input\").focus();\n });\n $el.on(\"click\", \".user-list-single\", debounce(2000, function(event) {\n var target;\n closeLightbox();\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return $scope.$apply(function() {\n $scope.usersSearch = null;\n return $scope.$broadcast(\"watcher:added\", target.data(\"user-id\"));\n });\n }));\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n closeLightbox();\n return $scope.$apply(function() {\n return $scope.usersSearch = null;\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-users.html\",\n link: link\n };\n };\n\n module.directive(\"tgLbWatchers\", [\"$tgRepo\", \"lightboxService\", \"lightboxKeyboardNavigationService\", \"$tgTemplate\", \"$compile\", WatchersLightboxDirective]);\n\n AttachmentPreviewLightboxDirective = function(lightboxService, $template, $compile) {\n var link;\n link = function($scope, $el, attrs) {\n return lightboxService.open($el);\n };\n return {\n templateUrl: 'common/lightbox/lightbox-attachment-preview.html',\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgLbAttachmentPreview\", [\"lightboxService\", \"$tgTemplate\", \"$compile\", AttachmentPreviewLightboxDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/loader.coffee\n */\n\n(function() {\n var Loader, LoaderDirective, module, sizeFormat, taiga, timeout;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaCommon\");\n\n LoaderDirective = function(tgLoader, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n tgLoader.onStart(function() {\n $(document.body).addClass(\"loader-active\");\n return $el.addClass(\"active\");\n });\n return tgLoader.onEnd(function() {\n $(document.body).removeClass(\"loader-active\");\n return $el.removeClass(\"active\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLoader\", [\"tgLoader\", \"$rootScope\", LoaderDirective]);\n\n Loader = function($rootscope) {\n var autoClose, config, lastResponseDate, open, pageLoaded, requestCount, start, startLoadTime;\n config = {\n minTime: 300\n };\n open = false;\n startLoadTime = 0;\n requestCount = 0;\n lastResponseDate = 0;\n pageLoaded = function(force) {\n var diff, endTime, timeoutValue;\n if (force == null) {\n force = false;\n }\n if (startLoadTime) {\n timeoutValue = 0;\n if (!force) {\n endTime = new Date().getTime();\n diff = endTime - startLoadTime;\n if (diff < config.minTime) {\n timeoutValue = config.minTime - diff;\n }\n }\n timeout(timeoutValue, function() {\n $rootscope.$broadcast(\"loader:end\");\n open = false;\n return window.prerenderReady = true;\n });\n }\n startLoadTime = 0;\n requestCount = 0;\n return lastResponseDate = 0;\n };\n autoClose = function() {\n var intervalAuto;\n return intervalAuto = setInterval((function() {\n if (lastResponseDate && requestCount === 0) {\n pageLoaded();\n return clearInterval(intervalAuto);\n }\n }), 50);\n };\n start = function() {\n startLoadTime = new Date().getTime();\n $rootscope.$broadcast(\"loader:start\");\n return open = true;\n };\n return {\n pageLoaded: pageLoaded,\n start: function(auto) {\n if (auto == null) {\n auto = false;\n }\n if (!open) {\n start();\n if (auto) {\n return autoClose();\n }\n }\n },\n onStart: function(fn) {\n return $rootscope.$on(\"loader:start\", fn);\n },\n onEnd: function(fn) {\n return $rootscope.$on(\"loader:end\", fn);\n },\n logRequest: function() {\n return requestCount++;\n },\n logResponse: function() {\n requestCount--;\n return lastResponseDate = new Date().getTime();\n }\n };\n };\n\n Loader.$inject = [\"$rootScope\"];\n\n module.factory(\"tgLoader\", Loader);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/lightboxes.coffee\n */\n\n(function() {\n var LoadingDirective, TgLoadingService, module,\n slice = [].slice;\n\n module = angular.module(\"taigaCommon\");\n\n TgLoadingService = function($compile) {\n var spinner;\n spinner = \"loading...\";\n return function() {\n var service;\n service = {\n settings: {\n target: null,\n scope: null,\n classes: [],\n timeout: 0,\n template: null\n },\n target: function(target) {\n service.settings.target = target;\n return service;\n },\n scope: function(scope) {\n service.settings.scope = scope;\n return service;\n },\n template: function(template) {\n service.settings.template = template;\n return service;\n },\n removeClasses: function() {\n var classess;\n classess = 1 <= arguments.length ? slice.call(arguments, 0) : [];\n service.settings.classes = classess;\n return service;\n },\n timeout: function(timeout) {\n service.settings.timeout = timeout;\n return service;\n },\n start: function() {\n var target, timeoutId;\n target = service.settings.target;\n service.settings.classes.map(function(className) {\n return target.removeClass(className);\n });\n timeoutId = setTimeout((function() {\n if (!target.hasClass('loading')) {\n if (!service.settings.template) {\n service.settings.template = target.html();\n }\n target.addClass('loading');\n return target.html(spinner);\n }\n }), service.settings.timeout);\n service.settings.timeoutId = timeoutId;\n return service;\n },\n finish: function() {\n var removeClasses, target, timeoutId;\n target = service.settings.target;\n timeoutId = service.settings.timeoutId;\n if (timeoutId) {\n clearTimeout(timeoutId);\n removeClasses = service.settings.classes;\n removeClasses.map(function(className) {\n return service.settings.target.addClass(className);\n });\n target.html(service.settings.template);\n target.removeClass('loading');\n if (service.settings.scope) {\n $compile(target.contents())(service.settings.scope);\n }\n }\n return service;\n }\n };\n return service;\n };\n };\n\n TgLoadingService.$inject = [\"$compile\"];\n\n module.factory(\"$tgLoading\", TgLoadingService);\n\n LoadingDirective = function($loading) {\n var link;\n link = function($scope, $el, attr) {\n var currentLoading, template;\n currentLoading = null;\n template = $el.html();\n return $scope.$watch(attr.tgLoading, (function(_this) {\n return function(showLoading) {\n if (showLoading) {\n return currentLoading = $loading().target($el).timeout(100).template(template).scope($scope).start();\n } else if (currentLoading) {\n return currentLoading.finish();\n }\n };\n })(this));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLoading\", [\"$tgLoading\", LoadingDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/popovers.coffee\n */\n\n(function() {\n var RelatedTaskStatusDirective, UsStatusDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaCommon\");\n\n UsStatusDirective = function($repo, $template) {\n\n /*\n Print the status of a US and a popover to change it.\n - tg-us-status: The user story\n - on-update: Method call after US is updated\n \n Example:\n \n div.status(tg-us-status=\"us\" on-update=\"ctrl.loadSprintState()\")\n a.us-status(href=\"\", title=\"Status Name\")\n \n NOTE: This directive need 'usStatusById' and 'project'.\n */\n var link, template;\n template = $template.get(\"common/popover/popover-us-status.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, render, us;\n $ctrl = $el.controller();\n render = function(us) {\n var usStatusById, usStatusDom, usStatusDomParent;\n usStatusDomParent = $el.find(\".us-status\");\n usStatusDom = $el.find(\".us-status .us-status-bind\");\n usStatusById = $scope.usStatusById;\n if (usStatusById[us.status]) {\n usStatusDom.text(usStatusById[us.status].name);\n return usStatusDomParent.css(\"color\", usStatusById[us.status].color);\n }\n };\n $el.on(\"click\", \".us-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", debounce(2000, function(event) {\n var target, us;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n us = $scope.$eval($attrs.tgUsStatus);\n us.status = target.data(\"status-id\");\n render(us);\n $el.find(\".pop-status\").popover().close();\n return $scope.$apply(function() {\n return $repo.save(us).then(function() {\n return $scope.$eval($attrs.onUpdate);\n });\n });\n }));\n $scope.$on(\"userstories:loaded\", function() {\n return render($scope.$eval($attrs.tgUsStatus));\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n us = $scope.$eval($attrs.tgUsStatus);\n render(us);\n return bindOnce($scope, \"project\", function(project) {\n var html;\n html = template({\n \"statuses\": project.us_statuses\n });\n $el.append(html);\n if ($scope.project.my_permissions.indexOf(\"modify_us\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUsStatus\", [\"$tgRepo\", \"$tgTemplate\", UsStatusDirective]);\n\n RelatedTaskStatusDirective = function($repo, $template) {\n\n /*\n Print the status of a related task and a popover to change it.\n - tg-related-task-status: The related task\n - on-update: Method call after US is updated\n \n Example:\n \n div.status(tg-related-task-status=\"task\" on-update=\"ctrl.loadSprintState()\")\n a.task-status(href=\"\", title=\"Status Name\")\n \n NOTE: This directive need 'taskStatusById' and 'project'.\n */\n var link, selectionTemplate, updateTaskStatus;\n selectionTemplate = $template.get(\"common/popover/popover-related-task-status.html\", true);\n updateTaskStatus = function($el, task, taskStatusById) {\n var taskStatusDom, taskStatusDomParent;\n taskStatusDomParent = $el.find(\".us-status\");\n taskStatusDom = $el.find(\".task-status .task-status-bind\");\n if (taskStatusById[task.status]) {\n taskStatusDom.text(taskStatusById[task.status].name);\n return taskStatusDomParent.css('color', taskStatusById[task.status].color);\n }\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, autoSave, notAutoSave, task;\n $ctrl = $el.controller();\n task = $scope.$eval($attrs.tgRelatedTaskStatus);\n notAutoSave = $scope.$eval($attrs.notAutoSave);\n autoSave = !notAutoSave;\n $el.on(\"click\", \".task-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n task.status = target.data(\"status-id\");\n $el.find(\".pop-status\").popover().close();\n updateTaskStatus($el, task, $scope.taskStatusById);\n if (autoSave) {\n return $scope.$apply(function() {\n return $repo.save(task).then(function() {\n $scope.$eval($attrs.onUpdate);\n return $scope.$emit(\"related-tasks:status-changed\");\n });\n });\n }\n }));\n taiga.bindOnce($scope, \"project\", function(project) {\n $el.append(selectionTemplate({\n 'statuses': project.task_statuses\n }));\n updateTaskStatus($el, task, $scope.taskStatusById);\n if (project.my_permissions.indexOf(\"modify_task\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskStatus\", [\"$tgRepo\", \"$tgTemplate\", RelatedTaskStatusDirective]);\n\n $.fn.popover = function() {\n var $el, close, closeAll, closePopover, isVisible, open;\n $el = this;\n isVisible = (function(_this) {\n return function() {\n var docViewBottom, docViewLeft, docViewRight, docViewTop, docViewWidth, elemBottom, elemLeft, elemRight, elemTop, elemWidth;\n $el.css({\n \"display\": \"block\",\n \"visibility\": \"hidden\"\n });\n docViewTop = $(window).scrollTop();\n docViewBottom = docViewTop + $(window).height();\n docViewWidth = $(window).width();\n docViewRight = docViewWidth;\n docViewLeft = 0;\n elemTop = $el.offset().top;\n elemBottom = elemTop + $el.height();\n elemWidth = $el.width();\n elemLeft = $el.offset().left;\n elemRight = $el.offset().left + elemWidth;\n $el.css({\n \"display\": \"none\",\n \"visibility\": \"visible\"\n });\n return (elemBottom <= docViewBottom) && (elemTop >= docViewTop) && (elemLeft >= docViewLeft) && (elemRight <= docViewRight);\n };\n })(this);\n closePopover = (function(_this) {\n return function(onClose) {\n if (onClose) {\n onClose.call($el);\n }\n $el.fadeOut(function() {\n return $el.removeClass(\"active\").removeClass(\"fix\");\n });\n return $el.off(\"popup:close\");\n };\n })(this);\n closeAll = (function(_this) {\n return function() {\n return $(\".popover.active\").each(function() {\n return $(this).trigger(\"popup:close\");\n });\n };\n })(this);\n open = (function(_this) {\n return function(onClose) {\n if ($el.hasClass(\"active\")) {\n return close();\n } else {\n closeAll();\n if (!isVisible()) {\n $el.addClass(\"fix\");\n }\n $el.fadeIn(function() {\n $el.addClass(\"active\");\n $(document.body).off(\"popover\");\n return $(document.body).one(\"click.popover\", function() {\n return closeAll();\n });\n });\n return $el.on(\"popup:close\", function(e) {\n return closePopover(onClose);\n });\n }\n };\n })(this);\n close = (function(_this) {\n return function() {\n return $el.trigger(\"popup:close\");\n };\n })(this);\n return {\n open: open,\n close: close,\n closeAll: closeAll\n };\n };\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/raven-logger.coffee\n */\n\n(function() {\n var ExceptionHandlerFactory, module, taiga;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n ExceptionHandlerFactory = function($log, config) {\n var ravenConfig;\n this.config = config;\n ravenConfig = this.config.get(\"ravenConfig\", null);\n if (ravenConfig) {\n $log.debug(\"Using the RavenJS exception handler.\");\n Raven.config(ravenConfig).install();\n return function(exception, cause) {\n $log.error.apply($log, arguments);\n return Raven.captureException(exception);\n };\n } else {\n $log.debug(\"Using the default logging exception handler.\");\n return function(exception, cause) {\n return $log.error.apply($log, arguments);\n };\n }\n };\n\n module.factory(\"$exceptionHandler\", [\"$log\", \"$tgConfig\", ExceptionHandlerFactory]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/tags.coffee\n */\n\n(function() {\n var ColorizeTagsDirective, LbTagLineDirective, TagLineDirective, TagsDirective, bindOnce, module, taiga, trim,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n TagsDirective = function() {\n var formatter, link, parser;\n formatter = function(v) {\n if (_.isArray(v)) {\n return v.join(\", \");\n }\n return \"\";\n };\n parser = function(v) {\n var result;\n if (!v) {\n return [];\n }\n result = _(v.split(\",\")).map(function(x) {\n return _.str.trim(x);\n });\n return result.value();\n };\n link = function($scope, $el, $attrs, $ctrl) {\n $ctrl.$formatters.push(formatter);\n $ctrl.$parsers.push(parser);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n require: \"ngModel\",\n link: link\n };\n };\n\n module.directive(\"tgTags\", TagsDirective);\n\n ColorizeTagsDirective = function() {\n var link, templates;\n templates = {\n backlog: _.template(\"<% _.each(tags, function(tag) { %>\\n \\\"><%- tag.name %>\\n<% }) %>\"),\n kanban: _.template(\"<% _.each(tags, function(tag) { %>\\n
\\\" title=\\\"<%- tag.name %>\\\" />\\n<% }) %>\"),\n taskboard: _.template(\"<% _.each(tags, function(tag) { %>\\n \\\" title=\\\"<%- tag.name %>\\\" />\\n<% }) %>\")\n };\n link = function($scope, $el, $attrs, $ctrl) {\n var render;\n render = function(srcTags) {\n var html, tags, template;\n template = templates[$attrs.tgColorizeTagsType];\n srcTags.sort();\n tags = _.map(srcTags, function(tag) {\n var color;\n color = $scope.project.tags_colors[tag];\n return {\n name: tag,\n color: color\n };\n });\n html = template({\n tags: tags\n });\n return $el.html(html);\n };\n $scope.$watch($attrs.tgColorizeTags, function(tags) {\n if (tags != null) {\n return render(tags);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgColorizeTags\", ColorizeTagsDirective);\n\n LbTagLineDirective = function($rs, $template, $compile) {\n var COMMA_KEY, ENTER_KEY, link, templateTags;\n ENTER_KEY = 13;\n COMMA_KEY = 188;\n templateTags = $template.get(\"common/tag/lb-tag-line-tags.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addValue, deleteValue, hideSaveButton, renderTags, resetInput, saveInputTag, showSaveButton;\n renderTags = function(tags, tagsColors) {\n var ctx, html;\n ctx = {\n tags: _.map(tags, function(t) {\n return {\n name: t,\n color: tagsColors[t]\n };\n })\n };\n _.map(ctx.tags, (function(_this) {\n return function(tag) {\n if (tag.color) {\n return tag.style = \"border-left: 5px solid \" + tag.color;\n }\n };\n })(this));\n html = $compile(templateTags(ctx))($scope);\n return $el.find(\"div.tags-container\").html(html);\n };\n showSaveButton = function() {\n return $el.find(\".save\").removeClass(\"hidden\");\n };\n hideSaveButton = function() {\n return $el.find(\".save\").addClass(\"hidden\");\n };\n resetInput = function() {\n $el.find(\"input\").val(\"\");\n return $el.find(\"input\").autocomplete(\"close\");\n };\n addValue = function(value) {\n var tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue, false);\n if (tags == null) {\n tags = [];\n }\n if (indexOf.call(tags, value) < 0) {\n tags.push(value);\n }\n $scope.$apply(function() {\n return $model.$setViewValue(tags);\n });\n return hideSaveButton();\n };\n deleteValue = function(value) {\n var tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue, false);\n tags = _.pull(tags, value);\n return $scope.$apply(function() {\n return $model.$setViewValue(tags);\n });\n };\n saveInputTag = function() {\n var value;\n value = $el.find(\"input\").val();\n addValue(value);\n return resetInput();\n };\n $el.on(\"keypress\", \"input\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if (event.keyCode === ENTER_KEY) {\n event.preventDefault();\n return saveInputTag();\n } else if (String.fromCharCode(event.keyCode) === ',') {\n event.preventDefault();\n return saveInputTag();\n } else {\n if (target.val().length) {\n return showSaveButton();\n } else {\n return hideSaveButton();\n }\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n event.preventDefault();\n return saveInputTag();\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var target, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n value = target.siblings(\".tag-name\").text();\n return deleteValue(value);\n });\n bindOnce($scope, \"project\", function(project) {\n var positioningFunction;\n positioningFunction = function(position, elements) {\n var menu;\n menu = elements.element.element;\n menu.css(\"width\", elements.target.width);\n menu.css(\"top\", position.top);\n return menu.css(\"left\", position.left);\n };\n return $el.find(\"input\").autocomplete({\n source: _.keys(project.tags_colors),\n position: {\n my: \"left top\",\n using: positioningFunction\n },\n select: function(event, ui) {\n addValue(ui.item.value);\n return ui.item.value = \"\";\n }\n });\n });\n $scope.$watch($attrs.ngModel, function(tags) {\n var ref, tagsColors;\n tagsColors = ((ref = $scope.project) != null ? ref.tags_colors : void 0) || [];\n return renderTags(tags, tagsColors);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\",\n templateUrl: \"common/tag/lb-tag-line.html\"\n };\n };\n\n module.directive(\"tgLbTagLine\", [\"$tgResources\", \"$tgTemplate\", \"$compile\", LbTagLineDirective]);\n\n TagLineDirective = function($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compile) {\n var COMMA_KEY, ENTER_KEY, ESC_KEY, link, templateTags;\n ENTER_KEY = 13;\n ESC_KEY = 27;\n COMMA_KEY = 188;\n templateTags = $template.get(\"common/tag/tags-line-tags.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addValue, deleteValue, hideAddTagButton, hideAddTagButtonText, hideInput, hideSaveButton, isEditable, renderInReadModeOnly, renderTags, resetInput, saveInputTag, showAddTagButton, showAddTagButtonText, showInput, showSaveButton;\n isEditable = function() {\n if ($attrs.requiredPerm != null) {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n }\n return true;\n };\n renderTags = function(tags, tagsColors) {\n var ctx, html;\n ctx = {\n tags: _.map(tags, function(t) {\n return {\n name: t,\n color: tagsColors[t]\n };\n }),\n isEditable: isEditable()\n };\n html = $compile(templateTags(ctx))($scope);\n return $el.find(\"div.tags-container\").html(html);\n };\n renderInReadModeOnly = function() {\n $el.find(\".add-tag\").remove();\n $el.find(\"input\").remove();\n return $el.find(\".save\").remove();\n };\n showAddTagButton = function() {\n return $el.find(\".add-tag\").removeClass(\"hidden\");\n };\n hideAddTagButton = function() {\n return $el.find(\".add-tag\").addClass(\"hidden\");\n };\n showAddTagButtonText = function() {\n return $el.find(\".add-tag-text\").removeClass(\"hidden\");\n };\n hideAddTagButtonText = function() {\n return $el.find(\".add-tag-text\").addClass(\"hidden\");\n };\n showSaveButton = function() {\n return $el.find(\".save\").removeClass(\"hidden\");\n };\n hideSaveButton = function() {\n return $el.find(\".save\").addClass(\"hidden\");\n };\n showInput = function() {\n return $el.find(\"input\").removeClass(\"hidden\").focus();\n };\n hideInput = function() {\n return $el.find(\"input\").addClass(\"hidden\").blur();\n };\n resetInput = function() {\n $el.find(\"input\").val(\"\");\n return $el.find(\"input\").autocomplete(\"close\");\n };\n addValue = $qqueue.bindAdd(function(value) {\n var model, onError, onSuccess, tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue.tags, false);\n if (tags == null) {\n tags = [];\n }\n if (indexOf.call(tags, value) < 0) {\n tags.push(value);\n }\n model = $model.$modelValue.clone();\n model.tags = tags;\n $model.$setViewValue(model);\n onSuccess = function() {\n return $rootScope.$broadcast(\"object:updated\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n model.revert();\n return $model.$setViewValue(model);\n };\n hideSaveButton();\n return $repo.save(model).then(onSuccess, onError);\n });\n deleteValue = $qqueue.bindAdd(function(value) {\n var model, onError, onSuccess, tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue.tags, false);\n tags = _.pull(tags, value);\n model = $model.$modelValue.clone();\n model.tags = tags;\n $model.$setViewValue(model);\n onSuccess = function() {\n return $rootScope.$broadcast(\"object:updated\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n model.revert();\n return $model.$setViewValue(model);\n };\n return $repo.save(model).then(onSuccess, onError);\n });\n saveInputTag = function() {\n var value;\n value = $el.find(\"input\").val();\n addValue(value);\n return resetInput();\n };\n $el.on(\"keypress\", \"input\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if (event.keyCode === ENTER_KEY) {\n return saveInputTag();\n } else if (String.fromCharCode(event.keyCode) === ',') {\n event.preventDefault();\n return saveInputTag();\n } else {\n if (target.val().length) {\n return showSaveButton();\n } else {\n return hideSaveButton();\n }\n }\n });\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === ESC_KEY) {\n resetInput();\n hideInput();\n hideSaveButton();\n return showAddTagButton();\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n event.preventDefault();\n return saveInputTag();\n });\n $el.on(\"click\", \".add-tag\", function(event) {\n event.preventDefault();\n hideAddTagButton();\n return showInput();\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var target, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n value = target.siblings(\".tag-name\").text();\n return deleteValue(value);\n });\n bindOnce($scope, \"project.tags_colors\", function(tags_colors) {\n var positioningFunction;\n if (!isEditable()) {\n renderInReadModeOnly();\n return;\n }\n showAddTagButton();\n positioningFunction = function(position, elements) {\n var menu;\n menu = elements.element.element;\n menu.css(\"width\", elements.target.width);\n menu.css(\"top\", position.top);\n return menu.css(\"left\", position.left);\n };\n return $el.find(\"input\").autocomplete({\n source: _.keys(tags_colors),\n position: {\n my: \"left top\",\n using: positioningFunction\n },\n select: function(event, ui) {\n addValue(ui.item.value);\n return ui.item.value = \"\";\n }\n });\n });\n $scope.$watch($attrs.ngModel, function(model) {\n var ref, ref1, tagsColors;\n if (!model) {\n return;\n }\n if ((ref = model.tags) != null ? ref.length : void 0) {\n hideAddTagButtonText();\n } else {\n showAddTagButtonText();\n }\n tagsColors = ((ref1 = $scope.project) != null ? ref1.tags_colors : void 0) || [];\n return renderTags(model.tags, tagsColors);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\",\n templateUrl: \"common/tag/tag-line.html\"\n };\n };\n\n module.directive(\"tgTagLine\", [\"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", TagLineDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/wisiwyg.coffee\n */\n\n(function() {\n var MarkitupDirective, bindOnce, module, taiga,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n MarkitupDirective = function($rootscope, $rs, $selectedText, $template, $compile, $translate) {\n var link, previewTemplate;\n previewTemplate = $template.get(\"common/wysiwyg/wysiwyg-markitup-preview.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addLine, cancelablePromise, closePreviewMode, element, markdownTitle, prepareUrlFormatting, preview, previewDomNode, renderMarkItUp, setCaretPosition, unbind, urlFormatting;\n element = angular.element($el);\n previewDomNode = $(\"
\", {\n \"class\": \"preview\"\n });\n closePreviewMode = function() {\n element.parents(\".markdown\").find(\".preview\").remove();\n return element.parents(\".markItUp\").show();\n };\n $scope.$on(\"markdown-editor:submit\", function() {\n return closePreviewMode();\n });\n cancelablePromise = null;\n preview = function() {\n var markItUpDomNode, markdownDomNode;\n markdownDomNode = element.parents(\".markdown\");\n markItUpDomNode = element.parents(\".markItUp\");\n return $rs.mdrender.render($scope.projectId, $model.$modelValue).then(function(data) {\n var html, markdown;\n html = previewTemplate({\n data: data.data\n });\n html = $compile(html)($scope);\n markdownDomNode.append(html);\n markItUpDomNode.hide();\n markdown = element.closest(\".markdown\");\n return markdown.on(\"mouseup.preview\", \".preview\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.target);\n if (!target.is('a') && $selectedText.get().length) {\n return;\n }\n markdown.off(\".preview\");\n return closePreviewMode();\n });\n });\n };\n setCaretPosition = function(textarea, caretPosition) {\n var line, range, scrollRelation, totalLines;\n if (textarea.createTextRange) {\n range = textarea.createTextRange();\n range.move(\"character\", caretPosition);\n range.select();\n } else if (textarea.selectionStart) {\n textarea.focus();\n textarea.setSelectionRange(caretPosition, caretPosition);\n }\n totalLines = textarea.value.split(\"\\n\").length;\n line = textarea.value.slice(0, +(caretPosition - 1) + 1 || 9e9).split(\"\\n\").length;\n scrollRelation = line / totalLines;\n return $el.scrollTop((scrollRelation * $el[0].scrollHeight) - ($el.height() / 2));\n };\n addLine = function(textarea, nline, replace) {\n var cursorPosition, j, key, len, line, lines;\n lines = textarea.value.split(\"\\n\");\n if (replace) {\n lines[nline] = replace + lines[nline];\n } else {\n lines[nline] = \"\";\n }\n cursorPosition = 0;\n for (key = j = 0, len = lines.length; j < len; key = ++j) {\n line = lines[key];\n cursorPosition += line.length + 1 || 1;\n if (key === nline) {\n break;\n }\n }\n textarea.value = lines.join(\"\\n\");\n if (replace) {\n return cursorPosition - lines[nline].length + replace.length - 1;\n } else {\n return cursorPosition;\n }\n };\n prepareUrlFormatting = function(markItUp) {\n var indices, regex, result;\n regex = /(<<<|>>>)/gi;\n result = 0;\n indices = [];\n while ((result = regex.exec(markItUp.textarea.value))) {\n indices.push(result.index);\n }\n return markItUp.donotparse = indices;\n };\n urlFormatting = function(markItUp) {\n var endIndex, ref, ref1, regex, result, startIndex, url, value;\n regex = /<<>>/gi;\n endIndex = 0;\n while (true) {\n result = regex.exec(markItUp.textarea.value);\n if (!result) {\n break;\n }\n if (ref1 = result.index, indexOf.call(markItUp.donotparse, ref1) < 0) {\n endIndex = result.index;\n break;\n }\n }\n value = markItUp.textarea.value;\n url = value.substring(startIndex, endIndex).replace('<<<', '').replace('>>>', '');\n url = url.replace('(', '%28').replace(')', '%29');\n url = url.replace('[', '%5B').replace(']', '%5D');\n value = value.substring(0, startIndex) + url + value.substring(endIndex + 3, value.length);\n markItUp.textarea.value = value;\n return markItUp.donotparse = void 0;\n };\n markdownTitle = function(markItUp, char) {\n var heading, i, j, n, ref;\n heading = \"\";\n n = $.trim(markItUp.selection || markItUp.placeHolder).length;\n for (i = j = 0, ref = n - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {\n heading += char;\n }\n return \"\\n\" + heading + \"\\n\";\n };\n renderMarkItUp = function() {\n var markdownSettings;\n markdownSettings = {\n nameSpace: \"markdown\",\n onShiftEnter: {\n keepDefault: false,\n openWith: \"\\n\\n\"\n },\n onEnter: {\n keepDefault: false,\n replaceWith: function() {\n if (!$('.textcomplete-dropdown').is(':visible')) {\n return \"\\n\";\n }\n },\n afterInsert: function(data) {\n var cursorLine, emptyListItem, lastLine, lines, markdownCaretPositon, match, newLineContent, nline, replace;\n lines = data.textarea.value.split(\"\\n\");\n if (data.caretPosition > 0) {\n cursorLine = data.textarea.value.slice(0, +(data.caretPosition - 1) + 1 || 9e9).split(\"\\n\").length;\n } else {\n cursorLine = 1;\n }\n newLineContent = data.textarea.value.slice(data.caretPosition).split(\"\\n\")[0];\n lastLine = lines[cursorLine - 1];\n match = lastLine.match(/^(\\s*- ).*/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*)\\-\\s$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = \"\" + match[1];\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n match = lastLine.match(/^(\\s*\\* ).*/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*\\* )$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = \"\" + match[1];\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n match = lastLine.match(/^(\\s*)(\\d+)\\.\\s/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*)(\\d+)\\.\\s$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = (match[1] + (parseInt(match[2], 10) + 1)) + \". \";\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n if (markdownCaretPositon) {\n return setCaretPosition(data.textarea, markdownCaretPositon);\n }\n }\n },\n markupSet: [\n {\n name: $translate.instant(\"COMMON.WYSIWYG.H1_BUTTON\"),\n key: \"1\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H1_SAMPLE_TEXT\"),\n closeWith: function(markItUp) {\n return markdownTitle(markItUp, \"=\");\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.H2_BUTTON\"),\n key: \"2\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H2_SAMPLE_TEXT\"),\n closeWith: function(markItUp) {\n return markdownTitle(markItUp, \"-\");\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.H3_BUTTON\"),\n key: \"3\",\n openWith: \"### \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H3_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.BOLD_BUTTON\"),\n key: \"B\",\n openWith: \"**\",\n closeWith: \"**\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.BOLD_BUTTON_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT\"),\n key: \"I\",\n openWith: \"_\",\n closeWith: \"_\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.STRIKE_BUTTON\"),\n key: \"S\",\n openWith: \"~~\",\n closeWith: \"~~\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.STRIKE_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.BULLETED_LIST_BUTTON\"),\n openWith: \"- \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.BULLETED_LIST_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.NUMERIC_LIST_BUTTON\"),\n openWith: function(markItUp) {\n return markItUp.line + \". \";\n },\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.NUMERIC_LIST_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.PICTURE_BUTTON\"),\n key: \"P\",\n openWith: \"![\",\n closeWith: '](<<<[![Url:!:http://]!]>>> \"[![Title]!]\")',\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.PICTURE_SAMPLE_TEXT\"),\n beforeInsert: function(markItUp) {\n return prepareUrlFormatting(markItUp);\n },\n afterInsert: function(markItUp) {\n return urlFormatting(markItUp);\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.LINK_BUTTON\"),\n key: \"L\",\n openWith: \"[\",\n closeWith: '](<<<[![Url:!:http://]!]>>> \"[![Title]!]\")',\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.LINK_SAMPLE_TEXT\"),\n beforeInsert: function(markItUp) {\n return prepareUrlFormatting(markItUp);\n },\n afterInsert: function(markItUp) {\n return urlFormatting(markItUp);\n }\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.QUOTE_BLOCK_BUTTON\"),\n openWith: \"> \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.QUOTE_BLOCK_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.CODE_BLOCK_BUTTON\"),\n openWith: \"```\\n\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.CODE_BLOCK_SAMPLE_TEXT\"),\n closeWith: \"\\n```\"\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.PREVIEW_BUTTON\"),\n call: preview,\n className: \"preview-icon\"\n }\n ],\n afterInsert: function(event) {\n var target;\n target = angular.element(event.textarea);\n return $model.$setViewValue(target.val());\n }\n };\n return element.markItUpRemove().markItUp(markdownSettings).textcomplete([\n {\n cache: true,\n match: /(^|\\s)#([a-z0-9]+)$/i,\n search: function(term, callback) {\n var filter, searchProps, searchTypes;\n term = taiga.slugify(term);\n searchTypes = ['issues', 'tasks', 'userstories'];\n searchProps = ['ref', 'subject'];\n filter = (function(_this) {\n return function(item) {\n var j, len, prop;\n for (j = 0, len = searchProps.length; j < len; j++) {\n prop = searchProps[j];\n if (taiga.slugify(item[prop]).indexOf(term) >= 0) {\n return true;\n }\n }\n return false;\n };\n })(this);\n if (cancelablePromise) {\n cancelablePromise.abort();\n }\n cancelablePromise = $rs.search[\"do\"]($scope.projectId, term);\n cancelablePromise.then((function(_this) {\n return function(res) {\n var j, len, results, type;\n if (res.count < 1 || res.count === res.wikipages.length) {\n return callback([]);\n } else {\n results = [];\n for (j = 0, len = searchTypes.length; j < len; j++) {\n type = searchTypes[j];\n if (res[type] && res[type].length > 0) {\n results.push(callback(res[type].filter(filter), true));\n } else {\n results.push(void 0);\n }\n }\n return results;\n }\n };\n })(this));\n return callback([]);\n },\n replace: function(res) {\n return \"$1\\#\" + res.ref + \" \";\n },\n template: function(res, term) {\n return \"\\#\" + res.ref + \" - \" + res.subject;\n }\n }, {\n cache: true,\n match: /(^|\\s)@([a-z0-9\\-\\._]{2,})$/i,\n search: function(term, callback) {\n var searchProps, username;\n username = taiga.slugify(term);\n searchProps = ['username', 'full_name', 'full_name_display'];\n if ($scope.project.members.length < 1) {\n return callback([]);\n } else {\n return callback($scope.project.members.filter((function(_this) {\n return function(user) {\n var j, len, prop;\n for (j = 0, len = searchProps.length; j < len; j++) {\n prop = searchProps[j];\n if (taiga.slugify(user[prop]).indexOf(username) >= 0) {\n return true;\n }\n }\n return false;\n };\n })(this)));\n }\n },\n replace: function(user) {\n return \"$1@\" + user.username + \" \";\n },\n template: function(user) {\n return user.username + \" - \" + user.full_name_display;\n }\n }, {\n cache: true,\n match: /(^|\\s)\\[\\[([a-z0-9\\-]+)$/i,\n search: function(term, callback) {\n term = taiga.slugify(term);\n return $rs.search[\"do\"]($scope.projectId, term).then((function(_this) {\n return function(res) {\n if (res.count < 1) {\n callback([]);\n }\n if (res.count < 1 || !res.wikipages || res.wikipages.length <= 0) {\n callback([]);\n } else {\n callback(res.wikipages.filter(function(page) {\n return taiga.slugify(page['slug']).indexOf(term) >= 0;\n }), true);\n }\n return callback([]);\n };\n })(this));\n },\n replace: function(res) {\n return \"$1[[\" + res.slug + \"]]\";\n },\n template: function(res, term) {\n return res.slug;\n }\n }\n ], {\n debounce: 200\n });\n };\n renderMarkItUp();\n unbind = $rootscope.$on(\"$translateChangeEnd\", renderMarkItUp);\n element.on(\"keypress\", function(event) {\n return $scope.$apply();\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return unbind();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgMarkitup\", [\"$rootScope\", \"$tgResources\", \"$selectedText\", \"$tgTemplate\", \"$compile\", \"$translate\", MarkitupDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/main.coffee\n */\n\n(function() {\n var BacklogFiltersDirective, bindOnce, debounceLeading, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n debounceLeading = this.taiga.debounceLeading;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogFiltersDirective = function($q, $log, $location, $templates) {\n var link, template, templateSelected;\n template = $templates.get(\"backlog/filters.html\", true);\n templateSelected = $templates.get(\"backlog/filter-selected.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, currentFiltersType, getFiltersType, initializeSelectedFilters, reloadUserstories, renderFilters, renderSelectedFilters, selectQFilter, selectedFilters, showCategories, showFilters, toggleFilterSelection;\n currentFiltersType = '';\n $ctrl = $el.closest(\".wrapper\").controller();\n selectedFilters = [];\n showFilters = function(title, type) {\n $el.find(\".filters-cats\").hide();\n $el.find(\".filter-list\").removeClass(\"hidden\");\n $el.find(\"h2.breadcrumb\").removeClass(\"hidden\");\n $el.find(\"h2 a.subfilter span.title\").html(title);\n $el.find(\"h2 a.subfilter span.title\").prop(\"data-type\", type);\n return currentFiltersType = getFiltersType();\n };\n showCategories = function() {\n $el.find(\".filters-cats\").show();\n $el.find(\".filter-list\").addClass(\"hidden\");\n return $el.find(\"h2.breadcrumb\").addClass(\"hidden\");\n };\n initializeSelectedFilters = function() {\n var i, len, name, ref, val, values;\n showCategories();\n selectedFilters = [];\n ref = $scope.filters;\n for (name in ref) {\n values = ref[name];\n for (i = 0, len = values.length; i < len; i++) {\n val = values[i];\n if (val.selected) {\n selectedFilters.push(val);\n }\n }\n }\n return renderSelectedFilters();\n };\n renderSelectedFilters = function() {\n var html;\n _.map(selectedFilters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = templateSelected({\n filters: selectedFilters\n });\n return $el.find(\".filters-applied\").html(html);\n };\n renderFilters = function(filters) {\n var html;\n _.map(filters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = template({\n filters: filters\n });\n return $el.find(\".filter-list\").html(html);\n };\n getFiltersType = function() {\n return $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n };\n reloadUserstories = function() {\n currentFiltersType = getFiltersType();\n return $q.all([$ctrl.loadUserstories(), $ctrl.generateFilters()]).then(function() {\n var currentFilters;\n currentFilters = $scope.filters[currentFiltersType];\n return renderFilters(_.reject(currentFilters, \"selected\"));\n });\n };\n toggleFilterSelection = function(type, id) {\n var filter, filters;\n currentFiltersType = getFiltersType();\n filters = $scope.filters[type];\n filter = _.find(filters, {\n id: id\n });\n filter.selected = !filter.selected;\n if (filter.selected) {\n selectedFilters.push(filter);\n $scope.$apply(function() {\n return $ctrl.selectFilter(type, id);\n });\n } else {\n selectedFilters = _.reject(selectedFilters, function(selected) {\n return filter.type === selected.type && filter.id === selected.id;\n });\n $ctrl.unselectFilter(type, id);\n }\n renderSelectedFilters(selectedFilters);\n if (type === currentFiltersType) {\n renderFilters(_.reject(filters, \"selected\"));\n }\n return reloadUserstories();\n };\n selectQFilter = debounceLeading(100, function(value) {\n if (value === void 0) {\n return;\n }\n if (value.length === 0) {\n $ctrl.replaceFilter(\"q\", null);\n } else {\n $ctrl.replaceFilter(\"q\", value);\n }\n return reloadUserstories();\n });\n $scope.$watch(\"filtersQ\", selectQFilter);\n $scope.$on(\"backlog:loaded\", function(ctx) {\n return initializeSelectedFilters();\n });\n $scope.$on(\"filters:update\", function(ctx) {\n return $ctrl.generateFilters().then(function() {\n var filters;\n filters = $scope.filters[currentFiltersType];\n if (currentFiltersType) {\n return renderFilters(_.reject(filters, \"selected\"));\n }\n });\n });\n $el.on(\"click\", \".filters-cats > ul > li > a\", function(event) {\n var tags, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n tags = $scope.filters[target.data(\"type\")];\n renderFilters(_.reject(tags, \"selected\"));\n return showFilters(target.attr(\"title\"), target.data('type'));\n });\n $el.on(\"click\", \".filters-inner > .filters-step-cat > .breadcrumb > .back\", function(event) {\n event.preventDefault();\n return showCategories();\n });\n $el.on(\"click\", \".filters-applied a\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n id = target.data(\"id\");\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n return $el.on(\"click\", \".filter-list .single-filter\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n if (target.hasClass(\"active\")) {\n target.removeClass(\"active\");\n } else {\n target.addClass(\"active\");\n }\n id = target.data(\"id\");\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogFilters\", [\"$q\", \"$log\", \"$tgLocation\", \"$tgTemplate\", BacklogFiltersDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/lightboxes.coffee\n */\n\n(function() {\n var CreateEditSprint, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaBacklog\");\n\n CreateEditSprint = function($repo, $confirm, $rs, $rootscope, lightboxService, $loading, $translate) {\n var link;\n link = function($scope, $el, attrs) {\n var createSprint, getLastSprint, hasErrors, remove, resetSprint, submit;\n hasErrors = false;\n createSprint = true;\n resetSprint = function() {\n return $scope.sprint = {\n project: null,\n name: null,\n estimated_start: null,\n estimated_finish: null\n };\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, newSprint, prettyDate, promise, submitButton, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n submitButton = $el.find(\".submit-button\");\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n hasErrors = true;\n $el.find(\".last-sprint-name\").addClass(\"disappear\");\n return;\n }\n hasErrors = false;\n newSprint = angular.copy($scope.sprint);\n broadcastEvent = null;\n if (createSprint) {\n newSprint.estimated_start = moment(newSprint.estimated_start, prettyDate).format(\"YYYY-MM-DD\");\n newSprint.estimated_finish = moment(newSprint.estimated_finish, prettyDate).format(\"YYYY-MM-DD\");\n promise = $repo.create(\"milestones\", newSprint);\n broadcastEvent = \"sprintform:create:success\";\n } else {\n newSprint.setAttr(\"estimated_start\", moment(newSprint.estimated_start, prettyDate).format(\"YYYY-MM-DD\"));\n newSprint.setAttr(\"estimated_finish\", moment(newSprint.estimated_finish, prettyDate).format(\"YYYY-MM-DD\"));\n promise = $repo.save(newSprint);\n broadcastEvent = \"sprintform:edit:success\";\n }\n currentLoading = $loading().target(submitButton).start();\n promise.then(function(data) {\n currentLoading.finish();\n if (createSprint) {\n $scope.sprintsCounter += 1;\n }\n $rootscope.$broadcast(broadcastEvent, data);\n return lightboxService.close($el);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"light-error\", data._error_message);\n } else if (data.__all__) {\n return $confirm.notify(\"light-error\", data.__all__[0]);\n }\n });\n };\n })(this));\n remove = function() {\n var message, title;\n title = $translate.instant(\"LIGHTBOX.DELETE_SPRINT.TITLE\");\n message = $scope.sprint.name;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onSuccess = function() {\n askResponse.finish();\n $scope.milestonesCounter -= 1;\n lightboxService.close($el);\n return $rootscope.$broadcast(\"sprintform:remove:success\", $scope.sprint);\n };\n onError = function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n };\n return $repo.remove($scope.sprint).then(onSuccess, onError);\n };\n })(this));\n };\n getLastSprint = function() {\n var openSprints, sortedSprints;\n openSprints = _.filter($scope.sprints, function(sprint) {\n return !sprint.closed;\n });\n sortedSprints = _.sortBy(openSprints, function(sprint) {\n return moment(sprint.estimated_finish, 'YYYY-MM-DD').format('X');\n });\n return sortedSprints[sortedSprints.length - 1];\n };\n $scope.$on(\"sprintform:create\", function(event, projectId) {\n var estimatedFinish, estimatedStart, form, lastSprint, lastSprintNameDom, prettyDate, text;\n resetSprint();\n form = $el.find(\"form\").checksley();\n form.reset();\n createSprint = true;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n $scope.sprint.project = projectId;\n $scope.sprint.name = null;\n $scope.sprint.slug = null;\n lastSprint = getLastSprint();\n estimatedStart = moment();\n if (lastSprint) {\n estimatedStart = moment(lastSprint.estimated_finish);\n } else if ($scope.sprint.estimated_start) {\n estimatedStart = moment($scope.sprint.estimated_start);\n }\n $scope.sprint.estimated_start = estimatedStart.format(prettyDate);\n estimatedFinish = moment().add(2, \"weeks\");\n if (lastSprint) {\n estimatedFinish = moment(lastSprint.estimated_finish).add(2, \"weeks\");\n } else if ($scope.sprint.estimated_finish) {\n estimatedFinish = moment($scope.sprint.estimated_finish);\n }\n $scope.sprint.estimated_finish = estimatedFinish.format(prettyDate);\n lastSprintNameDom = $el.find(\".last-sprint-name\");\n if ((lastSprint != null ? lastSprint.name : void 0) != null) {\n text = $translate.instant(\"LIGHTBOX.ADD_EDIT_SPRINT.LAST_SPRINT_NAME\", {\n lastSprint: lastSprint.name\n });\n lastSprintNameDom.html(text);\n }\n $el.find(\".delete-sprint\").addClass(\"hidden\");\n text = $translate.instant(\"LIGHTBOX.ADD_EDIT_SPRINT.TITLE\");\n $el.find(\".title\").text(text);\n text = $translate.instant(\"COMMON.CREATE\");\n $el.find(\".button-green\").text(text);\n lightboxService.open($el);\n $el.find(\".sprint-name\").focus();\n return $el.find(\".last-sprint-name\").removeClass(\"disappear\");\n });\n $scope.$on(\"sprintform:edit\", function(ctx, sprint) {\n var editSprint, prettyDate, save;\n resetSprint();\n createSprint = false;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n $scope.$apply(function() {\n $scope.sprint = sprint;\n $scope.sprint.estimated_start = moment($scope.sprint.estimated_start).format(prettyDate);\n return $scope.sprint.estimated_finish = moment($scope.sprint.estimated_finish).format(prettyDate);\n });\n $el.find(\".delete-sprint\").removeClass(\"hidden\");\n editSprint = $translate.instant(\"BACKLOG.EDIT_SPRINT\");\n $el.find(\".title\").text(editSprint);\n save = $translate.instant(\"COMMON.SAVE\");\n $el.find(\".button-green\").text(save);\n lightboxService.open($el);\n $el.find(\".sprint-name\").focus().select();\n return $el.find(\".last-sprint-name\").addClass(\"disappear\");\n });\n $el.on(\"keyup\", \".sprint-name\", function(event) {\n if ($el.find(\".sprint-name\").val().length > 0 || hasErrors) {\n return $el.find(\".last-sprint-name\").addClass(\"disappear\");\n } else {\n return $el.find(\".last-sprint-name\").removeClass(\"disappear\");\n }\n });\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".delete-sprint .icon-delete\", function(event) {\n event.preventDefault();\n return remove();\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return resetSprint();\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateEditSprint\", [\"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$translate\", CreateEditSprint]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/main.coffee\n */\n\n(function() {\n var BacklogController, BacklogDirective, BurndownBacklogGraphDirective, TgBacklogProgressBarDirective, ToggleBurndownVisibility, UsPointsDirective, UsRolePointsSelectorDirective, bindMethods, bindOnce, generateHash, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n generateHash = this.taiga.generateHash;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogController = (function(superClass) {\n extend(BacklogController, superClass);\n\n BacklogController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\", \"$tgLoading\", \"tgResources\"];\n\n function BacklogController(scope1, rootscope, repo, confirm, rs, params1, q, location, appMetaService, navUrls, events, analytics, translate, loading, rs2) {\n var promise;\n this.scope = scope1;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params1;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n this.loading = loading;\n this.rs2 = rs2;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"BACKLOG.SECTION_NAME\");\n this.showTags = false;\n this.activeFilters = false;\n this.scope.showGraphPlaceholder = null;\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"BACKLOG.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"BACKLOG.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n _this.appMetaService.setAll(title, description);\n if (_this.rs.userstories.getShowTags(_this.scope.projectId)) {\n _this.showTags = true;\n return _this.scope.$broadcast(\"showTags\", _this.showTags);\n }\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n BacklogController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"usform:bulk:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.loadProjectStats();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"bulk create userstory on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"sprintform:create:success\", (function(_this) {\n return function() {\n _this.loadSprints();\n _this.loadProjectStats();\n return _this.analytics.trackEvent(\"sprint\", \"create\", \"create sprint on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"usform:new:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.loadProjectStats();\n _this.rootscope.$broadcast(\"filters:update\");\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"create userstory on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"sprintform:edit:success\", (function(_this) {\n return function() {\n return _this.loadProjectStats();\n };\n })(this));\n this.scope.$on(\"sprintform:remove:success\", (function(_this) {\n return function(event, sprint) {\n _this.loadSprints();\n _this.loadProjectStats();\n _this.loadUserstories();\n if (sprint.closed) {\n _this.loadClosedSprints();\n }\n return _this.rootscope.$broadcast(\"filters:update\");\n };\n })(this));\n this.scope.$on(\"usform:edit:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.rootscope.$broadcast(\"filters:update\");\n };\n })(this));\n this.scope.$on(\"sprint:us:move\", this.moveUs);\n this.scope.$on(\"sprint:us:moved\", this.loadSprints);\n this.scope.$on(\"sprint:us:moved\", this.loadProjectStats);\n this.scope.$on(\"backlog:load-closed-sprints\", this.loadClosedSprints);\n return this.scope.$on(\"backlog:unload-closed-sprints\", this.unloadClosedSprints);\n };\n\n BacklogController.prototype.initializeSubscription = function() {\n var routingKey1, routingKey2;\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n _this.loadUserstories();\n return _this.loadSprints();\n };\n })(this));\n routingKey2 = \"changes.project.\" + this.scope.projectId + \".milestones\";\n return this.events.subscribe(this.scope, routingKey2, (function(_this) {\n return function(message) {\n return _this.loadSprints();\n };\n })(this));\n };\n\n BacklogController.prototype.toggleShowTags = function() {\n return this.scope.$apply((function(_this) {\n return function() {\n _this.showTags = !_this.showTags;\n return _this.rs.userstories.storeShowTags(_this.scope.projectId, _this.showTags);\n };\n })(this));\n };\n\n BacklogController.prototype.toggleActiveFilters = function() {\n return this.activeFilters = !this.activeFilters;\n };\n\n BacklogController.prototype.loadProjectStats = function() {\n return this.rs.projects.stats(this.scope.projectId).then((function(_this) {\n return function(stats) {\n var totalPoints;\n _this.scope.stats = stats;\n totalPoints = stats.total_points ? stats.total_points : stats.defined_points;\n if (totalPoints) {\n _this.scope.stats.completedPercentage = Math.round(100 * stats.closed_points / totalPoints);\n } else {\n _this.scope.stats.completedPercentage = 0;\n }\n _this.scope.showGraphPlaceholder = !((stats.total_points != null) && (stats.total_milestones != null));\n return stats;\n };\n })(this));\n };\n\n BacklogController.prototype.unloadClosedSprints = function() {\n return this.scope.$apply((function(_this) {\n return function() {\n _this.scope.closedSprints = [];\n return _this.rootscope.$broadcast(\"closed-sprints:reloaded\", []);\n };\n })(this));\n };\n\n BacklogController.prototype.loadClosedSprints = function() {\n var params;\n params = {\n closed: true\n };\n return this.rs.sprints.list(this.scope.projectId, params).then((function(_this) {\n return function(result) {\n var j, len, sprint, sprints;\n sprints = result.milestones;\n _this.scope.totalClosedMilestones = result.closed;\n for (j = 0, len = sprints.length; j < len; j++) {\n sprint = sprints[j];\n sprint.user_stories = _.sortBy(sprint.user_stories, \"sprint_order\");\n }\n _this.scope.closedSprints = sprints;\n _this.scope.closedSprintsById = groupBy(sprints, function(x) {\n return x.id;\n });\n _this.rootscope.$broadcast(\"closed-sprints:reloaded\", sprints);\n return sprints;\n };\n })(this));\n };\n\n BacklogController.prototype.loadSprints = function() {\n var params;\n params = {\n closed: false\n };\n return this.rs.sprints.list(this.scope.projectId, params).then((function(_this) {\n return function(result) {\n var j, len, sprint, sprints;\n sprints = result.milestones;\n _this.scope.totalMilestones = sprints;\n _this.scope.totalClosedMilestones = result.closed;\n _this.scope.totalOpenMilestones = result.open;\n _this.scope.totalMilestones = _this.scope.totalOpenMilestones + _this.scope.totalClosedMilestones;\n for (j = 0, len = sprints.length; j < len; j++) {\n sprint = sprints[j];\n sprint.user_stories = _.sortBy(sprint.user_stories, \"sprint_order\");\n }\n _this.scope.sprints = sprints;\n _this.scope.openSprints = _.filter(sprints, function(sprint) {\n return !sprint.closed;\n }).reverse();\n if (!_this.scope.closedSprints) {\n _this.scope.closedSprints = [];\n }\n _this.scope.sprintsCounter = sprints.length;\n _this.scope.sprintsById = groupBy(sprints, function(x) {\n return x.id;\n });\n _this.rootscope.$broadcast(\"sprints:loaded\", sprints);\n _this.scope.currentSprint = _this.findCurrentSprint();\n return sprints;\n };\n })(this));\n };\n\n BacklogController.prototype.restoreFilters = function() {\n var selectedStatuses, selectedTags;\n selectedTags = this.scope.oldSelectedTags;\n selectedStatuses = this.scope.oldSelectedStatuses;\n if (!selectedStatuses && !selectedStatuses) {\n return;\n }\n this.scope.filtersQ = this.scope.filtersQOld;\n this.replaceFilter(\"q\", this.scope.filtersQ);\n _.each([selectedTags, selectedStatuses], (function(_this) {\n return function(filterGrp) {\n return _.each(filterGrp, function(item) {\n var filter, filters;\n filters = _this.scope.filters[item.type];\n filter = _.find(filters, {\n id: item.id\n });\n filter.selected = true;\n return _this.selectFilter(item.type, item.id);\n });\n };\n })(this));\n return this.loadUserstories();\n };\n\n BacklogController.prototype.resetFilters = function() {\n var selectedStatuses, selectedTags;\n selectedTags = _.filter(this.scope.filters.tags, \"selected\");\n selectedStatuses = _.filter(this.scope.filters.status, \"selected\");\n this.scope.oldSelectedTags = selectedTags;\n this.scope.oldSelectedStatuses = selectedStatuses;\n this.scope.filtersQOld = this.scope.filtersQ;\n this.scope.filtersQ = void 0;\n this.replaceFilter(\"q\", this.scope.filtersQ);\n _.each([selectedTags, selectedStatuses], (function(_this) {\n return function(filterGrp) {\n return _.each(filterGrp, function(item) {\n var filter, filters;\n filters = _this.scope.filters[item.type];\n filter = _.find(filters, {\n id: item.id\n });\n filter.selected = false;\n return _this.unselectFilter(item.type, item.id);\n });\n };\n })(this));\n return this.loadUserstories();\n };\n\n BacklogController.prototype.loadUserstories = function() {\n var promise;\n this.scope.httpParams = this.getUrlFilters();\n this.rs.userstories.storeQueryParams(this.scope.projectId, this.scope.httpParams);\n promise = this.rs.userstories.listUnassigned(this.scope.projectId, this.scope.httpParams);\n return promise.then((function(_this) {\n return function(userstories) {\n _this.scope.userstories = _.sortBy(userstories, \"backlog_order\");\n _this.setSearchDataFilters();\n scopeDefer(_this.scope, function() {\n return _this.scope.$broadcast(\"userstories:loaded\");\n });\n return userstories;\n };\n })(this));\n };\n\n BacklogController.prototype.loadBacklog = function() {\n return this.q.all([this.loadProjectStats(), this.loadSprints(), this.loadUserstories()]);\n };\n\n BacklogController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_backlog_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.closedMilestones = !!project.total_closed_milestones;\n _this.scope.$emit('project:loaded', project);\n _this.scope.points = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"id\");\n return project;\n };\n })(this));\n };\n\n BacklogController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.initializeSubscription();\n };\n })(this));\n return promise.then((function(_this) {\n return function() {\n return _this.loadBacklog();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.generateFilters();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.scope.$emit(\"backlog:loaded\");\n };\n })(this));\n };\n\n BacklogController.prototype.prepareBulkUpdateData = function(uses, field) {\n if (field == null) {\n field = \"backlog_order\";\n }\n return _.map(uses, function(x) {\n return {\n \"us_id\": x.id,\n \"order\": x[field]\n };\n });\n };\n\n BacklogController.prototype.resortUserStories = function(uses, field) {\n var index, item, items, j, len;\n if (field == null) {\n field = \"backlog_order\";\n }\n items = [];\n for (index = j = 0, len = uses.length; j < len; index = ++j) {\n item = uses[index];\n item[field] = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n BacklogController.prototype.moveUs = function(ctx, usList, newUsIndex, newSprintId) {\n var data, items, j, l, len, len1, len2, m, movedFromClosedSprint, movedToClosedSprint, newSprint, oldSprintId, project, promise, promises, sprint, us, userstories;\n oldSprintId = usList[0].milestone;\n project = usList[0].project;\n movedFromClosedSprint = false;\n movedToClosedSprint = false;\n sprint = this.scope.sprintsById[oldSprintId];\n if (!sprint && this.scope.closedSprintsById) {\n sprint = this.scope.closedSprintsById[oldSprintId];\n if (sprint) {\n movedFromClosedSprint = true;\n }\n }\n newSprint = this.scope.sprintsById[newSprintId];\n if (!newSprint && newSprintId) {\n newSprint = this.scope.closedSprintsById[newSprintId];\n if (newSprint) {\n movedToClosedSprint = true;\n }\n }\n if (newSprintId === oldSprintId) {\n items = null;\n userstories = null;\n if (newSprintId === null) {\n userstories = this.scope.userstories;\n } else {\n userstories = newSprint.user_stories;\n }\n this.scope.$apply(function() {\n var args, j, key, len, r, us;\n for (key = j = 0, len = usList.length; j < len; key = ++j) {\n us = usList[key];\n r = userstories.indexOf(us);\n userstories.splice(r, 1);\n }\n args = [newUsIndex, 0].concat(usList);\n return Array.prototype.splice.apply(userstories, args);\n });\n if (newSprintId === null) {\n items = this.resortUserStories(userstories, \"backlog_order\");\n data = this.prepareBulkUpdateData(items, \"backlog_order\");\n this.rs.userstories.bulkUpdateBacklogOrder(project, data).then((function(_this) {\n return function() {\n var j, len, results, us;\n results = [];\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n };\n })(this));\n } else {\n items = this.resortUserStories(userstories, \"sprint_order\");\n data = this.prepareBulkUpdateData(items, \"sprint_order\");\n this.rs.userstories.bulkUpdateSprintOrder(project, data).then((function(_this) {\n return function() {\n var j, len, results, us;\n results = [];\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n };\n })(this));\n }\n return promise;\n }\n if (newSprintId === null) {\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n us.milestone = null;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, key, l, len1, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(_this.scope.userstories, args);\n results = [];\n for (key = l = 0, len1 = usList.length; l < len1; key = ++l) {\n us = usList[key];\n r = sprint.user_stories.indexOf(us);\n results.push(sprint.user_stories.splice(r, 1));\n }\n return results;\n };\n })(this));\n promise = this.repo.save(us);\n promise = promise.then((function(_this) {\n return function() {\n items = _this.resortUserStories(_this.scope.userstories, \"backlog_order\");\n data = _this.prepareBulkUpdateData(items, \"backlog_order\");\n return _this.rs.userstories.bulkUpdateBacklogOrder(us.project, data).then(function() {\n _this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId);\n if (movedFromClosedSprint) {\n return _this.rootscope.$broadcast(\"backlog:load-closed-sprints\");\n }\n });\n };\n })(this));\n promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n return promise;\n }\n if (oldSprintId === null) {\n for (l = 0, len1 = usList.length; l < len1; l++) {\n us = usList[l];\n us.milestone = newSprintId;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, key, len2, m, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(newSprint.user_stories, args);\n results = [];\n for (key = m = 0, len2 = usList.length; m < len2; key = ++m) {\n us = usList[key];\n r = _this.scope.userstories.indexOf(us);\n results.push(_this.scope.userstories.splice(r, 1));\n }\n return results;\n };\n })(this));\n } else {\n for (m = 0, len2 = usList.length; m < len2; m++) {\n us = usList[m];\n us.milestone = newSprintId;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, len3, n, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(newSprint.user_stories, args);\n results = [];\n for (n = 0, len3 = usList.length; n < len3; n++) {\n us = usList[n];\n r = sprint.user_stories.indexOf(us);\n results.push(sprint.user_stories.splice(r, 1));\n }\n return results;\n };\n })(this));\n }\n promises = _.map(usList, (function(_this) {\n return function(us) {\n return _this.repo.save(us);\n };\n })(this));\n promise = this.q.all(promises).then((function(_this) {\n return function() {\n items = _this.resortUserStories(newSprint.user_stories, \"sprint_order\");\n data = _this.prepareBulkUpdateData(items, \"sprint_order\");\n _this.rs.userstories.bulkUpdateSprintOrder(project, data).then(function(result) {\n return _this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId);\n });\n _this.rs.userstories.bulkUpdateBacklogOrder(project, data).then(function() {\n var len3, n, results;\n results = [];\n for (n = 0, len3 = usList.length; n < len3; n++) {\n us = usList[n];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n });\n if (movedToClosedSprint || movedFromClosedSprint) {\n return _this.scope.$broadcast(\"backlog:load-closed-sprints\");\n }\n };\n })(this));\n promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n return promise;\n };\n\n BacklogController.prototype.isFilterSelected = function(type, id) {\n if ((this.searchdata[type] != null) && this.searchdata[type][id]) {\n return true;\n }\n return false;\n };\n\n BacklogController.prototype.setSearchDataFilters = function() {\n var name, results, urlfilters, val, value;\n urlfilters = this.getUrlFilters();\n if (urlfilters.q) {\n this.scope.filtersQ = this.scope.filtersQ || urlfilters.q;\n }\n this.searchdata = {};\n results = [];\n for (name in urlfilters) {\n value = urlfilters[name];\n if (this.searchdata[name] == null) {\n this.searchdata[name] = {};\n }\n results.push((function() {\n var j, len, ref1, results1;\n ref1 = taiga.toString(value).split(\",\");\n results1 = [];\n for (j = 0, len = ref1.length; j < len; j++) {\n val = ref1[j];\n results1.push(this.searchdata[name][val] = true);\n }\n return results1;\n }).call(this));\n }\n return results;\n };\n\n BacklogController.prototype.getUrlFilters = function() {\n return _.pick(this.location.search(), \"status\", \"tags\", \"q\");\n };\n\n BacklogController.prototype.generateFilters = function() {\n var loadFilters, urlfilters;\n urlfilters = this.getUrlFilters();\n this.scope.filters = {};\n loadFilters = {};\n loadFilters.project = this.scope.projectId;\n loadFilters.tags = urlfilters.tags;\n loadFilters.status = urlfilters.status;\n loadFilters.q = urlfilters.q;\n loadFilters.milestone = 'null';\n return this.rs.userstories.filtersData(loadFilters).then((function(_this) {\n return function(data) {\n var choicesFiltersFormat, selectedStatuses, selectedTags, tagsFilterFormat;\n choicesFiltersFormat = function(choices, type, byIdObject) {\n return _.map(choices, function(t) {\n t.type = type;\n return t;\n });\n };\n tagsFilterFormat = function(tags) {\n return _.map(tags, function(t) {\n t.id = t.name;\n t.type = 'tags';\n return t;\n });\n };\n _this.scope.filters.status = choicesFiltersFormat(data.statuses, \"status\", _this.scope.usStatusById);\n _this.scope.filters.tags = tagsFilterFormat(data.tags);\n selectedTags = _.filter(_this.scope.filters.tags, \"selected\");\n selectedTags = _.map(selectedTags, \"id\");\n selectedStatuses = _.filter(_this.scope.filters.status, \"selected\");\n selectedStatuses = _.map(selectedStatuses, \"id\");\n _this.markSelectedFilters(_this.scope.filters, urlfilters);\n return _this.rs.userstories.storeQueryParams(_this.scope.projectId, {\n \"status\": selectedStatuses,\n \"tags\": selectedTags,\n \"project\": _this.scope.projectId,\n \"milestone\": null\n });\n };\n })(this));\n };\n\n BacklogController.prototype.markSelectedFilters = function(filters, urlfilters) {\n var isSelected, j, key, len, name, obj, ref1, ref2, results, searchdata, val, value;\n searchdata = {};\n ref1 = _.omit(urlfilters, \"page\", \"orderBy\");\n for (name in ref1) {\n value = ref1[name];\n if (searchdata[name] == null) {\n searchdata[name] = {};\n }\n ref2 = (\"\" + value).split(\",\");\n for (j = 0, len = ref2.length; j < len; j++) {\n val = ref2[j];\n searchdata[name][val] = true;\n }\n }\n isSelected = function(type, id) {\n if ((searchdata[type] != null) && searchdata[type][id]) {\n return true;\n }\n return false;\n };\n results = [];\n for (key in filters) {\n value = filters[key];\n results.push((function() {\n var l, len1, results1;\n results1 = [];\n for (l = 0, len1 = value.length; l < len1; l++) {\n obj = value[l];\n results1.push(obj.selected = isSelected(obj.type, obj.id) ? true : void 0);\n }\n return results1;\n })());\n }\n return results;\n };\n\n BacklogController.prototype.updateUserStoryStatus = function() {\n this.setSearchDataFilters();\n return this.generateFilters().then((function(_this) {\n return function() {\n _this.rootscope.$broadcast(\"filters:update\");\n return _this.loadProjectStats();\n };\n })(this));\n };\n\n BacklogController.prototype.editUserStory = function(projectId, ref, $event) {\n var currentLoading, target;\n target = $($event.target);\n currentLoading = this.loading().target(target).removeClasses(\"icon-edit\").timeout(200).start();\n return this.rs.userstories.getByRef(projectId, ref).then((function(_this) {\n return function(us) {\n return _this.rs2.attachments.list(\"us\", us.id, projectId).then(function(attachments) {\n _this.rootscope.$broadcast(\"usform:edit\", us, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n };\n\n BacklogController.prototype.deleteUserStory = function(us) {\n var message, title;\n title = this.translate.instant(\"US.TITLE_DELETE_ACTION\");\n message = us.subject;\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var promise;\n _this.scope.userstories = _.without(_this.scope.userstories, us);\n promise = _this.repo.remove(us);\n promise.then(function() {\n askResponse.finish();\n return _this.loadBacklog();\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return _this.confirm.notify(\"error\");\n });\n };\n })(this));\n };\n\n BacklogController.prototype.addNewUs = function(type) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"usform:new\", this.scope.projectId, this.scope.project.default_us_status, this.scope.usStatusList);\n case \"bulk\":\n return this.rootscope.$broadcast(\"usform:bulk\", this.scope.projectId, this.scope.project.default_us_status);\n }\n };\n\n BacklogController.prototype.addNewSprint = function() {\n return this.rootscope.$broadcast(\"sprintform:create\", this.scope.projectId);\n };\n\n BacklogController.prototype.findCurrentSprint = function() {\n var currentDate;\n currentDate = new Date().getTime();\n return _.find(this.scope.sprints, function(sprint) {\n var end, start;\n start = moment(sprint.estimated_start, 'YYYY-MM-DD').format('x');\n end = moment(sprint.estimated_finish, 'YYYY-MM-DD').format('x');\n return currentDate >= start && currentDate <= end;\n });\n };\n\n return BacklogController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"BacklogController\", BacklogController);\n\n BacklogDirective = function($repo, $rootscope, $translate) {\n var doomLineTemplate, link, linkDoomLine, linkFilters, linkToolbar, showHideFilter, showHideTags;\n doomLineTemplate = _.template(\"
<%- text %>
\");\n linkDoomLine = function($scope, $el, $attrs, $ctrl) {\n var addDoomLineDom, getUsItems, reloadDoomLine, removeDoomlineDom;\n reloadDoomLine = function() {\n var current_sum, domElement, i, j, len, ref1, results, stats, total_points, us;\n if (($scope.stats != null) && ($scope.stats.total_points != null) && $scope.stats.total_points !== 0) {\n removeDoomlineDom();\n stats = $scope.stats;\n total_points = stats.total_points;\n current_sum = stats.assigned_points;\n if (!$scope.userstories) {\n return;\n }\n ref1 = $scope.userstories;\n results = [];\n for (i = j = 0, len = ref1.length; j < len; i = ++j) {\n us = ref1[i];\n current_sum += us.total_points;\n if (current_sum > total_points) {\n domElement = $el.find('.backlog-table-body .us-item-row')[i];\n addDoomLineDom(domElement);\n break;\n } else {\n results.push(void 0);\n }\n }\n return results;\n }\n };\n removeDoomlineDom = function() {\n return $el.find(\".doom-line\").remove();\n };\n addDoomLineDom = function(element) {\n var text;\n text = $translate.instant(\"BACKLOG.DOOMLINE\");\n return $(element).before(doomLineTemplate({\n \"text\": text\n }));\n };\n getUsItems = function() {\n var rowElements;\n rowElements = $el.find('.backlog-table-body .us-item-row');\n return _.map(rowElements, function(x) {\n return angular.element(x);\n });\n };\n $scope.$on(\"userstories:loaded\", reloadDoomLine);\n return $scope.$watch(\"stats\", reloadDoomLine);\n };\n linkToolbar = function($scope, $el, $attrs, $ctrl) {\n var checkSelected, getUsToMove, lastChecked, moveToCurrentSprint, moveToLatestSprint, moveUssToSprint, shiftPressed;\n getUsToMove = function() {\n var ussDom;\n ussDom = $el.find(\".backlog-table-body input:checkbox:checked\");\n return _.map(ussDom, function(item) {\n var itemScope;\n item = $(item).closest('.tg-scope');\n itemScope = item.scope();\n itemScope.us.milestone = $scope.sprints[0].id;\n return itemScope.us;\n });\n };\n moveUssToSprint = function(selectedUss, sprint) {\n var extraPoints, totalExtraPoints, ussCurrent;\n ussCurrent = _($scope.userstories);\n $scope.userstories = ussCurrent.without.apply(ussCurrent, selectedUss).value();\n extraPoints = _.map(selectedUss, function(v, k) {\n return v.total_points;\n });\n totalExtraPoints = _.reduce(extraPoints, function(acc, num) {\n return acc + num;\n });\n sprint.user_stories = _.union(sprint.user_stories, selectedUss);\n sprint.total_points += totalExtraPoints;\n $repo.saveAll(selectedUss).then(function() {\n $ctrl.loadSprints();\n return $ctrl.loadProjectStats();\n });\n return $el.find(\".move-to-sprint\").hide();\n };\n moveToCurrentSprint = function(selectedUss) {\n return moveUssToSprint(selectedUss, $scope.currentSprint);\n };\n moveToLatestSprint = function(selectedUss) {\n return moveUssToSprint(selectedUss, $scope.sprints[0]);\n };\n shiftPressed = false;\n lastChecked = null;\n checkSelected = function(target) {\n var moveToSprintDom, selectedUsDom;\n lastChecked = target.closest(\".us-item-row\");\n target.closest('.us-item-row').toggleClass('ui-multisortable-multiple');\n moveToSprintDom = $el.find(\".move-to-sprint\");\n selectedUsDom = $el.find(\".backlog-table-body input:checkbox:checked\");\n if (selectedUsDom.length > 0 && $scope.sprints.length > 0) {\n return moveToSprintDom.show();\n } else {\n return moveToSprintDom.hide();\n }\n };\n $(window).on(\"keydown.shift-pressed keyup.shift-pressed\", function(event) {\n shiftPressed = !!event.shiftKey;\n return true;\n });\n $el.on(\"change\", \".backlog-table-body input:checkbox\", function(event) {\n var current, elements, nextAll, prevAll, target;\n if (lastChecked && shiftPressed) {\n elements = [];\n current = $(event.currentTarget).closest(\".us-item-row\");\n nextAll = lastChecked.nextAll();\n prevAll = lastChecked.prevAll();\n if (_.some(nextAll, function(next) {\n return next === current[0];\n })) {\n elements = lastChecked.nextUntil(current);\n } else if (_.some(prevAll, function(prev) {\n return prev === current[0];\n })) {\n elements = lastChecked.prevUntil(current);\n }\n _.map(elements, function(elm) {\n var input;\n input = $(elm).find(\"input:checkbox\");\n input.prop('checked', true);\n return checkSelected(input);\n });\n }\n target = angular.element(event.currentTarget);\n target.closest(\".us-item-row\").toggleClass('is-checked');\n return checkSelected(target);\n });\n $el.on(\"click\", \"#move-to-latest-sprint\", (function(_this) {\n return function(event) {\n var ussToMove;\n ussToMove = getUsToMove();\n return $scope.$apply(_.partial(moveToLatestSprint, ussToMove));\n };\n })(this));\n $el.on(\"click\", \"#move-to-current-sprint\", (function(_this) {\n return function(event) {\n var ussToMove;\n ussToMove = getUsToMove();\n return $scope.$apply(_.partial(moveToCurrentSprint, ussToMove));\n };\n })(this));\n return $el.on(\"click\", \"#show-tags\", function(event) {\n event.preventDefault();\n $ctrl.toggleShowTags();\n return showHideTags($ctrl);\n });\n };\n showHideTags = function($ctrl) {\n var elm, text;\n elm = angular.element(\"#show-tags\");\n if ($ctrl.showTags) {\n elm.addClass(\"active\");\n text = $translate.instant(\"BACKLOG.TAGS.HIDE\");\n return elm.text(text);\n } else {\n elm.removeClass(\"active\");\n text = $translate.instant(\"BACKLOG.TAGS.SHOW\");\n return elm.text(text);\n }\n };\n showHideFilter = function($scope, $el, $ctrl) {\n var hideText, showText, sidebar, target;\n sidebar = $el.find(\"sidebar.filters-bar\");\n sidebar.one(\"transitionend\", function() {\n return timeout(150, function() {\n $rootscope.$broadcast(\"resize\");\n return $('.burndown').css(\"visibility\", \"visible\");\n });\n });\n target = angular.element(\"#show-filters-button\");\n $('.burndown').css(\"visibility\", \"hidden\");\n sidebar.toggleClass(\"active\");\n target.toggleClass(\"active\");\n hideText = $translate.instant(\"BACKLOG.FILTERS.HIDE\");\n showText = $translate.instant(\"BACKLOG.FILTERS.SHOW\");\n toggleText(target, [hideText, showText]);\n if (!sidebar.hasClass(\"active\")) {\n $ctrl.resetFilters();\n } else {\n $ctrl.restoreFilters();\n }\n return $ctrl.toggleActiveFilters();\n };\n linkFilters = function($scope, $el, $attrs, $ctrl) {\n $scope.filtersSearch = {};\n return $el.on(\"click\", \"#show-filters-button\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n return showHideFilter($scope, $el, $ctrl);\n });\n });\n };\n link = function($scope, $el, $attrs, $rootscope) {\n var $ctrl, filters;\n $ctrl = $el.controller();\n linkToolbar($scope, $el, $attrs, $ctrl);\n linkFilters($scope, $el, $attrs, $ctrl);\n linkDoomLine($scope, $el, $attrs, $ctrl);\n $el.find(\".backlog-table-body\").disableSelection();\n filters = $ctrl.getUrlFilters();\n if (filters.status || filters.tags || filters.q) {\n showHideFilter($scope, $el, $ctrl);\n }\n $scope.$on(\"showTags\", function() {\n return showHideTags($ctrl);\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return $(window).off(\".shift-pressed\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklog\", [\"$tgRepo\", \"$rootScope\", \"$translate\", BacklogDirective]);\n\n UsRolePointsSelectorDirective = function($rootscope, $template, $compile, $translate) {\n var link, selectionTemplate;\n selectionTemplate = $template.get(\"backlog/us-role-points-popover.html\", true);\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var numberOfRoles, roles;\n roles = _.filter(project.roles, \"computable\");\n numberOfRoles = _.size(roles);\n if (numberOfRoles > 1) {\n return $el.append($compile(selectionTemplate({\n \"roles\": roles\n }))($scope));\n } else {\n $el.find(\".icon-arrow-bottom\").remove();\n return $el.find(\".header-points\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"uspoints:select\", function(ctx, roleId, roleName) {\n $el.find(\".popover\").popover().close();\n return $el.find(\".header-points\").html(roleName + \"/Total\");\n });\n $scope.$on(\"uspoints:clear-selection\", function(ctx, roleId) {\n var text;\n $el.find(\".popover\").popover().close();\n text = $translate.instant(\"COMMON.FIELDS.POINTS\");\n return $el.find(\".header-points\").text(text);\n });\n $el.on(\"click\", function(event) {\n var target;\n target = angular.element(event.target);\n if (target.is(\"span\") || target.is(\"div\")) {\n event.stopPropagation();\n }\n return $el.find(\".popover\").popover().open();\n });\n $el.on(\"click\", \".clear-selection\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $rootscope.$broadcast(\"uspoints:clear-selection\");\n });\n $el.on(\"click\", \".role\", function(event) {\n var rolScope, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n rolScope = target.scope();\n return $rootscope.$broadcast(\"uspoints:select\", target.data(\"role-id\"), target.text());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUsRolePointsSelector\", [\"$rootScope\", \"$tgTemplate\", \"$compile\", UsRolePointsSelectorDirective]);\n\n UsPointsDirective = function($tgEstimationsService, $repo, $tgTemplate) {\n var link, rolesTemplate;\n rolesTemplate = $tgTemplate.get(\"common/estimation/us-points-roles-popover.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, bindClickElements, estimationProcess, filteringRoleId, renderRolesSelector, selectedRoleId, updatingSelectedRoleId;\n $ctrl = $el.controller();\n updatingSelectedRoleId = null;\n selectedRoleId = null;\n filteringRoleId = null;\n estimationProcess = null;\n $scope.$on(\"uspoints:select\", function(ctx, roleId, roleName) {\n var us;\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n selectedRoleId = roleId;\n return estimationProcess.render();\n });\n $scope.$on(\"uspoints:clear-selection\", function(ctx) {\n var us;\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n selectedRoleId = null;\n return estimationProcess.render();\n });\n $scope.$watch($attrs.tgBacklogUsPoints, function(us) {\n var roles;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n roles = estimationProcess.calculateRoles();\n if (roles.length === 0) {\n $el.find(\".icon-arrow-bottom\").remove();\n $el.find(\"a.us-points\").addClass(\"not-clickable\");\n } else if (roles.length === 1) {\n selectedRoleId = _.keys(us.points)[0];\n }\n if (estimationProcess.isEditable) {\n bindClickElements();\n }\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return this.save(roleId, pointId).then(function() {\n return $ctrl.loadProjectStats();\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, pointId, pointObj, template, text, title, totalPoints;\n totalPoints = this.calculateTotalPoints();\n if ((selectedRoleId == null) || roles.length === 1) {\n text = totalPoints;\n title = totalPoints;\n } else {\n pointId = this.us.points[selectedRoleId];\n pointObj = this.pointsById[pointId];\n text = pointObj.name + \" / \" + totalPoints + \"\";\n title = pointObj.name + \" / \" + totalPoints;\n }\n ctx = {\n totalPoints: totalPoints,\n roles: this.calculateRoles(),\n editable: this.isEditable,\n text: text,\n title: title\n };\n mainTemplate = \"common/estimation/us-estimation-total.html\";\n template = $tgTemplate.get(mainTemplate, true);\n html = template(ctx);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n renderRolesSelector = function() {\n var html, roles;\n roles = estimationProcess.calculateRoles();\n html = rolesTemplate({\n \"roles\": roles\n });\n $el.append(html);\n return $el.find(\".pop-role\").popover().open(function() {\n return $(this).remove();\n });\n };\n bindClickElements = function() {\n $el.on(\"click\", \"a.us-points span\", function(event) {\n var us;\n event.preventDefault();\n event.stopPropagation();\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n updatingSelectedRoleId = selectedRoleId;\n if (selectedRoleId != null) {\n return estimationProcess.renderPointsSelector(selectedRoleId);\n } else {\n return renderRolesSelector();\n }\n });\n return $el.on(\"click\", \".role\", function(event) {\n var popRolesDom, target, us;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n updatingSelectedRoleId = target.data(\"role-id\");\n popRolesDom = $el.find(\".pop-role\");\n popRolesDom.find(\"a\").removeClass(\"active\");\n popRolesDom.find(\"a[data-role-id='\" + updatingSelectedRoleId + \"']\").addClass(\"active\");\n return estimationProcess.renderPointsSelector(updatingSelectedRoleId);\n });\n };\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogUsPoints\", [\"$tgEstimationsService\", \"$tgRepo\", \"$tgTemplate\", UsPointsDirective]);\n\n ToggleBurndownVisibility = function($storage) {\n var hide, link, show;\n hide = function() {\n $(\".js-burndown-graph\").removeClass(\"shown\");\n $(\".js-toggle-burndown-visibility-button\").removeClass(\"active\");\n return $(\".js-burndown-graph\").removeClass(\"open\");\n };\n show = function(firstLoad) {\n $(\".js-toggle-burndown-visibility-button\").addClass(\"active\");\n if (firstLoad) {\n return $(\".js-burndown-graph\").addClass(\"shown\");\n } else {\n return $(\".js-burndown-graph\").addClass(\"open\");\n }\n };\n link = function($scope, $el, $attrs) {\n var firstLoad, hash, toggleGraph;\n firstLoad = true;\n hash = generateHash([\"is-burndown-grpahs-collapsed\"]);\n $scope.isBurndownGraphCollapsed = $storage.get(hash) || false;\n toggleGraph = function() {\n if ($scope.isBurndownGraphCollapsed) {\n hide(firstLoad);\n } else {\n show(firstLoad);\n }\n return firstLoad = false;\n };\n $scope.$watch(\"showGraphPlaceholder\", function() {\n if ($scope.showGraphPlaceholder != null) {\n $scope.isBurndownGraphCollapsed = $scope.isBurndownGraphCollapsed || $scope.showGraphPlaceholder;\n return toggleGraph();\n }\n });\n $el.on(\"click\", \".js-toggle-burndown-visibility-button\", function() {\n $scope.isBurndownGraphCollapsed = !$scope.isBurndownGraphCollapsed;\n $storage.set(hash, $scope.isBurndownGraphCollapsed);\n return toggleGraph();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgToggleBurndownVisibility\", [\"$tgStorage\", ToggleBurndownVisibility]);\n\n BurndownBacklogGraphDirective = function($translate) {\n var link, redrawChart;\n redrawChart = function(element, dataToDraw) {\n var client_increment_line, colors, data, evolution_line, j, milestonesRange, optimal_line, options, ref1, results, team_increment_line, width, zero_line;\n width = element.width();\n element.height(width / 6);\n milestonesRange = (function() {\n results = [];\n for (var j = 0, ref1 = dataToDraw.milestones.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; 0 <= ref1 ? j++ : j--){ results.push(j); }\n return results;\n }).apply(this);\n data = [];\n zero_line = _.map(dataToDraw.milestones, function(ml) {\n return 0;\n });\n data.push({\n data: _.zip(milestonesRange, zero_line),\n lines: {\n fillColor: \"rgba(0,0,0,0)\"\n },\n points: {\n show: false\n }\n });\n optimal_line = _.map(dataToDraw.milestones, function(ml) {\n return ml.optimal;\n });\n data.push({\n data: _.zip(milestonesRange, optimal_line),\n lines: {\n fillColor: \"rgba(120,120,120,0.2)\"\n }\n });\n evolution_line = _.filter(_.map(dataToDraw.milestones, function(ml) {\n return ml.evolution;\n }), function(evolution) {\n return evolution != null;\n });\n data.push({\n data: _.zip(milestonesRange, evolution_line),\n lines: {\n fillColor: \"rgba(102,153,51,0.3)\"\n }\n });\n client_increment_line = _.map(dataToDraw.milestones, function(ml) {\n return -ml[\"team-increment\"] - ml[\"client-increment\"];\n });\n data.push({\n data: _.zip(milestonesRange, client_increment_line),\n lines: {\n fillColor: \"rgba(255,51,51,0.3)\"\n }\n });\n team_increment_line = _.map(dataToDraw.milestones, function(ml) {\n return -ml[\"team-increment\"];\n });\n data.push({\n data: _.zip(milestonesRange, team_increment_line),\n lines: {\n fillColor: \"rgba(153,51,51,0.3)\"\n }\n });\n colors = [\"rgba(0,0,0,1)\", \"rgba(120,120,120,0.2)\", \"rgba(102,153,51,1)\", \"rgba(153,51,51,1)\", \"rgba(255,51,51,1)\"];\n options = {\n grid: {\n borderWidth: {\n top: 0,\n right: 1,\n left: 0,\n bottom: 0\n },\n borderColor: \"#ccc\",\n hoverable: true\n },\n xaxis: {\n ticks: dataToDraw.milestones.length,\n axisLabel: $translate.instant(\"BACKLOG.CHART.XAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: \"Verdana, Arial, Helvetica, Tahoma, sans-serif\",\n axisLabelPadding: 5,\n tickFormatter: function(val, axis) {\n return \"\";\n }\n },\n yaxis: {\n axisLabel: $translate.instant(\"BACKLOG.CHART.YAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: \"Verdana, Arial, Helvetica, Tahoma, sans-serif\",\n axisLabelPadding: 5\n },\n series: {\n shadowSize: 0,\n lines: {\n show: true,\n fill: true\n },\n points: {\n show: true,\n fill: true,\n radius: 4,\n lineWidth: 2\n }\n },\n colors: colors,\n tooltip: true,\n tooltipOpts: {\n content: function(label, xval, yval, flotItem) {\n var ctx;\n if (flotItem.seriesIndex === 1) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.OPTIMAL\", ctx);\n } else if (flotItem.seriesIndex === 2) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.REAL\", ctx);\n } else if (flotItem.seriesIndex === 3) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.INCREMENT_CLIENT\", ctx);\n } else {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.INCREMENT_TEAM\", ctx);\n }\n }\n }\n };\n element.empty();\n return element.plot(data, options).data(\"plot\");\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch(\"stats\", function(value) {\n if ($scope.stats != null) {\n redrawChart(element, $scope.stats);\n return $scope.$on(\"resize\", function() {\n return redrawChart(element, $scope.stats);\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBurndownBacklogGraph\", [\"$translate\", BurndownBacklogGraphDirective]);\n\n TgBacklogProgressBarDirective = function($template, $compile) {\n var adjustPercentaje, link, render, template;\n template = $template.get(\"backlog/progress-bar.html\", true);\n render = function(scope, el, projectPointsPercentaje, closedPointsPercentaje) {\n var html;\n html = template({\n projectPointsPercentaje: projectPointsPercentaje,\n closedPointsPercentaje: closedPointsPercentaje\n });\n html = $compile(html)(scope);\n return el.html(html);\n };\n adjustPercentaje = function(percentage) {\n var adjusted;\n adjusted = _.max([0, percentage]);\n adjusted = _.min([100, adjusted]);\n return Math.round(adjusted);\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch($attrs.tgBacklogProgressBar, function(stats) {\n var closedPoints, closedPointsPercentaje, definedPoints, projectPointsPercentaje, totalPoints;\n if (stats != null) {\n totalPoints = stats.total_points ? stats.total_points : stats.defined_points;\n definedPoints = stats.defined_points;\n closedPoints = stats.closed_points;\n if (definedPoints > totalPoints) {\n projectPointsPercentaje = totalPoints * 100 / definedPoints;\n closedPointsPercentaje = closedPoints * 100 / definedPoints;\n } else {\n projectPointsPercentaje = 100;\n closedPointsPercentaje = closedPoints * 100 / totalPoints;\n }\n projectPointsPercentaje = adjustPercentaje(projectPointsPercentaje - 3);\n closedPointsPercentaje = adjustPercentaje(closedPointsPercentaje - 3);\n return render($scope, $el, projectPointsPercentaje, closedPointsPercentaje);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogProgressBar\", [\"$tgTemplate\", \"$compile\", TgBacklogProgressBarDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/sortable.coffee\n */\n\n(function() {\n var BacklogEmptySortableDirective, BacklogSortableDirective, SprintSortableDirective, bindOnce, deleteElement, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaBacklog\");\n\n deleteElement = function(el) {\n el.scope().$destroy();\n el.off();\n return el.remove();\n };\n\n BacklogSortableDirective = function($repo, $rs, $rootscope, $tgConfirm, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var getUsIndex;\n getUsIndex = (function(_this) {\n return function(us) {\n return $(us).index(\".backlog-table-body .row\");\n };\n })(this);\n bindOnce($scope, \"project\", function(project) {\n var filterError;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n filterError = function() {\n var text;\n text = $translate.instant(\"BACKLOG.SORTABLE_FILTER_ERROR\");\n return $tgConfirm.notify(\"error\", text);\n };\n $el.sortable({\n items: \".us-item-row\",\n cancel: \".popover\",\n connectWith: \".sprint\",\n dropOnEmpty: true,\n placeholder: \"row us-item-row us-item-drag sortable-placeholder\",\n scroll: true,\n disableHorizontalScroll: true,\n tolerance: \"pointer\",\n revert: false,\n start: function() {\n return $(document.body).addClass(\"drag-active\");\n },\n stop: function() {\n $(document.body).removeClass(\"drag-active\");\n if ($el.hasClass(\"active-filters\")) {\n $el.sortable(\"cancel\");\n return filterError();\n }\n }\n });\n $el.on(\"multiplesortreceive\", function(event, ui) {\n var itemIndex, itemUs;\n if ($el.hasClass(\"active-filters\")) {\n ui.source.sortable(\"cancel\");\n filterError();\n return;\n }\n itemUs = ui.item.scope().us;\n itemIndex = getUsIndex(ui.item);\n deleteElement(ui.item);\n $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, null);\n return ui.item.find('a').removeClass('noclick');\n });\n $el.on(\"multiplesortstop\", function(event, ui) {\n var index, items, us;\n if ($(ui.items[0]).parent().length === 0) {\n return;\n }\n if ($el.hasClass(\"active-filters\")) {\n return;\n }\n items = _.sortBy(ui.items, function(item) {\n return $(item).index();\n });\n index = _.min(_.map(items, function(item) {\n return getUsIndex(item);\n }));\n us = _.map(items, function(item) {\n var itemUs;\n item = $(item);\n itemUs = item.scope().us;\n setTimeout(((function(_this) {\n return function() {\n return item.find('a').removeClass('noclick');\n };\n })(this)), 300);\n return itemUs;\n });\n return $scope.$emit(\"sprint:us:move\", us, index, null);\n });\n return $el.on(\"sortstart\", function(event, ui) {\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n BacklogEmptySortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n $el.sortable({\n items: \".us-item-row\",\n dropOnEmpty: true\n });\n return $el.on(\"sortreceive\", function(event, ui) {\n var itemIndex, itemUs;\n itemUs = ui.item.scope().us;\n itemIndex = ui.item.index();\n deleteElement(ui.item);\n $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, null);\n return ui.item.find('a').removeClass('noclick');\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n SprintSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n $el.sortable({\n scroll: true,\n dropOnEmpty: true,\n items: \".sprint-table .milestone-us-item-row\",\n disableHorizontalScroll: true,\n connectWith: \".sprint,.backlog-table-body,.empty-backlog\",\n placeholder: \"row us-item-row sortable-placeholder\",\n forcePlaceholderSize: true\n });\n $el.on(\"multiplesortreceive\", function(event, ui) {\n var index, items, us;\n items = _.sortBy(ui.items, function(item) {\n return $(item).index();\n });\n index = _.min(_.map(items, function(item) {\n return $(item).index();\n }));\n us = _.map(items, function(item) {\n var itemUs;\n item = $(item);\n itemUs = item.scope().us;\n deleteElement(item);\n return itemUs;\n });\n return $scope.$emit(\"sprint:us:move\", us, index, $scope.sprint.id);\n });\n $el.on(\"multiplesortstop\", function(event, ui) {\n var itemIndex, itemUs;\n if (ui.item.parent().length === 0) {\n return;\n }\n itemUs = ui.item.scope().us;\n itemIndex = ui.item.index();\n setTimeout(((function(_this) {\n return function() {\n return ui.item.find('a').removeClass('noclick');\n };\n })(this)), 300);\n return $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, $scope.sprint.id);\n });\n return $el.on(\"sortstart\", function(event, ui) {\n return ui.item.find('a').addClass('noclick');\n });\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"$tgConfirm\", \"$translate\", BacklogSortableDirective]);\n\n module.directive(\"tgBacklogEmptySortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", BacklogEmptySortableDirective]);\n\n module.directive(\"tgSprintSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", SprintSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/sprints.coffee\n */\n\n(function() {\n var BacklogSprintDirective, BacklogSprintHeaderDirective, ToggleExcludeClosedSprintsVisualization, module, taiga;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogSprintDirective = function($repo, $rootscope) {\n var link, slideOptions, sprintTableMinHeight, toggleSprint;\n sprintTableMinHeight = 50;\n slideOptions = {\n duration: 500,\n easing: 'linear'\n };\n toggleSprint = (function(_this) {\n return function($el) {\n var sprintArrow, sprintTable;\n sprintTable = $el.find(\".sprint-table\");\n sprintArrow = $el.find(\".icon-arrow-up\");\n sprintArrow.toggleClass('active');\n return sprintTable.toggleClass('open');\n };\n })(this);\n link = function($scope, $el, $attrs) {\n $scope.$watch($attrs.tgBacklogSprint, function(sprint) {\n sprint = $scope.$eval($attrs.tgBacklogSprint);\n if (sprint.closed) {\n return $el.addClass(\"sprint-closed\");\n } else {\n return toggleSprint($el);\n }\n });\n $el.on(\"click\", \".sprint-name > .icon-arrow-up\", function(event) {\n event.preventDefault();\n toggleSprint($el);\n return $el.find(\".sprint-table\").slideToggle(slideOptions);\n });\n $el.on(\"click\", \".sprint-name > .icon-edit\", function(event) {\n var sprint;\n event.preventDefault();\n sprint = $scope.$eval($attrs.tgBacklogSprint);\n return $rootscope.$broadcast(\"sprintform:edit\", sprint);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogSprint\", [\"$tgRepo\", \"$rootScope\", BacklogSprintDirective]);\n\n BacklogSprintHeaderDirective = function($navUrls, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"backlog/sprint-header.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, isVisible, prettyDate, render;\n prettyDate = $translate.instant(\"BACKLOG.SPRINTS.DATE\");\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_milestone\") !== -1;\n };\n isVisible = function() {\n return $scope.project.my_permissions.indexOf(\"view_milestones\") !== -1;\n };\n render = function(sprint) {\n var compiledTemplate, ctx, estimatedDateRange, finish, start, taskboardUrl, templateScope;\n taskboardUrl = $navUrls.resolve(\"project-taskboard\", {\n project: $scope.project.slug,\n sprint: sprint.slug\n });\n start = moment(sprint.estimated_start).format(prettyDate);\n finish = moment(sprint.estimated_finish).format(prettyDate);\n estimatedDateRange = start + \"-\" + finish;\n ctx = {\n name: sprint.name,\n taskboardUrl: taskboardUrl,\n estimatedDateRange: estimatedDateRange,\n closedPoints: sprint.closed_points || 0,\n totalPoints: sprint.total_points || 0,\n isVisible: isVisible(),\n isEditable: isEditable()\n };\n templateScope = $scope.$new();\n _.assign(templateScope, ctx);\n compiledTemplate = $compile(template)(templateScope);\n return $el.html(compiledTemplate);\n };\n $scope.$watch($attrs.ngModel, function(sprint) {\n return render(sprint);\n });\n $scope.$on(\"sprintform:edit:success\", function() {\n return render($model.$modelValue);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgBacklogSprintHeader\", [\"$tgNavUrls\", \"$tgTemplate\", \"$compile\", \"$translate\", BacklogSprintHeaderDirective]);\n\n ToggleExcludeClosedSprintsVisualization = function($rootscope, $loading, $translate) {\n var excludeClosedSprints, link;\n excludeClosedSprints = true;\n link = function($scope, $el, $attrs) {\n var currentLoading, loadingElm;\n loadingElm = $(\"
\");\n $el.after(loadingElm);\n currentLoading = null;\n $el.on(\"click\", function(event) {\n event.preventDefault();\n excludeClosedSprints = !excludeClosedSprints;\n currentLoading = $loading().target(loadingElm).start();\n if (excludeClosedSprints) {\n return $rootscope.$broadcast(\"backlog:unload-closed-sprints\");\n } else {\n return $rootscope.$broadcast(\"backlog:load-closed-sprints\");\n }\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return $scope.$on(\"closed-sprints:reloaded\", (function(_this) {\n return function(ctx, sprints) {\n var key, text;\n currentLoading.finish();\n if (sprints.length > 0) {\n key = \"BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS\";\n } else {\n key = \"BACKLOG.SPRINTS.ACTION_SHOW_CLOSED_SPRINTS\";\n }\n text = $translate.instant(key);\n return $el.find(\".text\").text(text);\n };\n })(this));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogToggleClosedSprintsVisualization\", [\"$rootScope\", \"$tgLoading\", \"$translate\", ToggleExcludeClosedSprintsVisualization]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/charts.coffee\n */\n\n(function() {\n var SprintGraphDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaTaskboard\");\n\n SprintGraphDirective = function($translate) {\n var link, redrawChart;\n redrawChart = function(element, dataToDraw) {\n var data, days, options, width;\n width = element.width();\n element.height(240);\n days = _.map(dataToDraw, function(x) {\n return moment(x.day);\n });\n data = [];\n data.unshift({\n data: _.zip(days, _.map(dataToDraw, function(d) {\n return d.optimal_points;\n })),\n lines: {\n fillColor: \"rgba(120,120,120,0.2)\"\n }\n });\n data.unshift({\n data: _.zip(days, _.map(dataToDraw, function(d) {\n return d.open_points;\n })),\n lines: {\n fillColor: \"rgba(102,153,51,0.3)\"\n }\n });\n options = {\n grid: {\n borderWidth: {\n top: 0,\n right: 1,\n left: 0,\n bottom: 0\n },\n borderColor: '#ccc',\n hoverable: true\n },\n xaxis: {\n tickSize: [1, \"day\"],\n min: days[0],\n max: _.last(days),\n mode: \"time\",\n daysNames: days,\n axisLabel: $translate.instant(\"TASKBOARD.CHARTS.XAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',\n axisLabelPadding: 5\n },\n yaxis: {\n min: 0,\n axisLabel: $translate.instant(\"TASKBOARD.CHARTS.YAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',\n axisLabelPadding: 5\n },\n series: {\n shadowSize: 0,\n lines: {\n show: true,\n fill: true\n },\n points: {\n show: true,\n fill: true,\n radius: 4,\n lineWidth: 2\n }\n },\n colors: [\"rgba(102,153,51,1)\", \"rgba(120,120,120,0.2)\"],\n tooltip: true,\n tooltipOpts: {\n content: function(label, xval, yval, flotItem) {\n var formattedDate, roundedValue;\n formattedDate = moment(xval).format($translate.instant(\"TASKBOARD.CHARTS.DATE\"));\n roundedValue = Math.round(yval);\n if (flotItem.seriesIndex === 1) {\n return $translate.instant(\"TASKBOARD.CHARTS.OPTIMAL\", {\n formattedDate: formattedDate,\n roundedValue: roundedValue\n });\n } else {\n return $translate.instant(\"TASKBOARD.CHARTS.REAL\", {\n formattedDate: formattedDate,\n roundedValue: roundedValue\n });\n }\n }\n }\n };\n element.empty();\n return element.plot(data, options).data(\"plot\");\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$on(\"resize\", function() {\n if ($scope.stats) {\n return redrawChart(element, $scope.stats.days);\n }\n });\n $scope.$on(\"taskboard:graph:toggle-visibility\", function() {\n $el.parent().toggleClass('open');\n return timeout(100, function() {\n if ($scope.stats) {\n return redrawChart(element, $scope.stats.days);\n }\n });\n });\n $scope.$watch('stats', function(value) {\n if ($scope.stats == null) {\n return;\n }\n return redrawChart(element, $scope.stats.days);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSprintGraph\", [\"$translate\", SprintGraphDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/lightboxes.coffee\n */\n\n(function() {\n var CreateBulkTasksDirective, CreateEditTaskDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n CreateEditTaskDirective = function($repo, $model, $rs, $rootscope, $loading, lightboxService, $translate, $q, attachmentsService) {\n var link;\n link = function($scope, $el, attrs) {\n var attachmentsToAdd, attachmentsToDelete, createAttachments, deleteAttachments, resetAttachments, submit, submitButton;\n $scope.isNew = true;\n attachmentsToAdd = Immutable.List();\n attachmentsToDelete = Immutable.List();\n resetAttachments = function() {\n attachmentsToAdd = Immutable.List();\n return attachmentsToDelete = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n $scope.deleteAttachment = function(attachment) {\n return attachmentsToDelete = attachmentsToDelete.push(attachment);\n };\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.task.project, 'task');\n });\n return $q.all(promises);\n };\n deleteAttachments = function(obj) {\n var promises;\n console.log(attachmentsToDelete.toJS());\n promises = _.map(attachmentsToDelete.toJS(), function(attachment) {\n return attachmentsService[\"delete\"](\"task\", attachment.id);\n });\n return $q.all(promises);\n };\n $scope.$on(\"taskform:new\", function(ctx, sprintId, usId) {\n var create, newTask;\n $scope.task = {\n project: $scope.projectId,\n milestone: sprintId,\n user_story: usId,\n is_archived: false,\n status: $scope.project.default_task_status,\n assigned_to: null,\n tags: []\n };\n $scope.isNew = true;\n $scope.attachments = Immutable.List();\n resetAttachments();\n create = $translate.instant(\"COMMON.CREATE\");\n $el.find(\".button-green\").html(create);\n newTask = $translate.instant(\"LIGHTBOX.CREATE_EDIT_TASK.TITLE\");\n $el.find(\".title\").html(newTask + \" \");\n $el.find(\".tag-input\").val(\"\");\n return lightboxService.open($el);\n });\n $scope.$on(\"taskform:edit\", function(ctx, task, attachments) {\n var edit, save;\n $scope.task = task;\n $scope.isNew = false;\n $scope.attachments = Immutable.fromJS(attachments);\n resetAttachments();\n save = $translate.instant(\"COMMON.SAVE\");\n edit = $translate.instant(\"LIGHTBOX.CREATE_EDIT_TASK.ACTION_EDIT\");\n $el.find(\".button-green\").html(save);\n $el.find(\".title\").html(edit + \" \");\n $el.find(\".tag-input\").val(\"\");\n return lightboxService.open($el);\n });\n submitButton = $el.find(\".submit-button\");\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n if ($scope.isNew) {\n promise = $repo.create(\"tasks\", $scope.task);\n broadcastEvent = \"taskform:new:success\";\n } else {\n promise = $repo.save($scope.task);\n broadcastEvent = \"taskform:edit:success\";\n }\n promise.then(function(data) {\n createAttachments(data);\n deleteAttachments(data);\n return data;\n });\n currentLoading = $loading().target(submitButton).start();\n return promise.then(function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n return $rootscope.$broadcast(broadcastEvent, data);\n });\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n CreateBulkTasksDirective = function($repo, $rs, $rootscope, $loading, lightboxService) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.form = {\n data: \"\",\n usId: null\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, data, form, projectId, promise, sprintId, usId;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n data = $scope.form.data;\n projectId = $scope.projectId;\n sprintId = $scope.form.sprintId;\n usId = $scope.form.usId;\n promise = $rs.tasks.bulkCreate(projectId, sprintId, usId, data);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"taskform:bulk:success\", result);\n return lightboxService.close($el);\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return console.log(\"FAIL\");\n });\n };\n })(this));\n $scope.$on(\"taskform:bulk\", function(ctx, sprintId, usId) {\n lightboxService.open($el);\n return $scope.form = {\n data: \"\",\n sprintId: sprintId,\n usId: usId\n };\n });\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaTaskboard\");\n\n module.directive(\"tgLbCreateEditTask\", [\"$tgRepo\", \"$tgModel\", \"$tgResources\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", \"$translate\", \"$q\", \"tgAttachmentsService\", CreateEditTaskDirective]);\n\n module.directive(\"tgLbCreateBulkTasks\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", CreateBulkTasksDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard.coffee\n */\n\n(function() {\n var TaskboardController, TaskboardDirective, TaskboardSquishColumnDirective, TaskboardTaskDirective, TaskboardUserDirective, bindMethods, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n toggleText = this.taiga.toggleText;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n scopeDefer = this.taiga.scopeDefer;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaTaskboard\");\n\n TaskboardController = (function(superClass) {\n extend(TaskboardController, superClass);\n\n TaskboardController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"tgAppMetaService\", \"$tgLocation\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function TaskboardController(scope, rootscope, repo, confirm, rs1, params1, q, appMetaService, location, navUrls, events, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs1;\n this.params = params1;\n this.q = q;\n this.appMetaService = appMetaService;\n this.location = location;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"TASKBOARD.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n return _this._setMeta();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TaskboardController.prototype._setMeta = function() {\n var description, prettyDate, title;\n prettyDate = this.translate.instant(\"BACKLOG.SPRINTS.DATE\");\n title = this.translate.instant(\"TASKBOARD.PAGE_TITLE\", {\n projectName: this.scope.project.name,\n sprintName: this.scope.sprint.name\n });\n description = this.translate.instant(\"TASKBOARD.PAGE_DESCRIPTION\", {\n projectName: this.scope.project.name,\n sprintName: this.scope.sprint.name,\n startDate: moment(this.scope.sprint.estimated_start).format(prettyDate),\n endDate: moment(this.scope.sprint.estimated_finish).format(prettyDate),\n completedPercentage: this.scope.stats.completedPercentage || \"0\",\n completedPoints: this.scope.stats.completedPointsSum || \"--\",\n totalPoints: this.scope.stats.totalPointsSum || \"--\",\n openTasks: this.scope.stats.openTasks || \"--\",\n totalTasks: this.scope.stats.total_tasks || \"--\"\n });\n return this.appMetaService.setAll(title, description);\n };\n\n TaskboardController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"taskform:bulk:success\", (function(_this) {\n return function() {\n _this.loadTaskboard();\n return _this.analytics.trackEvent(\"task\", \"create\", \"bulk create task on taskboard\", 1);\n };\n })(this));\n this.scope.$on(\"taskform:new:success\", (function(_this) {\n return function() {\n _this.loadTaskboard();\n return _this.analytics.trackEvent(\"task\", \"create\", \"create task on taskboard\", 1);\n };\n })(this));\n this.scope.$on(\"taskform:edit:success\", (function(_this) {\n return function() {\n return _this.loadTaskboard();\n };\n })(this));\n this.scope.$on(\"taskboard:task:move\", this.taskMove);\n return this.scope.$on(\"assigned-to:added\", (function(_this) {\n return function(ctx, userId, task) {\n var promise;\n task.assigned_to = userId;\n promise = _this.repo.save(task);\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n })(this));\n };\n\n TaskboardController.prototype.initializeSubscription = function() {\n var routingKey, routingKey1;\n routingKey = \"changes.project.\" + this.scope.projectId + \".tasks\";\n this.events.subscribe(this.scope, routingKey, (function(_this) {\n return function(message) {\n return _this.loadTaskboard();\n };\n })(this));\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n return this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n _this.refreshTagsColors();\n _this.loadSprintStats();\n return _this.loadSprint();\n };\n })(this));\n };\n\n TaskboardController.prototype.loadProject = function() {\n return this.rs.projects.get(this.scope.projectId).then((function(_this) {\n return function(project) {\n if (!project.is_backlog_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.project = project;\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(e) {\n return e.id;\n });\n _this.scope.roleById = groupBy(project.roles, function(e) {\n return e.id;\n });\n _this.scope.taskStatusList = _.sortBy(project.task_statuses, \"order\");\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.scope.usStatusById = groupBy(project.us_statuses, function(e) {\n return e.id;\n });\n _this.scope.$emit('project:loaded', project);\n _this.fillUsersAndRoles(project.members, project.roles);\n return project;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadSprintStats = function() {\n return this.rs.sprints.stats(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(stats) {\n var completedPointsSum, remainingPointsSum, remainingTasks, totalPointsSum;\n totalPointsSum = _.reduce(_.values(stats.total_points), (function(res, n) {\n return res + n;\n }), 0);\n completedPointsSum = _.reduce(_.values(stats.completed_points), (function(res, n) {\n return res + n;\n }), 0);\n remainingPointsSum = totalPointsSum - completedPointsSum;\n remainingTasks = stats.total_tasks - stats.completed_tasks;\n _this.scope.stats = stats;\n _this.scope.stats.totalPointsSum = totalPointsSum;\n _this.scope.stats.completedPointsSum = completedPointsSum;\n _this.scope.stats.remainingPointsSum = remainingPointsSum;\n _this.scope.stats.remainingTasks = remainingTasks;\n if (stats.totalPointsSum) {\n _this.scope.stats.completedPercentage = Math.round(100 * stats.completedPointsSum / stats.totalPointsSum);\n } else {\n _this.scope.stats.completedPercentage = 0;\n }\n _this.scope.stats.openTasks = stats.total_tasks - stats.completed_tasks;\n return stats;\n };\n })(this));\n };\n\n TaskboardController.prototype.refreshTagsColors = function() {\n return this.rs.projects.tagsColors(this.scope.projectId).then((function(_this) {\n return function(tags_colors) {\n return _this.scope.project.tags_colors = tags_colors;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadSprint = function() {\n return this.rs.sprints.get(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n _this.scope.userstories = _.sortBy(sprint.user_stories, \"sprint_order\");\n return sprint;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadTasks = function() {\n return this.rs.tasks.list(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(tasks) {\n var i, j, k, len, len1, len2, ref, ref1, ref2, status, task, us, usId;\n _this.scope.tasks = _.sortBy(tasks, 'taskboard_order');\n _this.scope.usTasks = {};\n ref = _.union(_this.scope.userstories, [\n {\n id: null\n }\n ]);\n for (i = 0, len = ref.length; i < len; i++) {\n us = ref[i];\n _this.scope.usTasks[us.id] = {};\n ref1 = _this.scope.taskStatusList;\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n status = ref1[j];\n _this.scope.usTasks[us.id][status.id] = [];\n }\n }\n ref2 = _this.scope.tasks;\n for (k = 0, len2 = ref2.length; k < len2; k++) {\n task = ref2[k];\n if ((_this.scope.usTasks[task.user_story] != null) && (_this.scope.usTasks[task.user_story][task.status] != null)) {\n _this.scope.usTasks[task.user_story][task.status].push(task);\n }\n }\n if (tasks.length === 0) {\n if (_this.scope.userstories.length > 0) {\n usId = _this.scope.userstories[0].id;\n } else {\n usId = null;\n }\n _this.scope.usTasks[usId][_this.scope.taskStatusList[0].id].push({\n isPlaceholder: true\n });\n }\n return tasks;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadTaskboard = function() {\n return this.q.all([\n this.refreshTagsColors(), this.loadSprintStats(), this.loadSprint().then((function(_this) {\n return function() {\n return _this.loadTasks();\n };\n })(this))\n ]);\n };\n\n TaskboardController.prototype.loadInitialData = function() {\n var params, promise;\n params = {\n pslug: this.params.pslug,\n sslug: this.params.sslug\n };\n promise = this.repo.resolve(params).then((function(_this) {\n return function(data) {\n _this.scope.projectId = data.project;\n _this.scope.sprintId = data.milestone;\n _this.initializeSubscription();\n return data;\n };\n })(this));\n return promise.then((function(_this) {\n return function() {\n return _this.loadProject();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.loadTaskboard();\n };\n })(this));\n };\n\n TaskboardController.prototype.refreshTasksOrder = function(tasks) {\n var data, items;\n items = this.resortTasks(tasks);\n data = this.prepareBulkUpdateData(items);\n return this.rs.tasks.bulkUpdateTaskTaskboardOrder(this.scope.project.id, data);\n };\n\n TaskboardController.prototype.resortTasks = function(tasks) {\n var i, index, item, items, len;\n items = [];\n for (index = i = 0, len = tasks.length; i < len; index = ++i) {\n item = tasks[index];\n item[\"taskboard_order\"] = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n TaskboardController.prototype.prepareBulkUpdateData = function(uses) {\n return _.map(uses, function(x) {\n return {\n \"task_id\": x.id,\n \"order\": x[\"taskboard_order\"]\n };\n });\n };\n\n TaskboardController.prototype.taskMove = function(ctx, task, usId, statusId, order) {\n var promise, r, tasks;\n r = this.scope.usTasks[task.user_story][task.status].indexOf(task);\n this.scope.usTasks[task.user_story][task.status].splice(r, 1);\n tasks = this.scope.usTasks[usId][statusId];\n tasks.splice(order, 0, task);\n task.user_story = usId;\n task.status = statusId;\n task.taskboard_order = order;\n promise = this.repo.save(task);\n this.rootscope.$broadcast(\"sprint:task:moved\", task);\n promise.then((function(_this) {\n return function() {\n _this.refreshTasksOrder(tasks);\n return _this.loadSprintStats();\n };\n })(this));\n return promise.then(null, (function(_this) {\n return function() {\n return console.log(\"FAIL TASK SAVE\");\n };\n })(this));\n };\n\n TaskboardController.prototype.addNewTask = function(type, us) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"taskform:new\", this.scope.sprintId, us != null ? us.id : void 0);\n case \"bulk\":\n return this.rootscope.$broadcast(\"taskform:bulk\", this.scope.sprintId, us != null ? us.id : void 0);\n }\n };\n\n TaskboardController.prototype.editTaskAssignedTo = function(task) {\n return this.rootscope.$broadcast(\"assigned-to:add\", task);\n };\n\n return TaskboardController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TaskboardController\", TaskboardController);\n\n TaskboardDirective = function($rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, tableBodyDom;\n $ctrl = $el.controller();\n $el.on(\"click\", \".toggle-analytics-visibility\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.toggleClass('active');\n return $rootscope.$broadcast(\"taskboard:graph:toggle-visibility\");\n });\n tableBodyDom = $el.find(\".taskboard-table-body\");\n tableBodyDom.on(\"scroll\", function(event) {\n var tableHeaderDom, target;\n target = angular.element(event.currentTarget);\n tableHeaderDom = $el.find(\".taskboard-table-header .taskboard-table-inner\");\n return tableHeaderDom.css(\"left\", -1 * target.scrollLeft());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboard\", [\"$rootScope\", TaskboardDirective]);\n\n TaskboardTaskDirective = function($rootscope, $loading, $rs, $rs2) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $el.disableSelection();\n $scope.$watch(\"task\", function(task) {\n if (task.is_blocked && !$el.hasClass(\"blocked\")) {\n return $el.addClass(\"blocked\");\n } else if (!task.is_blocked && $el.hasClass(\"blocked\")) {\n return $el.removeClass(\"blocked\");\n }\n });\n return $el.find(\".icon-edit\").on(\"click\", function(event) {\n if ($el.find('.icon-edit').hasClass('noclick')) {\n return;\n }\n return $scope.$apply(function() {\n var currentLoading, target, task;\n target = $(event.target);\n currentLoading = $loading().target(target).timeout(200).removeClasses(\"icon-edit\").start();\n task = $scope.task;\n return $rs.tasks.getByRef(task.project, task.ref).then((function(_this) {\n return function(editingTask) {\n return $rs2.attachments.list(\"task\", editingTask.id, editingTask.project).then(function(attachments) {\n $rootscope.$broadcast(\"taskform:edit\", editingTask, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardTask\", [\"$rootScope\", \"$tgLoading\", \"$tgResources\", \"tgResources\", TaskboardTaskDirective]);\n\n TaskboardSquishColumnDirective = function(rs) {\n var avatarWidth, link, maxColumnWidth;\n avatarWidth = 40;\n maxColumnWidth = 300;\n link = function($scope, $el, $attrs) {\n var getCeilWidth, recalculateStatusColumnWidth, recalculateTaskboardWidth, refreshTaskboardTableWidth, setStatusColumnWidth;\n $scope.$on(\"sprint:task:moved\", (function(_this) {\n return function() {\n return recalculateTaskboardWidth();\n };\n })(this));\n bindOnce($scope, \"usTasks\", function(project) {\n $scope.statusesFolded = rs.tasks.getStatusColumnModes($scope.project.id);\n $scope.usFolded = rs.tasks.getUsRowModes($scope.project.id, $scope.sprintId);\n return recalculateTaskboardWidth();\n });\n $scope.foldStatus = function(status) {\n $scope.statusesFolded[status.id] = !!!$scope.statusesFolded[status.id];\n rs.tasks.storeStatusColumnModes($scope.projectId, $scope.statusesFolded);\n return recalculateTaskboardWidth();\n };\n $scope.foldUs = function(us) {\n if (!us) {\n $scope.usFolded[null] = !!!$scope.usFolded[null];\n } else {\n $scope.usFolded[us.id] = !!!$scope.usFolded[us.id];\n }\n rs.tasks.storeUsRowModes($scope.projectId, $scope.sprintId, $scope.usFolded);\n return recalculateTaskboardWidth();\n };\n getCeilWidth = (function(_this) {\n return function(usId, statusId) {\n var tasks, tasksMatrixSize, width;\n tasks = $scope.usTasks[usId][statusId].length;\n if ($scope.statusesFolded[statusId]) {\n if (tasks && $scope.usFolded[usId]) {\n tasksMatrixSize = Math.round(Math.sqrt(tasks));\n width = avatarWidth * tasksMatrixSize;\n } else {\n width = avatarWidth;\n }\n return width;\n }\n return 0;\n };\n })(this);\n setStatusColumnWidth = (function(_this) {\n return function(statusId, width) {\n var column;\n column = $el.find(\".squish-status-\" + statusId);\n if (width) {\n return column.css('max-width', width);\n } else {\n return column.css(\"max-width\", maxColumnWidth);\n }\n };\n })(this);\n refreshTaskboardTableWidth = (function(_this) {\n return function() {\n var columnWidths, columns, totalWidth;\n columnWidths = [];\n columns = $el.find(\".task-colum-name\");\n columnWidths = _.map(columns, function(column) {\n return $(column).outerWidth(true);\n });\n totalWidth = _.reduce(columnWidths, function(total, width) {\n return total + width;\n });\n return $el.find('.taskboard-table-inner').css(\"width\", totalWidth);\n };\n })(this);\n recalculateStatusColumnWidth = (function(_this) {\n return function(statusId) {\n var statusFoldedWidth;\n statusFoldedWidth = getCeilWidth(null, statusId);\n _.forEach($scope.userstories, function(us) {\n var width;\n width = getCeilWidth(us.id, statusId);\n if (width > statusFoldedWidth) {\n return statusFoldedWidth = width;\n }\n });\n return setStatusColumnWidth(statusId, statusFoldedWidth);\n };\n })(this);\n return recalculateTaskboardWidth = (function(_this) {\n return function() {\n _.forEach($scope.taskStatusList, function(status) {\n return recalculateStatusColumnWidth(status.id);\n });\n refreshTaskboardTableWidth();\n };\n })(this);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardSquishColumn\", [\"$tgResources\", TaskboardSquishColumnDirective]);\n\n TaskboardUserDirective = function($log, $translate) {\n var clickable, link;\n clickable = false;\n link = function($scope, $el, $attrs) {\n var username_label;\n username_label = $el.parent().find(\"a.task-assigned\");\n username_label.addClass(\"not-clickable\");\n $scope.$watch('task.assigned_to', function(assigned_to) {\n var user;\n user = $scope.usersById[assigned_to];\n if (user === void 0) {\n _.assign($scope, {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\",\n clickable: clickable\n });\n } else {\n _.assign($scope, {\n name: user.full_name_display,\n imgurl: user.photo,\n clickable: clickable\n });\n }\n return username_label.text($scope.name);\n });\n return bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_task\") > -1) {\n clickable = true;\n $el.find(\".avatar-assigned-to\").on(\"click\", (function(_this) {\n return function(event) {\n var $ctrl;\n if ($el.find('a').hasClass('noclick')) {\n return;\n }\n $ctrl = $el.controller();\n return $ctrl.editTaskAssignedTo($scope.task);\n };\n })(this));\n username_label.removeClass(\"not-clickable\");\n return username_label.on(\"click\", function(event) {\n var $ctrl;\n if ($el.find('a').hasClass('noclick')) {\n return;\n }\n $ctrl = $el.controller();\n return $ctrl.editTaskAssignedTo($scope.task);\n });\n }\n });\n };\n return {\n link: link,\n templateUrl: \"taskboard/taskboard-user.html\",\n scope: {\n \"usersById\": \"=users\",\n \"project\": \"=\",\n \"task\": \"=\"\n }\n };\n };\n\n module.directive(\"tgTaskboardUserAvatar\", [\"$log\", \"$translate\", TaskboardUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/sortable.coffee\n */\n\n(function() {\n var TaskboardSortableDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaBacklog\");\n\n TaskboardSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var deleteElement, itemEl, newParentScope, oldParentScope, tdom;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el;\n deleteElement = function(itemEl) {\n itemEl.scope().$destroy();\n itemEl.off();\n return itemEl.remove();\n };\n tdom.sortable({\n handle: \".taskboard-task-inner\",\n dropOnEmpty: true,\n connectWith: \".taskboard-tasks-box\",\n revert: 400\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemTask, newStatusId, newUsId, oldStatusId, oldUsId, parentEl;\n parentEl = ui.item.parent();\n itemEl = ui.item;\n itemTask = itemEl.scope().task;\n itemIndex = itemEl.index();\n newParentScope = parentEl.scope();\n oldUsId = oldParentScope.us ? oldParentScope.us.id : null;\n oldStatusId = oldParentScope.st.id;\n newUsId = newParentScope.us ? newParentScope.us.id : null;\n newStatusId = newParentScope.st.id;\n if (newStatusId !== oldStatusId || newUsId !== oldUsId) {\n deleteElement(itemEl);\n }\n $scope.$apply(function() {\n return $rootscope.$broadcast(\"taskboard:task:move\", itemTask, newUsId, newStatusId, itemIndex);\n });\n return ui.item.find('a').removeClass('noclick');\n });\n return tdom.on(\"sortstart\", function(event, ui) {\n oldParentScope = ui.item.parent().scope();\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", TaskboardSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban/main.coffee\n */\n\n(function() {\n var KanbanArchivedStatusHeaderDirective, KanbanArchivedStatusIntroDirective, KanbanController, KanbanDirective, KanbanSquishColumnDirective, KanbanUserDirective, KanbanUserstoryDirective, KanbanWipLimitDirective, bindMethods, bindOnce, defaultViewMode, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText, viewModes,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaKanban\");\n\n defaultViewMode = \"maximized\";\n\n viewModes = [\"maximized\", \"minimized\"];\n\n KanbanController = (function(superClass) {\n extend(KanbanController, superClass);\n\n KanbanController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function KanbanController(scope, rootscope, repo, confirm, rs1, params1, q, location, appMetaService, navUrls, events, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs1;\n this.params = params1;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"KANBAN.SECTION_NAME\");\n this.scope.statusViewModes = {};\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"KANBAN.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"KANBAN.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n KanbanController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"usform:new:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.refreshTagsColors();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"create userstory on kanban\", 1);\n };\n })(this));\n this.scope.$on(\"usform:bulk:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"bulk create userstory on kanban\", 1);\n };\n })(this));\n this.scope.$on(\"usform:edit:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.refreshTagsColors();\n };\n })(this));\n this.scope.$on(\"assigned-to:added\", this.onAssignedToChanged);\n this.scope.$on(\"kanban:us:move\", this.moveUs);\n this.scope.$on(\"kanban:show-userstories-for-status\", this.loadUserStoriesForStatus);\n return this.scope.$on(\"kanban:hide-userstories-for-status\", this.hideUserStoriesForStatus);\n };\n\n KanbanController.prototype.addNewUs = function(type, statusId) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"usform:new\", this.scope.projectId, statusId, this.scope.usStatusList);\n case \"bulk\":\n return this.rootscope.$broadcast(\"usform:bulk\", this.scope.projectId, statusId);\n }\n };\n\n KanbanController.prototype.changeUsAssignedTo = function(us) {\n return this.rootscope.$broadcast(\"assigned-to:add\", us);\n };\n\n KanbanController.prototype.onAssignedToChanged = function(ctx, userid, us) {\n var promise;\n us.assigned_to = userid;\n promise = this.repo.save(us);\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n\n KanbanController.prototype.refreshTagsColors = function() {\n return this.rs.projects.tagsColors(this.scope.projectId).then((function(_this) {\n return function(tags_colors) {\n return _this.scope.project.tags_colors = tags_colors;\n };\n })(this));\n };\n\n KanbanController.prototype.loadUserstories = function() {\n var params, promise;\n params = {\n status__is_archived: false\n };\n promise = this.rs.userstories.listAll(this.scope.projectId, params).then((function(_this) {\n return function(userstories) {\n var i, j, k, len, len1, len2, ref, ref1, ref2, status, us, usByStatus, us_archived;\n _this.scope.userstories = userstories;\n usByStatus = _.groupBy(userstories, \"status\");\n us_archived = [];\n ref = _this.scope.usStatusList;\n for (i = 0, len = ref.length; i < len; i++) {\n status = ref[i];\n if (usByStatus[status.id] == null) {\n usByStatus[status.id] = [];\n }\n if (_this.scope.usByStatus != null) {\n ref1 = _this.scope.usByStatus[status.id];\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n us = ref1[j];\n if (us.status !== status.id) {\n us_archived.push(us);\n }\n }\n }\n if (status.is_archived && (_this.scope.usByStatus != null) && _this.scope.usByStatus[status.id].length !== 0) {\n ref2 = _this.scope.usByStatus[status.id].concat(us_archived);\n for (k = 0, len2 = ref2.length; k < len2; k++) {\n us = ref2[k];\n if (us.status === status.id) {\n usByStatus[status.id].push(us);\n }\n }\n }\n usByStatus[status.id] = _.sortBy(usByStatus[status.id], \"kanban_order\");\n }\n if (userstories.length === 0) {\n status = _this.scope.usStatusList[0];\n usByStatus[status.id].push({\n isPlaceholder: true\n });\n }\n _this.scope.usByStatus = usByStatus;\n scopeDefer(_this.scope, function() {\n return _this.scope.$broadcast(\"userstories:loaded\", userstories);\n });\n return userstories;\n };\n })(this));\n promise.then((function(_this) {\n return function() {\n return _this.scope.$broadcast(\"redraw:wip\");\n };\n })(this));\n return promise;\n };\n\n KanbanController.prototype.loadUserStoriesForStatus = function(ctx, statusId) {\n var params;\n params = {\n status: statusId\n };\n return this.rs.userstories.listAll(this.scope.projectId, params).then((function(_this) {\n return function(userstories) {\n _this.scope.usByStatus[statusId] = _.sortBy(userstories, \"kanban_order\");\n _this.scope.$broadcast(\"kanban:shown-userstories-for-status\", statusId, userstories);\n return userstories;\n };\n })(this));\n };\n\n KanbanController.prototype.hideUserStoriesForStatus = function(ctx, statusId) {\n this.scope.usByStatus[statusId] = [];\n return this.scope.$broadcast(\"kanban:hidden-userstories-for-status\", statusId);\n };\n\n KanbanController.prototype.loadKanban = function() {\n return this.q.all([this.refreshTagsColors(), this.loadUserstories()]);\n };\n\n KanbanController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_kanban_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.projectId = project.id;\n _this.scope.points = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.generateStatusViewModes();\n _this.scope.$emit(\"project:loaded\", project);\n return project;\n };\n })(this));\n };\n\n KanbanController.prototype.initializeSubscription = function() {\n var routingKey1;\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n return this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n return _this.loadUserstories();\n };\n })(this));\n };\n\n KanbanController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.initializeSubscription();\n return _this.loadKanban();\n };\n })(this));\n };\n\n KanbanController.prototype.generateStatusViewModes = function() {\n var i, len, mode, ref, status, storedStatusViewModes;\n storedStatusViewModes = this.rs.kanban.getStatusViewModes(this.scope.projectId);\n this.scope.statusViewModes = {};\n ref = this.scope.usStatusList;\n for (i = 0, len = ref.length; i < len; i++) {\n status = ref[i];\n mode = storedStatusViewModes[status.id] || defaultViewMode;\n this.scope.statusViewModes[status.id] = mode;\n }\n return this.storeStatusViewModes();\n };\n\n KanbanController.prototype.storeStatusViewModes = function() {\n return this.rs.kanban.storeStatusViewModes(this.scope.projectId, this.scope.statusViewModes);\n };\n\n KanbanController.prototype.updateStatusViewMode = function(statusId, newViewMode) {\n this.scope.statusViewModes[statusId] = newViewMode;\n return this.storeStatusViewModes();\n };\n\n KanbanController.prototype.isMaximized = function(statusId) {\n var mode;\n mode = this.scope.statusViewModes[statusId] || defaultViewMode;\n return mode === 'maximized';\n };\n\n KanbanController.prototype.isMinimized = function(statusId) {\n var mode;\n mode = this.scope.statusViewModes[statusId] || defaultViewMode;\n return mode === 'minimized';\n };\n\n KanbanController.prototype.prepareBulkUpdateData = function(uses, field) {\n if (field == null) {\n field = \"kanban_order\";\n }\n return _.map(uses, function(x) {\n return {\n \"us_id\": x.id,\n \"order\": x[field]\n };\n });\n };\n\n KanbanController.prototype.resortUserStories = function(uses) {\n var i, index, item, items, len;\n items = [];\n for (index = i = 0, len = uses.length; i < len; index = ++i) {\n item = uses[index];\n item.kanban_order = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n KanbanController.prototype.moveUs = function(ctx, us, oldStatusId, newStatusId, index) {\n var itemsToSave, promise, r;\n if (oldStatusId !== newStatusId) {\n r = this.scope.usByStatus[oldStatusId].indexOf(us);\n this.scope.usByStatus[oldStatusId].splice(r, 1);\n this.scope.usByStatus[newStatusId].splice(index, 0, us);\n us.status = newStatusId;\n } else {\n r = this.scope.usByStatus[newStatusId].indexOf(us);\n this.scope.usByStatus[newStatusId].splice(r, 1);\n this.scope.usByStatus[newStatusId].splice(index, 0, us);\n }\n itemsToSave = this.resortUserStories(this.scope.usByStatus[newStatusId]);\n this.scope.usByStatus[newStatusId] = _.sortBy(this.scope.usByStatus[newStatusId], \"kanban_order\");\n promise = this.repo.save(us);\n promise = promise.then((function(_this) {\n return function() {\n var data;\n itemsToSave = _.reject(itemsToSave, {\n \"id\": us.id\n });\n data = _this.prepareBulkUpdateData(itemsToSave);\n return _this.rs.userstories.bulkUpdateKanbanOrder(us.project, data).then(function() {\n return itemsToSave;\n });\n };\n })(this));\n return promise;\n };\n\n return KanbanController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"KanbanController\", KanbanController);\n\n KanbanDirective = function($repo, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var tableBodyDom;\n tableBodyDom = $el.find(\".kanban-table-body\");\n tableBodyDom.on(\"scroll\", function(event) {\n var tableHeaderDom, target;\n target = angular.element(event.currentTarget);\n tableHeaderDom = $el.find(\".kanban-table-header .kanban-table-inner\");\n return tableHeaderDom.css(\"left\", -1 * target.scrollLeft());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanban\", [\"$tgRepo\", \"$rootScope\", KanbanDirective]);\n\n KanbanArchivedStatusHeaderDirective = function($rootscope, $translate) {\n var hideArchivedText, link, showArchivedText;\n showArchivedText = $translate.instant(\"KANBAN.ACTION_SHOW_ARCHIVED\");\n hideArchivedText = $translate.instant(\"KANBAN.ACTION_HIDE_ARCHIVED\");\n link = function($scope, $el, $attrs) {\n var hidden, status;\n status = $scope.$eval($attrs.tgKanbanArchivedStatusHeader);\n hidden = true;\n $scope[\"class\"] = \"icon-open-eye\";\n $scope.title = showArchivedText;\n $el.on(\"click\", function(event) {\n hidden = !hidden;\n return $scope.$apply(function() {\n if (hidden) {\n $scope[\"class\"] = \"icon-open-eye\";\n $scope.title = showArchivedText;\n return $rootscope.$broadcast(\"kanban:hide-userstories-for-status\", status.id);\n } else {\n $scope[\"class\"] = \"icon-closed-eye\";\n $scope.title = hideArchivedText;\n return $rootscope.$broadcast(\"kanban:show-userstories-for-status\", status.id);\n }\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanArchivedStatusHeader\", [\"$rootScope\", \"$translate\", KanbanArchivedStatusHeaderDirective]);\n\n KanbanArchivedStatusIntroDirective = function($translate) {\n var link, userStories;\n userStories = [];\n link = function($scope, $el, $attrs) {\n var hiddenUserStoriexText, status, updateIntroText;\n hiddenUserStoriexText = $translate.instant(\"KANBAN.HIDDEN_USER_STORIES\");\n status = $scope.$eval($attrs.tgKanbanArchivedStatusIntro);\n $el.text(hiddenUserStoriexText);\n updateIntroText = function() {\n if (userStories.length > 0) {\n return $el.text(\"\");\n } else {\n return $el.text(hiddenUserStoriexText);\n }\n };\n $scope.$on(\"kanban:us:move\", function(ctx, itemUs, oldStatusId, newStatusId, itemIndex) {\n var r;\n if (status.id === newStatusId) {\n if (status.id === oldStatusId) {\n r = userStories.indexOf(itemUs);\n userStories.splice(r, 1);\n userStories.splice(itemIndex, 0, itemUs);\n } else {\n itemUs.isArchived = true;\n userStories.splice(itemIndex, 0, itemUs);\n }\n } else if (status.id === oldStatusId) {\n itemUs.isArchived = false;\n r = userStories.indexOf(itemUs);\n userStories.splice(r, 1);\n }\n return updateIntroText();\n });\n $scope.$on(\"kanban:shown-userstories-for-status\", function(ctx, statusId, userStoriesLoaded) {\n if (statusId === status.id) {\n userStories = _.filter(userStoriesLoaded, function(us) {\n return us.status === status.id;\n });\n return updateIntroText();\n }\n });\n $scope.$on(\"kanban:hidden-userstories-for-status\", function(ctx, statusId) {\n if (statusId === status.id) {\n userStories = [];\n return updateIntroText();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanArchivedStatusIntro\", [\"$translate\", KanbanArchivedStatusIntroDirective]);\n\n KanbanUserstoryDirective = function($rootscope, $loading, $rs, $rs2) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $el.disableSelection();\n $scope.$watch(\"us\", function(us) {\n if (us.is_blocked && !$el.hasClass(\"blocked\")) {\n return $el.addClass(\"blocked\");\n } else if (!us.is_blocked && $el.hasClass(\"blocked\")) {\n return $el.removeClass(\"blocked\");\n }\n });\n $el.on('click', '.icon-edit', function(event) {\n var currentLoading, target, us;\n if ($el.find(\".icon-edit\").hasClass(\"noclick\")) {\n return;\n }\n target = $(event.target);\n currentLoading = $loading().target(target).timeout(200).removeClasses(\"icon-edit\").start();\n us = $model.$modelValue;\n return $rs.userstories.getByRef(us.project, us.ref).then((function(_this) {\n return function(editingUserStory) {\n return $rs2.attachments.list(\"us\", us.id, us.project).then(function(attachments) {\n $rootscope.$broadcast(\"usform:edit\", editingUserStory, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n });\n $scope.getTemplateUrl = function() {\n if ($scope.us.isPlaceholder) {\n return \"common/components/kanban-placeholder.html\";\n } else {\n return \"kanban/kanban-task.html\";\n }\n };\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n template: '',\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgKanbanUserstory\", [\"$rootScope\", \"$tgLoading\", \"$tgResources\", \"tgResources\", KanbanUserstoryDirective]);\n\n KanbanSquishColumnDirective = function(rs) {\n var link;\n link = function($scope, $el, $attrs) {\n var updateTableWidth;\n $scope.$on(\"project:loaded\", function(event, project) {\n $scope.folds = rs.kanban.getStatusColumnModes(project.id);\n return updateTableWidth();\n });\n $scope.foldStatus = function(status) {\n $scope.folds[status.id] = !!!$scope.folds[status.id];\n rs.kanban.storeStatusColumnModes($scope.projectId, $scope.folds);\n updateTableWidth();\n };\n return updateTableWidth = function() {\n var columnWidths, totalWidth;\n columnWidths = _.map($scope.usStatusList, function(status) {\n if ($scope.folds[status.id]) {\n return 40;\n } else {\n return 310;\n }\n });\n totalWidth = _.reduce(columnWidths, function(total, width) {\n return total + width;\n });\n return $el.find('.kanban-table-inner').css(\"width\", totalWidth);\n };\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanSquishColumn\", [\"$tgResources\", KanbanSquishColumnDirective]);\n\n KanbanWipLimitDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var redrawWipLimit, status;\n $el.disableSelection();\n status = $scope.$eval($attrs.tgKanbanWipLimit);\n redrawWipLimit = (function(_this) {\n return function() {\n $el.find(\".kanban-wip-limit\").remove();\n return timeout(200, function() {\n var element;\n element = $el.find(\".kanban-task\")[status.wip_limit];\n if (element) {\n return angular.element(element).before(\"
\");\n }\n });\n };\n })(this);\n if (status && !status.is_archived) {\n $scope.$on(\"redraw:wip\", redrawWipLimit);\n $scope.$on(\"kanban:us:move\", redrawWipLimit);\n $scope.$on(\"usform:new:success\", redrawWipLimit);\n $scope.$on(\"usform:bulk:success\", redrawWipLimit);\n }\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanWipLimit\", KanbanWipLimitDirective);\n\n KanbanUserDirective = function($log, $compile, $translate) {\n var clickable, link, template;\n template = _.template(\"
\\n class=\\\"not-clickable\\\"<% } %>>\\n \\\" alt=\\\"<%- name %>\\\" class=\\\"avatar\\\">\\n \\n
\");\n clickable = false;\n link = function($scope, $el, $attrs, $model) {\n var render, username_label, wtid;\n username_label = $el.parent().find(\"a.task-assigned\");\n username_label.addClass(\"not-clickable\");\n if (!$attrs.tgKanbanUserAvatar) {\n return $log.error(\"KanbanUserDirective: no attr is defined\");\n }\n wtid = $scope.$watch($attrs.tgKanbanUserAvatar, function(v) {\n var user;\n if ($scope.usersById == null) {\n $log.error(\"KanbanUserDirective requires userById set in scope.\");\n return wtid();\n } else {\n user = $scope.usersById[v];\n return render(user);\n }\n });\n render = function(user) {\n var ctx, html;\n if (user === void 0) {\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\",\n clickable: clickable\n };\n } else {\n ctx = {\n name: user.full_name_display,\n imgurl: user.photo,\n clickable: clickable\n };\n }\n html = $compile(template(ctx))($scope);\n $el.html(html);\n return username_label.text(ctx.name);\n };\n bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n clickable = true;\n $el.on(\"click\", (function(_this) {\n return function(event) {\n var $ctrl, us;\n if ($el.find(\"a\").hasClass(\"noclick\")) {\n return;\n }\n us = $model.$modelValue;\n $ctrl = $el.controller();\n return $ctrl.changeUsAssignedTo(us);\n };\n })(this));\n username_label.removeClass(\"not-clickable\");\n return username_label.on(\"click\", function(event) {\n var $ctrl, us;\n if ($el.find(\"a\").hasClass(\"noclick\")) {\n return;\n }\n us = $model.$modelValue;\n $ctrl = $el.controller();\n return $ctrl.changeUsAssignedTo(us);\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgKanbanUserAvatar\", [\"$log\", \"$compile\", \"$translate\", KanbanUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban/sortable.coffee\n */\n\n(function() {\n var KanbanSortableDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaKanban\");\n\n KanbanSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var deleteElement, itemEl, newParentScope, oldParentScope, tdom;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el;\n deleteElement = function(itemEl) {\n itemEl.scope().$destroy();\n itemEl.off();\n return itemEl.remove();\n };\n tdom.sortable({\n handle: \".kanban-task-inner\",\n dropOnEmpty: true,\n connectWith: \".kanban-uses-box\",\n revert: 400\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemUs, newStatusId, oldStatusId, parentEl;\n parentEl = ui.item.parent();\n itemEl = ui.item;\n itemUs = itemEl.scope().us;\n itemIndex = itemEl.index();\n newParentScope = parentEl.scope();\n newStatusId = newParentScope.s.id;\n oldStatusId = oldParentScope.s.id;\n if (newStatusId !== oldStatusId) {\n deleteElement(itemEl);\n }\n $scope.$apply(function() {\n return $rootscope.$broadcast(\"kanban:us:move\", itemUs, itemUs.status, newStatusId, itemIndex);\n });\n return ui.item.find('a').removeClass('noclick');\n });\n return tdom.on(\"sortstart\", function(event, ui) {\n oldParentScope = ui.item.parent().scope();\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", KanbanSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/detail.coffee\n */\n\n(function() {\n var IssueDetailController, IssuePriorityButtonDirective, IssueSeverityButtonDirective, IssueStatusButtonDirective, IssueStatusDisplayDirective, IssueTypeButtonDirective, PromoteIssueToUsButtonDirective, bindMethods, bindOnce, groupBy, joinStr, mixOf, module, taiga, toString,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaIssues\");\n\n IssueDetailController = (function(superClass) {\n extend(IssueDetailController, superClass);\n\n IssueDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgAnalytics\", \"$tgNavUrls\", \"$translate\"];\n\n function IssueDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, analytics, navUrls, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.analytics = analytics;\n this.navUrls = navUrls;\n this.translate = translate;\n bindMethods(this);\n this.scope.issueRef = this.params.issueref;\n this.scope.sectionName = this.translate.instant(\"ISSUES.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n IssueDetailController.prototype._setMeta = function() {\n var description, ref, ref1, ref2, ref3, title;\n title = this.translate.instant(\"ISSUE.PAGE_TITLE\", {\n issueRef: \"#\" + this.scope.issue.ref,\n issueSubject: this.scope.issue.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"ISSUE.PAGE_DESCRIPTION\", {\n issueStatus: ((ref = this.scope.statusById[this.scope.issue.status]) != null ? ref.name : void 0) || \"--\",\n issueType: ((ref1 = this.scope.typeById[this.scope.issue.type]) != null ? ref1.name : void 0) || \"--\",\n issueSeverity: ((ref2 = this.scope.severityById[this.scope.issue.severity]) != null ? ref2.name : void 0) || \"--\",\n issuePriority: ((ref3 = this.scope.priorityById[this.scope.issue.priority]) != null ? ref3.name : void 0) || \"--\",\n issueDescription: angular.element(this.scope.issue.description_html || \"\").text()\n });\n return this.appMetaService.setAll(title, description);\n };\n\n IssueDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on issue\", 1);\n };\n })(this));\n this.scope.$on(\"promote-issue-to-us:success\", (function(_this) {\n return function() {\n _this.analytics.trackEvent(\"issue\", \"promoteToUserstory\", \"promote issue to userstory\", 1);\n _this.rootscope.$broadcast(\"object:updated\");\n return _this.loadIssue();\n };\n })(this));\n this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadIssue();\n };\n })(this));\n return this.scope.$on(\"custom-attributes-values:edit\", (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this));\n };\n\n IssueDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n if (this.scope.project.is_issues_activated) {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-issues\", ctx);\n } else {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n }\n };\n\n IssueDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.issue_statuses;\n _this.scope.statusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.typeById = groupBy(project.issue_types, function(x) {\n return x.id;\n });\n _this.scope.typeList = _.sortBy(project.issue_types, \"order\");\n _this.scope.severityList = project.severities;\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.priorityList = project.priorities;\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n IssueDetailController.prototype.loadIssue = function() {\n return this.rs.issues.getByRef(this.scope.projectId, this.params.issueref).then((function(_this) {\n return function(issue) {\n var ctx, ref, ref1;\n _this.scope.issue = issue;\n _this.scope.issueId = issue.id;\n _this.scope.commentModel = issue;\n if (((ref = _this.scope.issue.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.issue.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-issues-detail\", ctx);\n }\n if (((ref1 = _this.scope.issue.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.issue.neighbors.next.ref\n };\n return _this.scope.nextUrl = _this.navUrls.resolve(\"project-issues-detail\", ctx);\n }\n };\n })(this));\n };\n\n IssueDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadIssue();\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n IssueDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.upvote(this.scope.issueId).then(onSuccess, onError);\n };\n\n IssueDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.downvote(this.scope.issueId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n IssueDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.watch(this.scope.issueId).then(onSuccess, onError);\n };\n\n IssueDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.unwatch(this.scope.issueId).then(onSuccess, onError);\n };\n\n return IssueDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"IssueDetailController\", IssueDetailController);\n\n IssueStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(issue) {\n var html, status;\n status = $scope.statusById[issue.status];\n html = template({\n is_closed: status.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue != null) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueStatusDisplay\", [\"$tgTemplate\", \"$compile\", IssueStatusDisplayDirective]);\n\n IssueStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issues-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, status;\n status = $scope.statusById[issue.status];\n html = template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(statusId) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.status = statusId;\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n return save(target.data(\"status-id\"));\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueStatusButtonDirective]);\n\n IssueTypeButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-type-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, type;\n type = $scope.typeById[issue.type];\n html = template({\n type: type,\n typees: $scope.typeList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(type) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.type = type;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".type-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-type\").popover().open();\n });\n $el.on(\"click\", \".type\", function(event) {\n var target, type;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n type = target.data(\"type-id\");\n return save(type);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueTypeButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueTypeButtonDirective]);\n\n IssueSeverityButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-severity-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, severity;\n severity = $scope.severityById[issue.severity];\n html = template({\n severity: severity,\n severityes: $scope.severityList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(severity) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.severity = severity;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".severity-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-severity\").popover().open();\n });\n $el.on(\"click\", \".severity\", function(event) {\n var severity, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n severity = target.data(\"severity-id\");\n return save(severity);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueSeverityButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueSeverityButtonDirective]);\n\n IssuePriorityButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-priority-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, priority;\n priority = $scope.priorityById[issue.priority];\n html = template({\n priority: priority,\n priorityes: $scope.priorityList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(priority) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.priority = priority;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".priority-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-priority\").popover().open();\n });\n $el.on(\"click\", \".priority\", function(event) {\n var priority, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n priority = target.data(\"priority-id\");\n return save(priority);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssuePriorityButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssuePriorityButtonDirective]);\n\n PromoteIssueToUsButtonDirective = function($rootScope, $repo, $confirm, $qqueue, $translate) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var save;\n save = $qqueue.bindAdd((function(_this) {\n return function(issue, askResponse) {\n var data, onError, onSuccess;\n data = {\n generated_from_issue: issue.id,\n project: issue.project,\n subject: issue.subject,\n description: issue.description,\n tags: issue.tags,\n is_blocked: issue.is_blocked,\n blocked_note: issue.blocked_note\n };\n onSuccess = function() {\n askResponse.finish();\n $confirm.notify(\"success\");\n return $rootScope.$broadcast(\"promote-issue-to-us:success\");\n };\n onError = function() {\n askResponse.finish();\n return $confirm.notify(\"error\");\n };\n return $repo.create(\"userstories\", data).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \"a\", function(event) {\n var issue, message, subtitle, title;\n event.preventDefault();\n issue = $model.$modelValue;\n title = $translate.instant(\"ISSUES.CONFIRM_PROMOTE.TITLE\");\n message = $translate.instant(\"ISSUES.CONFIRM_PROMOTE.MESSAGE\");\n subtitle = issue.subject;\n return $confirm.ask(title, subtitle, message).then((function(_this) {\n return function(response) {\n return save(issue, response);\n };\n })(this));\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n restrict: \"AE\",\n require: \"ngModel\",\n templateUrl: \"issue/promote-issue-to-us-button.html\",\n link: link\n };\n };\n\n module.directive(\"tgPromoteIssueToUsButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgQqueue\", \"$translate\", PromoteIssueToUsButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/lightboxes.coffee\n */\n\n(function() {\n var CreateBulkIssuesDirective, CreateIssueDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaIssues\");\n\n CreateIssueDirective = function($repo, $confirm, $rootscope, lightboxService, $loading, $q, attachmentsService) {\n var link;\n link = function($scope, $el, $attrs) {\n var attachmentsToAdd, createAttachments, form, resetAttachments, submit, submitButton;\n form = $el.find(\"form\").checksley();\n $scope.issue = {};\n $scope.attachments = Immutable.List();\n $scope.$on(\"issueform:new\", function(ctx, project) {\n var attachmentsToAdd;\n attachmentsToAdd = Immutable.List();\n $el.find(\".tag-input\").val(\"\");\n lightboxService.open($el);\n return $scope.issue = {\n project: project.id,\n subject: \"\",\n status: project.default_issue_status,\n type: project.default_issue_type,\n priority: project.default_priority,\n severity: project.default_severity,\n tags: []\n };\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.issue.project, 'issue');\n });\n return $q.all(promises);\n };\n attachmentsToAdd = Immutable.List();\n resetAttachments = function() {\n return attachmentsToAdd = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"issues\", $scope.issue);\n promise.then(function(data) {\n return createAttachments(data);\n });\n promise.then(function(data) {\n currentLoading.finish();\n $rootscope.$broadcast(\"issueform:new:success\", data);\n lightboxService.close($el);\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateIssue\", [\"$tgRepo\", \"$tgConfirm\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$q\", \"tgAttachmentsService\", CreateIssueDirective]);\n\n CreateBulkIssuesDirective = function($repo, $rs, $confirm, $rootscope, $loading, lightboxService) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.$on(\"issueform:bulk\", function(ctx, projectId, status) {\n lightboxService.open($el);\n return $scope[\"new\"] = {\n projectId: projectId,\n bulk: \"\"\n };\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, data, form, projectId, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n data = $scope[\"new\"].bulk;\n projectId = $scope[\"new\"].projectId;\n promise = $rs.issues.bulkCreate(projectId, data);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"issueform:new:success\", result);\n lightboxService.close($el);\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateBulkIssues\", [\"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", CreateBulkIssuesDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/list.coffee\n */\n\n(function() {\n var IssueAssignedToInlineEditionDirective, IssueStatusInlineEditionDirective, IssuesController, IssuesDirective, IssuesFiltersDirective, bindOnce, debounceLeading, groupBy, joinStr, mixOf, module, startswith, taiga, toString, trim,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounceLeading = this.taiga.debounceLeading;\n\n startswith = this.taiga.startswith;\n\n module = angular.module(\"taigaIssues\");\n\n IssuesController = (function(superClass) {\n extend(IssuesController, superClass);\n\n IssuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$tgUrls\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function IssuesController(scope, rootscope, repo, confirm, rs, urls, params, q, location, appMetaService, navUrls, events, analytics, translate) {\n var filters, promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.urls = urls;\n this.params = params;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n this.loadIssues = bind(this.loadIssues, this);\n this.scope.sectionName = \"Issues\";\n this.scope.filters = {};\n if (_.isEmpty(this.location.search())) {\n filters = this.rs.issues.getFilters(this.params.pslug);\n filters.page = 1;\n this.location.search(filters);\n this.location.replace();\n return;\n }\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ISSUES.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"ISSUES.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"issueform:new:success\", (function(_this) {\n return function() {\n _this.analytics.trackEvent(\"issue\", \"create\", \"create issue on issues list\", 1);\n return _this.loadIssues();\n };\n })(this));\n }\n\n IssuesController.prototype.initializeSubscription = function() {\n var routingKey;\n routingKey = \"changes.project.\" + this.scope.projectId + \".issues\";\n return this.events.subscribe(this.scope, routingKey, (function(_this) {\n return function(message) {\n return _this.loadIssues();\n };\n })(this));\n };\n\n IssuesController.prototype.storeFilters = function() {\n return this.rs.issues.storeFilters(this.params.pslug, this.location.search());\n };\n\n IssuesController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_issues_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issueStatusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.issueStatusList = _.sortBy(project.issue_statuses, \"order\");\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.severityList = _.sortBy(project.severities, \"order\");\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n _this.scope.priorityList = _.sortBy(project.priorities, \"order\");\n _this.scope.issueTypes = _.sortBy(project.issue_types, \"order\");\n _this.scope.issueTypeById = groupBy(project.issue_types, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n IssuesController.prototype.getUrlFilters = function() {\n var filters;\n filters = _.pick(this.location.search(), \"page\", \"tags\", \"status\", \"types\", \"q\", \"severities\", \"priorities\", \"assignedTo\", \"createdBy\", \"orderBy\");\n if (!filters.page) {\n filters.page = 1;\n }\n return filters;\n };\n\n IssuesController.prototype.getUrlFilter = function(name) {\n var filters;\n filters = _.pick(this.location.search(), name);\n return filters[name];\n };\n\n IssuesController.prototype.loadMyFilters = function() {\n return this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n return _.map(filters, function(value, key) {\n return {\n id: key,\n name: key,\n type: \"myFilters\",\n selected: false\n };\n });\n };\n })(this));\n };\n\n IssuesController.prototype.removeNotExistingFiltersFromUrl = function() {\n var currentSearch, existingValues, filterName, filterValue, splittedValues, urlfilters;\n currentSearch = this.location.search();\n urlfilters = this.getUrlFilters();\n for (filterName in urlfilters) {\n filterValue = urlfilters[filterName];\n if (filterName === \"page\" || filterName === \"orderBy\" || filterName === \"q\") {\n continue;\n }\n if (filterName === \"tags\") {\n splittedValues = _.map((\"\" + filterValue).split(\",\"));\n } else {\n splittedValues = _.map((\"\" + filterValue).split(\",\"), function(x) {\n if (x === \"null\") {\n return null;\n } else {\n return parseInt(x);\n }\n });\n }\n existingValues = _.intersection(splittedValues, _.map(this.scope.filters[filterName], \"id\"));\n if (splittedValues.length !== existingValues.length) {\n this.location.search(filterName, existingValues.join());\n }\n }\n if (currentSearch !== this.location.search()) {\n return this.location.replace();\n }\n };\n\n IssuesController.prototype.markSelectedFilters = function(filters, urlfilters) {\n var isSelected, j, key, len, name, obj, ref, ref1, results, searchdata, val, value;\n searchdata = {};\n ref = _.omit(urlfilters, \"page\", \"orderBy\");\n for (name in ref) {\n value = ref[name];\n if (searchdata[name] == null) {\n searchdata[name] = {};\n }\n ref1 = (\"\" + value).split(\",\");\n for (j = 0, len = ref1.length; j < len; j++) {\n val = ref1[j];\n searchdata[name][val] = true;\n }\n }\n isSelected = function(type, id) {\n if ((searchdata[type] != null) && searchdata[type][id]) {\n return true;\n }\n return false;\n };\n results = [];\n for (key in filters) {\n value = filters[key];\n results.push((function() {\n var k, len1, results1;\n results1 = [];\n for (k = 0, len1 = value.length; k < len1; k++) {\n obj = value[k];\n results1.push(obj.selected = isSelected(obj.type, obj.id) ? true : void 0);\n }\n return results1;\n })());\n }\n return results;\n };\n\n IssuesController.prototype.loadFilters = function() {\n var loadFilters, promise, urlfilters;\n urlfilters = this.getUrlFilters();\n if (urlfilters.q) {\n this.scope.filtersQ = urlfilters.q;\n }\n promise = this.loadMyFilters().then((function(_this) {\n return function(myFilters) {\n _this.scope.filters.myFilters = myFilters;\n return myFilters;\n };\n })(this));\n loadFilters = {};\n loadFilters.project = this.scope.projectId;\n loadFilters.tags = urlfilters.tags;\n loadFilters.status = urlfilters.status;\n loadFilters.q = urlfilters.q;\n loadFilters.types = urlfilters.types;\n loadFilters.severities = urlfilters.severities;\n loadFilters.priorities = urlfilters.priorities;\n loadFilters.assigned_to = urlfilters.assignedTo;\n loadFilters.owner = urlfilters.createdBy;\n promise = promise.then((function(_this) {\n return function() {\n return _this.rs.issues.filtersData(loadFilters);\n };\n })(this));\n return promise.then((function(_this) {\n return function(data) {\n var choicesFiltersFormat, tagsFilterFormat, usersFiltersFormat;\n usersFiltersFormat = function(users, type, unknownOption) {\n var reformatedUsers, unknownItem;\n reformatedUsers = _.map(users, function(t) {\n t.type = type;\n t.name = t.full_name ? t.full_name : unknownOption;\n return t;\n });\n unknownItem = _.remove(reformatedUsers, function(u) {\n return !u.id;\n });\n reformatedUsers = _.sortBy(reformatedUsers, function(u) {\n return u.name.toUpperCase();\n });\n if (unknownItem.length > 0) {\n reformatedUsers.unshift(unknownItem[0]);\n }\n return reformatedUsers;\n };\n choicesFiltersFormat = function(choices, type, byIdObject) {\n return _.map(choices, function(t) {\n t.type = type;\n return t;\n });\n };\n tagsFilterFormat = function(tags) {\n return _.map(tags, function(t) {\n t.id = t.name;\n t.type = 'tags';\n return t;\n });\n };\n _this.scope.filters.status = choicesFiltersFormat(data.statuses, \"status\", _this.scope.issueStatusById);\n _this.scope.filters.severities = choicesFiltersFormat(data.severities, \"severities\", _this.scope.severityById);\n _this.scope.filters.priorities = choicesFiltersFormat(data.priorities, \"priorities\", _this.scope.priorityById);\n _this.scope.filters.assignedTo = usersFiltersFormat(data.assigned_to, \"assignedTo\", \"Unassigned\");\n _this.scope.filters.createdBy = usersFiltersFormat(data.owners, \"createdBy\", \"Unknown\");\n _this.scope.filters.types = choicesFiltersFormat(data.types, \"types\", _this.scope.issueTypeById);\n _this.scope.filters.tags = tagsFilterFormat(data.tags);\n _this.removeNotExistingFiltersFromUrl();\n _this.markSelectedFilters(_this.scope.filters, urlfilters);\n return _this.rootscope.$broadcast(\"filters:loaded\", _this.scope.filters);\n };\n })(this));\n };\n\n IssuesController.prototype.loadIssuesRequests = 0;\n\n IssuesController.prototype.loadIssues = function() {\n var name, promise, ref, values;\n this.scope.urlFilters = this.getUrlFilters();\n this.scope.httpParams = {};\n ref = this.scope.urlFilters;\n for (name in ref) {\n values = ref[name];\n if (name === \"severities\") {\n name = \"severity\";\n } else if (name === \"orderBy\") {\n name = \"order_by\";\n } else if (name === \"priorities\") {\n name = \"priority\";\n } else if (name === \"assignedTo\") {\n name = \"assigned_to\";\n } else if (name === \"createdBy\") {\n name = \"owner\";\n } else if (name === \"status\") {\n name = \"status\";\n } else if (name === \"types\") {\n name = \"type\";\n }\n this.scope.httpParams[name] = values;\n }\n promise = this.rs.issues.list(this.scope.projectId, this.scope.httpParams);\n this.loadIssuesRequests += 1;\n promise.index = this.loadIssuesRequests;\n promise.then((function(_this) {\n return function(data) {\n if (promise.index === _this.loadIssuesRequests) {\n _this.scope.issues = data.models;\n _this.scope.page = data.current;\n _this.scope.count = data.count;\n _this.scope.paginatedBy = data.paginatedBy;\n }\n return data;\n };\n })(this));\n return promise;\n };\n\n IssuesController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.initializeSubscription();\n _this.loadFilters();\n return _this.loadIssues();\n };\n })(this));\n };\n\n IssuesController.prototype.saveCurrentFiltersTo = function(newFilter) {\n var deferred;\n deferred = this.q.defer();\n this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n filters[newFilter] = _this.location.search();\n return _this.rs.issues.storeMyFilters(_this.scope.projectId, filters).then(function() {\n return deferred.resolve();\n });\n };\n })(this));\n return deferred.promise;\n };\n\n IssuesController.prototype.deleteMyFilter = function(filter) {\n var deferred;\n deferred = this.q.defer();\n this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n delete filters[filter];\n return _this.rs.issues.storeMyFilters(_this.scope.projectId, filters).then(function() {\n return deferred.resolve();\n });\n };\n })(this));\n return deferred.promise;\n };\n\n IssuesController.prototype.addNewIssue = function() {\n return this.rootscope.$broadcast(\"issueform:new\", this.scope.project);\n };\n\n IssuesController.prototype.addIssuesInBulk = function() {\n return this.rootscope.$broadcast(\"issueform:bulk\", this.scope.projectId);\n };\n\n return IssuesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"IssuesController\", IssuesController);\n\n IssuesDirective = function($log, $location, $template, $compile) {\n var link, linkOrdering, linkPagination, template;\n template = $template.get(\"issue/issue-paginator.html\", true);\n linkPagination = function($scope, $el, $attrs, $ctrl) {\n var $pagEl, afterCurrent, atBegin, atEnd, beforeCurrent, getNumPages, renderPagination;\n afterCurrent = 2;\n beforeCurrent = 4;\n atBegin = 2;\n atEnd = 2;\n $pagEl = $el.find(\".issues-paginator\");\n getNumPages = function() {\n var numPages;\n numPages = $scope.count / $scope.paginatedBy;\n if (parseInt(numPages, 10) < numPages) {\n numPages = parseInt(numPages, 10) + 1;\n } else {\n numPages = parseInt(numPages, 10);\n }\n return numPages;\n };\n renderPagination = function() {\n var cpage, html, i, j, numPages, options, pages, ref;\n numPages = getNumPages();\n if (numPages <= 1) {\n $pagEl.hide();\n return;\n }\n $pagEl.show();\n pages = [];\n options = {};\n options.pages = pages;\n options.showPrevious = $scope.page > 1;\n options.showNext = !($scope.page === numPages);\n cpage = $scope.page;\n for (i = j = 1, ref = numPages; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\n if (i === (cpage + afterCurrent) && numPages > (cpage + afterCurrent + atEnd)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i === (cpage - beforeCurrent) && cpage > (atBegin + beforeCurrent)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i > (cpage + afterCurrent) && i <= (numPages - atEnd)) {\n\n } else if (i < (cpage - beforeCurrent) && i > atBegin) {\n\n } else if (i === cpage) {\n pages.push({\n classes: \"active\",\n num: i,\n type: \"page-active\"\n });\n } else {\n pages.push({\n classes: \"page\",\n num: i,\n type: \"page\"\n });\n }\n }\n html = template(options);\n html = $compile(html)($scope);\n return $pagEl.html(html);\n };\n $scope.$watch(\"issues\", function(value) {\n if (!value) {\n return;\n }\n return renderPagination();\n });\n $el.on(\"click\", \".issues-paginator a.next\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page + 1);\n return $ctrl.loadIssues();\n });\n });\n $el.on(\"click\", \".issues-paginator a.previous\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n return $ctrl.loadIssues();\n });\n });\n return $el.on(\"click\", \".issues-paginator li.page > a\", function(event) {\n var pagenum, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n pagenum = target.data(\"pagenum\");\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", pagenum);\n return $ctrl.loadIssues();\n });\n });\n };\n linkOrdering = function($scope, $el, $attrs, $ctrl) {\n var colHeadElement, currentOrder, icon;\n currentOrder = $ctrl.getUrlFilter(\"orderBy\") || \"created_date\";\n if (currentOrder) {\n icon = startswith(currentOrder, \"-\") ? \"icon-arrow-up\" : \"icon-arrow-bottom\";\n colHeadElement = $el.find(\".row.title > div[data-fieldname='\" + (trim(currentOrder, \"-\")) + \"']\");\n colHeadElement.html((colHeadElement.html()) + \"\");\n }\n return $el.on(\"click\", \".row.title > div\", function(event) {\n var finalOrder, newOrder, target;\n target = angular.element(event.currentTarget);\n currentOrder = $ctrl.getUrlFilter(\"orderBy\");\n newOrder = target.data(\"fieldname\");\n finalOrder = currentOrder === newOrder ? \"-\" + newOrder : newOrder;\n return $scope.$apply(function() {\n $ctrl.replaceFilter(\"orderBy\", finalOrder);\n $ctrl.storeFilters();\n return $ctrl.loadIssues().then(function() {\n $el.find(\".row.title > div > span.icon\").remove();\n icon = startswith(finalOrder, \"-\") ? \"icon-arrow-up\" : \"icon-arrow-bottom\";\n return target.html((target.html()) + \"\");\n });\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n linkOrdering($scope, $el, $attrs, $ctrl);\n linkPagination($scope, $el, $attrs, $ctrl);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssues\", [\"$log\", \"$tgLocation\", \"$tgTemplate\", \"$compile\", IssuesDirective]);\n\n IssuesFiltersDirective = function($q, $log, $location, $rs, $confirm, $loading, $template, $translate, $compile, $auth) {\n var link, template, templateSelected;\n template = $template.get(\"issue/issues-filters.html\", true);\n templateSelected = $template.get(\"issue/issues-filters-selected.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, getFiltersType, initializeSelectedFilters, reloadIssues, renderFilters, renderSelectedFilters, selectQFilter, selectedFilters, showCategories, showFilters, toggleFilterSelection, unwatchIssues;\n $ctrl = $el.closest(\".wrapper\").controller();\n selectedFilters = [];\n showFilters = function(title, type) {\n $el.find(\".filters-cats\").hide();\n $el.find(\".filter-list\").removeClass(\"hidden\");\n $el.find(\"h2.breadcrumb\").removeClass(\"hidden\");\n $el.find(\"h2 a.subfilter span.title\").html(title);\n return $el.find(\"h2 a.subfilter span.title\").prop(\"data-type\", type);\n };\n showCategories = function() {\n $el.find(\".filters-cats\").show();\n $el.find(\".filter-list\").addClass(\"hidden\");\n return $el.find(\"h2.breadcrumb\").addClass(\"hidden\");\n };\n initializeSelectedFilters = function(filters) {\n var j, len, name, val, values;\n selectedFilters = [];\n for (name in filters) {\n values = filters[name];\n for (j = 0, len = values.length; j < len; j++) {\n val = values[j];\n if (val.selected) {\n selectedFilters.push(val);\n }\n }\n }\n return renderSelectedFilters(selectedFilters);\n };\n renderSelectedFilters = function(selectedFilters) {\n var html;\n _.filter(selectedFilters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = templateSelected({\n filters: selectedFilters\n });\n html = $compile(html)($scope);\n $el.find(\".filters-applied\").html(html);\n if ($auth.isAuthenticated() && selectedFilters.length > 0) {\n return $el.find(\".save-filters\").show();\n } else {\n return $el.find(\".save-filters\").hide();\n }\n };\n renderFilters = function(filters) {\n var html;\n _.filter(filters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = template({\n filters: filters\n });\n html = $compile(html)($scope);\n return $el.find(\".filter-list\").html(html);\n };\n getFiltersType = function() {\n return $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n };\n reloadIssues = function() {\n var currentFiltersType;\n currentFiltersType = getFiltersType();\n return $q.all([$ctrl.loadIssues(), $ctrl.loadFilters()]).then(function() {\n var filters;\n filters = $scope.filters[currentFiltersType];\n return renderFilters(_.reject(filters, \"selected\"));\n });\n };\n toggleFilterSelection = function(type, id) {\n var currentFiltersType, filter, filterId, filters;\n if (type === \"myFilters\") {\n $rs.issues.getMyFilters($scope.projectId).then(function(data) {\n var filters, myFilters;\n myFilters = data;\n filters = myFilters[id];\n filters.page = 1;\n $ctrl.replaceAllFilters(filters);\n $ctrl.storeFilters();\n $ctrl.loadIssues();\n $ctrl.markSelectedFilters($scope.filters, filters);\n return initializeSelectedFilters($scope.filters);\n });\n return null;\n }\n filters = $scope.filters[type];\n filterId = type === 'tags' ? taiga.toString(id) : id;\n filter = _.find(filters, {\n id: filterId\n });\n filter.selected = !filter.selected;\n if (id === null) {\n id = \"null\";\n }\n if (filter.selected) {\n selectedFilters.push(filter);\n $ctrl.selectFilter(type, id);\n $ctrl.selectFilter(\"page\", 1);\n $ctrl.storeFilters();\n } else {\n selectedFilters = _.reject(selectedFilters, function(f) {\n return f.id === filter.id && f.type === filter.type;\n });\n $ctrl.unselectFilter(type, id);\n $ctrl.selectFilter(\"page\", 1);\n $ctrl.storeFilters();\n }\n reloadIssues();\n renderSelectedFilters(selectedFilters);\n currentFiltersType = getFiltersType();\n if (type === currentFiltersType) {\n return renderFilters(_.reject(filters, \"selected\"));\n }\n };\n $scope.$on(\"filters:loaded\", function(ctx, filters) {\n return initializeSelectedFilters(filters);\n });\n $scope.$on(\"filters:issueupdate\", function(ctx, filters) {\n var html;\n html = template({\n filters: filters.status\n });\n html = $compile(html)($scope);\n return $el.find(\".filter-list\").html(html);\n });\n selectQFilter = debounceLeading(100, function(value, oldValue) {\n if (value === void 0 || value === oldValue) {\n return;\n }\n $ctrl.replaceFilter(\"page\", null, true);\n if (value.length === 0) {\n $ctrl.replaceFilter(\"q\", null);\n $ctrl.storeFilters();\n } else {\n $ctrl.replaceFilter(\"q\", value);\n $ctrl.storeFilters();\n }\n return reloadIssues();\n });\n unwatchIssues = $scope.$watch(\"issues\", function(newValue) {\n if (!_.isUndefined(newValue)) {\n $scope.$watch(\"filtersQ\", selectQFilter);\n return unwatchIssues();\n }\n });\n $el.on(\"click\", \".filters-cats > ul > li > a\", function(event) {\n var tags, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n tags = $scope.filters[target.data(\"type\")];\n renderFilters(_.reject(tags, \"selected\"));\n return showFilters(target.attr(\"title\"), target.data(\"type\"));\n });\n $el.on(\"click\", \".filters-inner > .filters-step-cat > .breadcrumb > .back\", function(event) {\n event.preventDefault();\n return showCategories($el);\n });\n $el.on(\"click\", \".filters-applied a\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n id = target.data(\"id\") || null;\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n $el.on(\"click\", \".filter-list .single-filter\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.toggleClass(\"active\");\n id = target.data(\"id\") || null;\n type = target.data(\"type\");\n if (type === \"myFilters\") {\n target.removeClass(\"active\");\n }\n return toggleFilterSelection(type, id);\n });\n $el.on(\"click\", \".filter-list .single-filter .icon-delete\", function(event) {\n var customFilterName, message, target, title;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n customFilterName = target.parent().data('id');\n title = $translate.instant(\"ISSUES.FILTERS.CONFIRM_DELETE.TITLE\");\n message = $translate.instant(\"ISSUES.FILTERS.CONFIRM_DELETE.MESSAGE\", {\n customFilterName: customFilterName\n });\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var promise;\n promise = $ctrl.deleteMyFilter(customFilterName);\n promise.then(function() {\n promise = $ctrl.loadMyFilters();\n promise.then(function(filters) {\n askResponse.finish();\n $scope.filters.myFilters = filters;\n return renderFilters($scope.filters.myFilters);\n });\n return promise.then(null, function() {\n return askResponse.finish();\n });\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n });\n });\n $el.on(\"click\", \".save-filters\", function(event) {\n event.preventDefault();\n renderFilters($scope.filters[\"myFilters\"]);\n showFilters(\"My filters\", \"myFilters\");\n $el.find('.save-filters').hide();\n $el.find('.my-filter-name').removeClass(\"hidden\");\n $el.find('.my-filter-name').focus();\n return $scope.$apply();\n });\n return $el.on(\"keyup\", \".my-filter-name\", function(event) {\n var currentLoading, newFilter, promise, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newFilter = target.val();\n currentLoading = $loading().target($el.find(\".new\")).start();\n promise = $ctrl.saveCurrentFiltersTo(newFilter);\n promise.then(function() {\n var loadPromise;\n loadPromise = $ctrl.loadMyFilters();\n loadPromise.then(function(filters) {\n var currentfilterstype;\n currentLoading.finish();\n $scope.filters.myFilters = filters;\n currentfilterstype = $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n if (currentfilterstype === \"myFilters\") {\n renderFilters($scope.filters.myFilters);\n }\n $el.find('.my-filter-name').addClass(\"hidden\");\n return $el.find('.save-filters').show();\n });\n return loadPromise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\", \"Error loading custom filters\");\n });\n });\n return promise.then(null, function() {\n currentLoading.finish();\n $el.find(\".my-filter-name\").val(newFilter).focus().select();\n return $confirm.notify(\"error\", \"Filter not saved\");\n });\n } else if (event.keyCode === 27) {\n $el.find('.my-filter-name').val('');\n $el.find('.my-filter-name').addClass(\"hidden\");\n return $el.find('.save-filters').show();\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssuesFilters\", [\"$q\", \"$log\", \"$tgLocation\", \"$tgResources\", \"$tgConfirm\", \"$tgLoading\", \"$tgTemplate\", \"$translate\", \"$compile\", \"$tgAuth\", IssuesFiltersDirective]);\n\n IssueStatusInlineEditionDirective = function($repo, $template, $rootscope) {\n\n /*\n Print the status of an Issue and a popover to change it.\n - tg-issue-status-inline-edition: The issue\n \n Example:\n \n div.status(tg-issue-status-inline-edition=\"issue\")\n a.issue-status(href=\"\")\n \n NOTE: This directive need 'issueStatusById' and 'project'.\n */\n var link, selectionTemplate, updateIssueStatus;\n selectionTemplate = $template.get(\"issue/issue-status-inline-edition-selection.html\", true);\n updateIssueStatus = function($el, issue, issueStatusById) {\n var issueStatusDom, issueStatusDomParent, status;\n issueStatusDomParent = $el.find(\".issue-status\");\n issueStatusDom = $el.find(\".issue-status .issue-status-bind\");\n status = issueStatusById[issue.status];\n if (status) {\n issueStatusDom.text(status.name);\n issueStatusDom.prop(\"title\", status.name);\n return issueStatusDomParent.css('color', status.color);\n }\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, issue;\n $ctrl = $el.controller();\n issue = $scope.$eval($attrs.tgIssueStatusInlineEdition);\n $el.on(\"click\", \".issue-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var filter, j, len, ref, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n ref = $scope.filters.status;\n for (j = 0, len = ref.length; j < len; j++) {\n filter = ref[j];\n if (filter.id === issue.status) {\n filter.count--;\n }\n }\n issue.status = target.data(\"status-id\");\n $el.find(\".pop-status\").popover().close();\n updateIssueStatus($el, issue, $scope.issueStatusById);\n return $scope.$apply(function() {\n var k, len1, ref1;\n $repo.save(issue).then(function() {\n return $ctrl.loadIssues();\n });\n ref1 = $scope.filters.status;\n for (k = 0, len1 = ref1.length; k < len1; k++) {\n filter = ref1[k];\n if (filter.id === issue.status) {\n filter.count++;\n }\n }\n return $rootscope.$broadcast(\"filters:issueupdate\", $scope.filters);\n });\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n $el.append(selectionTemplate({\n 'statuses': project.issue_statuses\n }));\n updateIssueStatus($el, issue, $scope.issueStatusById);\n if (project.my_permissions.indexOf(\"modify_issue\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$watch($attrs.tgIssueStatusInlineEdition, (function(_this) {\n return function(val) {\n return updateIssueStatus($el, val, $scope.issueStatusById);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssueStatusInlineEdition\", [\"$tgRepo\", \"$tgTemplate\", \"$rootScope\", IssueStatusInlineEditionDirective]);\n\n IssueAssignedToInlineEditionDirective = function($repo, $rootscope, $translate) {\n var link, template;\n template = _.template(\"\\\" alt=\\\"<%- name %>\\\"/>\\n
<%- name %>
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, issue, updateIssue;\n updateIssue = function(issue) {\n var ctx, member;\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = $scope.usersById[issue.assigned_to];\n if (member) {\n ctx.name = member.full_name_display;\n ctx.imgurl = member.photo;\n }\n $el.find(\".avatar\").html(template(ctx));\n return $el.find(\".issue-assignedto\").attr('title', ctx.name);\n };\n $ctrl = $el.controller();\n issue = $scope.$eval($attrs.tgIssueAssignedToInlineEdition);\n updateIssue(issue);\n $el.on(\"click\", \".issue-assignedto\", function(event) {\n return $rootscope.$broadcast(\"assigned-to:add\", issue);\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_issue\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"assigned-to:added\", (function(_this) {\n return function(ctx, userId, updatedIssue) {\n if (updatedIssue.id === issue.id) {\n updatedIssue.assigned_to = userId;\n $repo.save(updatedIssue);\n return updateIssue(updatedIssue);\n }\n };\n })(this));\n $scope.$watch($attrs.tgIssueAssignedToInlineEdition, (function(_this) {\n return function(val) {\n return updateIssue(val);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssueAssignedToInlineEdition\", [\"$tgRepo\", \"$rootScope\", \"$translate\", IssueAssignedToInlineEditionDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/userstories/detail.coffee\n */\n\n(function() {\n var UsClientRequirementButtonDirective, UsStatusButtonDirective, UsStatusDisplayDirective, UsTeamRequirementButtonDirective, UserStoryDetailController, bindMethods, bindOnce, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaUserStories\");\n\n UserStoryDetailController = (function(superClass) {\n extend(UserStoryDetailController, superClass);\n\n UserStoryDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function UserStoryDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.usRef = this.params.usref;\n this.scope.sectionName = this.translate.instant(\"US.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserStoryDetailController.prototype._setMeta = function() {\n var closedTasks, description, progressPercentage, ref, title, totalTasks;\n totalTasks = this.scope.tasks.length;\n closedTasks = _.filter(this.scope.tasks, (function(_this) {\n return function(t) {\n return _this.scope.taskStatusById[t.status].is_closed;\n };\n })(this)).length;\n progressPercentage = totalTasks > 0 ? Math.round(100 * closedTasks / totalTasks) : 0;\n title = this.translate.instant(\"US.PAGE_TITLE\", {\n userStoryRef: \"#\" + this.scope.us.ref,\n userStorySubject: this.scope.us.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"US.PAGE_DESCRIPTION\", {\n userStoryStatus: ((ref = this.scope.statusById[this.scope.us.status]) != null ? ref.name : void 0) || \"--\",\n userStoryPoints: this.scope.us.total_points,\n userStoryDescription: angular.element(this.scope.us.description_html || \"\").text(),\n userStoryClosedTasks: closedTasks,\n userStoryTotalTasks: totalTasks,\n userStoryProgressPercentage: progressPercentage\n });\n return this.appMetaService.setAll(title, description);\n };\n\n UserStoryDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"related-tasks:update\", (function(_this) {\n return function() {\n return _this.scope.tasks = _.clone(_this.scope.tasks, false);\n };\n })(this));\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on userstory\", 1);\n };\n })(this));\n return this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadUs();\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n if (this.scope.project.is_backlog_activated) {\n if (this.scope.us.milestone) {\n ctx.sprint = this.scope.sprint.slug;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-taskboard\", ctx);\n } else {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-backlog\", ctx);\n }\n } else if (this.scope.project.is_kanban_activated) {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-kanban\", ctx);\n }\n };\n\n UserStoryDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.us_statuses;\n _this.scope.statusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.taskStatusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(_this.scope.pointsList, function(e) {\n return e.id;\n });\n return project;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadUs = function() {\n var httpParams, kanbanStaus, milestone, noMilestone;\n httpParams = _.pick(this.location.search(), \"milestone\", \"no-milestone\", \"kanban-status\");\n milestone = httpParams.milestone;\n if (milestone) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n milestone: milestone,\n order_by: \"sprint_order\"\n });\n }\n noMilestone = httpParams[\"no-milestone\"];\n if (noMilestone) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n milestone: \"null\",\n order_by: \"backlog_order\"\n });\n }\n kanbanStaus = httpParams[\"kanban-status\"];\n if (kanbanStaus) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n status: kanbanStaus,\n order_by: \"kanban_order\"\n });\n }\n return this.rs.userstories.getByRef(this.scope.projectId, this.params.usref).then((function(_this) {\n return function(us) {\n var ctx, ref, ref1;\n _this.scope.us = us;\n _this.scope.usId = us.id;\n _this.scope.commentModel = us;\n if (((ref = _this.scope.us.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.us.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n if (((ref1 = _this.scope.us.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.us.neighbors.next.ref\n };\n _this.scope.nextUrl = _this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n return us;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadSprint = function() {\n if (this.scope.us.milestone) {\n return this.rs.sprints.get(this.scope.us.project, this.scope.us.milestone).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n return sprint;\n };\n })(this));\n }\n };\n\n UserStoryDetailController.prototype.loadTasks = function() {\n return this.rs.tasks.list(this.scope.projectId, null, this.scope.usId).then((function(_this) {\n return function(tasks) {\n _this.scope.tasks = tasks;\n return tasks;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadUs().then(function() {\n return _this.q.all([_this.loadSprint(), _this.loadTasks()]);\n });\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n UserStoryDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.upvote(this.scope.usId).then(onSuccess, onError);\n };\n\n UserStoryDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.downvote(this.scope.usId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n UserStoryDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.watch(this.scope.usId).then(onSuccess, onError);\n };\n\n UserStoryDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.unwatch(this.scope.usId).then(onSuccess, onError);\n };\n\n return UserStoryDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserStoryDetailController\", UserStoryDetailController);\n\n UsStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(us) {\n var html, status;\n status = $scope.statusById[us.status];\n html = template({\n is_closed: us.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(us) {\n if (us != null) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsStatusDisplay\", [\"$tgTemplate\", \"$compile\", UsStatusDisplayDirective]);\n\n UsStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template) {\n var link, template;\n template = $template.get(\"us/us-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = (function(_this) {\n return function(us) {\n var html, status;\n status = $scope.statusById[us.status];\n html = template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n });\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(status) {\n var currentLoading, onError, onSuccess, us;\n us = $model.$modelValue.clone();\n us.status = status;\n $.fn.popover().closeAll();\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(us);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n return currentLoading.finish();\n };\n return $repo.save(us).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var status, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n status = target.data(\"status-id\");\n return save(status);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", UsStatusButtonDirective]);\n\n UsTeamRequirementButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"us/us-team-requirement-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var canEdit, render, save;\n canEdit = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = function(us) {\n var ctx, html;\n ctx = {\n canEdit: canEdit(),\n isRequired: us.team_requirement\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(team_requirement) {\n var currentLoading, promise, us;\n us = $model.$modelValue.clone();\n us.team_requirement = team_requirement;\n currentLoading = $loading().target($el.find(\"label\")).start();\n promise = $tgrepo.save(us);\n promise.then(function() {\n $model.$setViewValue(us);\n currentLoading.finish();\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n $el.on(\"click\", \".team-requirement\", function(event) {\n var team_requirement;\n if (!canEdit()) {\n return;\n }\n team_requirement = !$model.$modelValue.team_requirement;\n return save(team_requirement);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsTeamRequirementButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsTeamRequirementButtonDirective]);\n\n UsClientRequirementButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"us/us-client-requirement-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var canEdit, render, save;\n canEdit = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = function(us) {\n var ctx, html;\n ctx = {\n canEdit: canEdit(),\n isRequired: us.client_requirement\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(client_requirement) {\n var currentLoading, promise, us;\n us = $model.$modelValue.clone();\n us.client_requirement = client_requirement;\n currentLoading = $loading().target($el.find(\"label\")).start();\n promise = $tgrepo.save(us);\n promise.then(function() {\n $model.$setViewValue(us);\n currentLoading.finish();\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n $el.on(\"click\", \".client-requirement\", function(event) {\n var client_requirement;\n if (!canEdit()) {\n return;\n }\n client_requirement = !$model.$modelValue.client_requirement;\n return save(client_requirement);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsClientRequirementButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsClientRequirementButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/tasks/detail.coffee\n */\n\n(function() {\n var TaskDetailController, TaskIsIocaineButtonDirective, TaskStatusButtonDirective, TaskStatusDisplayDirective, bindMethods, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaTasks\");\n\n TaskDetailController = (function(superClass) {\n extend(TaskDetailController, superClass);\n\n TaskDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function TaskDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.taskRef = this.params.taskref;\n this.scope.sectionName = this.translate.instant(\"TASK.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TaskDetailController.prototype._setMeta = function() {\n var description, ref, title;\n title = this.translate.instant(\"TASK.PAGE_TITLE\", {\n taskRef: \"#\" + this.scope.task.ref,\n taskSubject: this.scope.task.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"TASK.PAGE_DESCRIPTION\", {\n taskStatus: ((ref = this.scope.statusById[this.scope.task.status]) != null ? ref.name : void 0) || \"--\",\n taskDescription: angular.element(this.scope.task.description_html || \"\").text()\n });\n return this.appMetaService.setAll(title, description);\n };\n\n TaskDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on task\", 1);\n };\n })(this));\n this.scope.$on(\"custom-attributes-values:edit\", (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this));\n return this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadTask();\n };\n })(this));\n };\n\n TaskDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n if (this.scope.project.is_backlog_activated) {\n if (this.scope.task.milestone) {\n ctx.sprint = this.scope.sprint.slug;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-taskboard\", ctx);\n } else if (this.scope.task.us) {\n ctx.ref = this.scope.us.ref;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n } else if (this.scope.project.is_kanban_activated) {\n if (this.scope.us) {\n ctx.ref = this.scope.us.ref;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n }\n };\n\n TaskDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.task_statuses;\n _this.scope.statusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n TaskDetailController.prototype.loadTask = function() {\n return this.rs.tasks.getByRef(this.scope.projectId, this.params.taskref).then((function(_this) {\n return function(task) {\n var ctx, ref, ref1;\n _this.scope.task = task;\n _this.scope.taskId = task.id;\n _this.scope.commentModel = task;\n if (((ref = _this.scope.task.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.task.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-tasks-detail\", ctx);\n }\n if (((ref1 = _this.scope.task.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.task.neighbors.next.ref\n };\n _this.scope.nextUrl = _this.navUrls.resolve(\"project-tasks-detail\", ctx);\n }\n return task;\n };\n })(this));\n };\n\n TaskDetailController.prototype.loadSprint = function() {\n if (this.scope.task.milestone) {\n return this.rs.sprints.get(this.scope.task.project, this.scope.task.milestone).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n return sprint;\n };\n })(this));\n }\n };\n\n TaskDetailController.prototype.loadUserStory = function() {\n if (this.scope.task.user_story) {\n return this.rs.userstories.get(this.scope.task.project, this.scope.task.user_story).then((function(_this) {\n return function(us) {\n _this.scope.us = us;\n return us;\n };\n })(this));\n }\n };\n\n TaskDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadTask().then(function() {\n return _this.q.all([_this.loadSprint(), _this.loadUserStory()]);\n });\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n TaskDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.upvote(this.scope.taskId).then(onSuccess, onError);\n };\n\n TaskDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.downvote(this.scope.taskId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n TaskDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.watch(this.scope.taskId).then(onSuccess, onError);\n };\n\n TaskDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.unwatch(this.scope.taskId).then(onSuccess, onError);\n };\n\n return TaskDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TaskDetailController\", TaskDetailController);\n\n TaskStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(task) {\n var html, status;\n status = $scope.statusById[task.status];\n html = template({\n is_closed: status.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(task) {\n if (task != null) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskStatusDisplay\", [\"$tgTemplate\", \"$compile\", TaskStatusDisplayDirective]);\n\n TaskStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $compile, $translate, $template) {\n var link, template;\n template = $template.get(\"us/us-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_task\") !== -1;\n };\n render = (function(_this) {\n return function(task) {\n var html, status;\n status = $scope.statusById[task.status];\n html = $compile(template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n }))($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(status) {\n var currentLoading, onError, onSuccess, task;\n task = $model.$modelValue.clone();\n task.status = status;\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(task);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n return currentLoading.finish();\n };\n return $repo.save(task).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n $.fn.popover().closeAll();\n return save(target.data(\"status-id\"));\n });\n $scope.$watch($attrs.ngModel, function(task) {\n if (task) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$compile\", \"$translate\", \"$tgTemplate\", TaskStatusButtonDirective]);\n\n TaskIsIocaineButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $compile, $template) {\n var link, template;\n template = $template.get(\"issue/iocaine-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_task\") !== -1;\n };\n render = function(task) {\n var ctx, html;\n if (!isEditable() && !task.is_iocaine) {\n $el.html(\"\");\n return;\n }\n ctx = {\n isIocaine: task.is_iocaine,\n isEditable: isEditable()\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(is_iocaine) {\n var currentLoading, promise, task;\n task = $model.$modelValue.clone();\n task.is_iocaine = is_iocaine;\n currentLoading = $loading().target($el.find('label')).start();\n promise = $tgrepo.save(task);\n promise.then(function() {\n $model.$setViewValue(task);\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n })(this));\n $el.on(\"click\", \".is-iocaine\", function(event) {\n var is_iocaine;\n if (!isEditable()) {\n return;\n }\n is_iocaine = !$model.$modelValue.is_iocaine;\n return save(is_iocaine);\n });\n $scope.$watch($attrs.ngModel, function(task) {\n if (task) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskIsIocaineButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$compile\", \"$tgTemplate\", TaskIsIocaineButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/team/main.coffee\n */\n\n(function() {\n var LeaveProjectDirective, TeamController, TeamFiltersDirective, TeamMemberCurrentUserDirective, TeamMemberStatsDirective, TeamMembersDirective, membersFilter, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n module = angular.module(\"taigaTeam\");\n\n TeamController = (function(superClass) {\n extend(TeamController, superClass);\n\n TeamController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$location\", \"$tgNavUrls\", \"tgAppMetaService\", \"$tgAuth\", \"$translate\", \"tgProjectService\"];\n\n function TeamController(scope, rootscope, repo, rs, params, q, location, navUrls, appMetaService, auth, translate, projectService) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.auth = auth;\n this.translate = translate;\n this.projectService = projectService;\n this.scope.sectionName = \"TEAM.SECTION_NAME\";\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"TEAM.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"TEAM.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TeamController.prototype.setRole = function(role) {\n if (role) {\n return this.scope.filtersRole = role;\n } else {\n return this.scope.filtersRole = null;\n }\n };\n\n TeamController.prototype.loadMembers = function() {\n var i, len, member, ref, user;\n user = this.auth.getUser();\n this.scope.totals = {};\n ref = this.scope.activeUsers;\n for (i = 0, len = ref.length; i < len; i++) {\n member = ref[i];\n this.scope.totals[member.id] = 0;\n }\n this.scope.currentUser = _.find(this.scope.activeUsers, {\n id: user != null ? user.id : void 0\n });\n return this.scope.memberships = _.reject(this.scope.activeUsers, {\n id: user != null ? user.id : void 0\n });\n };\n\n TeamController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issuesEnabled = project.is_issues_activated;\n _this.scope.tasksEnabled = project.is_kanban_activated || project.is_backlog_activated;\n _this.scope.wikiEnabled = project.is_wiki_activated;\n return project;\n };\n })(this));\n };\n\n TeamController.prototype.loadMemberStats = function() {\n return this.rs.projects.memberStats(this.scope.projectId).then((function(_this) {\n return function(stats) {\n var totals;\n totals = {};\n _.forEach(_this.scope.totals, function(total, userId) {\n var vals;\n vals = _.map(stats, function(memberStats, statsKey) {\n return memberStats[userId];\n });\n total = _.reduce(vals, function(sum, el) {\n return sum + el;\n });\n return _this.scope.totals[userId] = total;\n });\n _this.scope.stats = _this._processStats(stats);\n return _this.scope.stats.totals = _this.scope.totals;\n };\n })(this));\n };\n\n TeamController.prototype._processStat = function(stat) {\n var max, min, singleStat;\n max = _.max(stat);\n min = _.min(stat);\n singleStat = _.map(stat, function(value, key) {\n if (value === min) {\n return [key, 0.1];\n }\n if (value === max) {\n return [key, 1];\n }\n return [key, (value * 0.5) / max];\n });\n singleStat = _.object(singleStat);\n return singleStat;\n };\n\n TeamController.prototype._processStats = function(stats) {\n var key, value;\n for (key in stats) {\n value = stats[key];\n stats[key] = this._processStat(value);\n }\n return stats;\n };\n\n TeamController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.loadMembers();\n return _this.loadMemberStats();\n };\n })(this));\n };\n\n return TeamController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TeamController\", TeamController);\n\n TeamFiltersDirective = function() {\n return {\n templateUrl: \"team/team-filter.html\"\n };\n };\n\n module.directive(\"tgTeamFilters\", [TeamFiltersDirective]);\n\n TeamMemberStatsDirective = function() {\n return {\n templateUrl: \"team/team-member-stats.html\",\n scope: {\n stats: \"=\",\n userId: \"=user\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamMemberStats\", TeamMemberStatsDirective);\n\n TeamMemberCurrentUserDirective = function() {\n return {\n templateUrl: \"team/team-member-current-user.html\",\n scope: {\n projectId: \"=projectid\",\n currentUser: \"=currentuser\",\n stats: \"=\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamCurrentUser\", TeamMemberCurrentUserDirective);\n\n TeamMembersDirective = function() {\n var template;\n template = \"team/team-members.html\";\n return {\n templateUrl: template,\n scope: {\n memberships: \"=\",\n filtersQ: \"=filtersq\",\n filtersRole: \"=filtersrole\",\n stats: \"=\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamMembers\", TeamMembersDirective);\n\n LeaveProjectDirective = function($repo, $confirm, $location, $rs, $navurls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.leave = function() {\n var confirm_leave_project_text, leave_project_text;\n leave_project_text = $translate.instant(\"TEAM.ACTION_LEAVE_PROJECT\");\n confirm_leave_project_text = $translate.instant(\"TEAM.CONFIRM_LEAVE_PROJECT\");\n return $confirm.ask(leave_project_text, confirm_leave_project_text).then((function(_this) {\n return function(response) {\n var promise;\n promise = $rs.projects.leave($attrs.projectid);\n promise.then(function() {\n response.finish();\n $confirm.notify(\"success\");\n return $location.path($navurls.resolve(\"home\"));\n });\n return promise.then(null, function(response) {\n response.finish();\n return $confirm.notify('error', response.data._error_message);\n });\n };\n })(this));\n };\n };\n return {\n scope: {},\n templateUrl: \"team/leave-project.html\",\n link: link\n };\n };\n\n module.directive(\"tgLeaveProject\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"$tgResources\", \"$tgNavUrls\", \"$translate\", LeaveProjectDirective]);\n\n membersFilter = function() {\n return function(members, filtersQ, filtersRole) {\n return _.filter(members, function(m) {\n return (!filtersRole || m.role === filtersRole.id) && (!filtersQ || m.full_name.search(new RegExp(filtersQ, \"i\")) >= 0);\n });\n };\n };\n\n module.filter('membersFilter', membersFilter);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki/detail.coffee\n */\n\n(function() {\n var EditableWikiContentDirective, WikiDetailController, WikiSummaryDirective, bindOnce, debounce, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaWiki\");\n\n WikiDetailController = (function(superClass) {\n extend(WikiDetailController, superClass);\n\n WikiDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgModel\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$filter\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function WikiDetailController(scope, rootscope, repo, model, confirm, rs, params, q, location, filter, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.model = model;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.filter = filter;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n this.scope.projectSlug = this.params.pslug;\n this.scope.wikiSlug = this.params.slug;\n this.scope.wikiTitle = this.scope.wikiSlug;\n this.scope.sectionName = \"Wiki\";\n this.scope.linksVisible = false;\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n return _this._setMeta();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n WikiDetailController.prototype._setMeta = function() {\n var description, ref, ref1, ref2, title;\n title = this.translate.instant(\"WIKI.PAGE_TITLE\", {\n wikiPageName: this.scope.wikiTitle,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"WIKI.PAGE_DESCRIPTION\", {\n wikiPageContent: angular.element(((ref = this.scope.wiki) != null ? ref.html : void 0) || \"\").text(),\n totalEditions: ((ref1 = this.scope.wiki) != null ? ref1.editions : void 0) || 0,\n lastModifiedDate: moment((ref2 = this.scope.wiki) != null ? ref2.modified_date : void 0).format(this.translate.instant(\"WIKI.DATETIME\"))\n });\n return this.appMetaService.setAll(title, description);\n };\n\n WikiDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_wiki_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadWiki = function() {\n var promise;\n promise = this.rs.wiki.getBySlug(this.scope.projectId, this.params.slug);\n promise.then((function(_this) {\n return function(wiki) {\n _this.scope.wiki = wiki;\n _this.scope.wikiId = wiki.id;\n return _this.scope.wiki;\n };\n })(this));\n return promise.then(null, (function(_this) {\n return function(xhr) {\n var data;\n _this.scope.wikiId = null;\n if (_this.scope.project.my_permissions.indexOf(\"add_wiki_page\") === -1) {\n return null;\n }\n data = {\n project: _this.scope.projectId,\n slug: _this.scope.wikiSlug,\n content: \"\"\n };\n _this.scope.wiki = _this.model.make_model(\"wiki\", data);\n return _this.scope.wiki;\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadWikiLinks = function() {\n return this.rs.wiki.listLinks(this.scope.projectId).then((function(_this) {\n return function(wikiLinks) {\n var selectedWikiLink;\n _this.scope.wikiLinks = wikiLinks;\n selectedWikiLink = _.find(wikiLinks, {\n href: _this.scope.wikiSlug\n });\n if (selectedWikiLink != null) {\n return _this.scope.wikiTitle = selectedWikiLink.title;\n }\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.q.all([_this.loadWikiLinks(), _this.loadWiki()]).then(_this.checkLinksPerms.bind(_this));\n };\n })(this));\n };\n\n WikiDetailController.prototype.checkLinksPerms = function() {\n if (this.scope.project.my_permissions.indexOf(\"modify_wiki_link\") !== -1 || (this.scope.project.my_permissions.indexOf(\"view_wiki_links\") !== -1 && this.scope.wikiLinks.length)) {\n return this.scope.linksVisible = true;\n }\n };\n\n WikiDetailController.prototype[\"delete\"] = function() {\n var message, title;\n title = this.translate.instant(\"WIKI.DELETE_LIGHTBOX_TITLE\");\n message = this.scope.wikiTitle;\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onSuccess = function() {\n var ctx;\n askResponse.finish();\n ctx = {\n project: _this.scope.projectSlug\n };\n _this.location.path(_this.navUrls.resolve(\"project-wiki\", ctx));\n return _this.confirm.notify(\"success\");\n };\n onError = function() {\n askResponse.finish(false);\n return _this.confirm.notify(\"error\");\n };\n return _this.repo.remove(_this.scope.wiki).then(onSuccess, onError);\n };\n })(this));\n };\n\n return WikiDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"WikiDetailController\", WikiDetailController);\n\n WikiSummaryDirective = function($log, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"wiki/wiki-summary.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var render;\n render = function(wiki) {\n var ctx, html, user;\n if ($scope.usersById == null) {\n $log.error(\"WikiSummaryDirective requires userById set in scope.\");\n } else {\n user = $scope.usersById[wiki.last_modifier];\n }\n if (user === void 0) {\n user = {\n name: \"unknown\",\n imgUrl: \"/\" + window._version + \"/images/user-noimage.png\"\n };\n } else {\n user = {\n name: user.full_name_display,\n imgUrl: user.photo\n };\n }\n ctx = {\n totalEditions: wiki.editions,\n lastModifiedDate: moment(wiki.modified_date).format($translate.instant(\"WIKI.DATETIME\")),\n user: user\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(wikiPage) {\n if (!wikiPage) {\n return;\n }\n return render(wikiPage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgWikiSummary\", [\"$log\", \"$tgTemplate\", \"$compile\", \"$translate\", WikiSummaryDirective]);\n\n EditableWikiContentDirective = function($window, $document, $repo, $confirm, $loading, $analytics, $qqueue) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var cancelEdition, disableEdition, getSelectedText, isEditable, save, switchToEditMode, switchToReadMode;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_wiki_page\") !== -1;\n };\n switchToEditMode = function() {\n $el.find('.edit-wiki-content').show();\n $el.find('.view-wiki-content').hide();\n return $el.find('textarea').focus();\n };\n switchToReadMode = function() {\n $el.find('.edit-wiki-content').hide();\n return $el.find('.view-wiki-content').show();\n };\n disableEdition = function() {\n $el.find(\".view-wiki-content .edit\").remove();\n return $el.find(\".edit-wiki-content\").remove();\n };\n cancelEdition = function() {\n if (!$model.$modelValue.id) {\n return;\n }\n $scope.$apply((function(_this) {\n return function() {\n return $model.$modelValue.revert();\n };\n })(this));\n return switchToReadMode();\n };\n getSelectedText = function() {\n if ($window.getSelection) {\n return $window.getSelection().toString();\n } else if ($document.selection) {\n return $document.selection.createRange().text;\n }\n return null;\n };\n save = $qqueue.bindAdd(function(wiki) {\n var currentLoading, onError, onSuccess, promise;\n onSuccess = function(wikiPage) {\n if (wiki.id == null) {\n $analytics.trackEvent(\"wikipage\", \"create\", \"create wiki page\", 1);\n }\n $model.$setViewValue(wikiPage.clone());\n $confirm.notify(\"success\");\n return switchToReadMode();\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n currentLoading = $loading().removeClasses(\"icon-floppy\").target($el.find('.icon-floppy')).start();\n if (wiki.id != null) {\n promise = $repo.save(wiki).then(onSuccess, onError);\n } else {\n promise = $repo.create(\"wiki\", wiki).then(onSuccess, onError);\n }\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n });\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"mousedown\", \".view-wiki-content\", function(event) {\n var target;\n target = angular.element(event.target);\n if (!isEditable()) {\n return;\n }\n if (event.button === 2) {\n\n }\n });\n $el.on(\"mouseup\", \".view-wiki-content\", function(event) {\n var target;\n target = angular.element(event.target);\n if (getSelectedText()) {\n return;\n }\n if (!isEditable()) {\n return;\n }\n if (target.is('a')) {\n return;\n }\n if (target.is('pre')) {\n return;\n }\n return switchToEditMode();\n });\n $el.on(\"click\", \".save\", debounce(2000, function() {\n return save($scope.wiki);\n }));\n $el.on(\"click\", \".cancel\", function() {\n return cancelEdition();\n });\n $el.on(\"keydown\", \"textarea\", function(event) {\n if (event.keyCode === 27) {\n return cancelEdition();\n }\n });\n $scope.$watch($attrs.ngModel, function(wikiPage) {\n if (!wikiPage) {\n return;\n }\n if (isEditable()) {\n $el.addClass('editable');\n if ((wikiPage.id == null) || $.trim(wikiPage.content).length === 0) {\n return switchToEditMode();\n }\n } else {\n return disableEdition();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n templateUrl: \"wiki/editable-wiki-content.html\"\n };\n };\n\n module.directive(\"tgEditableWikiContent\", [\"$window\", \"$document\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgAnalytics\", \"$tgQqueue\", EditableWikiContentDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki/detail.coffee\n */\n\n(function() {\n var WikiNavDirective, bindOnce, groupBy, mixOf, module, taiga;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaWiki\");\n\n WikiNavDirective = function($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $loading, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"wiki/wiki-nav.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, render;\n $ctrl = $el.controller();\n if ($attrs.ngModel == null) {\n return $log.error(\"WikiNavDirective: no ng-model attr is defined\");\n }\n render = function(wikiLinks) {\n var addWikiLinkPermission, deleteWikiLinkPermission, html;\n addWikiLinkPermission = $scope.project.my_permissions.indexOf(\"add_wiki_link\") > -1;\n deleteWikiLinkPermission = $scope.project.my_permissions.indexOf(\"delete_wiki_link\") > -1;\n html = template({\n wikiLinks: wikiLinks,\n projectSlug: $scope.projectSlug,\n addWikiLinkPermission: addWikiLinkPermission,\n deleteWikiLinkPermission: deleteWikiLinkPermission\n });\n html = $compile(html)($scope);\n $el.off();\n $el.html(html);\n $el.on(\"click\", \".wiki-link .link-title\", function(event) {\n var linkId, linkSlug, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n linkId = target.parents('.wiki-link').data('id');\n linkSlug = $scope.wikiLinks[linkId].href;\n return $scope.$apply(function() {\n var ctx;\n ctx = {\n project: $scope.projectSlug,\n slug: linkSlug\n };\n return $location.path($navUrls.resolve(\"project-wiki-page\", ctx));\n });\n });\n $el.on(\"click\", \".add-button\", function(event) {\n event.preventDefault();\n $el.find(\".new\").removeClass(\"hidden\");\n $el.find(\".new input\").focus();\n return $el.find(\".add-button\").hide();\n });\n $el.on(\"click\", \".wiki-link .icon-delete\", function(event) {\n var linkId, message, target, title;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n linkId = target.parents('.wiki-link').data('id');\n title = $translate.instant(\"WIKI.DELETE_LIGHTBOX_TITLE\");\n message = $scope.wikiLinks[linkId].title;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var promise;\n promise = $tgrepo.remove($scope.wikiLinks[linkId]);\n promise.then(function() {\n promise = $ctrl.loadWikiLinks();\n promise.then(function() {\n askResponse.finish();\n return render($scope.wikiLinks);\n });\n return promise.then(null, function() {\n return askResponse.finish();\n });\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n });\n return $el.on(\"keyup\", \".new input\", function(event) {\n var currentLoading, newLink, promise, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newLink = target.val();\n currentLoading = $loading().target($el.find(\".new\")).start();\n promise = $tgrepo.create(\"wiki-links\", {\n project: $scope.projectId,\n title: newLink\n });\n promise.then(function() {\n var loadPromise;\n $analytics.trackEvent(\"wikilink\", \"create\", \"create wiki link\", 1);\n loadPromise = $ctrl.loadWikiLinks();\n loadPromise.then(function() {\n currentLoading.finish();\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n $el.find(\".add-button\").show();\n return render($scope.wikiLinks);\n });\n return loadPromise.then(null, function() {\n currentLoading.finish();\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n $el.find(\".add-button\").show();\n return $confirm.notify(\"error\", \"Error loading wiki links\");\n });\n });\n return promise.then(null, function(error) {\n var ref;\n currentLoading.finish();\n $el.find(\".new input\").val(newLink);\n $el.find(\".new input\").focus().select();\n if ((error != null ? (ref = error.__all__) != null ? ref[0] : void 0 : void 0) != null) {\n return $confirm.notify(\"error\", \"The link already exists\");\n } else {\n return $confirm.notify(\"error\");\n }\n });\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n return $el.find(\".add-button\").show();\n }\n });\n };\n return bindOnce($scope, $attrs.ngModel, render);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgWikiNav\", [\"$tgRepo\", \"$log\", \"$tgLocation\", \"$tgConfirm\", \"$tgNavUrls\", \"$tgAnalytics\", \"$tgLoading\", \"$tgTemplate\", \"$compile\", \"$translate\", WikiNavDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/lightboxes.coffee\n */\n\n(function() {\n var CreateMembersDirective, MAX_MEMBERSHIP_FIELDSETS, debounce, module, taiga;\n\n taiga = this.taiga;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaKanban\");\n\n MAX_MEMBERSHIP_FIELDSETS = 4;\n\n CreateMembersDirective = function($rs, $rootScope, $confirm, $loading, lightboxService, $compile) {\n var extraTextTemplate, link, template;\n extraTextTemplate = \"
\\n \\n
\";\n template = _.template(\"
\\n
\\n data-required=\\\"true\\\" <% } %> data-type=\\\"email\\\" />\\n
\\n
\\n \\n \\n
\\n
\");\n link = function($scope, $el, $attrs) {\n var createFieldSet, resetForm, submit, submitButton;\n createFieldSet = function(required) {\n var ctx;\n if (required == null) {\n required = true;\n }\n ctx = {\n roleList: $scope.project.roles,\n required: required\n };\n return $compile(template(ctx))($scope);\n };\n resetForm = function() {\n var fieldSet, invitations;\n $el.find(\"form textarea\").remove();\n $el.find(\"form .add-member-wrapper\").remove();\n invitations = $el.find(\".add-member-forms\");\n invitations.html($compile(extraTextTemplate)($scope));\n fieldSet = createFieldSet();\n return invitations.prepend(fieldSet);\n };\n $scope.$on(\"membersform:new\", function() {\n resetForm();\n return lightboxService.open($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $el.on(\"click\", \".delete-fieldset\", function(event) {\n var fieldSet, lastActionButton, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n fieldSet = target.closest('.add-member-wrapper');\n fieldSet.remove();\n lastActionButton = $el.find(\".add-member-wrapper fieldset:last > a\");\n if (lastActionButton.hasClass(\"icon-delete delete-fieldset\")) {\n return lastActionButton.removeClass(\"icon-delete delete-fieldset\").addClass(\"icon-plus add-fieldset\");\n }\n });\n $el.on(\"click\", \".add-fieldset\", function(event) {\n var fieldSet, newFieldSet, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n fieldSet = target.closest('.add-member-wrapper');\n target.removeClass(\"icon-plus add-fieldset\").addClass(\"icon-delete delete-fieldset\");\n newFieldSet = createFieldSet(false);\n fieldSet.after(newFieldSet);\n $scope.$digest();\n if ($el.find(\".add-member-wrapper\").length === MAX_MEMBERSHIP_FIELDSETS) {\n return $el.find(\".add-member-wrapper fieldset:last > a\").removeClass(\"icon-plus add-fieldset\").addClass(\"icon-delete delete-fieldset\");\n }\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, form, invitation_extra_text, invitations, memberWrappers, onError, onSuccess, promise;\n event.preventDefault();\n currentLoading = $loading().target(submitButton).start();\n onSuccess = function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n $confirm.notify(\"success\");\n return $rootScope.$broadcast(\"membersform:new:success\");\n };\n onError = function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n $confirm.notify(\"error\");\n return $rootScope.$broadcast(\"membersform:new:error\");\n };\n form = $el.find(\"form\").checksley();\n form.destroy();\n form.initialize();\n if (!form.validate()) {\n return;\n }\n memberWrappers = $el.find(\"form .add-member-wrapper\");\n memberWrappers = _.filter(memberWrappers, function(mw) {\n return angular.element(mw).find(\"input\").hasClass('checksley-ok');\n });\n invitations = _.map(memberWrappers, function(mw) {\n var email, memberWrapper, role;\n memberWrapper = angular.element(mw);\n email = memberWrapper.find(\"input\");\n role = memberWrapper.find(\"select\");\n return {\n email: email.val(),\n role_id: role.val()\n };\n });\n if (invitations.length) {\n invitation_extra_text = $el.find(\"form textarea\").val();\n promise = $rs.memberships.bulkCreateMemberships($scope.project.id, invitations, invitation_extra_text);\n return promise.then(onSuccess, onError);\n }\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateMembers\", [\"$tgResources\", \"$rootScope\", \"$tgConfirm\", \"$tgLoading\", \"lightboxService\", \"$compile\", CreateMembersDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/memberships.coffee\n */\n\n(function() {\n var MembershipsController, MembershipsDirective, MembershipsRowActionsDirective, MembershipsRowAdminCheckboxDirective, MembershipsRowAvatarDirective, MembershipsRowRoleSelectorDirective, bindMethods, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaAdmin\");\n\n MembershipsController = (function(superClass) {\n extend(MembershipsController, superClass);\n\n MembershipsController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAnalytics\", \"tgAppMetaService\", \"$translate\"];\n\n function MembershipsController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, analytics, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.project = {};\n this.scope.filters = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.MEMBERSHIPS.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"membersform:new:success\", (function(_this) {\n return function() {\n _this.loadMembers();\n return _this.analytics.trackEvent(\"membership\", \"create\", \"create memberships on admin\", 1);\n };\n })(this));\n }\n\n MembershipsController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n MembershipsController.prototype.loadMembers = function() {\n var httpFilters;\n httpFilters = this.getUrlFilters();\n return this.rs.memberships.list(this.scope.projectId, httpFilters).then((function(_this) {\n return function(data) {\n _this.scope.memberships = _.filter(data.models, function(membership) {\n return membership.user === null || membership.is_user_active;\n });\n _this.scope.page = data.current;\n _this.scope.count = data.count;\n _this.scope.paginatedBy = data.paginatedBy;\n return data;\n };\n })(this));\n };\n\n MembershipsController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadMembers();\n };\n })(this));\n return promise;\n };\n\n MembershipsController.prototype.getUrlFilters = function() {\n var filters;\n filters = _.pick(this.location.search(), \"page\");\n if (!filters.page) {\n filters.page = 1;\n }\n return filters;\n };\n\n MembershipsController.prototype.addNewMembers = function() {\n return this.rootscope.$broadcast(\"membersform:new\");\n };\n\n return MembershipsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"MembershipsController\", MembershipsController);\n\n MembershipsDirective = function($template, $compile) {\n var link, linkPagination, template;\n template = $template.get(\"admin/admin-membership-paginator.html\", true);\n linkPagination = function($scope, $el, $attrs, $ctrl) {\n var $pagEl, afterCurrent, atBegin, atEnd, beforeCurrent, getNumPages, renderPagination;\n afterCurrent = 2;\n beforeCurrent = 4;\n atBegin = 2;\n atEnd = 2;\n $pagEl = $el.find(\".memberships-paginator\");\n getNumPages = function() {\n var numPages;\n numPages = $scope.count / $scope.paginatedBy;\n if (parseInt(numPages, 10) < numPages) {\n numPages = parseInt(numPages, 10) + 1;\n } else {\n numPages = parseInt(numPages, 10);\n }\n return numPages;\n };\n renderPagination = function() {\n var cpage, html, i, j, numPages, options, pages, ref;\n numPages = getNumPages();\n if (numPages <= 1) {\n $pagEl.hide();\n return;\n }\n pages = [];\n options = {};\n options.pages = pages;\n options.showPrevious = $scope.page > 1;\n options.showNext = !($scope.page === numPages);\n cpage = $scope.page;\n for (i = j = 1, ref = numPages; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\n if (i === (cpage + afterCurrent) && numPages > (cpage + afterCurrent + atEnd)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i === (cpage - beforeCurrent) && cpage > (atBegin + beforeCurrent)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i > (cpage + afterCurrent) && i <= (numPages - atEnd)) {\n\n } else if (i < (cpage - beforeCurrent) && i > atBegin) {\n\n } else if (i === cpage) {\n pages.push({\n classes: \"active\",\n num: i,\n type: \"page-active\"\n });\n } else {\n pages.push({\n classes: \"page\",\n num: i,\n type: \"page\"\n });\n }\n }\n html = template(options);\n html = $compile(html)($scope);\n $pagEl.html(html);\n return $pagEl.show();\n };\n $scope.$watch(\"memberships\", function(value) {\n if (!value) {\n return;\n }\n return renderPagination();\n });\n $el.on(\"click\", \".memberships-paginator a.next\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page + 1);\n return $ctrl.loadMembers();\n });\n });\n $el.on(\"click\", \".memberships-paginator a.previous\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n return $ctrl.loadMembers();\n });\n });\n return $el.on(\"click\", \".memberships-paginator li.page > a\", function(event) {\n var pagenum, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n pagenum = target.data(\"pagenum\");\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", pagenum);\n return $ctrl.loadMembers();\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n linkPagination($scope, $el, $attrs, $ctrl);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMemberships\", [\"$tgTemplate\", \"$compile\", MembershipsDirective]);\n\n MembershipsRowAvatarDirective = function($log, $template, $translate) {\n var link, template;\n template = $template.get(\"admin/memberships-row-avatar.html\", true);\n link = function($scope, $el, $attrs) {\n var member, pending, render;\n pending = $translate.instant(\"ADMIN.MEMBERSHIP.STATUS_PENDING\");\n render = function(member) {\n var ctx, html;\n ctx = {\n full_name: member.full_name ? member.full_name : \"\",\n email: member.user_email ? member.user_email : member.email,\n imgurl: member.photo ? member.photo : \"/\" + window._version + \"/images/unnamed.png\",\n pending: !member.is_user_active ? pending : \"\"\n };\n html = template(ctx);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowAvatar == null) {\n return $log.error(\"MembershipsRowAvatarDirective: the directive need a member\");\n }\n member = $scope.$eval($attrs.tgMembershipsRowAvatar);\n render(member);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowAvatar\", [\"$log\", \"$tgTemplate\", '$translate', MembershipsRowAvatarDirective]);\n\n MembershipsRowAdminCheckboxDirective = function($log, $repo, $confirm, $template, $compile) {\n var link, template;\n template = $template.get(\"admin/admin-memberships-row-checkbox.html\", true);\n link = function($scope, $el, $attrs) {\n var html, member, render;\n render = function(member) {\n var ctx, html;\n ctx = {\n inputId: \"is-admin-\" + member.id\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowAdminCheckbox == null) {\n return $log.error(\"MembershipsRowAdminCheckboxDirective: the directive need a member\");\n }\n member = $scope.$eval($attrs.tgMembershipsRowAdminCheckbox);\n html = render(member);\n if (member.is_owner) {\n $el.find(\":checkbox\").prop(\"checked\", true);\n }\n $el.on(\"click\", \":checkbox\", (function(_this) {\n return function(event) {\n var onError, onSuccess, target;\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function(data) {\n member.revert();\n $el.find(\":checkbox\").prop(\"checked\", member.is_owner);\n return $confirm.notify(\"error\", data.is_owner[0]);\n };\n target = angular.element(event.currentTarget);\n member.is_owner = target.prop(\"checked\");\n return $repo.save(member).then(onSuccess, onError);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowAdminCheckbox\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgTemplate\", \"$compile\", MembershipsRowAdminCheckboxDirective]);\n\n MembershipsRowRoleSelectorDirective = function($log, $repo, $confirm) {\n var link, template;\n template = _.template(\"\");\n link = function($scope, $el, $attrs) {\n var $ctrl, html, member, render;\n render = function(member) {\n var ctx, html;\n ctx = {\n roleList: $scope.project.roles,\n selectedRole: member.role\n };\n html = template(ctx);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowRoleSelector == null) {\n return $log.error(\"MembershipsRowRoleSelectorDirective: the directive need a member\");\n }\n $ctrl = $el.controller();\n member = $scope.$eval($attrs.tgMembershipsRowRoleSelector);\n html = render(member);\n $el.on(\"change\", \"select\", (function(_this) {\n return function(event) {\n var newRole, onError, onSuccess, target;\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n target = angular.element(event.currentTarget);\n newRole = parseInt(target.val(), 10);\n if (member.role !== newRole) {\n member.role = newRole;\n return $repo.save(member).then(onSuccess, onError);\n }\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowRoleSelector\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", MembershipsRowRoleSelectorDirective]);\n\n MembershipsRowActionsDirective = function($log, $repo, $rs, $confirm, $compile, $translate) {\n var activedTemplate, link, pendingTemplate;\n activedTemplate = \"
\\n
\\n\\n \\n\";\n pendingTemplate = \"\\n\\n\\n \\n\";\n link = function($scope, $el, $attrs) {\n var $ctrl, member, render;\n render = function(member) {\n var html;\n if (member.user) {\n html = $compile(activedTemplate)($scope);\n } else {\n html = $compile(pendingTemplate)($scope);\n }\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowActions == null) {\n return $log.error(\"MembershipsRowActionsDirective: the directive need a member\");\n }\n $ctrl = $el.controller();\n member = $scope.$eval($attrs.tgMembershipsRowActions);\n render(member);\n $el.on(\"click\", \".js-resend\", function(event) {\n var onError, onSuccess;\n event.preventDefault();\n onSuccess = function() {\n var text;\n text = $translate.instant(\"ADMIN.MEMBERSHIP.SUCCESS_SEND_INVITATION\", {\n email: $scope.member.email\n });\n return $confirm.notify(\"success\", text);\n };\n onError = function() {\n var text;\n text = $translate.instant(\"ADMIM.MEMBERSHIP.ERROR_SEND_INVITATION\");\n return $confirm.notify(\"error\", text);\n };\n return $rs.memberships.resendInvitation($scope.member.id).then(onSuccess, onError);\n });\n $el.on(\"click\", \".delete\", function(event) {\n var defaultMsg, message, title;\n event.preventDefault();\n title = $translate.instant(\"ADMIN.MEMBERSHIP.DELETE_MEMBER\");\n defaultMsg = $translate.instant(\"ADMIN.MEMBERSHIP.DEFAULT_DELETE_MESSAGE\", {\n email: member.email\n });\n message = member.user ? member.full_name : defaultMsg;\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n var text;\n askResponse.finish();\n if ($scope.page > 1 && ($scope.count - 1) <= $scope.paginatedBy) {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n }\n $ctrl.loadMembers();\n text = $translate.instant(\"ADMIN.MEMBERSHIP.SUCCESS_DELETE\");\n return $confirm.notify(\"success\", null, text);\n };\n })(this);\n onError = (function(_this) {\n return function() {\n var text;\n askResponse.finish(false);\n text = $translate.instant(\"ADMIN.MEMBERSHIP.ERROR_DELETE\", {\n message: message\n });\n return $confirm.notify(\"error\", null, text);\n };\n })(this);\n return $repo.remove(member).then(onSuccess, onError);\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowActions\", [\"$log\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$compile\", \"$translate\", MembershipsRowActionsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/nav.coffee\n */\n\n(function() {\n var AdminNavigationDirective, module;\n\n AdminNavigationDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var section;\n section = $attrs.tgAdminNavigation;\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\"#adminmenu-\" + section + \" a\").addClass(\"active\");\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaAdmin\");\n\n module.directive(\"tgAdminNavigation\", AdminNavigationDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/project-profile.coffee\n */\n\n(function() {\n var CsvExporterController, CsvExporterIssuesController, CsvExporterTasksController, CsvExporterUserstoriesController, CsvIssueDirective, CsvTaskDirective, CsvUsDirective, ProjectDefaultValuesDirective, ProjectExportDirective, ProjectLogoDirective, ProjectLogoModelDirective, ProjectModulesDirective, ProjectProfileController, ProjectProfileDirective, bindOnce, debounce, groupBy, joinStr, mixOf, module, taiga, toString, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAdmin\");\n\n ProjectProfileController = (function(superClass) {\n extend(ProjectProfileController, superClass);\n\n ProjectProfileController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectProfileController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_PROFILE.PAGE_TITLE\", {\n sectionName: sectionName,\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:loaded\", (function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_PROFILE.PAGE_TITLE\", {\n sectionName: sectionName,\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n }\n\n ProjectProfileController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.scope.taskStatusList = _.sortBy(project.task_statuses, \"order\");\n _this.scope.prioritiesList = _.sortBy(project.priorities, \"order\");\n _this.scope.severitiesList = _.sortBy(project.severities, \"order\");\n _this.scope.issueTypesList = _.sortBy(project.issue_types, \"order\");\n _this.scope.issueStatusList = _.sortBy(project.issue_statuses, \"order\");\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ProjectProfileController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise;\n };\n\n ProjectProfileController.prototype.openDeleteLightbox = function() {\n return this.rootscope.$broadcast(\"deletelightbox:new\", this.scope.project);\n };\n\n return ProjectProfileController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectProfileController\", ProjectProfileController);\n\n ProjectProfileDirective = function($repo, $confirm, $loading, $navurls, $location, projectService, currentUserService) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, form, submit, submitButton;\n $ctrl = $el.controller();\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n var newUrl;\n currentLoading.finish();\n $confirm.notify(\"success\");\n newUrl = $navurls.resolve(\"project-admin-project-profile-details\", {\n project: $scope.project.slug\n });\n $location.path(newUrl);\n $ctrl.loadInitialData();\n projectService.fetchProject();\n return currentUserService.loadProjects();\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectProfile\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgNavUrls\", \"$tgLocation\", \"tgProjectService\", \"tgCurrentUserService\", ProjectProfileDirective]);\n\n ProjectDefaultValuesDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectDefaultValues\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", ProjectDefaultValuesDirective]);\n\n ProjectModulesDirective = function($repo, $confirm, $loading, projectService) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n submit = (function(_this) {\n return function() {\n var currentLoading, form, promise, target;\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n target = angular.element(\".admin-functionalities .submit-button\");\n currentLoading = $loading().target(target).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n $scope.$emit(\"project:loaded\", $scope.project);\n return projectService.fetchProject();\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n return $confirm.notify(\"error\", data._error_message);\n });\n };\n })(this);\n $el.on(\"submit\", \"form\", function(event) {\n event.preventDefault();\n return submit();\n });\n $el.on(\"click\", \".admin-functionalities a.button-green\", function(event) {\n event.preventDefault();\n return submit();\n });\n $scope.$watch(\"isVideoconferenceActivated\", function(isVideoconferenceActivated) {\n if (isVideoconferenceActivated) {\n return $el.find(\".videoconference-attributes\").removeClass(\"hidden\");\n } else {\n $el.find(\".videoconference-attributes\").addClass(\"hidden\");\n $scope.project.videoconferences = null;\n return $scope.project.videoconferences_extra_data = \"\";\n }\n });\n return $scope.$watch(\"project\", function(project) {\n if (project.videoconferences != null) {\n return $scope.isVideoconferenceActivated = true;\n } else {\n return $scope.isVideoconferenceActivated = false;\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectModules\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"tgProjectService\", ProjectModulesDirective]);\n\n ProjectExportDirective = function($window, $rs, $confirm, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var asyn_message, buttonsEl, dump_ready_text, hideButtons, hideResult, hideSpinner, loading_msg, loading_title, resultEl, resultMessageEl, resultTitleEl, setAsyncMessage, setAsyncTitle, setLoadingMessage, setLoadingTitle, setSyncMessage, setSyncTitle, showButtons, showErrorMode, showExportResultAsyncMode, showExportResultSyncMode, showLoadingMode, showResult, showSpinner, spinnerEl, syn_message;\n buttonsEl = $el.find(\".admin-project-export-buttons\");\n showButtons = function() {\n return buttonsEl.removeClass(\"hidden\");\n };\n hideButtons = function() {\n return buttonsEl.addClass(\"hidden\");\n };\n resultEl = $el.find(\".admin-project-export-result\");\n showResult = function() {\n return resultEl.removeClass(\"hidden\");\n };\n hideResult = function() {\n return resultEl.addClass(\"hidden\");\n };\n spinnerEl = $el.find(\".spin\");\n showSpinner = function() {\n return spinnerEl.removeClass(\"hidden\");\n };\n hideSpinner = function() {\n return spinnerEl.addClass(\"hidden\");\n };\n resultTitleEl = $el.find(\".result-title\");\n loading_title = $translate.instant(\"ADMIN.PROJECT_EXPORT.LOADING_TITLE\");\n loading_msg = $translate.instant(\"ADMIN.PROJECT_EXPORT.LOADING_MESSAGE\");\n dump_ready_text = function() {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.DUMP_READY\"));\n };\n asyn_message = function() {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.ASYNC_MESSAGE\"));\n };\n syn_message = function(url) {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.SYNC_MESSAGE\", {\n url: url\n }));\n };\n setLoadingTitle = function() {\n return resultTitleEl.html(loading_title);\n };\n setAsyncTitle = function() {\n return resultTitleEl.html(loading_msg);\n };\n setSyncTitle = function() {\n return resultTitleEl.html(dump_ready_text);\n };\n resultMessageEl = $el.find(\".result-message \");\n setLoadingMessage = function() {\n return resultMessageEl.html(loading_msg);\n };\n setAsyncMessage = function() {\n return resultMessageEl.html(asyn_message);\n };\n setSyncMessage = function(url) {\n return resultMessageEl.html(syn_message(url));\n };\n showLoadingMode = function() {\n showSpinner();\n setLoadingTitle();\n setLoadingMessage();\n hideButtons();\n return showResult();\n };\n showExportResultAsyncMode = function() {\n hideSpinner();\n setAsyncTitle();\n return setAsyncMessage();\n };\n showExportResultSyncMode = function(url) {\n hideSpinner();\n setSyncTitle();\n return setSyncMessage(url);\n };\n showErrorMode = function() {\n hideSpinner();\n hideResult();\n return showButtons();\n };\n return $el.on(\"click\", \"a.button-export\", debounce(2000, (function(_this) {\n return function(event) {\n var onError, onSuccess;\n event.preventDefault();\n onSuccess = function(result) {\n var dumpUrl;\n if (result.status === 202) {\n return showExportResultAsyncMode();\n } else {\n dumpUrl = result.data.url;\n showExportResultSyncMode(dumpUrl);\n return $window.open(dumpUrl, \"_blank\");\n }\n };\n onError = function(result) {\n var errorMsg, ref;\n showErrorMode();\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR\");\n if (result.status === 429) {\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR_BUSY\");\n } else if ((ref = result.data) != null ? ref._error_message : void 0) {\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR_BUSY\", {\n message: result.data._error_message\n });\n }\n return $confirm.notify(\"error\", errorMsg);\n };\n showLoadingMode();\n return $rs.projects[\"export\"]($scope.projectId).then(onSuccess, onError);\n };\n })(this)));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectExport\", [\"$window\", \"$tgResources\", \"$tgConfirm\", \"$translate\", ProjectExportDirective]);\n\n CsvExporterController = (function(superClass) {\n extend(CsvExporterController, superClass);\n\n CsvExporterController.$inject = [\"$scope\", \"$rootScope\", \"$tgUrls\", \"$tgConfirm\", \"$tgResources\", \"$translate\"];\n\n function CsvExporterController(scope, rootscope, urls, confirm, rs, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.urls = urls;\n this.confirm = confirm;\n this.rs = rs;\n this.translate = translate;\n this._generateUuid = bind(this._generateUuid, this);\n this.setCsvUuid = bind(this.setCsvUuid, this);\n this.rootscope.$on(\"project:loaded\", this.setCsvUuid);\n this.scope.$watch(\"csvUuid\", (function(_this) {\n return function(value) {\n if (value) {\n return _this.scope.csvUrl = _this.urls.resolveAbsolute(_this.type + \"-csv\", value);\n } else {\n return _this.scope.csvUrl = \"\";\n }\n };\n })(this));\n }\n\n CsvExporterController.prototype.setCsvUuid = function() {\n return this.scope.csvUuid = this.scope.project[this.type + \"_csv_uuid\"];\n };\n\n CsvExporterController.prototype._generateUuid = function(response) {\n var promise;\n if (response == null) {\n response = null;\n }\n promise = this.rs.projects[\"regenerate_\" + this.type + \"_csv_uuid\"](this.scope.projectId);\n promise.then((function(_this) {\n return function(data) {\n var ref;\n return _this.scope.csvUuid = (ref = data.data) != null ? ref.uuid : void 0;\n };\n })(this));\n promise.then(null, (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n promise[\"finally\"](function() {\n if (response) {\n return response.finish();\n }\n });\n return promise;\n };\n\n CsvExporterController.prototype.regenerateUuid = function() {\n var subtitle, title;\n if (this.scope.csvUuid) {\n title = this.translate.instant(\"ADMIN.REPORTS.REGENERATE_TITLE\");\n subtitle = this.translate.instant(\"ADMIN.REPORTS.REGENERATE_SUBTITLE\");\n return this.confirm.ask(title, subtitle).then(this._generateUuid);\n } else {\n return this._generateUuid();\n }\n };\n\n return CsvExporterController;\n\n })(taiga.Controller);\n\n CsvExporterUserstoriesController = (function(superClass) {\n extend(CsvExporterUserstoriesController, superClass);\n\n function CsvExporterUserstoriesController() {\n return CsvExporterUserstoriesController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterUserstoriesController.prototype.type = \"userstories\";\n\n return CsvExporterUserstoriesController;\n\n })(CsvExporterController);\n\n CsvExporterTasksController = (function(superClass) {\n extend(CsvExporterTasksController, superClass);\n\n function CsvExporterTasksController() {\n return CsvExporterTasksController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterTasksController.prototype.type = \"tasks\";\n\n return CsvExporterTasksController;\n\n })(CsvExporterController);\n\n CsvExporterIssuesController = (function(superClass) {\n extend(CsvExporterIssuesController, superClass);\n\n function CsvExporterIssuesController() {\n return CsvExporterIssuesController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterIssuesController.prototype.type = \"issues\";\n\n return CsvExporterIssuesController;\n\n })(CsvExporterController);\n\n module.controller(\"CsvExporterUserstoriesController\", CsvExporterUserstoriesController);\n\n module.controller(\"CsvExporterTasksController\", CsvExporterTasksController);\n\n module.controller(\"CsvExporterIssuesController\", CsvExporterIssuesController);\n\n CsvUsDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_US\";\n };\n return {\n controller: \"CsvExporterUserstoriesController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvUs\", [\"$translate\", CsvUsDirective]);\n\n CsvTaskDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_TASK\";\n };\n return {\n controller: \"CsvExporterTasksController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvTask\", [\"$translate\", CsvTaskDirective]);\n\n CsvIssueDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_ISSUE\";\n };\n return {\n controller: \"CsvExporterIssuesController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvIssue\", [\"$translate\", CsvIssueDirective]);\n\n ProjectLogoDirective = function($auth, $model, $rs, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var onError, onSuccess, showSizeInfo;\n showSizeInfo = function() {\n return $el.find(\".size-info\").addClass(\"active\");\n };\n onSuccess = function(response) {\n var project;\n project = $model.make_model(\"projects\", response.data);\n $scope.project = project;\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('success');\n };\n onError = function(response) {\n if (response.status === 413) {\n showSizeInfo();\n }\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('error', response.data._error_message);\n };\n $el.on(\"click\", \".js-change-logo\", function() {\n return $el.find(\"#logo-field\").click();\n });\n $el.on(\"change\", \"#logo-field\", function(event) {\n if ($scope.logoAttachment) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.projects.changeLogo($scope.project.id, $scope.logoAttachment).then(onSuccess, onError);\n }\n });\n $el.on(\"click\", \"a.js-use-default-logo\", function(event) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.projects.removeLogo($scope.project.id).then(onSuccess, onError);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectLogo\", [\"$tgAuth\", \"$tgModel\", \"$tgResources\", \"$tgConfirm\", ProjectLogoDirective]);\n\n ProjectLogoModelDirective = function($parse) {\n var link;\n link = function($scope, $el, $attrs) {\n var model, modelSetter;\n model = $parse($attrs.tgProjectLogoModel);\n modelSetter = model.assign;\n return $el.bind('change', function() {\n return $scope.$apply(function() {\n return modelSetter($scope, $el[0].files[0]);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive('tgProjectLogoModel', ['$parse', ProjectLogoModelDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/project-profile.coffee\n */\n\n(function() {\n var ColorSelectionDirective, DATE_TYPE, MULTILINE_TYPE, ProjectCustomAttributesController, ProjectCustomAttributesDirective, ProjectValuesController, ProjectValuesDirective, ProjectValuesSectionController, TEXT_TYPE, TYPE_CHOICES, bindOnce, debounce, groupBy, joinStr, mixOf, module, taiga, toString, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAdmin\");\n\n ProjectValuesSectionController = (function(superClass) {\n extend(ProjectValuesSectionController, superClass);\n\n ProjectValuesSectionController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectValuesSectionController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_VALUES.PAGE_TITLE\", {\n \"sectionName\": sectionName,\n \"projectName\": _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n ProjectValuesSectionController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ProjectValuesSectionController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise;\n };\n\n return ProjectValuesSectionController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectValuesSectionController\", ProjectValuesSectionController);\n\n ProjectValuesController = (function(superClass) {\n extend(ProjectValuesController, superClass);\n\n ProjectValuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\"];\n\n function ProjectValuesController(scope, rootscope, repo, confirm, rs) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.moveValue = bind(this.moveValue, this);\n this.loadValues = bind(this.loadValues, this);\n this.scope.$on(\"admin:project-values:move\", this.moveValue);\n this.rootscope.$on(\"project:loaded\", this.loadValues);\n }\n\n ProjectValuesController.prototype.loadValues = function() {\n return this.rs[this.scope.resource].listValues(this.scope.projectId, this.scope.type).then((function(_this) {\n return function(values) {\n _this.scope.values = values;\n _this.scope.maxValueOrder = _.max(values, \"order\").order;\n return values;\n };\n })(this));\n };\n\n ProjectValuesController.prototype.moveValue = function(ctx, itemValue, itemIndex) {\n var r, values;\n values = this.scope.values;\n r = values.indexOf(itemValue);\n values.splice(r, 1);\n values.splice(itemIndex, 0, itemValue);\n _.each(values, function(value, index) {\n return value.order = index;\n });\n return this.repo.saveAll(values);\n };\n\n return ProjectValuesController;\n\n })(taiga.Controller);\n\n module.controller(\"ProjectValuesController\", ProjectValuesController);\n\n ProjectValuesDirective = function($log, $repo, $confirm, $location, animationFrame, $translate, $rootscope) {\n var link, linkDragAndDrop, linkValue;\n linkDragAndDrop = function($scope, $el, $attrs) {\n var itemEl, newParentScope, oldParentScope, tdom;\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el.find(\".sortable\");\n tdom.sortable({\n handle: \".row.table-main.visualization\",\n dropOnEmpty: true,\n connectWith: \".project-values-body\",\n revert: 400,\n axis: \"y\"\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemValue;\n itemEl = ui.item;\n itemValue = itemEl.scope().value;\n itemIndex = itemEl.index();\n return $scope.$broadcast(\"admin:project-values:move\", itemValue, itemIndex);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n linkValue = function($scope, $el, $attrs) {\n var $ctrl, cancel, goToBottomList, initializeNewValue, initializeTextTranslations, objName, saveNewValue, saveValue, valueType;\n $ctrl = $el.controller();\n valueType = $attrs.type;\n objName = $attrs.objname;\n initializeNewValue = function() {\n return $scope.newValue = {\n \"name\": \"\",\n \"is_closed\": false,\n \"is_archived\": false\n };\n };\n initializeTextTranslations = function() {\n return $scope.addNewElementText = $translate.instant(\"ADMIN.PROJECT_VALUES_\" + (objName.toUpperCase()) + \".ACTION_ADD\");\n };\n initializeNewValue();\n initializeTextTranslations();\n $rootscope.$on(\"$translateChangeEnd\", function() {\n return $scope.$evalAsync(initializeTextTranslations);\n });\n goToBottomList = (function(_this) {\n return function(focus) {\n var table;\n if (focus == null) {\n focus = false;\n }\n table = $el.find(\".table-main\");\n $(document.body).scrollTop(table.offset().top + table.height());\n if (focus) {\n return $el.find(\".new-value input:visible\").first().focus();\n }\n };\n })(this);\n saveValue = function(target) {\n var form, formEl, promise, value;\n formEl = target.parents(\"form\");\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n value = formEl.scope().value;\n promise = $repo.save(value);\n promise.then((function(_this) {\n return function() {\n var row;\n row = target.parents(\".row.table-main\");\n row.addClass(\"hidden\");\n return row.siblings(\".visualization\").removeClass('hidden');\n };\n })(this));\n return promise.then(null, function(data) {\n return form.setErrors(data);\n });\n };\n saveNewValue = function(target) {\n var form, formEl, promise;\n formEl = target.parents(\"form\");\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n $scope.newValue.project = $scope.project.id;\n $scope.newValue.order = $scope.maxValueOrder ? $scope.maxValueOrder + 1 : 1;\n promise = $repo.create(valueType, $scope.newValue);\n promise.then((function(_this) {\n return function(data) {\n target.addClass(\"hidden\");\n $scope.values.push(data);\n $scope.maxValueOrder = data.order;\n return initializeNewValue();\n };\n })(this));\n return promise.then(null, function(data) {\n return form.setErrors(data);\n });\n };\n cancel = function(target) {\n var formEl, row, value;\n row = target.parents(\".row.table-main\");\n formEl = target.parents(\"form\");\n value = formEl.scope().value;\n return $scope.$apply(function() {\n row.addClass(\"hidden\");\n value.revert();\n return row.siblings(\".visualization\").removeClass('hidden');\n });\n };\n $el.on(\"click\", \".show-add-new\", function(event) {\n event.preventDefault();\n $el.find(\".new-value\").removeClass('hidden');\n return goToBottomList(true);\n });\n $el.on(\"click\", \".add-new\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n target = $el.find(\".new-value\");\n return saveNewValue(target);\n }));\n $el.on(\"click\", \".delete-new\", function(event) {\n event.preventDefault();\n $el.find(\".new-value\").addClass(\"hidden\");\n return initializeNewValue();\n });\n $el.on(\"click\", \".edit-value\", function(event) {\n var editionRow, row, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n row = target.parents(\".row.table-main\");\n row.addClass(\"hidden\");\n editionRow = row.siblings(\".edition\");\n editionRow.removeClass('hidden');\n return editionRow.find('input:visible').first().focus().select();\n });\n $el.on(\"keyup\", \".edition input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n return saveValue(target);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n return cancel(target);\n }\n });\n $el.on(\"keyup\", \".new-value input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = $el.find(\".new-value\");\n return saveNewValue(target);\n } else if (event.keyCode === 27) {\n $el.find(\".new-value\").addClass(\"hidden\");\n return initializeNewValue();\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return saveValue(target);\n });\n $el.on(\"click\", \".cancel\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return cancel(target);\n });\n return $el.on(\"click\", \".delete-value\", function(event) {\n var choices, formEl, subtitle, target, text, title, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.parents(\"form\");\n value = formEl.scope().value;\n choices = {};\n _.each($scope.values, function(option) {\n if (value.id !== option.id) {\n return choices[option.id] = option.name;\n }\n });\n subtitle = value.name;\n if (_.keys(choices).length === 0) {\n return $confirm.error($translate.instant(\"ADMIN.PROJECT_VALUES.ERROR_DELETE_ALL\"));\n }\n title = $translate.instant(\"ADMIN.COMMON.TITLE_ACTION_DELETE_VALUE\");\n text = $translate.instant(\"ADMIN.PROJECT_VALUES.REPLACEMENT\");\n return $confirm.askChoice(title, subtitle, choices, text).then(function(response) {\n var onError, onSucces;\n onSucces = function() {\n return $ctrl.loadValues()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n return $repo.remove(value, {\n \"moveTo\": response.selected\n }).then(onSucces, onError);\n });\n });\n };\n link = function($scope, $el, $attrs) {\n linkDragAndDrop($scope, $el, $attrs);\n linkValue($scope, $el, $attrs);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectValues\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"animationFrame\", \"$translate\", \"$rootScope\", ProjectValuesDirective]);\n\n ColorSelectionDirective = function() {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var $ctrl;\n $ctrl = $el.controller();\n $scope.$watch($attrs.ngModel, function(element) {\n return $scope.color = element.color;\n });\n $el.on(\"click\", \".current-color\", function(event) {\n var body, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n $el.find(\".select-color\").hide();\n target.siblings(\".select-color\").show();\n body = angular.element(\"body\");\n return body.on(\"click\", (function(_this) {\n return function(event) {\n if (angular.element(event.target).parent(\".select-color\").length === 0) {\n $el.find(\".select-color\").hide();\n return body.unbind(\"click\");\n }\n };\n })(this));\n });\n $el.on(\"click\", \".select-color .color\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n $scope.$apply(function() {\n return $model.$modelValue.color = target.data(\"color\");\n });\n return $el.find(\".select-color\").hide();\n });\n $el.on(\"click\", \".select-color .selected-color\", function(event) {\n event.preventDefault();\n $scope.$apply(function() {\n return $model.$modelValue.color = $scope.color;\n });\n return $el.find(\".select-color\").hide();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgColorSelection\", ColorSelectionDirective);\n\n TEXT_TYPE = \"text\";\n\n MULTILINE_TYPE = \"multiline\";\n\n DATE_TYPE = \"date\";\n\n TYPE_CHOICES = [\n {\n key: TEXT_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT\"\n }, {\n key: MULTILINE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI\"\n }, {\n key: DATE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE\"\n }\n ];\n\n ProjectCustomAttributesController = (function(superClass) {\n extend(ProjectCustomAttributesController, superClass);\n\n ProjectCustomAttributesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectCustomAttributesController(scope, rootscope, repo, rs, params, q, location, navUrls, appMetaService, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.moveCustomAttributes = bind(this.moveCustomAttributes, this);\n this.deleteCustomAttribute = bind(this.deleteCustomAttribute, this);\n this.saveCustomAttribute = bind(this.saveCustomAttribute, this);\n this.createCustomAttribute = bind(this.createCustomAttribute, this);\n this.loadCustomAttributes = bind(this.loadCustomAttributes, this);\n this.scope.TYPE_CHOICES = TYPE_CHOICES;\n this.scope.project = {};\n this.rootscope.$on(\"project:loaded\", (function(_this) {\n return function() {\n var description, sectionName, title;\n _this.loadCustomAttributes();\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.CUSTOM_ATTRIBUTES.PAGE_TITLE\", {\n \"sectionName\": sectionName,\n \"projectName\": _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n }\n\n ProjectCustomAttributesController.prototype.loadCustomAttributes = function() {\n return this.rs.customAttributes[this.scope.type].list(this.scope.projectId).then((function(_this) {\n return function(customAttributes) {\n _this.scope.customAttributes = customAttributes;\n _this.scope.maxOrder = _.max(customAttributes, \"order\").order;\n return customAttributes;\n };\n })(this));\n };\n\n ProjectCustomAttributesController.prototype.createCustomAttribute = function(attrValues) {\n return this.repo.create(\"custom-attributes/\" + this.scope.type, attrValues);\n };\n\n ProjectCustomAttributesController.prototype.saveCustomAttribute = function(attrModel) {\n return this.repo.save(attrModel);\n };\n\n ProjectCustomAttributesController.prototype.deleteCustomAttribute = function(attrModel) {\n return this.repo.remove(attrModel);\n };\n\n ProjectCustomAttributesController.prototype.moveCustomAttributes = function(attrModel, newIndex) {\n var customAttributes, r;\n customAttributes = this.scope.customAttributes;\n r = customAttributes.indexOf(attrModel);\n customAttributes.splice(r, 1);\n customAttributes.splice(newIndex, 0, attrModel);\n _.each(customAttributes, function(val, idx) {\n return val.order = idx;\n });\n return this.repo.saveAll(customAttributes);\n };\n\n return ProjectCustomAttributesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectCustomAttributesController\", ProjectCustomAttributesController);\n\n ProjectCustomAttributesDirective = function($log, $confirm, animationFrame, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, cancelCreate, cancelUpdate, create, deleteCustomAttribute, hideAddButton, hideCancelButton, hideCreateForm, hideEditForm, resetNewAttr, revertChangesInCustomAttribute, showAddButton, showCancelButton, showCreateForm, showEditForm, sortableEl, update;\n $ctrl = $el.controller();\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n sortableEl = $el.find(\".js-sortable\");\n sortableEl.sortable({\n handle: \".js-view-custom-field\",\n dropOnEmpty: true,\n revert: 400,\n axis: \"y\"\n });\n sortableEl.on(\"sortstop\", function(event, ui) {\n var itemAttr, itemEl, itemIndex;\n itemEl = ui.item;\n itemAttr = itemEl.scope().attr;\n itemIndex = itemEl.index();\n return $ctrl.moveCustomAttributes(itemAttr, itemIndex);\n });\n showCreateForm = function() {\n $el.find(\".js-new-custom-field\").removeClass(\"hidden\");\n return $el.find(\".js-new-custom-field input:visible\").first().focus();\n };\n hideCreateForm = function() {\n return $el.find(\".js-new-custom-field\").addClass(\"hidden\");\n };\n showAddButton = function() {\n return $el.find(\".js-add-custom-field-button\").removeClass(\"hidden\");\n };\n hideAddButton = function() {\n return $el.find(\".js-add-custom-field-button\").addClass(\"hidden\");\n };\n showCancelButton = function() {\n return $el.find(\".js-cancel-new-custom-field-button\").removeClass(\"hidden\");\n };\n hideCancelButton = function() {\n return $el.find(\".js-cancel-new-custom-field-button\").addClass(\"hidden\");\n };\n resetNewAttr = function() {\n return $scope.newAttr = {};\n };\n create = function(formEl) {\n var attr, form, onError, onSucces;\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n onSucces = (function(_this) {\n return function() {\n $ctrl.loadCustomAttributes();\n hideCreateForm();\n resetNewAttr();\n return $confirm.notify(\"success\");\n };\n })(this);\n onError = (function(_this) {\n return function(data) {\n return form.setErrors(data);\n };\n })(this);\n attr = $scope.newAttr;\n attr.project = $scope.projectId;\n attr.order = $scope.maxOrder ? $scope.maxOrder + 1 : 1;\n return $ctrl.createCustomAttribute(attr).then(onSucces, onError);\n };\n cancelCreate = function() {\n hideCreateForm();\n return resetNewAttr();\n };\n $scope.$watch(\"customAttributes\", function(customAttributes) {\n if (!customAttributes) {\n return;\n }\n if (customAttributes.length === 0) {\n hideCancelButton();\n hideAddButton();\n return showCreateForm();\n } else {\n hideCreateForm();\n showAddButton();\n return showCancelButton();\n }\n });\n $el.on(\"click\", \".js-add-custom-field-button\", function(event) {\n event.preventDefault();\n return showCreateForm();\n });\n $el.on(\"click\", \".js-create-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return create(formEl);\n }));\n $el.on(\"click\", \".js-cancel-new-custom-field-button\", function(event) {\n event.preventDefault();\n return cancelCreate();\n });\n $el.on(\"keyup\", \".js-new-custom-field input\", function(event) {\n var formEl, target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return create(formEl);\n } else if (event.keyCode === 27) {\n return cancelCreate();\n }\n });\n showEditForm = function(formEl) {\n formEl.find(\".js-view-custom-field\").addClass(\"hidden\");\n formEl.find(\".js-edit-custom-field\").removeClass(\"hidden\");\n return formEl.find(\".js-edit-custom-field input:visible\").first().focus().select();\n };\n hideEditForm = function(formEl) {\n formEl.find(\".js-edit-custom-field\").addClass(\"hidden\");\n return formEl.find(\".js-view-custom-field\").removeClass(\"hidden\");\n };\n revertChangesInCustomAttribute = function(formEl) {\n return $scope.$apply(function() {\n return formEl.scope().attr.revert();\n });\n };\n update = function(formEl) {\n var attr, form, onError, onSucces;\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n onSucces = (function(_this) {\n return function() {\n $ctrl.loadCustomAttributes();\n hideEditForm(formEl);\n return $confirm.notify(\"success\");\n };\n })(this);\n onError = (function(_this) {\n return function(data) {\n return form.setErrors(data);\n };\n })(this);\n attr = formEl.scope().attr;\n return $ctrl.saveCustomAttribute(attr).then(onSucces, onError);\n };\n cancelUpdate = function(formEl) {\n hideEditForm(formEl);\n return revertChangesInCustomAttribute(formEl);\n };\n $el.on(\"click\", \".js-edit-custom-field-button\", function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return showEditForm(formEl);\n });\n $el.on(\"click\", \".js-update-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return update(formEl);\n }));\n $el.on(\"click\", \".js-cancel-edit-custom-field-button\", function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return cancelUpdate(formEl);\n });\n $el.on(\"keyup\", \".js-edit-custom-field input\", function(event) {\n var formEl, target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return update(formEl);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return cancelUpdate(formEl);\n }\n });\n deleteCustomAttribute = function(formEl) {\n var attr, message, text, title;\n attr = formEl.scope().attr;\n message = attr.name;\n title = $translate.instant(\"COMMON.CUSTOM_ATTRIBUTES.DELETE\");\n text = $translate.instant(\"COMMON.CUSTOM_ATTRIBUTES.CONFIRM_DELETE\");\n return $confirm.ask(title, text, message).then(function(response) {\n var onError, onSucces;\n onSucces = function() {\n return $ctrl.loadCustomAttributes()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return $confirm.notify(\"error\", null, \"We have not been able to delete '\" + message + \"'.\");\n };\n return $ctrl.deleteCustomAttribute(attr).then(onSucces, onError);\n });\n };\n return $el.on(\"click\", \".js-delete-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return deleteCustomAttribute(formEl);\n }));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectCustomAttributes\", [\"$log\", \"$tgConfirm\", \"animationFrame\", \"$translate\", ProjectCustomAttributesDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/memberships.coffee\n */\n\n(function() {\n var EditRoleDirective, NewRoleDirective, RolePermissionsDirective, RolesController, RolesDirective, bindMethods, bindOnce, debounce, mixOf, module, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaAdmin\");\n\n RolesController = (function(superClass) {\n extend(RolesController, superClass);\n\n RolesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function RolesController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this._disableComputable = bind(this._disableComputable, this);\n this._enableComputable = bind(this._enableComputable, this);\n bindMethods(this);\n this.scope.sectionName = \"ADMIN.MENU.PERMISSIONS\";\n this.scope.project = {};\n this.scope.anyComputableRole = true;\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.ROLES.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n RolesController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.anyComputableRole = _.some(_.map(project.roles, function(point) {\n return point.computable;\n }));\n return project;\n };\n })(this));\n };\n\n RolesController.prototype.loadRoles = function() {\n return this.rs.roles.list(this.scope.projectId).then((function(_this) {\n return function(roles) {\n var public_permission;\n roles = roles.map(function(role) {\n role.external_user = false;\n return role;\n });\n public_permission = {\n \"name\": _this.translate.instant(\"ADMIN.ROLES.EXTERNAL_USER\"),\n \"permissions\": _this.scope.project.public_permissions,\n \"external_user\": true\n };\n roles.push(public_permission);\n _this.scope.roles = roles;\n _this.scope.role = _this.scope.roles[0];\n return roles;\n };\n })(this));\n };\n\n RolesController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadRoles();\n };\n })(this));\n return promise;\n };\n\n RolesController.prototype.setRole = function(role) {\n this.scope.role = role;\n return this.scope.$broadcast(\"role:changed\", this.scope.role);\n };\n\n RolesController.prototype[\"delete\"] = function() {\n var choices, i, len, ref, replacement, role, subtitle, title, warning;\n choices = {};\n ref = this.scope.roles;\n for (i = 0, len = ref.length; i < len; i++) {\n role = ref[i];\n if (role.id !== this.scope.role.id) {\n choices[role.id] = role.name;\n }\n }\n if (_.keys(choices).length === 0) {\n return this.confirm.error(this.translate.instant(\"ADMIN.ROLES.ERROR_DELETE_ALL\"));\n }\n title = this.translate.instant(\"ADMIN.ROLES.TITLE_DELETE_ROLE\");\n subtitle = this.scope.role.name;\n replacement = this.translate.instant(\"ADMIN.ROLES.REPLACEMENT_ROLE\");\n warning = this.translate.instant(\"ADMIN.ROLES.WARNING_DELETE_ROLE\");\n return this.confirm.askChoice(title, subtitle, choices, replacement, warning).then((function(_this) {\n return function(response) {\n var onError, onSuccess;\n onSuccess = function() {\n _this.loadProject();\n return _this.loadRoles()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return _this.confirm.notify('error');\n };\n return _this.repo.remove(_this.scope.role, {\n moveTo: response.selected\n }).then(onSuccess, onError);\n };\n })(this));\n };\n\n RolesController.prototype._enableComputable = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.confirm.notify(\"success\");\n return _this.loadProject();\n };\n })(this);\n onError = (function(_this) {\n return function() {\n _this.confirm.notify(\"error\");\n return _this.scope.role.revert();\n };\n })(this);\n return this.repo.save(this.scope.role).then(onSuccess, onError);\n };\n\n RolesController.prototype._disableComputable = function() {\n var askOnError, askOnSuccess, message, subtitle, title;\n askOnSuccess = (function(_this) {\n return function(response) {\n var onError, onSuccess;\n onSuccess = function() {\n response.finish();\n _this.confirm.notify(\"success\");\n return _this.loadProject();\n };\n onError = function() {\n response.finish();\n _this.confirm.notify(\"error\");\n return _this.scope.role.revert();\n };\n return _this.repo.save(_this.scope.role).then(onSuccess, onError);\n };\n })(this);\n askOnError = (function(_this) {\n return function(response) {\n return _this.scope.role.revert();\n };\n })(this);\n title = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_TITLE\");\n subtitle = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_SUBTITLE\", {\n roleName: this.scope.role.name\n });\n message = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_MESSAGE\");\n return this.confirm.ask(title, subtitle, message).then(askOnSuccess, askOnError);\n };\n\n RolesController.prototype.toggleComputable = debounce(2000, function() {\n if (!this.scope.role.computable) {\n return this._disableComputable();\n } else {\n return this._enableComputable();\n }\n });\n\n return RolesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"RolesController\", RolesController);\n\n EditRoleDirective = function($repo, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit, toggleView;\n toggleView = function() {\n $el.find('.total').toggle();\n return $el.find('.edit-role').toggle();\n };\n submit = function() {\n var promise;\n $scope.role.name = $el.find(\"input\").val();\n promise = $repo.save($scope.role);\n promise.then(function() {\n return $confirm.notify(\"success\");\n });\n promise.then(null, function(data) {\n return $confirm.notify(\"error\");\n });\n return toggleView();\n };\n $el.on(\"click\", \"a.icon-edit\", function() {\n toggleView();\n $el.find(\"input\").focus();\n return $el.find(\"input\").val($scope.role.name);\n });\n $el.on(\"click\", \"a.save\", submit);\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return submit();\n } else if (event.keyCode === 27) {\n return toggleView();\n }\n });\n $scope.$on(\"role:changed\", function() {\n if ($el.find('.edit-role').is(\":visible\")) {\n return toggleView();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgEditRole\", [\"$tgRepo\", \"$tgConfirm\", EditRoleDirective]);\n\n RolesDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRoles\", RolesDirective);\n\n NewRoleDirective = function($tgrepo, $confirm) {\n var DEFAULT_PERMISSIONS, link;\n DEFAULT_PERMISSIONS = [\"view_project\", \"view_milestones\", \"view_us\", \"view_tasks\", \"view_issues\"];\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $el.on(\"click\", \"a.add-button\", function(event) {\n event.preventDefault();\n $el.find(\".new\").removeClass(\"hidden\");\n $el.find(\".new\").focus();\n return $el.find(\".add-button\").hide();\n });\n return $el.on(\"keyup\", \".new\", function(event) {\n var newRole, onError, onSuccess, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newRole = {\n project: $scope.projectId,\n name: target.val(),\n permissions: DEFAULT_PERMISSIONS,\n order: _.max($scope.roles, function(r) {\n return r.order;\n }).order + 1,\n computable: false\n };\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new\").val('');\n onSuccess = function(role) {\n var insertPosition;\n insertPosition = $scope.roles.length - 1;\n $scope.roles.splice(insertPosition, 0, role);\n $ctrl.setRole(role);\n $el.find(\".add-button\").show();\n return $ctrl.loadProject();\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n return $tgrepo.create(\"roles\", newRole).then(onSuccess, onError);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new\").val('');\n return $el.find(\".add-button\").show();\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNewRole\", [\"$tgRepo\", \"$tgConfirm\", NewRoleDirective]);\n\n RolePermissionsDirective = function($rootscope, $repo, $confirm, $compile) {\n var baseTemplate, categoryTemplate, link, resumeTemplate;\n resumeTemplate = _.template(\"
\\\">
\\n
\\n
<%- category.activePermissions %>/<%- category.permissions.length %>
\\n <% _.each(category.permissions, function(permission) { %>\\n
active<% } %>\\\"\\n title=\\\"{{ '<%- permission.name %>' | translate }}\\\">
\\n <% }) %>\\n
\\n
\");\n categoryTemplate = _.template(\"
\\\">\\n
\\n
\\n
\\n
\\n <% _.each(category.permissions, function(permission) { %>\\n
\\\">\\n \\\">\\n
\\n disabled=\\\"disabled\\\" <% } %>\\n <% if(permission.active) { %> checked=\\\"checked\\\" <% } %>/>\\n
\\n \\n \\n
\\n
\\n <% }) %>\\n
\\n
\\n
\");\n baseTemplate = _.template(\"
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, generateCategoriesFromRole, renderCategory, renderPermissions, renderResume;\n $ctrl = $el.controller();\n generateCategoriesFromRole = function(role) {\n var categories, isPermissionEditable, issuePermissions, milestonePermissions, setActivePermissions, setActivePermissionsPerCategory, taskPermissions, userStoryPermissions, wikiPermissions;\n setActivePermissions = function(permissions) {\n return _.map(permissions, function(x) {\n var ref;\n return _.extend({}, x, {\n active: (ref = x[\"key\"], indexOf.call(role.permissions, ref) >= 0)\n });\n });\n };\n isPermissionEditable = function(permission, role, project) {\n if (role.external_user && !project.is_private && permission.key.indexOf(\"view_\") === 0) {\n return false;\n } else {\n return true;\n }\n };\n setActivePermissionsPerCategory = function(category) {\n return _.map(category, function(cat) {\n cat.permissions = cat.permissions.map(function(permission) {\n permission.editable = isPermissionEditable(permission, role, $scope.project);\n return permission;\n });\n return _.extend({}, cat, {\n activePermissions: _.filter(cat[\"permissions\"], \"active\").length\n });\n });\n };\n categories = [];\n milestonePermissions = [\n {\n key: \"view_milestones\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.VIEW_SPRINTS\"\n }, {\n key: \"add_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.ADD_SPRINTS\"\n }, {\n key: \"modify_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.MODIFY_SPRINTS\"\n }, {\n key: \"delete_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.DELETE_SPRINTS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.NAME\",\n permissions: setActivePermissions(milestonePermissions)\n });\n userStoryPermissions = [\n {\n key: \"view_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.VIEW_USER_STORIES\"\n }, {\n key: \"add_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.ADD_USER_STORIES\"\n }, {\n key: \"modify_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.MODIFY_USER_STORIES\"\n }, {\n key: \"delete_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.DELETE_USER_STORIES\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.NAME\",\n permissions: setActivePermissions(userStoryPermissions)\n });\n taskPermissions = [\n {\n key: \"view_tasks\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.VIEW_TASKS\"\n }, {\n key: \"add_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.ADD_TASKS\"\n }, {\n key: \"modify_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.MODIFY_TASKS\"\n }, {\n key: \"delete_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.DELETE_TASKS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.NAME\",\n permissions: setActivePermissions(taskPermissions)\n });\n issuePermissions = [\n {\n key: \"view_issues\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.VIEW_ISSUES\"\n }, {\n key: \"add_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.ADD_ISSUES\"\n }, {\n key: \"modify_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.MODIFY_ISSUES\"\n }, {\n key: \"delete_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.DELETE_ISSUES\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.NAME\",\n permissions: setActivePermissions(issuePermissions)\n });\n wikiPermissions = [\n {\n key: \"view_wiki_pages\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_PAGES\"\n }, {\n key: \"add_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_PAGES\"\n }, {\n key: \"modify_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.MODIFY_WIKI_PAGES\"\n }, {\n key: \"delete_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_PAGES\"\n }, {\n key: \"view_wiki_links\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_LINKS\"\n }, {\n key: \"add_wiki_link\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_LINKS\"\n }, {\n key: \"delete_wiki_link\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_LINKS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.NAME\",\n permissions: setActivePermissions(wikiPermissions)\n });\n return setActivePermissionsPerCategory(categories);\n };\n renderResume = function(element, category) {\n return element.find(\".resume\").html($compile(resumeTemplate({\n category: category\n }))($scope));\n };\n renderCategory = function(category, index) {\n var html;\n html = categoryTemplate({\n category: category,\n index: index\n });\n html = angular.element(html);\n renderResume(html, category);\n return $compile(html)($scope);\n };\n renderPermissions = function() {\n var html;\n $el.off();\n html = baseTemplate();\n _.each(generateCategoriesFromRole($scope.role), function(category, index) {\n return html = angular.element(html).append(renderCategory(category, index));\n });\n $el.html(html);\n $el.on(\"click\", \".resume\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return target.next().toggleClass(\"open\");\n });\n return $el.on(\"change\", \".category-item input\", function(event) {\n var getActivePermissions, onError, onSuccess, target;\n getActivePermissions = function() {\n var activePermissions;\n activePermissions = _.filter($el.find(\".category-item input\"), function(t) {\n return angular.element(t).is(\":checked\");\n });\n activePermissions = _.sortBy(_.map(activePermissions, function(t) {\n var permission;\n return permission = angular.element(t).parents(\".category-item\").data(\"id\");\n }));\n if (activePermissions.length) {\n activePermissions.push(\"view_project\");\n }\n return activePermissions;\n };\n target = angular.element(event.currentTarget);\n $scope.role.permissions = getActivePermissions();\n onSuccess = function() {\n var categories, categoryId;\n categories = generateCategoriesFromRole($scope.role);\n categoryId = target.parents(\".category-config\").data(\"id\");\n renderResume(target.parents(\".category-config\"), categories[categoryId]);\n $rootscope.$broadcast(\"projects:reload\");\n $confirm.notify(\"success\");\n return $ctrl.loadProject();\n };\n onError = function() {\n $confirm.notify(\"error\");\n target.prop(\"checked\", !target.prop(\"checked\"));\n return $scope.role.permissions = getActivePermissions();\n };\n if ($scope.role.external_user) {\n $scope.project.public_permissions = $scope.role.permissions;\n $scope.project.anon_permissions = $scope.role.permissions.filter(function(permission) {\n return permission.indexOf(\"view_\") === 0;\n });\n return $repo.save($scope.project).then(onSuccess, onError);\n } else {\n return $repo.save($scope.role).then(onSuccess, onError);\n }\n });\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $scope.$on(\"role:changed\", function() {\n return renderPermissions();\n });\n return bindOnce($scope, $attrs.ngModel, renderPermissions);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRolePermissions\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$compile\", RolePermissionsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/third-parties.coffee\n */\n\n(function() {\n var BitbucketController, BitbucketWebhooksDirective, GithubController, GithubWebhooksDirective, GitlabController, GitlabWebhooksDirective, NewWebhookDirective, SelectInputText, ValidOriginIpsDirective, WebhookDirective, WebhooksController, bindMethods, debounce, mixOf, module, taiga, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindMethods = this.taiga.bindMethods;\n\n debounce = this.taiga.debounce;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaAdmin\");\n\n WebhooksController = (function(superClass) {\n extend(WebhooksController, superClass);\n\n WebhooksController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function WebhooksController(scope, repo, rs, params, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = \"ADMIN.WEBHOOKS.SECTION_NAME\";\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.WEBHOOKS.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"webhooks:reload\", this.loadWebhooks);\n }\n\n WebhooksController.prototype.loadWebhooks = function() {\n return this.rs.webhooks.list(this.scope.projectId).then((function(_this) {\n return function(webhooks) {\n return _this.scope.webhooks = webhooks;\n };\n })(this));\n };\n\n WebhooksController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n WebhooksController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadWebhooks();\n };\n })(this));\n return promise;\n };\n\n return WebhooksController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"WebhooksController\", WebhooksController);\n\n WebhookDirective = function($rs, $repo, $confirm, $loading, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var cancel, openHistory, save, showEditMode, showVisualizationMode, updateLogs, updateShowHideHistoryText, webhook;\n webhook = $scope.$eval($attrs.tgWebhook);\n updateLogs = function() {\n var prettyDate;\n prettyDate = $translate.instant(\"ADMIN.WEBHOOKS.DATE\");\n return $rs.webhooklogs.list(webhook.id).then((function(_this) {\n return function(webhooklogs) {\n var i, len, log, ref;\n for (i = 0, len = webhooklogs.length; i < len; i++) {\n log = webhooklogs[i];\n log.validStatus = (200 <= (ref = log.status) && ref < 300);\n log.prettySentHeaders = _.map(_.pairs(log.request_headers), function(arg) {\n var header, value;\n header = arg[0], value = arg[1];\n return header + \": \" + value;\n }).join(\"\\n\");\n log.prettySentData = JSON.stringify(log.request_data);\n log.prettyDate = moment(log.created).format(prettyDate);\n }\n webhook.logs_counter = webhooklogs.length;\n webhook.logs = webhooklogs;\n return updateShowHideHistoryText();\n };\n })(this));\n };\n updateShowHideHistoryText = function() {\n var historyElement, text, textElement, title;\n textElement = $el.find(\".toggle-history\");\n historyElement = textElement.parents(\".single-webhook-wrapper\").find(\".webhooks-history\");\n if (historyElement.hasClass(\"open\")) {\n text = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY\");\n title = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY_TITLE\");\n } else {\n text = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY\");\n title = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY_TITLE\");\n }\n textElement.text(text);\n return textElement.prop(\"title\", title);\n };\n showVisualizationMode = function() {\n $el.find(\".edition-mode\").addClass(\"hidden\");\n return $el.find(\".visualization-mode\").removeClass(\"hidden\");\n };\n showEditMode = function() {\n $el.find(\".visualization-mode\").addClass(\"hidden\");\n return $el.find(\".edition-mode\").removeClass(\"hidden\");\n };\n openHistory = function() {\n return $el.find(\".webhooks-history\").addClass(\"open\");\n };\n cancel = function() {\n showVisualizationMode();\n return $scope.$apply(function() {\n return webhook.revert();\n });\n };\n save = debounce(2000, function(target) {\n var form, promise;\n form = target.parents(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n promise = $repo.save(webhook);\n promise.then((function(_this) {\n return function() {\n return showVisualizationMode();\n };\n })(this));\n return promise.then(null, function(data) {\n $confirm.notify(\"error\");\n return form.setErrors(data);\n });\n });\n $el.on(\"click\", \".test-webhook\", function() {\n openHistory();\n return $rs.webhooks.test(webhook.id).then((function(_this) {\n return function() {\n return updateLogs();\n };\n })(this));\n });\n $el.on(\"click\", \".edit-webhook\", function() {\n return showEditMode();\n });\n $el.on(\"click\", \".cancel-existing\", function() {\n return cancel();\n });\n $el.on(\"click\", \".edit-existing\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return save(target);\n });\n $el.on(\"keyup\", \".edition-mode input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n return save(target);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n return cancel(target);\n }\n });\n $el.on(\"click\", \".delete-webhook\", function() {\n var message, title;\n title = $translate.instant(\"ADMIN.WEBHOOKS.DELETE\");\n message = $translate.instant(\"ADMIN.WEBHOOKS.WEBHOOK_NAME\", {\n name: webhook.name\n });\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSucces;\n onSucces = function() {\n askResponse.finish();\n return $scope.$emit(\"webhooks:reload\");\n };\n onError = function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n };\n return $repo.remove(webhook).then(onSucces, onError);\n };\n })(this));\n });\n $el.on(\"click\", \".toggle-history\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if ((webhook.logs == null) || webhook.logs.length === 0) {\n return updateLogs().then(function() {\n return timeout(0, function() {\n $el.find(\".webhooks-history\").toggleClass(\"open\");\n return updateShowHideHistoryText();\n });\n });\n } else {\n $el.find(\".webhooks-history\").toggleClass(\"open\");\n return $scope.$apply(function() {\n return updateShowHideHistoryText();\n });\n }\n });\n $el.on(\"click\", \".history-single\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n target.toggleClass(\"history-single-open\");\n return target.siblings(\".history-single-response\").toggleClass(\"open\");\n });\n return $el.on(\"click\", \".resend-request\", function(event) {\n var log, target;\n target = angular.element(event.currentTarget);\n log = target.data(\"log\");\n return $rs.webhooklogs.resend(log).then((function(_this) {\n return function() {\n return updateLogs();\n };\n })(this));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgWebhook\", [\"$tgResources\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$translate\", WebhookDirective]);\n\n NewWebhookDirective = function($rs, $repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var addWebhookDOMNode, formDOMNode, initializeNewValue, save, webhook;\n webhook = $scope.$eval($attrs.tgWebhook);\n formDOMNode = $el.find(\".new-webhook-form\");\n addWebhookDOMNode = $el.find(\".add-webhook\");\n initializeNewValue = function() {\n return $scope.newValue = {\n \"name\": \"\",\n \"url\": \"\",\n \"key\": \"\"\n };\n };\n initializeNewValue();\n $scope.$watch(\"webhooks\", function(webhooks) {\n if (webhooks != null) {\n if (webhooks.length === 0) {\n formDOMNode.removeClass(\"hidden\");\n addWebhookDOMNode.addClass(\"hidden\");\n return formDOMNode.find(\"input\")[0].focus();\n } else {\n formDOMNode.addClass(\"hidden\");\n return addWebhookDOMNode.removeClass(\"hidden\");\n }\n }\n });\n save = debounce(2000, function() {\n var form, promise;\n form = formDOMNode.checksley();\n if (!form.validate()) {\n return;\n }\n $scope.newValue.project = $scope.project.id;\n promise = $repo.create(\"webhooks\", $scope.newValue);\n promise.then((function(_this) {\n return function() {\n $scope.$emit(\"webhooks:reload\");\n return initializeNewValue();\n };\n })(this));\n return promise.then(null, function(data) {\n $confirm.notify(\"error\");\n return form.setErrors(data);\n });\n });\n formDOMNode.on(\"click\", \".add-new\", function(event) {\n event.preventDefault();\n return save();\n });\n formDOMNode.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return save();\n }\n });\n formDOMNode.on(\"click\", \".cancel-new\", function(event) {\n return $scope.$apply(function() {\n return initializeNewValue();\n });\n });\n return addWebhookDOMNode.on(\"click\", function(event) {\n formDOMNode.removeClass(\"hidden\");\n return formDOMNode.find(\"input\")[0].focus();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNewWebhook\", [\"$tgResources\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", NewWebhookDirective]);\n\n GithubController = (function(superClass) {\n extend(GithubController, superClass);\n\n GithubController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function GithubController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.GITHUB.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.GITHUB.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n GithubController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"github\").then((function(_this) {\n return function(github) {\n return _this.scope.github = github;\n };\n })(this));\n };\n\n GithubController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n GithubController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return GithubController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"GithubController\", GithubController);\n\n GitlabController = (function(superClass) {\n extend(GitlabController, superClass);\n\n GitlabController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function GitlabController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.GITLAB.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.GITLAB.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:modules:reload\", (function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n }\n\n GitlabController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"gitlab\").then((function(_this) {\n return function(gitlab) {\n return _this.scope.gitlab = gitlab;\n };\n })(this));\n };\n\n GitlabController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n GitlabController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return GitlabController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"GitlabController\", GitlabController);\n\n BitbucketController = (function(superClass) {\n extend(BitbucketController, superClass);\n\n BitbucketController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function BitbucketController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.BITBUCKET.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.BITBUCKET.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:modules:reload\", (function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n }\n\n BitbucketController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"bitbucket\").then((function(_this) {\n return function(bitbucket) {\n return _this.scope.bitbucket = bitbucket;\n };\n })(this));\n };\n\n BitbucketController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n BitbucketController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return BitbucketController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"BitbucketController\", BitbucketController);\n\n SelectInputText = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.on(\"click\", \".select-input-content\", function() {\n $el.find(\"input\").select();\n return $el.find(\".help-copy\").addClass(\"visible\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSelectInputText\", SelectInputText);\n\n GithubWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.github, \"github\");\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgGithubWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", GithubWebhooksDirective]);\n\n GitlabWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.gitlab, \"gitlab\");\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n return $scope.$emit(\"project:modules:reload\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgGitlabWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", GitlabWebhooksDirective]);\n\n BitbucketWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.bitbucket, \"bitbucket\");\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n return $scope.$emit(\"project:modules:reload\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBitbucketWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", BitbucketWebhooksDirective]);\n\n ValidOriginIpsDirective = function() {\n var link;\n link = function($scope, $el, $attrs, $ngModel) {\n return $ngModel.$parsers.push(function(value) {\n value = $.trim(value);\n if (value === \"\") {\n return [];\n }\n return value.split(\",\");\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgValidOriginIps\", ValidOriginIpsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/attachments.coffee\n */\n\n(function() {\n var CreateProject, DeleteProjectDirective, bindOnce, debounce, module, taiga, timeout;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n timeout = this.taiga.timeout;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaProject\");\n\n CreateProject = function($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, $loading, lightboxService, $cacheFactory, $translate, currentUserService) {\n var directive, link;\n link = function($scope, $el, attrs) {\n var currentLoading, form, onErrorSubmit, onSuccessSubmit, openLightbox, submit, submitButton;\n $scope.data = {};\n $scope.templates = [];\n currentLoading = null;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n onSuccessSubmit = function(response) {\n $cacheFactory.get('$http').removeAll();\n currentLoading.finish();\n $rootscope.$broadcast(\"projects:reload\");\n $confirm.notify(\"success\", $translate.instant(\"COMMON.SAVE\"));\n $location.url($projectUrl.get(response));\n lightboxService.close($el);\n return currentUserService.loadProjects();\n };\n onErrorSubmit = function(response) {\n var error_field, error_step, i, len, ref, selectors;\n currentLoading.finish();\n form.setErrors(response);\n selectors = [];\n ref = _.keys(response);\n for (i = 0, len = ref.length; i < len; i++) {\n error_field = ref[i];\n selectors.push(\"[name=\" + error_field + \"]\");\n }\n $el.find(\".active\").removeClass(\"active\");\n error_step = $el.find(selectors.join(\",\")).first().parents(\".wizard-step\");\n error_step.addClass(\"active\");\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(error_step.data(\"step\"));\n };\n submit = (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"projects\", $scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this);\n openLightbox = function() {\n $scope.data = {};\n if (!$scope.templates.length) {\n $rs.projects.templates().then((function(_this) {\n return function(result) {\n $scope.templates = result;\n return $scope.data.creation_template = _.head(_.filter($scope.templates, function(x) {\n return x.slug === \"scrum\";\n })).id;\n };\n })(this));\n } else {\n $scope.data.creation_template = _.head(_.filter($scope.templates, function(x) {\n return x.slug === \"scrum\";\n })).id;\n }\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\".create-step1\").addClass(\"active\");\n lightboxService.open($el);\n return timeout(600, function() {\n return $el.find(\".progress-bar\").addClass('step1');\n });\n };\n $el.on(\"click\", \".button-next\", function(event) {\n var current, field, i, len, next, ref, step, valid;\n event.preventDefault();\n current = $el.find(\".active\");\n valid = true;\n ref = form.fields;\n for (i = 0, len = ref.length; i < len; i++) {\n field = ref[i];\n if (current.find(\"[name=\" + (field.element.attr('name')) + \"]\").length) {\n valid = field.validate() !== false && valid;\n }\n }\n if (!valid) {\n return;\n }\n next = current.next();\n current.toggleClass('active');\n next.toggleClass('active');\n step = next.data('step');\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(step);\n });\n $el.on(\"click\", \".button-prev\", function(event) {\n var current, prev, step;\n event.preventDefault();\n current = $el.find(\".active\");\n prev = current.prev();\n current.toggleClass('active');\n prev.toggleClass('active');\n step = prev.data('step');\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(step);\n });\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return openLightbox();\n };\n directive = {\n link: link,\n templateUrl: \"project/wizard-create-project.html\",\n scope: {}\n };\n return directive;\n };\n\n module.directive(\"tgLbCreateProject\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$location\", \"$tgNavUrls\", \"$tgResources\", \"$projectUrl\", \"$tgLoading\", \"lightboxService\", \"$cacheFactory\", \"$translate\", \"tgCurrentUserService\", CreateProject]);\n\n DeleteProjectDirective = function($repo, $rootscope, $auth, $location, $navUrls, $confirm, lightboxService, tgLoader, currentUserService) {\n var link;\n link = function($scope, $el, $attrs) {\n var projectToDelete, submit;\n projectToDelete = null;\n $scope.$on(\"deletelightbox:new\", function(ctx, project) {\n lightboxService.open($el);\n return projectToDelete = project;\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n submit = function() {\n var promise;\n tgLoader.start();\n lightboxService.close($el);\n promise = $repo.remove(projectToDelete);\n promise.then(function(data) {\n tgLoader.pageLoaded();\n $rootscope.$broadcast(\"projects:reload\");\n $location.path($navUrls.resolve(\"home\"));\n $confirm.notify(\"success\");\n return currentUserService.loadProjects();\n });\n return promise.then(null, function() {\n $confirm.notify(\"error\");\n return lightboxService.close($el);\n });\n };\n $el.on(\"click\", \".button-red\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n return $el.on(\"click\", \".button-green\", function(event) {\n event.preventDefault();\n return submit();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbDeleteProject\", [\"$tgRepo\", \"$rootScope\", \"$tgAuth\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfirm\", \"lightboxService\", \"tgLoader\", \"tgCurrentUserService\", DeleteProjectDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/bind.coffee\n */\n\n(function() {\n var BindHtmlDirective, BindOnceAltDirective, BindOnceBindDirective, BindOnceHrefDirective, BindOnceHtmlDirective, BindOnceRefDirective, BindOnceSrcDirective, BindOnceTitleDirective, BindTitleDirective, bindOnce, module;\n\n bindOnce = this.taiga.bindOnce;\n\n BindOnceBindDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoBind, function(val) {\n return $el.text(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHtml, function(val) {\n return $el.html(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceRefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoRef, function(val) {\n return $el.html(\"#\" + val + \" \");\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceSrcDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoSrc, function(val) {\n return $el.attr(\"src\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHrefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHref, function(val) {\n return $el.attr(\"href\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceAltDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoAlt, function(val) {\n return $el.attr(\"alt\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoTitle, function(val) {\n return $el.attr(\"title\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgTitleHtml, function(val) {\n if (val != null) {\n return $el.attr(\"title\", val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n BindHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgBindHtml, function(val) {\n if (val != null) {\n return $el.html(val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaBase\");\n\n module.directive(\"tgBoBind\", BindOnceBindDirective);\n\n module.directive(\"tgBoHtml\", BindOnceHtmlDirective);\n\n module.directive(\"tgBoRef\", BindOnceRefDirective);\n\n module.directive(\"tgBoSrc\", BindOnceSrcDirective);\n\n module.directive(\"tgBoHref\", BindOnceHrefDirective);\n\n module.directive(\"tgBoAlt\", BindOnceAltDirective);\n\n module.directive(\"tgBoTitle\", BindOnceTitleDirective);\n\n module.directive(\"tgBindTitle\", BindTitleDirective);\n\n module.directive(\"tgBindHtml\", BindHtmlDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/conf.coffee\n */\n\n(function() {\n var ConfigurationService, module;\n\n ConfigurationService = (function() {\n function ConfigurationService() {\n this.config = window.taigaConfig;\n }\n\n ConfigurationService.prototype.get = function(key, defaultValue) {\n if (defaultValue == null) {\n defaultValue = null;\n }\n if (_.has(this.config, key)) {\n return this.config[key];\n }\n return defaultValue;\n };\n\n return ConfigurationService;\n\n })();\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgConfig\", ConfigurationService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/contrib.coffee\n */\n\n(function() {\n var ContribController, module,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n module = angular.module(\"taigaBase\");\n\n ContribController = (function(superClass) {\n extend(ContribController, superClass);\n\n ContribController.$inject = [\"$rootScope\", \"$scope\", \"$routeParams\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\"];\n\n function ContribController(rootScope, scope, params, repo, rs, confirm) {\n var promise;\n this.rootScope = rootScope;\n this.scope = scope;\n this.params = params;\n this.repo = repo;\n this.rs = rs;\n this.confirm = confirm;\n this.scope.currentPlugin = _.first(_.where(this.rootScope.adminPlugins, {\n \"slug\": this.params.plugin\n }));\n this.scope.projectSlug = this.params.pslug;\n promise = this.loadInitialData();\n promise.then(null, (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n }\n\n ContribController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.$broadcast('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ContribController.prototype.loadInitialData = function() {\n return this.loadProject();\n };\n\n return ContribController;\n\n })(taiga.Controller);\n\n module.controller(\"ContribController\", ContribController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/filters.coffee\n */\n\n(function() {\n var FiltersStorageService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n FiltersStorageService = (function(superClass) {\n extend(FiltersStorageService, superClass);\n\n FiltersStorageService.$inject = [\"$tgStorage\", \"$routeParams\"];\n\n function FiltersStorageService(storage, params) {\n this.storage = storage;\n this.params = params;\n }\n\n FiltersStorageService.prototype.generateHash = function(components) {\n if (components == null) {\n components = [];\n }\n components = _.map(components, function(x) {\n return JSON.stringify(x);\n });\n return hex_sha1(components.join(\":\"));\n };\n\n return FiltersStorageService;\n\n })(taiga.Service);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var HttpService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n HttpService = (function(superClass) {\n extend(HttpService, superClass);\n\n HttpService.$inject = [\"$http\", \"$q\", \"$tgStorage\", \"$rootScope\", \"$cacheFactory\", \"$translate\"];\n\n function HttpService(http, q, storage, rootScope, cacheFactory, translate) {\n this.http = http;\n this.q = q;\n this.storage = storage;\n this.rootScope = rootScope;\n this.cacheFactory = cacheFactory;\n this.translate = translate;\n HttpService.__super__.constructor.call(this);\n this.cache = this.cacheFactory(\"httpget\");\n }\n\n HttpService.prototype.headers = function() {\n var headers, lang, token;\n headers = {};\n token = this.storage.get('token');\n if (token) {\n headers[\"Authorization\"] = \"Bearer \" + token;\n }\n lang = this.translate.preferredLanguage();\n if (lang) {\n headers[\"Accept-Language\"] = lang;\n }\n return headers;\n };\n\n HttpService.prototype.request = function(options) {\n options.headers = _.merge({}, options.headers || {}, this.headers());\n return this.http(options);\n };\n\n HttpService.prototype.get = function(url, params, options) {\n options = _.merge({\n method: \"GET\",\n url: url\n }, options);\n if (params) {\n options.params = params;\n }\n options.cache = this.cache;\n return this.request(options)[\"finally\"]((function(_this) {\n return function(data) {\n return _this.cache.removeAll();\n };\n })(this));\n };\n\n HttpService.prototype.post = function(url, data, params, options) {\n options = _.merge({\n method: \"POST\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.put = function(url, data, params, options) {\n options = _.merge({\n method: \"PUT\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.patch = function(url, data, params, options) {\n options = _.merge({\n method: \"PATCH\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype[\"delete\"] = function(url, data, params, options) {\n options = _.merge({\n method: \"DELETE\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n return HttpService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgHttp\", HttpService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/location.coffee\n */\n\n(function() {\n var locationFactory, module;\n\n locationFactory = function($location, $route, $rootscope) {\n $location.noreload = function(scope) {\n var lastRoute, un;\n lastRoute = $route.current;\n un = scope.$on(\"$locationChangeSuccess\", function() {\n $route.current = lastRoute;\n return un();\n });\n return $location;\n };\n $location.isInCurrentRouteParams = function(name, value) {\n var params;\n params = $location.search() || {};\n return params[name] === value;\n };\n return $location;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgLocation\", [\"$location\", \"$route\", \"$rootScope\", locationFactory]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/model.coffee\n */\n\n(function() {\n var Model, ModelService, module, provider, taiga,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n Model = (function() {\n function Model(name, data, dataTypes) {\n this._attrs = data;\n this._name = name;\n this._dataTypes = dataTypes;\n this.setAttrs(data);\n this.initialize();\n }\n\n Model.prototype.clone = function() {\n var instance;\n instance = new Model(this._name, this._attrs, this._dataTypes);\n instance._modifiedAttrs = this._modifiedAttrs;\n instance._isModified = this._isModified;\n return instance;\n };\n\n Model.prototype.applyCasts = function() {\n var attrName, castMethod, castName, ref, results;\n ref = this._dataTypes;\n results = [];\n for (attrName in ref) {\n castName = ref[attrName];\n castMethod = service.casts[castName];\n if (!castMethod) {\n continue;\n }\n results.push(this._attrs[attrName] = castMethod(this._attrs[attrName]));\n }\n return results;\n };\n\n Model.prototype.getIdAttrName = function() {\n return \"id\";\n };\n\n Model.prototype.getName = function() {\n return this._name;\n };\n\n Model.prototype.getAttrs = function(patch) {\n if (patch == null) {\n patch = false;\n }\n if (this._attrs.version != null) {\n this._modifiedAttrs.version = this._attrs.version;\n }\n if (patch) {\n return _.extend({}, this._modifiedAttrs);\n }\n return _.extend({}, this._attrs, this._modifiedAttrs);\n };\n\n Model.prototype.setAttrs = function(attrs) {\n this._attrs = attrs;\n this._modifiedAttrs = {};\n this.applyCasts();\n return this._isModified = false;\n };\n\n Model.prototype.setAttr = function(name, value) {\n this._modifiedAttrs[name] = value;\n return this._isModified = true;\n };\n\n Model.prototype.initialize = function() {\n var getter, self, setter;\n self = this;\n getter = function(name) {\n return function() {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n return self[name];\n }\n if (indexOf.call(_.keys(self._modifiedAttrs), name) < 0) {\n return self._attrs[name];\n }\n return self._modifiedAttrs[name];\n };\n };\n setter = function(name) {\n return function(value) {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n self[name] = value;\n return;\n }\n if (self._attrs[name] !== value) {\n self._modifiedAttrs[name] = value;\n self._isModified = true;\n } else {\n delete self._modifiedAttrs[name];\n }\n };\n };\n return _.each(this._attrs, function(value, name) {\n var options;\n options = {\n get: getter(name),\n set: setter(name),\n enumerable: true,\n configurable: true\n };\n return Object.defineProperty(self, name, options);\n });\n };\n\n Model.prototype.serialize = function() {\n var data;\n data = {\n \"data\": _.clone(this._attrs),\n \"name\": this._name\n };\n return JSON.stringify(data);\n };\n\n Model.prototype.isModified = function() {\n return this._isModified;\n };\n\n Model.prototype.isAttributeModified = function(attribute) {\n return this._modifiedAttrs[attribute] != null;\n };\n\n Model.prototype.markSaved = function() {\n this._isModified = false;\n this._attrs = this.getAttrs();\n return this._modifiedAttrs = {};\n };\n\n Model.prototype.revert = function() {\n this._modifiedAttrs = {};\n return this._isModified = false;\n };\n\n Model.desSerialize = function(sdata) {\n var ddata, model;\n ddata = JSON.parse(sdata);\n model = new Model(ddata.url, ddata.data);\n return model;\n };\n\n return Model;\n\n })();\n\n taiga = this.taiga;\n\n ModelService = (function(superClass) {\n extend(ModelService, superClass);\n\n ModelService.$inject = [\"$q\", \"$tgUrls\", \"$tgStorage\", \"$tgHttp\"];\n\n function ModelService(q, urls, storage, http) {\n this.q = q;\n this.urls = urls;\n this.storage = storage;\n this.http = http;\n ModelService.__super__.constructor.call(this);\n }\n\n return ModelService;\n\n })(taiga.Service);\n\n provider = function($q, $http, $gmUrls, $gmStorage) {\n var service;\n service = {};\n service.make_model = function(name, data, cls, dataTypes) {\n if (cls == null) {\n cls = Model;\n }\n if (dataTypes == null) {\n dataTypes = {};\n }\n return new cls(name, data, dataTypes);\n };\n service.cls = Model;\n service.casts = {\n int: function(value) {\n return parseInt(value, 10);\n },\n float: function(value) {\n return parseFloat(value, 10);\n }\n };\n return service;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgModel\", [\"$q\", \"$http\", \"$tgUrls\", \"$tgStorage\", provider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/navurl.coffee\n */\n\n(function() {\n var NavigationUrlsDirective, NavigationUrlsService, bindOnce, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\");\n\n NavigationUrlsService = (function(superClass) {\n extend(NavigationUrlsService, superClass);\n\n function NavigationUrlsService() {\n this.urls = {};\n }\n\n NavigationUrlsService.prototype.update = function(urls) {\n return this.urls = _.merge({}, this.urls, urls || {});\n };\n\n NavigationUrlsService.prototype.formatUrl = function(url, ctx) {\n var replacer;\n if (ctx == null) {\n ctx = {};\n }\n replacer = function(match) {\n match = trim(match, \":\");\n return ctx[match] || \"undefined\";\n };\n return url.replace(/(:\\w+)/g, replacer);\n };\n\n NavigationUrlsService.prototype.resolve = function(name, ctx) {\n var url;\n url = this.urls[name];\n if (!url) {\n return \"\";\n }\n if (ctx) {\n return this.formatUrl(url, ctx);\n }\n return url;\n };\n\n return NavigationUrlsService;\n\n })(taiga.Service);\n\n module.service(\"$tgNavUrls\", NavigationUrlsService);\n\n NavigationUrlsDirective = function($navurls, $auth, $q, $location) {\n var bindOnceP, link, parseNav;\n bindOnceP = function($scope, attr) {\n var defered;\n defered = $q.defer();\n bindOnce($scope, attr, function(v) {\n return defered.resolve(v);\n });\n return defered.promise;\n };\n parseNav = function(data, $scope) {\n var index, name, obj, params, promises, ref, result, values;\n ref = _.map(data.split(\":\"), trim), name = ref[0], params = ref[1];\n if (params) {\n result = params.split(/(\\w+)=/);\n result = _.filter(result, function(str) {\n return str.length;\n });\n result = _.map(result, function(str) {\n return trim(str.replace(/,$/g, ''));\n });\n params = [];\n index = 0;\n while (index < result.length) {\n obj = {};\n obj[result[index]] = result[index + 1];\n params.push(obj);\n index = index + 2;\n }\n } else {\n params = [];\n }\n values = _.map(params, function(param) {\n return _.values(param)[0];\n });\n promises = _.map(values, function(x) {\n return bindOnceP($scope, x);\n });\n return $q.all(promises).then(function() {\n var i, key, len, options, param, value;\n options = {};\n for (i = 0, len = params.length; i < len; i++) {\n param = params[i];\n key = Object.keys(param)[0];\n value = param[key];\n options[key] = $scope.$eval(value);\n }\n return [name, options];\n });\n };\n link = function($scope, $el, $attrs) {\n if ($el.is(\"a\")) {\n $el.attr(\"href\", \"#\");\n }\n $el.on(\"mouseenter\", function(event) {\n var target;\n target = $(event.currentTarget);\n if (!target.data(\"fullUrl\") || $attrs.tgNavGetParams !== target.data(\"params\")) {\n return parseNav($attrs.tgNav, $scope).then(function(result) {\n var fullUrl, getURLParams, getURLParamsStr, name, options, url, user;\n name = result[0], options = result[1];\n user = $auth.getUser();\n if (user) {\n options.user = user.username;\n }\n url = $navurls.resolve(name);\n fullUrl = $navurls.formatUrl(url, options);\n if ($attrs.tgNavGetParams) {\n getURLParams = JSON.parse($attrs.tgNavGetParams);\n getURLParamsStr = $.param(getURLParams);\n fullUrl = fullUrl + \"?\" + getURLParamsStr;\n target.data(\"params\", $attrs.tgNavGetParams);\n }\n target.data(\"fullUrl\", fullUrl);\n if (target.is(\"a\")) {\n target.attr(\"href\", fullUrl);\n }\n return $el.on(\"click\", function(event) {\n if (event.metaKey || event.ctrlKey) {\n return;\n }\n event.preventDefault();\n target = $(event.currentTarget);\n if (target.hasClass('noclick')) {\n return;\n }\n fullUrl = target.data(\"fullUrl\");\n switch (event.which) {\n case 1:\n $location.url(fullUrl);\n return $scope.$apply();\n case 2:\n return window.open(fullUrl);\n }\n });\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNav\", [\"$tgNavUrls\", \"$tgAuth\", \"$q\", \"$tgLocation\", NavigationUrlsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/repository.coffee\n */\n\n(function() {\n var RepositoryService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n RepositoryService = (function(superClass) {\n extend(RepositoryService, superClass);\n\n RepositoryService.$inject = [\"$q\", \"$tgModel\", \"$tgStorage\", \"$tgHttp\", \"$tgUrls\"];\n\n function RepositoryService(q, model1, storage, http, urls) {\n this.q = q;\n this.model = model1;\n this.storage = storage;\n this.http = http;\n this.urls = urls;\n RepositoryService.__super__.constructor.call(this);\n }\n\n RepositoryService.prototype.resolveUrlForModel = function(model) {\n var idAttrName;\n idAttrName = model.getIdAttrName();\n return (this.urls.resolve(model.getName())) + \"/\" + model[idAttrName];\n };\n\n RepositoryService.prototype.resolveUrlForAttributeModel = function(model) {\n return this.urls.resolve(model.getName(), model.parent);\n };\n\n RepositoryService.prototype.create = function(name, data, dataTypes, extraParams) {\n var defered, promise, url;\n if (dataTypes == null) {\n dataTypes = {};\n }\n if (extraParams == null) {\n extraParams = {};\n }\n defered = this.q.defer();\n url = this.urls.resolve(name);\n promise = this.http.post(url, JSON.stringify(data));\n promise.success((function(_this) {\n return function(_data, _status) {\n return defered.resolve(_this.model.make_model(name, _data, null, dataTypes));\n };\n })(this));\n promise.error((function(_this) {\n return function(data, status) {\n return defered.reject(data);\n };\n })(this));\n return defered.promise;\n };\n\n RepositoryService.prototype.remove = function(model, params) {\n var defered, promise, url;\n if (params == null) {\n params = {};\n }\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http[\"delete\"](url, {}, params);\n promise.success(function(data, status) {\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(model);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAll = function(models, patch) {\n var promises;\n if (patch == null) {\n patch = true;\n }\n promises = _.map(models, (function(_this) {\n return function(x) {\n return _this.save(x, true);\n };\n })(this));\n return this.q.all(promises);\n };\n\n RepositoryService.prototype.save = function(model, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForModel(model);\n data = JSON.stringify(model.getAttrs(patch));\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAttribute = function(model, attribute, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForAttributeModel(model);\n data = {};\n data[attribute] = model.getAttrs();\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.refresh = function(model) {\n var defered, promise, url;\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http.get(url);\n promise.success(function(data, status) {\n model._modifiedAttrs = {};\n model._attrs = data;\n model._isModified = false;\n model.applyCasts();\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.queryMany = function(name, params, options, headers) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n if (headers == null) {\n headers = false;\n }\n url = this.urls.resolve(name);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var result;\n result = _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n if (headers) {\n return [result, data.headers];\n }\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneAttribute = function(name, id, attribute, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name, id);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var model;\n model = _this.model.make_model(name, data.data[attribute]);\n model.parent = id;\n return model;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOne = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return _this.model.make_model(name, data.data);\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneRaw = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = _.merge({\n headers: {}\n }, options);\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryPaginated = function(name, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n httpOptions = _.merge({\n headers: {}\n }, options);\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var headers, result;\n headers = data.headers();\n result = {};\n result.models = _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n result.count = parseInt(headers[\"x-pagination-count\"], 10);\n result.current = parseInt(headers[\"x-pagination-current\"] || 1, 10);\n result.paginatedBy = parseInt(headers[\"x-paginated-by\"], 10);\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOnePaginatedRaw = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = _.merge({\n headers: {}\n }, options);\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var headers, result;\n headers = data.headers();\n result = {};\n result.data = data.data;\n result.count = parseInt(headers[\"x-pagination-count\"], 10);\n result.current = parseInt(headers[\"x-pagination-current\"] || 1, 10);\n result.paginatedBy = parseInt(headers[\"x-paginated-by\"], 10);\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.resolve = function(options) {\n var cache, params;\n params = {};\n if (options.pslug != null) {\n params.project = options.pslug;\n }\n if (options.usref != null) {\n params.us = options.usref;\n }\n if (options.taskref != null) {\n params.task = options.taskref;\n }\n if (options.issueref != null) {\n params.issue = options.issueref;\n }\n if (options.sslug != null) {\n params.milestone = options.sslug;\n }\n if (options.wikipage != null) {\n params.wikipage = options.wikipage;\n }\n cache = !(options.wikipage || options.sslug);\n return this.queryOneRaw(\"resolver\", null, params, {\n cache: cache\n });\n };\n\n return RepositoryService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgRepo\", RepositoryService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/storage.coffee\n */\n\n(function() {\n var StorageService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n StorageService = (function(superClass) {\n extend(StorageService, superClass);\n\n StorageService.$inject = [\"$rootScope\"];\n\n function StorageService($rootScope) {\n StorageService.__super__.constructor.call(this);\n }\n\n StorageService.prototype.get = function(key, _default) {\n var serializedValue;\n serializedValue = localStorage.getItem(key);\n if (serializedValue === null) {\n return _default || null;\n }\n return JSON.parse(serializedValue);\n };\n\n StorageService.prototype.set = function(key, val) {\n if (_.isObject(key)) {\n return _.each(key, (function(_this) {\n return function(val, key) {\n return _this.set(key, val);\n };\n })(this));\n } else {\n return localStorage.setItem(key, JSON.stringify(val));\n }\n };\n\n StorageService.prototype.contains = function(key) {\n var value;\n value = this.get(key);\n return value !== null;\n };\n\n StorageService.prototype.remove = function(key) {\n return localStorage.removeItem(key);\n };\n\n StorageService.prototype.clear = function() {\n return localStorage.clear();\n };\n\n return StorageService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgStorage\", StorageService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var UrlsService, format, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n format = function(fmt, obj) {\n obj = _.clone(obj);\n return fmt.replace(/%s/g, function(match) {\n return String(obj.shift());\n });\n };\n\n taiga = this.taiga;\n\n UrlsService = (function(superClass) {\n extend(UrlsService, superClass);\n\n UrlsService.$inject = [\"$tgConfig\"];\n\n function UrlsService(config) {\n this.config = config;\n this.urls = {};\n this.mainUrl = this.config.get(\"api\");\n }\n\n UrlsService.prototype.update = function(urls) {\n return this.urls = _.merge(this.urls, urls);\n };\n\n UrlsService.prototype.resolve = function() {\n var args, name, url;\n args = _.toArray(arguments);\n if (args.length === 0) {\n throw Error(\"wrong arguments to setUrls\");\n }\n name = args.slice(0, 1)[0];\n url = format(this.urls[name], args.slice(1));\n return format(\"%s/%s\", [_.str.rtrim(this.mainUrl, \"/\"), _.str.ltrim(url, \"/\")]);\n };\n\n UrlsService.prototype.resolveAbsolute = function() {\n var url;\n url = this.resolve.apply(this, arguments);\n if (/^https?:\\/\\//i.test(url)) {\n return url;\n }\n if (/^\\//.test(url)) {\n return window.location.protocol + \"//\" + window.location.host + url;\n }\n return window.location.protocol + \"//\" + window.location.host + \"/\" + url;\n };\n\n return UrlsService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service('$tgUrls', UrlsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/custom-field-values.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo) {\n var _get, service;\n _get = function(objectId, resource) {\n return $repo.queryOne(resource, objectId);\n };\n service = {\n userstory: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/userstory\");\n }\n },\n task: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/task\");\n }\n },\n issue: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/issue\");\n }\n }\n };\n return function(instance) {\n return instance.customAttributesValues = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgCustomAttributesValuesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($repo) {\n var _list, service;\n _list = function(projectId, resource) {\n return $repo.queryMany(resource, {\n project: projectId\n });\n };\n service = {\n userstory: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/userstory\");\n }\n },\n task: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/task\");\n }\n },\n issue: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/issue\");\n }\n }\n };\n return function(instance) {\n return instance.customAttributes = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgCustomAttributesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/history.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(type, objectId) {\n return $repo.queryOneRaw(\"history/\" + type, objectId);\n };\n service.deleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = url + \"/\" + objectId + \"/delete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n service.undeleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = url + \"/\" + objectId + \"/undelete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n return function(instance) {\n return instance.history = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgHistoryResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo) {\n var service;\n service = {};\n service.get = function(token) {\n return $repo.queryOne(\"invitations\", token);\n };\n return function(instance) {\n return instance.invitations = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgInvitationsResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/issues.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage, $q) {\n var filtersHashSuffix, hashSuffix, myFiltersHashSuffix, service;\n service = {};\n hashSuffix = \"issues-queryparams\";\n filtersHashSuffix = \"issues-filters\";\n myFiltersHashSuffix = \"issues-my-filters\";\n service.get = function(projectId, issueId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"issues\", issueId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"issues\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"issues\", filters);\n };\n service.list = function(projectId, filters, options) {\n var params;\n params = {\n project: projectId\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryPaginated(\"issues\", params, options);\n };\n service.bulkCreate = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-create-issues\");\n params = {\n project_id: projectId,\n bulk_issues: data\n };\n return $http.post(url, params);\n };\n service.upvote = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-upvote\", issueId);\n return $http.post(url);\n };\n service.downvote = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-downvote\", issueId);\n return $http.post(url);\n };\n service.watch = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-watch\", issueId);\n return $http.post(url);\n };\n service.unwatch = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-unwatch\", issueId);\n return $http.post(url);\n };\n service.stats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/issues_stats\");\n };\n service.filtersData = function(params) {\n return $repo.queryOneRaw(\"issues-filters\", null, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeFilters = function(projectSlug, params) {\n var hash, ns;\n ns = projectSlug + \":\" + filtersHashSuffix;\n hash = generateHash([projectSlug, ns]);\n return $storage.set(hash, params);\n };\n service.getFilters = function(projectSlug) {\n var hash, ns;\n ns = projectSlug + \":\" + filtersHashSuffix;\n hash = generateHash([projectSlug, ns]);\n return $storage.get(hash) || {};\n };\n service.storeMyFilters = function(projectId, myFilters) {\n var deferred, hash, ns, promise, url;\n deferred = $q.defer();\n url = $urls.resolve(\"user-storage\");\n ns = projectId + \":\" + myFiltersHashSuffix;\n hash = generateHash([projectId, ns]);\n if (_.isEmpty(myFilters)) {\n promise = $http[\"delete\"](url + \"/\" + hash, {\n key: hash,\n value: myFilters\n });\n promise.then(function() {\n return deferred.resolve();\n });\n promise.then(null, function() {\n return deferred.reject();\n });\n } else {\n promise = $http.put(url + \"/\" + hash, {\n key: hash,\n value: myFilters\n });\n promise.then(function(data) {\n return deferred.resolve();\n });\n promise.then(null, function(data) {\n var innerPromise;\n innerPromise = $http.post(\"\" + url, {\n key: hash,\n value: myFilters\n });\n innerPromise.then(function() {\n return deferred.resolve();\n });\n return innerPromise.then(null, function() {\n return deferred.reject();\n });\n });\n }\n return deferred.promise;\n };\n service.getMyFilters = function(projectId) {\n var deferred, hash, ns, promise, url;\n deferred = $q.defer();\n url = $urls.resolve(\"user-storage\");\n ns = projectId + \":\" + myFiltersHashSuffix;\n hash = generateHash([projectId, ns]);\n promise = $http.get(url + \"/\" + hash);\n promise.then(function(data) {\n return deferred.resolve(data.data.value);\n });\n promise.then(null, function(data) {\n return deferred.resolve({});\n });\n return deferred.promise;\n };\n return function(instance) {\n return instance.issues = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgIssuesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/kanban.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($storage) {\n var hashSuffixStatusColumnModes, hashSuffixStatusViewModes, service;\n service = {};\n hashSuffixStatusViewModes = \"kanban-statusviewmodels\";\n hashSuffixStatusColumnModes = \"kanban-statuscolumnmodels\";\n service.storeStatusViewModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusViewModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusViewModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusViewModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeStatusColumnModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusColumnModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n return function(instance) {\n return instance.kanban = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgKanbanResourcesProvider\", [\"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/locales.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($repo) {\n var service;\n service = {\n list: function() {\n return $repo.queryMany(\"locales\");\n }\n };\n return function(instance) {\n return instance.locales = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgLocalesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/mdrender.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.render = function(projectId, content) {\n var params, url;\n if ((content == null) || content === \"\") {\n content = ' ';\n }\n params = {\n project_id: projectId,\n content: content\n };\n url = $urls.resolve(\"wiki\");\n return $http.post(url + \"/render\", params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n return function(instance) {\n return instance.mdrender = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgMdRenderResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"memberships\", id);\n };\n service.list = function(projectId, filters, enablePagination) {\n var options, params;\n if (enablePagination == null) {\n enablePagination = true;\n }\n params = {\n project: projectId\n };\n params = _.extend({}, params, filters || {});\n if (enablePagination) {\n return $repo.queryPaginated(\"memberships\", params);\n }\n return $repo.queryMany(\"memberships\", params, options = {\n enablePagination: enablePagination\n });\n };\n service.listByUser = function(userId, filters) {\n var params;\n params = {\n user: userId\n };\n params = _.extend({}, params, filters || {});\n return $repo.queryPaginated(\"memberships\", params);\n };\n service.resendInvitation = function(id) {\n var url;\n url = $urls.resolve(\"memberships\");\n return $http.post(url + \"/\" + id + \"/resend_invitation\", {});\n };\n service.bulkCreateMemberships = function(projectId, data, invitation_extra_text) {\n var params, url;\n url = $urls.resolve(\"bulk-create-memberships\");\n params = {\n project_id: projectId,\n bulk_memberships: data,\n invitation_extra_text: invitation_extra_text\n };\n return $http.post(url, params);\n };\n return function(instance) {\n return instance.memberships = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgMembershipsResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo) {\n var service;\n service = {};\n service.list = function(projectId, module) {\n return $repo.queryOneAttribute(\"project-modules\", projectId, module);\n };\n return function(instance) {\n return instance.modules = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgModulesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"notify-policies\", id);\n };\n service.list = function(filters) {\n var params;\n params = _.extend({}, params, filters || {});\n return $repo.queryMany(\"notify-policies\", params);\n };\n return function(instance) {\n return instance.notifyPolicies = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgNotifyPoliciesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($config, $repo, $http, $urls, $auth, $q, $translate) {\n var service;\n service = {};\n service.get = function(projectId) {\n return $repo.queryOne(\"projects\", projectId);\n };\n service.getBySlug = function(projectSlug) {\n return $repo.queryOne(\"projects\", \"by_slug?slug=\" + projectSlug);\n };\n service.list = function() {\n return $repo.queryMany(\"projects\");\n };\n service.listByMember = function(memberId) {\n var params;\n params = {\n \"member\": memberId,\n \"order_by\": \"memberships__user_order\"\n };\n return $repo.queryMany(\"projects\", params);\n };\n service.templates = function() {\n return $repo.queryMany(\"project-templates\");\n };\n service.usersList = function(projectId) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(\"users\", params);\n };\n service.rolesList = function(projectId) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(\"roles\", params);\n };\n service.stats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/stats\");\n };\n service.bulkUpdateOrder = function(bulkData) {\n var url;\n url = $urls.resolve(\"bulk-update-projects-order\");\n return $http.post(url, bulkData);\n };\n service.regenerate_userstories_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_userstories_csv_uuid\";\n return $http.post(url);\n };\n service.regenerate_issues_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_issues_csv_uuid\";\n return $http.post(url);\n };\n service.regenerate_tasks_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_tasks_csv_uuid\";\n return $http.post(url);\n };\n service.leave = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/leave\";\n return $http.post(url);\n };\n service.memberStats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/member_stats\");\n };\n service.tagsColors = function(projectId) {\n return $repo.queryOne(\"projects\", projectId + \"/tags_colors\");\n };\n service[\"export\"] = function(projectId) {\n var url;\n url = ($urls.resolve(\"exporter\")) + \"/\" + projectId;\n return $http.get(url);\n };\n service[\"import\"] = function(file, statusUpdater) {\n var complete, data, defered, errorMsg, failed, maxFileSize, response, uploadComplete, uploadFailed, uploadProgress, xhr;\n defered = $q.defer();\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_MAX_SIZE_EXCEEDED\", {\n fileName: file.name,\n fileSize: sizeFormat(file.size),\n maxFileSize: sizeFormat(maxFileSize)\n });\n response = {\n status: 413,\n data: {\n _error_message: errorMsg\n }\n };\n defered.reject(response);\n return defered.promise;\n }\n uploadProgress = (function(_this) {\n return function(evt) {\n var message, percent;\n percent = Math.round((evt.loaded / evt.total) * 100);\n message = $translate.instant(\"PROJECT.IMPORT.UPLOAD_IN_PROGRESS_MESSAGE\", {\n uploadedSize: sizeFormat(evt.loaded),\n totalSize: sizeFormat(evt.total)\n });\n return statusUpdater(\"in-progress\", null, message, percent);\n };\n })(this);\n uploadComplete = (function(_this) {\n return function(evt) {\n return statusUpdater(\"done\", $translate.instant(\"PROJECT.IMPORT.TITLE\"), $translate.instant(\"PROJECT.IMPORT.DESCRIPTION\"));\n };\n })(this);\n uploadFailed = (function(_this) {\n return function(evt) {\n return statusUpdater(\"error\");\n };\n })(this);\n complete = (function(_this) {\n return function(evt) {\n var error, ref;\n response = {};\n try {\n response.data = JSON.parse(evt.target.responseText);\n } catch (error) {\n response.data = {};\n }\n response.status = evt.target.status;\n if ((ref = response.status) === 201 || ref === 202) {\n defered.resolve(response);\n }\n return defered.reject(response);\n };\n })(this);\n failed = (function(_this) {\n return function(evt) {\n return defered.reject(\"fail\");\n };\n })(this);\n data = new FormData();\n data.append('dump', file);\n xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.upload.addEventListener(\"load\", uploadComplete, false);\n xhr.upload.addEventListener(\"error\", uploadFailed, false);\n xhr.upload.addEventListener(\"abort\", uploadFailed, false);\n xhr.addEventListener(\"load\", complete, false);\n xhr.addEventListener(\"error\", failed, false);\n xhr.open(\"POST\", $urls.resolve(\"importer\"));\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + ($auth.getToken()));\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send(data);\n return defered.promise;\n };\n service.changeLogo = function(projectId, file) {\n var data, defered, maxFileSize, options, response, url;\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered = $q.defer();\n defered.reject(response);\n return defered.promise;\n }\n data = new FormData();\n data.append('logo', file);\n options = {\n transformRequest: angular.identity,\n headers: {\n 'Content-Type': void 0\n }\n };\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/change_logo\";\n return $http.post(url, data, {}, options);\n };\n service.removeLogo = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/remove_logo\";\n return $http.post(url);\n };\n return function(instance) {\n return instance.projects = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgProjectsResourcesProvider\", [\"$tgConfig\", \"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgAuth\", \"$q\", \"$translate\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"roles\", id);\n };\n service.list = function(projectId) {\n return $repo.queryMany(\"roles\", {\n project: projectId\n });\n };\n return function(instance) {\n return instance.roles = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgRolesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/search.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $urls, $http, $q) {\n var service;\n service = {};\n service[\"do\"] = function(projectId, term) {\n var deferredAbort, params, request, url;\n deferredAbort = $q.defer();\n url = $urls.resolve(\"search\");\n params = {\n url: url,\n method: \"GET\",\n timeout: deferredAbort.promise,\n cancelable: true,\n params: {\n project: projectId,\n text: term,\n get_all: false\n }\n };\n request = $http.request(params).then(function(data) {\n return data.data;\n });\n request.abort = function() {\n return deferredAbort.resolve();\n };\n request[\"finally\"] = function() {\n request.abort = angular.noop;\n return deferredAbort = request = null;\n };\n return request;\n };\n return function(instance) {\n return instance.search = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgSearchResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/sprints.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $model, $storage) {\n var service;\n service = {};\n service.get = function(projectId, sprintId) {\n return $repo.queryOne(\"milestones\", sprintId).then(function(sprint) {\n var uses;\n uses = sprint.user_stories;\n uses = _.map(uses, function(u) {\n return $model.make_model(\"userstories\", u);\n });\n sprint._attrs.user_stories = uses;\n return sprint;\n });\n };\n service.stats = function(projectId, sprintId) {\n return $repo.queryOneRaw(\"milestones\", sprintId + \"/stats\");\n };\n service.list = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId\n };\n params = _.extend({}, params, filters || {});\n return $repo.queryMany(\"milestones\", params, {}, true).then((function(_this) {\n return function(result) {\n var headers, i, len, m, milestones, uses;\n milestones = result[0];\n headers = result[1];\n for (i = 0, len = milestones.length; i < len; i++) {\n m = milestones[i];\n uses = m.user_stories;\n uses = _.map(uses, function(u) {\n return $model.make_model(\"userstories\", u);\n });\n m._attrs.user_stories = uses;\n }\n return {\n milestones: milestones,\n closed: parseInt(headers(\"Taiga-Info-Total-Closed-Milestones\"), 10),\n open: parseInt(headers(\"Taiga-Info-Total-Opened-Milestones\"), 10)\n };\n };\n })(this));\n };\n return function(instance) {\n return instance.sprints = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgSprintsResourcesProvider\", [\"$tgRepo\", \"$tgModel\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/tasks.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage) {\n var hashSuffix, hashSuffixStatusColumnModes, hashSuffixUsRowModes, service;\n service = {};\n hashSuffix = \"tasks-queryparams\";\n hashSuffixStatusColumnModes = \"tasks-statuscolumnmodels\";\n hashSuffixUsRowModes = \"tasks-usrowmodels\";\n service.get = function(projectId, taskId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"tasks\", taskId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"tasks\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"tasks\", filters);\n };\n service.list = function(projectId, sprintId, userStoryId) {\n var params;\n if (sprintId == null) {\n sprintId = null;\n }\n if (userStoryId == null) {\n userStoryId = null;\n }\n params = {\n project: projectId\n };\n if (sprintId) {\n params.milestone = sprintId;\n }\n if (userStoryId) {\n params.user_story = userStoryId;\n }\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"tasks\", params);\n };\n service.bulkCreate = function(projectId, sprintId, usId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-create-tasks\");\n params = {\n project_id: projectId,\n sprint_id: sprintId,\n us_id: usId,\n bulk_tasks: data\n };\n return $http.post(url, params).then(function(result) {\n return result.data;\n });\n };\n service.upvote = function(taskId) {\n var url;\n url = $urls.resolve(\"task-upvote\", taskId);\n return $http.post(url);\n };\n service.downvote = function(taskId) {\n var url;\n url = $urls.resolve(\"task-downvote\", taskId);\n return $http.post(url);\n };\n service.watch = function(taskId) {\n var url;\n url = $urls.resolve(\"task-watch\", taskId);\n return $http.post(url);\n };\n service.unwatch = function(taskId) {\n var url;\n url = $urls.resolve(\"task-unwatch\", taskId);\n return $http.post(url);\n };\n service.bulkUpdateTaskTaskboardOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-task-taskboard-order\");\n params = {\n project_id: projectId,\n bulk_tasks: data\n };\n return $http.post(url, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeStatusColumnModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusColumnModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeUsRowModes = function(projectId, sprintId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixUsRowModes;\n hash = generateHash([projectId, sprintId, ns]);\n return $storage.set(hash, params);\n };\n service.getUsRowModes = function(projectId, sprintId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixUsRowModes;\n hash = generateHash([projectId, sprintId, ns]);\n return $storage.get(hash) || {};\n };\n return function(instance) {\n return instance.tasks = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgTasksResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($config, $repo, $http, $urls, $q) {\n var service;\n service = {};\n service.changeAvatar = function(file) {\n var data, defered, maxFileSize, options, response, url;\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered = $q.defer();\n defered.reject(response);\n return defered.promise;\n }\n data = new FormData();\n data.append('avatar', file);\n options = {\n transformRequest: angular.identity,\n headers: {\n 'Content-Type': void 0\n }\n };\n url = ($urls.resolve(\"users\")) + \"/change_avatar\";\n return $http.post(url, data, {}, options);\n };\n service.removeAvatar = function() {\n var url;\n url = ($urls.resolve(\"users\")) + \"/remove_avatar\";\n return $http.post(url);\n };\n service.changePassword = function(currentPassword, newPassword) {\n var data, url;\n url = ($urls.resolve(\"users\")) + \"/change_password\";\n data = {\n current_password: currentPassword,\n password: newPassword\n };\n return $http.post(url, data);\n };\n return function(instance) {\n return instance.userSettings = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUserSettingsResourcesProvider\", [\"$tgConfig\", \"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/user.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($http, $urls) {\n var service;\n service = {};\n service.contacts = function(userId, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = $urls.resolve(\"user-contacts\", userId);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return $http.get(url, {}, httpOptions).then(function(result) {\n return result.data;\n });\n };\n return function(instance) {\n return instance.users = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUsersResourcesProvider\", [\"$tgHttp\", \"$tgUrls\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/userstories.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage) {\n var hashSuffix, service;\n service = {};\n hashSuffix = \"userstories-queryparams\";\n service.get = function(projectId, usId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"userstories\", usId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"userstories\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"userstories\", filters);\n };\n service.filtersData = function(params) {\n return $repo.queryOneRaw(\"userstories-filters\", null, params);\n };\n service.listUnassigned = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId,\n \"milestone\": \"null\"\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"userstories\", params);\n };\n service.listAll = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"userstories\", params);\n };\n service.bulkCreate = function(projectId, status, bulk) {\n var data, url;\n data = {\n project_id: projectId,\n status_id: status,\n bulk_stories: bulk\n };\n url = $urls.resolve(\"bulk-create-us\");\n return $http.post(url, data);\n };\n service.upvote = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-upvote\", userStoryId);\n return $http.post(url);\n };\n service.downvote = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-downvote\", userStoryId);\n return $http.post(url);\n };\n service.watch = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-watch\", userStoryId);\n return $http.post(url);\n };\n service.unwatch = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-unwatch\", userStoryId);\n return $http.post(url);\n };\n service.bulkUpdateBacklogOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-backlog-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.bulkUpdateSprintOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-sprint-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.bulkUpdateKanbanOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-kanban-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeShowTags = function(projectId, showTags) {\n var hash;\n hash = generateHash([projectId, 'showTags']);\n return $storage.set(hash, showTags);\n };\n service.getShowTags = function(projectId) {\n var hash;\n hash = generateHash([projectId, 'showTags']);\n return $storage.get(hash) || null;\n };\n return function(instance) {\n return instance.userstories = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUserstoriesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: webhooklogs.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.list = function(webhookId) {\n var params;\n params = {\n webhook: webhookId\n };\n return $repo.queryMany(\"webhooklogs\", params);\n };\n service.resend = function(webhooklogId) {\n var url;\n url = $urls.resolve(\"webhooklogs-resend\", webhooklogId);\n return $http.post(url);\n };\n return function(instance) {\n return instance.webhooklogs = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWebhookLogsResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: webhooks.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.list = function(projectId) {\n var params;\n params = {\n project: projectId\n };\n return $repo.queryMany(\"webhooks\", params);\n };\n service.test = function(webhookId) {\n var url;\n url = $urls.resolve(\"webhooks-test\", webhookId);\n return $http.post(url);\n };\n return function(instance) {\n return instance.webhooks = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWebhooksResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/wikis.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(wikiId) {\n return $repo.queryOne(\"wiki\", wikiId);\n };\n service.getBySlug = function(projectId, slug) {\n return $repo.queryOne(\"wiki\", \"by_slug?project=\" + projectId + \"&slug=\" + slug);\n };\n service.listLinks = function(projectId) {\n return $repo.queryMany(\"wiki-links\", {\n project: projectId\n });\n };\n return function(instance) {\n return instance.wiki = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWikiResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/main.coffee\n */\n\n(function() {\n var UserChangePasswordController, UserChangePasswordDirective, debounce, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaUserSettings\");\n\n UserChangePasswordController = (function(superClass) {\n extend(UserChangePasswordController, superClass);\n\n UserChangePasswordController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\", \"$translate\"];\n\n function UserChangePasswordController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, auth, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.translate = translate;\n this.scope.sectionName = this.translate.instant(\"CHANGE_PASSWORD.SECTION_NAME\");\n this.scope.user = this.auth.getUser();\n }\n\n return UserChangePasswordController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserChangePasswordController\", UserChangePasswordController);\n\n UserChangePasswordDirective = function($rs, $confirm, $loading, $translate) {\n var link;\n link = function($scope, $el, $attrs, ctrl) {\n var submit, submitButton;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if ($scope.newPassword1 !== $scope.newPassword2) {\n $confirm.notify('error', $translate.instant(\"CHANGE_PASSWORD.ERROR_PASSWORD_MATCH\"));\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $rs.userSettings.changePassword($scope.currentPassword, $scope.newPassword1);\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify('success');\n });\n return promise.then(null, function(response) {\n currentLoading.finish();\n return $confirm.notify('error', response.data._error_message);\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserChangePassword\", [\"$tgResources\", \"$tgConfirm\", \"$tgLoading\", \"$translate\", UserChangePasswordDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/lightboxes.coffee\n */\n\n(function() {\n var DeleteUserDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaUserSettings\");\n\n DeleteUserDirective = function($repo, $rootscope, $auth, $location, $navUrls, lightboxService) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n $scope.$on(\"deletelightbox:new\", function(ctx, user) {\n return lightboxService.open($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n submit = function() {\n var promise;\n promise = $repo.remove($scope.user);\n promise.then(function(data) {\n lightboxService.close($el);\n $auth.logout();\n return $location.path($navUrls.resolve(\"login\"));\n });\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n $el.on(\"click\", \".button-red\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n return $el.on(\"click\", \".button-green\", debounce(2000, function(event) {\n event.preventDefault();\n return submit();\n }));\n };\n return {\n link: link,\n templateUrl: \"user/lightbox/lightbox-delete-account.html\"\n };\n };\n\n module.directive(\"tgLbDeleteUser\", [\"$tgRepo\", \"$rootScope\", \"$tgAuth\", \"$tgLocation\", \"$tgNavUrls\", \"lightboxService\", DeleteUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/main.coffee\n */\n\n(function() {\n var TaigaAvatarModelDirective, UserAvatarDirective, UserProfileDirective, UserSettingsController, debounce, mixOf, module, sizeFormat, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n sizeFormat = this.taiga.sizeFormat;\n\n module = angular.module(\"taigaUserSettings\");\n\n debounce = this.taiga.debounce;\n\n UserSettingsController = (function(superClass) {\n extend(UserSettingsController, superClass);\n\n UserSettingsController.$inject = [\"$scope\", \"$rootScope\", \"$tgConfig\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\", \"$translate\"];\n\n function UserSettingsController(scope, rootscope, config, repo, confirm, rs, params, q, location, navUrls, auth, translate) {\n var maxFileSize, promise, text;\n this.scope = scope;\n this.rootscope = rootscope;\n this.config = config;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.translate = translate;\n this.scope.sectionName = \"USER_SETTINGS.MENU.SECTION_TITLE\";\n this.scope.project = {};\n this.scope.user = this.auth.getUser();\n if (!this.scope.user) {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n this.location.replace();\n }\n this.scope.lang = this.getLan();\n this.scope.theme = this.getTheme();\n maxFileSize = this.config.get(\"maxUploadFileSize\", null);\n if (maxFileSize) {\n text = this.translate.instant(\"USER_SETTINGS.AVATAR_MAX_SIZE\", {\n \"maxFileSize\": sizeFormat(maxFileSize)\n });\n this.scope.maxFileSizeMsg = text;\n }\n promise = this.loadInitialData();\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserSettingsController.prototype.loadInitialData = function() {\n this.scope.availableThemes = this.config.get(\"themes\", []);\n return this.rs.locales.list().then((function(_this) {\n return function(locales) {\n _this.scope.locales = locales;\n return locales;\n };\n })(this));\n };\n\n UserSettingsController.prototype.openDeleteLightbox = function() {\n return this.rootscope.$broadcast(\"deletelightbox:new\", this.scope.user);\n };\n\n UserSettingsController.prototype.getLan = function() {\n return this.scope.user.lang || this.translate.preferredLanguage();\n };\n\n UserSettingsController.prototype.getTheme = function() {\n return this.scope.user.theme || this.config.get(\"defaultTheme\") || \"taiga\";\n };\n\n return UserSettingsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserSettingsController\", UserSettingsController);\n\n UserProfileDirective = function($confirm, $auth, $repo, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var changeEmail, form, onError, onSuccess;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n changeEmail = $scope.user.isAttributeModified(\"email\");\n $scope.user.lang = $scope.lang;\n $scope.user.theme = $scope.theme;\n onSuccess = function(data) {\n var text;\n $auth.setUser(data);\n if (changeEmail) {\n text = $translate.instant(\"USER_PROFILE.CHANGE_EMAIL_SUCCESS\");\n return $confirm.success(text);\n } else {\n return $confirm.notify('success');\n }\n };\n onError = function(data) {\n form.setErrors(data);\n return $confirm.notify('error', data._error_message);\n };\n return $repo.save($scope.user).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserProfile\", [\"$tgConfirm\", \"$tgAuth\", \"$tgRepo\", \"$translate\", UserProfileDirective]);\n\n UserAvatarDirective = function($auth, $model, $rs, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var onError, onSuccess, showSizeInfo;\n showSizeInfo = function() {\n return $el.find(\".size-info\").removeClass(\"hidden\");\n };\n onSuccess = function(response) {\n var user;\n user = $model.make_model(\"users\", response.data);\n $auth.setUser(user);\n $scope.user = user;\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('success');\n };\n onError = function(response) {\n if (response.status === 413) {\n showSizeInfo();\n }\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('error', response.data._error_message);\n };\n $el.on(\"click\", \".js-change-avatar\", function() {\n return $el.find(\"#avatar-field\").click();\n });\n $el.on(\"change\", \"#avatar-field\", function(event) {\n if ($scope.avatarAttachment) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.userSettings.changeAvatar($scope.avatarAttachment).then(onSuccess, onError);\n }\n });\n $el.on(\"click\", \"a.js-use-gravatar\", function(event) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.userSettings.removeAvatar().then(onSuccess, onError);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserAvatar\", [\"$tgAuth\", \"$tgModel\", \"$tgResources\", \"$tgConfirm\", UserAvatarDirective]);\n\n TaigaAvatarModelDirective = function($parse) {\n var link;\n link = function($scope, $el, $attrs) {\n var model, modelSetter;\n model = $parse($attrs.tgAvatarModel);\n modelSetter = model.assign;\n return $el.bind('change', function() {\n return $scope.$apply(function() {\n return modelSetter($scope, $el[0].files[0]);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive('tgAvatarModel', ['$parse', TaigaAvatarModelDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/nav.coffee\n */\n\n(function() {\n var UserSettingsNavigationDirective, module;\n\n UserSettingsNavigationDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var section;\n section = $attrs.tgUserSettingsNavigation;\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\"#usersettingsmenu-\" + section + \" a\").addClass(\"active\");\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaUserSettings\");\n\n module.directive(\"tgUserSettingsNavigation\", UserSettingsNavigationDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/notifications.coffee\n */\n\n(function() {\n var UserNotificationsController, UserNotificationsDirective, UserNotificationsListDirective, bindOnce, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaUserSettings\");\n\n UserNotificationsController = (function(superClass) {\n extend(UserNotificationsController, superClass);\n\n UserNotificationsController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\"];\n\n function UserNotificationsController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, auth) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.scope.sectionName = \"USER_SETTINGS.NOTIFICATIONS.SECTION_NAME\";\n this.scope.user = this.auth.getUser();\n promise = this.loadInitialData();\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserNotificationsController.prototype.loadInitialData = function() {\n return this.rs.notifyPolicies.list().then((function(_this) {\n return function(notifyPolicies) {\n _this.scope.notifyPolicies = notifyPolicies;\n return notifyPolicies;\n };\n })(this));\n };\n\n return UserNotificationsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserNotificationsController\", UserNotificationsController);\n\n UserNotificationsDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserNotifications\", UserNotificationsDirective);\n\n UserNotificationsListDirective = function($repo, $confirm, $compile) {\n var link, template;\n template = _.template(\"<% _.each(notifyPolicies, function (notifyPolicy, index) { %>\\n
\\\">\\n
<%- notifyPolicy.project_name %>
\\n
\\n
\\n \\\" id=\\\"policy-all-<%- notifyPolicy.id %>\\\"\\n value=\\\"2\\\" <% if (notifyPolicy.notify_level == 2) { %>checked=\\\"checked\\\"<% } %>/>\\n \\n
\\n
\\n
\\n
\\n \\\" id=\\\"policy-involved-<%- notifyPolicy.id %>\\\"\\n value=\\\"1\\\" <% if (notifyPolicy.notify_level == 1) { %>checked=\\\"checked\\\"<% } %> />\\n \\n
\\n
\\n
\\n
\\n \\\" id=\\\"policy-none-<%- notifyPolicy.id %>\\\"\\n value=\\\"3\\\" <% if (notifyPolicy.notify_level == 3) { %>checked=\\\"checked\\\"<% } %> />\\n \\n
\\n
\\n
\\n<% }) %>\");\n link = function($scope, $el, $attrs) {\n var render;\n render = function() {\n var ctx, html;\n $el.off();\n ctx = {\n notifyPolicies: $scope.notifyPolicies\n };\n html = template(ctx);\n $el.html($compile(html)($scope));\n return $el.on(\"change\", \"input[type=radio]\", function(event) {\n var onError, onSuccess, policy, policyIndex, prev_level, target;\n target = angular.element(event.currentTarget);\n policyIndex = target.parents(\".policy-table-row\").data('index');\n policy = $scope.notifyPolicies[policyIndex];\n prev_level = policy.notify_level;\n policy.notify_level = parseInt(target.val(), 10);\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n return target.parents(\".policy-table-row\").find(\"input[value=\" + prev_level + \"]\").prop(\"checked\", true);\n };\n return $repo.save(policy).then(onSuccess, onError);\n });\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return bindOnce($scope, $attrs.ngModel, render);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserNotificationsList\", [\"$tgRepo\", \"$tgConfirm\", \"$compile\", UserNotificationsListDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: components.module.coffee\n */\n\n(function() {\n angular.module(\"taigaComponents\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaDiscover\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-apps.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaExternalApps\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaHome\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.module.coffee\n */\n\n(function() {\n angular.module(\"taigaNavigationBar\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaProfile\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects.module.coffee\n */\n\n(function() {\n angular.module(\"taigaProjects\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: resources.module.coffee\n */\n\n(function() {\n angular.module(\"taigaResources2\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.module.coffee\n */\n\n(function() {\n angular.module(\"taigaUserTimeline\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment-link.directive.coffee\n */\n\n(function() {\n var AttachmentLinkDirective;\n\n AttachmentLinkDirective = function($parse, lightboxFactory) {\n var link;\n link = function(scope, el, attrs) {\n var attachment;\n attachment = $parse(attrs.tgAttachmentLink)(scope);\n el.on(\"click\", function(event) {\n if (taiga.isImage(attachment.getIn(['file', 'name']))) {\n event.preventDefault();\n return scope.$apply(function() {\n return lightboxFactory.create('tg-lb-attachment-preview', {\n \"class\": 'lightbox lightbox-block'\n }, {\n file: attachment.get('file')\n });\n });\n }\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentLinkDirective.$inject = [\"$parse\", \"tgLightboxFactory\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentLink\", AttachmentLinkDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment-gallery.directive.coffee\n */\n\n(function() {\n var AttachmentGalleryDirective;\n\n AttachmentGalleryDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachment: \"=\",\n onDelete: \"&\",\n onUpdate: \"&\",\n type: \"=\"\n },\n controller: \"Attachment\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachment/attachment-gallery.html\",\n link: link\n };\n };\n\n AttachmentGalleryDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentGallery\", AttachmentGalleryDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchment.controller.coffee\n */\n\n(function() {\n var AttachmentController;\n\n AttachmentController = (function() {\n AttachmentController.$inject = ['tgAttachmentsService', '$translate'];\n\n function AttachmentController(attachmentsService, translate) {\n this.attachmentsService = attachmentsService;\n this.translate = translate;\n this.form = {};\n this.form.description = this.attachment.getIn(['file', 'description']);\n this.form.is_deprecated = this.attachment.get(['file', 'is_deprecated']);\n this.title = this.translate.instant(\"ATTACHMENT.TITLE\", {\n fileName: this.attachment.get('name'),\n date: moment(this.attachment.get('created_date')).format(this.translate.instant(\"ATTACHMENT.DATE\"))\n });\n }\n\n AttachmentController.prototype.editMode = function(mode) {\n var attachment;\n attachment = this.attachment.set('editable', mode);\n return this.onUpdate({\n attachment: attachment\n });\n };\n\n AttachmentController.prototype[\"delete\"] = function() {\n return this.onDelete({\n attachment: this.attachment\n });\n };\n\n AttachmentController.prototype.save = function() {\n var attachment;\n attachment = this.attachment.set('loading', true);\n this.onUpdate({\n attachment: attachment\n });\n attachment = this.attachment.merge({\n editable: false,\n loading: false\n });\n attachment = attachment.mergeIn(['file'], {\n description: this.form.description,\n is_deprecated: !!this.form.is_deprecated\n });\n return this.onUpdate({\n attachment: attachment\n });\n };\n\n return AttachmentController;\n\n })();\n\n angular.module('taigaComponents').controller('Attachment', AttachmentController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment.directive.coffee\n */\n\n(function() {\n var AttachmentDirective;\n\n AttachmentDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachment: \"=\",\n onDelete: \"&\",\n onUpdate: \"&\",\n type: \"=\"\n },\n controller: \"Attachment\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachment/attachment.html\",\n link: link\n };\n };\n\n AttachmentDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachment\", AttachmentDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-drop.directive.coffee\n */\n\n(function() {\n var AttachmentsDropDirective;\n\n AttachmentsDropDirective = function($parse) {\n var link;\n link = function(scope, el, attrs) {\n var eventAttr;\n eventAttr = $parse(attrs.tgAttachmentsDrop);\n el.on('dragover', function(e) {\n e.preventDefault();\n return false;\n });\n el.on('drop', function(e) {\n var dataTransfer;\n e.stopPropagation();\n e.preventDefault();\n dataTransfer = e.dataTransfer || (e.originalEvent && e.originalEvent.dataTransfer);\n return scope.$apply(function() {\n return eventAttr(scope, {\n files: dataTransfer.files\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentsDropDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsDrop\", AttachmentsDropDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-full.controller.coffee\n */\n\n(function() {\n var AttachmentsFullController, sizeFormat;\n\n sizeFormat = this.taiga.sizeFormat;\n\n AttachmentsFullController = (function() {\n AttachmentsFullController.$inject = [\"$translate\", \"$tgConfirm\", \"$tgConfig\", \"$tgStorage\", \"tgAttachmentsFullService\"];\n\n function AttachmentsFullController(translate, confirm, config, storage, attachmentsFullService) {\n this.translate = translate;\n this.confirm = confirm;\n this.config = config;\n this.storage = storage;\n this.attachmentsFullService = attachmentsFullService;\n this.mode = this.storage.get('attachment-mode', 'list');\n this.maxFileSize = this.config.get(\"maxUploadFileSize\", null);\n if (this.maxFileSize) {\n this.maxFileSize = sizeFormat(this.maxFileSize);\n }\n this.maxFileSizeMsg = this.maxFileSize ? this.translate.instant(\"ATTACHMENT.MAX_UPLOAD_SIZE\", {\n maxFileSize: this.maxFileSize\n }) : \"\";\n taiga.defineImmutableProperty(this, 'attachments', (function(_this) {\n return function() {\n return _this.attachmentsFullService.attachments;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsCount', (function(_this) {\n return function() {\n return _this.attachmentsFullService.deprecatedsCount;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'attachmentsVisible', (function(_this) {\n return function() {\n return _this.attachmentsFullService.attachmentsVisible;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsVisible', (function(_this) {\n return function() {\n return _this.attachmentsFullService.deprecatedsVisible;\n };\n })(this));\n }\n\n AttachmentsFullController.prototype.uploadingAttachments = function() {\n return this.attachmentsFullService.uploadingAttachments;\n };\n\n AttachmentsFullController.prototype.addAttachment = function(file) {\n var editable;\n editable = this.mode === 'list';\n return this.attachmentsFullService.addAttachment(this.projectId, this.objId, this.type, file, editable);\n };\n\n AttachmentsFullController.prototype.setMode = function(mode) {\n this.mode = mode;\n return this.storage.set('attachment-mode', mode);\n };\n\n AttachmentsFullController.prototype.toggleDeprecatedsVisible = function() {\n return this.attachmentsFullService.toggleDeprecatedsVisible();\n };\n\n AttachmentsFullController.prototype.addAttachments = function(files) {\n return _.forEach(files, (function(_this) {\n return function(file) {\n return _this.addAttachment(file);\n };\n })(this));\n };\n\n AttachmentsFullController.prototype.loadAttachments = function() {\n return this.attachmentsFullService.loadAttachments(this.type, this.objId, this.projectId);\n };\n\n AttachmentsFullController.prototype.deleteAttachment = function(toDeleteAttachment) {\n var message, title;\n title = this.translate.instant(\"ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT\");\n message = this.translate.instant(\"ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT\", {\n fileName: toDeleteAttachment.getIn(['file', 'name'])\n });\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onError = function() {\n message = _this.translate.instant(\"ATTACHMENT.ERROR_DELETE_ATTACHMENT\", {\n errorMessage: message\n });\n _this.confirm.notify(\"error\", null, message);\n return askResponse.finish(false);\n };\n onSuccess = function() {\n return askResponse.finish();\n };\n return _this.attachmentsFullService.deleteAttachment(toDeleteAttachment, _this.type).then(onSuccess, onError);\n };\n })(this));\n };\n\n AttachmentsFullController.prototype.reorderAttachment = function(attachment, newIndex) {\n return this.attachmentsFullService.reorderAttachment(this.type, attachment, newIndex);\n };\n\n AttachmentsFullController.prototype.updateAttachment = function(toUpdateAttachment) {\n return this.attachmentsFullService.updateAttachment(toUpdateAttachment, this.type);\n };\n\n return AttachmentsFullController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"AttachmentsFull\", AttachmentsFullController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-full.directive.coffee\n */\n\n(function() {\n var AttachmentsFullDirective, bindOnce;\n\n bindOnce = this.taiga.bindOnce;\n\n AttachmentsFullDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return bindOnce(scope, 'vm.objId', function(value) {\n return ctrl.loadAttachments();\n });\n };\n return {\n scope: {},\n bindToController: {\n type: \"@\",\n objId: \"=\",\n projectId: \"=\"\n },\n controller: \"AttachmentsFull\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachments-full/attachments-full.html\",\n link: link\n };\n };\n\n AttachmentsFullDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsFull\", AttachmentsFullDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-full.service.coffee\n */\n\n(function() {\n var AttachmentsFullService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n AttachmentsFullService = (function(superClass) {\n extend(AttachmentsFullService, superClass);\n\n AttachmentsFullService.$inject = [\"tgAttachmentsService\", \"$rootScope\"];\n\n function AttachmentsFullService(attachmentsService, rootScope) {\n this.attachmentsService = attachmentsService;\n this.rootScope = rootScope;\n this._attachments = Immutable.List();\n this._deprecatedsCount = 0;\n this._attachmentsVisible = Immutable.List();\n this._deprecatedsVisible = false;\n this.uploadingAttachments = [];\n taiga.defineImmutableProperty(this, 'attachments', (function(_this) {\n return function() {\n return _this._attachments;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsCount', (function(_this) {\n return function() {\n return _this._deprecatedsCount;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'attachmentsVisible', (function(_this) {\n return function() {\n return _this._attachmentsVisible;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsVisible', (function(_this) {\n return function() {\n return _this._deprecatedsVisible;\n };\n })(this));\n }\n\n AttachmentsFullService.prototype.toggleDeprecatedsVisible = function() {\n this._deprecatedsVisible = !this._deprecatedsVisible;\n return this.regenerate();\n };\n\n AttachmentsFullService.prototype.regenerate = function() {\n this._deprecatedsCount = this._attachments.count(function(it) {\n return it.getIn(['file', 'is_deprecated']);\n });\n if (this._deprecatedsVisible) {\n return this._attachmentsVisible = this._attachments;\n } else {\n return this._attachmentsVisible = this._attachments.filter(function(it) {\n return !it.getIn(['file', 'is_deprecated']);\n });\n }\n };\n\n AttachmentsFullService.prototype.addAttachment = function(projectId, objId, type, file, editable) {\n if (editable == null) {\n editable = true;\n }\n return new Promise((function(_this) {\n return function(resolve, reject) {\n var promise;\n if (_this.attachmentsService.validate(file)) {\n _this.uploadingAttachments.push(file);\n promise = _this.attachmentsService.upload(file, objId, projectId, type);\n return promise.then(function(file) {\n var attachment;\n _this.uploadingAttachments = _this.uploadingAttachments.filter(function(uploading) {\n return uploading.name !== file.get('name');\n });\n attachment = Immutable.Map();\n attachment = attachment.merge({\n file: file,\n editable: editable,\n loading: false\n });\n _this._attachments = _this._attachments.push(attachment);\n _this.regenerate();\n _this.rootScope.$broadcast(\"attachment:create\");\n return resolve(attachment);\n });\n } else {\n return reject(file);\n }\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.loadAttachments = function(type, objId, projectId) {\n return this.attachmentsService.list(type, objId, projectId).then((function(_this) {\n return function(files) {\n _this._attachments = files.map(function(file) {\n var attachment;\n attachment = Immutable.Map();\n return attachment.merge({\n loading: false,\n editable: false,\n file: file\n });\n });\n return _this.regenerate();\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.deleteAttachment = function(toDeleteAttachment, type) {\n var onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this._attachments = _this._attachments.filter(function(attachment) {\n return attachment !== toDeleteAttachment;\n });\n return _this.regenerate();\n };\n })(this);\n return this.attachmentsService[\"delete\"](type, toDeleteAttachment.getIn(['file', 'id'])).then(onSuccess);\n };\n\n AttachmentsFullService.prototype.reorderAttachment = function(type, attachment, newIndex) {\n var attachments, oldIndex, promises;\n oldIndex = this.attachments.findIndex(function(it) {\n return it === attachment;\n });\n if (oldIndex === newIndex) {\n return;\n }\n attachments = this.attachments.remove(oldIndex);\n attachments = attachments.splice(newIndex, 0, attachment);\n attachments = attachments.map(function(x, i) {\n return x.setIn(['file', 'order'], i + 1);\n });\n promises = [];\n attachments.forEach((function(_this) {\n return function(attachment) {\n var patch;\n patch = {\n order: attachment.getIn(['file', 'order'])\n };\n return promises.push(_this.attachmentsService.patch(attachment.getIn(['file', 'id']), type, patch));\n };\n })(this));\n return Promise.all(promises).then((function(_this) {\n return function() {\n _this._attachments = attachments;\n return _this.regenerate();\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.updateAttachment = function(toUpdateAttachment, type) {\n var index, oldAttachment, patch;\n index = this._attachments.findIndex(function(attachment) {\n return attachment.getIn(['file', 'id']) === toUpdateAttachment.getIn(['file', 'id']);\n });\n oldAttachment = this._attachments.get(index);\n patch = taiga.patch(oldAttachment.get('file'), toUpdateAttachment.get('file'));\n if (toUpdateAttachment.get('loading')) {\n this._attachments = this._attachments.set(index, toUpdateAttachment);\n return this.regenerate();\n } else {\n return this.attachmentsService.patch(toUpdateAttachment.getIn(['file', 'id']), type, patch).then((function(_this) {\n return function() {\n _this._attachments = _this._attachments.set(index, toUpdateAttachment);\n return _this.regenerate();\n };\n })(this));\n }\n };\n\n return AttachmentsFullService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgAttachmentsFullService\", AttachmentsFullService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-simple.controller.coffee\n */\n\n(function() {\n var AttachmentsSimpleController;\n\n AttachmentsSimpleController = (function() {\n AttachmentsSimpleController.$inject = [\"tgAttachmentsService\"];\n\n function AttachmentsSimpleController(attachmentsService) {\n this.attachmentsService = attachmentsService;\n }\n\n AttachmentsSimpleController.prototype.addAttachment = function(file) {\n var attachment;\n attachment = Immutable.fromJS({\n file: file,\n name: file.name,\n size: file.size\n });\n if (this.attachmentsService.validate(file)) {\n this.attachments = this.attachments.push(attachment);\n if (this.onAdd) {\n return this.onAdd({\n attachment: attachment\n });\n }\n }\n };\n\n AttachmentsSimpleController.prototype.addAttachments = function(files) {\n return _.forEach(files, this.addAttachment.bind(this));\n };\n\n AttachmentsSimpleController.prototype.deleteAttachment = function(toDeleteAttachment) {\n this.attachments = this.attachments.filter(function(attachment) {\n return attachment !== toDeleteAttachment;\n });\n if (this.onDelete) {\n return this.onDelete({\n attachment: toDeleteAttachment\n });\n }\n };\n\n return AttachmentsSimpleController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"AttachmentsSimple\", AttachmentsSimpleController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-simple.directive.coffee\n */\n\n(function() {\n var AttachmentsSimpleDirective;\n\n AttachmentsSimpleDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachments: \"=\",\n onAdd: \"&\",\n onDelete: \"&\"\n },\n controller: \"AttachmentsSimple\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachments-simple/attachments-simple.html\",\n link: link\n };\n };\n\n AttachmentsSimpleDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsSimple\", AttachmentsSimpleDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-sortable.directive.coffee\n */\n\n(function() {\n var AttachmentSortableDirective;\n\n AttachmentSortableDirective = function($parse) {\n var link;\n link = function(scope, el, attrs) {\n var callback;\n callback = $parse(attrs.tgAttachmentsSortable);\n el.sortable({\n items: \"div[tg-bind-scope]\",\n handle: \"a.settings.icon.icon-drag-v\",\n containment: \".attachments\",\n dropOnEmpty: true,\n helper: 'clone',\n scroll: false,\n tolerance: \"pointer\",\n placeholder: \"sortable-placeholder single-attachment\"\n });\n el.on(\"sortstop\", function(event, ui) {\n var attachment, newIndex;\n attachment = ui.item.scope().attachment;\n newIndex = ui.item.index();\n return scope.$apply(function() {\n return callback(scope, {\n attachment: attachment,\n index: newIndex\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentSortableDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsSortable\", AttachmentSortableDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: auto-select.directive.coffee\n */\n\n(function() {\n var AutoSelectDirective;\n\n AutoSelectDirective = function($timeout) {\n return {\n link: function(scope, elm) {\n return $timeout(function() {\n return elm[0].select();\n });\n }\n };\n };\n\n AutoSelectDirective.$inject = ['$timeout'];\n\n angular.module(\"taigaComponents\").directive(\"tgAutoSelect\", AutoSelectDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: file-change.directive.coffee\n */\n\n(function() {\n var FileChangeDirective;\n\n FileChangeDirective = function($parse) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var eventAttr;\n eventAttr = $parse(attrs.tgFileChange);\n el.on('change', function(event) {\n return scope.$apply(function() {\n return eventAttr(scope, {\n files: event.currentTarget.files\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n require: \"ngModel\",\n restrict: \"A\",\n link: link\n };\n };\n\n FileChangeDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgFileChange\", FileChangeDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: joy-ride.directive.coffee\n */\n\n(function() {\n var JoyRideDirective, taiga;\n\n taiga = this.taiga;\n\n JoyRideDirective = function($rootScope, currentUserService, joyRideService, $location, $translate) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var initJoyrRide, intro, unsuscribe;\n unsuscribe = null;\n intro = introJs();\n intro.oncomplete(function() {\n return $('html,body').scrollTop(0);\n });\n intro.onexit(function() {\n return currentUserService.disableJoyRide();\n });\n initJoyrRide = function(next, config) {\n if (!config[next.joyride]) {\n return;\n }\n intro.setOptions({\n exitOnEsc: false,\n exitOnOverlayClick: false,\n showStepNumbers: false,\n nextLabel: $translate.instant('JOYRIDE.NAV.NEXT') + ' →',\n prevLabel: '← ' + $translate.instant('JOYRIDE.NAV.BACK'),\n skipLabel: $translate.instant('JOYRIDE.NAV.SKIP'),\n doneLabel: $translate.instant('JOYRIDE.NAV.DONE'),\n disableInteraction: true\n });\n intro.setOption('steps', joyRideService.get(next.joyride));\n return intro.start();\n };\n return $rootScope.$on('$routeChangeSuccess', function(event, next) {\n if (!next.joyride || !currentUserService.isAuthenticated()) {\n intro.exit();\n if (unsuscribe) {\n unsuscribe();\n }\n return;\n }\n intro.oncomplete(function() {\n return currentUserService.disableJoyRide(next.joyride);\n });\n if (next.loader) {\n return unsuscribe = $rootScope.$on('loader:end', function() {\n currentUserService.loadJoyRideConfig().then(function(config) {\n return initJoyrRide(next, config);\n });\n return unsuscribe();\n });\n } else {\n return currentUserService.loadJoyRideConfig().then(function(config) {\n return initJoyrRide(next, config);\n });\n }\n });\n };\n return {\n scope: {},\n link: link\n };\n };\n\n JoyRideDirective.$inject = [\"$rootScope\", \"tgCurrentUserService\", \"tgJoyRideService\", \"$location\", \"$translate\"];\n\n angular.module(\"taigaComponents\").directive(\"tgJoyRide\", JoyRideDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: joy-ride.service.coffee\n */\n\n(function() {\n var JoyRideService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n JoyRideService = (function(superClass) {\n extend(JoyRideService, superClass);\n\n JoyRideService.$inject = ['$translate', 'tgCheckPermissionsService'];\n\n function JoyRideService(translate, checkPermissionsService) {\n this.translate = translate;\n this.checkPermissionsService = checkPermissionsService;\n }\n\n JoyRideService.prototype.getConfig = function() {\n return {\n dashboard: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.project-list > section:not(.ng-hide)',\n position: 'left',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP1.TITLE'),\n text: _this.translate.instant('JOYRIDE.DASHBOARD.STEP1.TEXT')\n }\n }, {\n element: '.working-on-container',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.DASHBOARD.STEP2.TEXT')\n }\n }, {\n element: '.watching-container',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TITLE'),\n text: [_this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TEXT1'), _this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TEXT2')]\n }\n }\n ];\n if (!$('.project-list .create-project-button').is(':hidden')) {\n steps.push({\n element: '.project-list .create-project-button',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TITLE'),\n text: [_this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TEXT1'), _this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TEXT2')]\n }\n });\n }\n return steps;\n };\n })(this),\n backlog: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.summary',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP1.TITLE'),\n text: [_this.translate.instant('JOYRIDE.BACKLOG.STEP1.TEXT1'), _this.translate.instant('JOYRIDE.BACKLOG.STEP1.TEXT2')]\n }\n }, {\n element: '.backlog-table-empty',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP2.TEXT')\n }\n }, {\n element: '.sprints',\n position: 'left',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP3.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP3.TEXT')\n }\n }\n ];\n if (_this.checkPermissionsService.check('add_us')) {\n steps.push({\n element: '.new-us',\n position: 'rigth',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP4.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP4.TEXT')\n }\n });\n }\n return steps;\n };\n })(this),\n kanban: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.kanban-table-inner',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP1.TITLE'),\n text: _this.translate.instant('JOYRIDE.KANBAN.STEP1.TEXT')\n }\n }, {\n element: '.card-placeholder',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.KANBAN.STEP2.TEXT')\n }\n }\n ];\n if (_this.checkPermissionsService.check('add_us')) {\n steps.push({\n element: '.icon-plus',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP3.TITLE'),\n text: [_this.translate.instant('JOYRIDE.KANBAN.STEP3.TEXT1'), _this.translate.instant('JOYRIDE.KANBAN.STEP3.TEXT2')]\n }\n });\n }\n return steps;\n };\n })(this)\n };\n };\n\n JoyRideService.prototype.get = function(name) {\n var joyRide, joyRides;\n joyRides = this.getConfig();\n joyRide = joyRides[name].call(this);\n return _.map(joyRide, function(item) {\n var html;\n html = \"\";\n if (item.joyride.title) {\n html += \"

\" + item.joyride.title + \"

\";\n }\n if (_.isArray(item.joyride.text)) {\n _.forEach(item.joyride.text, function(text) {\n return html += \"

\" + text + \"

\";\n });\n } else {\n html += \"

\" + item.joyride.text + \"

\";\n }\n item.intro = html;\n return item;\n });\n };\n\n return JoyRideService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgJoyRideService\", JoyRideService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Andrey Antukh \n * Copyright (C) 2014-2015 Jesús Espino Garcia \n * Copyright (C) 2014-2015 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: live-announcement.directive.coffee\n */\n\n(function() {\n var LiveAnnouncementDirective;\n\n LiveAnnouncementDirective = function(liveAnnouncementService) {\n var link;\n link = function(scope, el, attrs) {};\n return {\n restrict: \"AE\",\n scope: {},\n controllerAs: 'vm',\n controller: function() {\n this.close = function() {\n return liveAnnouncementService.open = false;\n };\n return Object.defineProperties(this, {\n open: {\n get: function() {\n return liveAnnouncementService.open;\n }\n },\n title: {\n get: function() {\n return liveAnnouncementService.title;\n }\n },\n desc: {\n get: function() {\n return liveAnnouncementService.desc;\n }\n }\n });\n },\n link: link,\n templateUrl: \"components/live-announcement/live-announcement.html\"\n };\n };\n\n LiveAnnouncementDirective.$inject = [\"tgLiveAnnouncementService\"];\n\n angular.module(\"taigaComponents\").directive(\"tgLiveAnnouncement\", LiveAnnouncementDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: notification.service.coffee\n */\n\n(function() {\n var LiveAnnouncementService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n LiveAnnouncementService = (function(superClass) {\n extend(LiveAnnouncementService, superClass);\n\n function LiveAnnouncementService() {\n this.open = false;\n this.title = \"\";\n this.desc = \"\";\n }\n\n LiveAnnouncementService.prototype.show = function(title, desc) {\n this.open = true;\n this.title = title;\n return this.desc = desc;\n };\n\n return LiveAnnouncementService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgLiveAnnouncementService\", LiveAnnouncementService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-logo.directive.coffee\n */\n\n(function() {\n var COLORS, IMAGES, LOGOS, ProjectLogoSrcDirective,\n modulo = function(a, b) { return (+a % (b = +b) + b) % b; };\n\n IMAGES = [\"/\" + window._version + \"/images/project-logos/project-logo-01.png\", \"/\" + window._version + \"/images/project-logos/project-logo-02.png\", \"/\" + window._version + \"/images/project-logos/project-logo-03.png\", \"/\" + window._version + \"/images/project-logos/project-logo-04.png\", \"/\" + window._version + \"/images/project-logos/project-logo-05.png\"];\n\n COLORS = [\"rgba( 153, 214, 220, 1 )\", \"rgba( 213, 156, 156, 1 )\", \"rgba( 214, 161, 212, 1 )\", \"rgba( 164, 162, 219, 1 )\", \"rgba( 152, 224, 168, 1 )\"];\n\n LOGOS = _.cartesianProduct(IMAGES, COLORS);\n\n ProjectLogoSrcDirective = function($parse) {\n var _getDefaultProjectLogo, link;\n _getDefaultProjectLogo = function(project) {\n var idx, key, logo;\n key = (project.get(\"slug\")) + \"-\" + (project.get(\"id\"));\n idx = modulo(murmurhash3_32_gc(key, 42), LOGOS.length);\n logo = LOGOS[idx];\n return {\n src: logo[0],\n color: logo[1]\n };\n };\n link = function(scope, el, attrs) {\n scope.$watch(\"project\", function(project) {\n var logo, projectLogo;\n project = Immutable.fromJS(project);\n if (!project) {\n return;\n }\n projectLogo = project.get('logo_small_url');\n if (projectLogo) {\n el.attr(\"src\", projectLogo);\n return el.css('background', \"\");\n } else {\n logo = _getDefaultProjectLogo(project);\n el.attr(\"src\", logo.src);\n return el.css('background', logo.color);\n }\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link,\n scope: {\n project: \"=tgProjectLogoSrc\"\n }\n };\n };\n\n ProjectLogoSrcDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgProjectLogoSrc\", ProjectLogoSrcDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-menu.controller.coffee\n */\n\n(function() {\n var ProjectMenuController;\n\n ProjectMenuController = (function() {\n ProjectMenuController.$inject = [\"tgProjectService\", \"tgLightboxFactory\"];\n\n function ProjectMenuController(projectService, lightboxFactory) {\n this.projectService = projectService;\n this.lightboxFactory = lightboxFactory;\n this.project = null;\n this.menu = Immutable.Map();\n }\n\n ProjectMenuController.prototype.show = function() {\n this.project = this.projectService.project;\n this.active = this._getActiveSection();\n this._setVideoConference();\n return this._setMenuPermissions();\n };\n\n ProjectMenuController.prototype.hide = function() {\n this.project = null;\n return this.menu = {};\n };\n\n ProjectMenuController.prototype.search = function() {\n return this.lightboxFactory.create(\"tg-search-box\", {\n \"class\": \"lightbox lightbox-search\"\n });\n };\n\n ProjectMenuController.prototype._setVideoConference = function() {\n var videoconferenceUrl;\n videoconferenceUrl = this._videoConferenceUrl();\n if (videoconferenceUrl) {\n return this.project = this.project.set(\"videoconferenceUrl\", videoconferenceUrl);\n }\n };\n\n ProjectMenuController.prototype._setMenuPermissions = function() {\n this.menu = Immutable.Map({\n backlog: false,\n kanban: false,\n issues: false,\n wiki: false\n });\n if (this.project.get(\"is_backlog_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_us\") !== -1) {\n this.menu = this.menu.set(\"backlog\", true);\n }\n if (this.project.get(\"is_kanban_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_us\") !== -1) {\n this.menu = this.menu.set(\"kanban\", true);\n }\n if (this.project.get(\"is_issues_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_issues\") !== -1) {\n this.menu = this.menu.set(\"issues\", true);\n }\n if (this.project.get(\"is_wiki_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_wiki_pages\") !== -1) {\n return this.menu = this.menu.set(\"wiki\", true);\n }\n };\n\n ProjectMenuController.prototype._getActiveSection = function() {\n var indexBacklog, indexKanban, oldSectionName, sectionName, sectionsBreadcrumb;\n sectionName = this.projectService.section;\n sectionsBreadcrumb = this.projectService.sectionsBreadcrumb;\n indexBacklog = sectionsBreadcrumb.lastIndexOf(\"backlog\");\n indexKanban = sectionsBreadcrumb.lastIndexOf(\"kanban\");\n if (indexBacklog !== -1 || indexKanban !== -1) {\n if (indexKanban === -1 || indexBacklog > indexKanban) {\n oldSectionName = \"backlog\";\n } else {\n oldSectionName = \"kanban\";\n }\n }\n if (sectionName === \"backlog-kanban\") {\n if (oldSectionName === \"backlog\" || oldSectionName === \"kanban\") {\n sectionName = oldSectionName;\n } else if (this.project.get(\"is_backlog_activated\") && !this.project.get(\"is_kanban_activated\")) {\n sectionName = \"backlog\";\n } else if (!this.project.get(\"is_backlog_activated\") && this.project.get(\"is_kanban_activated\")) {\n sectionName = \"kanban\";\n }\n }\n return sectionName;\n };\n\n ProjectMenuController.prototype._videoConferenceUrl = function() {\n var baseUrl, url;\n if (this.project.get(\"videoconferences\") === \"appear-in\") {\n baseUrl = \"https://appear.in/\";\n } else if (this.project.get(\"videoconferences\") === \"talky\") {\n baseUrl = \"https://talky.io/\";\n } else if (this.project.get(\"videoconferences\") === \"jitsi\") {\n baseUrl = \"https://meet.jit.si/\";\n url = this.project.get(\"slug\") + \"-\" + taiga.slugify(this.project.get(\"videoconferences_extra_data\"));\n url = url.replace(/-/g, \"\");\n return baseUrl + url;\n } else if (this.project.get(\"videoconferences\") === \"custom\") {\n return this.project.get(\"videoconferences_extra_data\");\n } else {\n return \"\";\n }\n if (this.project.get(\"videoconferences_extra_data\")) {\n url = this.project.get(\"slug\") + \"-\" + this.project.get(\"videoconferences_extra_data\");\n } else {\n url = this.project.get(\"slug\");\n }\n return baseUrl + url;\n };\n\n return ProjectMenuController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"ProjectMenu\", ProjectMenuController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-menu.directive.coffee\n */\n\n(function() {\n var ProjectMenuDirective, taiga;\n\n taiga = this.taiga;\n\n ProjectMenuDirective = function(projectService, lightboxFactory) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var projectChange;\n projectChange = function() {\n if (projectService.project) {\n return ctrl.show();\n } else {\n return ctrl.hide();\n }\n };\n scope.$watch((function() {\n return projectService.project;\n }), projectChange);\n scope.vm.fixed = false;\n return $(window).on(\"scroll\", function() {\n var position;\n position = $(window).scrollTop();\n if (position > 100 && scope.vm.fixed === false) {\n scope.vm.fixed = true;\n return scope.$digest();\n } else if (position < 100 && scope.vm.fixed === true) {\n scope.vm.fixed = false;\n return scope.$digest();\n }\n });\n };\n return {\n scope: {},\n controller: \"ProjectMenu\",\n controllerAs: \"vm\",\n templateUrl: \"components/project-menu/project-menu.html\",\n link: link\n };\n };\n\n ProjectMenuDirective.$inject = [\"tgProjectService\", \"tgLightboxFactory\"];\n\n angular.module(\"taigaComponents\").directive(\"tgProjectMenu\", ProjectMenuDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.directive.coffee\n */\n\n(function() {\n var TermsOfServiceAndPrivacyPolicyNoticeDirective;\n\n TermsOfServiceAndPrivacyPolicyNoticeDirective = function($config) {\n var link;\n link = function(scope, el, attrs) {\n scope.privacyPolicyUrl = $config.get(\"privacyPolicyUrl\");\n return scope.termsOfServiceUrl = $config.get(\"termsOfServiceUrl\");\n };\n return {\n restrict: \"AE\",\n scope: {},\n link: link,\n templateUrl: \"components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html\"\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgTermsOfServiceAndPrivacyPolicyNotice\", [\"$tgConfig\", TermsOfServiceAndPrivacyPolicyNoticeDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: vote-button.controller.coffee\n */\n\n(function() {\n var VoteButtonController;\n\n VoteButtonController = (function() {\n VoteButtonController.$inject = [\"tgCurrentUserService\"];\n\n function VoteButtonController(currentUserService) {\n this.currentUserService = currentUserService;\n this.user = this.currentUserService.getUser();\n this.isMouseOver = false;\n this.loading = false;\n }\n\n VoteButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n VoteButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n VoteButtonController.prototype.toggleVote = function() {\n var promise;\n this.loading = true;\n if (!this.item.is_voter) {\n promise = this._upvote();\n } else {\n promise = this._downvote();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n VoteButtonController.prototype._upvote = function() {\n return this.onUpvote().then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this));\n };\n\n VoteButtonController.prototype._downvote = function() {\n return this.onDownvote();\n };\n\n return VoteButtonController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"VoteButton\", VoteButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: vote-button.directive.coffee\n */\n\n(function() {\n var VoteButtonDirective;\n\n VoteButtonDirective = function() {\n return {\n scope: {},\n controller: \"VoteButton\",\n bindToController: {\n item: \"=\",\n onUpvote: \"=\",\n onDownvote: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: \"components/vote-button/vote-button.html\"\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgVoteButton\", VoteButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-button.controller.coffee\n */\n\n(function() {\n var WatchButtonController;\n\n WatchButtonController = (function() {\n WatchButtonController.$inject = [\"tgCurrentUserService\", \"$rootScope\"];\n\n function WatchButtonController(currentUserService, rootScope) {\n this.currentUserService = currentUserService;\n this.rootScope = rootScope;\n this.user = this.currentUserService.getUser();\n this.isMouseOver = false;\n this.loading = false;\n }\n\n WatchButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n WatchButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n WatchButtonController.prototype.openWatchers = function() {\n return this.rootScope.$broadcast(\"watcher:add\", this.item);\n };\n\n WatchButtonController.prototype.getPerms = function() {\n var name, perms;\n if (!this.item) {\n return \"\";\n }\n name = this.item._name;\n perms = {\n userstories: 'modify_us',\n issues: 'modify_issue',\n tasks: 'modify_task'\n };\n return perms[name];\n };\n\n WatchButtonController.prototype.toggleWatch = function() {\n var promise;\n this.loading = true;\n if (!this.item.is_watcher) {\n promise = this._watch();\n } else {\n promise = this._unwatch();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n WatchButtonController.prototype._watch = function() {\n return this.onWatch().then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this));\n };\n\n WatchButtonController.prototype._unwatch = function() {\n return this.onUnwatch();\n };\n\n return WatchButtonController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"WatchButton\", WatchButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-button.directive.coffee\n */\n\n(function() {\n var WatchButtonDirective;\n\n WatchButtonDirective = function() {\n return {\n scope: {},\n controller: \"WatchButton\",\n bindToController: {\n item: \"=\",\n onWatch: \"=\",\n onUnwatch: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: function(item, attributes) {\n return \"components/watch-button/watch-button-\" + attributes.environment + \".html\";\n }\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgWatchButton\", WatchButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home-order-by.controller.coffee\n */\n\n(function() {\n var DiscoverHomeOrderByController;\n\n DiscoverHomeOrderByController = (function() {\n DiscoverHomeOrderByController.$inject = ['$translate'];\n\n function DiscoverHomeOrderByController(translate) {\n this.translate = translate;\n this.is_open = false;\n this.texts = {\n week: this.translate.instant('DISCOVER.FILTERS.WEEK'),\n month: this.translate.instant('DISCOVER.FILTERS.MONTH'),\n year: this.translate.instant('DISCOVER.FILTERS.YEAR'),\n all: this.translate.instant('DISCOVER.FILTERS.ALL_TIME')\n };\n }\n\n DiscoverHomeOrderByController.prototype.currentText = function() {\n return this.texts[this.currentOrderBy];\n };\n\n DiscoverHomeOrderByController.prototype.open = function() {\n return this.is_open = true;\n };\n\n DiscoverHomeOrderByController.prototype.close = function() {\n return this.is_open = false;\n };\n\n DiscoverHomeOrderByController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n this.is_open = false;\n return this.onChange({\n orderBy: this.currentOrderBy\n });\n };\n\n return DiscoverHomeOrderByController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverHomeOrderBy\", DiscoverHomeOrderByController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home-order-by.directive.coffee\n */\n\n(function() {\n var DiscoverHomeOrderByDirective;\n\n DiscoverHomeOrderByDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"DiscoverHomeOrderBy\",\n controllerAs: \"vm\",\n bindToController: true,\n templateUrl: \"discover/components/discover-home-order-by/discover-home-order-by.html\",\n scope: {\n currentOrderBy: \"=orderBy\",\n onChange: \"&\"\n },\n link: link\n };\n };\n\n DiscoverHomeOrderByDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverHomeOrderBy\", DiscoverHomeOrderByDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-bar.controller.coffee\n */\n\n(function() {\n var DiscoverSearchBarController;\n\n DiscoverSearchBarController = (function() {\n DiscoverSearchBarController.$inject = ['tgDiscoverProjectsService'];\n\n function DiscoverSearchBarController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, 'projects', (function(_this) {\n return function() {\n return _this.discoverProjectsService.projectsCount;\n };\n })(this));\n this.discoverProjectsService.fetchStats();\n }\n\n DiscoverSearchBarController.prototype.selectFilter = function(filter) {\n return this.onChange({\n filter: filter,\n q: this.q\n });\n };\n\n DiscoverSearchBarController.prototype.submitFilter = function() {\n return this.onChange({\n filter: this.filter,\n q: this.q\n });\n };\n\n return DiscoverSearchBarController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearchBar\", DiscoverSearchBarController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.directive.coffee\n */\n\n(function() {\n var DiscoverSearchBarDirective;\n\n DiscoverSearchBarDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n controller: \"DiscoverSearchBar\",\n controllerAs: \"vm\",\n templateUrl: 'discover/components/discover-search-bar/discover-search-bar.html',\n bindToController: true,\n scope: {\n q: \"=\",\n filter: \"=\",\n onChange: \"&\"\n },\n link: link\n };\n };\n\n DiscoverSearchBarDirective.$inject = [];\n\n angular.module('taigaDiscover').directive('tgDiscoverSearchBar', DiscoverSearchBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-list-header.controller.coffee\n */\n\n(function() {\n var DiscoverSearchListHeaderController;\n\n DiscoverSearchListHeaderController = (function() {\n DiscoverSearchListHeaderController.$inject = [];\n\n function DiscoverSearchListHeaderController() {\n this.like_is_open = this.orderBy.indexOf('-total_fans') === 0;\n this.activity_is_open = this.orderBy.indexOf('-total_activity') === 0;\n }\n\n DiscoverSearchListHeaderController.prototype.openLike = function() {\n this.like_is_open = true;\n this.activity_is_open = false;\n return this.setOrderBy('-total_fans_last_week');\n };\n\n DiscoverSearchListHeaderController.prototype.openActivity = function() {\n this.activity_is_open = true;\n this.like_is_open = false;\n return this.setOrderBy('-total_activity_last_week');\n };\n\n DiscoverSearchListHeaderController.prototype.setOrderBy = function(type) {\n if (type == null) {\n type = '';\n }\n if (!type) {\n this.like_is_open = false;\n this.activity_is_open = false;\n }\n return this.onChange({\n orderBy: type\n });\n };\n\n return DiscoverSearchListHeaderController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearchListHeader\", DiscoverSearchListHeaderController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-list-header.directive.coffee\n */\n\n(function() {\n var DiscoverSearchListHeaderDirective;\n\n DiscoverSearchListHeaderDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"DiscoverSearchListHeader\",\n controllerAs: \"vm\",\n bindToController: true,\n templateUrl: \"discover/components/discover-search-list-header/discover-search-list-header.html\",\n scope: {\n onChange: \"&\",\n orderBy: \"=\"\n },\n link: link\n };\n };\n\n DiscoverSearchListHeaderDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverSearchListHeader\", DiscoverSearchListHeaderDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: featured-projects.controller.coffee\n */\n\n(function() {\n var FeaturedProjectsController;\n\n FeaturedProjectsController = (function() {\n FeaturedProjectsController.$inject = [\"tgDiscoverProjectsService\"];\n\n function FeaturedProjectsController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"featured\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.featured;\n };\n })(this));\n this.discoverProjectsService.fetchFeatured();\n }\n\n return FeaturedProjectsController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"FeaturedProjects\", FeaturedProjectsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: featured-projects.directive.coffee\n */\n\n(function() {\n var FeaturedProjectsDirective;\n\n FeaturedProjectsDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"FeaturedProjects\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/featured-projects/featured-projects.html\",\n scope: {},\n link: link\n };\n };\n\n FeaturedProjectsDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgFeaturedProjects\", FeaturedProjectsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: highlighted.directive.coffee\n */\n\n(function() {\n var HighlightedDirective;\n\n HighlightedDirective = function() {\n return {\n templateUrl: \"discover/components/highlighted/highlighted.html\",\n scope: {\n loading: \"=\",\n highlighted: \"=\",\n orderBy: \"=\"\n }\n };\n };\n\n HighlightedDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgHighlighted\", HighlightedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-active.controller.coffee\n */\n\n(function() {\n var MostActiveController;\n\n MostActiveController = (function() {\n MostActiveController.$inject = [\"tgDiscoverProjectsService\"];\n\n function MostActiveController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"highlighted\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.mostActive;\n };\n })(this));\n this.currentOrderBy = 'week';\n this.order_by = this.getOrderBy();\n }\n\n MostActiveController.prototype.fetch = function() {\n this.loading = true;\n this.order_by = this.getOrderBy();\n return this.discoverProjectsService.fetchMostActive({\n order_by: this.order_by\n }).then((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n MostActiveController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n return this.fetch();\n };\n\n MostActiveController.prototype.getOrderBy = function(type) {\n if (this.currentOrderBy === 'all') {\n return '-total_activity';\n } else {\n return '-total_activity_last_' + this.currentOrderBy;\n }\n };\n\n return MostActiveController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"MostActive\", MostActiveController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-active.directive.coffee\n */\n\n(function() {\n var MostActiveDirective;\n\n MostActiveDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"MostActive\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/most-active/most-active.html\",\n scope: {},\n link: link\n };\n };\n\n MostActiveDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgMostActive\", MostActiveDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: msot-liked.controller.coffee\n */\n\n(function() {\n var MostLikedController;\n\n MostLikedController = (function() {\n MostLikedController.$inject = [\"tgDiscoverProjectsService\"];\n\n function MostLikedController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"highlighted\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.mostLiked;\n };\n })(this));\n this.currentOrderBy = 'week';\n this.order_by = this.getOrderBy();\n }\n\n MostLikedController.prototype.fetch = function() {\n this.loading = true;\n this.order_by = this.getOrderBy();\n return this.discoverProjectsService.fetchMostLiked({\n order_by: this.order_by\n }).then((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n MostLikedController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n return this.fetch();\n };\n\n MostLikedController.prototype.getOrderBy = function() {\n if (this.currentOrderBy === 'all') {\n return '-total_fans';\n } else {\n return '-total_fans_last_' + this.currentOrderBy;\n }\n };\n\n return MostLikedController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"MostLiked\", MostLikedController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-liked.directive.coffee\n */\n\n(function() {\n var MostLikedDirective;\n\n MostLikedDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"MostLiked\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/most-liked/most-liked.html\",\n scope: {},\n link: link\n };\n };\n\n MostLikedDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgMostLiked\", MostLikedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home.controller.coffee\n */\n\n(function() {\n var DiscoverHomeController;\n\n DiscoverHomeController = (function() {\n DiscoverHomeController.$inject = ['$tgLocation', '$tgNavUrls'];\n\n function DiscoverHomeController(location, navUrls) {\n this.location = location;\n this.navUrls = navUrls;\n }\n\n DiscoverHomeController.prototype.onSubmit = function(q) {\n var url;\n url = this.navUrls.resolve('discover-search');\n return this.location.search('text', q).path(url);\n };\n\n return DiscoverHomeController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverHome\", DiscoverHomeController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.controller.coffee\n */\n\n(function() {\n var DiscoverSearchController;\n\n DiscoverSearchController = (function() {\n DiscoverSearchController.$inject = ['$routeParams', 'tgDiscoverProjectsService', '$route'];\n\n function DiscoverSearchController(routeParams, discoverProjectsService, route) {\n this.routeParams = routeParams;\n this.discoverProjectsService = discoverProjectsService;\n this.route = route;\n this.page = 1;\n taiga.defineImmutableProperty(this, \"searchResult\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.searchResult;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"nextSearchPage\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.nextSearchPage;\n };\n })(this));\n this.q = this.routeParams.text;\n this.filter = this.routeParams.filter || 'all';\n this.orderBy = this.routeParams['order_by'] || '';\n this.loadingGlobal = false;\n this.loadingList = false;\n this.loadingPagination = false;\n }\n\n DiscoverSearchController.prototype.fetch = function() {\n this.page = 1;\n this.discoverProjectsService.resetSearchList();\n return this.search();\n };\n\n DiscoverSearchController.prototype.fetchByGlobalSearch = function() {\n if (this.loadingGlobal) {\n return;\n }\n this.loadingGlobal = true;\n return this.fetch().then((function(_this) {\n return function() {\n return _this.loadingGlobal = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.fetchByOrderBy = function() {\n if (this.loadingList) {\n return;\n }\n this.loadingList = true;\n return this.fetch().then((function(_this) {\n return function() {\n return _this.loadingList = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.showMore = function() {\n if (this.loadingPagination) {\n return;\n }\n this.loadingPagination = true;\n this.page++;\n return this.search().then((function(_this) {\n return function() {\n return _this.loadingPagination = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.search = function() {\n var filter, params;\n filter = this.getFilter();\n params = {\n page: this.page,\n q: this.q,\n order_by: this.orderBy\n };\n _.assign(params, filter);\n return this.discoverProjectsService.fetchSearch(params);\n };\n\n DiscoverSearchController.prototype.getFilter = function() {\n if (this.filter === 'people') {\n return {\n is_looking_for_people: true\n };\n } else if (this.filter === 'scrum') {\n return {\n is_backlog_activated: true\n };\n } else if (this.filter === 'kanban') {\n return {\n is_kanban_activated: true\n };\n }\n return {};\n };\n\n DiscoverSearchController.prototype.onChangeFilter = function(filter, q) {\n this.filter = filter;\n this.q = q;\n this.route.updateParams({\n filter: this.filter,\n text: this.q\n });\n return this.fetchByGlobalSearch();\n };\n\n DiscoverSearchController.prototype.onChangeOrder = function(orderBy) {\n this.orderBy = orderBy;\n this.route.updateParams({\n order_by: orderBy\n });\n return this.fetchByOrderBy();\n };\n\n return DiscoverSearchController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearch\", DiscoverSearchController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.directive.coffee\n */\n\n(function() {\n var DiscoverSearchDirective;\n\n DiscoverSearchDirective = function() {\n var link;\n link = function(scope, element, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"DiscoverSearch\",\n controllerAs: \"vm\",\n link: link\n };\n };\n\n DiscoverSearchDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverSearch\", DiscoverSearchDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-projects.service.coffee\n */\n\n(function() {\n var DiscoverProjectsService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n DiscoverProjectsService = (function(superClass) {\n extend(DiscoverProjectsService, superClass);\n\n DiscoverProjectsService.$inject = [\"tgResources\", \"tgProjectsService\"];\n\n function DiscoverProjectsService(rs, projectsService) {\n this.rs = rs;\n this.projectsService = projectsService;\n this._mostLiked = Immutable.List();\n this._mostActive = Immutable.List();\n this._featured = Immutable.List();\n this._searchResult = Immutable.List();\n this._projectsCount = 0;\n this.decorate = this.projectsService._decorate.bind(this.projectsService);\n taiga.defineImmutableProperty(this, \"mostLiked\", (function(_this) {\n return function() {\n return _this._mostLiked;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"mostActive\", (function(_this) {\n return function() {\n return _this._mostActive;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"featured\", (function(_this) {\n return function() {\n return _this._featured;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"searchResult\", (function(_this) {\n return function() {\n return _this._searchResult;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"nextSearchPage\", (function(_this) {\n return function() {\n return _this._nextSearchPage;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"projectsCount\", (function(_this) {\n return function() {\n return _this._projectsCount;\n };\n })(this));\n }\n\n DiscoverProjectsService.prototype.fetchMostLiked = function(params) {\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 5);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._mostLiked = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchMostActive = function(params) {\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 5);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._mostActive = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchFeatured = function() {\n var params;\n params = {\n is_featured: true\n };\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 4);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._featured = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.resetSearchList = function() {\n return this._searchResult = Immutable.List();\n };\n\n DiscoverProjectsService.prototype.fetchStats = function() {\n return this.rs.stats.discover().then((function(_this) {\n return function(discover) {\n return _this._projectsCount = discover.getIn(['projects', 'total']);\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchSearch = function(params) {\n return this.rs.projects.getProjects(params).then((function(_this) {\n return function(result) {\n var projects;\n _this._nextSearchPage = !!result.headers('X-Pagination-Next');\n projects = Immutable.fromJS(result.data);\n projects = projects.map(_this.decorate);\n return _this._searchResult = _this._searchResult.concat(projects);\n };\n })(this));\n };\n\n return DiscoverProjectsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaDiscover\").service(\"tgDiscoverProjectsService\", DiscoverProjectsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-app.controller.coffee\n */\n\n(function() {\n var ExternalAppController, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ExternalAppController = (function(superClass) {\n extend(ExternalAppController, superClass);\n\n ExternalAppController.$inject = [\"$routeParams\", \"tgExternalAppsService\", \"$window\", \"tgCurrentUserService\", \"$location\", \"$tgNavUrls\", \"tgXhrErrorService\", \"tgLoader\"];\n\n function ExternalAppController(routeParams, externalAppsService, window, currentUserService, location, navUrls, xhrError, loader) {\n var loginUrl, nextUrl;\n this.routeParams = routeParams;\n this.externalAppsService = externalAppsService;\n this.window = window;\n this.currentUserService = currentUserService;\n this.location = location;\n this.navUrls = navUrls;\n this.xhrError = xhrError;\n this.loader = loader;\n this.createApplicationToken = bind(this.createApplicationToken, this);\n this._getApplicationToken = bind(this._getApplicationToken, this);\n this._redirect = bind(this._redirect, this);\n this.loader.start(false);\n this._applicationId = this.routeParams.application;\n this._state = this.routeParams.state;\n this._getApplicationToken();\n this._user = this.currentUserService.getUser();\n this._application = null;\n nextUrl = encodeURIComponent(this.location.url());\n loginUrl = this.navUrls.resolve(\"login\");\n this.loginWithAnotherUserUrl = loginUrl + \"?next=\" + nextUrl;\n taiga.defineImmutableProperty(this, \"user\", (function(_this) {\n return function() {\n return _this._user;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"application\", (function(_this) {\n return function() {\n return _this._application;\n };\n })(this));\n }\n\n ExternalAppController.prototype._redirect = function(applicationToken) {\n var nextUrl;\n nextUrl = applicationToken.get(\"next_url\");\n return this.window.open(nextUrl, \"_self\");\n };\n\n ExternalAppController.prototype._getApplicationToken = function() {\n return this.externalAppsService.getApplicationToken(this._applicationId, this._state).then((function(_this) {\n return function(data) {\n _this._application = data.get(\"application\");\n if (data.get(\"auth_code\")) {\n return _this._redirect(data);\n } else {\n return _this.loader.pageLoaded();\n }\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n _this.loader.pageLoaded();\n return _this.xhrError.response(xhr);\n };\n })(this));\n };\n\n ExternalAppController.prototype.cancel = function() {\n return this.window.history.back();\n };\n\n ExternalAppController.prototype.createApplicationToken = function() {\n return this.externalAppsService.authorizeApplicationToken(this._applicationId, this._state).then((function(_this) {\n return function(data) {\n return _this._redirect(data);\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n return _this.xhrError.response(xhr);\n };\n })(this));\n };\n\n return ExternalAppController;\n\n })(taiga.Controller);\n\n angular.module(\"taigaExternalApps\").controller(\"ExternalApp\", ExternalAppController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-app.service.coffee\n */\n\n(function() {\n var ExternalAppsService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n ExternalAppsService = (function(superClass) {\n extend(ExternalAppsService, superClass);\n\n ExternalAppsService.$inject = [\"tgResources\"];\n\n function ExternalAppsService(rs) {\n this.rs = rs;\n }\n\n ExternalAppsService.prototype.getApplicationToken = function(applicationId, state) {\n return this.rs.externalapps.getApplicationToken(applicationId, state);\n };\n\n ExternalAppsService.prototype.authorizeApplicationToken = function(applicationId, state) {\n return this.rs.externalapps.authorizeApplicationToken(applicationId, state);\n };\n\n return ExternalAppsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaExternalApps\").service(\"tgExternalAppsService\", ExternalAppsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: feedback.service.coffee\n */\n\n(function() {\n var FeedbackService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n FeedbackService = (function(superClass) {\n extend(FeedbackService, superClass);\n\n FeedbackService.$inject = [\"tgLightboxFactory\"];\n\n function FeedbackService(lightboxFactory) {\n this.lightboxFactory = lightboxFactory;\n }\n\n FeedbackService.prototype.sendFeedback = function() {\n return this.lightboxFactory.create(\"tg-lb-feedback\", {\n \"class\": \"lightbox lightbox-feedback lightbox-generic-form\"\n });\n };\n\n return FeedbackService;\n\n })(taiga.Service);\n\n angular.module(\"taigaFeedback\").service(\"tgFeedbackService\", FeedbackService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: duty.directive.coffee\n */\n\n(function() {\n var DutyDirective;\n\n DutyDirective = function(navurls, $translate) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.vm.duty = scope.duty;\n return scope.vm.getDutyType = function() {\n if (scope.vm.duty) {\n if (scope.vm.duty.get('_name') === \"userstories\") {\n return $translate.instant(\"COMMON.USER_STORY\");\n }\n if (scope.vm.duty.get('_name') === \"tasks\") {\n return $translate.instant(\"COMMON.TASK\");\n }\n if (scope.vm.duty.get('_name') === \"issues\") {\n return $translate.instant(\"COMMON.ISSUE\");\n }\n }\n };\n };\n return {\n templateUrl: \"home/duties/duty.html\",\n scope: {\n \"duty\": \"=tgDuty\"\n },\n link: link\n };\n };\n\n DutyDirective.$inject = [\"$tgNavUrls\", \"$translate\"];\n\n angular.module(\"taigaHome\").directive(\"tgDuty\", DutyDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.controller.coffee\n */\n\n(function() {\n var HomeController;\n\n HomeController = (function() {\n HomeController.$inject = [\"tgCurrentUserService\", \"$location\", \"$tgNavUrls\"];\n\n function HomeController(currentUserService, location, navUrls) {\n this.currentUserService = currentUserService;\n this.location = location;\n this.navUrls = navUrls;\n if (!this.currentUserService.getUser()) {\n this.location.path(this.navUrls.resolve(\"discover\"));\n }\n }\n\n return HomeController;\n\n })();\n\n angular.module(\"taigaHome\").controller(\"Home\", HomeController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.service.coffee\n */\n\n(function() {\n var HomeService, groupBy,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n groupBy = this.taiga.groupBy;\n\n HomeService = (function(superClass) {\n extend(HomeService, superClass);\n\n HomeService.$inject = [\"$tgNavUrls\", \"tgResources\", \"tgProjectsService\"];\n\n function HomeService(navurls, rs, projectsService) {\n this.navurls = navurls;\n this.rs = rs;\n this.projectsService = projectsService;\n }\n\n HomeService.prototype._attachProjectInfoToWorkInProgress = function(workInProgress, projectsById) {\n var _attachProjectInfoToDuty, _duties, assignedTo, watching;\n _attachProjectInfoToDuty = (function(_this) {\n return function(duty, objType) {\n var ctx, project, url;\n project = projectsById.get(String(duty.get('project')));\n ctx = {\n project: project.get('slug'),\n ref: duty.get('ref')\n };\n url = _this.navurls.resolve(\"project-\" + objType + \"-detail\", ctx);\n duty = duty.set('url', url);\n duty = duty.set('projectName', project.get('name'));\n duty = duty.set(\"_name\", objType);\n return duty;\n };\n })(this);\n assignedTo = workInProgress.get(\"assignedTo\");\n if (assignedTo.get(\"userStories\")) {\n _duties = assignedTo.get(\"userStories\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"userstories\");\n });\n assignedTo = assignedTo.set(\"userStories\", _duties);\n }\n if (assignedTo.get(\"tasks\")) {\n _duties = assignedTo.get(\"tasks\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"tasks\");\n });\n assignedTo = assignedTo.set(\"tasks\", _duties);\n }\n if (assignedTo.get(\"issues\")) {\n _duties = assignedTo.get(\"issues\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"issues\");\n });\n assignedTo = assignedTo.set(\"issues\", _duties);\n }\n watching = workInProgress.get(\"watching\");\n if (watching.get(\"userStories\")) {\n _duties = watching.get(\"userStories\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"userstories\");\n });\n watching = watching.set(\"userStories\", _duties);\n }\n if (watching.get(\"tasks\")) {\n _duties = watching.get(\"tasks\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"tasks\");\n });\n watching = watching.set(\"tasks\", _duties);\n }\n if (watching.get(\"issues\")) {\n _duties = watching.get(\"issues\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"issues\");\n });\n watching = watching.set(\"issues\", _duties);\n }\n workInProgress = workInProgress.set(\"assignedTo\", assignedTo);\n return workInProgress = workInProgress.set(\"watching\", watching);\n };\n\n HomeService.prototype.getWorkInProgress = function(userId) {\n var assignedIssuesPromise, assignedTasksPromise, assignedTo, assignedUserStoriesPromise, params, params_us, projectsById, projectsPromise, watching, watchingIssuesPromise, watchingTasksPromise, watchingUserStoriesPromise, workInProgress;\n projectsById = Immutable.Map();\n projectsPromise = this.projectsService.getProjectsByUserId(userId).then(function(projects) {\n return projectsById = Immutable.fromJS(groupBy(projects.toJS(), function(p) {\n return p.id;\n }));\n });\n assignedTo = Immutable.Map();\n params = {\n status__is_closed: false,\n assigned_to: userId\n };\n params_us = {\n is_closed: false,\n assigned_to: userId\n };\n assignedUserStoriesPromise = this.rs.userstories.listInAllProjects(params_us).then(function(userstories) {\n return assignedTo = assignedTo.set(\"userStories\", userstories);\n });\n assignedTasksPromise = this.rs.tasks.listInAllProjects(params).then(function(tasks) {\n return assignedTo = assignedTo.set(\"tasks\", tasks);\n });\n assignedIssuesPromise = this.rs.issues.listInAllProjects(params).then(function(issues) {\n return assignedTo = assignedTo.set(\"issues\", issues);\n });\n params = {\n status__is_closed: false,\n watchers: userId\n };\n params_us = {\n is_closed: false,\n watchers: userId\n };\n watching = Immutable.Map();\n watchingUserStoriesPromise = this.rs.userstories.listInAllProjects(params_us).then(function(userstories) {\n return watching = watching.set(\"userStories\", userstories);\n });\n watchingTasksPromise = this.rs.tasks.listInAllProjects(params).then(function(tasks) {\n return watching = watching.set(\"tasks\", tasks);\n });\n watchingIssuesPromise = this.rs.issues.listInAllProjects(params).then(function(issues) {\n return watching = watching.set(\"issues\", issues);\n });\n workInProgress = Immutable.Map();\n return Promise.all([projectsPromise, assignedUserStoriesPromise, assignedTasksPromise, assignedIssuesPromise, watchingUserStoriesPromise, watchingTasksPromise, watchingIssuesPromise]).then((function(_this) {\n return function() {\n workInProgress = workInProgress.set(\"assignedTo\", assignedTo);\n workInProgress = workInProgress.set(\"watching\", watching);\n workInProgress = _this._attachProjectInfoToWorkInProgress(workInProgress, projectsById);\n return workInProgress;\n };\n })(this));\n };\n\n return HomeService;\n\n })(taiga.Service);\n\n angular.module(\"taigaHome\").service(\"tgHomeService\", HomeService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home-project-list.directive.coffee\n */\n\n(function() {\n var HomeProjectListDirective;\n\n HomeProjectListDirective = function(currentUserService, projectsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n return scope.vm.newProject = function() {\n return projectsService.newProject();\n };\n };\n directive = {\n templateUrl: \"home/projects/home-project-list.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n HomeProjectListDirective.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n angular.module(\"taigaHome\").directive(\"tgHomeProjectList\", HomeProjectListDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: working-on.controller.coffee\n */\n\n(function() {\n var WorkingOnController;\n\n WorkingOnController = (function() {\n WorkingOnController.$inject = [\"tgHomeService\"];\n\n function WorkingOnController(homeService) {\n this.homeService = homeService;\n this.assignedTo = Immutable.Map();\n this.watching = Immutable.Map();\n }\n\n WorkingOnController.prototype._setAssignedTo = function(workInProgress) {\n var issues, tasks, userStories;\n userStories = workInProgress.get(\"assignedTo\").get(\"userStories\");\n tasks = workInProgress.get(\"assignedTo\").get(\"tasks\");\n issues = workInProgress.get(\"assignedTo\").get(\"issues\");\n this.assignedTo = userStories.concat(tasks).concat(issues);\n if (this.assignedTo.size > 0) {\n return this.assignedTo = this.assignedTo.sortBy(function(elem) {\n return elem.get(\"modified_date\");\n }).reverse();\n }\n };\n\n WorkingOnController.prototype._setWatching = function(workInProgress) {\n var issues, tasks, userStories;\n userStories = workInProgress.get(\"watching\").get(\"userStories\");\n tasks = workInProgress.get(\"watching\").get(\"tasks\");\n issues = workInProgress.get(\"watching\").get(\"issues\");\n this.watching = userStories.concat(tasks).concat(issues);\n if (this.watching.size > 0) {\n return this.watching = this.watching.sortBy(function(elem) {\n return elem.get(\"modified_date\");\n }).reverse();\n }\n };\n\n WorkingOnController.prototype.getWorkInProgress = function(userId) {\n return this.homeService.getWorkInProgress(userId).then((function(_this) {\n return function(workInProgress) {\n _this._setAssignedTo(workInProgress);\n return _this._setWatching(workInProgress);\n };\n })(this));\n };\n\n return WorkingOnController;\n\n })();\n\n angular.module(\"taigaHome\").controller(\"WorkingOn\", WorkingOnController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: working-on.directive.coffee\n */\n\n(function() {\n var WorkingOnDirective;\n\n WorkingOnDirective = function(homeService, currentUserService) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var user, userId;\n user = currentUserService.getUser();\n if (user) {\n userId = user.get(\"id\");\n return ctrl.getWorkInProgress(userId);\n }\n };\n return {\n controller: \"WorkingOn\",\n controllerAs: \"vm\",\n templateUrl: \"home/working-on/working-on.html\",\n scope: {},\n link: link\n };\n };\n\n WorkingOnDirective.$inject = [\"tgHomeService\", \"tgCurrentUserService\"];\n\n angular.module(\"taigaHome\").directive(\"tgWorkingOn\", WorkingOnDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: dropdown-project-list.directive.coffee\n */\n\n(function() {\n var DropdownProjectListDirective;\n\n DropdownProjectListDirective = function(currentUserService, projectsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n return scope.vm.newProject = function() {\n return projectsService.newProject();\n };\n };\n directive = {\n templateUrl: \"navigation-bar/dropdown-project-list/dropdown-project-list.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n DropdownProjectListDirective.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgDropdownProjectList\", DropdownProjectListDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: dropdown-user.directive.coffee\n */\n\n(function() {\n var DropdownUserDirective;\n\n DropdownUserDirective = function(authService, configService, locationService, navUrlsService, feedbackService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.vm.isFeedbackEnabled = configService.get(\"feedbackEnabled\");\n taiga.defineImmutableProperty(scope.vm, \"user\", function() {\n return authService.userData;\n });\n scope.vm.logout = function() {\n authService.logout();\n locationService.url(navUrlsService.resolve(\"discover\"));\n return locationService.search({});\n };\n return scope.vm.sendFeedback = function() {\n return feedbackService.sendFeedback();\n };\n };\n directive = {\n templateUrl: \"navigation-bar/dropdown-user/dropdown-user.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n DropdownUserDirective.$inject = [\"$tgAuth\", \"$tgConfig\", \"$tgLocation\", \"$tgNavUrls\", \"tgFeedbackService\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgDropdownUser\", DropdownUserDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.directive.coffee\n */\n\n(function() {\n var NavigationBarDirective;\n\n NavigationBarDirective = function(currentUserService, navigationBarService, locationService, navUrlsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.$on(\"$routeChangeSuccess\", function() {\n if (locationService.path() === \"/\") {\n return scope.vm.active = true;\n } else {\n return scope.vm.active = false;\n }\n });\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n taiga.defineImmutableProperty(scope.vm, \"isAuthenticated\", function() {\n return currentUserService.isAuthenticated();\n });\n taiga.defineImmutableProperty(scope.vm, \"isEnabledHeader\", function() {\n return navigationBarService.isEnabledHeader();\n });\n scope.vm.login = function() {\n var nextUrl;\n nextUrl = encodeURIComponent(locationService.url());\n locationService.url(navUrlsService.resolve(\"login\"));\n return locationService.search({\n next: nextUrl\n });\n };\n return scope.vm.register = function() {\n var nextUrl;\n nextUrl = encodeURIComponent(locationService.url());\n locationService.url(navUrlsService.resolve(\"register\"));\n return locationService.search({\n next: nextUrl\n });\n };\n };\n directive = {\n templateUrl: \"navigation-bar/navigation-bar.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n NavigationBarDirective.$inject = [\"tgCurrentUserService\", \"tgNavigationBarService\", \"$tgLocation\", \"$tgNavUrls\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgNavigationBar\", NavigationBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.service.coffee\n */\n\n(function() {\n var NavigationBarService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n NavigationBarService = (function(superClass) {\n extend(NavigationBarService, superClass);\n\n function NavigationBarService() {\n this.disableHeader();\n }\n\n NavigationBarService.prototype.enableHeader = function() {\n return this.enabledHeader = true;\n };\n\n NavigationBarService.prototype.disableHeader = function() {\n return this.enabledHeader = false;\n };\n\n NavigationBarService.prototype.isEnabledHeader = function() {\n return this.enabledHeader;\n };\n\n return NavigationBarService;\n\n })(taiga.Service);\n\n angular.module(\"taigaNavigationBar\").service(\"tgNavigationBarService\", NavigationBarService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-bar.controller.coffee\n */\n\n(function() {\n var ProfileBarController;\n\n ProfileBarController = (function() {\n ProfileBarController.$inject = [\"tgUserService\"];\n\n function ProfileBarController(userService) {\n this.userService = userService;\n this.loadStats();\n }\n\n ProfileBarController.prototype.loadStats = function() {\n return this.userService.getStats(this.user.get(\"id\")).then((function(_this) {\n return function(stats) {\n return _this.stats = stats;\n };\n })(this));\n };\n\n return ProfileBarController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileBar\", ProfileBarController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-bar.directive.coffee\n */\n\n(function() {\n var ProfileBarDirective;\n\n ProfileBarDirective = function() {\n return {\n templateUrl: \"profile/profile-bar/profile-bar.html\",\n controller: \"ProfileBar\",\n controllerAs: \"vm\",\n scope: {\n user: \"=user\",\n isCurrentUser: \"=iscurrentuser\"\n },\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileBar\", ProfileBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-contacts.controller.coffee\n */\n\n(function() {\n var ProfileContactsController;\n\n ProfileContactsController = (function() {\n ProfileContactsController.$inject = [\"tgUserService\", \"tgCurrentUserService\"];\n\n function ProfileContactsController(userService, currentUserService) {\n this.userService = userService;\n this.currentUserService = currentUserService;\n this.currentUser = this.currentUserService.getUser();\n this.isCurrentUser = false;\n if (this.currentUser && this.currentUser.get(\"id\") === this.user.get(\"id\")) {\n this.isCurrentUser = true;\n }\n }\n\n ProfileContactsController.prototype.loadContacts = function() {\n return this.userService.getContacts(this.user.get(\"id\")).then((function(_this) {\n return function(contacts) {\n return _this.contacts = contacts;\n };\n })(this));\n };\n\n return ProfileContactsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileContacts\", ProfileContactsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-contacts.directive.coffee\n */\n\n(function() {\n var ProfileContactsDirective;\n\n ProfileContactsDirective = function() {\n var link;\n link = function(scope, elm, attrs, ctrl) {\n return ctrl.loadContacts();\n };\n return {\n templateUrl: \"profile/profile-contacts/profile-contacts.html\",\n scope: {\n user: \"=\"\n },\n controllerAs: \"vm\",\n controller: \"ProfileContacts\",\n link: link,\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileContacts\", ProfileContactsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: items.directive.coffee\n */\n\n(function() {\n var FavItemDirective;\n\n FavItemDirective = function() {\n var link, templateUrl;\n link = function(scope, el, attrs, ctrl) {\n return scope.vm = {\n item: scope.item\n };\n };\n templateUrl = function(el, attrs) {\n if (attrs.itemType === \"project\") {\n return \"profile/profile-favs/items/project.html\";\n } else {\n return \"profile/profile-favs/items/ticket.html\";\n }\n };\n return {\n scope: {\n \"item\": \"=tgFavItem\"\n },\n link: link,\n templateUrl: templateUrl\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgFavItem\", FavItemDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-favs.controller.coffee\n */\n\n(function() {\n var FavsBaseController, ProfileLikedController, ProfileVotedController, ProfileWatchedController, debounceLeading,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n debounceLeading = this.taiga.debounceLeading;\n\n FavsBaseController = (function() {\n function FavsBaseController() {\n this._init();\n }\n\n FavsBaseController.prototype._init = function() {\n this.enableFilterByAll = true;\n this.enableFilterByProjects = true;\n this.enableFilterByUserStories = true;\n this.enableFilterByTasks = true;\n this.enableFilterByIssues = true;\n this.enableFilterByTextQuery = true;\n this._resetList();\n this.q = null;\n return this.type = null;\n };\n\n FavsBaseController.prototype._resetList = function() {\n this.items = Immutable.List();\n this.scrollDisabled = false;\n return this._page = 1;\n };\n\n FavsBaseController.prototype._enableLoadingSpinner = function() {\n return this.isLoading = true;\n };\n\n FavsBaseController.prototype._disableLoadingSpinner = function() {\n return this.isLoading = false;\n };\n\n FavsBaseController.prototype._enableScroll = function() {\n return this.scrollDisabled = false;\n };\n\n FavsBaseController.prototype._disableScroll = function() {\n return this.scrollDisabled = true;\n };\n\n FavsBaseController.prototype._checkIfHasMorePages = function(hasNext) {\n if (hasNext) {\n this._page += 1;\n return this._enableScroll();\n } else {\n return this._disableScroll();\n }\n };\n\n FavsBaseController.prototype._checkIfHasNoResults = function() {\n return this.hasNoResults = this.items.size === 0;\n };\n\n FavsBaseController.prototype.loadItems = function() {\n this._enableLoadingSpinner();\n this._disableScroll();\n return this._getItems(this.user.get(\"id\"), this._page, this.type, this.q).then((function(_this) {\n return function(response) {\n _this.items = _this.items.concat(response.get(\"data\"));\n _this._checkIfHasMorePages(response.get(\"next\"));\n _this._checkIfHasNoResults();\n _this._disableLoadingSpinner();\n return _this.items;\n };\n })(this))[\"catch\"]((function(_this) {\n return function() {\n _this._disableLoadingSpinner();\n return _this.items;\n };\n })(this));\n };\n\n FavsBaseController.prototype.filterByTextQuery = debounceLeading(500, function() {\n this._resetList();\n return this.loadItems();\n });\n\n FavsBaseController.prototype.showAll = function() {\n if (this.type !== null) {\n this.type = null;\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showProjectsOnly = function() {\n if (this.type !== \"project\") {\n this.type = \"project\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showUserStoriesOnly = function() {\n if (this.type !== \"userstory\") {\n this.type = \"userstory\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showTasksOnly = function() {\n if (this.type !== \"task\") {\n this.type = \"task\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showIssuesOnly = function() {\n if (this.type !== \"issue\") {\n this.type = \"issue\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n return FavsBaseController;\n\n })();\n\n ProfileLikedController = (function(superClass) {\n extend(ProfileLikedController, superClass);\n\n ProfileLikedController.$inject = [\"tgUserService\"];\n\n function ProfileLikedController(userService) {\n this.userService = userService;\n ProfileLikedController.__super__.constructor.call(this);\n this.enableFilterByAll = false;\n this.enableFilterByProjects = false;\n this.enableFilterByUserStories = false;\n this.enableFilterByTasks = false;\n this.enableFilterByIssues = false;\n this.enableFilterByTextQuery = true;\n this._getItems = this.userService.getLiked;\n }\n\n return ProfileLikedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileLiked\", ProfileLikedController);\n\n ProfileVotedController = (function(superClass) {\n extend(ProfileVotedController, superClass);\n\n ProfileVotedController.$inject = [\"tgUserService\"];\n\n function ProfileVotedController(userService) {\n this.userService = userService;\n ProfileVotedController.__super__.constructor.call(this);\n this.enableFilterByAll = true;\n this.enableFilterByProjects = false;\n this.enableFilterByUserStories = true;\n this.enableFilterByTasks = true;\n this.enableFilterByIssues = true;\n this.enableFilterByTextQuery = true;\n this._getItems = this.userService.getVoted;\n }\n\n return ProfileVotedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileVoted\", ProfileVotedController);\n\n ProfileWatchedController = (function(superClass) {\n extend(ProfileWatchedController, superClass);\n\n ProfileWatchedController.$inject = [\"tgUserService\"];\n\n function ProfileWatchedController(userService) {\n this.userService = userService;\n ProfileWatchedController.__super__.constructor.call(this);\n this._getItems = this.userService.getWatched;\n }\n\n return ProfileWatchedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileWatched\", ProfileWatchedController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-favs.directive.coffee\n */\n\n(function() {\n var ProfileLikedDirective, ProfileVotedDirective, ProfileWatchedDirective, base;\n\n base = {\n scope: {},\n bindToController: {\n user: \"=\",\n type: \"@\",\n q: \"@\",\n scrollDisabled: \"@\",\n isLoading: \"@\",\n hasNoResults: \"@\"\n },\n controller: null,\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-favs/profile-favs.html\"\n };\n\n ProfileLikedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileLiked\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileLiked\", ProfileLikedDirective);\n\n ProfileVotedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileVoted\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileVoted\", ProfileVotedDirective);\n\n ProfileWatchedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileWatched\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileWatched\", ProfileWatchedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-hints.controller.coffee\n */\n\n(function() {\n var ProfileHints;\n\n ProfileHints = (function() {\n ProfileHints.prototype.HINTS = [\n {\n url: \"https://taiga.io/support/import-export-projects/\"\n }, {\n url: \"https://taiga.io/support/custom-fields/\"\n }, {}, {}\n ];\n\n function ProfileHints(translate) {\n var hintKey;\n this.translate = translate;\n hintKey = Math.floor(Math.random() * this.HINTS.length) + 1;\n this.hint = this.HINTS[hintKey - 1];\n this.hint.linkText = this.hint.linkText || 'HINTS.LINK';\n this.hint.title = this.translate.instant(\"HINTS.HINT\" + hintKey + \"_TITLE\");\n this.hint.text = this.translate.instant(\"HINTS.HINT\" + hintKey + \"_TEXT\");\n }\n\n return ProfileHints;\n\n })();\n\n ProfileHints.$inject = [\"$translate\"];\n\n angular.module(\"taigaProfile\").controller(\"ProfileHints\", ProfileHints);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-hints.directive.coffee\n */\n\n(function() {\n var ProfileHints;\n\n ProfileHints = function($translate) {\n return {\n scope: {},\n controller: \"ProfileHints\",\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-hints/profile-hints.html\"\n };\n };\n\n ProfileHints.$inject = [\"$translate\"];\n\n angular.module(\"taigaProfile\").directive(\"tgProfileHints\", ProfileHints);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-projects.controller.coffee\n */\n\n(function() {\n var ProfileProjectsController;\n\n ProfileProjectsController = (function() {\n ProfileProjectsController.$inject = [\"tgProjectsService\", \"tgUserService\"];\n\n function ProfileProjectsController(projectsService, userService) {\n this.projectsService = projectsService;\n this.userService = userService;\n }\n\n ProfileProjectsController.prototype.loadProjects = function() {\n return this.projectsService.getProjectsByUserId(this.user.get(\"id\")).then((function(_this) {\n return function(projects) {\n return _this.userService.attachUserContactsToProjects(_this.user.get(\"id\"), projects);\n };\n })(this)).then((function(_this) {\n return function(projects) {\n return _this.projects = projects;\n };\n })(this));\n };\n\n return ProfileProjectsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileProjects\", ProfileProjectsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-projects.directive.coffee\n */\n\n(function() {\n var ProfileProjectsDirective;\n\n ProfileProjectsDirective = function() {\n var link;\n link = function(scope, elm, attr, ctrl) {\n return ctrl.loadProjects();\n };\n return {\n templateUrl: \"profile/profile-projects/profile-projects.html\",\n scope: {\n user: \"=\"\n },\n link: link,\n bindToController: true,\n controllerAs: \"vm\",\n controller: \"ProfileProjects\"\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileProjects\", ProfileProjectsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tab.directive.coffee\n */\n\n(function() {\n var ProfileTabDirective;\n\n ProfileTabDirective = function() {\n var link;\n link = function(scope, element, attrs, ctrl, transclude) {\n scope.tab = {};\n attrs.$observe(\"tgProfileTab\", function(name) {\n return scope.tab.name = name;\n });\n attrs.$observe(\"tabTitle\", function(title) {\n return scope.tab.title = title;\n });\n scope.tab.icon = attrs.tabIcon;\n scope.tab.active = !!attrs.tabActive;\n if (scope.$eval(attrs.tabDisabled) !== true) {\n return ctrl.addTab(scope.tab);\n }\n };\n return {\n templateUrl: \"profile/profile-tab/profile-tab.html\",\n scope: {},\n require: \"^tgProfileTabs\",\n link: link,\n transclude: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileTab\", ProfileTabDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tabs.controller.coffee\n */\n\n(function() {\n var ProfileTabsController;\n\n ProfileTabsController = (function() {\n function ProfileTabsController() {\n this.tabs = [];\n }\n\n ProfileTabsController.prototype.addTab = function(tab) {\n return this.tabs.push(tab);\n };\n\n ProfileTabsController.prototype.toggleTab = function(tab) {\n _.map(this.tabs, function(tab) {\n return tab.active = false;\n });\n return tab.active = true;\n };\n\n return ProfileTabsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileTabs\", ProfileTabsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tabs.directive.coffee\n */\n\n(function() {\n var ProfileTabsDirective;\n\n ProfileTabsDirective = function() {\n return {\n scope: {},\n controller: \"ProfileTabs\",\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-tabs/profile-tabs.html\",\n transclude: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileTabs\", ProfileTabsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile.controller.coffee\n */\n\n(function() {\n var ProfileController;\n\n ProfileController = (function() {\n ProfileController.$inject = [\"tgAppMetaService\", \"tgCurrentUserService\", \"$routeParams\", \"tgUserService\", \"tgXhrErrorService\", \"$translate\"];\n\n function ProfileController(appMetaService, currentUserService, routeParams, userService, xhrError, translate) {\n this.appMetaService = appMetaService;\n this.currentUserService = currentUserService;\n this.routeParams = routeParams;\n this.userService = userService;\n this.xhrError = xhrError;\n this.translate = translate;\n this.isCurrentUser = false;\n if (this.routeParams.slug) {\n this.userService.getUserByUserName(this.routeParams.slug).then((function(_this) {\n return function(user) {\n if (!user.get('is_active')) {\n return _this.xhrError.notFound();\n } else {\n _this.user = user;\n _this.isCurrentUser = false;\n _this._setMeta(_this.user);\n return user;\n }\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n return _this.xhrError.response(xhr);\n };\n })(this));\n } else {\n this.user = this.currentUserService.getUser();\n this.isCurrentUser = true;\n this._setMeta(this.user);\n }\n }\n\n ProfileController.prototype._setMeta = function(user) {\n var ctx, description, title;\n ctx = {\n userFullName: user.get(\"full_name_display\"),\n userUsername: user.get(\"username\")\n };\n title = this.translate.instant(\"USER.PROFILE.PAGE_TITLE\", ctx);\n description = user.get(\"bio\");\n return this.appMetaService.setAll(title, description);\n };\n\n return ProfileController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"Profile\", ProfileController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.controller.coffee\n */\n\n(function() {\n var LikeProjectButtonController;\n\n LikeProjectButtonController = (function() {\n LikeProjectButtonController.$inject = [\"$tgConfirm\", \"tgLikeProjectButtonService\"];\n\n function LikeProjectButtonController(confirm, likeButtonService) {\n this.confirm = confirm;\n this.likeButtonService = likeButtonService;\n this.isMouseOver = false;\n this.loading = false;\n }\n\n LikeProjectButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n LikeProjectButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n LikeProjectButtonController.prototype.toggleLike = function() {\n var promise;\n this.loading = true;\n if (!this.project.get(\"is_fan\")) {\n promise = this._like();\n } else {\n promise = this._unlike();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n LikeProjectButtonController.prototype._like = function() {\n return this.likeButtonService.like(this.project.get('id')).then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n };\n\n LikeProjectButtonController.prototype._unlike = function() {\n return this.likeButtonService.unlike(this.project.get('id'))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n };\n\n return LikeProjectButtonController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"LikeProjectButton\", LikeProjectButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.directive.coffee\n */\n\n(function() {\n var LikeProjectButtonDirective;\n\n LikeProjectButtonDirective = function() {\n return {\n scope: {},\n controller: \"LikeProjectButton\",\n bindToController: {\n project: '='\n },\n controllerAs: \"vm\",\n templateUrl: \"projects/components/like-project-button/like-project-button.html\"\n };\n };\n\n angular.module(\"taigaProjects\").directive(\"tgLikeProjectButton\", LikeProjectButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.service.coffee\n */\n\n(function() {\n var LikeProjectButtonService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n LikeProjectButtonService = (function(superClass) {\n extend(LikeProjectButtonService, superClass);\n\n LikeProjectButtonService.$inject = [\"tgResources\", \"tgCurrentUserService\", \"tgProjectService\"];\n\n function LikeProjectButtonService(rs, currentUserService, projectService) {\n this.rs = rs;\n this.currentUserService = currentUserService;\n this.projectService = projectService;\n }\n\n LikeProjectButtonService.prototype._getProjectIndex = function(projectId) {\n return this.currentUserService.projects.get('all').findIndex(function(project) {\n return project.get('id') === projectId;\n });\n };\n\n LikeProjectButtonService.prototype._updateProjects = function(projectId, isFan) {\n var projectIndex, projects;\n projectIndex = this._getProjectIndex(projectId);\n if (projectIndex === -1) {\n return;\n }\n projects = this.currentUserService.projects.get('all').update(projectIndex, function(project) {\n var totalFans;\n totalFans = project.get(\"total_fans\");\n if (isFan) {\n totalFans++;\n } else {\n totalFans--;\n }\n return project.merge({\n is_fan: isFan,\n total_fans: totalFans\n });\n });\n return this.currentUserService.setProjects(projects);\n };\n\n LikeProjectButtonService.prototype._updateCurrentProject = function(isFan) {\n var project, totalFans;\n totalFans = this.projectService.project.get(\"total_fans\");\n if (isFan) {\n totalFans++;\n } else {\n totalFans--;\n }\n project = this.projectService.project.merge({\n is_fan: isFan,\n total_fans: totalFans\n });\n return this.projectService.setProject(project);\n };\n\n LikeProjectButtonService.prototype.like = function(projectId) {\n return this.rs.projects.likeProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, true);\n return _this._updateCurrentProject(true);\n };\n })(this));\n };\n\n LikeProjectButtonService.prototype.unlike = function(projectId) {\n return this.rs.projects.unlikeProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, false);\n return _this._updateCurrentProject(false);\n };\n })(this));\n };\n\n return LikeProjectButtonService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgLikeProjectButtonService\", LikeProjectButtonService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: sort-projects.directive.coffee\n */\n\n(function() {\n var SortProjectsDirective;\n\n SortProjectsDirective = function(currentUserService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n var itemEl;\n itemEl = null;\n el.sortable({\n dropOnEmpty: true,\n revert: 200,\n axis: \"y\",\n opacity: .95,\n placeholder: 'placeholder',\n cancel: '.project-name'\n });\n return el.on(\"sortstop\", function(event, ui) {\n var i, index, len, project, sortData, sorted_project_ids, value;\n itemEl = ui.item;\n project = itemEl.scope().project;\n index = itemEl.index();\n sorted_project_ids = _.map(scope.projects.toJS(), function(p) {\n return p.id;\n });\n sorted_project_ids = _.without(sorted_project_ids, project.get(\"id\"));\n sorted_project_ids.splice(index, 0, project.get('id'));\n sortData = [];\n for (index = i = 0, len = sorted_project_ids.length; i < len; index = ++i) {\n value = sorted_project_ids[index];\n sortData.push({\n \"project_id\": value,\n \"order\": index\n });\n }\n return currentUserService.bulkUpdateProjectsOrder(sortData);\n });\n };\n directive = {\n scope: {\n projects: \"=tgSortProjects\"\n },\n link: link\n };\n return directive;\n };\n\n angular.module(\"taigaProjects\").directive(\"tgSortProjects\", [\"tgCurrentUserService\", SortProjectsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.controller.coffee\n */\n\n(function() {\n var WatchProjectButtonController;\n\n WatchProjectButtonController = (function() {\n WatchProjectButtonController.$inject = [\"$tgConfirm\", \"tgWatchProjectButtonService\"];\n\n function WatchProjectButtonController(confirm, watchButtonService) {\n this.confirm = confirm;\n this.watchButtonService = watchButtonService;\n this.showWatchOptions = false;\n this.loading = false;\n }\n\n WatchProjectButtonController.prototype.toggleWatcherOptions = function() {\n return this.showWatchOptions = !this.showWatchOptions;\n };\n\n WatchProjectButtonController.prototype.closeWatcherOptions = function() {\n return this.showWatchOptions = false;\n };\n\n WatchProjectButtonController.prototype.watch = function(notifyLevel) {\n if (notifyLevel === this.project.get('notify_level')) {\n return;\n }\n this.loading = true;\n this.closeWatcherOptions();\n return this.watchButtonService.watch(this.project.get('id'), notifyLevel)[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this))[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n WatchProjectButtonController.prototype.unwatch = function() {\n this.loading = true;\n this.closeWatcherOptions();\n return this.watchButtonService.unwatch(this.project.get('id'))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this))[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n return WatchProjectButtonController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"WatchProjectButton\", WatchProjectButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.directive.coffee\n */\n\n(function() {\n var WatchProjectButtonDirective;\n\n WatchProjectButtonDirective = function() {\n return {\n scope: {},\n controller: \"WatchProjectButton\",\n bindToController: {\n project: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: \"projects/components/watch-project-button/watch-project-button.html\"\n };\n };\n\n angular.module(\"taigaProjects\").directive(\"tgWatchProjectButton\", WatchProjectButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.service.coffee\n */\n\n(function() {\n var WatchProjectButtonService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n WatchProjectButtonService = (function(superClass) {\n extend(WatchProjectButtonService, superClass);\n\n WatchProjectButtonService.$inject = [\"tgResources\", \"tgCurrentUserService\", \"tgProjectService\"];\n\n function WatchProjectButtonService(rs, currentUserService, projectService) {\n this.rs = rs;\n this.currentUserService = currentUserService;\n this.projectService = projectService;\n }\n\n WatchProjectButtonService.prototype._getProjectIndex = function(projectId) {\n return this.currentUserService.projects.get('all').findIndex(function(project) {\n return project.get('id') === projectId;\n });\n };\n\n WatchProjectButtonService.prototype._updateProjects = function(projectId, notifyLevel, isWatcher) {\n var projectIndex, projects;\n projectIndex = this._getProjectIndex(projectId);\n if (projectIndex === -1) {\n return;\n }\n projects = this.currentUserService.projects.get('all').update(projectIndex, (function(_this) {\n return function(project) {\n var totalWatchers;\n totalWatchers = project.get('total_watchers');\n if (!_this.projectService.project.get('is_watcher') && isWatcher) {\n totalWatchers++;\n } else if (_this.projectService.project.get('is_watcher') && !isWatcher) {\n totalWatchers--;\n }\n return project.merge({\n is_watcher: isWatcher,\n total_watchers: totalWatchers,\n notify_level: notifyLevel\n });\n };\n })(this));\n return this.currentUserService.setProjects(projects);\n };\n\n WatchProjectButtonService.prototype._updateCurrentProject = function(notifyLevel, isWatcher) {\n var project, totalWatchers;\n totalWatchers = this.projectService.project.get(\"total_watchers\");\n if (!this.projectService.project.get('is_watcher') && isWatcher) {\n totalWatchers++;\n } else if (this.projectService.project.get('is_watcher') && !isWatcher) {\n totalWatchers--;\n }\n project = this.projectService.project.merge({\n is_watcher: isWatcher,\n notify_level: notifyLevel,\n total_watchers: totalWatchers\n });\n return this.projectService.setProject(project);\n };\n\n WatchProjectButtonService.prototype.watch = function(projectId, notifyLevel) {\n return this.rs.projects.watchProject(projectId, notifyLevel).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, notifyLevel, true);\n return _this._updateCurrentProject(notifyLevel, true);\n };\n })(this));\n };\n\n WatchProjectButtonService.prototype.unwatch = function(projectId) {\n return this.rs.projects.unwatchProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, null, false);\n return _this._updateCurrentProject(null, false);\n };\n })(this));\n };\n\n return WatchProjectButtonService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgWatchProjectButtonService\", WatchProjectButtonService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects-listing.controller.coffee\n */\n\n(function() {\n var ProjectsListingController;\n\n ProjectsListingController = (function() {\n ProjectsListingController.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n function ProjectsListingController(currentUserService, projectsService) {\n this.currentUserService = currentUserService;\n this.projectsService = projectsService;\n taiga.defineImmutableProperty(this, \"projects\", (function(_this) {\n return function() {\n return _this.currentUserService.projects.get(\"all\");\n };\n })(this));\n }\n\n ProjectsListingController.prototype.newProject = function() {\n return this.projectsService.newProject();\n };\n\n return ProjectsListingController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"ProjectsListing\", ProjectsListingController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project.controller.coffee\n */\n\n(function() {\n var ProjectController;\n\n ProjectController = (function() {\n ProjectController.$inject = [\"$routeParams\", \"tgAppMetaService\", \"$tgAuth\", \"$translate\", \"tgProjectService\"];\n\n function ProjectController(routeParams, appMetaService, auth, translate, projectService) {\n var projectSlug;\n this.routeParams = routeParams;\n this.appMetaService = appMetaService;\n this.auth = auth;\n this.translate = translate;\n this.projectService = projectService;\n projectSlug = this.routeParams.pslug;\n this.user = this.auth.userData;\n taiga.defineImmutableProperty(this, \"project\", (function(_this) {\n return function() {\n return _this.projectService.project;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"members\", (function(_this) {\n return function() {\n return _this.projectService.activeMembers;\n };\n })(this));\n this.appMetaService.setfn(this._setMeta.bind(this));\n }\n\n ProjectController.prototype._setMeta = function(project) {\n var ctx, metas;\n if (!this.project) {\n return null;\n }\n metas = {};\n ctx = {\n projectName: this.project.get(\"name\")\n };\n metas.title = this.translate.instant(\"PROJECT.PAGE_TITLE\", ctx);\n metas.description = this.project.get(\"description\");\n return metas;\n };\n\n return ProjectController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"Project\", ProjectController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects.service.coffee\n */\n\n(function() {\n var ProjectsService, groupBy, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n ProjectsService = (function(superClass) {\n extend(ProjectsService, superClass);\n\n ProjectsService.$inject = [\"tgResources\", \"$projectUrl\", \"tgLightboxFactory\"];\n\n function ProjectsService(rs, projectUrl, lightboxFactory) {\n this.rs = rs;\n this.projectUrl = projectUrl;\n this.lightboxFactory = lightboxFactory;\n }\n\n ProjectsService.prototype.getProjectBySlug = function(projectSlug) {\n return this.rs.projects.getProjectBySlug(projectSlug).then((function(_this) {\n return function(project) {\n return _this._decorate(project);\n };\n })(this));\n };\n\n ProjectsService.prototype.getProjectStats = function(projectId) {\n return this.rs.projects.getProjectStats(projectId);\n };\n\n ProjectsService.prototype.getProjectsByUserId = function(userId, paginate) {\n return this.rs.projects.getProjectsByUserId(userId, paginate).then((function(_this) {\n return function(projects) {\n return projects.map(_this._decorate.bind(_this));\n };\n })(this));\n };\n\n ProjectsService.prototype._decorate = function(project) {\n var colorized_tags, tags, url;\n url = this.projectUrl.get(project.toJS());\n project = project.set(\"url\", url);\n colorized_tags = [];\n if (project.get(\"tags\")) {\n tags = project.get(\"tags\").sort();\n colorized_tags = tags.map(function(tag) {\n var color;\n color = project.get(\"tags_colors\").get(tag);\n return Immutable.fromJS({\n name: tag,\n color: color\n });\n });\n project = project.set(\"colorized_tags\", colorized_tags);\n }\n return project;\n };\n\n ProjectsService.prototype.newProject = function() {\n return this.lightboxFactory.create(\"tg-lb-create-project\", {\n \"class\": \"wizard-create-project\"\n });\n };\n\n ProjectsService.prototype.bulkUpdateProjectsOrder = function(sortData) {\n return this.rs.projects.bulkUpdateOrder(sortData);\n };\n\n return ProjectsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgProjectsService\", ProjectsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-resource.service.coffee\n */\n\n(function() {\n var Resource, module, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n Resource = function(urlsService, http, config, $rootScope, $q, storage) {\n var service;\n service = {};\n service.list = function(type, objectId, projectId) {\n var httpOptions, params, url, urlname;\n urlname = \"attachments/\" + type;\n params = {\n object_id: objectId,\n project: projectId\n };\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n url = urlsService.resolve(urlname);\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service[\"delete\"] = function(type, id) {\n var url, urlname;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname) + (\"/\" + id);\n return http[\"delete\"](url);\n };\n service.patch = function(type, id, patch) {\n var url, urlname;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname) + (\"/\" + id);\n return http.patch(url, patch);\n };\n service.create = function(type, projectId, objectId, file) {\n var data, defered, maxFileSize, response, token, uploadComplete, uploadFailed, uploadProgress, url, urlname, xhr;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname);\n defered = $q.defer();\n if (file === void 0) {\n defered.reject(null);\n return defered.promise;\n }\n maxFileSize = config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered.reject(response);\n return defered.promise;\n }\n uploadProgress = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"in-progress\";\n file.size = sizeFormat(evt.total);\n file.progressMessage = \"upload \" + (sizeFormat(evt.loaded)) + \" of \" + (sizeFormat(evt.total));\n return file.progressPercent = (Math.round((evt.loaded / evt.total) * 100)) + \"%\";\n });\n };\n })(this);\n uploadComplete = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n var attachment, error, ref, status;\n file.status = \"done\";\n status = evt.target.status;\n try {\n attachment = JSON.parse(evt.target.responseText);\n } catch (error) {\n attachment = {};\n }\n if (status >= 200 && status < 400) {\n attachment = Immutable.fromJS(attachment);\n return defered.resolve(attachment);\n } else {\n response = {\n status: status,\n data: {\n _error_message: (ref = data['attached_file']) != null ? ref[0] : void 0\n }\n };\n return defered.reject(response);\n }\n });\n };\n })(this);\n uploadFailed = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"error\";\n return defered.reject(\"fail\");\n });\n };\n })(this);\n data = new FormData();\n data.append(\"project\", projectId);\n data.append(\"object_id\", objectId);\n data.append(\"attached_file\", file);\n xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.addEventListener(\"load\", uploadComplete, false);\n xhr.addEventListener(\"error\", uploadFailed, false);\n token = storage.get('token');\n xhr.open(\"POST\", url);\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send(data);\n return defered.promise;\n };\n return function() {\n return {\n \"attachments\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"$tgConfig\", \"$rootScope\", \"$q\", \"$tgStorage\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgAttachmentsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-apps-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.getApplicationToken = function(applicationId, state) {\n var url;\n url = urlsService.resolve(\"applications\");\n url = url + \"/\" + applicationId + \"/token?state=\" + state;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.authorizeApplicationToken = function(applicationId, state) {\n var data, url;\n url = urlsService.resolve(\"application-tokens\");\n url = url + \"/authorize\";\n data = {\n \"state\": state,\n \"application\": applicationId\n };\n return http.post(url, data).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"externalapps\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgExternalAppsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: issues-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"issues\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"issues\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgIssuesResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects-resource.service.coffee\n */\n\n(function() {\n var Resource, module, pagination;\n\n pagination = function() {};\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getProjects = function(params, pagination) {\n var httpOptions, url;\n if (params == null) {\n params = {};\n }\n if (pagination == null) {\n pagination = true;\n }\n url = urlsService.resolve(\"projects\");\n httpOptions = {};\n if (!pagination) {\n httpOptions = {\n headers: {\n \"x-lazy-pagination\": true\n }\n };\n }\n return http.get(url, params, httpOptions);\n };\n service.getProjectBySlug = function(projectSlug) {\n var url;\n url = urlsService.resolve(\"projects\");\n url = url + \"/by_slug?slug=\" + projectSlug;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getProjectsByUserId = function(userId, paginate) {\n var httpOptions, params, url;\n if (paginate == null) {\n paginate = false;\n }\n url = urlsService.resolve(\"projects\");\n httpOptions = {};\n if (!paginate) {\n httpOptions.headers = {\n \"x-disable-pagination\": \"1\"\n };\n }\n params = {\n \"member\": userId,\n \"order_by\": \"memberships__user_order\"\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getProjectStats = function(projectId) {\n var url;\n url = urlsService.resolve(\"projects\");\n url = url + \"/\" + projectId;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.bulkUpdateOrder = function(bulkData) {\n var url;\n url = urlsService.resolve(\"bulk-update-projects-order\");\n return http.post(url, bulkData);\n };\n service.getTimeline = function(projectId, page) {\n var params, url;\n params = {\n page: page,\n only_relevant: true\n };\n url = urlsService.resolve(\"timeline-project\");\n url = url + \"/\" + projectId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.likeProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-like\", projectId);\n return http.post(url);\n };\n service.unlikeProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-unlike\", projectId);\n return http.post(url);\n };\n service.watchProject = function(projectId, notifyLevel) {\n var data, url;\n data = {\n notify_level: notifyLevel\n };\n url = urlsService.resolve(\"project-watch\", projectId);\n return http.post(url, data);\n };\n service.unwatchProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-unwatch\", projectId);\n return http.post(url);\n };\n return function() {\n return {\n \"projects\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"tgPaginateResponseService\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgProjectsResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: resources.coffee\n */\n\n(function() {\n var Resources, services;\n\n services = [\"tgProjectsResources\", \"tgUserResources\", \"tgUsersResources\", \"tgUserstoriesResource\", \"tgTasksResource\", \"tgIssuesResource\", \"tgExternalAppsResource\", \"tgAttachmentsResource\", \"tgStatsResource\"];\n\n Resources = function($injector) {\n var i, j, len, len1, ref, service, serviceFn, serviceName, serviceProperty;\n for (i = 0, len = services.length; i < len; i++) {\n serviceName = services[i];\n serviceFn = $injector.get(serviceName);\n service = $injector.invoke(serviceFn);\n ref = Object.keys(service);\n for (j = 0, len1 = ref.length; j < len1; j++) {\n serviceProperty = ref[j];\n if (this[serviceProperty]) {\n console.warm(\"repeated resource \" + serviceProperty);\n }\n this[serviceProperty] = service[serviceProperty];\n }\n }\n return this;\n };\n\n Resources.$inject = [\"$injector\"];\n\n angular.module(\"taigaResources2\").service(\"tgResources\", Resources);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: stats-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.discover = function(applicationId, state) {\n var url;\n url = urlsService.resolve(\"stats-discover\");\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"stats\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgStatsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: tasks-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"tasks\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"tasks\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgTasksResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getUserStorage = function(key) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-storage\");\n if (key) {\n url += '/' + key;\n }\n httpOptions = {};\n return http.get(url, {}).then(function(response) {\n return response.data.value;\n });\n };\n service.setUserStorage = function(key, value) {\n var params, url;\n url = urlsService.resolve(\"user-storage\") + '/' + key;\n params = {\n key: key,\n value: value\n };\n return http.put(url, params);\n };\n service.createUserStorage = function(key, value) {\n var params, url;\n url = urlsService.resolve(\"user-storage\");\n params = {\n key: key,\n value: value\n };\n return http.post(url, params);\n };\n return function() {\n return {\n \"user\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUserResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: users-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getUserByUsername = function(username) {\n var httpOptions, params, url;\n url = urlsService.resolve(\"by_username\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n params = {\n username: username\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getStats = function(userId) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-stats\", userId);\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, {}, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getContacts = function(userId) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-contacts\", userId);\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, {}, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getLiked = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-liked\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n params.only_relevant = true;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getVoted = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-voted\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getWatched = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-watched\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getProfileTimeline = function(userId, page) {\n var params, url;\n params = {\n page: page\n };\n url = urlsService.resolve(\"timeline-profile\");\n url = url + \"/\" + userId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getUserTimeline = function(userId, page) {\n var params, url;\n params = {\n page: page,\n only_relevant: true\n };\n url = urlsService.resolve(\"timeline-user\");\n url = url + \"/\" + userId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n return function() {\n return {\n \"users\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"tgPaginateResponseService\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUsersResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: userstories-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"userstories\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"userstories\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUserstoriesResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: app-meta.service.coffee\n */\n\n(function() {\n var AppMetaService, taiga, truncate;\n\n taiga = this.taiga;\n\n truncate = taiga.truncate;\n\n AppMetaService = (function() {\n AppMetaService.$inject = [\"$rootScope\"];\n\n function AppMetaService(rootScope) {\n this.rootScope = rootScope;\n }\n\n AppMetaService.prototype._set = function(key, value) {\n var meta;\n if (!key) {\n return;\n }\n if (key === \"title\") {\n meta = $(\"title\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.text(value || \"\");\n } else if (key.indexOf(\"og:\") === 0) {\n meta = $(\"meta[property='\" + key + \"']\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.attr(\"content\", value || \"\");\n } else {\n meta = $(\"meta[name='\" + key + \"']\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.attr(\"content\", value || \"\");\n }\n };\n\n AppMetaService.prototype.setTitle = function(title) {\n return this._set('title', title);\n };\n\n AppMetaService.prototype.setDescription = function(description) {\n return this._set(\"description\", truncate(description, 250));\n };\n\n AppMetaService.prototype.setTwitterMetas = function(title, description) {\n this._set(\"twitter:card\", \"summary\");\n this._set(\"twitter:site\", \"@taigaio\");\n this._set(\"twitter:title\", title);\n this._set(\"twitter:description\", truncate(description, 300));\n return this._set(\"twitter:image\", window.location.origin + \"/\" + window._version + \"/images/logo-color.png\");\n };\n\n AppMetaService.prototype.setOpenGraphMetas = function(title, description) {\n this._set(\"og:type\", \"object\");\n this._set(\"og:site_name\", \"Taiga - Love your projects\");\n this._set(\"og:title\", title);\n this._set(\"og:description\", truncate(description, 300));\n this._set(\"og:image\", window.location.origin + \"/\" + window._version + \"/images/logo-color.png\");\n return this._set(\"og:url\", window.location.href);\n };\n\n AppMetaService.prototype.setAll = function(title, description) {\n this.setTitle(title);\n this.setDescription(description);\n this.setTwitterMetas(title, description);\n return this.setOpenGraphMetas(title, description);\n };\n\n AppMetaService.prototype.addMobileViewport = function() {\n return $(\"head\").append(\"\");\n };\n\n AppMetaService.prototype.removeMobileViewport = function() {\n return $(\"meta[name=\\\"viewport\\\"]\").remove();\n };\n\n AppMetaService.prototype.setfn = function(fn) {\n if (this.listener) {\n this._listener();\n }\n return this._listener = this.rootScope.$watchCollection(fn, (function(_this) {\n return function(metas) {\n if (metas) {\n _this.setAll(metas.title, metas.description);\n return _this._listener();\n }\n };\n })(this));\n };\n\n return AppMetaService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgAppMetaService\", AppMetaService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments.service.coffee\n */\n\n(function() {\n var AttachmentsService, sizeFormat;\n\n sizeFormat = this.taiga.sizeFormat;\n\n AttachmentsService = (function() {\n AttachmentsService.$inject = [\"$tgConfirm\", \"$tgConfig\", \"$translate\", \"tgResources\"];\n\n function AttachmentsService(confirm, config, translate, rs) {\n this.confirm = confirm;\n this.config = config;\n this.translate = translate;\n this.rs = rs;\n this.maxFileSize = this.getMaxFileSize();\n if (this.maxFileSize) {\n this.maxFileSizeFormated = sizeFormat(this.maxFileSize);\n }\n }\n\n AttachmentsService.prototype.sizeError = function(file) {\n var message;\n message = this.translate.instant(\"ATTACHMENT.ERROR_MAX_SIZE_EXCEEDED\", {\n fileName: file.name,\n fileSize: sizeFormat(file.size),\n maxFileSize: this.maxFileSizeFormated\n });\n return this.confirm.notify(\"error\", message);\n };\n\n AttachmentsService.prototype.validate = function(file) {\n if (this.maxFileSize && file.size > this.maxFileSize) {\n this.sizeError(file);\n return false;\n }\n return true;\n };\n\n AttachmentsService.prototype.getMaxFileSize = function() {\n return this.config.get(\"maxUploadFileSize\", null);\n };\n\n AttachmentsService.prototype.list = function(type, objId, projectId) {\n return this.rs.attachments.list(type, objId, projectId).then((function(_this) {\n return function(attachments) {\n return attachments.sortBy(function(attachment) {\n return attachment.get('order');\n });\n };\n })(this));\n };\n\n AttachmentsService.prototype[\"delete\"] = function(type, id) {\n return this.rs.attachments[\"delete\"](type, id);\n };\n\n AttachmentsService.prototype.saveError = function(file, data) {\n var message;\n message = \"\";\n if (file) {\n message = this.translate.instant(\"ATTACHMENT.ERROR_UPLOAD_ATTACHMENT\", {\n fileName: file.name,\n errorMessage: data.data._error_message\n });\n }\n return this.confirm.notify(\"error\", message);\n };\n\n AttachmentsService.prototype.upload = function(file, objId, projectId, type) {\n var promise;\n promise = this.rs.attachments.create(type, projectId, objId, file);\n promise.then(null, this.saveError.bind(this, file));\n return promise;\n };\n\n AttachmentsService.prototype.patch = function(id, type, patch) {\n var promise;\n promise = this.rs.attachments.patch(type, id, patch);\n promise.then(null, this.saveError.bind(this, null));\n return promise;\n };\n\n return AttachmentsService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgAttachmentsService\", AttachmentsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: check-permissions.service.coffee\n */\n\n(function() {\n var ChekcPermissionsService, taiga;\n\n taiga = this.taiga;\n\n ChekcPermissionsService = (function() {\n ChekcPermissionsService.$inject = [\"tgProjectService\"];\n\n function ChekcPermissionsService(projectService) {\n this.projectService = projectService;\n }\n\n ChekcPermissionsService.prototype.check = function(permission) {\n return this.projectService.project.get('my_permissions').indexOf(permission) !== -1;\n };\n\n return ChekcPermissionsService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgCheckPermissionsService\", ChekcPermissionsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: current-user.service.coffee\n */\n\n(function() {\n var CurrentUserService, groupBy, taiga;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n CurrentUserService = (function() {\n CurrentUserService.$inject = [\"tgProjectsService\", \"$tgStorage\", \"tgResources\"];\n\n function CurrentUserService(projectsService, storageService, rs) {\n this.projectsService = projectsService;\n this.storageService = storageService;\n this.rs = rs;\n this._user = null;\n this._projects = Immutable.Map();\n this._projectsById = Immutable.Map();\n this._joyride = null;\n taiga.defineImmutableProperty(this, \"projects\", (function(_this) {\n return function() {\n return _this._projects;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"projectsById\", (function(_this) {\n return function() {\n return _this._projectsById;\n };\n })(this));\n }\n\n CurrentUserService.prototype.isAuthenticated = function() {\n if (this.getUser() !== null) {\n return true;\n }\n return false;\n };\n\n CurrentUserService.prototype.getUser = function() {\n var userData;\n if (!this._user) {\n userData = this.storageService.get(\"userInfo\");\n if (userData) {\n userData = Immutable.fromJS(userData);\n this.setUser(userData);\n }\n }\n return this._user;\n };\n\n CurrentUserService.prototype.removeUser = function() {\n this._user = null;\n this._projects = Immutable.Map();\n this._projectsById = Immutable.Map();\n return this._joyride = null;\n };\n\n CurrentUserService.prototype.setUser = function(user) {\n this._user = user;\n return this._loadUserInfo();\n };\n\n CurrentUserService.prototype.bulkUpdateProjectsOrder = function(sortData) {\n return this.projectsService.bulkUpdateProjectsOrder(sortData).then((function(_this) {\n return function() {\n return _this.loadProjects();\n };\n })(this));\n };\n\n CurrentUserService.prototype.loadProjects = function() {\n return this.projectsService.getProjectsByUserId(this._user.get(\"id\")).then((function(_this) {\n return function(projects) {\n return _this.setProjects(projects);\n };\n })(this));\n };\n\n CurrentUserService.prototype.disableJoyRide = function(section) {\n if (section) {\n this._joyride[section] = false;\n } else {\n this._joyride = {\n backlog: false,\n kanban: false,\n dashboard: false\n };\n }\n return this.rs.user.setUserStorage('joyride', this._joyride);\n };\n\n CurrentUserService.prototype.loadJoyRideConfig = function() {\n return new Promise((function(_this) {\n return function(resolve) {\n if (_this._joyride !== null) {\n resolve(_this._joyride);\n return;\n }\n return _this.rs.user.getUserStorage('joyride').then(function(config) {\n _this._joyride = config;\n return resolve(_this._joyride);\n })[\"catch\"](function() {\n _this._joyride = {\n backlog: true,\n kanban: true,\n dashboard: true\n };\n _this.rs.user.createUserStorage('joyride', _this._joyride);\n return resolve(_this._joyride);\n });\n };\n })(this));\n };\n\n CurrentUserService.prototype._loadUserInfo = function() {\n return Promise.all([this.loadProjects()]);\n };\n\n CurrentUserService.prototype.setProjects = function(projects) {\n this._projects = this._projects.set(\"all\", projects);\n this._projects = this._projects.set(\"recents\", projects.slice(0, 10));\n this._projectsById = Immutable.fromJS(groupBy(projects.toJS(), function(p) {\n return p.id;\n }));\n return this.projects;\n };\n\n return CurrentUserService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgCurrentUserService\", CurrentUserService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: lightbox-factory.service.coffee\n */\n\n(function() {\n var LightboxFactory;\n\n LightboxFactory = (function() {\n LightboxFactory.$inject = [\"$rootScope\", \"$compile\"];\n\n function LightboxFactory(rootScope, compile) {\n this.rootScope = rootScope;\n this.compile = compile;\n }\n\n LightboxFactory.prototype.create = function(name, attrs, scopeAttrs) {\n var elm, html, scope;\n scope = this.rootScope.$new();\n scope = _.merge(scope, scopeAttrs);\n elm = $(\"
\").attr(name, true).attr(\"tg-bind-scope\", true);\n if (attrs) {\n elm.attr(attrs);\n }\n elm.addClass(\"remove-on-close\");\n html = this.compile(elm)(scope);\n $(document.body).append(html);\n };\n\n return LightboxFactory;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgLightboxFactory\", LightboxFactory);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: paginate-response.service.coffee\n */\n\n(function() {\n var PaginateResponse;\n\n PaginateResponse = function() {\n return function(result) {\n var paginateResponse;\n paginateResponse = Immutable.Map({\n \"data\": result.get(\"data\"),\n \"next\": !!result.get(\"headers\")(\"x-pagination-next\"),\n \"prev\": !!result.get(\"headers\")(\"x-pagination-prev\"),\n \"current\": result.get(\"headers\")(\"x-pagination-current\"),\n \"count\": result.get(\"headers\")(\"x-pagination-count\")\n });\n return paginateResponse;\n };\n };\n\n angular.module(\"taigaCommon\").factory(\"tgPaginateResponseService\", PaginateResponse);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project.service.coffee\n */\n\n(function() {\n var ProjectService, taiga;\n\n taiga = this.taiga;\n\n ProjectService = (function() {\n ProjectService.$inject = [\"tgProjectsService\", \"tgXhrErrorService\"];\n\n function ProjectService(projectsService, xhrError) {\n this.projectsService = projectsService;\n this.xhrError = xhrError;\n this._project = null;\n this._section = null;\n this._sectionsBreadcrumb = Immutable.List();\n this._activeMembers = Immutable.List();\n taiga.defineImmutableProperty(this, \"project\", (function(_this) {\n return function() {\n return _this._project;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"section\", (function(_this) {\n return function() {\n return _this._section;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"sectionsBreadcrumb\", (function(_this) {\n return function() {\n return _this._sectionsBreadcrumb;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"activeMembers\", (function(_this) {\n return function() {\n return _this._activeMembers;\n };\n })(this));\n }\n\n ProjectService.prototype.setSection = function(section) {\n this._section = section;\n if (section) {\n return this._sectionsBreadcrumb = this._sectionsBreadcrumb.push(this._section);\n } else {\n return this._sectionsBreadcrumb = Immutable.List();\n }\n };\n\n ProjectService.prototype.setProjectBySlug = function(pslug) {\n return new Promise((function(_this) {\n return function(resolve, reject) {\n if (!_this.project || _this.project.get('slug') !== pslug) {\n return _this.projectsService.getProjectBySlug(pslug).then(function(project) {\n _this.setProject(project);\n return resolve();\n })[\"catch\"](function(xhr) {\n return _this.xhrError.response(xhr);\n });\n } else {\n return resolve();\n }\n };\n })(this));\n };\n\n ProjectService.prototype.setProject = function(project) {\n this._project = project;\n return this._activeMembers = this._project.get('members').filter(function(member) {\n return member.get('is_active');\n });\n };\n\n ProjectService.prototype.cleanProject = function() {\n this._project = null;\n this._activeMembers = Immutable.List();\n this._section = null;\n return this._sectionsBreadcrumb = Immutable.List();\n };\n\n ProjectService.prototype.hasPermission = function(permission) {\n return this._project.get('my_permissions').indexOf(permission) !== -1;\n };\n\n ProjectService.prototype.fetchProject = function() {\n var pslug;\n pslug = this.project.get('slug');\n return this.projectsService.getProjectBySlug(pslug).then((function(_this) {\n return function(project) {\n return _this.setProject(project);\n };\n })(this));\n };\n\n return ProjectService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgProjectService\", ProjectService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: scope-event.service.coffee\n */\n\n(function() {\n var ScopeEvent;\n\n ScopeEvent = (function() {\n function ScopeEvent() {}\n\n ScopeEvent.prototype.scopes = {};\n\n ScopeEvent.prototype._searchDuplicatedScopes = function(id) {\n return _.find(Object.keys(this.scopes), (function(_this) {\n return function(key) {\n return _this.scopes[key].$id === id;\n };\n })(this));\n };\n\n ScopeEvent.prototype._create = function(name, scope) {\n var duplicatedScopeName;\n duplicatedScopeName = this._searchDuplicatedScopes(scope.$id);\n if (duplicatedScopeName) {\n throw new Error(\"scopeEvent: this scope is already register with the name \\\"\" + duplicatedScopeName + \"\\\"\");\n }\n if (this.scopes[name]) {\n throw new Error(\"scopeEvent: \\\"\" + name + \"\\\" already in use\");\n } else {\n scope._tgEmitter = new EventEmitter2();\n scope.$on(\"$destroy\", (function(_this) {\n return function() {\n scope._tgEmitter.removeAllListeners();\n return delete _this.scopes[name];\n };\n })(this));\n return this.scopes[name] = scope;\n }\n };\n\n ScopeEvent.prototype.emitter = function(name, scope) {\n if (scope) {\n scope = this._create(name, scope);\n } else if (this.scopes[name]) {\n scope = this.scopes[name];\n } else {\n throw new Error(\"scopeEvent: \\\"\" + name + \"\\\" scope doesn't exist'\");\n }\n return scope._tgEmitter;\n };\n\n return ScopeEvent;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgScopeEvent\", ScopeEvent);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: theme.service.coffee\n */\n\n(function() {\n var ThemeService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ThemeService = (function(superClass) {\n extend(ThemeService, superClass);\n\n function ThemeService() {\n return ThemeService.__super__.constructor.apply(this, arguments);\n }\n\n return ThemeService;\n\n })(taiga.Service = function() {\n return {\n use: function(themeName) {\n var stylesheetEl;\n stylesheetEl = $(\"link[rel='stylesheet']:first\");\n if (stylesheetEl.length === 0) {\n stylesheetEl = $(\"\");\n $(\"head\").append(stylesheetEl);\n }\n return stylesheetEl.attr(\"href\", \"/\" + window._version + \"/styles/theme-\" + themeName + \".css\");\n }\n };\n });\n\n angular.module(\"taigaCommon\").service(\"tgThemeService\", ThemeService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user.service.coffee\n */\n\n(function() {\n var UserService, bindMethods, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n bindMethods = taiga.bindMethods;\n\n UserService = (function(superClass) {\n extend(UserService, superClass);\n\n UserService.$inject = [\"tgResources\"];\n\n function UserService(rs) {\n this.rs = rs;\n bindMethods(this);\n }\n\n UserService.prototype.getUserByUserName = function(username) {\n return this.rs.users.getUserByUsername(username);\n };\n\n UserService.prototype.getContacts = function(userId) {\n return this.rs.users.getContacts(userId);\n };\n\n UserService.prototype.getLiked = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getLiked(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getVoted = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getVoted(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getWatched = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getWatched(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getStats = function(userId) {\n return this.rs.users.getStats(userId);\n };\n\n UserService.prototype.attachUserContactsToProjects = function(userId, projects) {\n return this.getContacts(userId).then(function(contacts) {\n projects = projects.map(function(project) {\n var contactsFiltered;\n contactsFiltered = contacts.filter(function(contact) {\n var contactId;\n contactId = contact.get(\"id\");\n return project.get('members').indexOf(contactId) !== -1;\n });\n project = project.set(\"contacts\", contactsFiltered);\n return project;\n });\n return projects;\n });\n };\n\n return UserService;\n\n })(taiga.Service);\n\n angular.module(\"taigaCommon\").service(\"tgUserService\", UserService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: xhrError.service.coffee\n */\n\n(function() {\n var xhrError,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n xhrError = (function(superClass) {\n extend(xhrError, superClass);\n\n xhrError.$inject = [\"$q\", \"$location\", \"$tgNavUrls\"];\n\n function xhrError(q, location, navUrls) {\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n }\n\n xhrError.prototype.notFound = function() {\n this.location.path(this.navUrls.resolve(\"not-found\"));\n return this.location.replace();\n };\n\n xhrError.prototype.permissionDenied = function() {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n return this.location.replace();\n };\n\n xhrError.prototype.response = function(xhr) {\n if (xhr) {\n if (xhr.status === 404) {\n this.notFound();\n } else if (xhr.status === 403) {\n this.permissionDenied();\n }\n }\n return this.q.reject(xhr);\n };\n\n return xhrError;\n\n })(taiga.Service);\n\n angular.module(\"taigaCommon\").service(\"tgXhrErrorService\", xhrError);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-attachment.directive.coffee\n */\n\n(function() {\n var UserTimelineAttachmentDirective;\n\n UserTimelineAttachmentDirective = function(template, $compile) {\n var isImage, link, validFileExtensions;\n validFileExtensions = [\".jpg\", \".jpeg\", \".bmp\", \".gif\", \".png\"];\n isImage = function(url) {\n url = url.toLowerCase();\n return _.some(validFileExtensions, function(extension) {\n return url.indexOf(extension, url - extension.length) !== -1;\n });\n };\n link = function(scope, el) {\n var is_image, templateHtml;\n is_image = isImage(scope.attachment.get('url'));\n if (is_image) {\n templateHtml = template.get(\"user-timeline/user-timeline-attachment/user-timeline-attachment-image.html\");\n } else {\n templateHtml = template.get(\"user-timeline/user-timeline-attachment/user-timeline-attachment.html\");\n }\n el.html(templateHtml);\n $compile(el.contents())(scope);\n return el.find(\"img\").error(function() {\n return this.remove();\n });\n };\n return {\n link: link,\n scope: {\n attachment: \"=tgUserTimelineAttachment\"\n }\n };\n };\n\n UserTimelineAttachmentDirective.$inject = [\"$tgTemplate\", \"$compile\"];\n\n angular.module(\"taigaUserTimeline\").directive(\"tgUserTimelineAttachment\", UserTimelineAttachmentDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item-title.service.coffee\n */\n\n(function() {\n var UserTimelineItemTitle, unslugify;\n\n unslugify = this.taiga.unslugify;\n\n UserTimelineItemTitle = (function() {\n UserTimelineItemTitle.$inject = [\"$translate\", \"$sce\"];\n\n UserTimelineItemTitle.prototype._fieldTranslationKey = {\n 'status': 'COMMON.FIELDS.STATUS',\n 'subject': 'COMMON.FIELDS.SUBJECT',\n 'description_diff': 'COMMON.FIELDS.DESCRIPTION',\n 'points': 'COMMON.FIELDS.POINTS',\n 'assigned_to': 'COMMON.FIELDS.ASSIGNED_TO',\n 'severity': 'ISSUES.FIELDS.SEVERITY',\n 'priority': 'ISSUES.FIELDS.PRIORITY',\n 'type': 'ISSUES.FIELDS.TYPE',\n 'is_iocaine': 'TASK.FIELDS.IS_IOCAINE',\n 'is_blocked': 'COMMON.FIELDS.IS_BLOCKED'\n };\n\n UserTimelineItemTitle.prototype._params = {\n username: function(timeline, event) {\n var title_attr, url, user;\n user = timeline.getIn(['data', 'user']);\n if (user.get('is_profile_visible')) {\n title_attr = this.translate.instant('COMMON.SEE_USER_PROFILE', {\n username: user.get('username')\n });\n url = \"user-profile:username=timeline.getIn(['data', 'user', 'username'])\";\n return this._getLink(url, user.get('name'), title_attr);\n } else {\n return this._getUsernameSpan(user.get('name'));\n }\n },\n field_name: function(timeline, event) {\n var field_name;\n field_name = timeline.getIn(['data', 'value_diff', 'key']);\n return this.translate.instant(this._fieldTranslationKey[field_name]);\n },\n project_name: function(timeline, event) {\n var url;\n url = \"project:project=timeline.getIn(['data', 'project', 'slug'])\";\n return this._getLink(url, timeline.getIn([\"data\", \"project\", \"name\"]));\n },\n new_value: function(timeline, event) {\n var new_value, value;\n if (_.isArray(timeline.getIn([\"data\", \"value_diff\", \"value\"]).toJS())) {\n value = timeline.getIn([\"data\", \"value_diff\", \"value\"]).get(1);\n if (value === null && timeline.getIn([\"data\", \"value_diff\", \"key\"]) === 'assigned_to') {\n value = this.translate.instant('ACTIVITY.VALUES.UNASSIGNED');\n }\n new_value = value;\n } else {\n new_value = timeline.getIn([\"data\", \"value_diff\", \"value\"]).first().get(1);\n }\n return _.escape(new_value);\n },\n sprint_name: function(timeline, event) {\n var url;\n url = \"project-taskboard:project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['data', 'milestone', 'slug'])\";\n return this._getLink(url, timeline.getIn(['data', 'milestone', 'name']));\n },\n us_name: function(timeline, event) {\n var event_us, obj, text, url;\n obj = this._getTimelineObj(timeline, event).get('userstory');\n event_us = {\n obj: 'parent_userstory'\n };\n url = this._getDetailObjUrl(event_us);\n text = '#' + obj.get('ref') + ' ' + obj.get('subject');\n return this._getLink(url, text);\n },\n obj_name: function(timeline, event) {\n var obj, text, url;\n obj = this._getTimelineObj(timeline, event);\n url = this._getDetailObjUrl(event);\n if (event.obj === 'wikipage') {\n text = unslugify(obj.get('slug'));\n } else if (event.obj === 'milestone') {\n text = obj.get('name');\n } else {\n text = '#' + obj.get('ref') + ' ' + obj.get('subject');\n }\n return this._getLink(url, text);\n },\n role_name: function(timeline, event) {\n return _.escape(timeline.getIn(['data', 'value_diff', 'value']).keySeq().first());\n }\n };\n\n function UserTimelineItemTitle(translate, sce) {\n this.translate = translate;\n this.sce = sce;\n }\n\n UserTimelineItemTitle.prototype._translateTitleParams = function(param, timeline, event) {\n return this._params[param].call(this, timeline, event);\n };\n\n UserTimelineItemTitle.prototype._getTimelineObj = function(timeline, event) {\n return timeline.getIn(['data', event.obj]);\n };\n\n UserTimelineItemTitle.prototype._getDetailObjUrl = function(event) {\n var url;\n url = {\n \"issue\": [\"project-issues-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"wikipage\": [\"project-wiki-page\", \":project=timeline.getIn(['data', 'project', 'slug']),slug=timeline.getIn(['obj', 'slug'])\"],\n \"task\": [\"project-tasks-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"userstory\": [\"project-userstories-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"parent_userstory\": [\"project-userstories-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'userstory', 'ref'])\"],\n \"milestone\": [\"project-taskboard\", \":project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['obj', 'slug'])\"]\n };\n return url[event.obj][0] + url[event.obj][1];\n };\n\n UserTimelineItemTitle.prototype._getLink = function(url, text, title) {\n title = title || text;\n return $('').attr('tg-nav', url).text(text).attr('title', title).prop('outerHTML');\n };\n\n UserTimelineItemTitle.prototype._getUsernameSpan = function(text) {\n var title;\n title = title || text;\n return $('').addClass('username').text(text).prop('outerHTML');\n };\n\n UserTimelineItemTitle.prototype._getParams = function(timeline, event, timeline_type) {\n var params;\n params = {};\n timeline_type.translate_params.forEach((function(_this) {\n return function(param) {\n return params[param] = _this._translateTitleParams(param, timeline, event);\n };\n })(this));\n return params;\n };\n\n UserTimelineItemTitle.prototype.getTitle = function(timeline, event, type) {\n var params, paramsKeys, translation;\n params = this._getParams(timeline, event, type);\n paramsKeys = {};\n Object.keys(params).forEach(function(key) {\n return paramsKeys[key] = '{{' + key + '}}';\n });\n translation = this.translate.instant(type.key, paramsKeys);\n Object.keys(params).forEach(function(key) {\n var find;\n find = '{{' + key + '}}';\n return translation = translation.replace(new RegExp(find, 'g'), params[key]);\n });\n return translation;\n };\n\n return UserTimelineItemTitle;\n\n })();\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineItemTitle\", UserTimelineItemTitle);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item-type.service.coffee\n */\n\n(function() {\n var UserTimelineType, timelineType;\n\n timelineType = function(timeline, event) {\n var types;\n types = [\n {\n check: function(timeline, event) {\n return event.obj === 'membership';\n },\n key: 'TIMELINE.NEW_MEMBER',\n translate_params: ['project_name'],\n member: function(timeline) {\n return Immutable.Map({\n user: timeline.getIn(['data', 'user']),\n role: timeline.getIn(['data', 'role'])\n });\n }\n }, {\n check: function(timeline, event) {\n return event.obj === 'project' && event.type === 'create';\n },\n key: 'TIMELINE.NEW_PROJECT',\n translate_params: ['username', 'project_name'],\n description: function(timeline) {\n return timeline.getIn(['data', 'project', 'description']);\n }\n }, {\n check: function(timeline, event) {\n return event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'attachments';\n },\n key: 'TIMELINE.UPLOAD_ATTACHMENT',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'create';\n },\n key: 'TIMELINE.US_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'create';\n },\n key: 'TIMELINE.ISSUE_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'wikipage' && event.type === 'create';\n },\n key: 'TIMELINE.WIKI_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'create' && !timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'create' && timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_CREATED_WITH_US',\n translate_params: ['username', 'project_name', 'obj_name', 'us_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'milestone' && event.type === 'create';\n },\n key: 'TIMELINE.MILESTONE_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'userstory';\n },\n key: 'TIMELINE.NEW_COMMENT_US',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'issue';\n },\n key: 'TIMELINE.NEW_COMMENT_ISSUE',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'task';\n },\n key: 'TIMELINE.NEW_COMMENT_TASK',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && timeline.hasIn(['data', 'value_diff', 'value', 'backlog_order']) && event.type === 'change';\n },\n key: 'TIMELINE.US_MOVED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && event.type === 'change' && event.obj === 'userstory') {\n return timeline.getIn(['data', 'value_diff', 'value', 'milestone']).get(1) === null;\n }\n return false;\n },\n key: 'TIMELINE.US_REMOVED_FROM_MILESTONE',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && event.type === 'change' && event.obj === 'userstory';\n },\n key: 'TIMELINE.US_ADDED_MILESTONE',\n translate_params: ['username', 'obj_name', 'sprint_name']\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'blocked' && event.type === 'change') {\n return timeline.getIn(['data', 'value_diff', 'value', 'is_blocked']).get(1) === true;\n }\n return false;\n },\n key: 'TIMELINE.BLOCKED',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n if (timeline.hasIn(['data', 'value_diff', 'value', 'blocked_note_html'])) {\n text = timeline.getIn(['data', 'value_diff', 'value', 'blocked_note_html']).get(1);\n return $($.parseHTML(text)).text();\n } else {\n return false;\n }\n }\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'blocked' && event.type === 'change') {\n return timeline.getIn(['data', 'value_diff', 'value', 'is_blocked']).get(1) === false;\n }\n return false;\n },\n key: 'TIMELINE.UNBLOCKED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'milestone' && event.type === 'change';\n },\n key: 'TIMELINE.MILESTONE_UPDATED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'wikipage' && event.type === 'change';\n },\n key: 'TIMELINE.WIKI_UPDATED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'points';\n },\n key: 'TIMELINE.US_UPDATED_POINTS',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value', 'role_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.US_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change';\n },\n key: 'TIMELINE.US_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.ISSUE_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'change';\n },\n key: 'TIMELINE.ISSUE_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && !timeline.getIn(['data', 'task', 'userstory']) && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.TASK_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && timeline.getIn(['data', 'task', 'userstory']) && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_US',\n translate_params: ['username', 'field_name', 'obj_name', 'us_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && !timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_US_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'us_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'user' && event.type === 'create';\n },\n key: 'TIMELINE.NEW_USER',\n translate_params: ['username']\n }\n ];\n return _.find(types, function(obj) {\n return obj.check(timeline, event);\n });\n };\n\n UserTimelineType = (function() {\n function UserTimelineType() {}\n\n UserTimelineType.prototype.getType = function(timeline, event) {\n return timelineType(timeline, event);\n };\n\n return UserTimelineType;\n\n })();\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineItemType\", UserTimelineType);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item.directive.coffee\n */\n\n(function() {\n var UserTimelineItemDirective;\n\n UserTimelineItemDirective = function() {\n return {\n templateUrl: \"user-timeline/user-timeline-item/user-timeline-item.html\",\n scope: {\n timeline: \"=tgUserTimelineItem\"\n }\n };\n };\n\n angular.module(\"taigaUserTimeline\").directive(\"tgUserTimelineItem\", UserTimelineItemDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-pagination-sequence.service.coffee\n */\n\n(function() {\n var UserTimelinePaginationSequence;\n\n UserTimelinePaginationSequence = function() {\n var obj;\n obj = {};\n obj.generate = function(config) {\n var getContent, items, next, page;\n page = 1;\n items = Immutable.List();\n config.minItems = config.minItems || 20;\n next = function() {\n items = Immutable.List();\n return getContent();\n };\n getContent = function() {\n return config.fetch(page).then(function(response) {\n var data;\n page++;\n data = response.get(\"data\");\n if (config.filter) {\n data = config.filter(data);\n }\n if (config.map) {\n data = data.map(config.map);\n }\n items = items.concat(data);\n if (items.size < config.minItems && response.get(\"next\")) {\n return getContent();\n }\n return Immutable.Map({\n items: items,\n next: response.get(\"next\")\n });\n });\n };\n return {\n next: function() {\n return next();\n }\n };\n };\n return obj;\n };\n\n angular.module(\"taigaUserTimeline\").factory(\"tgUserTimelinePaginationSequenceService\", UserTimelinePaginationSequence);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/profile/profile-timeline/profile-timeline.controller.coffee\n */\n\n(function() {\n var UserTimelineController, mixOf, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n UserTimelineController = (function(superClass) {\n extend(UserTimelineController, superClass);\n\n UserTimelineController.$inject = [\"tgUserTimelineService\"];\n\n function UserTimelineController(userTimelineService) {\n this.userTimelineService = userTimelineService;\n this.timelineList = Immutable.List();\n this.scrollDisabled = false;\n this.timeline = null;\n if (this.projectId) {\n this.timeline = this.userTimelineService.getProjectTimeline(this.projectId);\n } else if (this.currentUser) {\n this.timeline = this.userTimelineService.getProfileTimeline(this.user.get(\"id\"));\n } else {\n this.timeline = this.userTimelineService.getUserTimeline(this.user.get(\"id\"));\n }\n }\n\n UserTimelineController.prototype.loadTimeline = function() {\n this.scrollDisabled = true;\n return this.timeline.next().then((function(_this) {\n return function(response) {\n _this.timelineList = _this.timelineList.concat(response.get(\"items\"));\n if (response.get(\"next\")) {\n _this.scrollDisabled = false;\n }\n return _this.timelineList;\n };\n })(this));\n };\n\n return UserTimelineController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n angular.module(\"taigaUserTimeline\").controller(\"UserTimeline\", UserTimelineController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.directive.coffee\n */\n\n(function() {\n var UserTimelineDirective;\n\n UserTimelineDirective = function() {\n return {\n templateUrl: \"user-timeline/user-timeline/user-timeline.html\",\n controller: \"UserTimeline\",\n controllerAs: \"vm\",\n scope: {\n projectId: \"=projectid\",\n user: \"=\",\n currentUser: \"=\"\n },\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgUserTimeline\", UserTimelineDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.service.coffee\n */\n\n(function() {\n var UserTimelineService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n UserTimelineService = (function(superClass) {\n extend(UserTimelineService, superClass);\n\n UserTimelineService.$inject = [\"tgResources\", \"tgUserTimelinePaginationSequenceService\", \"tgUserTimelineItemType\", \"tgUserTimelineItemTitle\"];\n\n function UserTimelineService(rs, userTimelinePaginationSequenceService, userTimelineItemType, userTimelineItemTitle) {\n this.rs = rs;\n this.userTimelinePaginationSequenceService = userTimelinePaginationSequenceService;\n this.userTimelineItemType = userTimelineItemType;\n this.userTimelineItemTitle = userTimelineItemTitle;\n }\n\n UserTimelineService.prototype._valid_fields = ['status', 'subject', 'description_diff', 'assigned_to', 'points', 'severity', 'priority', 'type', 'attachments', 'is_iocaine', 'content_diff', 'name', 'estimated_finish', 'estimated_start', 'blocked', 'moveInBacklog', 'milestone'];\n\n UserTimelineService.prototype._invalid = [\n {\n check: function(timeline) {\n var fieldKey, value_diff;\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n if (value_diff) {\n fieldKey = value_diff.get('key');\n if (this._valid_fields.indexOf(fieldKey) === -1) {\n return true;\n } else if (fieldKey === 'attachments' && value_diff.get('value').get('new').size === 0) {\n return true;\n }\n }\n return false;\n }\n }, {\n check: function(timeline) {\n var event, value_diff;\n event = timeline.get('event_type').split(\".\");\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n return event[2] === 'change' && value_diff === void 0;\n }\n }, {\n check: function(timeline) {\n var event;\n event = timeline.get('event_type').split(\".\");\n return event[2] === 'delete';\n }\n }, {\n check: function(timeline) {\n var event;\n event = timeline.get('event_type').split(\".\");\n return event[1] === 'project' && event[2] === 'change';\n }\n }, {\n check: function(timeline) {\n return !!timeline.get(\"data\").get(\"comment_deleted\");\n }\n }, {\n check: function(timeline) {\n var event, value_diff;\n event = timeline.get('event_type').split(\".\");\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n if (value_diff && event[1] === \"task\" && event[2] === \"change\" && value_diff.get(\"key\") === \"milestone\") {\n return timeline.get(\"data\").get(\"value_diff\").get(\"value\");\n }\n return false;\n }\n }\n ];\n\n UserTimelineService.prototype._isInValidTimeline = function(timeline) {\n return _.some(this._invalid, (function(_this) {\n return function(invalid) {\n return invalid.check.call(_this, timeline);\n };\n })(this));\n };\n\n UserTimelineService.prototype._parseEventType = function(event_type) {\n event_type = event_type.split(\".\");\n return {\n section: event_type[0],\n obj: event_type[1],\n type: event_type[2]\n };\n };\n\n UserTimelineService.prototype._getTimelineObject = function(timeline, event) {\n if (timeline.get('data').get(event.obj)) {\n return timeline.get('data').get(event.obj);\n }\n };\n\n UserTimelineService.prototype._attachExtraInfoToTimelineEntry = function(timeline, event, type) {\n var title;\n title = this.userTimelineItemTitle.getTitle(timeline, event, type);\n timeline = timeline.set('title_html', title);\n timeline = timeline.set('obj', this._getTimelineObject(timeline, event));\n if (type.description) {\n timeline = timeline.set('description', type.description(timeline));\n }\n if (type.member) {\n timeline = timeline.set('member', type.member(timeline));\n }\n if (timeline.getIn(['data', 'value_diff', 'key']) === 'attachments' && timeline.hasIn(['data', 'value_diff', 'value', 'new'])) {\n timeline = timeline.set('attachments', timeline.getIn(['data', 'value_diff', 'value', 'new']));\n }\n return timeline;\n };\n\n UserTimelineService.prototype._parseTimeline = function(response) {\n var newdata;\n newdata = Immutable.List();\n response.get('data').forEach((function(_this) {\n return function(item) {\n var data, event, newItem, values_diff;\n event = _this._parseEventType(item.get('event_type'));\n data = item.get('data');\n values_diff = data.get('values_diff');\n if (values_diff && values_diff.count()) {\n if (values_diff.has('is_blocked')) {\n values_diff = Immutable.Map({\n 'blocked': values_diff\n });\n }\n if (values_diff.has('milestone')) {\n if (event.obj === 'userstory') {\n values_diff = Immutable.Map({\n 'moveInBacklog': values_diff\n });\n } else {\n values_diff = values_diff.deleteIn(['values_diff', 'milestone']);\n }\n } else if (event.obj === 'milestone') {\n values_diff = Immutable.Map({\n 'milestone': values_diff\n });\n }\n return values_diff.forEach(function(value, key) {\n var newItem, obj;\n obj = Immutable.Map({\n key: key,\n value: value\n });\n newItem = item.setIn(['data', 'value_diff'], obj);\n newItem = newItem.deleteIn(['data', 'values_diff']);\n return newdata = newdata.push(newItem);\n });\n } else {\n newItem = item.deleteIn(['data', 'values_diff']);\n return newdata = newdata.push(newItem);\n }\n };\n })(this));\n return response.set('data', newdata);\n };\n\n UserTimelineService.prototype._addEntyAttributes = function(item) {\n var event, type;\n event = this._parseEventType(item.get('event_type'));\n type = this.userTimelineItemType.getType(item, event);\n return this._attachExtraInfoToTimelineEntry(item, event, type);\n };\n\n UserTimelineService.prototype.getProfileTimeline = function(userId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.users.getProfileTimeline(userId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n UserTimelineService.prototype.getUserTimeline = function(userId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.users.getUserTimeline(userId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n UserTimelineService.prototype.getProjectTimeline = function(projectId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.projects.getTimeline(projectId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n return UserTimelineService;\n\n })(taiga.Service);\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineService\", UserTimelineService);\n\n}).call(this);\n\n//# sourceMappingURL=maps/app.js.map\n"]} \ No newline at end of file diff --git a/dist/v-1454069705160/fonts/OpenSans-Bold.ttf b/dist/v-1454071457968/fonts/OpenSans-Bold.ttf similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-Bold.ttf rename to dist/v-1454071457968/fonts/OpenSans-Bold.ttf diff --git a/dist/v-1454069705160/fonts/OpenSans-CondLight.eot b/dist/v-1454071457968/fonts/OpenSans-CondLight.eot similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-CondLight.eot rename to dist/v-1454071457968/fonts/OpenSans-CondLight.eot diff --git a/dist/v-1454069705160/fonts/OpenSans-CondLight.svg b/dist/v-1454071457968/fonts/OpenSans-CondLight.svg similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-CondLight.svg rename to dist/v-1454071457968/fonts/OpenSans-CondLight.svg diff --git a/dist/v-1454069705160/fonts/OpenSans-CondLight.ttf b/dist/v-1454071457968/fonts/OpenSans-CondLight.ttf similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-CondLight.ttf rename to dist/v-1454071457968/fonts/OpenSans-CondLight.ttf diff --git a/dist/v-1454069705160/fonts/OpenSans-CondLight.woff b/dist/v-1454071457968/fonts/OpenSans-CondLight.woff similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-CondLight.woff rename to dist/v-1454071457968/fonts/OpenSans-CondLight.woff diff --git a/dist/v-1454069705160/fonts/OpenSans-Light.ttf b/dist/v-1454071457968/fonts/OpenSans-Light.ttf similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-Light.ttf rename to dist/v-1454071457968/fonts/OpenSans-Light.ttf diff --git a/dist/v-1454069705160/fonts/OpenSans-Regular.ttf b/dist/v-1454071457968/fonts/OpenSans-Regular.ttf similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-Regular.ttf rename to dist/v-1454071457968/fonts/OpenSans-Regular.ttf diff --git a/dist/v-1454069705160/fonts/OpenSans-Semibold.ttf b/dist/v-1454071457968/fonts/OpenSans-Semibold.ttf similarity index 100% rename from dist/v-1454069705160/fonts/OpenSans-Semibold.ttf rename to dist/v-1454071457968/fonts/OpenSans-Semibold.ttf diff --git a/dist/v-1454069705160/fonts/taiga.eot b/dist/v-1454071457968/fonts/taiga.eot similarity index 100% rename from dist/v-1454069705160/fonts/taiga.eot rename to dist/v-1454071457968/fonts/taiga.eot diff --git a/dist/v-1454069705160/fonts/taiga.svg b/dist/v-1454071457968/fonts/taiga.svg similarity index 100% rename from dist/v-1454069705160/fonts/taiga.svg rename to dist/v-1454071457968/fonts/taiga.svg diff --git a/dist/v-1454069705160/fonts/taiga.ttf b/dist/v-1454071457968/fonts/taiga.ttf similarity index 100% rename from dist/v-1454069705160/fonts/taiga.ttf rename to dist/v-1454071457968/fonts/taiga.ttf diff --git a/dist/v-1454069705160/fonts/taiga.woff b/dist/v-1454071457968/fonts/taiga.woff similarity index 100% rename from dist/v-1454069705160/fonts/taiga.woff rename to dist/v-1454071457968/fonts/taiga.woff diff --git a/dist/v-1454069705160/images/attachment-gallery.png b/dist/v-1454071457968/images/attachment-gallery.png similarity index 100% rename from dist/v-1454069705160/images/attachment-gallery.png rename to dist/v-1454071457968/images/attachment-gallery.png diff --git a/dist/v-1454069705160/images/backlog-empty.png b/dist/v-1454071457968/images/backlog-empty.png similarity index 100% rename from dist/v-1454069705160/images/backlog-empty.png rename to dist/v-1454071457968/images/backlog-empty.png diff --git a/dist/v-1454069705160/images/beta.png b/dist/v-1454071457968/images/beta.png similarity index 100% rename from dist/v-1454069705160/images/beta.png rename to dist/v-1454071457968/images/beta.png diff --git a/dist/v-1454069705160/images/bg.png b/dist/v-1454071457968/images/bg.png similarity index 100% rename from dist/v-1454069705160/images/bg.png rename to dist/v-1454071457968/images/bg.png diff --git a/dist/v-1454069705160/images/discover.png b/dist/v-1454071457968/images/discover.png similarity index 100% rename from dist/v-1454069705160/images/discover.png rename to dist/v-1454071457968/images/discover.png diff --git a/dist/v-1454069705160/images/favicon.png b/dist/v-1454071457968/images/favicon.png similarity index 100% rename from dist/v-1454069705160/images/favicon.png rename to dist/v-1454071457968/images/favicon.png diff --git a/dist/v-1454069705160/images/invitation_bg.jpg b/dist/v-1454071457968/images/invitation_bg.jpg similarity index 100% rename from dist/v-1454069705160/images/invitation_bg.jpg rename to dist/v-1454071457968/images/invitation_bg.jpg diff --git a/dist/v-1454069705160/images/issues-empty.png b/dist/v-1454071457968/images/issues-empty.png similarity index 100% rename from dist/v-1454069705160/images/issues-empty.png rename to dist/v-1454071457968/images/issues-empty.png diff --git a/dist/v-1454069705160/images/logo-color.png b/dist/v-1454071457968/images/logo-color.png similarity index 100% rename from dist/v-1454069705160/images/logo-color.png rename to dist/v-1454071457968/images/logo-color.png diff --git a/dist/v-1454069705160/images/logo.png b/dist/v-1454071457968/images/logo.png similarity index 100% rename from dist/v-1454069705160/images/logo.png rename to dist/v-1454071457968/images/logo.png diff --git a/dist/v-1454069705160/images/looking-for-people.png b/dist/v-1454071457968/images/looking-for-people.png similarity index 100% rename from dist/v-1454069705160/images/looking-for-people.png rename to dist/v-1454071457968/images/looking-for-people.png diff --git a/dist/v-1454069705160/images/markitup/bg-container.png b/dist/v-1454071457968/images/markitup/bg-container.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-container.png rename to dist/v-1454071457968/images/markitup/bg-container.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-bbcode.png b/dist/v-1454071457968/images/markitup/bg-editor-bbcode.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-bbcode.png rename to dist/v-1454071457968/images/markitup/bg-editor-bbcode.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-dotclear.png b/dist/v-1454071457968/images/markitup/bg-editor-dotclear.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-dotclear.png rename to dist/v-1454071457968/images/markitup/bg-editor-dotclear.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-html.png b/dist/v-1454071457968/images/markitup/bg-editor-html.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-html.png rename to dist/v-1454071457968/images/markitup/bg-editor-html.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-json.png b/dist/v-1454071457968/images/markitup/bg-editor-json.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-json.png rename to dist/v-1454071457968/images/markitup/bg-editor-json.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-markdown.png b/dist/v-1454071457968/images/markitup/bg-editor-markdown.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-markdown.png rename to dist/v-1454071457968/images/markitup/bg-editor-markdown.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-textile.png b/dist/v-1454071457968/images/markitup/bg-editor-textile.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-textile.png rename to dist/v-1454071457968/images/markitup/bg-editor-textile.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-wiki.png b/dist/v-1454071457968/images/markitup/bg-editor-wiki.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-wiki.png rename to dist/v-1454071457968/images/markitup/bg-editor-wiki.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor-xml.png b/dist/v-1454071457968/images/markitup/bg-editor-xml.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor-xml.png rename to dist/v-1454071457968/images/markitup/bg-editor-xml.png diff --git a/dist/v-1454069705160/images/markitup/bg-editor.png b/dist/v-1454071457968/images/markitup/bg-editor.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bg-editor.png rename to dist/v-1454071457968/images/markitup/bg-editor.png diff --git a/dist/v-1454069705160/images/markitup/body.png b/dist/v-1454071457968/images/markitup/body.png similarity index 100% rename from dist/v-1454069705160/images/markitup/body.png rename to dist/v-1454071457968/images/markitup/body.png diff --git a/dist/v-1454069705160/images/markitup/bold.png b/dist/v-1454071457968/images/markitup/bold.png similarity index 100% rename from dist/v-1454069705160/images/markitup/bold.png rename to dist/v-1454071457968/images/markitup/bold.png diff --git a/dist/v-1454069705160/images/markitup/clean.png b/dist/v-1454071457968/images/markitup/clean.png similarity index 100% rename from dist/v-1454069705160/images/markitup/clean.png rename to dist/v-1454071457968/images/markitup/clean.png diff --git a/dist/v-1454069705160/images/markitup/code.png b/dist/v-1454071457968/images/markitup/code.png similarity index 100% rename from dist/v-1454069705160/images/markitup/code.png rename to dist/v-1454071457968/images/markitup/code.png diff --git a/dist/v-1454069705160/images/markitup/h1.png b/dist/v-1454071457968/images/markitup/h1.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h1.png rename to dist/v-1454071457968/images/markitup/h1.png diff --git a/dist/v-1454069705160/images/markitup/h2.png b/dist/v-1454071457968/images/markitup/h2.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h2.png rename to dist/v-1454071457968/images/markitup/h2.png diff --git a/dist/v-1454069705160/images/markitup/h3.png b/dist/v-1454071457968/images/markitup/h3.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h3.png rename to dist/v-1454071457968/images/markitup/h3.png diff --git a/dist/v-1454069705160/images/markitup/h4.png b/dist/v-1454071457968/images/markitup/h4.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h4.png rename to dist/v-1454071457968/images/markitup/h4.png diff --git a/dist/v-1454069705160/images/markitup/h5.png b/dist/v-1454071457968/images/markitup/h5.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h5.png rename to dist/v-1454071457968/images/markitup/h5.png diff --git a/dist/v-1454069705160/images/markitup/h6.png b/dist/v-1454071457968/images/markitup/h6.png similarity index 100% rename from dist/v-1454069705160/images/markitup/h6.png rename to dist/v-1454071457968/images/markitup/h6.png diff --git a/dist/v-1454069705160/images/markitup/handle.png b/dist/v-1454071457968/images/markitup/handle.png similarity index 100% rename from dist/v-1454069705160/images/markitup/handle.png rename to dist/v-1454071457968/images/markitup/handle.png diff --git a/dist/v-1454069705160/images/markitup/help.png b/dist/v-1454071457968/images/markitup/help.png similarity index 100% rename from dist/v-1454069705160/images/markitup/help.png rename to dist/v-1454071457968/images/markitup/help.png diff --git a/dist/v-1454069705160/images/markitup/image.png b/dist/v-1454071457968/images/markitup/image.png similarity index 100% rename from dist/v-1454069705160/images/markitup/image.png rename to dist/v-1454071457968/images/markitup/image.png diff --git a/dist/v-1454069705160/images/markitup/italic.png b/dist/v-1454071457968/images/markitup/italic.png similarity index 100% rename from dist/v-1454069705160/images/markitup/italic.png rename to dist/v-1454071457968/images/markitup/italic.png diff --git a/dist/v-1454069705160/images/markitup/jaysalvat.png b/dist/v-1454071457968/images/markitup/jaysalvat.png similarity index 100% rename from dist/v-1454069705160/images/markitup/jaysalvat.png rename to dist/v-1454071457968/images/markitup/jaysalvat.png diff --git a/dist/v-1454069705160/images/markitup/link.png b/dist/v-1454071457968/images/markitup/link.png similarity index 100% rename from dist/v-1454069705160/images/markitup/link.png rename to dist/v-1454071457968/images/markitup/link.png diff --git a/dist/v-1454069705160/images/markitup/list-bullet.png b/dist/v-1454071457968/images/markitup/list-bullet.png similarity index 100% rename from dist/v-1454069705160/images/markitup/list-bullet.png rename to dist/v-1454071457968/images/markitup/list-bullet.png diff --git a/dist/v-1454069705160/images/markitup/list-numeric.png b/dist/v-1454071457968/images/markitup/list-numeric.png similarity index 100% rename from dist/v-1454069705160/images/markitup/list-numeric.png rename to dist/v-1454071457968/images/markitup/list-numeric.png diff --git a/dist/v-1454069705160/images/markitup/markitup.png b/dist/v-1454071457968/images/markitup/markitup.png similarity index 100% rename from dist/v-1454069705160/images/markitup/markitup.png rename to dist/v-1454071457968/images/markitup/markitup.png diff --git a/dist/v-1454069705160/images/markitup/menu.png b/dist/v-1454071457968/images/markitup/menu.png similarity index 100% rename from dist/v-1454069705160/images/markitup/menu.png rename to dist/v-1454071457968/images/markitup/menu.png diff --git a/dist/v-1454069705160/images/markitup/picture.png b/dist/v-1454071457968/images/markitup/picture.png similarity index 100% rename from dist/v-1454069705160/images/markitup/picture.png rename to dist/v-1454071457968/images/markitup/picture.png diff --git a/dist/v-1454069705160/images/markitup/preview.png b/dist/v-1454071457968/images/markitup/preview.png similarity index 100% rename from dist/v-1454069705160/images/markitup/preview.png rename to dist/v-1454071457968/images/markitup/preview.png diff --git a/dist/v-1454069705160/images/markitup/preview_ico.png b/dist/v-1454071457968/images/markitup/preview_ico.png similarity index 100% rename from dist/v-1454069705160/images/markitup/preview_ico.png rename to dist/v-1454071457968/images/markitup/preview_ico.png diff --git a/dist/v-1454069705160/images/markitup/quotes.png b/dist/v-1454071457968/images/markitup/quotes.png similarity index 100% rename from dist/v-1454069705160/images/markitup/quotes.png rename to dist/v-1454071457968/images/markitup/quotes.png diff --git a/dist/v-1454069705160/images/markitup/stroke.png b/dist/v-1454071457968/images/markitup/stroke.png similarity index 100% rename from dist/v-1454069705160/images/markitup/stroke.png rename to dist/v-1454071457968/images/markitup/stroke.png diff --git a/dist/v-1454069705160/images/markitup/submenu.png b/dist/v-1454071457968/images/markitup/submenu.png similarity index 100% rename from dist/v-1454069705160/images/markitup/submenu.png rename to dist/v-1454071457968/images/markitup/submenu.png diff --git a/dist/v-1454069705160/images/menu-vert.png b/dist/v-1454071457968/images/menu-vert.png similarity index 100% rename from dist/v-1454069705160/images/menu-vert.png rename to dist/v-1454071457968/images/menu-vert.png diff --git a/dist/v-1454069705160/images/menu.png b/dist/v-1454071457968/images/menu.png similarity index 100% rename from dist/v-1454069705160/images/menu.png rename to dist/v-1454071457968/images/menu.png diff --git a/dist/v-1454069705160/images/notification-decoration.png b/dist/v-1454071457968/images/notification-decoration.png similarity index 100% rename from dist/v-1454069705160/images/notification-decoration.png rename to dist/v-1454071457968/images/notification-decoration.png diff --git a/dist/v-1454069705160/images/project-logos/project-logo-01.png b/dist/v-1454071457968/images/project-logos/project-logo-01.png similarity index 100% rename from dist/v-1454069705160/images/project-logos/project-logo-01.png rename to dist/v-1454071457968/images/project-logos/project-logo-01.png diff --git a/dist/v-1454069705160/images/project-logos/project-logo-02.png b/dist/v-1454071457968/images/project-logos/project-logo-02.png similarity index 100% rename from dist/v-1454069705160/images/project-logos/project-logo-02.png rename to dist/v-1454071457968/images/project-logos/project-logo-02.png diff --git a/dist/v-1454069705160/images/project-logos/project-logo-03.png b/dist/v-1454071457968/images/project-logos/project-logo-03.png similarity index 100% rename from dist/v-1454069705160/images/project-logos/project-logo-03.png rename to dist/v-1454071457968/images/project-logos/project-logo-03.png diff --git a/dist/v-1454069705160/images/project-logos/project-logo-04.png b/dist/v-1454071457968/images/project-logos/project-logo-04.png similarity index 100% rename from dist/v-1454069705160/images/project-logos/project-logo-04.png rename to dist/v-1454071457968/images/project-logos/project-logo-04.png diff --git a/dist/v-1454069705160/images/project-logos/project-logo-05.png b/dist/v-1454071457968/images/project-logos/project-logo-05.png similarity index 100% rename from dist/v-1454069705160/images/project-logos/project-logo-05.png rename to dist/v-1454071457968/images/project-logos/project-logo-05.png diff --git a/dist/v-1454069705160/images/quote.png b/dist/v-1454071457968/images/quote.png similarity index 100% rename from dist/v-1454069705160/images/quote.png rename to dist/v-1454071457968/images/quote.png diff --git a/dist/v-1454069705160/images/search-empty.png b/dist/v-1454071457968/images/search-empty.png similarity index 100% rename from dist/v-1454069705160/images/search-empty.png rename to dist/v-1454071457968/images/search-empty.png diff --git a/dist/v-1454069705160/images/sprint-empty.png b/dist/v-1454071457968/images/sprint-empty.png similarity index 100% rename from dist/v-1454069705160/images/sprint-empty.png rename to dist/v-1454071457968/images/sprint-empty.png diff --git a/dist/v-1454069705160/images/unnamed.png b/dist/v-1454071457968/images/unnamed.png similarity index 100% rename from dist/v-1454069705160/images/unnamed.png rename to dist/v-1454071457968/images/unnamed.png diff --git a/dist/v-1454069705160/images/user-noimage.png b/dist/v-1454071457968/images/user-noimage.png similarity index 100% rename from dist/v-1454069705160/images/user-noimage.png rename to dist/v-1454071457968/images/user-noimage.png diff --git a/dist/v-1454069705160/js/app-loader.js b/dist/v-1454071457968/js/app-loader.js similarity index 98% rename from dist/v-1454069705160/js/app-loader.js rename to dist/v-1454071457968/js/app-loader.js index cc8254b..17c931a 100644 --- a/dist/v-1454069705160/js/app-loader.js +++ b/dist/v-1454071457968/js/app-loader.js @@ -1,7 +1,7 @@ (function() { var loadPlugin, loadPlugins, loadStylesheet, promise; - window._version = "v-1454069705160"; + window._version = "v-1454071457968"; window.taigaConfig = { "api": "http://localhost:8000/api/v1/", diff --git a/dist/v-1454071457968/js/app.js b/dist/v-1454071457968/js/app.js new file mode 100644 index 0000000..beeffec --- /dev/null +++ b/dist/v-1454071457968/js/app.js @@ -0,0 +1,23 @@ +(function(){var configure,i18nInit,init,module,modules,pluginsWithModule,taiga;this.taiga=taiga={},this.taigaContribPlugins=this.taigaContribPlugins||window.taigaContribPlugins||[],taiga.generateHash=function(components){return null==components&&(components=[]),components=_.map(components,function(x){return JSON.stringify(x)}),hex_sha1(components.join(":"))},taiga.generateUniqueSessionIdentifier=function(){var date,randomNumber;return date=(new Date).getTime(),randomNumber=Math.floor(150994944*Math.random()),taiga.generateHash([date,randomNumber])},taiga.sessionId=taiga.generateUniqueSessionIdentifier(),configure=function($routeProvider,$locationProvider,$httpProvider,$provide,$tgEventsProvider,$compileProvider,$translateProvider,$translatePartialLoaderProvider,$animateProvider){var authHttpIntercept,decorators,defaultHeaders,loaderIntercept,originalWhen,preferedLangCode,userInfo,versionCheckHttpIntercept;return $animateProvider.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/),originalWhen=$routeProvider.when,$routeProvider.when=function(path,route){return route.resolve||(route.resolve={}),angular.extend(route.resolve,{languageLoad:["$q","$translate",function($q,$translate){var deferred;return deferred=$q.defer(),$translate().then(function(){return deferred.resolve()}),deferred.promise}]}),originalWhen.call($routeProvider,path,route)},$routeProvider.when("/",{templateUrl:"home/home.html",controller:"Home",controllerAs:"vm",loader:!0,title:"HOME.PAGE_TITLE",loader:!0,description:"HOME.PAGE_DESCRIPTION",joyride:"dashboard"}),$routeProvider.when("/discover",{templateUrl:"discover/discover-home/discover-home.html",controller:"DiscoverHome",controllerAs:"vm",title:"PROJECT.NAVIGATION.DISCOVER",loader:!0}),$routeProvider.when("/discover/search",{templateUrl:"discover/discover-search/discover-search.html",title:"PROJECT.NAVIGATION.DISCOVER",loader:!0,controller:"DiscoverSearch",controllerAs:"vm",reloadOnSearch:!1}),$routeProvider.when("/projects/",{templateUrl:"projects/listing/projects-listing.html",access:{requiresLogin:!0},title:"PROJECTS.PAGE_TITLE",description:"PROJECTS.PAGE_DESCRIPTION",loader:!0,controller:"ProjectsListing",controllerAs:"vm"}),$routeProvider.when("/project/:pslug/",{templateUrl:"projects/project/project.html",loader:!0,controller:"Project",controllerAs:"vm",section:"project-timeline"}),$routeProvider.when("/project/:pslug/search",{templateUrl:"search/search.html",reloadOnSearch:!1,section:"search",loader:!0}),$routeProvider.when("/project/:pslug/backlog",{templateUrl:"backlog/backlog.html",loader:!0,section:"backlog",joyride:"backlog"}),$routeProvider.when("/project/:pslug/kanban",{templateUrl:"kanban/kanban.html",loader:!0,section:"kanban",joyride:"kanban"}),$routeProvider.when("/project/:pslug/taskboard/:sslug",{templateUrl:"taskboard/taskboard.html",loader:!0,section:"backlog"}),$routeProvider.when("/project/:pslug/us/:usref",{templateUrl:"us/us-detail.html",loader:!0,section:"backlog-kanban"}),$routeProvider.when("/project/:pslug/task/:taskref",{templateUrl:"task/task-detail.html",loader:!0,section:"backlog-kanban"}),$routeProvider.when("/project/:pslug/wiki",{redirectTo:function(params){return"/project/"+params.pslug+"/wiki/home"}}),$routeProvider.when("/project/:pslug/wiki/:slug",{templateUrl:"wiki/wiki.html",loader:!0,section:"wiki"}),$routeProvider.when("/project/:pslug/team",{templateUrl:"team/team.html",loader:!0,section:"team"}),$routeProvider.when("/project/:pslug/issues",{templateUrl:"issue/issues.html",loader:!0,section:"issues"}),$routeProvider.when("/project/:pslug/issue/:issueref",{templateUrl:"issue/issues-detail.html",loader:!0,section:"issues"}),$routeProvider.when("/project/:pslug/admin/project-profile/details",{templateUrl:"admin/admin-project-profile.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/default-values",{templateUrl:"admin/admin-project-default-values.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/modules",{templateUrl:"admin/admin-project-modules.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/export",{templateUrl:"admin/admin-project-export.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-profile/reports",{templateUrl:"admin/admin-project-reports.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/status",{templateUrl:"admin/admin-project-values-status.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/points",{templateUrl:"admin/admin-project-values-points.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/priorities",{templateUrl:"admin/admin-project-values-priorities.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/severities",{templateUrl:"admin/admin-project-values-severities.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/types",{templateUrl:"admin/admin-project-values-types.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/project-values/custom-fields",{templateUrl:"admin/admin-project-values-custom-fields.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/memberships",{templateUrl:"admin/admin-memberships.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/roles",{templateUrl:"admin/admin-roles.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/webhooks",{templateUrl:"admin/admin-third-parties-webhooks.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/github",{templateUrl:"admin/admin-third-parties-github.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/gitlab",{templateUrl:"admin/admin-third-parties-gitlab.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/third-parties/bitbucket",{templateUrl:"admin/admin-third-parties-bitbucket.html",section:"admin"}),$routeProvider.when("/project/:pslug/admin/contrib/:plugin",{templateUrl:"contrib/main.html"}),$routeProvider.when("/user-settings/user-profile",{templateUrl:"user/user-profile.html"}),$routeProvider.when("/user-settings/user-change-password",{templateUrl:"user/user-change-password.html"}),$routeProvider.when("/user-settings/mail-notifications",{templateUrl:"user/mail-notifications.html"}),$routeProvider.when("/change-email/:email_token",{templateUrl:"user/change-email.html"}),$routeProvider.when("/cancel-account/:cancel_token",{templateUrl:"user/cancel-account.html"}),$routeProvider.when("/profile",{templateUrl:"profile/profile.html",loader:!0,access:{requiresLogin:!0},controller:"Profile",controllerAs:"vm"}),$routeProvider.when("/profile/:slug",{templateUrl:"profile/profile.html",loader:!0,controller:"Profile",controllerAs:"vm"}),$routeProvider.when("/login",{templateUrl:"auth/login.html",title:"LOGIN.PAGE_TITLE",description:"LOGIN.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/register",{templateUrl:"auth/register.html",title:"REGISTER.PAGE_TITLE",description:"REGISTER.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/forgot-password",{templateUrl:"auth/forgot-password.html",title:"FORGOT_PASSWORD.PAGE_TITLE",description:"FORGOT_PASSWORD.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/change-password/:token",{templateUrl:"auth/change-password-from-recovery.html",title:"CHANGE_PASSWORD.PAGE_TITLE",description:"CHANGE_PASSWORD.PAGE_TITLE",disableHeader:!0}),$routeProvider.when("/invitation/:token",{templateUrl:"auth/invitation.html",title:"INVITATION.PAGE_TITLE",description:"INVITATION.PAGE_DESCRIPTION",disableHeader:!0}),$routeProvider.when("/external-apps",{templateUrl:"external-apps/external-app.html",title:"EXTERNAL_APP.PAGE_TITLE",description:"EXTERNAL_APP.PAGE_DESCRIPTION",controller:"ExternalApp",controllerAs:"vm",disableHeader:!0,mobileViewport:!0}),$routeProvider.when("/error",{templateUrl:"error/error.html"}),$routeProvider.when("/not-found",{templateUrl:"error/not-found.html"}),$routeProvider.when("/permission-denied",{templateUrl:"error/permission-denied.html"}),$routeProvider.otherwise({redirectTo:"/not-found"}),$locationProvider.html5Mode({enabled:!0,requireBase:!1}),defaultHeaders={"Content-Type":"application/json","Accept-Language":window.taigaConfig.defaultLanguage||"en","X-Session-Id":taiga.sessionId},$httpProvider.defaults.headers["delete"]=defaultHeaders,$httpProvider.defaults.headers.patch=defaultHeaders,$httpProvider.defaults.headers.post=defaultHeaders,$httpProvider.defaults.headers.put=defaultHeaders,$httpProvider.defaults.headers.get={"X-Session-Id":taiga.sessionId},$httpProvider.useApplyAsync(!0),$tgEventsProvider.setSessionId(taiga.sessionId),authHttpIntercept=function($q,$location,$navUrls,$lightboxService){var httpResponseError;return httpResponseError=function(response){var nextUrl;return 0===response.status||-1===response.status&&!response.config.cancelable?($lightboxService.closeAll(),$location.path($navUrls.resolve("error")),$location.replace()):401===response.status&&-1===$location.url().indexOf("/login")&&(nextUrl=encodeURIComponent($location.url()),$location.url($navUrls.resolve("login")).search("next="+nextUrl)),$q.reject(response)},{responseError:httpResponseError}},$provide.factory("authHttpIntercept",["$q","$location","$tgNavUrls","lightboxService",authHttpIntercept]),$httpProvider.interceptors.push("authHttpIntercept"),loaderIntercept=function($q,loaderService){return{request:function(config){return loaderService.logRequest(),config},requestError:function(rejection){return loaderService.logResponse(),$q.reject(rejection)},responseError:function(rejection){return loaderService.logResponse(),$q.reject(rejection)},response:function(response){return loaderService.logResponse(),response}}},$provide.factory("loaderIntercept",["$q","tgLoader",loaderIntercept]),$httpProvider.interceptors.push("loaderIntercept"),versionCheckHttpIntercept=function($q){var httpResponseError;return httpResponseError=function(response){var $injector;return 400===response.status&&response.data.version&&($injector=angular.element("body").injector(),$injector.invoke(["$tgConfirm","$translate",function(_this){return function($confirm,$translate){var versionErrorMsg;return versionErrorMsg=$translate.instant("ERROR.VERSION_ERROR"),$confirm.notify("error",versionErrorMsg,null,1e4)}}(this)])),$q.reject(response)},{responseError:httpResponseError}},$provide.factory("versionCheckHttpIntercept",["$q",versionCheckHttpIntercept]),$httpProvider.interceptors.push("versionCheckHttpIntercept"),window.checksley.updateValidators({linewidth:function(val,width){var lines,valid;return lines=taiga.nl2br(val).split("
"),valid=_.every(lines,function(line){return line.lengthi;i++)if(i in this&&this[i]===item)return i;return-1},slice=[].slice,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;nl2br=function(_this){return function(str){var breakTag;return breakTag="
",(str+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")}}(this),bindMethods=function(_this){return function(object){var dependencies,methods;return dependencies=_.keys(object),methods=[],_.forIn(object,function(value,key){return indexOf.call(dependencies,key)<0?methods.push(key):void 0}),_.bindAll(object,methods)}}(this),bindOnce=function(_this){return function(scope,attr,continuation){var delBind,val;return val=scope.$eval(attr),void 0!==val?continuation(val):(delBind=null,delBind=scope.$watch(attr,function(val){return void 0!==val?(continuation(val),delBind?delBind():void 0):void 0}))}}(this),mixOf=function(){var Mixed,base,i,method,mixin,mixins,name,ref;for(base=arguments[0],mixins=2<=arguments.length?slice.call(arguments,1):[],Mixed=function(superClass){function Mixed(){return Mixed.__super__.constructor.apply(this,arguments)}return extend(Mixed,superClass),Mixed}(base),i=mixins.length-1;i>=0;i+=-1){mixin=mixins[i],ref=mixin.prototype;for(name in ref)method=ref[name],Mixed.prototype[name]=method}return Mixed},trim=function(data,char){return _.str.trim(data,char)},slugify=function(data){return _.str.slugify(data)},unslugify=function(data){return data?_.str.capitalize(data.replace(/-/g," ")):data},toggleText=function(element,texts){var nextTextPosition,text;return nextTextPosition=element.data("nextTextPosition"),(null==nextTextPosition||nextTextPosition>=texts.length)&&(nextTextPosition=0),text=texts[nextTextPosition],element.data("nextTextPosition",nextTextPosition+1),element.text(text)},groupBy=function(coll,pred){var i,item,len,result;for(result={},i=0,len=coll.length;len>i;i++)item=coll[i],result[pred(item)]=item;return result},timeout=function(wait,continuation){return window.setTimeout(continuation,wait)},cancelTimeout=function(timeoutVar){return window.clearTimeout(timeoutVar)},scopeDefer=function(scope,func){return _.defer(function(_this){return function(){return scope.$apply(func)}}(this))},toString=function(value){return _.isNumber(value)?value+"":_.isString(value)?value:_.isPlainObject(value)?JSON.stringify(value):_.isUndefined(value)?"":value.toString()},joinStr=function(str,coll){return _.str.join(str,coll)},debounce=function(wait,func){return _.debounce(func,wait,{leading:!0,trailing:!1})},debounceLeading=function(wait,func){return _.debounce(func,wait,{leading:!1,trailing:!0})},startswith=function(str1,str2){return _.str.startsWith(str1,str2)},truncate=function(str,maxLength,suffix){var out;return null==suffix&&(suffix="..."),"string"==typeof str||str instanceof String?(out=str.slice(0),out.length>maxLength&&(out=out.substring(0,maxLength+1),out=out.substring(0,Math.min(out.length,out.lastIndexOf(" "))),out+=suffix),out):str},sizeFormat=function(input,precision){var number,size,units;return null==precision&&(precision=1),isNaN(parseFloat(input))||!isFinite(input)?"-":0===input?"0 bytes":(units=["bytes","KB","MB","GB","TB","PB"],number=Math.floor(Math.log(input)/Math.log(1024)),number>5&&(number=5),size=(input/Math.pow(1024,number)).toFixed(precision),size+" "+units[number])},stripTags=function(str,exception){var pattern;return exception?(pattern=new RegExp("<(?!"+exception+"s*/?)[^>]+>","gi"),String(str).replace(pattern,"")):String(str).replace(/<\/?[^>]+>/g,"")},replaceTags=function(str,tags,replace){var pattern;return pattern=new RegExp("<("+tags+")>","gi"),str=str.replace(pattern,"<"+replace+">"),pattern=new RegExp("","gi"),str=str.replace(pattern,"")},defineImmutableProperty=function(_this){return function(obj,name,fn){return Object.defineProperty(obj,name,{get:function(){var fn_result;if(!_.isFunction(fn))throw"defineImmutableProperty third param must be a function";if(fn_result=fn(),fn_result&&_.isObject(fn_result)&&void 0===fn_result.size)throw"defineImmutableProperty must return immutable data";return fn_result}})}}(this),_.mixin({removeKeys:function(obj,keys){return _.chain([keys]).flatten().reduce(function(obj,key){return delete obj[key],obj},obj).value()},cartesianProduct:function(){return _.reduceRight(arguments,function(a,b){return _.flatten(_.map(a,function(x){return _.map(b,function(y){return[y].concat(x)})}),!0)},[[]])}}),isImage=function(name){return null!==name.match(/\.(jpe?g|png|gif|gifv|webm)/i)},patch=function(oldImmutable,newImmutable){var pathObj;return pathObj={},newImmutable.forEach(function(newValue,key){return newValue!==oldImmutable.get(key)?newValue.toJS?pathObj[key]=newValue.toJS():pathObj[key]=newValue:void 0}),pathObj},taiga=this.taiga,taiga.nl2br=nl2br,taiga.bindMethods=bindMethods,taiga.bindOnce=bindOnce,taiga.mixOf=mixOf,taiga.trim=trim,taiga.slugify=slugify,taiga.unslugify=unslugify,taiga.toggleText=toggleText,taiga.groupBy=groupBy,taiga.timeout=timeout,taiga.cancelTimeout=cancelTimeout,taiga.scopeDefer=scopeDefer,taiga.toString=toString,taiga.joinStr=joinStr,taiga.truncate=truncate,taiga.debounce=debounce,taiga.debounceLeading=debounceLeading,taiga.startswith=startswith,taiga.sizeFormat=sizeFormat,taiga.stripTags=stripTags,taiga.replaceTags=replaceTags,taiga.defineImmutableProperty=defineImmutableProperty,taiga.isImage=isImage,taiga.patch=patch}.call(this),function(){var FiltersMixin,PageMixin,groupBy,joinStr,taiga,toString,trim;taiga=this.taiga,groupBy=this.taiga.groupBy,joinStr=this.taiga.joinStr,trim=this.taiga.trim,toString=this.taiga.toString,PageMixin=function(){function PageMixin(){}return PageMixin.prototype.fillUsersAndRoles=function(users,roles){var activeUsers,computableRoles;return activeUsers=_.filter(users,function(_this){return function(user){return user.is_active}}(this)),this.scope.activeUsers=_.sortBy(activeUsers,"full_name_display"),this.scope.activeUsersById=groupBy(this.scope.activeUsers,function(e){return e.id}),this.scope.users=_.sortBy(users,"full_name_display"),this.scope.usersById=groupBy(this.scope.users,function(e){return e.id}),this.scope.roles=_.sortBy(roles,"order"),computableRoles=_(this.scope.project.members).map("role").uniq().value(),this.scope.computableRoles=_(roles).filter("computable").filter(function(x){return _.contains(computableRoles,x.id)}).value()},PageMixin.prototype.loadUsersAndRoles=function(){var promise;return promise=this.q.all([this.rs.projects.usersList(this.scope.projectId),this.rs.projects.rolesList(this.scope.projectId)]),promise.then(function(_this){return function(results){var roles,users;return users=results[0],roles=results[1],_this.fillUsersAndRoles(users,roles),results}}(this))},PageMixin}(),taiga.PageMixin=PageMixin,FiltersMixin=function(){function FiltersMixin(){}return FiltersMixin.prototype.selectFilter=function(name,value,load){var existing,location,params;return null==load&&(load=!1),params=this.location.search(),void 0!==params[name]&&"page"!==name&&(existing=_.map(taiga.toString(params[name]).split(","),function(x){return trim(x)}),existing.push(taiga.toString(value)),existing=_.compact(existing),value=joinStr(",",_.uniq(existing))),this.location.isInCurrentRouteParams(name,value)?void 0:(location=load?this.location:this.location.noreload(this.scope),location.search(name,value))},FiltersMixin.prototype.replaceFilter=function(name,value,load){var location;return null==load&&(load=!1),this.location.isInCurrentRouteParams(name,value)?void 0:(location=load?this.location:this.location.noreload(this.scope),location.search(name,value))},FiltersMixin.prototype.replaceAllFilters=function(filters,load){var location;return null==load&&(load=!1),location=load?this.location:this.location.noreload(this.scope),location.search(filters)},FiltersMixin.prototype.unselectFilter=function(name,value,load){var location,newValues,params,parsedValues;return null==load&&(load=!1),params=this.location.search(),void 0!==params[name]?((void 0===value||null===value)&&delete params[name],parsedValues=_.map(taiga.toString(params[name]).split(","),function(x){return trim(x)}),newValues=_.reject(parsedValues,function(x){return x===taiga.toString(value)}),newValues=_.compact(newValues),value=_.isEmpty(newValues)?null:joinStr(",",_.uniq(newValues)),location=load?this.location:this.location.noreload(this.scope),location.search(name,value)):void 0},FiltersMixin}(),taiga.FiltersMixin=FiltersMixin}.call(this),function(){var module;module=angular.module("taigaAdmin",[])}.call(this),function(){var AuthService,CancelAccountDirective,ChangeEmailDirective,ChangePasswordFromRecoveryDirective,ForgotPasswordDirective,InvitationDirective,LoginDirective,PublicRegisterMessageDirective,RegisterDirective,debounce,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,debounce=this.taiga.debounce,module=angular.module("taigaAuth",["taigaResources"]),AuthService=function(superClass){function AuthService(rootscope,storage,model,rs,http,urls,config,translate,currentUserService,themeService){var userModel;this.rootscope=rootscope,this.storage=storage,this.model=model,this.rs=rs,this.http=http,this.urls=urls,this.config=config,this.translate=translate,this.currentUserService=currentUserService,this.themeService=themeService,AuthService.__super__.constructor.call(this),userModel=this.getUser(),this._currentTheme=this._getUserTheme(),this.setUserdata(userModel)}return extend(AuthService,superClass),AuthService.$inject=["$rootScope","$tgStorage","$tgModel","$tgResources","$tgHttp","$tgUrls","$tgConfig","$translate","tgCurrentUserService","tgThemeService"],AuthService.prototype.setUserdata=function(userModel){return userModel?(this.userData=Immutable.fromJS(userModel.getAttrs()),this.currentUserService.setUser(this.userData)):this.userData=null},AuthService.prototype._getUserTheme=function(){var ref;return(null!=(ref=this.rootscope.user)?ref.theme:void 0)||this.config.get("defaultTheme")||"taiga"},AuthService.prototype._setTheme=function(){var newTheme;return newTheme=this._getUserTheme(),this._currentTheme!==newTheme?(this._currentTheme=newTheme,this.themeService.use(this._currentTheme)):void 0},AuthService.prototype._setLocales=function(){var lang,ref;return lang=(null!=(ref=this.rootscope.user)?ref.lang:void 0)||this.config.get("defaultLanguage")||"en",this.translate.preferredLanguage(lang),this.translate.use(lang)},AuthService.prototype.getUser=function(){var user,userData;return this.rootscope.user?this.rootscope.user:(userData=this.storage.get("userInfo"))?(user=this.model.make_model("users",userData),this.rootscope.user=user,this._setLocales(),this._setTheme(),user):(this._setTheme(),null)},AuthService.prototype.setUser=function(user){return this.rootscope.auth=user,this.storage.set("userInfo",user.getAttrs()),this.rootscope.user=user,this.setUserdata(user),this._setLocales(),this._setTheme()},AuthService.prototype.clear=function(){return this.rootscope.auth=null,this.rootscope.user=null,this.storage.remove("userInfo")},AuthService.prototype.setToken=function(token){return this.storage.set("token",token)},AuthService.prototype.getToken=function(){return this.storage.get("token")},AuthService.prototype.removeToken=function(){return this.storage.remove("token")},AuthService.prototype.isAuthenticated=function(){return null!==this.getUser()?!0:!1},AuthService.prototype.login=function(data,type){var url;return url=this.urls.resolve("auth"),data=_.clone(data,!1),data.type=type?type:"normal",this.removeToken(),this.http.post(url,data).then(function(_this){return function(data,status){var user;return user=_this.model.make_model("users",data.data),_this.setToken(user.auth_token),_this.setUser(user),user}}(this))},AuthService.prototype.logout=function(){return this.removeToken(),this.clear(),this.currentUserService.removeUser(),this._setTheme(),this._setLocales()},AuthService.prototype.register=function(data,type,existing){var url;return url=this.urls.resolve("auth-register"),data=_.clone(data,!1),data.type=type?type:"public","private"===type&&(data.existing=existing?existing:!1),this.removeToken(),this.http.post(url,data).then(function(_this){return function(response){var user;return user=_this.model.make_model("users",response.data),_this.setToken(user.auth_token),_this.setUser(user),user}}(this))},AuthService.prototype.getInvitation=function(token){return this.rs.invitations.get(token)},AuthService.prototype.acceptInvitiationWithNewUser=function(data){return this.register(data,"private",!1)},AuthService.prototype.acceptInvitiationWithExistingUser=function(data){return this.register(data,"private",!0)},AuthService.prototype.forgotPassword=function(data){var url;return url=this.urls.resolve("users-password-recovery"),data=_.clone(data,!1),this.removeToken(),this.http.post(url,data)},AuthService.prototype.changePasswordFromRecovery=function(data){var url;return url=this.urls.resolve("users-change-password-from-recovery"),data=_.clone(data,!1),this.removeToken(),this.http.post(url,data)},AuthService.prototype.changeEmail=function(data){var url;return url=this.urls.resolve("users-change-email"),data=_.clone(data,!1),this.http.post(url,data)},AuthService.prototype.cancelAccount=function(data){var url;return url=this.urls.resolve("users-cancel-account"),data=_.clone(data,!1),this.http.post(url,data)},AuthService}(taiga.Service),module.service("$tgAuth",AuthService),PublicRegisterMessageDirective=function($config,$navUrls,$routeParams,templates){var template,templateFn;return template=templates.get("auth/login-text.html",!0),templateFn=function(){var nextUrl,publicRegisterEnabled,url;return(publicRegisterEnabled=$config.get("publicRegisterEnabled"))?(url=$navUrls.resolve("register"),$routeParams.next&&$routeParams.next!==$navUrls.resolve("register")&&(nextUrl=encodeURIComponent($routeParams.next),console.log("-----",nextUrl),url+="?next="+nextUrl),template({url:url})):""},{restrict:"AE",scope:{},template:templateFn}},module.directive("tgPublicRegisterMessage",["$tgConfig","$tgNavUrls","$routeParams","$tgTemplate",PublicRegisterMessageDirective]),LoginDirective=function($auth,$confirm,$location,$config,$routeParams,$navUrls,$events,$translate){var link;return link=function($scope,$el,$attrs){ +var form,onError,onSuccess,submit;return form=new checksley.Form($el.find("form.login-form")),$routeParams.next&&$routeParams.next!==$navUrls.resolve("login")?$scope.nextUrl=decodeURIComponent($routeParams.next):$scope.nextUrl=$navUrls.resolve("home"),onSuccess=function(response){return $events.setupConnection(),$location.url($scope.nextUrl)},onError=function(response){return $confirm.notify("light-error",$translate.instant("LOGIN_FORM.ERROR_AUTH_INCORRECT"))},submit=debounce(2e3,function(_this){return function(event){var data,loginFormType,promise;return event.preventDefault(),form.validate()?(data={username:$el.find("form.login-form input[name=username]").val(),password:$el.find("form.login-form input[name=password]").val()},loginFormType=$config.get("loginFormType","normal"),promise=$auth.login(data,loginFormType),promise.then(onSuccess,onError)):void 0}}(this)),$el.on("submit","form",submit),window.prerenderReady=!0,$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLogin",["$tgAuth","$tgConfirm","$tgLocation","$tgConfig","$routeParams","$tgNavUrls","$tgEvents","$translate",LoginDirective]),RegisterDirective=function($auth,$confirm,$location,$navUrls,$config,$routeParams,$analytics,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $config.get("publicRegisterEnabled")||($location.path($navUrls.resolve("not-found")),$location.replace()),$scope.data={},form=$el.find("form").checksley({onlyOneErrorElement:!0}),$routeParams.next&&$routeParams.next!==$navUrls.resolve("register")?$scope.nextUrl=decodeURIComponent($routeParams.next):$scope.nextUrl=$navUrls.resolve("home"),onSuccessSubmit=function(response){return $analytics.trackEvent("auth","register","user registration",1),$confirm.notify("success",$translate.instant("LOGIN_FORM.SUCCESS")),$location.url($scope.nextUrl)},onErrorSubmit=function(response){var text;return response.data._error_message&&(text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)),form.setErrors(response.data)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.register($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()}),window.prerenderReady=!0},{link:link}},module.directive("tgRegister",["$tgAuth","$tgConfirm","$tgLocation","$tgNavUrls","$tgConfig","$routeParams","$tgAnalytics","$translate",RegisterDirective]),ForgotPasswordDirective=function($auth,$confirm,$location,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $location.path($navUrls.resolve("login")),text=$translate.instant("FORGOT_PASSWORD_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("FORGOT_PASSWORD_FORM.ERROR"),$confirm.notify("light-error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.forgotPassword($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()}),window.prerenderReady=!0},{link:link}},module.directive("tgForgotPassword",["$tgAuth","$tgConfirm","$tgLocation","$tgNavUrls","$translate",ForgotPasswordDirective]),ChangePasswordFromRecoveryDirective=function($auth,$confirm,$location,$params,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit,text;return $scope.data={},null!=$params.token?($scope.tokenInParams=!0,$scope.data.token=$params.token):($location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.ERROR"),$confirm.notify("light-error",text)),form=$el.find("form").checksley(),onSuccessSubmit=function(response){return $location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){return text=$translate.instant("CHANGE_PASSWORD_RECOVERY_FORM.ERROR"),$confirm.notify("light-error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.changePasswordFromRecovery($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgChangePasswordFromRecovery",["$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$translate",ChangePasswordFromRecoveryDirective]),InvitationDirective=function($auth,$confirm,$location,$params,$navUrls,$analytics,$translate){var link;return link=function($scope,$el,$attrs){var loginForm,onErrorSubmitLogin,onErrorSubmitRegister,onSuccessSubmitLogin,onSuccessSubmitRegister,promise,registerForm,submitLogin,submitRegister,token;return token=$params.token,promise=$auth.getInvitation(token),promise.then(function(invitation){return $scope.invitation=invitation}),promise.then(null,function(response){var text;return $location.path($navUrls.resolve("login")),text=$translate.instant("INVITATION_LOGIN_FORM.NOT_FOUND"),$confirm.notify("light-error",text)}),$scope.dataLogin={token:token},loginForm=$el.find("form.login-form").checksley({onlyOneErrorElement:!0}),onSuccessSubmitLogin=function(response){var text;return $analytics.trackEvent("auth","invitationAccept","invitation accept with existing user",1),$location.path($navUrls.resolve("project",{project:$scope.invitation.project_slug})),text=$translate.instant("INVITATION_LOGIN_FORM.SUCCESS",{project_name:$scope.invitation.project_name}),$confirm.notify("success",text)},onErrorSubmitLogin=function(response){return $confirm.notify("light-error",response.data._error_message)},submitLogin=debounce(2e3,function(_this){return function(event){return event.preventDefault(),loginForm.validate()?(promise=$auth.acceptInvitiationWithExistingUser($scope.dataLogin),promise.then(onSuccessSubmitLogin,onErrorSubmitLogin)):void 0}}(this)),$el.on("submit","form.login-form",submitLogin),$el.on("click",".button-login",submitLogin),$scope.dataRegister={token:token},registerForm=$el.find("form.register-form").checksley({onlyOneErrorElement:!0}),onSuccessSubmitRegister=function(response){return $analytics.trackEvent("auth","invitationAccept","invitation accept with new user",1),$location.path($navUrls.resolve("project",{project:$scope.invitation.project_slug})),$confirm.notify("success","You've successfully joined this project","Welcome to "+_.escape($scope.invitation.project_name))},onErrorSubmitRegister=function(response){var text;return response.data._error_message&&(text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)),registerForm.setErrors(response.data)},submitRegister=debounce(2e3,function(_this){return function(event){return event.preventDefault(),registerForm.validate()?(promise=$auth.acceptInvitiationWithNewUser($scope.dataRegister),promise.then(onSuccessSubmitRegister,onErrorSubmitRegister)):void 0}}(this)),$el.on("submit","form.register-form",submitRegister),$el.on("click",".button-register",submitRegister),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgInvitation",["$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$tgAnalytics","$translate",InvitationDirective]),ChangeEmailDirective=function($repo,$model,$auth,$confirm,$location,$params,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},$scope.data.email_token=$params.email_token,form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $auth.isAuthenticated()?$repo.queryOne("users",$auth.getUser().id).then(function(_this){return function(data){return $auth.setUser(data),$location.path($navUrls.resolve("home"))}}(this)):$location.path($navUrls.resolve("login")),text=$translate.instant("CHANGE_EMAIL_FORM.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("light-error",text)},submit=function(){var promise;if(form.validate())return promise=$auth.changeEmail($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)},$el.on("submit",function(event){return event.preventDefault(),submit()}),$el.on("click","a.button-change-email",function(event){return event.preventDefault(),submit()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgChangeEmail",["$tgRepo","$tgModel","$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls","$translate",ChangeEmailDirective]),CancelAccountDirective=function($repo,$model,$auth,$confirm,$location,$params,$navUrls){var link;return link=function($scope,$el,$attrs){var form,onErrorSubmit,onSuccessSubmit,submit;return $scope.data={},$scope.data.cancel_token=$params.cancel_token,form=$el.find("form").checksley(),onSuccessSubmit=function(response){var text;return $auth.logout(),$location.path($navUrls.resolve("home")),text=$translate.instant("CANCEL_ACCOUNT.SUCCESS"),$confirm.success(text)},onErrorSubmit=function(response){var text;return text=$translate.instant("COMMON.GENERIC_ERROR",{error:response.data._error_message}),$confirm.notify("error",text)},submit=debounce(2e3,function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(promise=$auth.cancelAccount($scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgCancelAccount",["$tgRepo","$tgModel","$tgAuth","$tgConfirm","$tgLocation","$routeParams","$tgNavUrls",CancelAccountDirective])}.call(this),function(){var module;module=angular.module("taigaBacklog",[])}.call(this),function(){var TaigaMainDirective,bindOnce,groupBy,init,module,taiga,urls;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,module=angular.module("taigaBase",[]),TaigaMainDirective=function($rootscope,$window){var link;return link=function($scope,$el,$attrs){return $window.onresize=function(){return $rootscope.$broadcast("resize")}},{link:link}},module.directive("tgMain",["$rootScope","$window",TaigaMainDirective]),urls={home:"/",projects:"/projects",error:"/error","not-found":"/not-found","permission-denied":"/permission-denied",discover:"/discover","discover-search":"/discover/search",login:"/login","forgot-password":"/forgot-password","change-password":"/change-password/:token","change-email":"/change-email/:token","cancel-account":"/cancel-account/:token",register:"/register",invitation:"/invitation/:token","create-project":"/create-project",profile:"/profile","user-profile":"/profile/:username",project:"/project/:project","project-backlog":"/project/:project/backlog","project-taskboard":"/project/:project/taskboard/:sprint","project-kanban":"/project/:project/kanban","project-issues":"/project/:project/issues","project-search":"/project/:project/search","project-userstories-detail":"/project/:project/us/:ref","project-tasks-detail":"/project/:project/task/:ref","project-issues-detail":"/project/:project/issue/:ref","project-wiki":"/project/:project/wiki","project-wiki-page":"/project/:project/wiki/:slug","project-team":"/project/:project/team","project-admin-home":"/project/:project/admin/project-profile/details","project-admin-project-profile-details":"/project/:project/admin/project-profile/details","project-admin-project-profile-default-values":"/project/:project/admin/project-profile/default-values","project-admin-project-profile-modules":"/project/:project/admin/project-profile/modules","project-admin-project-profile-export":"/project/:project/admin/project-profile/export","project-admin-project-profile-reports":"/project/:project/admin/project-profile/reports","project-admin-project-values-status":"/project/:project/admin/project-values/status","project-admin-project-values-points":"/project/:project/admin/project-values/points","project-admin-project-values-priorities":"/project/:project/admin/project-values/priorities","project-admin-project-values-severities":"/project/:project/admin/project-values/severities","project-admin-project-values-types":"/project/:project/admin/project-values/types","project-admin-project-values-custom-fields":"/project/:project/admin/project-values/custom-fields","project-admin-memberships":"/project/:project/admin/memberships","project-admin-roles":"/project/:project/admin/roles","project-admin-third-parties-webhooks":"/project/:project/admin/third-parties/webhooks","project-admin-third-parties-github":"/project/:project/admin/third-parties/github","project-admin-third-parties-gitlab":"/project/:project/admin/third-parties/gitlab","project-admin-third-parties-bitbucket":"/project/:project/admin/third-parties/bitbucket","project-admin-contrib":"/project/:project/admin/contrib/:plugin","user-settings-user-profile":"/user-settings/user-profile","user-settings-user-change-password":"/user-settings/user-change-password","user-settings-user-avatar":"/user-settings/user-avatar","user-settings-mail-notifications":"/user-settings/mail-notifications"},init=function($log,$navurls){return $log.debug("Initialize navigation urls"),$navurls.update(urls)},module.run(["$log","$tgNavUrls",init])}.call(this),function(){var AnimationFrame,Capslock,CheckPermissionDirective,ClassPermissionDirective,DataPickerConfig,LimitLineLengthDirective,ProjectUrl,Qqueue,SelectedText,Template,ToggleCommentDirective,module,taiga,slice=[].slice;taiga=this.taiga,module=angular.module("taigaCommon",[]),DataPickerConfig=function($translate){return{get:function(){return{i18n:{previousMonth:$translate.instant("COMMON.PICKERDATE.PREV_MONTH"),nextMonth:$translate.instant("COMMON.PICKERDATE.NEXT_MONTH"),months:[$translate.instant("COMMON.PICKERDATE.MONTHS.JAN"),$translate.instant("COMMON.PICKERDATE.MONTHS.FEB"),$translate.instant("COMMON.PICKERDATE.MONTHS.MAR"),$translate.instant("COMMON.PICKERDATE.MONTHS.APR"),$translate.instant("COMMON.PICKERDATE.MONTHS.MAY"),$translate.instant("COMMON.PICKERDATE.MONTHS.JUN"),$translate.instant("COMMON.PICKERDATE.MONTHS.JUL"),$translate.instant("COMMON.PICKERDATE.MONTHS.AUG"),$translate.instant("COMMON.PICKERDATE.MONTHS.SEP"),$translate.instant("COMMON.PICKERDATE.MONTHS.OCT"),$translate.instant("COMMON.PICKERDATE.MONTHS.NOV"),$translate.instant("COMMON.PICKERDATE.MONTHS.DEC")],weekdays:[$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.SUN"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.MON"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.TUE"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.WED"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.THU"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.FRI"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS.SAT")],weekdaysShort:[$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.SUN"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.MON"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.TUE"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.WED"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.THU"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.FRI"),$translate.instant("COMMON.PICKERDATE.WEEK_DAYS_SHORT.SAT")]},isRTL:"true"===$translate.instant("COMMON.PICKERDATE.IS_RTL"),firstDay:parseInt($translate.instant("COMMON.PICKERDATE.FIRST_DAY_OF_WEEK"),10),format:$translate.instant("COMMON.PICKERDATE.FORMAT")}}}},module.factory("tgDatePickerConfigService",["$translate",DataPickerConfig]),SelectedText=function($window,$document){var get;return get=function(){return $window.getSelection?$window.getSelection().toString():$document.selection?$document.selection.createRange().text:""},{get:get}},module.factory("$selectedText",["$window","$document",SelectedText]),CheckPermissionDirective=function(projectService){var link,render;return render=function($el,project,permission){return project&&permission&&project.get("my_permissions").indexOf(permission)>-1?$el.removeClass("hidden"):void 0},link=function($scope,$el,$attrs){var permission,unObserve,unwatch;return $el.addClass("hidden"),permission=$attrs.tgCheckPermission,unwatch=$scope.$watch(function(){return projectService.project},function(){return projectService.project?(render($el,projectService.project,permission),unwatch()):void 0}),unObserve=$attrs.$observe("tgCheckPermission",function(permission){return permission?(render($el,projectService.project,permission),unObserve()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},CheckPermissionDirective.$inject=["tgProjectService"],module.directive("tgCheckPermission",CheckPermissionDirective),ClassPermissionDirective=function(){var link,name;return name="tgClassPermission",link=function($scope,$el,$attrs){var checkPermissions,tgClassPermissionWatchAction,unbindWatcher;return checkPermissions=function(project,className,permission){var negation;return negation="!"===permission[0],negation&&(permission=permission.slice(1)),negation&&-1===project.my_permissions.indexOf(permission)?$el.addClass(className):negation||-1===project.my_permissions.indexOf(permission)?$el.removeClass(className):$el.addClass(className)},tgClassPermissionWatchAction=function(project){var className,classes,permission,results;if(project){unbindWatcher(),classes=$scope.$eval($attrs[name]),results=[];for(className in classes)permission=classes[className],results.push(checkPermissions(project,className,permission));return results}},unbindWatcher=$scope.$watch("project",tgClassPermissionWatchAction)},{link:link}},module.directive("tgClassPermission",ClassPermissionDirective),AnimationFrame=function(){var add,animationFrame,performAnimation,tail;return animationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,performAnimation=function(_this){return function(time){var fn;return fn=tail.shift(),fn(),tail.length?animationFrame(performAnimation):void 0}}(this),tail=[],add=function(){var fn,i,len,results;for(results=[],i=0,len=arguments.length;len>i;i++)fn=arguments[i],tail.push(fn),1===tail.length?results.push(animationFrame(performAnimation)):results.push(void 0);return results},{add:add}},module.factory("animationFrame",AnimationFrame),ToggleCommentDirective=function(){var link;return link=function($scope,$el,$attrs){return $el.find("textarea").on("focus",function(){return $el.addClass("active")})},{link:link}},module.directive("tgToggleComment",ToggleCommentDirective),ProjectUrl=function($navurls){var get;return get=function(project){var ctx;return ctx={project:project.slug},project.is_backlog_activated&&project.my_permissions.indexOf("view_us")>-1?$navurls.resolve("project-backlog",ctx):project.is_kanban_activated&&project.my_permissions.indexOf("view_us")>-1?$navurls.resolve("project-kanban",ctx):project.is_wiki_activated&&project.my_permissions.indexOf("view_wiki_pages")>-1?$navurls.resolve("project-wiki",ctx):project.is_issues_activated&&project.my_permissions.indexOf("view_issues")>-1?$navurls.resolve("project-issues",ctx):$navurls.resolve("project",ctx)},{get:get}},module.factory("$projectUrl",["$tgNavUrls",ProjectUrl]),LimitLineLengthDirective=function(){var link;return link=function($scope,$el,$attrs){var maxColsPerLine;return maxColsPerLine=parseInt($el.attr("cols")),$el.on("keyup",function(event){var code,lines;return code=event.keyCode,lines=$el.val().split("\n"),_.each(lines,function(line,index){return lines[index]=line.substring(0,maxColsPerLine-2)}),$el.val(lines.join("\n"))})},{link:link}},module.directive("tgLimitLineLength",LimitLineLengthDirective),Qqueue=function($q){var deferred,lastPromise,qqueue;return deferred=$q.defer(),deferred.resolve(),lastPromise=deferred.promise,qqueue={bindAdd:function(_this){return function(fn){return function(){var args;return args=1<=arguments.length?slice.call(arguments,0):[],lastPromise=lastPromise.then(function(){return fn.apply(_this,args)})}}}(this),add:function(_this){return function(fn){return lastPromise=lastPromise?lastPromise.then(fn):fn(),qqueue}}(this)}},module.factory("$tgQqueue",["$q",Qqueue]),Template=function($templateCache){return{get:function(_this){return function(name,lodash){var tmp;return null==lodash&&(lodash=!1),tmp=$templateCache.get(name),lodash&&(tmp=_.template(tmp)),tmp}}(this)}},module.factory("$tgTemplate",["$templateCache",Template]),Capslock=function($translate){var link;return link=function($scope,$el,$attrs){var hideIcon,open,showIcon,warningIcon;return open=!1,warningIcon=$("
").addClass("icon").addClass("icon-capslock").attr("title",$translate.instant("COMMON.CAPSLOCK_WARNING")),hideIcon=function(){return warningIcon.fadeOut(function(){return open=!1,$(this).remove()})},showIcon=function(e){var element;if(!open)return element=e.currentTarget,$(element).parent().append(warningIcon),$(".icon-capslock").fadeIn(),open=!0},$el.on("blur",function(e){return hideIcon()}),$el.on("keyup.capslock, focus",function(e){return $el.val()===$el.val().toLowerCase()?hideIcon(e):showIcon(e)}),$scope.$on("$destroy",function(){return $el.off(".capslock")})},{link:link}},module.directive("tgCapslock",["$translate",Capslock])}.call(this),function(){var EventsProvider,EventsService,bindMethods,module,startswith,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,startswith=this.taiga.startswith,bindMethods=this.taiga.bindMethods,module=angular.module("taigaEvents",[]),EventsService=function(){function EventsService(win,log,config,auth,liveAnnouncementService1,rootScope){this.win=win,this.log=log,this.config=config,this.auth=auth,this.liveAnnouncementService=liveAnnouncementService1,this.rootScope=rootScope,this.processMessage=bind(this.processMessage,this),bindMethods(this)}return EventsService.prototype.initialize=function(sessionId){return this.sessionId=sessionId,this.subscriptions={},this.connected=!1,this.error=!1,this.pendingMessages=[],this.missedHeartbeats=0,this.heartbeatInterval=null,void 0===this.win.WebSocket?this.log.info("WebSockets not supported on your browser"):void 0},EventsService.prototype.setupConnection=function(){var loc,path,scheme,url;return this.stopExistingConnection(),(url=this.config.get("eventsUrl"))?(startswith(url,"ws:")||startswith(url,"wss:")||(loc=this.win.location,scheme="https:"===loc.protocol?"wss:":"ws:",path=_.str.ltrim(url,"/"),url=scheme+"//"+loc.host+"/"+path),this.ws=new this.win.WebSocket(url),this.ws.addEventListener("open",this.onOpen),this.ws.addEventListener("message",this.onMessage),this.ws.addEventListener("error",this.onError),this.ws.addEventListener("close",this.onClose)):void 0},EventsService.prototype.stopExistingConnection=function(){return void 0!==this.ws?(this.ws.removeEventListener("open",this.onOpen),this.ws.removeEventListener("close",this.onClose),this.ws.removeEventListener("error",this.onError),this.ws.removeEventListener("message",this.onMessage),this.stopHeartBeatMessages(),this.ws.close(),delete this.ws):void 0},EventsService.prototype.notifications=function(){return this.subscribe(null,"notifications",function(_this){return function(data){return _this.liveAnnouncementService.show(data.title,data.desc),_this.rootScope.$digest()}}(this))},EventsService.prototype.startHeartBeatMessages=function(){var heartbeatIntervalTime,maxMissedHeartbeats;if(!this.heartbeatInterval)return maxMissedHeartbeats=this.config.get("eventsMaxMissedHeartbeats",5),heartbeatIntervalTime=this.config.get("eventsHeartbeatIntervalTime",6e4),this.missedHeartbeats=0,this.heartbeatInterval=setInterval(function(_this){return function(){var e,error1;try{if(_this.missedHeartbeats>=maxMissedHeartbeats)throw new Error("Too many missed heartbeats PINGs.");return _this.missedHeartbeats++,_this.sendMessage({cmd:"ping"}),_this.log.debug("HeartBeat send PING")}catch(error1){return e=error1,_this.log.error("HeartBeat error: "+e.message),_this.stopHeartBeatMessages()}}}(this),heartbeatIntervalTime),this.log.debug("HeartBeat enabled")},EventsService.prototype.stopHeartBeatMessages=function(){return this.heartbeatInterval?(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null,this.log.debug("HeartBeat disabled")):void 0},EventsService.prototype.processHeartBeatPongMessage=function(data){return this.missedHeartbeats=0,this.log.debug("HeartBeat recived PONG")},EventsService.prototype.serialize=function(message){return _.isObject(message)?JSON.stringify(message):message},EventsService.prototype.sendMessage=function(message){var i,len,messages,msg,results;if(this.pendingMessages.push(message),this.connected){for(messages=_.map(this.pendingMessages,this.serialize),this.pendingMessages=[],results=[],i=0,len=messages.length;len>i;i++)msg=messages[i],results.push(this.ws.send(msg));return results}},EventsService.prototype.processMessage=function(data){var routingKey,subscription;return routingKey=data.routing_key,null!=this.subscriptions[routingKey]?(subscription=this.subscriptions[routingKey],subscription.scope?subscription.scope.$apply(function(){return subscription.callback(data.data)}):subscription.callback(data.data)):void 0},EventsService.prototype.subscribe=function(scope,routingKey,callback){var message,subscription;if(!this.error)return this.log.debug("Subscribe to: "+routingKey),subscription={scope:scope,routingKey:routingKey,callback:_.debounce(callback,500,{leading:!0,trailing:!1})},message={cmd:"subscribe",routing_key:routingKey},this.subscriptions[routingKey]=subscription,this.sendMessage(message),scope?scope.$on("$destroy",function(_this){return function(){return _this.unsubscribe(routingKey)}}(this)):void 0},EventsService.prototype.unsubscribe=function(routingKey){var message;if(!this.error)return this.log.debug("Unsubscribe from: "+routingKey),message={cmd:"unsubscribe",routing_key:routingKey},this.sendMessage(message)},EventsService.prototype.onOpen=function(){var message,token;return this.connected=!0,this.startHeartBeatMessages(),this.notifications(),this.log.debug("WebSocket connection opened"),token=this.auth.getToken(),message={cmd:"auth",data:{token:token,sessionId:this.sessionId}},this.sendMessage(message)},EventsService.prototype.onMessage=function(event){var data;return this.log.debug("WebSocket message received: "+event.data),data=JSON.parse(event.data),"pong"===data.cmd?this.processHeartBeatPongMessage(data):this.processMessage(data)},EventsService.prototype.onError=function(error){return this.log.error("WebSocket error: "+error),this.error=!0},EventsService.prototype.onClose=function(){return this.log.debug("WebSocket closed."),this.connected=!1,this.stopHeartBeatMessages()},EventsService}(),EventsProvider=function(){function EventsProvider(){}return EventsProvider.prototype.setSessionId=function(sessionId){return this.sessionId=sessionId},EventsProvider.prototype.$get=function($win,$log,$conf,$auth,liveAnnouncementService,$rootScope){var service;return service=new EventsService($win,$log,$conf,$auth,liveAnnouncementService,$rootScope),service.initialize(this.sessionId),service},EventsProvider.prototype.$get.$inject=["$window","$log","$tgConfig","$tgAuth","tgLiveAnnouncementService","$rootScope"],EventsProvider}(),module.provider("$tgEvents",EventsProvider)}.call(this),function(){var FeedbackDirective,bindOnce,debounce,groupBy,mixOf,module,taiga,trim;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,mixOf=this.taiga.mixOf,debounce=this.taiga.debounce,trim=this.taiga.trim,module=angular.module("taigaFeedback",[]),FeedbackDirective=function($lightboxService,$repo,$confirm,$loading,feedbackService){var directive,link;return link=function($scope,$el,$attrs){var form,openLightbox,submit,submitButton;return form=$el.find("form").checksley(),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("feedback",$scope.feedback),promise.then(function(data){return currentLoading.finish(),$lightboxService.close($el),$confirm.notify("success","\\o/ we'll be happy to read your")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),openLightbox=function(){return $scope.feedback={},$lightboxService.open($el),$el.find("textarea").focus()},$scope.$on("$destroy",function(){return $el.off()}),openLightbox()},directive={link:link,templateUrl:"common/lightbox-feedback.html",scope:{}}},module.directive("tgLbFeedback",["lightboxService","$tgRepo","$tgConfirm","$tgLoading","tgFeedbackService",FeedbackDirective])}.call(this),function(){var module;module=angular.module("taigaIntegrations",[])}.call(this),function(){var module;module=angular.module("taigaIssues",[])}.call(this),function(){var module;module=angular.module("taigaKanban",[])}.call(this),function(){var module;module=angular.module("taigaPlugins",["ngRoute"])}.call(this),function(){var module;module=angular.module("taigaProject",[])}.call(this),function(){var RelatedTaskAssignedToInlineEditionDirective,RelatedTaskCreateButtonDirective,RelatedTaskCreateFormDirective,RelatedTaskRowDirective,RelatedTasksDirective,debounce,module,taiga,trim;taiga=this.taiga,trim=this.taiga.trim,debounce=this.taiga.debounce,module=angular.module("taigaRelatedTasks",[]),RelatedTaskRowDirective=function($repo,$compile,$confirm,$rootscope,$loading,$template,$translate){var link,templateEdit,templateView;return templateView=$template.get("task/related-task-row.html",!0),templateEdit=$template.get("task/related-task-row-edit.html",!0),link=function($scope,$el,$attrs,$model){var renderEdit,renderView,saveTask;return saveTask=debounce(2e3,function(task){var currentLoading,promise;return task.subject=$el.find("input").val(),currentLoading=$loading().target($el.find(".task-name")).start(),promise=$repo.save(task),promise.then(function(_this){return function(){return currentLoading.finish(),$rootscope.$broadcast("related-tasks:update")}}(this)),promise.then(null,function(_this){return function(){return currentLoading.finish(),$el.find("input").val(task.subject),$confirm.notify("error")}}(this)),promise}),renderEdit=function(task){return $el.html($compile(templateEdit({task:task}))($scope)),$el.on("keyup","input",function(event){return 13===event.keyCode?saveTask($model.$modelValue).then(function(){return renderView($model.$modelValue)}):27===event.keyCode?renderView($model.$modelValue):void 0}),$el.on("click",".icon-floppy",function(event){return saveTask($model.$modelValue).then(function(){return renderView($model.$modelValue)})}),$el.on("click",".cancel-edit",function(event){return renderView($model.$modelValue)})},renderView=function(task){var perms;return $el.off(),perms={modify_task:-1!==$scope.project.my_permissions.indexOf("modify_task"),delete_task:-1!==$scope.project.my_permissions.indexOf("delete_task")},$el.html($compile(templateView({task:task,perms:perms}))($scope)),$el.on("click",".icon-edit",function(){return renderEdit($model.$modelValue),$el.find("input").focus().select()}),$el.on("click",".delete-task",function(event){var message,title;return title=$translate.instant("TASK.TITLE_DELETE_ACTION"),task=$model.$modelValue,message=task.subject,$confirm.askOnDelete(title,message).then(function(askResponse){var promise;return promise=$repo.remove(task),promise.then(function(){return askResponse.finish(),$scope.$emit("related-tasks:delete")}),promise.then(null,function(){ +return askResponse.finish(!1),$confirm.notify("error")})})})},$scope.$watch($attrs.ngModel,function(val){return val?renderView(val):void 0}),$scope.$on("related-tasks:assigned-to-changed",function(){return $rootscope.$broadcast("related-tasks:update")}),$scope.$on("related-tasks:status-changed",function(){return $rootscope.$broadcast("related-tasks:update")}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgRelatedTaskRow",["$tgRepo","$compile","$tgConfirm","$rootScope","$tgLoading","$tgTemplate","$translate",RelatedTaskRowDirective]),RelatedTaskCreateFormDirective=function($repo,$compile,$confirm,$tgmodel,$loading,$analytics,$template){var link,newTask,template;return template=$template.get("task/related-task-create-form.html",!0),newTask={subject:"",assigned_to:null},link=function($scope,$el,$attrs){var close,createTask,render;return createTask=debounce(2e3,function(task){var currentLoading,promise;return task.subject=$el.find("input").val(),task.assigned_to=$scope.newTask.assigned_to,task.status=$scope.newTask.status,$scope.newTask.status=$scope.project.default_task_status,$scope.newTask.assigned_to=null,currentLoading=$loading().target($el.find(".task-name")).start(),promise=$repo.create("tasks",task),promise.then(function(){return $analytics.trackEvent("task","create","create task on userstory",1),currentLoading.finish(),$scope.$emit("related-tasks:add")}),promise.then(null,function(){return $el.find("input").val(task.subject),currentLoading.finish(),$confirm.notify("error")}),promise}),close=function(){return $el.off(),$el.html(""),$scope.newRelatedTaskFormOpen=!1},render=function(){return $scope.newRelatedTaskFormOpen=!0,$el.html($compile(template())($scope)),$el.find("input").focus().select(),$el.addClass("active"),$el.on("keyup","input",function(event){return 13===event.keyCode?createTask(newTask).then(function(){return render()}):27===event.keyCode?$scope.$apply(function(){return close()}):void 0}),$el.on("click",".icon-delete",function(event){return $scope.$apply(function(){return close()})}),$el.on("click",".icon-floppy",function(event){return createTask(newTask).then(function(){return close()})})},taiga.bindOnce($scope,"us",function(val){return newTask.status=$scope.project.default_task_status,newTask.project=$scope.project.id,newTask.user_story=$scope.us.id,$scope.newTask=$tgmodel.make_model("tasks",newTask),$el.html("")}),$scope.$on("related-tasks:show-form",function(){return render()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskCreateForm",["$tgRepo","$compile","$tgConfirm","$tgModel","$tgLoading","$tgAnalytics","$tgTemplate",RelatedTaskCreateFormDirective]),RelatedTaskCreateButtonDirective=function($repo,$compile,$confirm,$tgmodel,$template){var link,template;return template=$template.get("common/components/add-button.html",!0),link=function($scope,$el,$attrs){return $scope.$watch("project",function(val){return val?($el.off(),-1!==$scope.project.my_permissions.indexOf("add_task")?$el.html($compile(template())($scope)):$el.html(""),$el.on("click",".add-button",function(event){return $scope.$emit("related-tasks:add-new-clicked")})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskCreateButton",["$tgRepo","$compile","$tgConfirm","$tgModel","$tgTemplate",RelatedTaskCreateButtonDirective]),RelatedTasksDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){var loadTasks;return loadTasks=function(){return $rs.tasks.list($scope.projectId,null,$scope.usId).then(function(_this){return function(tasks){return $scope.tasks=_.sortBy(tasks,"ref"),tasks}}(this))},$scope.$on("related-tasks:add",function(){return loadTasks().then(function(){return $rootscope.$broadcast("related-tasks:update")})}),$scope.$on("related-tasks:delete",function(){return loadTasks().then(function(){return $rootscope.$broadcast("related-tasks:update")})}),$scope.$on("related-tasks:add-new-clicked",function(){return $scope.$broadcast("related-tasks:show-form")}),taiga.bindOnce($scope,"us",function(val){return loadTasks()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTasks",["$tgRepo","$tgResources","$rootScope",RelatedTasksDirective]),RelatedTaskAssignedToInlineEditionDirective=function($repo,$rootscope,$translate){var link,template;return template=_.template('<%- name %>\n
<%- name %>
'),link=function($scope,$el,$attrs){var $ctrl,autoSave,notAutoSave,task,updateRelatedTask;return updateRelatedTask=function(task){var ctx,member;return ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=$scope.usersById[task.assigned_to],member&&(ctx.imgurl=member.photo,ctx.name=member.full_name_display),$el.find(".avatar").html(template(ctx)),$el.find(".task-assignedto").attr("title",ctx.name)},$ctrl=$el.controller(),task=$scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition),notAutoSave=$scope.$eval($attrs.notAutoSave),autoSave=!notAutoSave,updateRelatedTask(task),$el.on("click",".task-assignedto",function(event){return $rootscope.$broadcast("assigned-to:add",task)}),taiga.bindOnce($scope,"project",function(project){return-1===project.my_permissions.indexOf("modify_task")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("assigned-to:added",debounce(2e3,function(_this){return function(ctx,userId,updatedRelatedTask){return updatedRelatedTask.id===task.id?(updatedRelatedTask.assigned_to=userId,autoSave&&$repo.save(updatedRelatedTask).then(function(){return $scope.$emit("related-tasks:assigned-to-changed")}),updateRelatedTask(updatedRelatedTask)):void 0}}(this))),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskAssignedToInlineEdition",["$tgRepo","$rootScope","$translate",RelatedTaskAssignedToInlineEditionDirective])}.call(this),function(){var ResourcesService,initResources,initUrls,module,taiga,urls,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ResourcesService=function(superClass){function ResourcesService(){return ResourcesService.__super__.constructor.apply(this,arguments)}return extend(ResourcesService,superClass),ResourcesService}(taiga.Service),urls={auth:"/auth","auth-register":"/auth/register",invitations:"/invitations",users:"/users",by_username:"/users/by_username","users-password-recovery":"/users/password_recovery","users-change-password-from-recovery":"/users/change_password_from_recovery","users-change-password":"/users/change_password","users-change-email":"/users/change_email","users-cancel-account":"/users/cancel","user-stats":"/users/%s/stats","user-liked":"/users/%s/liked","user-voted":"/users/%s/voted","user-watched":"/users/%s/watched","user-contacts":"/users/%s/contacts",permissions:"/permissions","notify-policies":"/notify-policies","user-storage":"/user-storage",memberships:"/memberships","bulk-create-memberships":"/memberships/bulk_create",roles:"/roles",permissions:"/permissions",resolver:"/resolver",projects:"/projects","project-templates":"/project-templates","project-modules":"/projects/%s/modules","bulk-update-projects-order":"/projects/bulk_update_order","project-like":"/projects/%s/like","project-unlike":"/projects/%s/unlike","project-watch":"/projects/%s/watch","project-unwatch":"/projects/%s/unwatch","userstory-statuses":"/userstory-statuses",points:"/points","task-statuses":"/task-statuses","issue-statuses":"/issue-statuses","issue-types":"/issue-types",priorities:"/priorities",severities:"/severities",milestones:"/milestones",userstories:"/userstories","bulk-create-us":"/userstories/bulk_create","bulk-update-us-backlog-order":"/userstories/bulk_update_backlog_order","bulk-update-us-sprint-order":"/userstories/bulk_update_sprint_order","bulk-update-us-kanban-order":"/userstories/bulk_update_kanban_order","userstories-filters":"/userstories/filters_data","userstory-upvote":"/userstories/%s/upvote","userstory-downvote":"/userstories/%s/downvote","userstory-watch":"/userstories/%s/watch","userstory-unwatch":"/userstories/%s/unwatch",tasks:"/tasks","bulk-create-tasks":"/tasks/bulk_create","bulk-update-task-taskboard-order":"/tasks/bulk_update_taskboard_order","task-upvote":"/tasks/%s/upvote","task-downvote":"/tasks/%s/downvote","task-watch":"/tasks/%s/watch","task-unwatch":"/tasks/%s/unwatch",issues:"/issues","bulk-create-issues":"/issues/bulk_create","issues-filters":"/issues/filters_data","issue-upvote":"/issues/%s/upvote","issue-downvote":"/issues/%s/downvote","issue-watch":"/issues/%s/watch","issue-unwatch":"/issues/%s/unwatch",wiki:"/wiki","wiki-restore":"/wiki/%s/restore","wiki-links":"/wiki-links","history/us":"/history/userstory","history/issue":"/history/issue","history/task":"/history/task","history/wiki":"/history/wiki","attachments/us":"/userstories/attachments","attachments/issue":"/issues/attachments","attachments/task":"/tasks/attachments","attachments/wiki_page":"/wiki/attachments","custom-attributes/userstory":"/userstory-custom-attributes","custom-attributes/issue":"/issue-custom-attributes","custom-attributes/task":"/task-custom-attributes","custom-attributes-values/userstory":"/userstories/custom-attributes-values","custom-attributes-values/issue":"/issues/custom-attributes-values","custom-attributes-values/task":"/tasks/custom-attributes-values",webhooks:"/webhooks","webhooks-test":"/webhooks/%s/test",webhooklogs:"/webhooklogs","webhooklogs-resend":"/webhooklogs/%s/resend","userstories-csv":"/userstories/csv?uuid=%s","tasks-csv":"/tasks/csv?uuid=%s","issues-csv":"/issues/csv?uuid=%s","timeline-profile":"/timeline/profile","timeline-user":"/timeline/user","timeline-project":"/timeline/project",search:"/search",exporter:"/exporter",importer:"/importer/load_dump",feedback:"/feedback",locales:"/locales",applications:"/applications","application-tokens":"/application-tokens","stats-discover":"/stats/discover"},initUrls=function($log,$urls){return $log.debug("Initialize api urls"),$urls.update(urls)},initResources=function($log,$rs){var i,len,provider,providers,results;for($log.debug("Initialize resources"),providers=_.toArray(arguments).slice(2),results=[],i=0,len=providers.length;len>i;i++)provider=providers[i],results.push(provider($rs));return results},module=angular.module("taigaResources",["taigaBase"]),module.service("$tgResources",ResourcesService),module.run(["$log","$tgUrls",initUrls]),module.run(["$log","$tgResources","$tgProjectsResourcesProvider","$tgCustomAttributesResourcesProvider","$tgCustomAttributesValuesResourcesProvider","$tgMembershipsResourcesProvider","$tgNotifyPoliciesResourcesProvider","$tgInvitationsResourcesProvider","$tgRolesResourcesProvider","$tgUserSettingsResourcesProvider","$tgSprintsResourcesProvider","$tgUserstoriesResourcesProvider","$tgTasksResourcesProvider","$tgIssuesResourcesProvider","$tgWikiResourcesProvider","$tgSearchResourcesProvider","$tgMdRenderResourcesProvider","$tgHistoryResourcesProvider","$tgKanbanResourcesProvider","$tgModulesResourcesProvider","$tgWebhooksResourcesProvider","$tgWebhookLogsResourcesProvider","$tgLocalesResourcesProvider","$tgUsersResourcesProvider",initResources])}.call(this),function(){var SearchBoxDirective,SearchController,SearchDirective,bindOnce,debounce,debounceLeading,groupBy,mixOf,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,mixOf=this.taiga.mixOf,debounceLeading=this.taiga.debounceLeading,trim=this.taiga.trim,debounce=this.taiga.debounce,module=angular.module("taigaSearch",[]),SearchController=function(superClass){function SearchController(scope1,repo,rs,params,q,location,appMetaService,navUrls,translate){var loadSearchData,promise;this.scope=scope1,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.translate=translate,this.scope.sectionName="Search",promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("SEARCH.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("SEARCH.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.searchTerm=null,loadSearchData=debounceLeading(100,function(_this){return function(t){return _this.loadSearchData(t)}}(this)),bindOnce(this.scope,"projectId",function(_this){return function(projectId){return!_this.scope.searchResults&&_this.scope.searchTerm?_this.loadSearchData():void 0}}(this)),this.scope.$watch("searchTerm",function(_this){return function(term){return void 0!==term&&_this.scope.projectId?_this.loadSearchData(term):void 0}}(this))}return extend(SearchController,superClass),SearchController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$translate"],SearchController.prototype.loadFilters=function(){var defered;return defered=this.q.defer(),defered.resolve(),defered.promise},SearchController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issueStatusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.taskStatusById=groupBy(project.task_statuses,function(x){return x.id}),_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),project}}(this))},SearchController.prototype.loadSearchData=function(term){return null==term&&(term=""),this.scope.loading=!0,this._loadSearchData(term).then(function(_this){return function(data){return _this.scope.searchResults=data,_this.scope.loading=!1}}(this))},SearchController.prototype._loadSearchData=function(term){return null==term&&(term=""),this._promise&&this._promise.abort(),this._promise=this.rs.search["do"](this.scope.projectId,term),this._promise},SearchController.prototype.loadInitialData=function(){return this.loadProject().then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.fillUsersAndRoles(project.members,project.roles)}}(this))},SearchController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("SearchController",SearchController),SearchBoxDirective=function(projectService,$lightboxService,$navurls,$location,$route){var link;return link=function($scope,$el,$attrs){var openLightbox,project,submit;return project=null,submit=debounce(2e3,function(_this){return function(event){var form,text,url;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(text=$el.find("#search-text").val(),url=$navurls.resolve("project-search",{project:project.get("slug")}),$scope.$apply(function(){return $lightboxService.close($el),$location.path(url),$location.search("text",text).path(url),$route.reload()})):void 0}}(this)),openLightbox=function(){return project=projectService.project,$lightboxService.open($el).then(function(){return $el.find("#search-text").focus()})},$el.on("submit","form",submit),openLightbox()},{templateUrl:"search/lightbox-search.html",link:link}},SearchBoxDirective.$inject=["tgProjectService","lightboxService","$tgNavUrls","$tgLocation","$route"],module.directive("tgSearchBox",SearchBoxDirective),SearchDirective=function($log,$compile,$templatecache,$routeparams,$location){var link,linkTable;return linkTable=function($scope,$el,$attrs,$ctrl){var activeSectionName,applyAutoTab,getActiveSection,lastSearchResults,markSectionTabActive,renderFilterTabs,renderTableContent,tabsDom,templates;return applyAutoTab=!0,activeSectionName="userstories",tabsDom=$el.find(".search-filter"),lastSearchResults=null,getActiveSection=function(data){var i,len,maxVal,name,ref,selectedSection,value;if(maxVal=0,selectedSection={},selectedSection.name="userstories",selectedSection.value=[],!applyAutoTab)return selectedSection.name=activeSectionName,selectedSection.value=data[activeSectionName],selectedSection;if(data)for(ref=["userstories","issues","tasks","wikipages"],i=0,len=ref.length;len>i;i++)if(name=ref[i],value=data[name],value.length>maxVal){maxVal=value.length,selectedSection.name=name,selectedSection.value=value;break}return 0===maxVal?selectedSection:selectedSection},renderFilterTabs=function(data){var name,results,value;results=[];for(name in data)value=data[name],tabsDom.find("li."+name).show(),results.push(tabsDom.find("li."+name+" .num").html(value.length));return results},markSectionTabActive=function(section){return tabsDom.find("a.active").removeClass("active"),tabsDom.find("li."+section.name+" a").addClass("active"),applyAutoTab=!1,activeSectionName=section.name},templates={issues:$templatecache.get("search-issues"),tasks:$templatecache.get("search-tasks"),userstories:$templatecache.get("search-userstories"),wikipages:$templatecache.get("search-wikipages")},renderTableContent=function(section){var element,oldElements,oldScope,scope,template;return oldElements=$el.find(".search-result-table").children(),oldScope=oldElements.scope(),oldScope&&(oldScope.$destroy(),oldElements.remove()),scope=$scope.$new(),scope[section.name]=section.value,template=angular.element.parseHTML(trim(templates[section.name])),element=$compile(template)(scope),$el.find(".search-result-table").html(element)},$scope.$watch("searchResults",function(data){var activeSection;return(lastSearchResults=data)?(activeSection=getActiveSection(data),renderFilterTabs(data),renderTableContent(activeSection),markSectionTabActive(activeSection)):void 0}),$scope.$watch("searchTerm",function(searchTerm){return void 0!==searchTerm?$location.search("text",searchTerm):void 0}),$el.on("click",".search-filter li > a",function(event){var section,sectionData,sectionName,target;return event.preventDefault(),target=angular.element(event.currentTarget),sectionName=target.parent().data("name"),sectionData=lastSearchResults?lastSearchResults[sectionName]:[],section={name:sectionName,value:sectionData},$scope.$apply(function(){return renderTableContent(section),markSectionTabActive(section)})})},link=function($scope,$el,$attrs){var $ctrl,searchText;return $ctrl=$el.controller(),linkTable($scope,$el,$attrs,$ctrl),searchText=$routeparams.text,$scope.$watch("projectId",function(projectId){return null!=projectId?$scope.searchTerm=searchText:void 0})},{link:link}},module.directive("tgSearch",["$log","$compile","$templateCache","$routeParams","$tgLocation",SearchDirective])}.call(this),function(){var module;module=angular.module("taigaTaskboard",[])}.call(this),function(){var module;module=angular.module("taigaTasks",[])}.call(this),function(){var module;module=angular.module("taigaTeam",[])}.call(this),function(){var module;module=angular.module("taigaUserSettings",[])}.call(this),function(){var module;module=angular.module("taigaUserStories",[])}.call(this),function(){var module;module=angular.module("taigaWiki",[])}.call(this),function(){var AnalyticsService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,module=angular.module("taigaCommon"),AnalyticsService=function(superClass){function AnalyticsService(rootscope,log,config,win,doc,location){var conf;this.rootscope=rootscope,this.log=log,this.config=config,this.win=win,this.doc=doc,this.location=location,this.initialized=!1,conf=this.config.get("analytics",{}),this.accountId=conf.accountId,this.pageEvent=conf.pageEvent||"$routeChangeSuccess",this.trackRoutes=conf.trackRoutes||!0,this.ignoreFirstPageLoad=conf.ignoreFirstPageLoad||!1}return extend(AnalyticsService,superClass),AnalyticsService.$inject=["$rootScope","$log","$tgConfig","$window","$document","$location"],AnalyticsService.prototype.initialize=function(){return this.accountId?(this.injectAnalytics(),this.win.ga("create",this.accountId,"auto"),this.win.ga("require","displayfeatures"),this.trackRoutes&&!this.ignoreFirstPageLoad&&this.win.ga("send","pageview",this.getUrl()),this.trackRoutes&&this.rootscope.$on(this.pageEvent,function(_this){return function(){return _this.trackPage(_this.getUrl(),"Taiga")}}(this)),this.initialized=!0):void this.log.debug("Analytics: no acount id provided. Disabling.")},AnalyticsService.prototype.getUrl=function(){return this.location.path()},AnalyticsService.prototype.injectAnalytics=function(){var fn;return(fn=function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r,i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date,a=s.createElement(o),m=s.getElementsByTagName(o)[0],a.async=1,a.src=g,m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga")},AnalyticsService.prototype.trackPage=function(url,title){return this.initialized&&this.win.ga?(title=title||this.doc[0].title,this.win.ga("send","pageview",{page:url,title:title})):void 0},AnalyticsService.prototype.trackEvent=function(category,action,label,value){return this.initialized&&this.win.ga?this.win.ga("send","event",category,action,label,value):void 0},AnalyticsService}(taiga.Service),module.service("$tgAnalytics",AnalyticsService)}.call(this),function(){var BindScope,module;module=angular.module("taigaCommon"),BindScope=function(config){var link;return config.debugInfo||(jQuery.fn.scope=function(){return this.data("scope")}),link=function($scope,$el){return config.debugInfo?void 0:$el.data("scope",$scope).addClass("tg-scope")},{link:link}},module.directive("tgBindScope",["$tgConfig",BindScope])}.call(this),function(){var CompileHtmlDirective;CompileHtmlDirective=function($compile){var link;return link=function(scope,element,attrs){return scope.$watch(attrs.tgCompileHtml,function(newValue,oldValue){return element.html(newValue),$compile(element.contents())(scope)})},{link:link}},CompileHtmlDirective.$inject=["$compile"],angular.module("taigaCommon").directive("tgCompileHtml",CompileHtmlDirective)}.call(this),function(){var AssignedToDirective,BlockButtonDirective,CreatedByDisplayDirective,DateRangeDirective,DateSelectorDirective,DeleteButtonDirective,EditableDescriptionDirective,EditableSubjectDirective,EditableWysiwyg,ListItemAssignedtoDirective,ListItemIssueStatusDirective,ListItemPriorityDirective,ListItemSeverityDirective,ListItemTaskStatusDirective,ListItemTypeDirective,ListItemUsStatusDirective,SprintProgressBarDirective,TgMainTitleDirective,TgProgressBarDirective,WatchersDirective,bindOnce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),DateRangeDirective=function($translate){var link,renderRange;return renderRange=function($el,first,second){var endDate,initDate,prettyDate;return prettyDate=$translate.instant("BACKLOG.SPRINTS.DATE"),initDate=moment(first).format(prettyDate),endDate=moment(second).format(prettyDate),$el.html(initDate+"-"+endDate)},link=function($scope,$el,$attrs){var first,ref,second;return ref=$attrs.tgDateRange.split(","),first=ref[0],second=ref[1],bindOnce($scope,first,function(valFirst){return bindOnce($scope,second,function(valSecond){return renderRange($el,valFirst,valSecond)})})},{link:link}},module.directive("tgDateRange",["$translate",DateRangeDirective]),DateSelectorDirective=function($rootscope,datePickerConfigService){var link;return link=function($scope,$el,$attrs,$model){var initialize,selectedDate,unbind;return selectedDate=null,initialize=function(){var datePickerConfig;return datePickerConfig=datePickerConfigService.get(),_.merge(datePickerConfig,{field:$el[0],onSelect:function(_this){return function(date){return selectedDate=date}}(this),onOpen:function(_this){return function(){return null!=selectedDate?$el.picker.setDate(selectedDate):void 0}}(this)}),$el.picker=new Pikaday(datePickerConfig)},unbind=$rootscope.$on("$translateChangeEnd",function(_this){return function(ctx){return initialize()}}(this)),$scope.$watch($attrs.ngModel,function(val){return null==val||$el.picker||initialize(),null!=val?$el.picker.setDate(val):void 0}),$scope.$on("$destroy",function(){return $el.off(),unbind()})},{link:link,require:"ngModel"}},module.directive("tgDateSelector",["$rootScope","tgDatePickerConfigService",DateSelectorDirective]),SprintProgressBarDirective=function(){var link,renderProgress;return renderProgress=function($el,percentage,visual_percentage){return $el.hasClass(".current-progress")?$el.css("width",percentage+"%"):($el.find(".current-progress").css("width",visual_percentage+"%"),$el.find(".number").html(percentage+" %"))},link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgSprintProgressbar,function(sprint){var closedPoints,percentage,totalPoints,visual_percentage;return closedPoints=sprint.closed_points,totalPoints=sprint.total_points,percentage=0,0!==totalPoints&&(percentage=Math.round(100*(closedPoints/totalPoints))),visual_percentage=0,0!==totalPoints&&(visual_percentage=Math.round(98*(closedPoints/totalPoints))),renderProgress($el,percentage,visual_percentage)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgSprintProgressbar",SprintProgressBarDirective),CreatedByDisplayDirective=function($template,$compile,$translate,$navUrls){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.ngModel,function(model){var ref;return null!=model?($scope.owner=model.owner_extra_info||{full_name_display:$translate.instant("COMMON.EXTERNAL_USER"),photo:"/"+window._version+"/images/user-noimage.png"},$scope.url=(null!=(ref=$scope.owner)?ref.is_active:void 0)?$navUrls.resolve("user-profile",{username:$scope.owner.username}):"",$scope.date=moment(model.created_date).format($translate.instant("COMMON.DATETIME"))):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",scope:!0,templateUrl:"common/components/created-by.html"}},module.directive("tgCreatedByDisplay",["$tgTemplate","$compile","$translate","$tgNavUrls",CreatedByDisplayDirective]),WatchersDirective=function($rootscope,$confirm,$repo,$qqueue,$template,$compile,$translate){var link,template;return template=$template.get("common/components/watchers.html",!0),link=function($scope,$el,$attrs,$model){var deleteWatcher,isEditable,renderWatchers,save;return isEditable=function(){var ref,ref1;return-1!==(null!=(ref=$scope.project)&&null!=(ref1=ref.my_permissions)?ref1.indexOf($attrs.requiredPerm):void 0)},save=$qqueue.bindAdd(function(_this){return function(watchers){var item,promise;return item=$model.$modelValue.clone(),item.watchers=watchers,$model.$setViewValue(item),promise=$repo.save($model.$modelValue),promise.then(function(){return watchers=_.map(watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $model.$modelValue.revert(),$confirm.notify("error")})}}(this)),deleteWatcher=$qqueue.bindAdd(function(_this){return function(watcherIds){var item,promise;return item=$model.$modelValue.clone(),item.watchers=watcherIds,$model.$setViewValue(item),promise=$repo.save($model.$modelValue),promise.then(function(){var watchers;return watchers=_.map(item.watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return item.revert(),$confirm.notify("error")})}}(this)),renderWatchers=function(watchers){var ctx,html;return ctx={watchers:watchers,isEditable:isEditable()},html=$compile(template(ctx))($scope),$el.html(html)},$el.on("click",".js-delete-watcher",function(event){var message,target,title,watcherId;return event.preventDefault(),isEditable()?(target=angular.element(event.currentTarget),watcherId=target.data("watcher-id"),title=$translate.instant("COMMON.WATCHERS.TITLE_LIGHTBOX_DELETE_WARTCHER"),message=$scope.usersById[watcherId].full_name_display,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var watcherIds;return askResponse.finish(),watcherIds=_.clone($model.$modelValue.watchers,!1),watcherIds=_.pull(watcherIds,watcherId),deleteWatcher(watcherIds)}}(this))):void 0}),$scope.$on("watcher:added",function(ctx,watcherId){var watchers;return watchers=_.clone($model.$modelValue.watchers,!1),watchers.push(watcherId),watchers=_.uniq(watchers),save(watchers)}),$scope.$watch($attrs.ngModel,function(item){var watchers;if(null!=item)return watchers=_.map(item.watchers,function(watcherId){return $scope.usersById[watcherId]}),renderWatchers(watchers)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgWatchers",["$rootScope","$tgConfirm","$tgRepo","$tgQqueue","$tgTemplate","$compile","$translate",WatchersDirective]),AssignedToDirective=function($rootscope,$confirm,$repo,$loading,$qqueue,$template,$translate,$compile,$currentUserService){var link,template;return template=$template.get("common/components/assigned-to.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,renderAssignedTo,save;return isEditable=function(){var ref,ref1;return-1!==(null!=(ref=$scope.project)&&null!=(ref1=ref.my_permissions)?ref1.indexOf($attrs.requiredPerm):void 0)},save=$qqueue.bindAdd(function(_this){return function(userId){var currentLoading,promise;return $model.$modelValue.assigned_to=userId,currentLoading=$loading().target($el).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return currentLoading.finish(),renderAssignedTo($model.$modelValue),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $model.$modelValue.revert(),$confirm.notify("error"),currentLoading.finish()}),promise}}(this)),renderAssignedTo=function(assignedObject){var ctx,fullName,html,isIocaine,isUnassigned,photo;return null!=(null!=assignedObject?assignedObject.assigned_to:void 0)?(fullName=assignedObject.assigned_to_extra_info.full_name_display,photo=assignedObject.assigned_to_extra_info.photo,isUnassigned=!1):(fullName=$translate.instant("COMMON.ASSIGNED_TO.ASSIGN"),photo="/"+window._version+"/images/unnamed.png",isUnassigned=!0),isIocaine=null!=assignedObject?assignedObject.is_iocaine:void 0,ctx={fullName:fullName,photo:photo,isUnassigned:isUnassigned,isEditable:isEditable(),isIocaine:isIocaine,fullNameVisible:!(isUnassigned&&!$currentUserService.isAuthenticated())},html=$compile(template(ctx))($scope),$el.html(html)},$el.on("click",".user-assigned",function(event){return event.preventDefault(),isEditable()?$scope.$apply(function(){return $rootscope.$broadcast("assigned-to:add",$model.$modelValue)}):void 0}),$el.on("click",".assign-to-me",function(event){return event.preventDefault(),isEditable()?($model.$modelValue.assigned_to=$currentUserService.getUser().get("id"),save($currentUserService.getUser().get("id"))):void 0}),$el.on("click",".icon-delete",function(event){var title;return event.preventDefault(),isEditable()?(title=$translate.instant("COMMON.ASSIGNED_TO.CONFIRM_UNASSIGNED"), +$confirm.ask(title).then(function(_this){return function(response){return response.finish(),$model.$modelValue.assigned_to=null,save(null)}}(this))):void 0}),$scope.$on("assigned-to:added",function(ctx,userId,item){return item.id===$model.$modelValue.id?save(userId):void 0}),$scope.$watch($attrs.ngModel,function(instance){return renderAssignedTo(instance)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgAssignedTo",["$rootScope","$tgConfirm","$tgRepo","$tgLoading","$tgQqueue","$tgTemplate","$translate","$compile","tgCurrentUserService",AssignedToDirective]),BlockButtonDirective=function($rootscope,$loading,$template){var link,template;return template=$template.get("common/components/block-button.html"),link=function($scope,$el,$attrs,$model){var isEditable;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},$scope.$watch($attrs.ngModel,function(item){return item?(isEditable()&&$el.find(".item-block").addClass("editable"),item.is_blocked?($el.find(".item-block").removeClass("is-active"),$el.find(".item-unblock").addClass("is-active")):($el.find(".item-block").addClass("is-active"),$el.find(".item-unblock").removeClass("is-active"))):void 0}),$el.on("click",".item-block",function(event){return event.preventDefault(),$rootscope.$broadcast("block",$model.$modelValue)}),$el.on("click",".item-unblock",function(event){var currentLoading,finish;return event.preventDefault(),currentLoading=$loading().target($el.find(".item-unblock")).start(),finish=function(){return currentLoading.finish()},$rootscope.$broadcast("unblock",$model.$modelValue,finish)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgBlockButton",["$rootScope","$tgLoading","$tgTemplate",BlockButtonDirective]),DeleteButtonDirective=function($log,$repo,$confirm,$location,$template){var link,template;return template=$template.get("common/components/delete-button.html"),link=function($scope,$el,$attrs,$model){return $attrs.onDeleteGoToUrl?$attrs.onDeleteTitle?($el.on("click",".button-delete",function(event){var subtitle,title;return title=$attrs.onDeleteTitle,subtitle=$model.$modelValue.subject,$confirm.askOnDelete(title,subtitle).then(function(_this){return function(askResponse){var promise;return promise=$repo.remove($model.$modelValue),promise.then(function(){var url;return askResponse.finish(),url=$scope.$eval($attrs.onDeleteGoToUrl),$location.path(url)}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})}}(this))}),$scope.$on("$destroy",function(){return $el.off()})):$log.error("DeleteButtonDirective requires on-delete-title set in scope."):$log.error("DeleteButtonDirective requires on-delete-go-to-url set in scope.")},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgDeleteButton",["$log","$tgRepo","$tgConfirm","$tgLocation","$tgTemplate",DeleteButtonDirective]),EditableSubjectDirective=function($rootscope,$repo,$confirm,$loading,$qqueue,$template){var link,template;return template=$template.get("common/components/editable-subject.html"),link=function($scope,$el,$attrs,$model){var isEditable,save;return $scope.$on("object:updated",function(){return $el.find(".edit-subject").hide(),$el.find(".view-subject").show()}),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm)},save=$qqueue.bindAdd(function(_this){return function(subject){var currentLoading,promise;return $model.$modelValue.subject=subject,currentLoading=$loading().target($el.find(".save-container")).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$el.find(".edit-subject").hide(),$el.find(".view-subject").show()}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()}),promise}}(this)),$el.click(function(){return isEditable()?($el.find(".edit-subject").show(),$el.find(".view-subject").hide(),$el.find("input").focus()):void 0}),$el.on("click",".save",function(e){var subject;return e.preventDefault(),subject=$scope.item.subject,save(subject)}),$el.on("keyup","input",function(event){var subject;return 13===event.keyCode?(subject=$scope.item.subject,save(subject)):27===event.keyCode?($scope.$apply(function(_this){return function(){return $model.$modelValue.revert()}}(this)),$el.find("div.edit-subject").hide(),$el.find("div.view-subject").show()):void 0}),$el.find("div.edit-subject").hide(),$el.find("div.view-subject span.edit").hide(),$scope.$watch($attrs.ngModel,function(value){return value?($scope.item=value,isEditable()?void 0:$el.find(".view-subject .edit").remove()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgEditableSubject",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate",EditableSubjectDirective]),EditableDescriptionDirective=function($rootscope,$repo,$confirm,$compile,$loading,$selectedText,$qqueue,$template){var link,noDescriptionMegEditMode,noDescriptionMegReadMode,template;return template=$template.get("common/components/editable-description.html"),noDescriptionMegEditMode=$template.get("common/components/editable-description-msg-edit-mode.html"),noDescriptionMegReadMode=$template.get("common/components/editable-description-msg-read-mode.html"),link=function($scope,$el,$attrs,$model){var isEditable,save;return $el.find(".edit-description").hide(),$el.find(".view-description .edit").hide(),$scope.$on("object:updated",function(){return $el.find(".edit-description").hide(),$el.find(".view-description").show()}),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm)},save=$qqueue.bindAdd(function(_this){return function(description){var currentLoading,promise;return $model.$modelValue.description=description,currentLoading=$loading().target($el.find(".save-container")).start(),promise=$repo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$el.find(".edit-description").hide(),$el.find(".view-description").show()}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()})}}(this)),$el.on("mouseup",".view-description",function(event){var target;return target=angular.element(event.target),!isEditable()||target.is("a")||$selectedText.get().length?void 0:($el.find(".edit-description").show(),$el.find(".view-description").hide(),$el.find("textarea").focus())}),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("click",".save",function(e){var description;return e.preventDefault(),description=$scope.item.description,save(description)}),$el.on("keydown","textarea",function(event){return 27===event.keyCode?($scope.$apply(function(_this){return function(){return $scope.item.revert()}}(this)),$el.find(".edit-description").hide(),$el.find(".view-description").show()):void 0}),$scope.$watch($attrs.ngModel,function(value){return value?($scope.item=value,isEditable()?($el.find(".view-description .edit").show(),$el.find(".view-description .us-content").addClass("editable"),$scope.noDescriptionMsg=$compile(noDescriptionMegEditMode)($scope)):$scope.noDescriptionMsg=$compile(noDescriptionMegReadMode)($scope)):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",template:template}},module.directive("tgEditableDescription",["$rootScope","$tgRepo","$tgConfirm","$compile","$tgLoading","$selectedText","$tgQqueue","$tgTemplate",EditableDescriptionDirective]),EditableWysiwyg=function(attachmentsService,attachmentsFullService){var link;return link=function($scope,$el,$attrs,$model){var isInEditMode,uploadFile;return isInEditMode=function(){return $el.find("textarea").is(":visible")},uploadFile=function(file,type){return attachmentsService.validate(file)?attachmentsFullService.addAttachment($model.$modelValue.project,$model.$modelValue.id,type,file).then(function(result){return taiga.isImage(result.getIn(["file","name"]))?"!["+result.getIn(["file","name"])+"]("+result.getIn(["file","url"])+")":"["+result.getIn(["file","name"])+"]("+result.getIn(["file","url"])+")"}):void 0},$el.on("dragover",function(e){var textarea;return textarea=$el.find("textarea").focus(),!1}),$el.on("drop",function(e){var dataTransfer,promises,textarea,type;return e.stopPropagation(),e.preventDefault(),isInEditMode()?(dataTransfer=e.dataTransfer||e.originalEvent&&e.originalEvent.dataTransfer,textarea=$el.find("textarea"),textarea.addClass("in-progress"),type=$model.$modelValue._name,"userstories"===type?type="us":"tasks"===type?type="task":"issues"===type?type="issue":"wiki"===type&&(type="wiki_page"),promises=_.map(dataTransfer.files,function(file){return uploadFile(file,type)}),Promise.all(promises).then(function(result){return textarea=$el.find("textarea"),$.markItUp({replaceWith:result.join(" ")}),textarea.removeClass("in-progress")})):void 0})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgEditableWysiwyg",["tgAttachmentsService","tgAttachmentsFullService",EditableWysiwyg]),ListItemUsStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var us;return us=$scope.$eval($attrs.tgListitemUsStatus),bindOnce($scope,"usStatusById",function(usStatusById){return $el.html(usStatusById[us.status].name)})},{link:link}},module.directive("tgListitemUsStatus",ListItemUsStatusDirective),ListItemTaskStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var task;return task=$scope.$eval($attrs.tgListitemTaskStatus),bindOnce($scope,"taskStatusById",function(taskStatusById){return $el.html(taskStatusById[task.status].name)})},{link:link}},module.directive("tgListitemTaskStatus",ListItemTaskStatusDirective),ListItemAssignedtoDirective=function($template,$translate){var link,template;return template=$template.get("common/components/list-item-assigned-to-avatar.html",!0),link=function($scope,$el,$attrs){return bindOnce($scope,"usersById",function(usersById){var ctx,item,member;return item=$scope.$eval($attrs.tgListitemAssignedto),ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=usersById[item.assigned_to],member&&(ctx.imgurl=member.photo,ctx.name=member.full_name_display),$el.html(template(ctx))})},{link:link}},module.directive("tgListitemAssignedto",["$tgTemplate","$translate",ListItemAssignedtoDirective]),ListItemIssueStatusDirective=function(){var link;return link=function($scope,$el,$attrs){var issue;return issue=$scope.$eval($attrs.tgListitemIssueStatus),bindOnce($scope,"issueStatusById",function(issueStatusById){return $el.html(issueStatusById[issue.status].name)})},{link:link}},module.directive("tgListitemIssueStatus",ListItemIssueStatusDirective),ListItemTypeDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(issueTypeById,issue){var domNode,type;return type=issueTypeById[issue.type],domNode=$el.find(".level"),domNode.css("background-color",type.color),domNode.attr("title",type.name)},bindOnce($scope,"issueTypeById",function(issueTypeById){var issue;return issue=$scope.$eval($attrs.tgListitemType),render(issueTypeById,issue)}),$scope.$watch($attrs.tgListitemType,function(issue){return render($scope.issueTypeById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemType",ListItemTypeDirective),ListItemPriorityDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(priorityById,issue){var domNode,priority;return priority=priorityById[issue.priority],domNode=$el.find(".level"),domNode.css("background-color",priority.color),domNode.attr("title",priority.name)},bindOnce($scope,"priorityById",function(priorityById){var issue;return issue=$scope.$eval($attrs.tgListitemPriority),render(priorityById,issue)}),$scope.$watch($attrs.tgListitemPriority,function(issue){return render($scope.priorityById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemPriority",ListItemPriorityDirective),ListItemSeverityDirective=function(){var link;return link=function($scope,$el,$attrs){var render;return render=function(severityById,issue){var domNode,severity;return severity=severityById[issue.severity],domNode=$el.find(".level"),domNode.css("background-color",severity.color),domNode.attr("title",severity.name)},bindOnce($scope,"severityById",function(severityById){var issue;return issue=$scope.$eval($attrs.tgListitemSeverity),render(severityById,issue)}),$scope.$watch($attrs.tgListitemSeverity,function(issue){return render($scope.severityById,issue)})},{link:link,templateUrl:"common/components/level.html"}},module.directive("tgListitemSeverity",ListItemSeverityDirective),TgProgressBarDirective=function($template){var link,render,template;return template=$template.get("common/components/progress-bar.html",!0),render=function(el,percentage){return el.html(template({percentage:percentage}))},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch($attrs.tgProgressBar,function(percentage){return percentage=_.max([0,percentage]),percentage=_.min([100,percentage]),render($el,percentage)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProgressBar",["$tgTemplate",TgProgressBarDirective]),TgMainTitleDirective=function($translate){var link;return link=function($scope,$el,$attrs){return $attrs.$observe("i18nSectionName",function(i18nSectionName){return $scope.sectionName=i18nSectionName}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,templateUrl:"common/components/main-title.html",scope:{projectName:"=projectName"}}},module.directive("tgMainTitle",["$translate",TgMainTitleDirective])}.call(this),function(){var ConfirmService,NOTIFICATION_MSG,bindMethods,cancelTimeout,debounce,module,taiga,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,timeout=this.taiga.timeout,cancelTimeout=this.taiga.cancelTimeout,debounce=this.taiga.debounce,bindMethods=this.taiga.bindMethods,NOTIFICATION_MSG={success:{title:"NOTIFICATION.OK",message:"NOTIFICATION.SAVED"},error:{title:"NOTIFICATION.WARNING",message:"NOTIFICATION.WARNING_TEXT"},"light-error":{title:"NOTIFICATION.WARNING",message:"NOTIFICATION.WARNING_TEXT"}},ConfirmService=function(superClass){function ConfirmService(q,lightboxService,loading,translate){this.q=q,this.lightboxService=lightboxService,this.loading=loading,this.translate=translate,bindMethods(this)}return extend(ConfirmService,superClass),ConfirmService.$inject=["$q","lightboxService","$tgLoading","$translate"],ConfirmService.prototype.hide=function(el){return el?(this.lightboxService.close(el),el.off(".confirm-dialog")):void 0},ConfirmService.prototype.ask=function(title,subtitle,message,lightboxSelector){var defered,el;return null==lightboxSelector&&(lightboxSelector=".lightbox-generic-ask"),defered=this.q.defer(),el=angular.element(lightboxSelector),el.find("h2.title").text(title),el.find("span.subtitle").text(subtitle),el.find("span.message").text(message),el.on("click.confirm-dialog","a.button-green",debounce(2e3,function(_this){return function(event){var currentLoading,target;return event.preventDefault(),target=angular.element(event.currentTarget),currentLoading=_this.loading().target(target).start(),defered.resolve({finish:function(ok){return null==ok&&(ok=!0),currentLoading.finish(),ok?_this.hide(el):void 0}})}}(this))),el.on("click.confirm-dialog","a.button-red",function(_this){return function(event){return event.preventDefault(),defered.reject(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.askOnDelete=function(title,message){return this.ask(title,this.translate.instant("NOTIFICATION.ASK_DELETE"),message)},ConfirmService.prototype.askChoice=function(title,subtitle,choices,replacement,warning,lightboxSelector){var choicesField,defered,el;return null==lightboxSelector&&(lightboxSelector=".lightbox-ask-choice"),defered=this.q.defer(),el=angular.element(lightboxSelector),el.find(".title").text(title),el.find(".subtitle").text(subtitle),replacement?el.find(".replacement").text(replacement):el.find(".replacement").remove(),warning?el.find(".warning").text(warning):el.find(".warning").remove(),choicesField=el.find(".choices"),choicesField.html(""),_.each(choices,function(value,key){return value=_.escape(value),choicesField.append(angular.element(""))}),el.on("click.confirm-dialog","a.button-green",debounce(2e3,function(_this){return function(event){var currentLoading,target;return event.preventDefault(),target=angular.element(event.currentTarget),currentLoading=_this.loading().target(target).start(),defered.resolve({selected:choicesField.val(),finish:function(ok){return null==ok&&(ok=!0),currentLoading.finish(),ok?_this.hide(el):void 0}})}}(this))),el.on("click.confirm-dialog","a.button-red",function(_this){return function(event){return event.preventDefault(),defered.reject(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.error=function(message){var defered,el;return defered=this.q.defer(),el=angular.element(".lightbox-generic-error"),el.find("h2.title").html(message),el.on("click.confirm-dialog","a.button-green",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),el.on("click.confirm-dialog","a.close",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.success=function(title,message){var defered,el;return defered=this.q.defer(),el=angular.element(".lightbox-generic-success"),title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),el.on("click.confirm-dialog","a.button-green",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),el.on("click.confirm-dialog","a.close",function(_this){return function(event){return event.preventDefault(),defered.resolve(),_this.hide(el)}}(this)),this.lightboxService.open(el),defered.promise},ConfirmService.prototype.loader=function(title,message){var el;return el=angular.element(".lightbox-generic-loading"),title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),{start:function(_this){return function(){return _this.lightboxService.open(el)}}(this),stop:function(_this){return function(){return _this.lightboxService.close(el)}}(this),update:function(_this){return function(status,title,message,percent){return title&&el.find("h2.title").html(title),message&&el.find("p.message").html(message),percent?(el.find(".spin").addClass("hidden"),el.find(".progress-bar-wrapper").removeClass("hidden"),el.find(".progress-bar-wrapper > .bar").width(percent+"%"),el.find(".progress-bar-wrapper > span").html(percent+"%").css("left",percent-9+"%")):(el.find(".spin").removeClass("hidden"),el.find(".progress-bar-wrapper").addClass("hidden"))}}(this)}},ConfirmService.prototype.notify=function(type,message,title,time){var body,el,selector;return selector=".notification-message-"+type,el=angular.element(selector),el.hasClass("active")?void 0:(title?el.find("h4").html(title):el.find("h4").html(this.translate.instant(NOTIFICATION_MSG[type].title)),message?el.find("p").html(message):el.find("p").html(this.translate.instant(NOTIFICATION_MSG[type].message)),body=angular.element("body"),body.find(".notification-message .notification-light").removeClass("active").addClass("inactive"),body.find(selector).removeClass("inactive").addClass("active"),this.tsem&&cancelTimeout(this.tsem),time||(time="error"===type||"light-error"===type?3500:1500),this.tsem=timeout(time,function(_this){return function(){return body.find(selector).removeClass("active").addClass("inactive"),delete _this.tsem}}(this)),el.on("click",".icon-delete, .close",function(_this){return function(event){return body.find(selector).removeClass("active").addClass("inactive")}}(this)))},ConfirmService}(taiga.Service),module=angular.module("taigaCommon"),module.service("$tgConfirm",ConfirmService)}.call(this),function(){var CustomAttributeValueDirective,CustomAttributesValuesController,CustomAttributesValuesDirective,DATE_TYPE,MULTILINE_TYPE,TEXT_TYPE,TYPE_CHOICES,bindMethods,bindOnce,debounce,generateHash,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,bindMethods=this.taiga.bindMethods,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,generateHash=taiga.generateHash,module=angular.module("taigaCommon"),TEXT_TYPE="text",MULTILINE_TYPE="multiline",DATE_TYPE="date",TYPE_CHOICES=[{key:TEXT_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT"},{key:MULTILINE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI"},{key:DATE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE"}],CustomAttributesValuesController=function(superClass){function CustomAttributesValuesController(scope,rootscope,repo,rs,confirm,q){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.confirm=confirm,this.q=q,bindMethods(this),this.type=null,this.objectId=null,this.projectId=null,this.customAttributes=[],this.customAttributesValues=null}return extend(CustomAttributesValuesController,superClass),CustomAttributesValuesController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$tgConfirm","$q"],CustomAttributesValuesController.prototype.initialize=function(type,objectId){return this.project=this.scope.project,this.type=type,this.objectId=objectId,this.projectId=this.scope.projectId},CustomAttributesValuesController.prototype.loadCustomAttributesValues=function(){return this.objectId?this.rs.customAttributesValues[this.type].get(this.objectId).then(function(_this){return function(customAttributesValues){return _this.customAttributes=_this.project[_this.type+"_custom_attributes"],_this.customAttributesValues=customAttributesValues,customAttributesValues}}(this)):this.customAttributesValues},CustomAttributesValuesController.prototype.getAttributeValue=function(attribute){var attributeValue;return attributeValue=_.clone(attribute,!1),attributeValue.value=this.customAttributesValues.attributes_values[attribute.id],attributeValue},CustomAttributesValuesController.prototype.updateAttributeValue=function(attributeValue){var attributesValues,onError,onSuccess;return onSuccess=function(_this){return function(){return _this.rootscope.$broadcast("custom-attributes-values:edit")}}(this),onError=function(_this){return function(response){return _this.confirm.notify("error"),_this.q.reject()}}(this),attributesValues=_.clone(this.customAttributesValues.attributes_values,!0),attributesValues[attributeValue.id]=attributeValue.value,this.customAttributesValues.attributes_values=attributesValues,this.customAttributesValues.id=this.objectId,this.repo.save(this.customAttributesValues).then(onSuccess,onError)},CustomAttributesValuesController}(taiga.Controller),CustomAttributesValuesDirective=function($templates,$storage){var collapsedHash,link,template,templateFn;return template=$templates.get("custom-attributes/custom-attributes-values.html",!0),collapsedHash=function(type){return generateHash(["custom-attributes-collapsed",type])},link=function($scope,$el,$attrs,$ctrls){var $ctrl,$model;return $ctrl=$ctrls[0],$model=$ctrls[1],bindOnce($scope,$attrs.ngModel,function(value){return $ctrl.initialize($attrs.type,value.id),$ctrl.loadCustomAttributesValues()}),$el.on("click",".custom-fields-header a",function(){var collapsed,hash;return hash=collapsedHash($attrs.type),collapsed=!$storage.get(hash),$storage.set(hash,collapsed),collapsed?($el.find(".custom-fields-header a").removeClass("open"),$el.find(".custom-fields-body").removeClass("open")):($el.find(".custom-fields-header a").addClass("open"),$el.find(".custom-fields-body").addClass("open"))}),$scope.$on("$destroy",function(){return $el.off()})},templateFn=function($el,$attrs){var collapsed;return collapsed=$storage.get(collapsedHash($attrs.type))||!1,template({requiredEditionPerm:$attrs.requiredEditionPerm,collapsed:collapsed})},{require:["tgCustomAttributesValues","ngModel"],controller:CustomAttributesValuesController,controllerAs:"ctrl",restrict:"AE",scope:!0,link:link,template:templateFn}},module.directive("tgCustomAttributesValues",["$tgTemplate","$tgStorage","$translate",CustomAttributesValuesDirective]),CustomAttributeValueDirective=function($template,$selectedText,$compile,$translate,datePickerConfigService){var link,template,templateEdit;return template=$template.get("custom-attributes/custom-attribute-value.html",!0),templateEdit=$template.get("custom-attributes/custom-attribute-value-edit.html",!0),link=function($scope,$el,$attrs,$ctrl){var attributeValue,isEditable,prettyDate,render,setFocusAndSelectOnInputField,submit;return prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),render=function(attributeValue,edit){var ctx,datePickerConfig,editable,html,value;return null==edit&&(edit=!1),value=attributeValue.type===DATE_TYPE&&attributeValue.value?moment(attributeValue.value,"YYYY-MM-DD").format(prettyDate):attributeValue.value,editable=isEditable(),ctx={id:attributeValue.id,name:attributeValue.name,description:attributeValue.description,value:value,isEditable:editable,type:attributeValue.type},!editable||!edit&&value?(html=template(ctx),html=$compile(html)($scope),$el.html(html)):(html=templateEdit(ctx),html=$compile(html)($scope),$el.html(html),attributeValue.type===DATE_TYPE?(datePickerConfig=datePickerConfigService.get(),_.merge(datePickerConfig,{field:$el.find("input[name=value]")[0],onSelect:function(_this){return function(date){var selectedDate;return selectedDate=date}}(this),onOpen:function(_this){return function(){return"undefined"!=typeof selectedDate&&null!==selectedDate?$el.picker.setDate(selectedDate):void 0}}(this)}),$el.picker=new Pikaday(datePickerConfig)):void 0)},isEditable=function(){var permissions,requiredEditionPerm;return permissions=$scope.project.my_permissions,requiredEditionPerm=$attrs.requiredEditionPerm,permissions.indexOf(requiredEditionPerm)>-1},submit=debounce(2e3,function(_this){return function(event){return event.preventDefault(),attributeValue.value=$el.find("input[name=value], textarea[name='value']").val(),attributeValue.type===DATE_TYPE&&(moment(attributeValue.value,prettyDate).isValid()?attributeValue.value=moment(attributeValue.value,prettyDate).format("YYYY-MM-DD"):attributeValue.value=""),$scope.$apply(function(){return $ctrl.updateAttributeValue(attributeValue).then(function(){return render(attributeValue,!1)})})}}(this)),setFocusAndSelectOnInputField=function(){return $el.find("input[name='value'], textarea[name='value']").focus().select()},attributeValue=$scope.$eval($attrs.tgCustomAttributeValue),render(attributeValue),$el.on("click",".js-value-view-mode",function(){return isEditable()&&!$selectedText.get().length?(render(attributeValue,!0),setFocusAndSelectOnInputField()):void 0}),$el.on("click","a.icon-edit",function(event){return event.preventDefault(),render(attributeValue,!0),setFocusAndSelectOnInputField()}),$el.on("keyup","input[name=value], textarea[name='value']",function(event){return 13===event.keyCode&&"textarea"!==event.currentTarget.type?submit(event):27===event.keyCode?render(attributeValue,!1):void 0}),$el.on("submit","form",submit),$el.on("click","a.icon-floppy",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"^tgCustomAttributesValues",restrict:"AE"}},module.directive("tgCustomAttributeValue",["$tgTemplate","$selectedText","$compile","$translate","tgDatePickerConfigService",CustomAttributeValueDirective])}.call(this),function(){var EstimationsService,LbUsEstimationDirective,UsEstimationDirective,groupBy,module,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,groupBy=this.taiga.groupBy,module=angular.module("taigaCommon"),LbUsEstimationDirective=function($tgEstimationsService,$rootScope,$repo,$template,$compile){var link;return link=function($scope,$el,$attrs,$model){return $scope.$watch($attrs.ngModel,function(us){var estimationProcess;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return $scope.$apply(function(){return $model.$setViewValue(us)})},estimationProcess.render=function(){var ctx,html,mainTemplate,template;return ctx={totalPoints:this.calculateTotalPoints(),roles:this.calculateRoles(),editable:this.isEditable},mainTemplate="common/estimation/us-estimation-points-per-role.html",template=$template.get(mainTemplate,!0),html=template(ctx),html=$compile(html)($scope),this.$el.html(html)},estimationProcess.render()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgLbUsEstimation",["$tgEstimationsService","$rootScope","$tgRepo","$tgTemplate","$compile",LbUsEstimationDirective]),UsEstimationDirective=function($tgEstimationsService,$rootScope,$repo,$qqueue,$template,$compile){var link;return link=function($scope,$el,$attrs,$model){return $scope.$watch($attrs.ngModel,function(us){var estimationProcess;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return this.save(roleId,pointId).then(function(){return $rootScope.$broadcast("object:updated")})},estimationProcess.render=function(){var ctx,html,mainTemplate,template;return ctx={totalPoints:this.calculateTotalPoints(),roles:this.calculateRoles(),editable:this.isEditable},mainTemplate="common/estimation/us-estimation-points-per-role.html",template=$template.get(mainTemplate,!0),html=template(ctx),html=$compile(html)($scope),this.$el.html(html)},estimationProcess.render()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsEstimation",["$tgEstimationsService","$rootScope","$tgRepo","$tgQqueue","$tgTemplate","$compile",UsEstimationDirective]),EstimationsService=function($template,$qqueue,$repo,$confirm,$q){var EstimationProcess,create,pointsTemplate;return pointsTemplate=$template.get("common/estimation/us-estimation-points.html",!0),EstimationProcess=function(){function EstimationProcess($el1,us1,project1){this.$el=$el1,this.us=us1,this.project=project1,this.bindClickEvents=bind(this.bindClickEvents,this),this.isEditable=-1!==this.project.my_permissions.indexOf("modify_us"),this.roles=this.project.roles,this.points=this.project.points,this.pointsById=groupBy(this.points,function(x){return x.id}),this.onSelectedPointForRole=function(roleId,pointId){},this.render=function(){}}return EstimationProcess.prototype.save=function(roleId,pointId){var deferred;return deferred=$q.defer(),$qqueue.add(function(_this){return function(){var onError,onSuccess;return onSuccess=function(){return deferred.resolve()},onError=function(){return $confirm.notify("error"), +_this.us.revert(),_this.render(),deferred.reject()},$repo.save(_this.us).then(onSuccess,onError)}}(this)),deferred.promise},EstimationProcess.prototype.calculateTotalPoints=function(){var notNullValues,values;return values=_.map(this.us.points,function(_this){return function(v,k){var ref;return null!=(ref=_this.pointsById[v])?ref.value:void 0}}(this)),0===values.length?"0":(notNullValues=_.filter(values,function(v){return null!=v}),0===notNullValues.length?"?":_.reduce(notNullValues,function(acc,num){return acc+num}))},EstimationProcess.prototype.calculateRoles=function(){var computableRoles,roles;return computableRoles=_.filter(this.project.roles,"computable"),roles=_.map(computableRoles,function(_this){return function(role){var pointId,pointObj;return pointId=_this.us.points[role.id],pointObj=_this.pointsById[pointId],role=_.clone(role,!0),role.points=null!=pointObj&&null!=pointObj.name?pointObj.name:"?",role}}(this))},EstimationProcess.prototype.bindClickEvents=function(){return this.$el.on("click",".total.clickable",function(_this){return function(event){var roleId,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),roleId=target.data("role-id"),_this.renderPointsSelector(roleId,target),target.siblings().removeClass("active"),target.addClass("active")}}(this)),this.$el.on("click",".point",function(_this){return function(event){var pointId,points,roleId,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),roleId=target.data("role-id"),pointId=target.data("point-id"),_this.$el.find(".popover").popover().close(),points=_.clone(_this.us.points,!0),points[roleId]=pointId,_this.us.points=points,_this.render(),_this.onSelectedPointForRole(roleId,pointId)}}(this))},EstimationProcess.prototype.renderPointsSelector=function(roleId,target){var horizontalList,html,maxPointLength,points,pop;return points=_.map(this.points,function(_this){return function(point){return point=_.clone(point,!0),point.selected=_this.us.points[roleId]===point.id?!1:!0,point}}(this)),maxPointLength=5,horizontalList=_.some(points,function(_this){return function(point){return point.name.length>maxPointLength}}(this)),html=pointsTemplate({points:points,roleId:roleId,horizontal:horizontalList}),this.$el.find(".popover").popover().close(),this.$el.find(".pop-points-open").remove(),null!=target?this.$el.find(target).append(html):this.$el.append(html),this.$el.find(".pop-points-open").popover().open(function(){return $(this).removeClass("active").closest("li").removeClass("active")}),this.$el.find(".pop-points-open").show(),pop=this.$el.find(".pop-points-open"),pop.offset().top+pop.height()>document.body.clientHeight?pop.addClass("pop-bottom"):void 0},EstimationProcess}(),create=function($el,us,project){var estimationProcess;return $el.unbind("click"),estimationProcess=new EstimationProcess($el,us,project),estimationProcess.isEditable&&estimationProcess.bindClickEvents(),estimationProcess},{create:create}},module.factory("$tgEstimationsService",["$tgTemplate","$tgQqueue","$tgRepo","$tgConfirm","$q",EstimationsService])}.call(this),function(){var defaultFilter,module,momentFormat,momentFromNow,sizeFormat,taiga,unslugify,yesNoFilter;taiga=this.taiga,module=angular.module("taigaCommon"),defaultFilter=function(){return function(value,defaultValue){return value===[null,void 0]?defaultValue:value}},module.filter("default",defaultFilter),yesNoFilter=function($translate){return function(value){return value?$translate.instant("COMMON.YES"):$translate.instant("COMMON.NO")}},module.filter("yesNo",["$translate",yesNoFilter]),unslugify=function(){return taiga.unslugify},module.filter("unslugify",unslugify),momentFormat=function(){return function(input,format){return input?moment(input).format(format):""}},module.filter("momentFormat",momentFormat),momentFromNow=function(){return function(input,without_suffix){return input?moment(input).fromNow(without_suffix||!1):""}},module.filter("momentFromNow",momentFromNow),sizeFormat=function(_this){return function(){return _this.taiga.sizeFormat}}(this),module.filter("sizeFormat",sizeFormat)}.call(this),function(){var HistoryController,HistoryDirective,IGNORED_FIELDS,bindOnce,debounce,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaCommon"),IGNORED_FIELDS={"userstories.userstory":["watchers","kanban_order","backlog_order","sprint_order","finish_date","tribe_gig"],"tasks.task":["watchers","us_order","taskboard_order"],"issues.issue":["watchers"]},HistoryController=function(superClass){function HistoryController(scope,repo,rs){this.scope=scope,this.repo=repo,this.rs=rs}return extend(HistoryController,superClass),HistoryController.$inject=["$scope","$tgRepo","$tgResources"],HistoryController.prototype.initialize=function(type,objectId){return this.type=type,this.objectId=objectId},HistoryController.prototype.loadHistory=function(type,objectId){return this.rs.history.get(type,objectId).then(function(_this){return function(history){var changeModel,historyEntry,historyResult,i,j,len,len1;for(i=0,len=history.length;len>i;i++)historyResult=history[i],null!=historyResult.values_diff.description_diff&&(historyResult.values_diff.description=historyResult.values_diff.description_diff),delete historyResult.values_diff.description_html,delete historyResult.values_diff.description_diff,null!=historyResult.values_diff.blocked_note_diff&&(historyResult.values_diff.blocked_note=historyResult.values_diff.blocked_note_diff),delete historyResult.values_diff.blocked_note_html,delete historyResult.values_diff.blocked_note_diff;for(j=0,len1=history.length;len1>j;j++)historyEntry=history[j],changeModel=historyEntry.key.split(":")[0],null!=IGNORED_FIELDS[changeModel]&&(historyEntry.values_diff=_.removeKeys(historyEntry.values_diff,IGNORED_FIELDS[changeModel]));return _this.scope.history=_.filter(history,function(item){return Object.keys(item.values_diff).length>0}),_this.scope.comments=_.filter(history,function(item){return""!==item.comment})}}(this))},HistoryController.prototype.deleteComment=function(type,objectId,activityId){return this.rs.history.deleteComment(type,objectId,activityId).then(function(_this){return function(){return _this.loadHistory(type,objectId)}}(this))},HistoryController.prototype.undeleteComment=function(type,objectId,activityId){return this.rs.history.undeleteComment(type,objectId,activityId).then(function(_this){return function(){return _this.loadHistory(type,objectId)}}(this))},HistoryController}(taiga.Controller),HistoryDirective=function($log,$loading,$qqueue,$template,$confirm,$translate,$compile,$navUrls,$rootScope){var link,templateActivity,templateBase,templateBaseEntries,templateChangeAttachment,templateChangeDiff,templateChangeGeneric,templateChangeList,templateChangePoints,templateDeletedComment,templateFn;return templateChangeDiff=$template.get("common/history/history-change-diff.html",!0),templateChangePoints=$template.get("common/history/history-change-points.html",!0),templateChangeGeneric=$template.get("common/history/history-change-generic.html",!0),templateChangeAttachment=$template.get("common/history/history-change-attachment.html",!0),templateChangeList=$template.get("common/history/history-change-list.html",!0),templateDeletedComment=$template.get("common/history/history-deleted-comment.html",!0),templateActivity=$template.get("common/history/history-activity.html",!0),templateBaseEntries=$template.get("common/history/history-base-entries.html",!0),templateBase=$template.get("common/history/history-base.html",!0),link=function($scope,$el,$attrs,$ctrl){var countChanges,formatChange,getHumanizedFieldName,getPrettyDateFormat,objectId,renderActivity,renderAttachmentEntry,renderChange,renderChangeEntries,renderChangeEntry,renderChangesHelperText,renderComment,renderComments,renderCustomAttributesEntry,renderHistory,save,showAllActivity,showAllComments,type;return type=$attrs.type,objectId=null,showAllComments=!1,showAllActivity=!1,getPrettyDateFormat=function(){return $translate.instant("ACTIVITY.DATETIME")},bindOnce($scope,$attrs.ngModel,function(model){return type=$attrs.type,objectId=model.id,$ctrl.initialize(type,objectId),$ctrl.loadHistory(type,objectId)}),getHumanizedFieldName=function(field){var humanizedFieldNames;return humanizedFieldNames={subject:$translate.instant("ACTIVITY.FIELDS.SUBJECT"),name:$translate.instant("ACTIVITY.FIELDS.NAME"),description:$translate.instant("ACTIVITY.FIELDS.DESCRIPTION"),content:$translate.instant("ACTIVITY.FIELDS.CONTENT"),status:$translate.instant("ACTIVITY.FIELDS.STATUS"),is_closed:$translate.instant("ACTIVITY.FIELDS.IS_CLOSED"),finish_date:$translate.instant("ACTIVITY.FIELDS.FINISH_DATE"),type:$translate.instant("ACTIVITY.FIELDS.TYPE"),priority:$translate.instant("ACTIVITY.FIELDS.PRIORITY"),severity:$translate.instant("ACTIVITY.FIELDS.SEVERITY"),assigned_to:$translate.instant("ACTIVITY.FIELDS.ASSIGNED_TO"),watchers:$translate.instant("ACTIVITY.FIELDS.WATCHERS"),milestone:$translate.instant("ACTIVITY.FIELDS.MILESTONE"),user_story:$translate.instant("ACTIVITY.FIELDS.USER_STORY"),project:$translate.instant("ACTIVITY.FIELDS.PROJECT"),is_blocked:$translate.instant("ACTIVITY.FIELDS.IS_BLOCKED"),blocked_note:$translate.instant("ACTIVITY.FIELDS.BLOCKED_NOTE"),points:$translate.instant("ACTIVITY.FIELDS.POINTS"),client_requirement:$translate.instant("ACTIVITY.FIELDS.CLIENT_REQUIREMENT"),team_requirement:$translate.instant("ACTIVITY.FIELDS.TEAM_REQUIREMENT"),is_iocaine:$translate.instant("ACTIVITY.FIELDS.IS_IOCAINE"),tags:$translate.instant("ACTIVITY.FIELDS.TAGS"),attachments:$translate.instant("ACTIVITY.FIELDS.ATTACHMENTS"),is_deprecated:$translate.instant("ACTIVITY.FIELDS.IS_DEPRECATED"),blocked_note:$translate.instant("ACTIVITY.FIELDS.BLOCKED_NOTE"),is_blocked:$translate.instant("ACTIVITY.FIELDS.IS_BLOCKED"),order:$translate.instant("ACTIVITY.FIELDS.ORDER"),backlog_order:$translate.instant("ACTIVITY.FIELDS.BACKLOG_ORDER"),sprint_order:$translate.instant("ACTIVITY.FIELDS.SPRINT_ORDER"),kanban_order:$translate.instant("ACTIVITY.FIELDS.KANBAN_ORDER"),taskboard_order:$translate.instant("ACTIVITY.FIELDS.TASKBOARD_ORDER"),us_order:$translate.instant("ACTIVITY.FIELDS.US_ORDER")},humanizedFieldNames[field]||field},countChanges=function(comment){return _.keys(comment.values_diff).length},formatChange=function(change){return _.isArray(change)?0===change.length?$translate.instant("ACTIVITY.VALUES.EMPTY"):change.join(", "):""===change?$translate.instant("ACTIVITY.VALUES.EMPTY"):null==change||change===!1?$translate.instant("ACTIVITY.VALUES.NO"):change===!0?$translate.instant("ACTIVITY.VALUES.YES"):change},renderAttachmentEntry=function(value){var attachments;return attachments=_.map(value,function(changes,type){return"new"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.NEW_ATTACHMENT"),diff:change.filename})}):"deleted"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.DELETED_ATTACHMENT"),diff:change.filename})}):_.map(changes,function(change){var diff,name;return name=$translate.instant("ACTIVITY.UPDATED_ATTACHMENT",{filename:change.filename}),diff=_.map(change.changes,function(values,name){return{name:getHumanizedFieldName(name),from:formatChange(values[0]),to:formatChange(values[1])}}),templateChangeAttachment({name:name,diff:diff})})}),_.flatten(attachments).join("\n")},renderCustomAttributesEntry=function(value){var customAttributes;return customAttributes=_.map(value,function(changes,type){return"new"===type?_.map(changes,function(change){var html;return html=templateChangeGeneric({name:change.name,from:formatChange(""),to:formatChange(change.value)}),html=$compile(html)($scope),html[0].outerHTML}):"deleted"===type?_.map(changes,function(change){return templateChangeDiff({name:$translate.instant("ACTIVITY.DELETED_CUSTOM_ATTRIBUTE"),diff:change.name})}):_.map(changes,function(change){var customAttrsChanges;return customAttrsChanges=_.map(change.changes,function(values){return templateChangeGeneric({name:change.name,from:formatChange(values[0]),to:formatChange(values[1])})}),_.flatten(customAttrsChanges).join("\n")})}),_.flatten(customAttributes).join("\n")},renderChangeEntry=function(field,value){var added,from,html,name,removed,to;return"description"===field?templateChangeDiff({name:getHumanizedFieldName("description"),diff:value[1]}):"blocked_note"===field?templateChangeDiff({name:getHumanizedFieldName("blocked_note"),diff:value[1]}):"points"===field?(html=templateChangePoints({points:value}),html=$compile(html)($scope),html[0].outerHTML):"attachments"===field?renderAttachmentEntry(value):"custom_attributes"===field?renderCustomAttributesEntry(value):"tags"===field||"watchers"===field?(name=getHumanizedFieldName(field),removed=_.difference(value[0],value[1]),added=_.difference(value[1],value[0]),html=templateChangeList({name:name,removed:removed,added:added}),html=$compile(html)($scope),html[0].outerHTML):"assigned_to"===field?(name=getHumanizedFieldName(field),from=formatChange(value[0]||$translate.instant("ACTIVITY.VALUES.UNASSIGNED")),to=formatChange(value[1]||$translate.instant("ACTIVITY.VALUES.UNASSIGNED")),templateChangeGeneric({name:name,from:from,to:to})):(name=getHumanizedFieldName(field),from=formatChange(value[0]),to=formatChange(value[1]),templateChangeGeneric({name:name,from:from,to:to}))},renderChangeEntries=function(change){return _.map(change.values_diff,function(value,field){return renderChangeEntry(field,value)})},renderChangesHelperText=function(change){var size;return size=countChanges(change),$translate.instant("ACTIVITY.SIZE_CHANGE",{size:size},"messageformat")},renderComment=function(comment){var html,ref,ref1,ref2;return comment.delete_comment_date||(null!=(ref=comment.delete_comment_user)?ref.name:void 0)?(html=templateDeletedComment({deleteCommentDate:comment.delete_comment_date?moment(comment.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:comment.delete_comment_user.name,deleteComment:comment.comment_html,activityId:comment.id,canRestoreComment:$scope.user&&(comment.delete_comment_user.pk===$scope.user.id||$scope.project.my_permissions.indexOf("modify_project")>-1)}),html=$compile(html)($scope),html[0].outerHTML):(html=templateActivity({avatar:comment.user.photo,userFullName:comment.user.name,userProfileUrl:comment.user.is_active?$navUrls.resolve("user-profile",{username:comment.user.username}):"",creationDate:moment(comment.created_at).format(getPrettyDateFormat()),comment:comment.comment_html,changesText:renderChangesHelperText(comment),changes:renderChangeEntries(comment),mode:"comment",deleteCommentActionTitle:$translate.instant("COMMENTS.DELETE"),deleteCommentDate:comment.delete_comment_date?moment(comment.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:(null!=(ref1=comment.delete_comment_user)?ref1.name:void 0)?comment.delete_comment_user.name:void 0,activityId:comment.id,canDeleteComment:comment.user.pk===(null!=(ref2=$scope.user)?ref2.id:void 0)||$scope.project.my_permissions.indexOf("modify_project")>-1}),html=$compile(html)($scope),html[0].outerHTML)},renderChange=function(change){var ref;return templateActivity({avatar:change.user.photo,userFullName:change.user.name,userProfileUrl:change.user.is_active?$navUrls.resolve("user-profile",{username:change.user.username}):"",creationDate:moment(change.created_at).format(getPrettyDateFormat()),comment:change.comment_html,changes:renderChangeEntries(change),changesText:"",mode:"activity",deleteCommentDate:change.delete_comment_date?moment(change.delete_comment_date).format(getPrettyDateFormat()):void 0,deleteCommentUser:(null!=(ref=change.delete_comment_user)?ref.name:void 0)?change.delete_comment_user.name:void 0,activityId:change.id})},renderHistory=function(entries,totalEntries){var html,showMore;return showMore=entries.length===totalEntries?0:totalEntries-entries.length,html=templateBaseEntries({entries:entries,showMore:showMore}),html=$compile(html)($scope)},renderComments=function(){var comments,html,totalComments;return comments=$scope.comments||[],totalComments=comments.length,showAllComments||(comments=_.last(comments,4)),comments=_.map(comments,function(x){return renderComment(x)}),html=renderHistory(comments,totalComments),$el.find(".comments-list").html(html)},renderActivity=function(){var changes,html,totalChanges;return changes=$scope.history||[],totalChanges=changes.length,showAllActivity||(changes=_.last(changes,4)),changes=_.map(changes,function(x){return renderChange(x)}),html=renderHistory(changes,totalChanges),$el.find(".changes-list").html(html)},save=$qqueue.bindAdd(function(_this){return function(target){var currentLoading,model,onError,onSuccess;return $scope.$broadcast("markdown-editor:submit"),$el.find(".comment-list").addClass("activeanimation"),currentLoading=$loading().target(target).start(),onSuccess=function(){return $rootScope.$broadcast("comment:new"),$ctrl.loadHistory(type,objectId)["finally"](function(){return currentLoading.finish()})},onError=function(){return currentLoading.finish(),$confirm.notify("error")},model=$scope.$eval($attrs.ngModel),$ctrl.repo.save(model).then(onSuccess,onError)}}(this)),$scope.$watch("comments",renderComments),$scope.$watch("history",renderActivity),$scope.$on("object:updated",function(){return $ctrl.loadHistory(type,objectId)}),$el.on("click",".add-comment button.button-green",debounce(2e3,function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),save(target)})),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),href&&0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("click",".show-more",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parent().is(".changes-list")?(showAllActivity=!showAllActivity,renderActivity()):(showAllComments=!showAllComments,renderComments())}),$el.on("click",".show-deleted-comment",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parents(".activity-single").find(".hide-deleted-comment").show(),target.parents(".activity-single").find(".show-deleted-comment").hide(),target.parents(".activity-single").find(".comment-body").show()}),$el.on("click",".hide-deleted-comment",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parents(".activity-single").find(".hide-deleted-comment").hide(),target.parents(".activity-single").find(".show-deleted-comment").show(),target.parents(".activity-single").find(".comment-body").hide()}),$el.on("click",".changes-title",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.parent().find(".change-entry").toggleClass("active")}),$el.on("focus",".add-comment textarea",function(event){return $(this).addClass("active")}),$el.on("click",".history-tabs li a",function(event){var target;return target=angular.element(event.currentTarget),$el.find(".history-tabs li a").removeClass("active"),target.addClass("active"),$el.find(".history section").addClass("hidden"),$el.find(".history section."+target.data("section-class")).removeClass("hidden")}),$el.on("click",".comment-delete",debounce(2e3,function(event){var activityId,target;return event.preventDefault(),target=angular.element(event.currentTarget),activityId=target.data("activity-id"),$ctrl.deleteComment(type,objectId,activityId)})),$el.on("click",".comment-restore",debounce(2e3,function(event){var activityId,target;return event.preventDefault(),target=angular.element(event.currentTarget),activityId=target.data("activity-id"),$ctrl.undeleteComment(type,objectId,activityId)})),$scope.$on("$destroy",function(){return $el.off()})},templateFn=function($el,$attrs){var html;return html=templateBase({ngmodel:$attrs.ngModel,type:$attrs.type,mode:$attrs.mode})},{controller:HistoryController,template:templateFn,restrict:"AE",link:link}},module.directive("tgHistory",["$log","$tgLoading","$tgQqueue","$tgTemplate","$tgConfirm","$translate","$compile","$tgNavUrls","$rootScope",HistoryDirective])}.call(this),function(){var ImportProjectButtonDirective,module;module=angular.module("taigaCommon"),ImportProjectButtonDirective=function($rs,$confirm,$location,$navUrls,$translate){var link;return link=function($scope,$el,$attrs){return $el.on("click",".import-project-button",function(event){return event.preventDefault(),$el.find("input.import-file").val(""),$el.find("input.import-file").trigger("click")}),$el.on("change","input.import-file",function(event){var file,loader,onError,onSuccess;return event.preventDefault(),(file=event.target.files[0])?(loader=$confirm.loader($translate.instant("PROJECT.IMPORT.UPLOADING_FILE")),onSuccess=function(result){var ctx,message,msg,title;return loader.stop(),202===result.status?(title=$translate.instant("PROJECT.IMPORT.ASYNC_IN_PROGRESS_TITLE"),message=$translate.instant("PROJECT.IMPORT.ASYNC_IN_PROGRESS_MESSAGE"),$confirm.success(title,message)):(ctx={project:result.data.slug},$location.path($navUrls.resolve("project-admin-project-profile-details",ctx)),msg=$translate.instant("PROJECT.IMPORT.SYNC_SUCCESS"),$confirm.notify("success",msg))},onError=function(result){var errorMsg,ref;return loader.stop(),errorMsg=$translate.instant("PROJECT.IMPORT.ERROR"),429===result.status?errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST"):(null!=(ref=result.data)?ref._error_message:void 0)&&(errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_MESSAGE",{error_message:result.data._error_message})),$confirm.notify("error",errorMsg)},loader.start(),$rs.projects["import"](file,loader.update).then(onSuccess,onError)):void 0})},{link:link}},module.directive("tgImportProjectButton",["$tgResources","$tgConfirm","$location","$tgNavUrls","$translate",ImportProjectButtonDirective])}.call(this),function(){var AssignedToLightboxDirective,AttachmentPreviewLightboxDirective,BlockLightboxDirective,BlockingMessageInputDirective,CreateBulkUserstoriesDirective,CreateEditUserstoryDirective,LightboxDirective,LightboxKeyboardNavigationService,LightboxService,WatchersLightboxDirective,bindOnce,debounce,module,sizeFormat,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;module=angular.module("taigaCommon"),bindOnce=this.taiga.bindOnce,timeout=this.taiga.timeout,debounce=this.taiga.debounce,sizeFormat=this.taiga.sizeFormat,LightboxService=function(superClass){function LightboxService(animationFrame,q){this.animationFrame=animationFrame,this.q=q}return extend(LightboxService,superClass),LightboxService.prototype.open=function($el){var defered,docEl,lightboxContent;return defered=this.q.defer(),lightboxContent=$el.children().not(".close"),lightboxContent.hide(),this.animationFrame.add(function(){return $el.css("display","flex")}),this.animationFrame.add(function(){return $el.addClass("open"),$el.one("transitionend",function(_this){return function(){return $el.find("input,textarea").first().focus()}}(this))}),this.animationFrame.add(function(_this){return function(){return lightboxContent.show(),defered.resolve()}}(this)),docEl=angular.element(document),docEl.on("keydown.lightbox",function(_this){return function(e){var code;return code=e.keyCode?e.keyCode:e.which,27===code?_this.close($el):void 0}}(this)),defered.promise},LightboxService.prototype.close=function($el){var docEl,scope;return docEl=angular.element(document),docEl.off(".lightbox"),docEl.off(".keyboard-navigation"),$el.one("transitionend",function(_this){return function(){return $el.removeAttr("style"),$el.removeClass("open").removeClass("close")}}(this)),$el.addClass("close"),$el.hasClass("remove-on-close")?(scope=$el.data("scope"),scope.$destroy(),$el.remove()):void 0},LightboxService.prototype.closeAll=function(){var docEl,i,len,lightboxEl,ref,results;for(docEl=angular.element(document),ref=docEl.find(".lightbox.open"),results=[],i=0,len=ref.length;len>i;i++)lightboxEl=ref[i],results.push(this.close($(lightboxEl)));return results},LightboxService}(taiga.Service),module.service("lightboxService",["animationFrame","$q",LightboxService]),LightboxKeyboardNavigationService=function(superClass){function LightboxKeyboardNavigationService(){return LightboxKeyboardNavigationService.__super__.constructor.apply(this,arguments)}return extend(LightboxKeyboardNavigationService,superClass),LightboxKeyboardNavigationService.prototype.stop=function(){var docEl;return docEl=angular.element(document),docEl.off(".keyboard-navigation")},LightboxKeyboardNavigationService.prototype.dispatch=function($el,code){var activeElement,next,prev;if(activeElement=$el.find(".selected"),13===code)return 1===$el.find(".user-list-single").length?$el.find(".user-list-single:first").trigger("click"):activeElement.trigger("click");if(40===code){if(!activeElement.length)return $el.find('.user-list-single:not(".is-active"):first').addClass("selected");if(next=activeElement.next(".user-list-single"),next.length)return activeElement.removeClass("selected"),next.addClass("selected")}else if(38===code){if(!activeElement.length)return $el.find(".user-list-single:last").addClass("selected");if(prev=activeElement.prev('.user-list-single:not(".is-active")'),prev.length)return activeElement.removeClass("selected"),prev.addClass("selected")}},LightboxKeyboardNavigationService.prototype.init=function($el){var docEl;return this.stop(),docEl=angular.element(document),docEl.on("keydown.keyboard-navigation",function(_this){return function(event){var code;return code=event.keyCode?event.keyCode:event.which,40===code||38===code||13===code?(event.preventDefault(),_this.dispatch($el,code)):void 0}}(this))},LightboxKeyboardNavigationService}(taiga.Service),module.service("lightboxKeyboardNavigationService",LightboxKeyboardNavigationService),LightboxDirective=function(lightboxService){var link;return link=function($scope,$el,$attrs){return $el.on("click",".close",function(event){return event.preventDefault(),lightboxService.close($el)})},{restrict:"C",link:link}},module.directive("lightbox",["lightboxService",LightboxDirective]),BlockLightboxDirective=function($rootscope,$tgrepo,$confirm,lightboxService,$loading,$qqueue,$translate){var link;return link=function($scope,$el,$attrs,$model){var block,title,unblock;return title=$translate.instant($attrs.title),$el.find("h2.title").text(title),unblock=$qqueue.bindAdd(function(_this){return function(item,finishCallback){var promise;return promise=$tgrepo.save(item),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated"),$model.$setViewValue(item),finishCallback()}),promise.then(null,function(){return $confirm.notify("error"),item.revert(),$model.$setViewValue(item)}),promise["finally"](function(){return finishCallback()}),promise}}(this)),block=$qqueue.bindAdd(function(_this){return function(item){var currentLoading,promise;return $model.$setViewValue(item),currentLoading=$loading().target($el.find(".button-green")).start(),promise=$tgrepo.save($model.$modelValue),promise.then(function(){return $confirm.notify("success"),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error"),item.revert(),$model.$setViewValue(item)}),promise["finally"](function(){return currentLoading.finish(),lightboxService.close($el)})}}(this)),$scope.$on("block",function(){return $el.find(".reason").val($model.$modelValue.blocked_note),lightboxService.open($el)}),$scope.$on("unblock",function(_this){return function(event,model,finishCallback){var item;return item=$model.$modelValue.clone(),item.is_blocked=!1,item.blocked_note="",unblock(item,finishCallback)}}(this)),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click",".button-green",function(event){var item;return event.preventDefault(),item=$model.$modelValue.clone(),item.is_blocked=!0,item.blocked_note=$el.find(".reason").val(),block(item)})},{templateUrl:"common/lightbox/lightbox-block.html",link:link,require:"ngModel"}},module.directive("tgLbBlock",["$rootScope","$tgRepo","$tgConfirm","lightboxService","$tgLoading","$tgQqueue","$translate",BlockLightboxDirective]),BlockingMessageInputDirective=function($log,$template,$compile){var link,template,templateFn;return template=$template.get("common/lightbox/lightbox-blocking-message-input.html",!0),link=function($scope,$el,$attrs,$model){return $attrs.watch?$scope.$watch($attrs.watch,function(value){return value===!0&&value===!0?$el.find(".blocked-note").removeClass("hidden"):$el.find(".blocked-note").addClass("hidden")}):$log.error("No watch attribute on tg-blocking-message-input directive")},templateFn=function($el,$attrs){return template({ngmodel:$attrs.ngModel})},{template:templateFn,link:link,require:"ngModel",restrict:"EA"}},module.directive("tgBlockingMessageInput",["$log","$tgTemplate","$compile",BlockingMessageInputDirective]),CreateEditUserstoryDirective=function($repo,$model,$rs,$rootScope,lightboxService,$loading,$translate,$confirm,$q,attachmentsService){var link;return link=function($scope,$el,attrs){var attachmentsToAdd,attachmentsToDelete,createAttachments,deleteAttachments,resetAttachments,submit,submitButton;return $scope.createEditUs={},$scope.isNew=!0,attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},$scope.deleteAttachment=function(attachment){return attachmentsToDelete=attachmentsToDelete.push(attachment)},$scope.$on("usform:new",function(ctx,projectId,status,statusList){return $scope.isNew=!0,$scope.usStatusList=statusList,$scope.attachments=Immutable.List(),resetAttachments(),$scope.us=$model.make_model("userstories",{project:projectId,points:{},status:status,is_archived:!1,tags:[]}),$el.find(".button-green").html($translate.instant("COMMON.CREATE")),$el.find(".title").html($translate.instant("LIGHTBOX.CREATE_EDIT_US.NEW_US")),$el.find(".tag-input").val(""),$el.find(".blocked-note").addClass("hidden"),$el.find("label.blocked").removeClass("selected"),$el.find("label.team-requirement").removeClass("selected"),$el.find("label.client-requirement").removeClass("selected"),lightboxService.open($el)}),$scope.$on("usform:edit",function(ctx,us,attachments){return $scope.us=us,$scope.attachments=Immutable.fromJS(attachments),$scope.isNew=!1,resetAttachments(),$el.find(".button-green").html($translate.instant("COMMON.SAVE")),$el.find(".title").html($translate.instant("LIGHTBOX.CREATE_EDIT_US.EDIT_US")),$el.find(".tag-input").val(""),us.is_blocked?($el.find(".blocked-note").removeClass("hidden"),$el.find("label.blocked").addClass("selected")):($el.find(".blocked-note").addClass("hidden"),$el.find("label.blocked").removeClass("selected")),us.team_requirement?$el.find("label.team-requirement").addClass("selected"):$el.find("label.team-requirement").removeClass("selected"),us.client_requirement?$el.find("label.client-requirement").addClass("selected"):$el.find("label.client-requirement").removeClass("selected"),lightboxService.open($el)}),createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){ +return attachmentsService.upload(attachment.file,obj.id,$scope.us.project,"us")}),$q.all(promises)},deleteAttachments=function(obj){var promises;return promises=_.map(attachmentsToDelete.toJS(),function(attachment){return attachmentsService["delete"]("us",attachment.id)}),$q.all(promises)},submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),$scope.isNew?(promise=$repo.create("userstories",$scope.us),broadcastEvent="usform:new:success"):(promise=$repo.save($scope.us),broadcastEvent="usform:edit:success"),promise.then(function(data){return deleteAttachments(data).then(function(_this){return function(){return createAttachments(data)}}(this)),data}),promise.then(function(data){return currentLoading.finish(),lightboxService.close($el),$rootScope.$broadcast(broadcastEvent,data)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$el.on("click",".close",function(event){return event.preventDefault(),$scope.$apply(function(){return $scope.us.revert()}),lightboxService.close($el)}),$el.keydown(function(event){var code;return code=event.keyCode?event.keyCode:event.which,27===code?(lightboxService.close($el),$scope.$apply(function(){return $scope.us.revert()})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateEditUserstory",["$tgRepo","$tgModel","$tgResources","$rootScope","lightboxService","$tgLoading","$translate","$tgConfirm","$q","tgAttachmentsService",CreateEditUserstoryDirective]),CreateBulkUserstoriesDirective=function($repo,$rs,$rootscope,lightboxService,$loading){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.$on("usform:bulk",function(ctx,projectId,status){return $scope["new"]={projectId:projectId,statusId:status,bulk:""},lightboxService.open($el)}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley({onlyOneErrorElement:!0}),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$rs.userstories.bulkCreate($scope["new"].projectId,$scope["new"].statusId,$scope["new"].bulk),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("usform:bulk:success",result),lightboxService.close($el)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateBulkUserstories",["$tgRepo","$tgResources","$rootScope","lightboxService","$tgLoading",CreateBulkUserstoriesDirective]),AssignedToLightboxDirective=function(lightboxService,lightboxKeyboardNavigationService,$template,$compile){var link;return link=function($scope,$el,$attrs){var closeLightbox,filterUsers,normalizeString,render,selectedItem,selectedUser,usersTemplate;return selectedUser=null,selectedItem=null,usersTemplate=$template.get("common/lightbox/lightbox-assigned-to-users.html",!0),normalizeString=function(string){var normalizedString;return normalizedString=string,normalizedString=normalizedString.replace("Á","A").replace("Ä","A").replace("À","A"),normalizedString=normalizedString.replace("É","E").replace("Ë","E").replace("È","E"),normalizedString=normalizedString.replace("Í","I").replace("Ï","I").replace("Ì","I"),normalizedString=normalizedString.replace("Ó","O").replace("Ö","O").replace("Ò","O"),normalizedString=normalizedString.replace("Ú","U").replace("Ü","U").replace("Ù","U")},filterUsers=function(text,user){var username;return username=user.full_name_display.toUpperCase(),username=normalizeString(username),text=text.toUpperCase(),text=normalizeString(text),_.contains(username,text)},render=function(selected,text){var ctx,html,users;return users=_.clone($scope.activeUsers,!0),null!=selected&&(users=_.reject(users,{id:selected.id})),null!=text&&(users=_.filter(users,_.partial(filterUsers,text))),ctx={selected:selected,users:_.first(users,5),showMore:users.length>5},html=usersTemplate(ctx),html=$compile(html)($scope),$el.find(".assigned-to-list").html(html)},closeLightbox=function(){return lightboxKeyboardNavigationService.stop(),lightboxService.close($el)},$scope.$on("assigned-to:add",function(ctx,item){var assignedToId;return selectedItem=item,assignedToId=item.assigned_to,selectedUser=$scope.usersById[assignedToId],render(selectedUser),lightboxService.open($el).then(function(){return $el.find("input").focus(),lightboxKeyboardNavigationService.init($el)})}),$scope.$watch("usersSearch",function(searchingText){return null!=searchingText?(render(selectedUser,searchingText),$el.find("input").focus()):void 0}),$el.on("click",".user-list-single",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),closeLightbox(),$scope.$apply(function(){return $scope.$broadcast("assigned-to:added",target.data("user-id"),selectedItem),$scope.usersSearch=null})}),$el.on("click",".remove-assigned-to",function(event){return event.preventDefault(),event.stopPropagation(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null,$scope.$broadcast("assigned-to:added",null,selectedItem)})}),$el.on("click",".close",function(event){return event.preventDefault(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null})}),$scope.$on("$destroy",function(){return $el.off()})},{templateUrl:"common/lightbox/lightbox-assigned-to.html",link:link}},module.directive("tgLbAssignedto",["lightboxService","lightboxKeyboardNavigationService","$tgTemplate","$compile",AssignedToLightboxDirective]),WatchersLightboxDirective=function($repo,lightboxService,lightboxKeyboardNavigationService,$template,$compile){var link;return link=function($scope,$el,$attrs){var closeLightbox,getFilteredUsers,render,selectedItem,usersTemplate;return selectedItem=null,usersTemplate=$template.get("common/lightbox/lightbox-assigned-to-users.html",!0),getFilteredUsers=function(text){var _filterUsers,users;return null==text&&(text=""),_filterUsers=function(text,user){var username;return selectedItem&&_.find(selectedItem.watchers,function(x){return x===user.id})?!1:(username=user.full_name_display.toUpperCase(),text=text.toUpperCase(),_.contains(username,text))},users=_.clone($scope.activeUsers,!0),users=_.filter(users,_.partial(_filterUsers,text))},render=function(users){var ctx,html;return ctx={selected:!1,users:_.first(users,5),showMore:users.length>5},html=usersTemplate(ctx),html=$compile(html)($scope),$el.find(".ticket-watchers").html(html)},closeLightbox=function(){return lightboxKeyboardNavigationService.stop(),lightboxService.close($el)},$scope.$on("watcher:add",function(ctx,item){var users;return selectedItem=item,users=getFilteredUsers(),render(users),lightboxService.open($el).then(function(){return $el.find("input").focus(),lightboxKeyboardNavigationService.init($el)})}),$scope.$watch("usersSearch",function(searchingText){var users;if(null!=searchingText)return users=getFilteredUsers(searchingText),render(users),$el.find("input").focus()}),$el.on("click",".user-list-single",debounce(2e3,function(event){var target;return closeLightbox(),event.preventDefault(),target=angular.element(event.currentTarget),$scope.$apply(function(){return $scope.usersSearch=null,$scope.$broadcast("watcher:added",target.data("user-id"))})})),$el.on("click",".close",function(event){return event.preventDefault(),closeLightbox(),$scope.$apply(function(){return $scope.usersSearch=null})}),$scope.$on("$destroy",function(){return $el.off()})},{templateUrl:"common/lightbox/lightbox-users.html",link:link}},module.directive("tgLbWatchers",["$tgRepo","lightboxService","lightboxKeyboardNavigationService","$tgTemplate","$compile",WatchersLightboxDirective]),AttachmentPreviewLightboxDirective=function(lightboxService,$template,$compile){var link;return link=function($scope,$el,attrs){return lightboxService.open($el)},{templateUrl:"common/lightbox/lightbox-attachment-preview.html",link:link,scope:!0}},module.directive("tgLbAttachmentPreview",["lightboxService","$tgTemplate","$compile",AttachmentPreviewLightboxDirective])}.call(this),function(){var Loader,LoaderDirective,module,sizeFormat,taiga,timeout;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,timeout=this.taiga.timeout,module=angular.module("taigaCommon"),LoaderDirective=function(tgLoader,$rootscope){var link;return link=function($scope,$el,$attrs){return tgLoader.onStart(function(){return $(document.body).addClass("loader-active"),$el.addClass("active")}),tgLoader.onEnd(function(){return $(document.body).removeClass("loader-active"),$el.removeClass("active")})},{link:link}},module.directive("tgLoader",["tgLoader","$rootScope",LoaderDirective]),Loader=function($rootscope){var autoClose,config,lastResponseDate,open,pageLoaded,requestCount,start,startLoadTime;return config={minTime:300},open=!1,startLoadTime=0,requestCount=0,lastResponseDate=0,pageLoaded=function(force){var diff,endTime,timeoutValue;return null==force&&(force=!1),startLoadTime&&(timeoutValue=0,force||(endTime=(new Date).getTime(),diff=endTime-startLoadTime,diff",function(){var service;return service={settings:{target:null,scope:null,classes:[],timeout:0,template:null},target:function(target){return service.settings.target=target,service},scope:function(scope){return service.settings.scope=scope,service},template:function(template){return service.settings.template=template,service},removeClasses:function(){var classess;return classess=1<=arguments.length?slice.call(arguments,0):[],service.settings.classes=classess,service},timeout:function(timeout){return service.settings.timeout=timeout,service},start:function(){var target,timeoutId;return target=service.settings.target,service.settings.classes.map(function(className){return target.removeClass(className)}),timeoutId=setTimeout(function(){return target.hasClass("loading")?void 0:(service.settings.template||(service.settings.template=target.html()),target.addClass("loading"),target.html(spinner))},service.settings.timeout),service.settings.timeoutId=timeoutId,service},finish:function(){var removeClasses,target,timeoutId;return target=service.settings.target,timeoutId=service.settings.timeoutId,timeoutId&&(clearTimeout(timeoutId),removeClasses=service.settings.classes,removeClasses.map(function(className){return service.settings.target.addClass(className)}),target.html(service.settings.template),target.removeClass("loading"),service.settings.scope&&$compile(target.contents())(service.settings.scope)),service}}}},TgLoadingService.$inject=["$compile"],module.factory("$tgLoading",TgLoadingService),LoadingDirective=function($loading){var link;return link=function($scope,$el,attr){var currentLoading,template;return currentLoading=null,template=$el.html(),$scope.$watch(attr.tgLoading,function(_this){return function(showLoading){return showLoading?currentLoading=$loading().target($el).timeout(100).template(template).scope($scope).start():currentLoading?currentLoading.finish():void 0}}(this))},{link:link}},module.directive("tgLoading",["$tgLoading",LoadingDirective])}.call(this),function(){var RelatedTaskStatusDirective,UsStatusDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaCommon"),UsStatusDirective=function($repo,$template){var link,template;return template=$template.get("common/popover/popover-us-status.html",!0),link=function($scope,$el,$attrs){var $ctrl,render,us;return $ctrl=$el.controller(),render=function(us){var usStatusById,usStatusDom,usStatusDomParent;return usStatusDomParent=$el.find(".us-status"),usStatusDom=$el.find(".us-status .us-status-bind"),usStatusById=$scope.usStatusById,usStatusById[us.status]?(usStatusDom.text(usStatusById[us.status].name),usStatusDomParent.css("color",usStatusById[us.status].color)):void 0},$el.on("click",".us-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",debounce(2e3,function(event){var target,us;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),us=$scope.$eval($attrs.tgUsStatus),us.status=target.data("status-id"),render(us),$el.find(".pop-status").popover().close(),$scope.$apply(function(){return $repo.save(us).then(function(){return $scope.$eval($attrs.onUpdate)})})})),$scope.$on("userstories:loaded",function(){return render($scope.$eval($attrs.tgUsStatus))}),$scope.$on("$destroy",function(){return $el.off()}),us=$scope.$eval($attrs.tgUsStatus),render(us),bindOnce($scope,"project",function(project){var html;return html=template({statuses:project.us_statuses}),$el.append(html),-1===$scope.project.my_permissions.indexOf("modify_us")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0})},{link:link}},module.directive("tgUsStatus",["$tgRepo","$tgTemplate",UsStatusDirective]),RelatedTaskStatusDirective=function($repo,$template){var link,selectionTemplate,updateTaskStatus;return selectionTemplate=$template.get("common/popover/popover-related-task-status.html",!0),updateTaskStatus=function($el,task,taskStatusById){var taskStatusDom,taskStatusDomParent;return taskStatusDomParent=$el.find(".us-status"),taskStatusDom=$el.find(".task-status .task-status-bind"),taskStatusById[task.status]?(taskStatusDom.text(taskStatusById[task.status].name),taskStatusDomParent.css("color",taskStatusById[task.status].color)):void 0},link=function($scope,$el,$attrs){var $ctrl,autoSave,notAutoSave,task;return $ctrl=$el.controller(),task=$scope.$eval($attrs.tgRelatedTaskStatus),notAutoSave=$scope.$eval($attrs.notAutoSave),autoSave=!notAutoSave,$el.on("click",".task-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",debounce(2e3,function(event){var target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),task.status=target.data("status-id"),$el.find(".pop-status").popover().close(),updateTaskStatus($el,task,$scope.taskStatusById),autoSave?$scope.$apply(function(){return $repo.save(task).then(function(){return $scope.$eval($attrs.onUpdate),$scope.$emit("related-tasks:status-changed")})}):void 0})),taiga.bindOnce($scope,"project",function(project){return $el.append(selectionTemplate({statuses:project.task_statuses})),updateTaskStatus($el,task,$scope.taskStatusById),-1===project.my_permissions.indexOf("modify_task")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRelatedTaskStatus",["$tgRepo","$tgTemplate",RelatedTaskStatusDirective]),$.fn.popover=function(){var $el,close,closeAll,closePopover,isVisible,open;return $el=this,isVisible=function(_this){return function(){var docViewBottom,docViewLeft,docViewRight,docViewTop,docViewWidth,elemBottom,elemLeft,elemRight,elemTop,elemWidth;return $el.css({display:"block",visibility:"hidden"}),docViewTop=$(window).scrollTop(),docViewBottom=docViewTop+$(window).height(),docViewWidth=$(window).width(),docViewRight=docViewWidth,docViewLeft=0,elemTop=$el.offset().top,elemBottom=elemTop+$el.height(),elemWidth=$el.width(),elemLeft=$el.offset().left,elemRight=$el.offset().left+elemWidth,$el.css({display:"none",visibility:"visible"}),docViewBottom>=elemBottom&&elemTop>=docViewTop&&elemLeft>=docViewLeft&&docViewRight>=elemRight}}(this),closePopover=function(_this){return function(onClose){return onClose&&onClose.call($el),$el.fadeOut(function(){return $el.removeClass("active").removeClass("fix")}),$el.off("popup:close")}}(this),closeAll=function(_this){return function(){return $(".popover.active").each(function(){return $(this).trigger("popup:close")})}}(this),open=function(_this){return function(onClose){return $el.hasClass("active")?close():(closeAll(),isVisible()||$el.addClass("fix"),$el.fadeIn(function(){return $el.addClass("active"),$(document.body).off("popover"),$(document.body).one("click.popover",function(){return closeAll()})}),$el.on("popup:close",function(e){return closePopover(onClose)}))}}(this),close=function(_this){return function(){return $el.trigger("popup:close")}}(this),{open:open,close:close,closeAll:closeAll}}}.call(this),function(){var ExceptionHandlerFactory,module,taiga;taiga=this.taiga,module=angular.module("taigaCommon"),ExceptionHandlerFactory=function($log,config){var ravenConfig;return this.config=config,ravenConfig=this.config.get("ravenConfig",null),ravenConfig?($log.debug("Using the RavenJS exception handler."),Raven.config(ravenConfig).install(),function(exception,cause){return $log.error.apply($log,arguments),Raven.captureException(exception)}):($log.debug("Using the default logging exception handler."),function(exception,cause){return $log.error.apply($log,arguments)})},module.factory("$exceptionHandler",["$log","$tgConfig",ExceptionHandlerFactory])}.call(this),function(){var ColorizeTagsDirective,LbTagLineDirective,TagLineDirective,TagsDirective,bindOnce,module,taiga,trim,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),TagsDirective=function(){var formatter,link,parser;return formatter=function(v){return _.isArray(v)?v.join(", "):""},parser=function(v){var result;return v?(result=_(v.split(",")).map(function(x){return _.str.trim(x)}),result.value()):[]},link=function($scope,$el,$attrs,$ctrl){return $ctrl.$formatters.push(formatter),$ctrl.$parsers.push(parser),$scope.$on("$destroy",function(){return $el.off()})},{require:"ngModel",link:link}},module.directive("tgTags",TagsDirective),ColorizeTagsDirective=function(){var link,templates;return templates={backlog:_.template('<% _.each(tags, function(tag) { %>\n <%- tag.name %>\n<% }) %>'),kanban:_.template('<% _.each(tags, function(tag) { %>\n
\n<% }) %>'),taskboard:_.template('<% _.each(tags, function(tag) { %>\n \n<% }) %>')},link=function($scope,$el,$attrs,$ctrl){var render;return render=function(srcTags){var html,tags,template;return template=templates[$attrs.tgColorizeTagsType],srcTags.sort(),tags=_.map(srcTags,function(tag){var color;return color=$scope.project.tags_colors[tag],{name:tag,color:color}}),html=template({tags:tags}),$el.html(html)},$scope.$watch($attrs.tgColorizeTags,function(tags){return null!=tags?render(tags):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgColorizeTags",ColorizeTagsDirective),LbTagLineDirective=function($rs,$template,$compile){var COMMA_KEY,ENTER_KEY,link,templateTags;return ENTER_KEY=13,COMMA_KEY=188,templateTags=$template.get("common/tag/lb-tag-line-tags.html",!0),link=function($scope,$el,$attrs,$model){var addValue,deleteValue,hideSaveButton,renderTags,resetInput,saveInputTag,showSaveButton;return renderTags=function(tags,tagsColors){var ctx,html;return ctx={tags:_.map(tags,function(t){return{name:t,color:tagsColors[t]}})},_.map(ctx.tags,function(_this){return function(tag){return tag.color?tag.style="border-left: 5px solid "+tag.color:void 0}}(this)),html=$compile(templateTags(ctx))($scope),$el.find("div.tags-container").html(html)},showSaveButton=function(){return $el.find(".save").removeClass("hidden")},hideSaveButton=function(){return $el.find(".save").addClass("hidden")},resetInput=function(){return $el.find("input").val(""),$el.find("input").autocomplete("close")},addValue=function(value){var tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue,!1),null==tags&&(tags=[]),indexOf.call(tags,value)<0&&tags.push(value),$scope.$apply(function(){return $model.$setViewValue(tags)}),hideSaveButton()):void 0},deleteValue=function(value){var tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue,!1),tags=_.pull(tags,value),$scope.$apply(function(){return $model.$setViewValue(tags)})):void 0},saveInputTag=function(){var value;return value=$el.find("input").val(),addValue(value),resetInput()},$el.on("keypress","input",function(event){var target;return target=angular.element(event.currentTarget),event.keyCode===ENTER_KEY?(event.preventDefault(),saveInputTag()):","===String.fromCharCode(event.keyCode)?(event.preventDefault(),saveInputTag()):target.val().length?showSaveButton():hideSaveButton()}),$el.on("click",".save",function(event){return event.preventDefault(),saveInputTag()}),$el.on("click",".icon-delete",function(event){var target,value;return event.preventDefault(),target=angular.element(event.currentTarget),value=target.siblings(".tag-name").text(),deleteValue(value)}),bindOnce($scope,"project",function(project){var positioningFunction;return positioningFunction=function(position,elements){var menu;return menu=elements.element.element,menu.css("width",elements.target.width),menu.css("top",position.top),menu.css("left",position.left)},$el.find("input").autocomplete({source:_.keys(project.tags_colors),position:{my:"left top",using:positioningFunction},select:function(event,ui){return addValue(ui.item.value),ui.item.value=""}})}),$scope.$watch($attrs.ngModel,function(tags){var ref,tagsColors;return tagsColors=(null!=(ref=$scope.project)?ref.tags_colors:void 0)||[],renderTags(tags,tagsColors)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel",templateUrl:"common/tag/lb-tag-line.html"}},module.directive("tgLbTagLine",["$tgResources","$tgTemplate","$compile",LbTagLineDirective]),TagLineDirective=function($rootScope,$repo,$rs,$confirm,$qqueue,$template,$compile){var COMMA_KEY,ENTER_KEY,ESC_KEY,link,templateTags;return ENTER_KEY=13,ESC_KEY=27,COMMA_KEY=188,templateTags=$template.get("common/tag/tags-line-tags.html",!0),link=function($scope,$el,$attrs,$model){var addValue,deleteValue,hideAddTagButton,hideAddTagButtonText,hideInput,hideSaveButton,isEditable,renderInReadModeOnly,renderTags,resetInput,saveInputTag,showAddTagButton,showAddTagButtonText,showInput,showSaveButton;return isEditable=function(){return null!=$attrs.requiredPerm?-1!==$scope.project.my_permissions.indexOf($attrs.requiredPerm):!0},renderTags=function(tags,tagsColors){var ctx,html;return ctx={tags:_.map(tags,function(t){return{name:t,color:tagsColors[t]}}),isEditable:isEditable()},html=$compile(templateTags(ctx))($scope),$el.find("div.tags-container").html(html)},renderInReadModeOnly=function(){return $el.find(".add-tag").remove(),$el.find("input").remove(),$el.find(".save").remove()},showAddTagButton=function(){return $el.find(".add-tag").removeClass("hidden")},hideAddTagButton=function(){return $el.find(".add-tag").addClass("hidden")},showAddTagButtonText=function(){return $el.find(".add-tag-text").removeClass("hidden")},hideAddTagButtonText=function(){return $el.find(".add-tag-text").addClass("hidden")},showSaveButton=function(){return $el.find(".save").removeClass("hidden")},hideSaveButton=function(){return $el.find(".save").addClass("hidden")},showInput=function(){return $el.find("input").removeClass("hidden").focus()},hideInput=function(){return $el.find("input").addClass("hidden").blur()},resetInput=function(){return $el.find("input").val(""),$el.find("input").autocomplete("close")},addValue=$qqueue.bindAdd(function(value){var model,onError,onSuccess,tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue.tags,!1),null==tags&&(tags=[]),indexOf.call(tags,value)<0&&tags.push(value),model=$model.$modelValue.clone(),model.tags=tags,$model.$setViewValue(model),onSuccess=function(){return $rootScope.$broadcast("object:updated")},onError=function(){return $confirm.notify("error"),model.revert(),$model.$setViewValue(model)},hideSaveButton(),$repo.save(model).then(onSuccess,onError)):void 0}),deleteValue=$qqueue.bindAdd(function(value){var model,onError,onSuccess,tags;return value=trim(value.toLowerCase()),0!==value.length?(tags=_.clone($model.$modelValue.tags,!1),tags=_.pull(tags,value),model=$model.$modelValue.clone(),model.tags=tags,$model.$setViewValue(model),onSuccess=function(){return $rootScope.$broadcast("object:updated")},onError=function(){return $confirm.notify("error"),model.revert(),$model.$setViewValue(model)},$repo.save(model).then(onSuccess,onError)):void 0}),saveInputTag=function(){var value;return value=$el.find("input").val(),addValue(value),resetInput()},$el.on("keypress","input",function(event){var target;return target=angular.element(event.currentTarget),event.keyCode===ENTER_KEY?saveInputTag():","===String.fromCharCode(event.keyCode)?(event.preventDefault(),saveInputTag()):target.val().length?showSaveButton():hideSaveButton()}),$el.on("keyup","input",function(event){return event.keyCode===ESC_KEY?(resetInput(),hideInput(),hideSaveButton(),showAddTagButton()):void 0}),$el.on("click",".save",function(event){return event.preventDefault(),saveInputTag()}),$el.on("click",".add-tag",function(event){return event.preventDefault(),hideAddTagButton(),showInput()}),$el.on("click",".icon-delete",function(event){var target,value;return event.preventDefault(),target=angular.element(event.currentTarget),value=target.siblings(".tag-name").text(),deleteValue(value)}),bindOnce($scope,"project.tags_colors",function(tags_colors){var positioningFunction;return isEditable()?(showAddTagButton(),positioningFunction=function(position,elements){var menu;return menu=elements.element.element,menu.css("width",elements.target.width),menu.css("top",position.top),menu.css("left",position.left)},$el.find("input").autocomplete({source:_.keys(tags_colors),position:{my:"left top",using:positioningFunction},select:function(event,ui){return addValue(ui.item.value),ui.item.value=""}})):void renderInReadModeOnly()}),$scope.$watch($attrs.ngModel,function(model){var ref,ref1,tagsColors;if(model)return(null!=(ref=model.tags)?ref.length:void 0)?hideAddTagButtonText():showAddTagButtonText(),tagsColors=(null!=(ref1=$scope.project)?ref1.tags_colors:void 0)||[],renderTags(model.tags,tagsColors)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel",templateUrl:"common/tag/tag-line.html"}},module.directive("tgTagLine",["$rootScope","$tgRepo","$tgResources","$tgConfirm","$tgQqueue","$tgTemplate","$compile",TagLineDirective])}.call(this),function(){var MarkitupDirective,bindOnce,module,taiga,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,bindOnce=this.taiga.bindOnce,module=angular.module("taigaCommon"),MarkitupDirective=function($rootscope,$rs,$selectedText,$template,$compile,$translate){var link,previewTemplate;return previewTemplate=$template.get("common/wysiwyg/wysiwyg-markitup-preview.html",!0),link=function($scope,$el,$attrs,$model){var addLine,cancelablePromise,closePreviewMode,element,markdownTitle,prepareUrlFormatting,preview,previewDomNode,renderMarkItUp,setCaretPosition,unbind,urlFormatting;return element=angular.element($el),previewDomNode=$("
",{"class":"preview"}),closePreviewMode=function(){return element.parents(".markdown").find(".preview").remove(),element.parents(".markItUp").show()},$scope.$on("markdown-editor:submit",function(){return closePreviewMode()}),cancelablePromise=null,preview=function(){var markItUpDomNode,markdownDomNode;return markdownDomNode=element.parents(".markdown"),markItUpDomNode=element.parents(".markItUp"),$rs.mdrender.render($scope.projectId,$model.$modelValue).then(function(data){var html,markdown;return html=previewTemplate({data:data.data}),html=$compile(html)($scope),markdownDomNode.append(html),markItUpDomNode.hide(),markdown=element.closest(".markdown"),markdown.on("mouseup.preview",".preview",function(event){var target;return event.preventDefault(),target=angular.element(event.target),target.is("a")||!$selectedText.get().length?(markdown.off(".preview"),closePreviewMode()):void 0})})},setCaretPosition=function(textarea,caretPosition){var line,range,scrollRelation,totalLines;return textarea.createTextRange?(range=textarea.createTextRange(),range.move("character",caretPosition),range.select()):textarea.selectionStart&&(textarea.focus(),textarea.setSelectionRange(caretPosition,caretPosition)),totalLines=textarea.value.split("\n").length,line=textarea.value.slice(0,+(caretPosition-1)+1||9e9).split("\n").length,scrollRelation=line/totalLines,$el.scrollTop(scrollRelation*$el[0].scrollHeight-$el.height()/2)},addLine=function(textarea,nline,replace){var cursorPosition,j,key,len,line,lines;for(lines=textarea.value.split("\n"),replace?lines[nline]=replace+lines[nline]:lines[nline]="",cursorPosition=0,key=j=0,len=lines.length;len>j&&(line=lines[key],cursorPosition+=line.length+1||1,key!==nline);key=++j);return textarea.value=lines.join("\n"),replace?cursorPosition-lines[nline].length+replace.length-1:cursorPosition},prepareUrlFormatting=function(markItUp){var indices,regex,result;for(regex=/(<<<|>>>)/gi,result=0,indices=[];result=regex.exec(markItUp.textarea.value);)indices.push(result.index);return markItUp.donotparse=indices},urlFormatting=function(markItUp){var endIndex,ref,ref1,regex,result,startIndex,url,value;for(regex=/<<>>/gi,endIndex=0;;){if(result=regex.exec(markItUp.textarea.value),!result)break;if(ref1=result.index,indexOf.call(markItUp.donotparse,ref1)<0){endIndex=result.index;break}}return value=markItUp.textarea.value,url=value.substring(startIndex,endIndex).replace("<<<","").replace(">>>",""),url=url.replace("(","%28").replace(")","%29"),url=url.replace("[","%5B").replace("]","%5D"),value=value.substring(0,startIndex)+url+value.substring(endIndex+3,value.length),markItUp.textarea.value=value,markItUp.donotparse=void 0}},markdownTitle=function(markItUp,char){var heading,i,j,n,ref;for(heading="",n=$.trim(markItUp.selection||markItUp.placeHolder).length, +i=j=0,ref=n-1;ref>=0?ref>=j:j>=ref;i=ref>=0?++j:--j)heading+=char;return"\n"+heading+"\n"},renderMarkItUp=function(){var markdownSettings;return markdownSettings={nameSpace:"markdown",onShiftEnter:{keepDefault:!1,openWith:"\n\n"},onEnter:{keepDefault:!1,replaceWith:function(){return $(".textcomplete-dropdown").is(":visible")?void 0:"\n"},afterInsert:function(data){var cursorLine,emptyListItem,lastLine,lines,markdownCaretPositon,match,newLineContent,nline,replace;return lines=data.textarea.value.split("\n"),cursorLine=data.caretPosition>0?data.textarea.value.slice(0,+(data.caretPosition-1)+1||9e9).split("\n").length:1,newLineContent=data.textarea.value.slice(data.caretPosition).split("\n")[0],lastLine=lines[cursorLine-1],match=lastLine.match(/^(\s*- ).*/),match&&(emptyListItem=lastLine.match(/^(\s*)\-\s$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=""+match[1]),markdownCaretPositon=addLine(data.textarea,nline,replace)),match=lastLine.match(/^(\s*\* ).*/),match&&(emptyListItem=lastLine.match(/^(\s*\* )$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=""+match[1]),markdownCaretPositon=addLine(data.textarea,nline,replace)),match=lastLine.match(/^(\s*)(\d+)\.\s/),match&&(emptyListItem=lastLine.match(/^(\s*)(\d+)\.\s$/),emptyListItem?(nline=cursorLine-1,replace=null):(nline=cursorLine,replace=match[1]+(parseInt(match[2],10)+1)+". "),markdownCaretPositon=addLine(data.textarea,nline,replace)),markdownCaretPositon?setCaretPosition(data.textarea,markdownCaretPositon):void 0}},markupSet:[{name:$translate.instant("COMMON.WYSIWYG.H1_BUTTON"),key:"1",placeHolder:$translate.instant("COMMON.WYSIWYG.H1_SAMPLE_TEXT"),closeWith:function(markItUp){return markdownTitle(markItUp,"=")}},{name:$translate.instant("COMMON.WYSIWYG.H2_BUTTON"),key:"2",placeHolder:$translate.instant("COMMON.WYSIWYG.H2_SAMPLE_TEXT"),closeWith:function(markItUp){return markdownTitle(markItUp,"-")}},{name:$translate.instant("COMMON.WYSIWYG.H3_BUTTON"),key:"3",openWith:"### ",placeHolder:$translate.instant("COMMON.WYSIWYG.H3_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.BOLD_BUTTON"),key:"B",openWith:"**",closeWith:"**",placeHolder:$translate.instant("COMMON.WYSIWYG.BOLD_BUTTON_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT"),key:"I",openWith:"_",closeWith:"_",placeHolder:$translate.instant("COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.STRIKE_BUTTON"),key:"S",openWith:"~~",closeWith:"~~",placeHolder:$translate.instant("COMMON.WYSIWYG.STRIKE_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.BULLETED_LIST_BUTTON"),openWith:"- ",placeHolder:$translate.instant("COMMON.WYSIWYG.BULLETED_LIST_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.NUMERIC_LIST_BUTTON"),openWith:function(markItUp){return markItUp.line+". "},placeHolder:$translate.instant("COMMON.WYSIWYG.NUMERIC_LIST_SAMPLE_TEXT")},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.PICTURE_BUTTON"),key:"P",openWith:"![",closeWith:'](<<<[![Url:!:http://]!]>>> "[![Title]!]")',placeHolder:$translate.instant("COMMON.WYSIWYG.PICTURE_SAMPLE_TEXT"),beforeInsert:function(markItUp){return prepareUrlFormatting(markItUp)},afterInsert:function(markItUp){return urlFormatting(markItUp)}},{name:$translate.instant("COMMON.WYSIWYG.LINK_BUTTON"),key:"L",openWith:"[",closeWith:'](<<<[![Url:!:http://]!]>>> "[![Title]!]")',placeHolder:$translate.instant("COMMON.WYSIWYG.LINK_SAMPLE_TEXT"),beforeInsert:function(markItUp){return prepareUrlFormatting(markItUp)},afterInsert:function(markItUp){return urlFormatting(markItUp)}},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.QUOTE_BLOCK_BUTTON"),openWith:"> ",placeHolder:$translate.instant("COMMON.WYSIWYG.QUOTE_BLOCK_SAMPLE_TEXT")},{name:$translate.instant("COMMON.WYSIWYG.CODE_BLOCK_BUTTON"),openWith:"```\n",placeHolder:$translate.instant("COMMON.WYSIWYG.CODE_BLOCK_SAMPLE_TEXT"),closeWith:"\n```"},{separator:"---------------"},{name:$translate.instant("COMMON.WYSIWYG.PREVIEW_BUTTON"),call:preview,className:"preview-icon"}],afterInsert:function(event){var target;return target=angular.element(event.textarea),$model.$setViewValue(target.val())}},element.markItUpRemove().markItUp(markdownSettings).textcomplete([{cache:!0,match:/(^|\s)#([a-z0-9]+)$/i,search:function(term,callback){var filter,searchProps,searchTypes;return term=taiga.slugify(term),searchTypes=["issues","tasks","userstories"],searchProps=["ref","subject"],filter=function(_this){return function(item){var j,len,prop;for(j=0,len=searchProps.length;len>j;j++)if(prop=searchProps[j],taiga.slugify(item[prop]).indexOf(term)>=0)return!0;return!1}}(this),cancelablePromise&&cancelablePromise.abort(),cancelablePromise=$rs.search["do"]($scope.projectId,term),cancelablePromise.then(function(_this){return function(res){var j,len,results,type;if(res.count<1||res.count===res.wikipages.length)return callback([]);for(results=[],j=0,len=searchTypes.length;len>j;j++)type=searchTypes[j],res[type]&&res[type].length>0?results.push(callback(res[type].filter(filter),!0)):results.push(void 0);return results}}(this)),callback([])},replace:function(res){return"$1#"+res.ref+" "},template:function(res,term){return"#"+res.ref+" - "+res.subject}},{cache:!0,match:/(^|\s)@([a-z0-9\-\._]{2,})$/i,search:function(term,callback){var searchProps,username;return username=taiga.slugify(term),searchProps=["username","full_name","full_name_display"],callback($scope.project.members.length<1?[]:$scope.project.members.filter(function(_this){return function(user){var j,len,prop;for(j=0,len=searchProps.length;len>j;j++)if(prop=searchProps[j],taiga.slugify(user[prop]).indexOf(username)>=0)return!0;return!1}}(this)))},replace:function(user){return"$1@"+user.username+" "},template:function(user){return user.username+" - "+user.full_name_display}},{cache:!0,match:/(^|\s)\[\[([a-z0-9\-]+)$/i,search:function(term,callback){return term=taiga.slugify(term),$rs.search["do"]($scope.projectId,term).then(function(_this){return function(res){return res.count<1&&callback([]),res.count<1||!res.wikipages||res.wikipages.length<=0?callback([]):callback(res.wikipages.filter(function(page){return taiga.slugify(page.slug).indexOf(term)>=0}),!0),callback([])}}(this))},replace:function(res){return"$1[["+res.slug+"]]"},template:function(res,term){return res.slug}}],{debounce:200})},renderMarkItUp(),unbind=$rootscope.$on("$translateChangeEnd",renderMarkItUp),element.on("keypress",function(event){return $scope.$apply()}),$scope.$on("$destroy",function(){return $el.off(),unbind()})},{link:link,require:"ngModel"}},module.directive("tgMarkitup",["$rootScope","$tgResources","$selectedText","$tgTemplate","$compile","$translate",MarkitupDirective])}.call(this),function(){var BacklogFiltersDirective,bindOnce,debounceLeading,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,debounceLeading=this.taiga.debounceLeading,module=angular.module("taigaBacklog"),BacklogFiltersDirective=function($q,$log,$location,$templates){var link,template,templateSelected;return template=$templates.get("backlog/filters.html",!0),templateSelected=$templates.get("backlog/filter-selected.html",!0),link=function($scope,$el,$attrs){var $ctrl,currentFiltersType,getFiltersType,initializeSelectedFilters,reloadUserstories,renderFilters,renderSelectedFilters,selectQFilter,selectedFilters,showCategories,showFilters,toggleFilterSelection;return currentFiltersType="",$ctrl=$el.closest(".wrapper").controller(),selectedFilters=[],showFilters=function(title,type){return $el.find(".filters-cats").hide(),$el.find(".filter-list").removeClass("hidden"),$el.find("h2.breadcrumb").removeClass("hidden"),$el.find("h2 a.subfilter span.title").html(title),$el.find("h2 a.subfilter span.title").prop("data-type",type),currentFiltersType=getFiltersType()},showCategories=function(){return $el.find(".filters-cats").show(),$el.find(".filter-list").addClass("hidden"),$el.find("h2.breadcrumb").addClass("hidden")},initializeSelectedFilters=function(){var i,len,name,ref,val,values;showCategories(),selectedFilters=[],ref=$scope.filters;for(name in ref)for(values=ref[name],i=0,len=values.length;len>i;i++)val=values[i],val.selected&&selectedFilters.push(val);return renderSelectedFilters()},renderSelectedFilters=function(){var html;return _.map(selectedFilters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=templateSelected({filters:selectedFilters}),$el.find(".filters-applied").html(html)},renderFilters=function(filters){var html;return _.map(filters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=template({filters:filters}),$el.find(".filter-list").html(html)},getFiltersType=function(){return $el.find("h2 a.subfilter span.title").prop("data-type")},reloadUserstories=function(){return currentFiltersType=getFiltersType(),$q.all([$ctrl.loadUserstories(),$ctrl.generateFilters()]).then(function(){var currentFilters;return currentFilters=$scope.filters[currentFiltersType],renderFilters(_.reject(currentFilters,"selected"))})},toggleFilterSelection=function(type,id){var filter,filters;return currentFiltersType=getFiltersType(),filters=$scope.filters[type],filter=_.find(filters,{id:id}),filter.selected=!filter.selected,filter.selected?(selectedFilters.push(filter),$scope.$apply(function(){return $ctrl.selectFilter(type,id)})):(selectedFilters=_.reject(selectedFilters,function(selected){return filter.type===selected.type&&filter.id===selected.id}),$ctrl.unselectFilter(type,id)),renderSelectedFilters(selectedFilters),type===currentFiltersType&&renderFilters(_.reject(filters,"selected")),reloadUserstories()},selectQFilter=debounceLeading(100,function(value){return void 0!==value?(0===value.length?$ctrl.replaceFilter("q",null):$ctrl.replaceFilter("q",value),reloadUserstories()):void 0}),$scope.$watch("filtersQ",selectQFilter),$scope.$on("backlog:loaded",function(ctx){return initializeSelectedFilters()}),$scope.$on("filters:update",function(ctx){return $ctrl.generateFilters().then(function(){var filters;return filters=$scope.filters[currentFiltersType],currentFiltersType?renderFilters(_.reject(filters,"selected")):void 0})}),$el.on("click",".filters-cats > ul > li > a",function(event){var tags,target;return event.preventDefault(),target=angular.element(event.currentTarget),tags=$scope.filters[target.data("type")],renderFilters(_.reject(tags,"selected")),showFilters(target.attr("title"),target.data("type"))}),$el.on("click",".filters-inner > .filters-step-cat > .breadcrumb > .back",function(event){return event.preventDefault(),showCategories()}),$el.on("click",".filters-applied a",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),id=target.data("id"),type=target.data("type"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),target.hasClass("active")?target.removeClass("active"):target.addClass("active"),id=target.data("id"),type=target.data("type"),toggleFilterSelection(type,id)})},{link:link}},module.directive("tgBacklogFilters",["$q","$log","$tgLocation","$tgTemplate",BacklogFiltersDirective])}.call(this),function(){var CreateEditSprint,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaBacklog"),CreateEditSprint=function($repo,$confirm,$rs,$rootscope,lightboxService,$loading,$translate){var link;return link=function($scope,$el,attrs){var createSprint,getLastSprint,hasErrors,remove,resetSprint,submit;return hasErrors=!1,createSprint=!0,resetSprint=function(){return $scope.sprint={project:null,name:null,estimated_start:null,estimated_finish:null}},submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,newSprint,prettyDate,promise,submitButton,target;return event.preventDefault(),target=angular.element(event.currentTarget),prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),submitButton=$el.find(".submit-button"),form=$el.find("form").checksley(),form.validate()?(hasErrors=!1,newSprint=angular.copy($scope.sprint),broadcastEvent=null,createSprint?(newSprint.estimated_start=moment(newSprint.estimated_start,prettyDate).format("YYYY-MM-DD"),newSprint.estimated_finish=moment(newSprint.estimated_finish,prettyDate).format("YYYY-MM-DD"),promise=$repo.create("milestones",newSprint),broadcastEvent="sprintform:create:success"):(newSprint.setAttr("estimated_start",moment(newSprint.estimated_start,prettyDate).format("YYYY-MM-DD")),newSprint.setAttr("estimated_finish",moment(newSprint.estimated_finish,prettyDate).format("YYYY-MM-DD")),promise=$repo.save(newSprint),broadcastEvent="sprintform:edit:success"),currentLoading=$loading().target(submitButton).start(),promise.then(function(data){return currentLoading.finish(),createSprint&&($scope.sprintsCounter+=1),$rootscope.$broadcast(broadcastEvent,data),lightboxService.close($el)}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("light-error",data._error_message):data.__all__?$confirm.notify("light-error",data.__all__[0]):void 0})):(hasErrors=!0,void $el.find(".last-sprint-name").addClass("disappear"))}}(this)),remove=function(){var message,title;return title=$translate.instant("LIGHTBOX.DELETE_SPRINT.TITLE"),message=$scope.sprint.name,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onSuccess=function(){return askResponse.finish(),$scope.milestonesCounter-=1,lightboxService.close($el),$rootscope.$broadcast("sprintform:remove:success",$scope.sprint)},onError=function(){return askResponse.finish(!1),$confirm.notify("error")},$repo.remove($scope.sprint).then(onSuccess,onError)}}(this))},getLastSprint=function(){var openSprints,sortedSprints;return openSprints=_.filter($scope.sprints,function(sprint){return!sprint.closed}),sortedSprints=_.sortBy(openSprints,function(sprint){return moment(sprint.estimated_finish,"YYYY-MM-DD").format("X")}),sortedSprints[sortedSprints.length-1]},$scope.$on("sprintform:create",function(event,projectId){var estimatedFinish,estimatedStart,form,lastSprint,lastSprintNameDom,prettyDate,text;return resetSprint(),form=$el.find("form").checksley(),form.reset(),createSprint=!0,prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),$scope.sprint.project=projectId,$scope.sprint.name=null,$scope.sprint.slug=null,lastSprint=getLastSprint(),estimatedStart=moment(),lastSprint?estimatedStart=moment(lastSprint.estimated_finish):$scope.sprint.estimated_start&&(estimatedStart=moment($scope.sprint.estimated_start)),$scope.sprint.estimated_start=estimatedStart.format(prettyDate),estimatedFinish=moment().add(2,"weeks"),lastSprint?estimatedFinish=moment(lastSprint.estimated_finish).add(2,"weeks"):$scope.sprint.estimated_finish&&(estimatedFinish=moment($scope.sprint.estimated_finish)),$scope.sprint.estimated_finish=estimatedFinish.format(prettyDate),lastSprintNameDom=$el.find(".last-sprint-name"),null!=(null!=lastSprint?lastSprint.name:void 0)&&(text=$translate.instant("LIGHTBOX.ADD_EDIT_SPRINT.LAST_SPRINT_NAME",{lastSprint:lastSprint.name}),lastSprintNameDom.html(text)),$el.find(".delete-sprint").addClass("hidden"),text=$translate.instant("LIGHTBOX.ADD_EDIT_SPRINT.TITLE"),$el.find(".title").text(text),text=$translate.instant("COMMON.CREATE"),$el.find(".button-green").text(text),lightboxService.open($el),$el.find(".sprint-name").focus(),$el.find(".last-sprint-name").removeClass("disappear")}),$scope.$on("sprintform:edit",function(ctx,sprint){var editSprint,prettyDate,save;return resetSprint(),createSprint=!1,prettyDate=$translate.instant("COMMON.PICKERDATE.FORMAT"),$scope.$apply(function(){return $scope.sprint=sprint,$scope.sprint.estimated_start=moment($scope.sprint.estimated_start).format(prettyDate),$scope.sprint.estimated_finish=moment($scope.sprint.estimated_finish).format(prettyDate)}),$el.find(".delete-sprint").removeClass("hidden"),editSprint=$translate.instant("BACKLOG.EDIT_SPRINT"),$el.find(".title").text(editSprint),save=$translate.instant("COMMON.SAVE"),$el.find(".button-green").text(save),lightboxService.open($el),$el.find(".sprint-name").focus().select(),$el.find(".last-sprint-name").addClass("disappear")}),$el.on("keyup",".sprint-name",function(event){return $el.find(".sprint-name").val().length>0||hasErrors?$el.find(".last-sprint-name").addClass("disappear"):$el.find(".last-sprint-name").removeClass("disappear")}),$el.on("submit","form",submit),$el.on("click",".delete-sprint .icon-delete",function(event){return event.preventDefault(),remove()}),$scope.$on("$destroy",function(){return $el.off()}),resetSprint()},{link:link}},module.directive("tgLbCreateEditSprint",["$tgRepo","$tgConfirm","$tgResources","$rootScope","lightboxService","$tgLoading","$translate",CreateEditSprint])}.call(this),function(){var BacklogController,BacklogDirective,BurndownBacklogGraphDirective,TgBacklogProgressBarDirective,ToggleBurndownVisibility,UsPointsDirective,UsRolePointsSelectorDirective,bindMethods,bindOnce,generateHash,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,generateHash=this.taiga.generateHash,module=angular.module("taigaBacklog"),BacklogController=function(superClass){function BacklogController(scope1,rootscope,repo,confirm,rs,params1,q,location,appMetaService,navUrls,events,analytics,translate,loading,rs2){var promise;this.scope=scope1,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params1,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,this.loading=loading,this.rs2=rs2,bindMethods(this),this.scope.sectionName=this.translate.instant("BACKLOG.SECTION_NAME"),this.showTags=!1,this.activeFilters=!1,this.scope.showGraphPlaceholder=null,this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("BACKLOG.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("BACKLOG.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description),_this.rs.userstories.getShowTags(_this.scope.projectId)?(_this.showTags=!0,_this.scope.$broadcast("showTags",_this.showTags)):void 0}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(BacklogController,superClass),BacklogController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate","$tgLoading","tgResources"],BacklogController.prototype.initializeEventHandlers=function(){return this.scope.$on("usform:bulk:success",function(_this){return function(){return _this.loadUserstories(),_this.loadProjectStats(),_this.analytics.trackEvent("userstory","create","bulk create userstory on backlog",1)}}(this)),this.scope.$on("sprintform:create:success",function(_this){return function(){return _this.loadSprints(),_this.loadProjectStats(),_this.analytics.trackEvent("sprint","create","create sprint on backlog",1)}}(this)),this.scope.$on("usform:new:success",function(_this){return function(){return _this.loadUserstories(),_this.loadProjectStats(),_this.rootscope.$broadcast("filters:update"),_this.analytics.trackEvent("userstory","create","create userstory on backlog",1)}}(this)),this.scope.$on("sprintform:edit:success",function(_this){return function(){return _this.loadProjectStats()}}(this)),this.scope.$on("sprintform:remove:success",function(_this){return function(event,sprint){return _this.loadSprints(),_this.loadProjectStats(),_this.loadUserstories(),sprint.closed&&_this.loadClosedSprints(),_this.rootscope.$broadcast("filters:update")}}(this)),this.scope.$on("usform:edit:success",function(_this){return function(){return _this.loadUserstories(),_this.rootscope.$broadcast("filters:update")}}(this)),this.scope.$on("sprint:us:move",this.moveUs),this.scope.$on("sprint:us:moved",this.loadSprints),this.scope.$on("sprint:us:moved",this.loadProjectStats),this.scope.$on("backlog:load-closed-sprints",this.loadClosedSprints),this.scope.$on("backlog:unload-closed-sprints",this.unloadClosedSprints)},BacklogController.prototype.initializeSubscription=function(){var routingKey1,routingKey2;return routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.loadUserstories(),_this.loadSprints()}}(this)),routingKey2="changes.project."+this.scope.projectId+".milestones",this.events.subscribe(this.scope,routingKey2,function(_this){return function(message){return _this.loadSprints()}}(this))},BacklogController.prototype.toggleShowTags=function(){return this.scope.$apply(function(_this){return function(){return _this.showTags=!_this.showTags,_this.rs.userstories.storeShowTags(_this.scope.projectId,_this.showTags)}}(this))},BacklogController.prototype.toggleActiveFilters=function(){return this.activeFilters=!this.activeFilters},BacklogController.prototype.loadProjectStats=function(){return this.rs.projects.stats(this.scope.projectId).then(function(_this){return function(stats){var totalPoints;return _this.scope.stats=stats,totalPoints=stats.total_points?stats.total_points:stats.defined_points,totalPoints?_this.scope.stats.completedPercentage=Math.round(100*stats.closed_points/totalPoints):_this.scope.stats.completedPercentage=0,_this.scope.showGraphPlaceholder=!(null!=stats.total_points&&null!=stats.total_milestones),stats}}(this))},BacklogController.prototype.unloadClosedSprints=function(){return this.scope.$apply(function(_this){return function(){return _this.scope.closedSprints=[],_this.rootscope.$broadcast("closed-sprints:reloaded",[])}}(this))},BacklogController.prototype.loadClosedSprints=function(){var params;return params={closed:!0},this.rs.sprints.list(this.scope.projectId,params).then(function(_this){return function(result){var j,len,sprint,sprints;for(sprints=result.milestones,_this.scope.totalClosedMilestones=result.closed,j=0,len=sprints.length;len>j;j++)sprint=sprints[j],sprint.user_stories=_.sortBy(sprint.user_stories,"sprint_order");return _this.scope.closedSprints=sprints,_this.scope.closedSprintsById=groupBy(sprints,function(x){return x.id}),_this.rootscope.$broadcast("closed-sprints:reloaded",sprints),sprints}}(this))},BacklogController.prototype.loadSprints=function(){var params;return params={closed:!1},this.rs.sprints.list(this.scope.projectId,params).then(function(_this){return function(result){var j,len,sprint,sprints;for(sprints=result.milestones,_this.scope.totalMilestones=sprints,_this.scope.totalClosedMilestones=result.closed,_this.scope.totalOpenMilestones=result.open,_this.scope.totalMilestones=_this.scope.totalOpenMilestones+_this.scope.totalClosedMilestones,j=0,len=sprints.length;len>j;j++)sprint=sprints[j],sprint.user_stories=_.sortBy(sprint.user_stories,"sprint_order");return _this.scope.sprints=sprints,_this.scope.openSprints=_.filter(sprints,function(sprint){return!sprint.closed}).reverse(),_this.scope.closedSprints||(_this.scope.closedSprints=[]),_this.scope.sprintsCounter=sprints.length,_this.scope.sprintsById=groupBy(sprints,function(x){return x.id}),_this.rootscope.$broadcast("sprints:loaded",sprints),_this.scope.currentSprint=_this.findCurrentSprint(),sprints}}(this))},BacklogController.prototype.restoreFilters=function(){var selectedStatuses,selectedTags;return selectedTags=this.scope.oldSelectedTags,selectedStatuses=this.scope.oldSelectedStatuses,selectedStatuses||selectedStatuses?(this.scope.filtersQ=this.scope.filtersQOld,this.replaceFilter("q",this.scope.filtersQ),_.each([selectedTags,selectedStatuses],function(_this){return function(filterGrp){return _.each(filterGrp,function(item){var filter,filters;return filters=_this.scope.filters[item.type],filter=_.find(filters,{id:item.id}),filter.selected=!0,_this.selectFilter(item.type,item.id)})}}(this)),this.loadUserstories()):void 0},BacklogController.prototype.resetFilters=function(){var selectedStatuses,selectedTags;return selectedTags=_.filter(this.scope.filters.tags,"selected"),selectedStatuses=_.filter(this.scope.filters.status,"selected"),this.scope.oldSelectedTags=selectedTags,this.scope.oldSelectedStatuses=selectedStatuses,this.scope.filtersQOld=this.scope.filtersQ,this.scope.filtersQ=void 0,this.replaceFilter("q",this.scope.filtersQ),_.each([selectedTags,selectedStatuses],function(_this){return function(filterGrp){return _.each(filterGrp,function(item){var filter,filters;return filters=_this.scope.filters[item.type],filter=_.find(filters,{id:item.id}),filter.selected=!1,_this.unselectFilter(item.type,item.id)})}}(this)),this.loadUserstories()},BacklogController.prototype.loadUserstories=function(){var promise;return this.scope.httpParams=this.getUrlFilters(),this.rs.userstories.storeQueryParams(this.scope.projectId,this.scope.httpParams),promise=this.rs.userstories.listUnassigned(this.scope.projectId,this.scope.httpParams),promise.then(function(_this){return function(userstories){return _this.scope.userstories=_.sortBy(userstories,"backlog_order"),_this.setSearchDataFilters(),scopeDefer(_this.scope,function(){return _this.scope.$broadcast("userstories:loaded")}),userstories}}(this))},BacklogController.prototype.loadBacklog=function(){return this.q.all([this.loadProjectStats(),this.loadSprints(),this.loadUserstories()])},BacklogController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_backlog_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.closedMilestones=!!project.total_closed_milestones,_this.scope.$emit("project:loaded",project),_this.scope.points=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.usStatusList=_.sortBy(project.us_statuses,"id"),project}}(this))},BacklogController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription()}}(this)),promise.then(function(_this){return function(){return _this.loadBacklog()}}(this)).then(function(_this){return function(){return _this.generateFilters()}}(this)).then(function(_this){return function(){return _this.scope.$emit("backlog:loaded")}}(this))},BacklogController.prototype.prepareBulkUpdateData=function(uses,field){return null==field&&(field="backlog_order"),_.map(uses,function(x){return{us_id:x.id,order:x[field]}})},BacklogController.prototype.resortUserStories=function(uses,field){var index,item,items,j,len;for(null==field&&(field="backlog_order"),items=[],index=j=0,len=uses.length;len>j;index=++j)item=uses[index],item[field]=index,item.isModified()&&items.push(item);return items},BacklogController.prototype.moveUs=function(ctx,usList,newUsIndex,newSprintId){var data,items,j,l,len,len1,len2,m,movedFromClosedSprint,movedToClosedSprint,newSprint,oldSprintId,project,promise,promises,sprint,us,userstories;if(oldSprintId=usList[0].milestone,project=usList[0].project,movedFromClosedSprint=!1,movedToClosedSprint=!1,sprint=this.scope.sprintsById[oldSprintId],!sprint&&this.scope.closedSprintsById&&(sprint=this.scope.closedSprintsById[oldSprintId],sprint&&(movedFromClosedSprint=!0)),newSprint=this.scope.sprintsById[newSprintId],!newSprint&&newSprintId&&(newSprint=this.scope.closedSprintsById[newSprintId],newSprint&&(movedToClosedSprint=!0)),newSprintId===oldSprintId)return items=null,userstories=null,userstories=null===newSprintId?this.scope.userstories:newSprint.user_stories,this.scope.$apply(function(){var args,j,key,len,r,us;for(key=j=0,len=usList.length;len>j;key=++j)us=usList[key],r=userstories.indexOf(us),userstories.splice(r,1);return args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(userstories,args)}),null===newSprintId?(items=this.resortUserStories(userstories,"backlog_order"),data=this.prepareBulkUpdateData(items,"backlog_order"),this.rs.userstories.bulkUpdateBacklogOrder(project,data).then(function(_this){return function(){var j,len,results,us;for(results=[],j=0,len=usList.length;len>j;j++)us=usList[j],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}}(this))):(items=this.resortUserStories(userstories,"sprint_order"),data=this.prepareBulkUpdateData(items,"sprint_order"),this.rs.userstories.bulkUpdateSprintOrder(project,data).then(function(_this){return function(){var j,len,results,us;for(results=[],j=0,len=usList.length;len>j;j++)us=usList[j],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}}(this))),promise;if(null===newSprintId){for(j=0,len=usList.length;len>j;j++)us=usList[j],us.milestone=null;return this.scope.$apply(function(_this){return function(){var args,key,l,len1,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(_this.scope.userstories,args),results=[],key=l=0,len1=usList.length;len1>l;key=++l)us=usList[key],r=sprint.user_stories.indexOf(us),results.push(sprint.user_stories.splice(r,1));return results}}(this)),promise=this.repo.save(us),promise=promise.then(function(_this){return function(){return items=_this.resortUserStories(_this.scope.userstories,"backlog_order"),data=_this.prepareBulkUpdateData(items,"backlog_order"),_this.rs.userstories.bulkUpdateBacklogOrder(us.project,data).then(function(){return _this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId),movedFromClosedSprint?_this.rootscope.$broadcast("backlog:load-closed-sprints"):void 0})}}(this)),promise.then(null,function(){return console.log("FAIL")}),promise}if(null===oldSprintId){for(l=0,len1=usList.length;len1>l;l++)us=usList[l],us.milestone=newSprintId;this.scope.$apply(function(_this){return function(){var args,key,len2,m,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(newSprint.user_stories,args),results=[],key=m=0,len2=usList.length;len2>m;key=++m)us=usList[key],r=_this.scope.userstories.indexOf(us),results.push(_this.scope.userstories.splice(r,1));return results}}(this))}else{for(m=0,len2=usList.length;len2>m;m++)us=usList[m],us.milestone=newSprintId;this.scope.$apply(function(_this){return function(){var args,len3,n,r,results;for(args=[newUsIndex,0].concat(usList),Array.prototype.splice.apply(newSprint.user_stories,args),results=[],n=0,len3=usList.length;len3>n;n++)us=usList[n],r=sprint.user_stories.indexOf(us),results.push(sprint.user_stories.splice(r,1));return results}}(this))}return promises=_.map(usList,function(_this){return function(us){return _this.repo.save(us)}}(this)),promise=this.q.all(promises).then(function(_this){ +return function(){return items=_this.resortUserStories(newSprint.user_stories,"sprint_order"),data=_this.prepareBulkUpdateData(items,"sprint_order"),_this.rs.userstories.bulkUpdateSprintOrder(project,data).then(function(result){return _this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId)}),_this.rs.userstories.bulkUpdateBacklogOrder(project,data).then(function(){var len3,n,results;for(results=[],n=0,len3=usList.length;len3>n;n++)us=usList[n],results.push(_this.rootscope.$broadcast("sprint:us:moved",us,oldSprintId,newSprintId));return results}),movedToClosedSprint||movedFromClosedSprint?_this.scope.$broadcast("backlog:load-closed-sprints"):void 0}}(this)),promise.then(null,function(){return console.log("FAIL")}),promise},BacklogController.prototype.isFilterSelected=function(type,id){return null!=this.searchdata[type]&&this.searchdata[type][id]?!0:!1},BacklogController.prototype.setSearchDataFilters=function(){var name,results,urlfilters,val,value;urlfilters=this.getUrlFilters(),urlfilters.q&&(this.scope.filtersQ=this.scope.filtersQ||urlfilters.q),this.searchdata={},results=[];for(name in urlfilters)value=urlfilters[name],null==this.searchdata[name]&&(this.searchdata[name]={}),results.push(function(){var j,len,ref1,results1;for(ref1=taiga.toString(value).split(","),results1=[],j=0,len=ref1.length;len>j;j++)val=ref1[j],results1.push(this.searchdata[name][val]=!0);return results1}.call(this));return results},BacklogController.prototype.getUrlFilters=function(){return _.pick(this.location.search(),"status","tags","q")},BacklogController.prototype.generateFilters=function(){var loadFilters,urlfilters;return urlfilters=this.getUrlFilters(),this.scope.filters={},loadFilters={},loadFilters.project=this.scope.projectId,loadFilters.tags=urlfilters.tags,loadFilters.status=urlfilters.status,loadFilters.q=urlfilters.q,loadFilters.milestone="null",this.rs.userstories.filtersData(loadFilters).then(function(_this){return function(data){var choicesFiltersFormat,selectedStatuses,selectedTags,tagsFilterFormat;return choicesFiltersFormat=function(choices,type,byIdObject){return _.map(choices,function(t){return t.type=type,t})},tagsFilterFormat=function(tags){return _.map(tags,function(t){return t.id=t.name,t.type="tags",t})},_this.scope.filters.status=choicesFiltersFormat(data.statuses,"status",_this.scope.usStatusById),_this.scope.filters.tags=tagsFilterFormat(data.tags),selectedTags=_.filter(_this.scope.filters.tags,"selected"),selectedTags=_.map(selectedTags,"id"),selectedStatuses=_.filter(_this.scope.filters.status,"selected"),selectedStatuses=_.map(selectedStatuses,"id"),_this.markSelectedFilters(_this.scope.filters,urlfilters),_this.rs.userstories.storeQueryParams(_this.scope.projectId,{status:selectedStatuses,tags:selectedTags,project:_this.scope.projectId,milestone:null})}}(this))},BacklogController.prototype.markSelectedFilters=function(filters,urlfilters){var isSelected,j,key,len,name,obj,ref1,ref2,results,searchdata,val,value;searchdata={},ref1=_.omit(urlfilters,"page","orderBy");for(name in ref1)for(value=ref1[name],null==searchdata[name]&&(searchdata[name]={}),ref2=(""+value).split(","),j=0,len=ref2.length;len>j;j++)val=ref2[j],searchdata[name][val]=!0;isSelected=function(type,id){return null!=searchdata[type]&&searchdata[type][id]?!0:!1},results=[];for(key in filters)value=filters[key],results.push(function(){var l,len1,results1;for(results1=[],l=0,len1=value.length;len1>l;l++)obj=value[l],results1.push(obj.selected=isSelected(obj.type,obj.id)?!0:void 0);return results1}());return results},BacklogController.prototype.updateUserStoryStatus=function(){return this.setSearchDataFilters(),this.generateFilters().then(function(_this){return function(){return _this.rootscope.$broadcast("filters:update"),_this.loadProjectStats()}}(this))},BacklogController.prototype.editUserStory=function(projectId,ref,$event){var currentLoading,target;return target=$($event.target),currentLoading=this.loading().target(target).removeClasses("icon-edit").timeout(200).start(),this.rs.userstories.getByRef(projectId,ref).then(function(_this){return function(us){return _this.rs2.attachments.list("us",us.id,projectId).then(function(attachments){return _this.rootscope.$broadcast("usform:edit",us,attachments.toJS()),currentLoading.finish()})}}(this))},BacklogController.prototype.deleteUserStory=function(us){var message,title;return title=this.translate.instant("US.TITLE_DELETE_ACTION"),message=us.subject,this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var promise;return _this.scope.userstories=_.without(_this.scope.userstories,us),promise=_this.repo.remove(us),promise.then(function(){return askResponse.finish(),_this.loadBacklog()}),promise.then(null,function(){return askResponse.finish(!1),_this.confirm.notify("error")})}}(this))},BacklogController.prototype.addNewUs=function(type){switch(type){case"standard":return this.rootscope.$broadcast("usform:new",this.scope.projectId,this.scope.project.default_us_status,this.scope.usStatusList);case"bulk":return this.rootscope.$broadcast("usform:bulk",this.scope.projectId,this.scope.project.default_us_status)}},BacklogController.prototype.addNewSprint=function(){return this.rootscope.$broadcast("sprintform:create",this.scope.projectId)},BacklogController.prototype.findCurrentSprint=function(){var currentDate;return currentDate=(new Date).getTime(),_.find(this.scope.sprints,function(sprint){var end,start;return start=moment(sprint.estimated_start,"YYYY-MM-DD").format("x"),end=moment(sprint.estimated_finish,"YYYY-MM-DD").format("x"),currentDate>=start&&end>=currentDate})},BacklogController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("BacklogController",BacklogController),BacklogDirective=function($repo,$rootscope,$translate){var doomLineTemplate,link,linkDoomLine,linkFilters,linkToolbar,showHideFilter,showHideTags;return doomLineTemplate=_.template('
<%- text %>
'),linkDoomLine=function($scope,$el,$attrs,$ctrl){var addDoomLineDom,getUsItems,reloadDoomLine,removeDoomlineDom;return reloadDoomLine=function(){var current_sum,domElement,i,j,len,ref1,results,stats,total_points,us;if(null!=$scope.stats&&null!=$scope.stats.total_points&&0!==$scope.stats.total_points){if(removeDoomlineDom(),stats=$scope.stats,total_points=stats.total_points,current_sum=stats.assigned_points,!$scope.userstories)return;for(ref1=$scope.userstories,results=[],i=j=0,len=ref1.length;len>j;i=++j){if(us=ref1[i],current_sum+=us.total_points,current_sum>total_points){domElement=$el.find(".backlog-table-body .us-item-row")[i],addDoomLineDom(domElement);break}results.push(void 0)}return results}},removeDoomlineDom=function(){return $el.find(".doom-line").remove()},addDoomLineDom=function(element){var text;return text=$translate.instant("BACKLOG.DOOMLINE"),$(element).before(doomLineTemplate({text:text}))},getUsItems=function(){var rowElements;return rowElements=$el.find(".backlog-table-body .us-item-row"),_.map(rowElements,function(x){return angular.element(x)})},$scope.$on("userstories:loaded",reloadDoomLine),$scope.$watch("stats",reloadDoomLine)},linkToolbar=function($scope,$el,$attrs,$ctrl){var checkSelected,getUsToMove,lastChecked,moveToCurrentSprint,moveToLatestSprint,moveUssToSprint,shiftPressed;return getUsToMove=function(){var ussDom;return ussDom=$el.find(".backlog-table-body input:checkbox:checked"),_.map(ussDom,function(item){var itemScope;return item=$(item).closest(".tg-scope"),itemScope=item.scope(),itemScope.us.milestone=$scope.sprints[0].id,itemScope.us})},moveUssToSprint=function(selectedUss,sprint){var extraPoints,totalExtraPoints,ussCurrent;return ussCurrent=_($scope.userstories),$scope.userstories=ussCurrent.without.apply(ussCurrent,selectedUss).value(),extraPoints=_.map(selectedUss,function(v,k){return v.total_points}),totalExtraPoints=_.reduce(extraPoints,function(acc,num){return acc+num}),sprint.user_stories=_.union(sprint.user_stories,selectedUss),sprint.total_points+=totalExtraPoints,$repo.saveAll(selectedUss).then(function(){return $ctrl.loadSprints(),$ctrl.loadProjectStats()}),$el.find(".move-to-sprint").hide()},moveToCurrentSprint=function(selectedUss){return moveUssToSprint(selectedUss,$scope.currentSprint)},moveToLatestSprint=function(selectedUss){return moveUssToSprint(selectedUss,$scope.sprints[0])},shiftPressed=!1,lastChecked=null,checkSelected=function(target){var moveToSprintDom,selectedUsDom;return lastChecked=target.closest(".us-item-row"),target.closest(".us-item-row").toggleClass("ui-multisortable-multiple"),moveToSprintDom=$el.find(".move-to-sprint"),selectedUsDom=$el.find(".backlog-table-body input:checkbox:checked"),selectedUsDom.length>0&&$scope.sprints.length>0?moveToSprintDom.show():moveToSprintDom.hide()},$(window).on("keydown.shift-pressed keyup.shift-pressed",function(event){return shiftPressed=!!event.shiftKey,!0}),$el.on("change",".backlog-table-body input:checkbox",function(event){var current,elements,nextAll,prevAll,target;return lastChecked&&shiftPressed&&(elements=[],current=$(event.currentTarget).closest(".us-item-row"),nextAll=lastChecked.nextAll(),prevAll=lastChecked.prevAll(),_.some(nextAll,function(next){return next===current[0]})?elements=lastChecked.nextUntil(current):_.some(prevAll,function(prev){return prev===current[0]})&&(elements=lastChecked.prevUntil(current)),_.map(elements,function(elm){var input;return input=$(elm).find("input:checkbox"),input.prop("checked",!0),checkSelected(input)})),target=angular.element(event.currentTarget),target.closest(".us-item-row").toggleClass("is-checked"),checkSelected(target)}),$el.on("click","#move-to-latest-sprint",function(_this){return function(event){var ussToMove;return ussToMove=getUsToMove(),$scope.$apply(_.partial(moveToLatestSprint,ussToMove))}}(this)),$el.on("click","#move-to-current-sprint",function(_this){return function(event){var ussToMove;return ussToMove=getUsToMove(),$scope.$apply(_.partial(moveToCurrentSprint,ussToMove))}}(this)),$el.on("click","#show-tags",function(event){return event.preventDefault(),$ctrl.toggleShowTags(),showHideTags($ctrl)})},showHideTags=function($ctrl){var elm,text;return elm=angular.element("#show-tags"),$ctrl.showTags?(elm.addClass("active"),text=$translate.instant("BACKLOG.TAGS.HIDE"),elm.text(text)):(elm.removeClass("active"),text=$translate.instant("BACKLOG.TAGS.SHOW"),elm.text(text))},showHideFilter=function($scope,$el,$ctrl){var hideText,showText,sidebar,target;return sidebar=$el.find("sidebar.filters-bar"),sidebar.one("transitionend",function(){return timeout(150,function(){return $rootscope.$broadcast("resize"),$(".burndown").css("visibility","visible")})}),target=angular.element("#show-filters-button"),$(".burndown").css("visibility","hidden"),sidebar.toggleClass("active"),target.toggleClass("active"),hideText=$translate.instant("BACKLOG.FILTERS.HIDE"),showText=$translate.instant("BACKLOG.FILTERS.SHOW"),toggleText(target,[hideText,showText]),sidebar.hasClass("active")?$ctrl.restoreFilters():$ctrl.resetFilters(),$ctrl.toggleActiveFilters()},linkFilters=function($scope,$el,$attrs,$ctrl){return $scope.filtersSearch={},$el.on("click","#show-filters-button",function(event){return event.preventDefault(),$scope.$apply(function(){return showHideFilter($scope,$el,$ctrl)})})},link=function($scope,$el,$attrs,$rootscope){var $ctrl,filters;return $ctrl=$el.controller(),linkToolbar($scope,$el,$attrs,$ctrl),linkFilters($scope,$el,$attrs,$ctrl),linkDoomLine($scope,$el,$attrs,$ctrl),$el.find(".backlog-table-body").disableSelection(),filters=$ctrl.getUrlFilters(),(filters.status||filters.tags||filters.q)&&showHideFilter($scope,$el,$ctrl),$scope.$on("showTags",function(){return showHideTags($ctrl)}),$scope.$on("$destroy",function(){return $el.off(),$(window).off(".shift-pressed")})},{link:link}},module.directive("tgBacklog",["$tgRepo","$rootScope","$translate",BacklogDirective]),UsRolePointsSelectorDirective=function($rootscope,$template,$compile,$translate){var link,selectionTemplate;return selectionTemplate=$template.get("backlog/us-role-points-popover.html",!0),link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var numberOfRoles,roles;return roles=_.filter(project.roles,"computable"),numberOfRoles=_.size(roles),numberOfRoles>1?$el.append($compile(selectionTemplate({roles:roles}))($scope)):($el.find(".icon-arrow-bottom").remove(),$el.find(".header-points").addClass("not-clickable"))}),$scope.$on("uspoints:select",function(ctx,roleId,roleName){return $el.find(".popover").popover().close(),$el.find(".header-points").html(roleName+"/Total")}),$scope.$on("uspoints:clear-selection",function(ctx,roleId){var text;return $el.find(".popover").popover().close(),text=$translate.instant("COMMON.FIELDS.POINTS"),$el.find(".header-points").text(text)}),$el.on("click",function(event){var target;return target=angular.element(event.target),(target.is("span")||target.is("div"))&&event.stopPropagation(),$el.find(".popover").popover().open()}),$el.on("click",".clear-selection",function(event){return event.preventDefault(),event.stopPropagation(),$rootscope.$broadcast("uspoints:clear-selection")}),$el.on("click",".role",function(event){var rolScope,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),rolScope=target.scope(),$rootscope.$broadcast("uspoints:select",target.data("role-id"),target.text())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUsRolePointsSelector",["$rootScope","$tgTemplate","$compile",UsRolePointsSelectorDirective]),UsPointsDirective=function($tgEstimationsService,$repo,$tgTemplate){var link,rolesTemplate;return rolesTemplate=$tgTemplate.get("common/estimation/us-points-roles-popover.html",!0),link=function($scope,$el,$attrs){var $ctrl,bindClickElements,estimationProcess,filteringRoleId,renderRolesSelector,selectedRoleId,updatingSelectedRoleId;return $ctrl=$el.controller(),updatingSelectedRoleId=null,selectedRoleId=null,filteringRoleId=null,estimationProcess=null,$scope.$on("uspoints:select",function(ctx,roleId,roleName){var us;return us=$scope.$eval($attrs.tgBacklogUsPoints),selectedRoleId=roleId,estimationProcess.render()}),$scope.$on("uspoints:clear-selection",function(ctx){var us;return us=$scope.$eval($attrs.tgBacklogUsPoints),selectedRoleId=null,estimationProcess.render()}),$scope.$watch($attrs.tgBacklogUsPoints,function(us){var roles;return us?(estimationProcess=$tgEstimationsService.create($el,us,$scope.project),roles=estimationProcess.calculateRoles(),0===roles.length?($el.find(".icon-arrow-bottom").remove(),$el.find("a.us-points").addClass("not-clickable")):1===roles.length&&(selectedRoleId=_.keys(us.points)[0]),estimationProcess.isEditable&&bindClickElements(),estimationProcess.onSelectedPointForRole=function(roleId,pointId){return this.save(roleId,pointId).then(function(){return $ctrl.loadProjectStats()})},estimationProcess.render=function(){var ctx,html,mainTemplate,pointId,pointObj,template,text,title,totalPoints;return totalPoints=this.calculateTotalPoints(),null==selectedRoleId||1===roles.length?(text=totalPoints,title=totalPoints):(pointId=this.us.points[selectedRoleId],pointObj=this.pointsById[pointId],text=pointObj.name+" / "+totalPoints+"",title=pointObj.name+" / "+totalPoints),ctx={totalPoints:totalPoints,roles:this.calculateRoles(),editable:this.isEditable,text:text,title:title},mainTemplate="common/estimation/us-estimation-total.html",template=$tgTemplate.get(mainTemplate,!0),html=template(ctx),this.$el.html(html)},estimationProcess.render()):void 0}),renderRolesSelector=function(){var html,roles;return roles=estimationProcess.calculateRoles(),html=rolesTemplate({roles:roles}),$el.append(html),$el.find(".pop-role").popover().open(function(){return $(this).remove()})},bindClickElements=function(){return $el.on("click","a.us-points span",function(event){var us;return event.preventDefault(),event.stopPropagation(),us=$scope.$eval($attrs.tgBacklogUsPoints),updatingSelectedRoleId=selectedRoleId,null!=selectedRoleId?estimationProcess.renderPointsSelector(selectedRoleId):renderRolesSelector()}),$el.on("click",".role",function(event){var popRolesDom,target,us;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),us=$scope.$eval($attrs.tgBacklogUsPoints),updatingSelectedRoleId=target.data("role-id"),popRolesDom=$el.find(".pop-role"),popRolesDom.find("a").removeClass("active"),popRolesDom.find("a[data-role-id='"+updatingSelectedRoleId+"']").addClass("active"),estimationProcess.renderPointsSelector(updatingSelectedRoleId)})},$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogUsPoints",["$tgEstimationsService","$tgRepo","$tgTemplate",UsPointsDirective]),ToggleBurndownVisibility=function($storage){var hide,link,show;return hide=function(){return $(".js-burndown-graph").removeClass("shown"),$(".js-toggle-burndown-visibility-button").removeClass("active"),$(".js-burndown-graph").removeClass("open")},show=function(firstLoad){return $(".js-toggle-burndown-visibility-button").addClass("active"),firstLoad?$(".js-burndown-graph").addClass("shown"):$(".js-burndown-graph").addClass("open")},link=function($scope,$el,$attrs){var firstLoad,hash,toggleGraph;return firstLoad=!0,hash=generateHash(["is-burndown-grpahs-collapsed"]),$scope.isBurndownGraphCollapsed=$storage.get(hash)||!1,toggleGraph=function(){return $scope.isBurndownGraphCollapsed?hide(firstLoad):show(firstLoad),firstLoad=!1},$scope.$watch("showGraphPlaceholder",function(){return null!=$scope.showGraphPlaceholder?($scope.isBurndownGraphCollapsed=$scope.isBurndownGraphCollapsed||$scope.showGraphPlaceholder,toggleGraph()):void 0}),$el.on("click",".js-toggle-burndown-visibility-button",function(){return $scope.isBurndownGraphCollapsed=!$scope.isBurndownGraphCollapsed,$storage.set(hash,$scope.isBurndownGraphCollapsed),toggleGraph()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgToggleBurndownVisibility",["$tgStorage",ToggleBurndownVisibility]),BurndownBacklogGraphDirective=function($translate){var link,redrawChart;return redrawChart=function(element,dataToDraw){var client_increment_line,colors,data,evolution_line,milestonesRange,optimal_line,options,results,team_increment_line,width,zero_line;return width=element.width(),element.height(width/6),milestonesRange=function(){results=[];for(var j=0,ref1=dataToDraw.milestones.length-1;ref1>=0?ref1>=j:j>=ref1;ref1>=0?j++:j--)results.push(j);return results}.apply(this),data=[],zero_line=_.map(dataToDraw.milestones,function(ml){return 0}),data.push({data:_.zip(milestonesRange,zero_line),lines:{fillColor:"rgba(0,0,0,0)"},points:{show:!1}}),optimal_line=_.map(dataToDraw.milestones,function(ml){return ml.optimal}),data.push({data:_.zip(milestonesRange,optimal_line),lines:{fillColor:"rgba(120,120,120,0.2)"}}),evolution_line=_.filter(_.map(dataToDraw.milestones,function(ml){return ml.evolution}),function(evolution){return null!=evolution}),data.push({data:_.zip(milestonesRange,evolution_line),lines:{fillColor:"rgba(102,153,51,0.3)"}}),client_increment_line=_.map(dataToDraw.milestones,function(ml){return-ml["team-increment"]-ml["client-increment"]}),data.push({data:_.zip(milestonesRange,client_increment_line),lines:{fillColor:"rgba(255,51,51,0.3)"}}),team_increment_line=_.map(dataToDraw.milestones,function(ml){return-ml["team-increment"]}),data.push({data:_.zip(milestonesRange,team_increment_line),lines:{fillColor:"rgba(153,51,51,0.3)"}}),colors=["rgba(0,0,0,1)","rgba(120,120,120,0.2)","rgba(102,153,51,1)","rgba(153,51,51,1)","rgba(255,51,51,1)"],options={grid:{borderWidth:{top:0,right:1,left:0,bottom:0},borderColor:"#ccc",hoverable:!0},xaxis:{ticks:dataToDraw.milestones.length,axisLabel:$translate.instant("BACKLOG.CHART.XAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5,tickFormatter:function(val,axis){return""}},yaxis:{axisLabel:$translate.instant("BACKLOG.CHART.YAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},series:{shadowSize:0,lines:{show:!0,fill:!0},points:{show:!0,fill:!0,radius:4,lineWidth:2}},colors:colors,tooltip:!0,tooltipOpts:{content:function(label,xval,yval,flotItem){var ctx;return 1===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.OPTIMAL",ctx)):2===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.REAL",ctx)):3===flotItem.seriesIndex?(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.INCREMENT_CLIENT",ctx)):(ctx={sprintName:dataToDraw.milestones[xval].name,value:Math.abs(yval)},$translate.instant("BACKLOG.CHART.INCREMENT_TEAM",ctx))}}},element.empty(),element.plot(data,options).data("plot")},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch("stats",function(value){return null!=$scope.stats?(redrawChart(element,$scope.stats),$scope.$on("resize",function(){return redrawChart(element,$scope.stats)})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBurndownBacklogGraph",["$translate",BurndownBacklogGraphDirective]),TgBacklogProgressBarDirective=function($template,$compile){var adjustPercentaje,link,render,template;return template=$template.get("backlog/progress-bar.html",!0),render=function(scope,el,projectPointsPercentaje,closedPointsPercentaje){var html;return html=template({projectPointsPercentaje:projectPointsPercentaje,closedPointsPercentaje:closedPointsPercentaje}),html=$compile(html)(scope),el.html(html)},adjustPercentaje=function(percentage){var adjusted;return adjusted=_.max([0,percentage]),adjusted=_.min([100,adjusted]),Math.round(adjusted)},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$watch($attrs.tgBacklogProgressBar,function(stats){var closedPoints,closedPointsPercentaje,definedPoints,projectPointsPercentaje,totalPoints;return null!=stats?(totalPoints=stats.total_points?stats.total_points:stats.defined_points,definedPoints=stats.defined_points,closedPoints=stats.closed_points,definedPoints>totalPoints?(projectPointsPercentaje=100*totalPoints/definedPoints,closedPointsPercentaje=100*closedPoints/definedPoints):(projectPointsPercentaje=100,closedPointsPercentaje=100*closedPoints/totalPoints),projectPointsPercentaje=adjustPercentaje(projectPointsPercentaje-3),closedPointsPercentaje=adjustPercentaje(closedPointsPercentaje-3),render($scope,$el,projectPointsPercentaje,closedPointsPercentaje)):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogProgressBar",["$tgTemplate","$compile",TgBacklogProgressBarDirective])}.call(this),function(){var BacklogEmptySortableDirective,BacklogSortableDirective,SprintSortableDirective,bindOnce,deleteElement,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,module=angular.module("taigaBacklog"),deleteElement=function(el){return el.scope().$destroy(),el.off(),el.remove()},BacklogSortableDirective=function($repo,$rs,$rootscope,$tgConfirm,$translate){var link;return link=function($scope,$el,$attrs){var getUsIndex;return getUsIndex=function(_this){return function(us){return $(us).index(".backlog-table-body .row")}}(this),bindOnce($scope,"project",function(project){var filterError;if(project.my_permissions.indexOf("modify_us")>-1)return filterError=function(){var text;return text=$translate.instant("BACKLOG.SORTABLE_FILTER_ERROR"),$tgConfirm.notify("error",text)},$el.sortable({items:".us-item-row",cancel:".popover",connectWith:".sprint",dropOnEmpty:!0,placeholder:"row us-item-row us-item-drag sortable-placeholder",scroll:!0,disableHorizontalScroll:!0,tolerance:"pointer",revert:!1,start:function(){return $(document.body).addClass("drag-active")},stop:function(){return $(document.body).removeClass("drag-active"),$el.hasClass("active-filters")?($el.sortable("cancel"),filterError()):void 0}}),$el.on("multiplesortreceive",function(event,ui){var itemIndex,itemUs;return $el.hasClass("active-filters")?(ui.source.sortable("cancel"),void filterError()):(itemUs=ui.item.scope().us,itemIndex=getUsIndex(ui.item),deleteElement(ui.item),$scope.$emit("sprint:us:move",[itemUs],itemIndex,null),ui.item.find("a").removeClass("noclick"))}),$el.on("multiplesortstop",function(event,ui){var index,items,us;if(0!==$(ui.items[0]).parent().length&&!$el.hasClass("active-filters"))return items=_.sortBy(ui.items,function(item){return $(item).index()}),index=_.min(_.map(items,function(item){return getUsIndex(item)})),us=_.map(items,function(item){var itemUs;return item=$(item),itemUs=item.scope().us,setTimeout(function(_this){return function(){return item.find("a").removeClass("noclick")}}(this),300),itemUs}),$scope.$emit("sprint:us:move",us,index,null)}),$el.on("sortstart",function(event,ui){return ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},BacklogEmptySortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?($el.sortable({items:".us-item-row",dropOnEmpty:!0}),$el.on("sortreceive",function(event,ui){var itemIndex,itemUs;return itemUs=ui.item.scope().us,itemIndex=ui.item.index(),deleteElement(ui.item),$scope.$emit("sprint:us:move",[itemUs],itemIndex,null),ui.item.find("a").removeClass("noclick")})):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},SprintSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?($el.sortable({scroll:!0,dropOnEmpty:!0,items:".sprint-table .milestone-us-item-row",disableHorizontalScroll:!0,connectWith:".sprint,.backlog-table-body,.empty-backlog",placeholder:"row us-item-row sortable-placeholder",forcePlaceholderSize:!0}),$el.on("multiplesortreceive",function(event,ui){var index,items,us;return items=_.sortBy(ui.items,function(item){return $(item).index()}),index=_.min(_.map(items,function(item){return $(item).index()})),us=_.map(items,function(item){var itemUs;return item=$(item),itemUs=item.scope().us,deleteElement(item),itemUs}),$scope.$emit("sprint:us:move",us,index,$scope.sprint.id)}),$el.on("multiplesortstop",function(event,ui){var itemIndex,itemUs;if(0!==ui.item.parent().length)return itemUs=ui.item.scope().us,itemIndex=ui.item.index(),setTimeout(function(_this){return function(){return ui.item.find("a").removeClass("noclick")}}(this),300),$scope.$emit("sprint:us:move",[itemUs],itemIndex,$scope.sprint.id)}),$el.on("sortstart",function(event,ui){return ui.item.find("a").addClass("noclick")})):void 0})},{link:link}},module.directive("tgBacklogSortable",["$tgRepo","$tgResources","$rootScope","$tgConfirm","$translate",BacklogSortableDirective]),module.directive("tgBacklogEmptySortable",["$tgRepo","$tgResources","$rootScope",BacklogEmptySortableDirective]),module.directive("tgSprintSortable",["$tgRepo","$tgResources","$rootScope",SprintSortableDirective])}.call(this),function(){var BacklogSprintDirective,BacklogSprintHeaderDirective,ToggleExcludeClosedSprintsVisualization,module,taiga;taiga=this.taiga,module=angular.module("taigaBacklog"),BacklogSprintDirective=function($repo,$rootscope){var link,slideOptions,sprintTableMinHeight,toggleSprint;return sprintTableMinHeight=50,slideOptions={duration:500,easing:"linear"},toggleSprint=function(_this){return function($el){var sprintArrow,sprintTable;return sprintTable=$el.find(".sprint-table"),sprintArrow=$el.find(".icon-arrow-up"),sprintArrow.toggleClass("active"),sprintTable.toggleClass("open")}}(this),link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgBacklogSprint,function(sprint){return sprint=$scope.$eval($attrs.tgBacklogSprint),sprint.closed?$el.addClass("sprint-closed"):toggleSprint($el)}),$el.on("click",".sprint-name > .icon-arrow-up",function(event){return event.preventDefault(),toggleSprint($el),$el.find(".sprint-table").slideToggle(slideOptions)}),$el.on("click",".sprint-name > .icon-edit",function(event){var sprint;return event.preventDefault(),sprint=$scope.$eval($attrs.tgBacklogSprint),$rootscope.$broadcast("sprintform:edit",sprint)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgBacklogSprint",["$tgRepo","$rootScope",BacklogSprintDirective]),BacklogSprintHeaderDirective=function($navUrls,$template,$compile,$translate){var link,template;return template=$template.get("backlog/sprint-header.html"),link=function($scope,$el,$attrs,$model){var isEditable,isVisible,prettyDate,render;return prettyDate=$translate.instant("BACKLOG.SPRINTS.DATE"),isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_milestone")},isVisible=function(){return-1!==$scope.project.my_permissions.indexOf("view_milestones")},render=function(sprint){var compiledTemplate,ctx,estimatedDateRange,finish,start,taskboardUrl,templateScope;return taskboardUrl=$navUrls.resolve("project-taskboard",{project:$scope.project.slug,sprint:sprint.slug}),start=moment(sprint.estimated_start).format(prettyDate),finish=moment(sprint.estimated_finish).format(prettyDate),estimatedDateRange=start+"-"+finish,ctx={name:sprint.name,taskboardUrl:taskboardUrl,estimatedDateRange:estimatedDateRange,closedPoints:sprint.closed_points||0,totalPoints:sprint.total_points||0,isVisible:isVisible(),isEditable:isEditable()},templateScope=$scope.$new(),_.assign(templateScope,ctx),compiledTemplate=$compile(template)(templateScope),$el.html(compiledTemplate)},$scope.$watch($attrs.ngModel,function(sprint){return render(sprint)}),$scope.$on("sprintform:edit:success",function(){return render($model.$modelValue)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgBacklogSprintHeader",["$tgNavUrls","$tgTemplate","$compile","$translate",BacklogSprintHeaderDirective]),ToggleExcludeClosedSprintsVisualization=function($rootscope,$loading,$translate){var excludeClosedSprints,link;return excludeClosedSprints=!0,link=function($scope,$el,$attrs){var currentLoading,loadingElm;return loadingElm=$("
"),$el.after(loadingElm),currentLoading=null,$el.on("click",function(event){return event.preventDefault(),excludeClosedSprints=!excludeClosedSprints,currentLoading=$loading().target(loadingElm).start(),excludeClosedSprints?$rootscope.$broadcast("backlog:unload-closed-sprints"):$rootscope.$broadcast("backlog:load-closed-sprints")}),$scope.$on("$destroy",function(){return $el.off()}),$scope.$on("closed-sprints:reloaded",function(_this){return function(ctx,sprints){var key,text;return currentLoading.finish(),key=sprints.length>0?"BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS":"BACKLOG.SPRINTS.ACTION_SHOW_CLOSED_SPRINTS",text=$translate.instant(key),$el.find(".text").text(text)}}(this))},{link:link}},module.directive("tgBacklogToggleClosedSprintsVisualization",["$rootScope","$tgLoading","$translate",ToggleExcludeClosedSprintsVisualization])}.call(this),function(){var SprintGraphDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,module=angular.module("taigaTaskboard"),SprintGraphDirective=function($translate){var link,redrawChart; +return redrawChart=function(element,dataToDraw){var data,days,options,width;return width=element.width(),element.height(240),days=_.map(dataToDraw,function(x){return moment(x.day)}),data=[],data.unshift({data:_.zip(days,_.map(dataToDraw,function(d){return d.optimal_points})),lines:{fillColor:"rgba(120,120,120,0.2)"}}),data.unshift({data:_.zip(days,_.map(dataToDraw,function(d){return d.open_points})),lines:{fillColor:"rgba(102,153,51,0.3)"}}),options={grid:{borderWidth:{top:0,right:1,left:0,bottom:0},borderColor:"#ccc",hoverable:!0},xaxis:{tickSize:[1,"day"],min:days[0],max:_.last(days),mode:"time",daysNames:days,axisLabel:$translate.instant("TASKBOARD.CHARTS.XAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},yaxis:{min:0,axisLabel:$translate.instant("TASKBOARD.CHARTS.YAXIS_LABEL"),axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"Verdana, Arial, Helvetica, Tahoma, sans-serif",axisLabelPadding:5},series:{shadowSize:0,lines:{show:!0,fill:!0},points:{show:!0,fill:!0,radius:4,lineWidth:2}},colors:["rgba(102,153,51,1)","rgba(120,120,120,0.2)"],tooltip:!0,tooltipOpts:{content:function(label,xval,yval,flotItem){var formattedDate,roundedValue;return formattedDate=moment(xval).format($translate.instant("TASKBOARD.CHARTS.DATE")),roundedValue=Math.round(yval),1===flotItem.seriesIndex?$translate.instant("TASKBOARD.CHARTS.OPTIMAL",{formattedDate:formattedDate,roundedValue:roundedValue}):$translate.instant("TASKBOARD.CHARTS.REAL",{formattedDate:formattedDate,roundedValue:roundedValue})}}},element.empty(),element.plot(data,options).data("plot")},link=function($scope,$el,$attrs){var element;return element=angular.element($el),$scope.$on("resize",function(){return $scope.stats?redrawChart(element,$scope.stats.days):void 0}),$scope.$on("taskboard:graph:toggle-visibility",function(){return $el.parent().toggleClass("open"),timeout(100,function(){return $scope.stats?redrawChart(element,$scope.stats.days):void 0})}),$scope.$watch("stats",function(value){return null!=$scope.stats?redrawChart(element,$scope.stats.days):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgSprintGraph",["$translate",SprintGraphDirective])}.call(this),function(){var CreateBulkTasksDirective,CreateEditTaskDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,CreateEditTaskDirective=function($repo,$model,$rs,$rootscope,$loading,lightboxService,$translate,$q,attachmentsService){var link;return link=function($scope,$el,attrs){var attachmentsToAdd,attachmentsToDelete,createAttachments,deleteAttachments,resetAttachments,submit,submitButton;return $scope.isNew=!0,attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List(),attachmentsToDelete=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},$scope.deleteAttachment=function(attachment){return attachmentsToDelete=attachmentsToDelete.push(attachment)},createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){return attachmentsService.upload(attachment.file,obj.id,$scope.task.project,"task")}),$q.all(promises)},deleteAttachments=function(obj){var promises;return console.log(attachmentsToDelete.toJS()),promises=_.map(attachmentsToDelete.toJS(),function(attachment){return attachmentsService["delete"]("task",attachment.id)}),$q.all(promises)},$scope.$on("taskform:new",function(ctx,sprintId,usId){var create,newTask;return $scope.task={project:$scope.projectId,milestone:sprintId,user_story:usId,is_archived:!1,status:$scope.project.default_task_status,assigned_to:null,tags:[]},$scope.isNew=!0,$scope.attachments=Immutable.List(),resetAttachments(),create=$translate.instant("COMMON.CREATE"),$el.find(".button-green").html(create),newTask=$translate.instant("LIGHTBOX.CREATE_EDIT_TASK.TITLE"),$el.find(".title").html(newTask+" "),$el.find(".tag-input").val(""),lightboxService.open($el)}),$scope.$on("taskform:edit",function(ctx,task,attachments){var edit,save;return $scope.task=task,$scope.isNew=!1,$scope.attachments=Immutable.fromJS(attachments),resetAttachments(),save=$translate.instant("COMMON.SAVE"),edit=$translate.instant("LIGHTBOX.CREATE_EDIT_TASK.ACTION_EDIT"),$el.find(".button-green").html(save),$el.find(".title").html(edit+" "),$el.find(".tag-input").val(""),lightboxService.open($el)}),submitButton=$el.find(".submit-button"),submit=debounce(2e3,function(_this){return function(event){var broadcastEvent,currentLoading,form,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?($scope.isNew?(promise=$repo.create("tasks",$scope.task),broadcastEvent="taskform:new:success"):(promise=$repo.save($scope.task),broadcastEvent="taskform:edit:success"),promise.then(function(data){return createAttachments(data),deleteAttachments(data),data}),currentLoading=$loading().target(submitButton).start(),promise.then(function(data){return currentLoading.finish(),lightboxService.close($el),$rootscope.$broadcast(broadcastEvent,data)})):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},CreateBulkTasksDirective=function($repo,$rs,$rootscope,$loading,lightboxService){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.form={data:"",usId:null},submit=debounce(2e3,function(_this){return function(event){var currentLoading,data,form,projectId,promise,sprintId,usId;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),data=$scope.form.data,projectId=$scope.projectId,sprintId=$scope.form.sprintId,usId=$scope.form.usId,promise=$rs.tasks.bulkCreate(projectId,sprintId,usId,data),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("taskform:bulk:success",result),lightboxService.close($el)}),promise.then(null,function(){return currentLoading.finish(),console.log("FAIL")})):void 0}}(this)),$scope.$on("taskform:bulk",function(ctx,sprintId,usId){return lightboxService.open($el),$scope.form={data:"",sprintId:sprintId,usId:usId}}),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaTaskboard"),module.directive("tgLbCreateEditTask",["$tgRepo","$tgModel","$tgResources","$rootScope","$tgLoading","lightboxService","$translate","$q","tgAttachmentsService",CreateEditTaskDirective]),module.directive("tgLbCreateBulkTasks",["$tgRepo","$tgResources","$rootScope","$tgLoading","lightboxService",CreateBulkTasksDirective])}.call(this),function(){var TaskboardController,TaskboardDirective,TaskboardSquishColumnDirective,TaskboardTaskDirective,TaskboardUserDirective,bindMethods,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,toggleText=this.taiga.toggleText,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,scopeDefer=this.taiga.scopeDefer,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,module=angular.module("taigaTaskboard"),TaskboardController=function(superClass){function TaskboardController(scope,rootscope,repo,confirm,rs1,params1,q,appMetaService,location,navUrls,events,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs1,this.params=params1,this.q=q,this.appMetaService=appMetaService,this.location=location,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("TASKBOARD.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TaskboardController,superClass),TaskboardController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","tgAppMetaService","$tgLocation","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],TaskboardController.prototype._setMeta=function(){var description,prettyDate,title;return prettyDate=this.translate.instant("BACKLOG.SPRINTS.DATE"),title=this.translate.instant("TASKBOARD.PAGE_TITLE",{projectName:this.scope.project.name,sprintName:this.scope.sprint.name}),description=this.translate.instant("TASKBOARD.PAGE_DESCRIPTION",{projectName:this.scope.project.name,sprintName:this.scope.sprint.name,startDate:moment(this.scope.sprint.estimated_start).format(prettyDate),endDate:moment(this.scope.sprint.estimated_finish).format(prettyDate),completedPercentage:this.scope.stats.completedPercentage||"0",completedPoints:this.scope.stats.completedPointsSum||"--",totalPoints:this.scope.stats.totalPointsSum||"--",openTasks:this.scope.stats.openTasks||"--",totalTasks:this.scope.stats.total_tasks||"--"}),this.appMetaService.setAll(title,description)},TaskboardController.prototype.initializeEventHandlers=function(){return this.scope.$on("taskform:bulk:success",function(_this){return function(){return _this.loadTaskboard(),_this.analytics.trackEvent("task","create","bulk create task on taskboard",1)}}(this)),this.scope.$on("taskform:new:success",function(_this){return function(){return _this.loadTaskboard(),_this.analytics.trackEvent("task","create","create task on taskboard",1)}}(this)),this.scope.$on("taskform:edit:success",function(_this){return function(){return _this.loadTaskboard()}}(this)),this.scope.$on("taskboard:task:move",this.taskMove),this.scope.$on("assigned-to:added",function(_this){return function(ctx,userId,task){var promise;return task.assigned_to=userId,promise=_this.repo.save(task),promise.then(null,function(){return console.log("FAIL")})}}(this))},TaskboardController.prototype.initializeSubscription=function(){var routingKey,routingKey1;return routingKey="changes.project."+this.scope.projectId+".tasks",this.events.subscribe(this.scope,routingKey,function(_this){return function(message){return _this.loadTaskboard()}}(this)),routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.refreshTagsColors(),_this.loadSprintStats(),_this.loadSprint()}}(this))},TaskboardController.prototype.loadProject=function(){return this.rs.projects.get(this.scope.projectId).then(function(_this){return function(project){return project.is_backlog_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.project=project,_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(e){return e.id}),_this.scope.roleById=groupBy(project.roles,function(e){return e.id}),_this.scope.taskStatusList=_.sortBy(project.task_statuses,"order"),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.scope.usStatusById=groupBy(project.us_statuses,function(e){return e.id}),_this.scope.$emit("project:loaded",project),_this.fillUsersAndRoles(project.members,project.roles),project}}(this))},TaskboardController.prototype.loadSprintStats=function(){return this.rs.sprints.stats(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(stats){var completedPointsSum,remainingPointsSum,remainingTasks,totalPointsSum;return totalPointsSum=_.reduce(_.values(stats.total_points),function(res,n){return res+n},0),completedPointsSum=_.reduce(_.values(stats.completed_points),function(res,n){return res+n},0),remainingPointsSum=totalPointsSum-completedPointsSum,remainingTasks=stats.total_tasks-stats.completed_tasks,_this.scope.stats=stats,_this.scope.stats.totalPointsSum=totalPointsSum,_this.scope.stats.completedPointsSum=completedPointsSum,_this.scope.stats.remainingPointsSum=remainingPointsSum,_this.scope.stats.remainingTasks=remainingTasks,stats.totalPointsSum?_this.scope.stats.completedPercentage=Math.round(100*stats.completedPointsSum/stats.totalPointsSum):_this.scope.stats.completedPercentage=0,_this.scope.stats.openTasks=stats.total_tasks-stats.completed_tasks,stats}}(this))},TaskboardController.prototype.refreshTagsColors=function(){return this.rs.projects.tagsColors(this.scope.projectId).then(function(_this){return function(tags_colors){return _this.scope.project.tags_colors=tags_colors}}(this))},TaskboardController.prototype.loadSprint=function(){return this.rs.sprints.get(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,_this.scope.userstories=_.sortBy(sprint.user_stories,"sprint_order"),sprint}}(this))},TaskboardController.prototype.loadTasks=function(){return this.rs.tasks.list(this.scope.projectId,this.scope.sprintId).then(function(_this){return function(tasks){var i,j,k,len,len1,len2,ref,ref1,ref2,status,task,us,usId;for(_this.scope.tasks=_.sortBy(tasks,"taskboard_order"),_this.scope.usTasks={},ref=_.union(_this.scope.userstories,[{id:null}]),i=0,len=ref.length;len>i;i++)for(us=ref[i],_this.scope.usTasks[us.id]={},ref1=_this.scope.taskStatusList,j=0,len1=ref1.length;len1>j;j++)status=ref1[j],_this.scope.usTasks[us.id][status.id]=[];for(ref2=_this.scope.tasks,k=0,len2=ref2.length;len2>k;k++)task=ref2[k],null!=_this.scope.usTasks[task.user_story]&&null!=_this.scope.usTasks[task.user_story][task.status]&&_this.scope.usTasks[task.user_story][task.status].push(task);return 0===tasks.length&&(usId=_this.scope.userstories.length>0?_this.scope.userstories[0].id:null,_this.scope.usTasks[usId][_this.scope.taskStatusList[0].id].push({isPlaceholder:!0})),tasks}}(this))},TaskboardController.prototype.loadTaskboard=function(){return this.q.all([this.refreshTagsColors(),this.loadSprintStats(),this.loadSprint().then(function(_this){return function(){return _this.loadTasks()}}(this))])},TaskboardController.prototype.loadInitialData=function(){var params,promise;return params={pslug:this.params.pslug,sslug:this.params.sslug},promise=this.repo.resolve(params).then(function(_this){return function(data){return _this.scope.projectId=data.project,_this.scope.sprintId=data.milestone,_this.initializeSubscription(),data}}(this)),promise.then(function(_this){return function(){return _this.loadProject()}}(this)).then(function(_this){return function(){return _this.loadTaskboard()}}(this))},TaskboardController.prototype.refreshTasksOrder=function(tasks){var data,items;return items=this.resortTasks(tasks),data=this.prepareBulkUpdateData(items),this.rs.tasks.bulkUpdateTaskTaskboardOrder(this.scope.project.id,data)},TaskboardController.prototype.resortTasks=function(tasks){var i,index,item,items,len;for(items=[],index=i=0,len=tasks.length;len>i;index=++i)item=tasks[index],item.taskboard_order=index,item.isModified()&&items.push(item);return items},TaskboardController.prototype.prepareBulkUpdateData=function(uses){return _.map(uses,function(x){return{task_id:x.id,order:x.taskboard_order}})},TaskboardController.prototype.taskMove=function(ctx,task,usId,statusId,order){var promise,r,tasks;return r=this.scope.usTasks[task.user_story][task.status].indexOf(task),this.scope.usTasks[task.user_story][task.status].splice(r,1),tasks=this.scope.usTasks[usId][statusId],tasks.splice(order,0,task),task.user_story=usId,task.status=statusId,task.taskboard_order=order,promise=this.repo.save(task),this.rootscope.$broadcast("sprint:task:moved",task),promise.then(function(_this){return function(){return _this.refreshTasksOrder(tasks),_this.loadSprintStats()}}(this)),promise.then(null,function(_this){return function(){return console.log("FAIL TASK SAVE")}}(this))},TaskboardController.prototype.addNewTask=function(type,us){switch(type){case"standard":return this.rootscope.$broadcast("taskform:new",this.scope.sprintId,null!=us?us.id:void 0);case"bulk":return this.rootscope.$broadcast("taskform:bulk",this.scope.sprintId,null!=us?us.id:void 0)}},TaskboardController.prototype.editTaskAssignedTo=function(task){return this.rootscope.$broadcast("assigned-to:add",task)},TaskboardController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TaskboardController",TaskboardController),TaskboardDirective=function($rootscope){var link;return link=function($scope,$el,$attrs){var $ctrl,tableBodyDom;return $ctrl=$el.controller(),$el.on("click",".toggle-analytics-visibility",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.toggleClass("active"),$rootscope.$broadcast("taskboard:graph:toggle-visibility")}),tableBodyDom=$el.find(".taskboard-table-body"),tableBodyDom.on("scroll",function(event){var tableHeaderDom,target;return target=angular.element(event.currentTarget),tableHeaderDom=$el.find(".taskboard-table-header .taskboard-table-inner"),tableHeaderDom.css("left",-1*target.scrollLeft())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgTaskboard",["$rootScope",TaskboardDirective]),TaskboardTaskDirective=function($rootscope,$loading,$rs,$rs2){var link;return link=function($scope,$el,$attrs,$model){return $el.disableSelection(),$scope.$watch("task",function(task){return task.is_blocked&&!$el.hasClass("blocked")?$el.addClass("blocked"):!task.is_blocked&&$el.hasClass("blocked")?$el.removeClass("blocked"):void 0}),$el.find(".icon-edit").on("click",function(event){return $el.find(".icon-edit").hasClass("noclick")?void 0:$scope.$apply(function(){var currentLoading,target,task;return target=$(event.target),currentLoading=$loading().target(target).timeout(200).removeClasses("icon-edit").start(),task=$scope.task,$rs.tasks.getByRef(task.project,task.ref).then(function(_this){return function(editingTask){return $rs2.attachments.list("task",editingTask.id,editingTask.project).then(function(attachments){return $rootscope.$broadcast("taskform:edit",editingTask,attachments.toJS()),currentLoading.finish()})}}(this))})})},{link:link}},module.directive("tgTaskboardTask",["$rootScope","$tgLoading","$tgResources","tgResources",TaskboardTaskDirective]),TaskboardSquishColumnDirective=function(rs){var avatarWidth,link,maxColumnWidth;return avatarWidth=40,maxColumnWidth=300,link=function($scope,$el,$attrs){var getCeilWidth,recalculateStatusColumnWidth,recalculateTaskboardWidth,refreshTaskboardTableWidth,setStatusColumnWidth;return $scope.$on("sprint:task:moved",function(_this){return function(){return recalculateTaskboardWidth()}}(this)),bindOnce($scope,"usTasks",function(project){return $scope.statusesFolded=rs.tasks.getStatusColumnModes($scope.project.id),$scope.usFolded=rs.tasks.getUsRowModes($scope.project.id,$scope.sprintId),recalculateTaskboardWidth()}),$scope.foldStatus=function(status){return $scope.statusesFolded[status.id]=!$scope.statusesFolded[status.id],rs.tasks.storeStatusColumnModes($scope.projectId,$scope.statusesFolded),recalculateTaskboardWidth()},$scope.foldUs=function(us){return us?$scope.usFolded[us.id]=!$scope.usFolded[us.id]:$scope.usFolded[null]=!$scope.usFolded[null],rs.tasks.storeUsRowModes($scope.projectId,$scope.sprintId,$scope.usFolded),recalculateTaskboardWidth()},getCeilWidth=function(_this){return function(usId,statusId){var tasks,tasksMatrixSize,width;return tasks=$scope.usTasks[usId][statusId].length,$scope.statusesFolded[statusId]?(tasks&&$scope.usFolded[usId]?(tasksMatrixSize=Math.round(Math.sqrt(tasks)),width=avatarWidth*tasksMatrixSize):width=avatarWidth,width):0}}(this),setStatusColumnWidth=function(_this){return function(statusId,width){var column;return column=$el.find(".squish-status-"+statusId),width?column.css("max-width",width):column.css("max-width",maxColumnWidth)}}(this),refreshTaskboardTableWidth=function(_this){return function(){var columnWidths,columns,totalWidth;return columnWidths=[],columns=$el.find(".task-colum-name"),columnWidths=_.map(columns,function(column){return $(column).outerWidth(!0)}),totalWidth=_.reduce(columnWidths,function(total,width){return total+width}),$el.find(".taskboard-table-inner").css("width",totalWidth)}}(this),recalculateStatusColumnWidth=function(_this){return function(statusId){var statusFoldedWidth;return statusFoldedWidth=getCeilWidth(null,statusId),_.forEach($scope.userstories,function(us){var width;return width=getCeilWidth(us.id,statusId),width>statusFoldedWidth?statusFoldedWidth=width:void 0}),setStatusColumnWidth(statusId,statusFoldedWidth)}}(this),recalculateTaskboardWidth=function(_this){return function(){_.forEach($scope.taskStatusList,function(status){return recalculateStatusColumnWidth(status.id)}),refreshTaskboardTableWidth()}}(this)},{link:link}},module.directive("tgTaskboardSquishColumn",["$tgResources",TaskboardSquishColumnDirective]),TaskboardUserDirective=function($log,$translate){var clickable,link;return clickable=!1,link=function($scope,$el,$attrs){var username_label;return username_label=$el.parent().find("a.task-assigned"),username_label.addClass("not-clickable"),$scope.$watch("task.assigned_to",function(assigned_to){var user;return user=$scope.usersById[assigned_to],void 0===user?_.assign($scope,{name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png",clickable:clickable}):_.assign($scope,{name:user.full_name_display,imgurl:user.photo,clickable:clickable}),username_label.text($scope.name)}),bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_task")>-1?(clickable=!0,$el.find(".avatar-assigned-to").on("click",function(_this){return function(event){var $ctrl;if(!$el.find("a").hasClass("noclick"))return $ctrl=$el.controller(),$ctrl.editTaskAssignedTo($scope.task)}}(this)),username_label.removeClass("not-clickable"),username_label.on("click",function(event){var $ctrl;if(!$el.find("a").hasClass("noclick"))return $ctrl=$el.controller(),$ctrl.editTaskAssignedTo($scope.task)})):void 0})},{link:link,templateUrl:"taskboard/taskboard-user.html",scope:{usersById:"=users",project:"=",task:"="}}},module.directive("tgTaskboardUserAvatar",["$log","$translate",TaskboardUserDirective])}.call(this),function(){var TaskboardSortableDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,module=angular.module("taigaBacklog"),TaskboardSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var deleteElement,itemEl,newParentScope,oldParentScope,tdom;if(project.my_permissions.indexOf("modify_us")>-1)return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el,deleteElement=function(itemEl){return itemEl.scope().$destroy(),itemEl.off(),itemEl.remove()},tdom.sortable({handle:".taskboard-task-inner",dropOnEmpty:!0,connectWith:".taskboard-tasks-box",revert:400}),tdom.on("sortstop",function(event,ui){var itemIndex,itemTask,newStatusId,newUsId,oldStatusId,oldUsId,parentEl;return parentEl=ui.item.parent(),itemEl=ui.item,itemTask=itemEl.scope().task,itemIndex=itemEl.index(),newParentScope=parentEl.scope(),oldUsId=oldParentScope.us?oldParentScope.us.id:null,oldStatusId=oldParentScope.st.id,newUsId=newParentScope.us?newParentScope.us.id:null,newStatusId=newParentScope.st.id,(newStatusId!==oldStatusId||newUsId!==oldUsId)&&deleteElement(itemEl),$scope.$apply(function(){return $rootscope.$broadcast("taskboard:task:move",itemTask,newUsId,newStatusId,itemIndex)}),ui.item.find("a").removeClass("noclick")}),tdom.on("sortstart",function(event,ui){return oldParentScope=ui.item.parent().scope(),ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgTaskboardSortable",["$tgRepo","$tgResources","$rootScope",TaskboardSortableDirective])}.call(this),function(){var KanbanArchivedStatusHeaderDirective,KanbanArchivedStatusIntroDirective,KanbanController,KanbanDirective,KanbanSquishColumnDirective,KanbanUserDirective,KanbanUserstoryDirective,KanbanWipLimitDirective,bindMethods,bindOnce,defaultViewMode,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText,viewModes,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,bindMethods=this.taiga.bindMethods,module=angular.module("taigaKanban"),defaultViewMode="maximized",viewModes=["maximized","minimized"],KanbanController=function(superClass){function KanbanController(scope,rootscope,repo,confirm,rs1,params1,q,location,appMetaService,navUrls,events,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs1,this.params=params1,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("KANBAN.SECTION_NAME"),this.scope.statusViewModes={},this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("KANBAN.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("KANBAN.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(KanbanController,superClass),KanbanController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],KanbanController.prototype.initializeEventHandlers=function(){return this.scope.$on("usform:new:success",function(_this){return function(){return _this.loadUserstories(),_this.refreshTagsColors(),_this.analytics.trackEvent("userstory","create","create userstory on kanban",1)}}(this)),this.scope.$on("usform:bulk:success",function(_this){return function(){return _this.loadUserstories(),_this.analytics.trackEvent("userstory","create","bulk create userstory on kanban",1)}}(this)),this.scope.$on("usform:edit:success",function(_this){return function(){return _this.loadUserstories(),_this.refreshTagsColors()}}(this)),this.scope.$on("assigned-to:added",this.onAssignedToChanged),this.scope.$on("kanban:us:move",this.moveUs),this.scope.$on("kanban:show-userstories-for-status",this.loadUserStoriesForStatus),this.scope.$on("kanban:hide-userstories-for-status",this.hideUserStoriesForStatus)},KanbanController.prototype.addNewUs=function(type,statusId){switch(type){case"standard":return this.rootscope.$broadcast("usform:new",this.scope.projectId,statusId,this.scope.usStatusList);case"bulk":return this.rootscope.$broadcast("usform:bulk",this.scope.projectId,statusId)}},KanbanController.prototype.changeUsAssignedTo=function(us){return this.rootscope.$broadcast("assigned-to:add",us)},KanbanController.prototype.onAssignedToChanged=function(ctx,userid,us){var promise;return us.assigned_to=userid,promise=this.repo.save(us),promise.then(null,function(){return console.log("FAIL")})},KanbanController.prototype.refreshTagsColors=function(){return this.rs.projects.tagsColors(this.scope.projectId).then(function(_this){return function(tags_colors){return _this.scope.project.tags_colors=tags_colors}}(this))},KanbanController.prototype.loadUserstories=function(){var params,promise;return params={status__is_archived:!1},promise=this.rs.userstories.listAll(this.scope.projectId,params).then(function(_this){return function(userstories){var i,j,k,len,len1,len2,ref,ref1,ref2,status,us,usByStatus,us_archived;for(_this.scope.userstories=userstories,usByStatus=_.groupBy(userstories,"status"),us_archived=[],ref=_this.scope.usStatusList,i=0,len=ref.length;len>i;i++){if(status=ref[i],null==usByStatus[status.id]&&(usByStatus[status.id]=[]),null!=_this.scope.usByStatus)for(ref1=_this.scope.usByStatus[status.id],j=0,len1=ref1.length;len1>j;j++)us=ref1[j],us.status!==status.id&&us_archived.push(us);if(status.is_archived&&null!=_this.scope.usByStatus&&0!==_this.scope.usByStatus[status.id].length)for(ref2=_this.scope.usByStatus[status.id].concat(us_archived),k=0,len2=ref2.length;len2>k;k++)us=ref2[k],us.status===status.id&&usByStatus[status.id].push(us);usByStatus[status.id]=_.sortBy(usByStatus[status.id],"kanban_order")}return 0===userstories.length&&(status=_this.scope.usStatusList[0],usByStatus[status.id].push({isPlaceholder:!0})),_this.scope.usByStatus=usByStatus,scopeDefer(_this.scope,function(){return _this.scope.$broadcast("userstories:loaded",userstories)}),userstories}}(this)),promise.then(function(_this){return function(){return _this.scope.$broadcast("redraw:wip")}}(this)),promise},KanbanController.prototype.loadUserStoriesForStatus=function(ctx,statusId){var params;return params={status:statusId},this.rs.userstories.listAll(this.scope.projectId,params).then(function(_this){return function(userstories){return _this.scope.usByStatus[statusId]=_.sortBy(userstories,"kanban_order"),_this.scope.$broadcast("kanban:shown-userstories-for-status",statusId,userstories),userstories}}(this))},KanbanController.prototype.hideUserStoriesForStatus=function(ctx,statusId){return this.scope.usByStatus[statusId]=[],this.scope.$broadcast("kanban:hidden-userstories-for-status",statusId)},KanbanController.prototype.loadKanban=function(){return this.q.all([this.refreshTagsColors(),this.loadUserstories()])},KanbanController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_kanban_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.projectId=project.id,_this.scope.points=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(project.points,function(x){return x.id}),_this.scope.usStatusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.generateStatusViewModes(),_this.scope.$emit("project:loaded",project),project}}(this))},KanbanController.prototype.initializeSubscription=function(){var routingKey1;return routingKey1="changes.project."+this.scope.projectId+".userstories",this.events.subscribe(this.scope,routingKey1,function(_this){return function(message){return _this.loadUserstories()}}(this))},KanbanController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription(),_this.loadKanban()}}(this))},KanbanController.prototype.generateStatusViewModes=function(){var i,len,mode,ref,status,storedStatusViewModes;for(storedStatusViewModes=this.rs.kanban.getStatusViewModes(this.scope.projectId),this.scope.statusViewModes={},ref=this.scope.usStatusList,i=0,len=ref.length;len>i;i++)status=ref[i],mode=storedStatusViewModes[status.id]||defaultViewMode,this.scope.statusViewModes[status.id]=mode;return this.storeStatusViewModes()}, +KanbanController.prototype.storeStatusViewModes=function(){return this.rs.kanban.storeStatusViewModes(this.scope.projectId,this.scope.statusViewModes)},KanbanController.prototype.updateStatusViewMode=function(statusId,newViewMode){return this.scope.statusViewModes[statusId]=newViewMode,this.storeStatusViewModes()},KanbanController.prototype.isMaximized=function(statusId){var mode;return mode=this.scope.statusViewModes[statusId]||defaultViewMode,"maximized"===mode},KanbanController.prototype.isMinimized=function(statusId){var mode;return mode=this.scope.statusViewModes[statusId]||defaultViewMode,"minimized"===mode},KanbanController.prototype.prepareBulkUpdateData=function(uses,field){return null==field&&(field="kanban_order"),_.map(uses,function(x){return{us_id:x.id,order:x[field]}})},KanbanController.prototype.resortUserStories=function(uses){var i,index,item,items,len;for(items=[],index=i=0,len=uses.length;len>i;index=++i)item=uses[index],item.kanban_order=index,item.isModified()&&items.push(item);return items},KanbanController.prototype.moveUs=function(ctx,us,oldStatusId,newStatusId,index){var itemsToSave,promise,r;return oldStatusId!==newStatusId?(r=this.scope.usByStatus[oldStatusId].indexOf(us),this.scope.usByStatus[oldStatusId].splice(r,1),this.scope.usByStatus[newStatusId].splice(index,0,us),us.status=newStatusId):(r=this.scope.usByStatus[newStatusId].indexOf(us),this.scope.usByStatus[newStatusId].splice(r,1),this.scope.usByStatus[newStatusId].splice(index,0,us)),itemsToSave=this.resortUserStories(this.scope.usByStatus[newStatusId]),this.scope.usByStatus[newStatusId]=_.sortBy(this.scope.usByStatus[newStatusId],"kanban_order"),promise=this.repo.save(us),promise=promise.then(function(_this){return function(){var data;return itemsToSave=_.reject(itemsToSave,{id:us.id}),data=_this.prepareBulkUpdateData(itemsToSave),_this.rs.userstories.bulkUpdateKanbanOrder(us.project,data).then(function(){return itemsToSave})}}(this))},KanbanController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("KanbanController",KanbanController),KanbanDirective=function($repo,$rootscope){var link;return link=function($scope,$el,$attrs){var tableBodyDom;return tableBodyDom=$el.find(".kanban-table-body"),tableBodyDom.on("scroll",function(event){var tableHeaderDom,target;return target=angular.element(event.currentTarget),tableHeaderDom=$el.find(".kanban-table-header .kanban-table-inner"),tableHeaderDom.css("left",-1*target.scrollLeft())}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanban",["$tgRepo","$rootScope",KanbanDirective]),KanbanArchivedStatusHeaderDirective=function($rootscope,$translate){var hideArchivedText,link,showArchivedText;return showArchivedText=$translate.instant("KANBAN.ACTION_SHOW_ARCHIVED"),hideArchivedText=$translate.instant("KANBAN.ACTION_HIDE_ARCHIVED"),link=function($scope,$el,$attrs){var hidden,status;return status=$scope.$eval($attrs.tgKanbanArchivedStatusHeader),hidden=!0,$scope["class"]="icon-open-eye",$scope.title=showArchivedText,$el.on("click",function(event){return hidden=!hidden,$scope.$apply(function(){return hidden?($scope["class"]="icon-open-eye",$scope.title=showArchivedText,$rootscope.$broadcast("kanban:hide-userstories-for-status",status.id)):($scope["class"]="icon-closed-eye",$scope.title=hideArchivedText,$rootscope.$broadcast("kanban:show-userstories-for-status",status.id))})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanArchivedStatusHeader",["$rootScope","$translate",KanbanArchivedStatusHeaderDirective]),KanbanArchivedStatusIntroDirective=function($translate){var link,userStories;return userStories=[],link=function($scope,$el,$attrs){var hiddenUserStoriexText,status,updateIntroText;return hiddenUserStoriexText=$translate.instant("KANBAN.HIDDEN_USER_STORIES"),status=$scope.$eval($attrs.tgKanbanArchivedStatusIntro),$el.text(hiddenUserStoriexText),updateIntroText=function(){return userStories.length>0?$el.text(""):$el.text(hiddenUserStoriexText)},$scope.$on("kanban:us:move",function(ctx,itemUs,oldStatusId,newStatusId,itemIndex){var r;return status.id===newStatusId?status.id===oldStatusId?(r=userStories.indexOf(itemUs),userStories.splice(r,1),userStories.splice(itemIndex,0,itemUs)):(itemUs.isArchived=!0,userStories.splice(itemIndex,0,itemUs)):status.id===oldStatusId&&(itemUs.isArchived=!1,r=userStories.indexOf(itemUs),userStories.splice(r,1)),updateIntroText()}),$scope.$on("kanban:shown-userstories-for-status",function(ctx,statusId,userStoriesLoaded){return statusId===status.id?(userStories=_.filter(userStoriesLoaded,function(us){return us.status===status.id}),updateIntroText()):void 0}),$scope.$on("kanban:hidden-userstories-for-status",function(ctx,statusId){return statusId===status.id?(userStories=[],updateIntroText()):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanArchivedStatusIntro",["$translate",KanbanArchivedStatusIntroDirective]),KanbanUserstoryDirective=function($rootscope,$loading,$rs,$rs2){var link;return link=function($scope,$el,$attrs,$model){return $el.disableSelection(),$scope.$watch("us",function(us){return us.is_blocked&&!$el.hasClass("blocked")?$el.addClass("blocked"):!us.is_blocked&&$el.hasClass("blocked")?$el.removeClass("blocked"):void 0}),$el.on("click",".icon-edit",function(event){var currentLoading,target,us;if(!$el.find(".icon-edit").hasClass("noclick"))return target=$(event.target),currentLoading=$loading().target(target).timeout(200).removeClasses("icon-edit").start(),us=$model.$modelValue,$rs.userstories.getByRef(us.project,us.ref).then(function(_this){return function(editingUserStory){return $rs2.attachments.list("us",us.id,us.project).then(function(attachments){return $rootscope.$broadcast("usform:edit",editingUserStory,attachments.toJS()),currentLoading.finish()})}}(this))}),$scope.getTemplateUrl=function(){return $scope.us.isPlaceholder?"common/components/kanban-placeholder.html":"kanban/kanban-task.html"},$scope.$on("$destroy",function(){return $el.off()})},{template:'',link:link,require:"ngModel"}},module.directive("tgKanbanUserstory",["$rootScope","$tgLoading","$tgResources","tgResources",KanbanUserstoryDirective]),KanbanSquishColumnDirective=function(rs){var link;return link=function($scope,$el,$attrs){var updateTableWidth;return $scope.$on("project:loaded",function(event,project){return $scope.folds=rs.kanban.getStatusColumnModes(project.id),updateTableWidth()}),$scope.foldStatus=function(status){$scope.folds[status.id]=!$scope.folds[status.id],rs.kanban.storeStatusColumnModes($scope.projectId,$scope.folds),updateTableWidth()},updateTableWidth=function(){var columnWidths,totalWidth;return columnWidths=_.map($scope.usStatusList,function(status){return $scope.folds[status.id]?40:310}),totalWidth=_.reduce(columnWidths,function(total,width){return total+width}),$el.find(".kanban-table-inner").css("width",totalWidth)}},{link:link}},module.directive("tgKanbanSquishColumn",["$tgResources",KanbanSquishColumnDirective]),KanbanWipLimitDirective=function(){var link;return link=function($scope,$el,$attrs){var redrawWipLimit,status;return $el.disableSelection(),status=$scope.$eval($attrs.tgKanbanWipLimit),redrawWipLimit=function(_this){return function(){return $el.find(".kanban-wip-limit").remove(),timeout(200,function(){var element;return element=$el.find(".kanban-task")[status.wip_limit],element?angular.element(element).before("
"):void 0})}}(this),status&&!status.is_archived&&($scope.$on("redraw:wip",redrawWipLimit),$scope.$on("kanban:us:move",redrawWipLimit),$scope.$on("usform:new:success",redrawWipLimit),$scope.$on("usform:bulk:success",redrawWipLimit)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanWipLimit",KanbanWipLimitDirective),KanbanUserDirective=function($log,$compile,$translate){var clickable,link,template;return template=_.template('
\n class="not-clickable"<% } %>>\n <%- name %>\n \n
'),clickable=!1,link=function($scope,$el,$attrs,$model){var render,username_label,wtid;return username_label=$el.parent().find("a.task-assigned"),username_label.addClass("not-clickable"),$attrs.tgKanbanUserAvatar?(wtid=$scope.$watch($attrs.tgKanbanUserAvatar,function(v){var user;return null==$scope.usersById?($log.error("KanbanUserDirective requires userById set in scope."),wtid()):(user=$scope.usersById[v],render(user))}),render=function(user){var ctx,html;return ctx=void 0===user?{name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png",clickable:clickable}:{name:user.full_name_display,imgurl:user.photo,clickable:clickable},html=$compile(template(ctx))($scope),$el.html(html),username_label.text(ctx.name)},bindOnce($scope,"project",function(project){return project.my_permissions.indexOf("modify_us")>-1?(clickable=!0,$el.on("click",function(_this){return function(event){var $ctrl,us;if(!$el.find("a").hasClass("noclick"))return us=$model.$modelValue,$ctrl=$el.controller(),$ctrl.changeUsAssignedTo(us)}}(this)),username_label.removeClass("not-clickable"),username_label.on("click",function(event){var $ctrl,us;if(!$el.find("a").hasClass("noclick"))return us=$model.$modelValue,$ctrl=$el.controller(),$ctrl.changeUsAssignedTo(us)})):void 0}),$scope.$on("$destroy",function(){return $el.off()})):$log.error("KanbanUserDirective: no attr is defined")},{link:link,require:"ngModel"}},module.directive("tgKanbanUserAvatar",["$log","$compile","$translate",KanbanUserDirective])}.call(this),function(){var KanbanSortableDirective,bindOnce,groupBy,mixOf,module,scopeDefer,taiga,timeout,toggleText;taiga=this.taiga,mixOf=this.taiga.mixOf,toggleText=this.taiga.toggleText,scopeDefer=this.taiga.scopeDefer,bindOnce=this.taiga.bindOnce,groupBy=this.taiga.groupBy,timeout=this.taiga.timeout,module=angular.module("taigaKanban"),KanbanSortableDirective=function($repo,$rs,$rootscope){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,"project",function(project){var deleteElement,itemEl,newParentScope,oldParentScope,tdom;if(project.my_permissions.indexOf("modify_us")>-1)return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el,deleteElement=function(itemEl){return itemEl.scope().$destroy(),itemEl.off(),itemEl.remove()},tdom.sortable({handle:".kanban-task-inner",dropOnEmpty:!0,connectWith:".kanban-uses-box",revert:400}),tdom.on("sortstop",function(event,ui){var itemIndex,itemUs,newStatusId,oldStatusId,parentEl;return parentEl=ui.item.parent(),itemEl=ui.item,itemUs=itemEl.scope().us,itemIndex=itemEl.index(),newParentScope=parentEl.scope(),newStatusId=newParentScope.s.id,oldStatusId=oldParentScope.s.id,newStatusId!==oldStatusId&&deleteElement(itemEl),$scope.$apply(function(){return $rootscope.$broadcast("kanban:us:move",itemUs,itemUs.status,newStatusId,itemIndex)}),ui.item.find("a").removeClass("noclick")}),tdom.on("sortstart",function(event,ui){return oldParentScope=ui.item.parent().scope(),ui.item.find("a").addClass("noclick")})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgKanbanSortable",["$tgRepo","$tgResources","$rootScope",KanbanSortableDirective])}.call(this),function(){var IssueDetailController,IssuePriorityButtonDirective,IssueSeverityButtonDirective,IssueStatusButtonDirective,IssueStatusDisplayDirective,IssueTypeButtonDirective,PromoteIssueToUsButtonDirective,bindMethods,bindOnce,groupBy,joinStr,mixOf,module,taiga,toString,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaIssues"),IssueDetailController=function(superClass){function IssueDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,analytics,navUrls,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.analytics=analytics,this.navUrls=navUrls,this.translate=translate,bindMethods(this),this.scope.issueRef=this.params.issueref,this.scope.sectionName=this.translate.instant("ISSUES.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(IssueDetailController,superClass),IssueDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgAnalytics","$tgNavUrls","$translate"],IssueDetailController.prototype._setMeta=function(){var description,ref,ref1,ref2,ref3,title;return title=this.translate.instant("ISSUE.PAGE_TITLE",{issueRef:"#"+this.scope.issue.ref,issueSubject:this.scope.issue.subject,projectName:this.scope.project.name}),description=this.translate.instant("ISSUE.PAGE_DESCRIPTION",{issueStatus:(null!=(ref=this.scope.statusById[this.scope.issue.status])?ref.name:void 0)||"--",issueType:(null!=(ref1=this.scope.typeById[this.scope.issue.type])?ref1.name:void 0)||"--",issueSeverity:(null!=(ref2=this.scope.severityById[this.scope.issue.severity])?ref2.name:void 0)||"--",issuePriority:(null!=(ref3=this.scope.priorityById[this.scope.issue.priority])?ref3.name:void 0)||"--",issueDescription:angular.element(this.scope.issue.description_html||"").text()}),this.appMetaService.setAll(title,description)},IssueDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on issue",1)}}(this)),this.scope.$on("promote-issue-to-us:success",function(_this){return function(){return _this.analytics.trackEvent("issue","promoteToUserstory","promote issue to userstory",1),_this.rootscope.$broadcast("object:updated"),_this.loadIssue()}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadIssue()}}(this)),this.scope.$on("custom-attributes-values:edit",function(_this){return function(){return _this.rootscope.$broadcast("object:updated")}}(this))},IssueDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;return ctx={project:this.scope.project.slug},this.scope.project.is_issues_activated?this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-issues",ctx):this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx)},IssueDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.issue_statuses,_this.scope.statusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.typeById=groupBy(project.issue_types,function(x){return x.id}),_this.scope.typeList=_.sortBy(project.issue_types,"order"),_this.scope.severityList=project.severities,_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.priorityList=project.priorities,_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),project}}(this))},IssueDetailController.prototype.loadIssue=function(){return this.rs.issues.getByRef(this.scope.projectId,this.params.issueref).then(function(_this){return function(issue){var ctx,ref,ref1;return _this.scope.issue=issue,_this.scope.issueId=issue.id,_this.scope.commentModel=issue,null!=(null!=(ref=_this.scope.issue.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.issue.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-issues-detail",ctx)),null!=(null!=(ref1=_this.scope.issue.neighbors.next)?ref1.ref:void 0)?(ctx={project:_this.scope.project.slug,ref:_this.scope.issue.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-issues-detail",ctx)):void 0}}(this))},IssueDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadIssue()}}(this))},IssueDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.upvote(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.downvote(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onWatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.watch(this.scope.issueId).then(onSuccess,onError)},IssueDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadIssue(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.issues.unwatch(this.scope.issueId).then(onSuccess,onError)},IssueDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("IssueDetailController",IssueDetailController),IssueStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(issue){var html,status;return status=$scope.statusById[issue.status],html=template({is_closed:status.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(issue){return null!=issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueStatusDisplay",["$tgTemplate","$compile",IssueStatusDisplayDirective]),IssueStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issues-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,status;return status=$scope.statusById[issue.status],html=template({status:status,statuses:$scope.statusList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(statusId){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.status=statusId,currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),save(target.data("status-id"))):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueStatusButtonDirective]),IssueTypeButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-type-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,type;return type=$scope.typeById[issue.type],html=template({type:type,typees:$scope.typeList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(type){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.type=type,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".type-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-type").popover().open():void 0}),$el.on("click",".type",function(event){var target,type;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),type=target.data("type-id"),save(type)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueTypeButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueTypeButtonDirective]),IssueSeverityButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-severity-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,severity;return severity=$scope.severityById[issue.severity],html=template({severity:severity,severityes:$scope.severityList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(severity){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.severity=severity,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".severity-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-severity").popover().open():void 0}),$el.on("click",".severity",function(event){var severity,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),severity=target.data("severity-id"),save(severity)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssueSeverityButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssueSeverityButtonDirective]),IssuePriorityButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("issue/issue-priority-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_issue")},render=function(_this){return function(issue){var html,priority;return priority=$scope.priorityById[issue.priority],html=template({priority:priority,priorityes:$scope.priorityList,editable:isEditable()}),html=$compile(html)($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(priority){var currentLoading,issue,onError,onSuccess;return $.fn.popover().closeAll(),issue=$model.$modelValue.clone(),issue.priority=priority,currentLoading=$loading().target($el.find(".level-name")).start(),onSuccess=function(){return $model.$setViewValue(issue),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),issue.revert(),$model.$setViewValue(issue),currentLoading.finish()},$repo.save(issue).then(onSuccess,onError)}}(this)),$el.on("click",".priority-data",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-priority").popover().open():void 0}),$el.on("click",".priority",function(event){var priority,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),priority=target.data("priority-id"),save(priority)):void 0}),$scope.$watch($attrs.ngModel,function(issue){return issue?render(issue):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgIssuePriorityButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",IssuePriorityButtonDirective]),PromoteIssueToUsButtonDirective=function($rootScope,$repo,$confirm,$qqueue,$translate){var link;return link=function($scope,$el,$attrs,$model){var save;return save=$qqueue.bindAdd(function(_this){return function(issue,askResponse){var data,onError,onSuccess;return data={generated_from_issue:issue.id,project:issue.project,subject:issue.subject,description:issue.description,tags:issue.tags,is_blocked:issue.is_blocked,blocked_note:issue.blocked_note},onSuccess=function(){return askResponse.finish(),$confirm.notify("success"),$rootScope.$broadcast("promote-issue-to-us:success")},onError=function(){return askResponse.finish(),$confirm.notify("error")},$repo.create("userstories",data).then(onSuccess,onError)}}(this)),$el.on("click","a",function(event){var issue,message,subtitle,title;return event.preventDefault(),issue=$model.$modelValue,title=$translate.instant("ISSUES.CONFIRM_PROMOTE.TITLE"),message=$translate.instant("ISSUES.CONFIRM_PROMOTE.MESSAGE"),subtitle=issue.subject,$confirm.ask(title,subtitle,message).then(function(_this){return function(response){return save(issue,response)}}(this))}),$scope.$on("$destroy",function(){return $el.off()})},{restrict:"AE",require:"ngModel",templateUrl:"issue/promote-issue-to-us-button.html",link:link}},module.directive("tgPromoteIssueToUsButton",["$rootScope","$tgRepo","$tgConfirm","$tgQqueue","$translate",PromoteIssueToUsButtonDirective])}.call(this),function(){var CreateBulkIssuesDirective,CreateIssueDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaIssues"),CreateIssueDirective=function($repo,$confirm,$rootscope,lightboxService,$loading,$q,attachmentsService){var link;return link=function($scope,$el,$attrs){var attachmentsToAdd,createAttachments,form,resetAttachments,submit,submitButton;return form=$el.find("form").checksley(),$scope.issue={},$scope.attachments=Immutable.List(),$scope.$on("issueform:new",function(ctx,project){var attachmentsToAdd;return attachmentsToAdd=Immutable.List(),$el.find(".tag-input").val(""),lightboxService.open($el),$scope.issue={project:project.id,subject:"",status:project.default_issue_status,type:project.default_issue_type,priority:project.default_priority,severity:project.default_severity,tags:[]}}),$scope.$on("$destroy",function(){return $el.off()}),createAttachments=function(obj){var promises;return promises=_.map(attachmentsToAdd.toJS(),function(attachment){return attachmentsService.upload(attachment.file,obj.id,$scope.issue.project,"issue")}),$q.all(promises)},attachmentsToAdd=Immutable.List(),resetAttachments=function(){return attachmentsToAdd=Immutable.List()},$scope.addAttachment=function(attachment){return attachmentsToAdd=attachmentsToAdd.push(attachment)},submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("issues",$scope.issue),promise.then(function(data){return createAttachments(data)}),promise.then(function(data){return currentLoading.finish(),$rootscope.$broadcast("issueform:new:success",data),lightboxService.close($el),$confirm.notify("success")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgLbCreateIssue",["$tgRepo","$tgConfirm","$rootScope","lightboxService","$tgLoading","$q","tgAttachmentsService",CreateIssueDirective]),CreateBulkIssuesDirective=function($repo,$rs,$confirm,$rootscope,$loading,lightboxService){var link;return link=function($scope,$el,attrs){var submit,submitButton;return $scope.$on("issueform:bulk",function(ctx,projectId,status){return lightboxService.open($el),$scope["new"]={projectId:projectId,bulk:""}}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,data,form,projectId,promise;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(currentLoading=$loading().target(submitButton).start(),data=$scope["new"].bulk,projectId=$scope["new"].projectId,promise=$rs.issues.bulkCreate(projectId,data),promise.then(function(result){return currentLoading.finish(),$rootscope.$broadcast("issueform:new:success",result),lightboxService.close($el),$confirm.notify("success")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgLbCreateBulkIssues",["$tgRepo","$tgResources","$tgConfirm","$rootScope","$tgLoading","lightboxService",CreateBulkIssuesDirective])}.call(this),function(){var IssueAssignedToInlineEditionDirective,IssueStatusInlineEditionDirective,IssuesController,IssuesDirective,IssuesFiltersDirective,bindOnce,debounceLeading,groupBy,joinStr,mixOf,module,startswith,taiga,toString,trim,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim, +toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounceLeading=this.taiga.debounceLeading,startswith=this.taiga.startswith,module=angular.module("taigaIssues"),IssuesController=function(superClass){function IssuesController(scope,rootscope,repo,confirm,rs,urls,params,q,location,appMetaService,navUrls,events,analytics,translate){var filters,promise;return this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.urls=urls,this.params=params,this.q=q,this.location=location,this.appMetaService=appMetaService,this.navUrls=navUrls,this.events=events,this.analytics=analytics,this.translate=translate,this.loadIssues=bind(this.loadIssues,this),this.scope.sectionName="Issues",this.scope.filters={},_.isEmpty(this.location.search())?(filters=this.rs.issues.getFilters(this.params.pslug),filters.page=1,this.location.search(filters),void this.location.replace()):(promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ISSUES.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("ISSUES.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),void this.scope.$on("issueform:new:success",function(_this){return function(){return _this.analytics.trackEvent("issue","create","create issue on issues list",1),_this.loadIssues()}}(this)))}return extend(IssuesController,superClass),IssuesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$tgUrls","$routeParams","$q","$tgLocation","tgAppMetaService","$tgNavUrls","$tgEvents","$tgAnalytics","$translate"],IssuesController.prototype.initializeSubscription=function(){var routingKey;return routingKey="changes.project."+this.scope.projectId+".issues",this.events.subscribe(this.scope,routingKey,function(_this){return function(message){return _this.loadIssues()}}(this))},IssuesController.prototype.storeFilters=function(){return this.rs.issues.storeFilters(this.params.pslug,this.location.search())},IssuesController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_issues_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issueStatusById=groupBy(project.issue_statuses,function(x){return x.id}),_this.scope.issueStatusList=_.sortBy(project.issue_statuses,"order"),_this.scope.severityById=groupBy(project.severities,function(x){return x.id}),_this.scope.severityList=_.sortBy(project.severities,"order"),_this.scope.priorityById=groupBy(project.priorities,function(x){return x.id}),_this.scope.priorityList=_.sortBy(project.priorities,"order"),_this.scope.issueTypes=_.sortBy(project.issue_types,"order"),_this.scope.issueTypeById=groupBy(project.issue_types,function(x){return x.id}),project}}(this))},IssuesController.prototype.getUrlFilters=function(){var filters;return filters=_.pick(this.location.search(),"page","tags","status","types","q","severities","priorities","assignedTo","createdBy","orderBy"),filters.page||(filters.page=1),filters},IssuesController.prototype.getUrlFilter=function(name){var filters;return filters=_.pick(this.location.search(),name),filters[name]},IssuesController.prototype.loadMyFilters=function(){return this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return _.map(filters,function(value,key){return{id:key,name:key,type:"myFilters",selected:!1}})}}(this))},IssuesController.prototype.removeNotExistingFiltersFromUrl=function(){var currentSearch,existingValues,filterName,filterValue,splittedValues,urlfilters;currentSearch=this.location.search(),urlfilters=this.getUrlFilters();for(filterName in urlfilters)filterValue=urlfilters[filterName],"page"!==filterName&&"orderBy"!==filterName&&"q"!==filterName&&(splittedValues="tags"===filterName?_.map((""+filterValue).split(",")):_.map((""+filterValue).split(","),function(x){return"null"===x?null:parseInt(x)}),existingValues=_.intersection(splittedValues,_.map(this.scope.filters[filterName],"id")),splittedValues.length!==existingValues.length&&this.location.search(filterName,existingValues.join()));return currentSearch!==this.location.search()?this.location.replace():void 0},IssuesController.prototype.markSelectedFilters=function(filters,urlfilters){var isSelected,j,key,len,name,obj,ref,ref1,results,searchdata,val,value;searchdata={},ref=_.omit(urlfilters,"page","orderBy");for(name in ref)for(value=ref[name],null==searchdata[name]&&(searchdata[name]={}),ref1=(""+value).split(","),j=0,len=ref1.length;len>j;j++)val=ref1[j],searchdata[name][val]=!0;isSelected=function(type,id){return null!=searchdata[type]&&searchdata[type][id]?!0:!1},results=[];for(key in filters)value=filters[key],results.push(function(){var k,len1,results1;for(results1=[],k=0,len1=value.length;len1>k;k++)obj=value[k],results1.push(obj.selected=isSelected(obj.type,obj.id)?!0:void 0);return results1}());return results},IssuesController.prototype.loadFilters=function(){var loadFilters,promise,urlfilters;return urlfilters=this.getUrlFilters(),urlfilters.q&&(this.scope.filtersQ=urlfilters.q),promise=this.loadMyFilters().then(function(_this){return function(myFilters){return _this.scope.filters.myFilters=myFilters,myFilters}}(this)),loadFilters={},loadFilters.project=this.scope.projectId,loadFilters.tags=urlfilters.tags,loadFilters.status=urlfilters.status,loadFilters.q=urlfilters.q,loadFilters.types=urlfilters.types,loadFilters.severities=urlfilters.severities,loadFilters.priorities=urlfilters.priorities,loadFilters.assigned_to=urlfilters.assignedTo,loadFilters.owner=urlfilters.createdBy,promise=promise.then(function(_this){return function(){return _this.rs.issues.filtersData(loadFilters)}}(this)),promise.then(function(_this){return function(data){var choicesFiltersFormat,tagsFilterFormat,usersFiltersFormat;return usersFiltersFormat=function(users,type,unknownOption){var reformatedUsers,unknownItem;return reformatedUsers=_.map(users,function(t){return t.type=type,t.name=t.full_name?t.full_name:unknownOption,t}),unknownItem=_.remove(reformatedUsers,function(u){return!u.id}),reformatedUsers=_.sortBy(reformatedUsers,function(u){return u.name.toUpperCase()}),unknownItem.length>0&&reformatedUsers.unshift(unknownItem[0]),reformatedUsers},choicesFiltersFormat=function(choices,type,byIdObject){return _.map(choices,function(t){return t.type=type,t})},tagsFilterFormat=function(tags){return _.map(tags,function(t){return t.id=t.name,t.type="tags",t})},_this.scope.filters.status=choicesFiltersFormat(data.statuses,"status",_this.scope.issueStatusById),_this.scope.filters.severities=choicesFiltersFormat(data.severities,"severities",_this.scope.severityById),_this.scope.filters.priorities=choicesFiltersFormat(data.priorities,"priorities",_this.scope.priorityById),_this.scope.filters.assignedTo=usersFiltersFormat(data.assigned_to,"assignedTo","Unassigned"),_this.scope.filters.createdBy=usersFiltersFormat(data.owners,"createdBy","Unknown"),_this.scope.filters.types=choicesFiltersFormat(data.types,"types",_this.scope.issueTypeById),_this.scope.filters.tags=tagsFilterFormat(data.tags),_this.removeNotExistingFiltersFromUrl(),_this.markSelectedFilters(_this.scope.filters,urlfilters),_this.rootscope.$broadcast("filters:loaded",_this.scope.filters)}}(this))},IssuesController.prototype.loadIssuesRequests=0,IssuesController.prototype.loadIssues=function(){var name,promise,ref,values;this.scope.urlFilters=this.getUrlFilters(),this.scope.httpParams={},ref=this.scope.urlFilters;for(name in ref)values=ref[name],"severities"===name?name="severity":"orderBy"===name?name="order_by":"priorities"===name?name="priority":"assignedTo"===name?name="assigned_to":"createdBy"===name?name="owner":"status"===name?name="status":"types"===name&&(name="type"),this.scope.httpParams[name]=values;return promise=this.rs.issues.list(this.scope.projectId,this.scope.httpParams),this.loadIssuesRequests+=1,promise.index=this.loadIssuesRequests,promise.then(function(_this){return function(data){return promise.index===_this.loadIssuesRequests&&(_this.scope.issues=data.models,_this.scope.page=data.current,_this.scope.count=data.count,_this.scope.paginatedBy=data.paginatedBy),data}}(this)),promise},IssuesController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.initializeSubscription(),_this.loadFilters(),_this.loadIssues()}}(this))},IssuesController.prototype.saveCurrentFiltersTo=function(newFilter){var deferred;return deferred=this.q.defer(),this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return filters[newFilter]=_this.location.search(),_this.rs.issues.storeMyFilters(_this.scope.projectId,filters).then(function(){return deferred.resolve()})}}(this)),deferred.promise},IssuesController.prototype.deleteMyFilter=function(filter){var deferred;return deferred=this.q.defer(),this.rs.issues.getMyFilters(this.scope.projectId).then(function(_this){return function(filters){return delete filters[filter],_this.rs.issues.storeMyFilters(_this.scope.projectId,filters).then(function(){return deferred.resolve()})}}(this)),deferred.promise},IssuesController.prototype.addNewIssue=function(){return this.rootscope.$broadcast("issueform:new",this.scope.project)},IssuesController.prototype.addIssuesInBulk=function(){return this.rootscope.$broadcast("issueform:bulk",this.scope.projectId)},IssuesController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("IssuesController",IssuesController),IssuesDirective=function($log,$location,$template,$compile){var link,linkOrdering,linkPagination,template;return template=$template.get("issue/issue-paginator.html",!0),linkPagination=function($scope,$el,$attrs,$ctrl){var $pagEl,afterCurrent,atBegin,atEnd,beforeCurrent,getNumPages,renderPagination;return afterCurrent=2,beforeCurrent=4,atBegin=2,atEnd=2,$pagEl=$el.find(".issues-paginator"),getNumPages=function(){var numPages;return numPages=$scope.count/$scope.paginatedBy,numPages=parseInt(numPages,10)=numPages)return void $pagEl.hide();for($pagEl.show(),pages=[],options={},options.pages=pages,options.showPrevious=$scope.page>1,options.showNext=!($scope.page===numPages),cpage=$scope.page,i=j=1,ref=numPages;ref>=1?ref>=j:j>=ref;i=ref>=1?++j:--j)i===cpage+afterCurrent&&numPages>cpage+afterCurrent+atEnd?pages.push({classes:"dots",type:"dots"}):i===cpage-beforeCurrent&&cpage>atBegin+beforeCurrent?pages.push({classes:"dots",type:"dots"}):i>cpage+afterCurrent&&numPages-atEnd>=i||cpage-beforeCurrent>i&&i>atBegin||(i===cpage?pages.push({classes:"active",num:i,type:"page-active"}):pages.push({classes:"page",num:i,type:"page"}));return html=template(options),html=$compile(html)($scope),$pagEl.html(html)},$scope.$watch("issues",function(value){return value?renderPagination():void 0}),$el.on("click",".issues-paginator a.next",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page+1),$ctrl.loadIssues()})}),$el.on("click",".issues-paginator a.previous",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page-1),$ctrl.loadIssues()})}),$el.on("click",".issues-paginator li.page > a",function(event){var pagenum,target;return event.preventDefault(),target=angular.element(event.currentTarget),pagenum=target.data("pagenum"),$scope.$apply(function(){return $ctrl.selectFilter("page",pagenum),$ctrl.loadIssues()})})},linkOrdering=function($scope,$el,$attrs,$ctrl){var colHeadElement,currentOrder,icon;return currentOrder=$ctrl.getUrlFilter("orderBy")||"created_date",currentOrder&&(icon=startswith(currentOrder,"-")?"icon-arrow-up":"icon-arrow-bottom",colHeadElement=$el.find(".row.title > div[data-fieldname='"+trim(currentOrder,"-")+"']"),colHeadElement.html(colHeadElement.html()+"")),$el.on("click",".row.title > div",function(event){var finalOrder,newOrder,target;return target=angular.element(event.currentTarget),currentOrder=$ctrl.getUrlFilter("orderBy"),newOrder=target.data("fieldname"),finalOrder=currentOrder===newOrder?"-"+newOrder:newOrder,$scope.$apply(function(){return $ctrl.replaceFilter("orderBy",finalOrder),$ctrl.storeFilters(),$ctrl.loadIssues().then(function(){return $el.find(".row.title > div > span.icon").remove(),icon=startswith(finalOrder,"-")?"icon-arrow-up":"icon-arrow-bottom",target.html(target.html()+"")})})})},link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),linkOrdering($scope,$el,$attrs,$ctrl),linkPagination($scope,$el,$attrs,$ctrl),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssues",["$log","$tgLocation","$tgTemplate","$compile",IssuesDirective]),IssuesFiltersDirective=function($q,$log,$location,$rs,$confirm,$loading,$template,$translate,$compile,$auth){var link,template,templateSelected;return template=$template.get("issue/issues-filters.html",!0),templateSelected=$template.get("issue/issues-filters-selected.html",!0),link=function($scope,$el,$attrs){var $ctrl,getFiltersType,initializeSelectedFilters,reloadIssues,renderFilters,renderSelectedFilters,selectQFilter,selectedFilters,showCategories,showFilters,toggleFilterSelection,unwatchIssues;return $ctrl=$el.closest(".wrapper").controller(),selectedFilters=[],showFilters=function(title,type){return $el.find(".filters-cats").hide(),$el.find(".filter-list").removeClass("hidden"),$el.find("h2.breadcrumb").removeClass("hidden"),$el.find("h2 a.subfilter span.title").html(title),$el.find("h2 a.subfilter span.title").prop("data-type",type)},showCategories=function(){return $el.find(".filters-cats").show(),$el.find(".filter-list").addClass("hidden"),$el.find("h2.breadcrumb").addClass("hidden")},initializeSelectedFilters=function(filters){var j,len,name,val,values;selectedFilters=[];for(name in filters)for(values=filters[name],j=0,len=values.length;len>j;j++)val=values[j],val.selected&&selectedFilters.push(val);return renderSelectedFilters(selectedFilters)},renderSelectedFilters=function(selectedFilters){var html;return _.filter(selectedFilters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=templateSelected({filters:selectedFilters}),html=$compile(html)($scope),$el.find(".filters-applied").html(html),$auth.isAuthenticated()&&selectedFilters.length>0?$el.find(".save-filters").show():$el.find(".save-filters").hide()},renderFilters=function(filters){var html;return _.filter(filters,function(_this){return function(f){return f.color?f.style="border-left: 3px solid "+f.color:void 0}}(this)),html=template({filters:filters}),html=$compile(html)($scope),$el.find(".filter-list").html(html)},getFiltersType=function(){return $el.find("h2 a.subfilter span.title").prop("data-type")},reloadIssues=function(){var currentFiltersType;return currentFiltersType=getFiltersType(),$q.all([$ctrl.loadIssues(),$ctrl.loadFilters()]).then(function(){var filters;return filters=$scope.filters[currentFiltersType],renderFilters(_.reject(filters,"selected"))})},toggleFilterSelection=function(type,id){var currentFiltersType,filter,filterId,filters;return"myFilters"===type?($rs.issues.getMyFilters($scope.projectId).then(function(data){var filters,myFilters;return myFilters=data,filters=myFilters[id],filters.page=1,$ctrl.replaceAllFilters(filters),$ctrl.storeFilters(),$ctrl.loadIssues(),$ctrl.markSelectedFilters($scope.filters,filters),initializeSelectedFilters($scope.filters)}),null):(filters=$scope.filters[type],filterId="tags"===type?taiga.toString(id):id,filter=_.find(filters,{id:filterId}),filter.selected=!filter.selected,null===id&&(id="null"),filter.selected?(selectedFilters.push(filter),$ctrl.selectFilter(type,id),$ctrl.selectFilter("page",1),$ctrl.storeFilters()):(selectedFilters=_.reject(selectedFilters,function(f){return f.id===filter.id&&f.type===filter.type}),$ctrl.unselectFilter(type,id),$ctrl.selectFilter("page",1),$ctrl.storeFilters()),reloadIssues(),renderSelectedFilters(selectedFilters),currentFiltersType=getFiltersType(),type===currentFiltersType?renderFilters(_.reject(filters,"selected")):void 0)},$scope.$on("filters:loaded",function(ctx,filters){return initializeSelectedFilters(filters)}),$scope.$on("filters:issueupdate",function(ctx,filters){var html;return html=template({filters:filters.status}),html=$compile(html)($scope),$el.find(".filter-list").html(html)}),selectQFilter=debounceLeading(100,function(value,oldValue){return void 0!==value&&value!==oldValue?($ctrl.replaceFilter("page",null,!0),0===value.length?($ctrl.replaceFilter("q",null),$ctrl.storeFilters()):($ctrl.replaceFilter("q",value),$ctrl.storeFilters()),reloadIssues()):void 0}),unwatchIssues=$scope.$watch("issues",function(newValue){return _.isUndefined(newValue)?void 0:($scope.$watch("filtersQ",selectQFilter),unwatchIssues())}),$el.on("click",".filters-cats > ul > li > a",function(event){var tags,target;return event.preventDefault(),target=angular.element(event.currentTarget),tags=$scope.filters[target.data("type")],renderFilters(_.reject(tags,"selected")),showFilters(target.attr("title"),target.data("type"))}),$el.on("click",".filters-inner > .filters-step-cat > .breadcrumb > .back",function(event){return event.preventDefault(),showCategories($el)}),$el.on("click",".filters-applied a",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),id=target.data("id")||null,type=target.data("type"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter",function(event){var id,target,type;return event.preventDefault(),target=angular.element(event.currentTarget),target.toggleClass("active"),id=target.data("id")||null,type=target.data("type"),"myFilters"===type&&target.removeClass("active"),toggleFilterSelection(type,id)}),$el.on("click",".filter-list .single-filter .icon-delete",function(event){var customFilterName,message,target,title;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),customFilterName=target.parent().data("id"),title=$translate.instant("ISSUES.FILTERS.CONFIRM_DELETE.TITLE"),message=$translate.instant("ISSUES.FILTERS.CONFIRM_DELETE.MESSAGE",{customFilterName:customFilterName}),$confirm.askOnDelete(title,message).then(function(askResponse){var promise;return promise=$ctrl.deleteMyFilter(customFilterName),promise.then(function(){return promise=$ctrl.loadMyFilters(),promise.then(function(filters){return askResponse.finish(),$scope.filters.myFilters=filters,renderFilters($scope.filters.myFilters)}),promise.then(null,function(){return askResponse.finish()})}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})})}),$el.on("click",".save-filters",function(event){return event.preventDefault(),renderFilters($scope.filters.myFilters),showFilters("My filters","myFilters"),$el.find(".save-filters").hide(),$el.find(".my-filter-name").removeClass("hidden"),$el.find(".my-filter-name").focus(),$scope.$apply()}),$el.on("keyup",".my-filter-name",function(event){var currentLoading,newFilter,promise,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newFilter=target.val(),currentLoading=$loading().target($el.find(".new")).start(),promise=$ctrl.saveCurrentFiltersTo(newFilter),promise.then(function(){var loadPromise;return loadPromise=$ctrl.loadMyFilters(),loadPromise.then(function(filters){var currentfilterstype;return currentLoading.finish(),$scope.filters.myFilters=filters,currentfilterstype=$el.find("h2 a.subfilter span.title").prop("data-type"),"myFilters"===currentfilterstype&&renderFilters($scope.filters.myFilters),$el.find(".my-filter-name").addClass("hidden"),$el.find(".save-filters").show()}),loadPromise.then(null,function(){return currentLoading.finish(),$confirm.notify("error","Error loading custom filters")})}),promise.then(null,function(){return currentLoading.finish(),$el.find(".my-filter-name").val(newFilter).focus().select(),$confirm.notify("error","Filter not saved")})):27===event.keyCode?($el.find(".my-filter-name").val(""),$el.find(".my-filter-name").addClass("hidden"),$el.find(".save-filters").show()):void 0})},{link:link}},module.directive("tgIssuesFilters",["$q","$log","$tgLocation","$tgResources","$tgConfirm","$tgLoading","$tgTemplate","$translate","$compile","$tgAuth",IssuesFiltersDirective]),IssueStatusInlineEditionDirective=function($repo,$template,$rootscope){var link,selectionTemplate,updateIssueStatus;return selectionTemplate=$template.get("issue/issue-status-inline-edition-selection.html",!0),updateIssueStatus=function($el,issue,issueStatusById){var issueStatusDom,issueStatusDomParent,status;return issueStatusDomParent=$el.find(".issue-status"),issueStatusDom=$el.find(".issue-status .issue-status-bind"),status=issueStatusById[issue.status],status?(issueStatusDom.text(status.name),issueStatusDom.prop("title",status.name),issueStatusDomParent.css("color",status.color)):void 0},link=function($scope,$el,$attrs){var $ctrl,issue;return $ctrl=$el.controller(),issue=$scope.$eval($attrs.tgIssueStatusInlineEdition),$el.on("click",".issue-status",function(event){return event.preventDefault(),event.stopPropagation(),$el.find(".pop-status").popover().open()}),$el.on("click",".status",function(event){var filter,j,len,ref,target;for(event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),ref=$scope.filters.status,j=0,len=ref.length;len>j;j++)filter=ref[j],filter.id===issue.status&&filter.count--;return issue.status=target.data("status-id"),$el.find(".pop-status").popover().close(),updateIssueStatus($el,issue,$scope.issueStatusById),$scope.$apply(function(){var k,len1,ref1;for($repo.save(issue).then(function(){return $ctrl.loadIssues()}),ref1=$scope.filters.status,k=0,len1=ref1.length;len1>k;k++)filter=ref1[k],filter.id===issue.status&&filter.count++;return $rootscope.$broadcast("filters:issueupdate",$scope.filters)})}),taiga.bindOnce($scope,"project",function(project){return $el.append(selectionTemplate({statuses:project.issue_statuses})),updateIssueStatus($el,issue,$scope.issueStatusById),-1===project.my_permissions.indexOf("modify_issue")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$watch($attrs.tgIssueStatusInlineEdition,function(_this){return function(val){return updateIssueStatus($el,val,$scope.issueStatusById)}}(this)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssueStatusInlineEdition",["$tgRepo","$tgTemplate","$rootScope",IssueStatusInlineEditionDirective]),IssueAssignedToInlineEditionDirective=function($repo,$rootscope,$translate){var link,template;return template=_.template('<%- name %>\n
<%- name %>
'),link=function($scope,$el,$attrs){var $ctrl,issue,updateIssue;return updateIssue=function(issue){var ctx,member;return ctx={name:$translate.instant("COMMON.ASSIGNED_TO.NOT_ASSIGNED"),imgurl:"/"+window._version+"/images/unnamed.png"},member=$scope.usersById[issue.assigned_to],member&&(ctx.name=member.full_name_display,ctx.imgurl=member.photo),$el.find(".avatar").html(template(ctx)),$el.find(".issue-assignedto").attr("title",ctx.name)},$ctrl=$el.controller(),issue=$scope.$eval($attrs.tgIssueAssignedToInlineEdition),updateIssue(issue),$el.on("click",".issue-assignedto",function(event){return $rootscope.$broadcast("assigned-to:add",issue)}),taiga.bindOnce($scope,"project",function(project){return-1===project.my_permissions.indexOf("modify_issue")?($el.unbind("click"),$el.find("a").addClass("not-clickable")):void 0}),$scope.$on("assigned-to:added",function(_this){return function(ctx,userId,updatedIssue){return updatedIssue.id===issue.id?(updatedIssue.assigned_to=userId,$repo.save(updatedIssue),updateIssue(updatedIssue)):void 0}}(this)),$scope.$watch($attrs.tgIssueAssignedToInlineEdition,function(_this){return function(val){return updateIssue(val)}}(this)),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgIssueAssignedToInlineEdition",["$tgRepo","$rootScope","$translate",IssueAssignedToInlineEditionDirective])}.call(this),function(){var UsClientRequirementButtonDirective,UsStatusButtonDirective,UsStatusDisplayDirective,UsTeamRequirementButtonDirective,UserStoryDetailController,bindMethods,bindOnce,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaUserStories"),UserStoryDetailController=function(superClass){function UserStoryDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.usRef=this.params.usref,this.scope.sectionName=this.translate.instant("US.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserStoryDetailController,superClass),UserStoryDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],UserStoryDetailController.prototype._setMeta=function(){var closedTasks,description,progressPercentage,ref,title,totalTasks;return totalTasks=this.scope.tasks.length,closedTasks=_.filter(this.scope.tasks,function(_this){return function(t){return _this.scope.taskStatusById[t.status].is_closed}}(this)).length,progressPercentage=totalTasks>0?Math.round(100*closedTasks/totalTasks):0,title=this.translate.instant("US.PAGE_TITLE",{userStoryRef:"#"+this.scope.us.ref,userStorySubject:this.scope.us.subject,projectName:this.scope.project.name}),description=this.translate.instant("US.PAGE_DESCRIPTION",{userStoryStatus:(null!=(ref=this.scope.statusById[this.scope.us.status])?ref.name:void 0)||"--",userStoryPoints:this.scope.us.total_points,userStoryDescription:angular.element(this.scope.us.description_html||"").text(),userStoryClosedTasks:closedTasks,userStoryTotalTasks:totalTasks,userStoryProgressPercentage:progressPercentage}),this.appMetaService.setAll(title,description)},UserStoryDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("related-tasks:update",function(_this){return function(){return _this.scope.tasks=_.clone(_this.scope.tasks,!1)}}(this)),this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on userstory",1)}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadUs()}}(this))},UserStoryDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;return ctx={project:this.scope.project.slug},this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx),this.scope.project.is_backlog_activated?this.scope.us.milestone?(ctx.sprint=this.scope.sprint.slug,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-taskboard",ctx)):this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-backlog",ctx):this.scope.project.is_kanban_activated?this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-kanban",ctx):void 0},UserStoryDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.us_statuses,_this.scope.statusById=groupBy(project.us_statuses,function(x){return x.id}),_this.scope.taskStatusById=groupBy(project.task_statuses,function(x){return x.id}),_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.pointsById=groupBy(_this.scope.pointsList,function(e){return e.id}),project}}(this))},UserStoryDetailController.prototype.loadUs=function(){var httpParams,kanbanStaus,milestone,noMilestone;return httpParams=_.pick(this.location.search(),"milestone","no-milestone","kanban-status"),milestone=httpParams.milestone,milestone&&this.rs.userstories.storeQueryParams(this.scope.projectId,{milestone:milestone,order_by:"sprint_order"}),noMilestone=httpParams["no-milestone"],noMilestone&&this.rs.userstories.storeQueryParams(this.scope.projectId,{milestone:"null",order_by:"backlog_order"}),kanbanStaus=httpParams["kanban-status"],kanbanStaus&&this.rs.userstories.storeQueryParams(this.scope.projectId,{status:kanbanStaus,order_by:"kanban_order"}),this.rs.userstories.getByRef(this.scope.projectId,this.params.usref).then(function(_this){return function(us){var ctx,ref,ref1;return _this.scope.us=us,_this.scope.usId=us.id,_this.scope.commentModel=us,null!=(null!=(ref=_this.scope.us.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.us.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-userstories-detail",ctx)),null!=(null!=(ref1=_this.scope.us.neighbors.next)?ref1.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.us.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-userstories-detail",ctx)),us}}(this))},UserStoryDetailController.prototype.loadSprint=function(){return this.scope.us.milestone?this.rs.sprints.get(this.scope.us.project,this.scope.us.milestone).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,sprint}}(this)):void 0},UserStoryDetailController.prototype.loadTasks=function(){return this.rs.tasks.list(this.scope.projectId,null,this.scope.usId).then(function(_this){return function(tasks){return _this.scope.tasks=tasks,tasks}}(this))},UserStoryDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadUs().then(function(){return _this.q.all([_this.loadSprint(),_this.loadTasks()])})}}(this))},UserStoryDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.upvote(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error"); +}}(this),this.rs.userstories.downvote(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onWatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.watch(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadUs(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.userstories.unwatch(this.scope.usId).then(onSuccess,onError)},UserStoryDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserStoryDetailController",UserStoryDetailController),UsStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(us){var html,status;return status=$scope.statusById[us.status],html=template({is_closed:us.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(us){return null!=us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsStatusDisplay",["$tgTemplate","$compile",UsStatusDisplayDirective]),UsStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$template){var link,template;return template=$template.get("us/us-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(_this){return function(us){var html,status;return status=$scope.statusById[us.status],html=template({status:status,statuses:$scope.statusList,editable:isEditable()}),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(status){var currentLoading,onError,onSuccess,us;return us=$model.$modelValue.clone(),us.status=status,$.fn.popover().closeAll(),currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(us),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),currentLoading.finish()},$repo.save(us).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var status,target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),status=target.data("status-id"),save(status)):void 0}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate",UsStatusButtonDirective]),UsTeamRequirementButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("us/us-team-requirement-button.html",!0),link=function($scope,$el,$attrs,$model){var canEdit,render,save;return canEdit=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(us){var ctx,html;return ctx={canEdit:canEdit(),isRequired:us.team_requirement},html=template(ctx),html=$compile(html)($scope),$el.html(html)},save=$qqueue.bindAdd(function(_this){return function(team_requirement){var currentLoading,promise,us;return us=$model.$modelValue.clone(),us.team_requirement=team_requirement,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(us),promise.then(function(){return $model.$setViewValue(us),currentLoading.finish(),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return currentLoading.finish(),$confirm.notify("error")})}}(this)),$el.on("click",".team-requirement",function(event){var team_requirement;if(canEdit())return team_requirement=!$model.$modelValue.team_requirement,save(team_requirement)}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsTeamRequirementButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",UsTeamRequirementButtonDirective]),UsClientRequirementButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$template,$compile){var link,template;return template=$template.get("us/us-client-requirement-button.html",!0),link=function($scope,$el,$attrs,$model){var canEdit,render,save;return canEdit=function(){return-1!==$scope.project.my_permissions.indexOf("modify_us")},render=function(us){var ctx,html;return ctx={canEdit:canEdit(),isRequired:us.client_requirement},html=$compile(template(ctx))($scope),$el.html(html)},save=$qqueue.bindAdd(function(_this){return function(client_requirement){var currentLoading,promise,us;return us=$model.$modelValue.clone(),us.client_requirement=client_requirement,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(us),promise.then(function(){return $model.$setViewValue(us),currentLoading.finish(),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error")})}}(this)),$el.on("click",".client-requirement",function(event){var client_requirement;if(canEdit())return client_requirement=!$model.$modelValue.client_requirement,save(client_requirement)}),$scope.$watch($attrs.ngModel,function(us){return us?render(us):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgUsClientRequirementButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$tgTemplate","$compile",UsClientRequirementButtonDirective])}.call(this),function(){var TaskDetailController,TaskIsIocaineButtonDirective,TaskStatusButtonDirective,TaskStatusDisplayDirective,bindMethods,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindMethods=this.taiga.bindMethods,module=angular.module("taigaTasks"),TaskDetailController=function(superClass){function TaskDetailController(scope,rootscope,repo,confirm,rs,params,q,location,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,bindMethods(this),this.scope.taskRef=this.params.taskref,this.scope.sectionName=this.translate.instant("TASK.SECTION_NAME"),this.initializeEventHandlers(),promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta(),_this.initializeOnDeleteGoToUrl()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TaskDetailController,superClass),TaskDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],TaskDetailController.prototype._setMeta=function(){var description,ref,title;return title=this.translate.instant("TASK.PAGE_TITLE",{taskRef:"#"+this.scope.task.ref,taskSubject:this.scope.task.subject,projectName:this.scope.project.name}),description=this.translate.instant("TASK.PAGE_DESCRIPTION",{taskStatus:(null!=(ref=this.scope.statusById[this.scope.task.status])?ref.name:void 0)||"--",taskDescription:angular.element(this.scope.task.description_html||"").text()}),this.appMetaService.setAll(title,description)},TaskDetailController.prototype.initializeEventHandlers=function(){return this.scope.$on("attachment:create",function(_this){return function(){return _this.analytics.trackEvent("attachment","create","create attachment on task",1)}}(this)),this.scope.$on("custom-attributes-values:edit",function(_this){return function(){return _this.rootscope.$broadcast("object:updated")}}(this)),this.scope.$on("comment:new",function(_this){return function(){return _this.loadTask()}}(this))},TaskDetailController.prototype.initializeOnDeleteGoToUrl=function(){var ctx;if(ctx={project:this.scope.project.slug},this.scope.onDeleteGoToUrl=this.navUrls.resolve("project",ctx),this.scope.project.is_backlog_activated){if(this.scope.task.milestone)return ctx.sprint=this.scope.sprint.slug,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-taskboard",ctx);if(this.scope.task.us)return ctx.ref=this.scope.us.ref,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-userstories-detail",ctx)}else if(this.scope.project.is_kanban_activated&&this.scope.us)return ctx.ref=this.scope.us.ref,this.scope.onDeleteGoToUrl=this.navUrls.resolve("project-userstories-detail",ctx)},TaskDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.statusList=project.task_statuses,_this.scope.statusById=groupBy(project.task_statuses,function(x){return x.id}),project}}(this))},TaskDetailController.prototype.loadTask=function(){return this.rs.tasks.getByRef(this.scope.projectId,this.params.taskref).then(function(_this){return function(task){var ctx,ref,ref1;return _this.scope.task=task,_this.scope.taskId=task.id,_this.scope.commentModel=task,null!=(null!=(ref=_this.scope.task.neighbors.previous)?ref.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.task.neighbors.previous.ref},_this.scope.previousUrl=_this.navUrls.resolve("project-tasks-detail",ctx)),null!=(null!=(ref1=_this.scope.task.neighbors.next)?ref1.ref:void 0)&&(ctx={project:_this.scope.project.slug,ref:_this.scope.task.neighbors.next.ref},_this.scope.nextUrl=_this.navUrls.resolve("project-tasks-detail",ctx)),task}}(this))},TaskDetailController.prototype.loadSprint=function(){return this.scope.task.milestone?this.rs.sprints.get(this.scope.task.project,this.scope.task.milestone).then(function(_this){return function(sprint){return _this.scope.sprint=sprint,sprint}}(this)):void 0},TaskDetailController.prototype.loadUserStory=function(){return this.scope.task.user_story?this.rs.userstories.get(this.scope.task.project,this.scope.task.user_story).then(function(_this){return function(us){return _this.scope.us=us,us}}(this)):void 0},TaskDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadTask().then(function(){return _this.q.all([_this.loadSprint(),_this.loadUserStory()])})}}(this))},TaskDetailController.prototype.onUpvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.upvote(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onDownvote=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.downvote(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onWatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.watch(this.scope.taskId).then(onSuccess,onError)},TaskDetailController.prototype.onUnwatch=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.loadTask(),_this.rootscope.$broadcast("object:updated")}}(this),onError=function(_this){return function(){return _this.confirm.notify("error")}}(this),this.rs.tasks.unwatch(this.scope.taskId).then(onSuccess,onError)},TaskDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TaskDetailController",TaskDetailController),TaskStatusDisplayDirective=function($template,$compile){var link,template;return template=$template.get("common/components/status-display.html",!0),link=function($scope,$el,$attrs){var render;return render=function(task){var html,status;return status=$scope.statusById[task.status],html=template({is_closed:status.is_closed,status:status}),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(task){return null!=task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskStatusDisplay",["$tgTemplate","$compile",TaskStatusDisplayDirective]),TaskStatusButtonDirective=function($rootScope,$repo,$confirm,$loading,$qqueue,$compile,$translate,$template){var link,template;return template=$template.get("us/us-status-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_task")},render=function(_this){return function(task){var html,status;return status=$scope.statusById[task.status],html=$compile(template({status:status,statuses:$scope.statusList,editable:isEditable()}))($scope),$el.html(html)}}(this),save=$qqueue.bindAdd(function(_this){return function(status){var currentLoading,onError,onSuccess,task;return task=$model.$modelValue.clone(),task.status=status,currentLoading=$loading().target($el).start(),onSuccess=function(){return $model.$setViewValue(task),$rootScope.$broadcast("object:updated"),currentLoading.finish()},onError=function(){return $confirm.notify("error"),currentLoading.finish()},$repo.save(task).then(onSuccess,onError)}}(this)),$el.on("click",".js-edit-status",function(event){return event.preventDefault(),event.stopPropagation(),isEditable()?$el.find(".pop-status").popover().open():void 0}),$el.on("click",".status",function(event){var target;return event.preventDefault(),event.stopPropagation(),isEditable()?(target=angular.element(event.currentTarget),$.fn.popover().closeAll(),save(target.data("status-id"))):void 0}),$scope.$watch($attrs.ngModel,function(task){return task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskStatusButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$compile","$translate","$tgTemplate",TaskStatusButtonDirective]),TaskIsIocaineButtonDirective=function($rootscope,$tgrepo,$confirm,$loading,$qqueue,$compile,$template){var link,template;return template=$template.get("issue/iocaine-button.html",!0),link=function($scope,$el,$attrs,$model){var isEditable,render,save;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_task")},render=function(task){var ctx,html;return isEditable()||task.is_iocaine?(ctx={isIocaine:task.is_iocaine,isEditable:isEditable()},html=$compile(template(ctx))($scope),$el.html(html)):void $el.html("")},save=$qqueue.bindAdd(function(_this){return function(is_iocaine){var currentLoading,promise,task;return task=$model.$modelValue.clone(),task.is_iocaine=is_iocaine,currentLoading=$loading().target($el.find("label")).start(),promise=$tgrepo.save(task),promise.then(function(){return $model.$setViewValue(task),$rootscope.$broadcast("object:updated")}),promise.then(null,function(){return $confirm.notify("error")}),promise["finally"](function(){return currentLoading.finish()})}}(this)),$el.on("click",".is-iocaine",function(event){var is_iocaine;if(isEditable())return is_iocaine=!$model.$modelValue.is_iocaine,save(is_iocaine)}),$scope.$watch($attrs.ngModel,function(task){return task?render(task):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgTaskIsIocaineButton",["$rootScope","$tgRepo","$tgConfirm","$tgLoading","$tgQqueue","$compile","$tgTemplate",TaskIsIocaineButtonDirective])}.call(this),function(){var LeaveProjectDirective,TeamController,TeamFiltersDirective,TeamMemberCurrentUserDirective,TeamMemberStatsDirective,TeamMembersDirective,membersFilter,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,module=angular.module("taigaTeam"),TeamController=function(superClass){function TeamController(scope,rootscope,repo,rs,params,q,location,navUrls,appMetaService,auth,translate,projectService){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.auth=auth,this.translate=translate,this.projectService=projectService,this.scope.sectionName="TEAM.SECTION_NAME",promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("TEAM.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.translate.instant("TEAM.PAGE_DESCRIPTION",{projectName:_this.scope.project.name,projectDescription:_this.scope.project.description}),_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(TeamController,superClass),TeamController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$routeParams","$q","$location","$tgNavUrls","tgAppMetaService","$tgAuth","$translate","tgProjectService"],TeamController.prototype.setRole=function(role){return role?this.scope.filtersRole=role:this.scope.filtersRole=null},TeamController.prototype.loadMembers=function(){var i,len,member,ref,user;for(user=this.auth.getUser(),this.scope.totals={},ref=this.scope.activeUsers,i=0,len=ref.length;len>i;i++)member=ref[i],this.scope.totals[member.id]=0;return this.scope.currentUser=_.find(this.scope.activeUsers,{id:null!=user?user.id:void 0}),this.scope.memberships=_.reject(this.scope.activeUsers,{id:null!=user?user.id:void 0})},TeamController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.issuesEnabled=project.is_issues_activated,_this.scope.tasksEnabled=project.is_kanban_activated||project.is_backlog_activated,_this.scope.wikiEnabled=project.is_wiki_activated,project}}(this))},TeamController.prototype.loadMemberStats=function(){return this.rs.projects.memberStats(this.scope.projectId).then(function(_this){return function(stats){var totals;return totals={},_.forEach(_this.scope.totals,function(total,userId){var vals;return vals=_.map(stats,function(memberStats,statsKey){return memberStats[userId]}),total=_.reduce(vals,function(sum,el){return sum+el}),_this.scope.totals[userId]=total}),_this.scope.stats=_this._processStats(stats),_this.scope.stats.totals=_this.scope.totals}}(this))},TeamController.prototype._processStat=function(stat){var max,min,singleStat;return max=_.max(stat),min=_.min(stat),singleStat=_.map(stat,function(value,key){return value===min?[key,.1]:value===max?[key,1]:[key,.5*value/max]}),singleStat=_.object(singleStat)},TeamController.prototype._processStats=function(stats){var key,value;for(key in stats)value=stats[key],stats[key]=this._processStat(value);return stats},TeamController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.loadMembers(),_this.loadMemberStats()}}(this))},TeamController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("TeamController",TeamController),TeamFiltersDirective=function(){return{templateUrl:"team/team-filter.html"}},module.directive("tgTeamFilters",[TeamFiltersDirective]),TeamMemberStatsDirective=function(){return{templateUrl:"team/team-member-stats.html",scope:{stats:"=",userId:"=user",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamMemberStats",TeamMemberStatsDirective),TeamMemberCurrentUserDirective=function(){return{templateUrl:"team/team-member-current-user.html",scope:{projectId:"=projectid",currentUser:"=currentuser",stats:"=",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamCurrentUser",TeamMemberCurrentUserDirective),TeamMembersDirective=function(){var template;return template="team/team-members.html",{templateUrl:template,scope:{memberships:"=",filtersQ:"=filtersq",filtersRole:"=filtersrole",stats:"=",issuesEnabled:"=issuesenabled",tasksEnabled:"=tasksenabled",wikiEnabled:"=wikienabled"}}},module.directive("tgTeamMembers",TeamMembersDirective),LeaveProjectDirective=function($repo,$confirm,$location,$rs,$navurls,$translate){var link;return link=function($scope,$el,$attrs){return $scope.leave=function(){var confirm_leave_project_text,leave_project_text;return leave_project_text=$translate.instant("TEAM.ACTION_LEAVE_PROJECT"),confirm_leave_project_text=$translate.instant("TEAM.CONFIRM_LEAVE_PROJECT"),$confirm.ask(leave_project_text,confirm_leave_project_text).then(function(_this){return function(response){var promise;return promise=$rs.projects.leave($attrs.projectid),promise.then(function(){return response.finish(),$confirm.notify("success"),$location.path($navurls.resolve("home"))}),promise.then(null,function(response){return response.finish(),$confirm.notify("error",response.data._error_message)})}}(this))}},{scope:{},templateUrl:"team/leave-project.html",link:link}},module.directive("tgLeaveProject",["$tgRepo","$tgConfirm","$tgLocation","$tgResources","$tgNavUrls","$translate",LeaveProjectDirective]),membersFilter=function(){return function(members,filtersQ,filtersRole){return _.filter(members,function(m){return(!filtersRole||m.role===filtersRole.id)&&(!filtersQ||m.full_name.search(new RegExp(filtersQ,"i"))>=0)})}},module.filter("membersFilter",membersFilter)}.call(this),function(){var EditableWikiContentDirective,WikiDetailController,WikiSummaryDirective,bindOnce,debounce,groupBy,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaWiki"),WikiDetailController=function(superClass){function WikiDetailController(scope,rootscope,repo,model,confirm,rs,params,q,location,filter,log,appMetaService,navUrls,analytics,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.model=model,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.filter=filter,this.log=log,this.appMetaService=appMetaService,this.navUrls=navUrls,this.analytics=analytics,this.translate=translate,this.scope.projectSlug=this.params.pslug,this.scope.wikiSlug=this.params.slug,this.scope.wikiTitle=this.scope.wikiSlug,this.scope.sectionName="Wiki",this.scope.linksVisible=!1,promise=this.loadInitialData(),promise.then(function(_this){return function(){return _this._setMeta()}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(WikiDetailController,superClass),WikiDetailController.$inject=["$scope","$rootScope","$tgRepo","$tgModel","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$filter","$log","tgAppMetaService","$tgNavUrls","$tgAnalytics","$translate"],WikiDetailController.prototype._setMeta=function(){var description,ref,ref1,ref2,title;return title=this.translate.instant("WIKI.PAGE_TITLE",{wikiPageName:this.scope.wikiTitle,projectName:this.scope.project.name}),description=this.translate.instant("WIKI.PAGE_DESCRIPTION",{wikiPageContent:angular.element((null!=(ref=this.scope.wiki)?ref.html:void 0)||"").text(),totalEditions:(null!=(ref1=this.scope.wiki)?ref1.editions:void 0)||0,lastModifiedDate:moment(null!=(ref2=this.scope.wiki)?ref2.modified_date:void 0).format(this.translate.instant("WIKI.DATETIME"))}),this.appMetaService.setAll(title,description)},WikiDetailController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.is_wiki_activated||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},WikiDetailController.prototype.loadWiki=function(){var promise;return promise=this.rs.wiki.getBySlug(this.scope.projectId,this.params.slug),promise.then(function(_this){return function(wiki){return _this.scope.wiki=wiki,_this.scope.wikiId=wiki.id,_this.scope.wiki}}(this)),promise.then(null,function(_this){return function(xhr){var data;return _this.scope.wikiId=null,-1===_this.scope.project.my_permissions.indexOf("add_wiki_page")?null:(data={project:_this.scope.projectId,slug:_this.scope.wikiSlug,content:""},_this.scope.wiki=_this.model.make_model("wiki",data),_this.scope.wiki)}}(this))},WikiDetailController.prototype.loadWikiLinks=function(){return this.rs.wiki.listLinks(this.scope.projectId).then(function(_this){return function(wikiLinks){var selectedWikiLink;return _this.scope.wikiLinks=wikiLinks,selectedWikiLink=_.find(wikiLinks,{href:_this.scope.wikiSlug}),null!=selectedWikiLink?_this.scope.wikiTitle=selectedWikiLink.title:void 0}}(this))},WikiDetailController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(project){return _this.fillUsersAndRoles(project.members,project.roles),_this.q.all([_this.loadWikiLinks(),_this.loadWiki()]).then(_this.checkLinksPerms.bind(_this))}}(this))},WikiDetailController.prototype.checkLinksPerms=function(){return-1!==this.scope.project.my_permissions.indexOf("modify_wiki_link")||-1!==this.scope.project.my_permissions.indexOf("view_wiki_links")&&this.scope.wikiLinks.length?this.scope.linksVisible=!0:void 0},WikiDetailController.prototype["delete"]=function(){var message,title;return title=this.translate.instant("WIKI.DELETE_LIGHTBOX_TITLE"),message=this.scope.wikiTitle,this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onSuccess=function(){var ctx;return askResponse.finish(),ctx={project:_this.scope.projectSlug},_this.location.path(_this.navUrls.resolve("project-wiki",ctx)),_this.confirm.notify("success")},onError=function(){return askResponse.finish(!1),_this.confirm.notify("error")},_this.repo.remove(_this.scope.wiki).then(onSuccess,onError)}}(this))},WikiDetailController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("WikiDetailController",WikiDetailController),WikiSummaryDirective=function($log,$template,$compile,$translate){var link,template;return template=$template.get("wiki/wiki-summary.html",!0),link=function($scope,$el,$attrs,$model){var render;return render=function(wiki){var ctx,html,user;return null==$scope.usersById?$log.error("WikiSummaryDirective requires userById set in scope."):user=$scope.usersById[wiki.last_modifier],user=void 0===user?{name:"unknown",imgUrl:"/"+window._version+"/images/user-noimage.png"}:{name:user.full_name_display,imgUrl:user.photo},ctx={totalEditions:wiki.editions,lastModifiedDate:moment(wiki.modified_date).format($translate.instant("WIKI.DATETIME")),user:user},html=template(ctx),html=$compile(html)($scope),$el.html(html)},$scope.$watch($attrs.ngModel,function(wikiPage){return wikiPage?render(wikiPage):void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgWikiSummary",["$log","$tgTemplate","$compile","$translate",WikiSummaryDirective]),EditableWikiContentDirective=function($window,$document,$repo,$confirm,$loading,$analytics,$qqueue){var link;return link=function($scope,$el,$attrs,$model){var cancelEdition,disableEdition,getSelectedText,isEditable,save,switchToEditMode,switchToReadMode;return isEditable=function(){return-1!==$scope.project.my_permissions.indexOf("modify_wiki_page")},switchToEditMode=function(){return $el.find(".edit-wiki-content").show(),$el.find(".view-wiki-content").hide(),$el.find("textarea").focus()},switchToReadMode=function(){return $el.find(".edit-wiki-content").hide(),$el.find(".view-wiki-content").show()},disableEdition=function(){return $el.find(".view-wiki-content .edit").remove(),$el.find(".edit-wiki-content").remove()},cancelEdition=function(){return $model.$modelValue.id?($scope.$apply(function(_this){return function(){return $model.$modelValue.revert()}}(this)),switchToReadMode()):void 0},getSelectedText=function(){return $window.getSelection?$window.getSelection().toString():$document.selection?$document.selection.createRange().text:null},save=$qqueue.bindAdd(function(wiki){var currentLoading,onError,onSuccess,promise;return onSuccess=function(wikiPage){return null==wiki.id&&$analytics.trackEvent("wikipage","create","create wiki page",1),$model.$setViewValue(wikiPage.clone()),$confirm.notify("success"),switchToReadMode()},onError=function(){return $confirm.notify("error")},currentLoading=$loading().removeClasses("icon-floppy").target($el.find(".icon-floppy")).start(),promise=null!=wiki.id?$repo.save(wiki).then(onSuccess,onError):$repo.create("wiki",wiki).then(onSuccess,onError),promise["finally"](function(){return currentLoading.finish()})}),$el.on("click","a",function(event){var href,target;return target=angular.element(event.target),href=target.attr("href"),0===href.indexOf("#")?(event.preventDefault(),$("body").scrollTop($(href).offset().top)):void 0}),$el.on("mousedown",".view-wiki-content",function(event){var target;target=angular.element(event.target),isEditable()&&2===event.button}),$el.on("mouseup",".view-wiki-content",function(event){var target;return target=angular.element(event.target),getSelectedText()||!isEditable()||target.is("a")||target.is("pre")?void 0:switchToEditMode()}),$el.on("click",".save",debounce(2e3,function(){return save($scope.wiki)})),$el.on("click",".cancel",function(){return cancelEdition()}),$el.on("keydown","textarea",function(event){return 27===event.keyCode?cancelEdition():void 0}),$scope.$watch($attrs.ngModel,function(wikiPage){return wikiPage?isEditable()?($el.addClass("editable"),null==wikiPage.id||0===$.trim(wikiPage.content).length?switchToEditMode():void 0):disableEdition():void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,restrict:"EA",require:"ngModel",templateUrl:"wiki/editable-wiki-content.html" +}},module.directive("tgEditableWikiContent",["$window","$document","$tgRepo","$tgConfirm","$tgLoading","$tgAnalytics","$tgQqueue",EditableWikiContentDirective])}.call(this),function(){var WikiNavDirective,bindOnce,groupBy,mixOf,module,taiga;taiga=this.taiga,mixOf=this.taiga.mixOf,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,module=angular.module("taigaWiki"),WikiNavDirective=function($tgrepo,$log,$location,$confirm,$navUrls,$analytics,$loading,$template,$compile,$translate){var link,template;return template=$template.get("wiki/wiki-nav.html",!0),link=function($scope,$el,$attrs){var $ctrl,render;return $ctrl=$el.controller(),null==$attrs.ngModel?$log.error("WikiNavDirective: no ng-model attr is defined"):(render=function(wikiLinks){var addWikiLinkPermission,deleteWikiLinkPermission,html;return addWikiLinkPermission=$scope.project.my_permissions.indexOf("add_wiki_link")>-1,deleteWikiLinkPermission=$scope.project.my_permissions.indexOf("delete_wiki_link")>-1,html=template({wikiLinks:wikiLinks,projectSlug:$scope.projectSlug,addWikiLinkPermission:addWikiLinkPermission,deleteWikiLinkPermission:deleteWikiLinkPermission}),html=$compile(html)($scope),$el.off(),$el.html(html),$el.on("click",".wiki-link .link-title",function(event){var linkId,linkSlug,target;return event.preventDefault(),target=angular.element(event.currentTarget),linkId=target.parents(".wiki-link").data("id"),linkSlug=$scope.wikiLinks[linkId].href,$scope.$apply(function(){var ctx;return ctx={project:$scope.projectSlug,slug:linkSlug},$location.path($navUrls.resolve("project-wiki-page",ctx))})}),$el.on("click",".add-button",function(event){return event.preventDefault(),$el.find(".new").removeClass("hidden"),$el.find(".new input").focus(),$el.find(".add-button").hide()}),$el.on("click",".wiki-link .icon-delete",function(event){var linkId,message,target,title;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),linkId=target.parents(".wiki-link").data("id"),title=$translate.instant("WIKI.DELETE_LIGHTBOX_TITLE"),message=$scope.wikiLinks[linkId].title,$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var promise;return promise=$tgrepo.remove($scope.wikiLinks[linkId]),promise.then(function(){return promise=$ctrl.loadWikiLinks(),promise.then(function(){return askResponse.finish(),render($scope.wikiLinks)}),promise.then(null,function(){return askResponse.finish()})}),promise.then(null,function(){return askResponse.finish(!1),$confirm.notify("error")})}}(this))}),$el.on("keyup",".new input",function(event){var currentLoading,newLink,promise,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newLink=target.val(),currentLoading=$loading().target($el.find(".new")).start(),promise=$tgrepo.create("wiki-links",{project:$scope.projectId,title:newLink}),promise.then(function(){var loadPromise;return $analytics.trackEvent("wikilink","create","create wiki link",1),loadPromise=$ctrl.loadWikiLinks(),loadPromise.then(function(){return currentLoading.finish(),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show(),render($scope.wikiLinks)}),loadPromise.then(null,function(){return currentLoading.finish(),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show(),$confirm.notify("error","Error loading wiki links")})}),promise.then(null,function(error){var ref;return currentLoading.finish(),$el.find(".new input").val(newLink),$el.find(".new input").focus().select(),null!=(null!=error&&null!=(ref=error.__all__)?ref[0]:void 0)?$confirm.notify("error","The link already exists"):$confirm.notify("error")})):27===event.keyCode?(target=angular.element(event.currentTarget),$el.find(".new").addClass("hidden"),$el.find(".new input").val(""),$el.find(".add-button").show()):void 0})},bindOnce($scope,$attrs.ngModel,render))},{link:link}},module.directive("tgWikiNav",["$tgRepo","$log","$tgLocation","$tgConfirm","$tgNavUrls","$tgAnalytics","$tgLoading","$tgTemplate","$compile","$translate",WikiNavDirective])}.call(this),function(){var CreateMembersDirective,MAX_MEMBERSHIP_FIELDSETS,debounce,module,taiga;taiga=this.taiga,debounce=this.taiga.debounce,module=angular.module("taigaKanban"),MAX_MEMBERSHIP_FIELDSETS=4,CreateMembersDirective=function($rs,$rootScope,$confirm,$loading,lightboxService,$compile){var extraTextTemplate,link,template;return extraTextTemplate='
\n \n
',template=_.template('
\n
\n data-required="true" <% } %> data-type="email" />\n
\n
\n \n \n
\n
'),link=function($scope,$el,$attrs){var createFieldSet,resetForm,submit,submitButton;return createFieldSet=function(required){var ctx;return null==required&&(required=!0),ctx={roleList:$scope.project.roles,required:required},$compile(template(ctx))($scope)},resetForm=function(){var fieldSet,invitations;return $el.find("form textarea").remove(),$el.find("form .add-member-wrapper").remove(),invitations=$el.find(".add-member-forms"),invitations.html($compile(extraTextTemplate)($scope)),fieldSet=createFieldSet(),invitations.prepend(fieldSet)},$scope.$on("membersform:new",function(){return resetForm(),lightboxService.open($el)}),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click",".delete-fieldset",function(event){var fieldSet,lastActionButton,target;return event.preventDefault(),target=angular.element(event.currentTarget),fieldSet=target.closest(".add-member-wrapper"),fieldSet.remove(),lastActionButton=$el.find(".add-member-wrapper fieldset:last > a"),lastActionButton.hasClass("icon-delete delete-fieldset")?lastActionButton.removeClass("icon-delete delete-fieldset").addClass("icon-plus add-fieldset"):void 0}),$el.on("click",".add-fieldset",function(event){var fieldSet,newFieldSet,target;return event.preventDefault(),target=angular.element(event.currentTarget),fieldSet=target.closest(".add-member-wrapper"),target.removeClass("icon-plus add-fieldset").addClass("icon-delete delete-fieldset"),newFieldSet=createFieldSet(!1),fieldSet.after(newFieldSet),$scope.$digest(),$el.find(".add-member-wrapper").length===MAX_MEMBERSHIP_FIELDSETS?$el.find(".add-member-wrapper fieldset:last > a").removeClass("icon-plus add-fieldset").addClass("icon-delete delete-fieldset"):void 0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,form,invitation_extra_text,invitations,memberWrappers,onError,onSuccess,promise;return event.preventDefault(),currentLoading=$loading().target(submitButton).start(),onSuccess=function(data){return currentLoading.finish(),lightboxService.close($el),$confirm.notify("success"),$rootScope.$broadcast("membersform:new:success")},onError=function(data){return currentLoading.finish(),lightboxService.close($el),$confirm.notify("error"),$rootScope.$broadcast("membersform:new:error")},form=$el.find("form").checksley(),form.destroy(),form.initialize(),form.validate()?(memberWrappers=$el.find("form .add-member-wrapper"),memberWrappers=_.filter(memberWrappers,function(mw){return angular.element(mw).find("input").hasClass("checksley-ok")}),invitations=_.map(memberWrappers,function(mw){var email,memberWrapper,role;return memberWrapper=angular.element(mw),email=memberWrapper.find("input"),role=memberWrapper.find("select"),{email:email.val(),role_id:role.val()}}),invitations.length?(invitation_extra_text=$el.find("form textarea").val(),promise=$rs.memberships.bulkCreateMemberships($scope.project.id,invitations,invitation_extra_text),promise.then(onSuccess,onError)):void 0):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgLbCreateMembers",["$tgResources","$rootScope","$tgConfirm","$tgLoading","lightboxService","$compile",CreateMembersDirective])}.call(this),function(){var MembershipsController,MembershipsDirective,MembershipsRowActionsDirective,MembershipsRowAdminCheckboxDirective,MembershipsRowAvatarDirective,MembershipsRowRoleSelectorDirective,bindMethods,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindMethods=this.taiga.bindMethods,module=angular.module("taigaAdmin"),MembershipsController=function(superClass){function MembershipsController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,analytics,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.analytics=analytics,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.project={},this.scope.filters={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.MEMBERSHIPS.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("membersform:new:success",function(_this){return function(){return _this.loadMembers(),_this.analytics.trackEvent("membership","create","create memberships on admin",1)}}(this))}return extend(MembershipsController,superClass),MembershipsController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAnalytics","tgAppMetaService","$translate"],MembershipsController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},MembershipsController.prototype.loadMembers=function(){var httpFilters;return httpFilters=this.getUrlFilters(),this.rs.memberships.list(this.scope.projectId,httpFilters).then(function(_this){return function(data){return _this.scope.memberships=_.filter(data.models,function(membership){return null===membership.user||membership.is_user_active}),_this.scope.page=data.current,_this.scope.count=data.count,_this.scope.paginatedBy=data.paginatedBy,data}}(this))},MembershipsController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadMembers()}}(this)),promise},MembershipsController.prototype.getUrlFilters=function(){var filters;return filters=_.pick(this.location.search(),"page"),filters.page||(filters.page=1),filters},MembershipsController.prototype.addNewMembers=function(){return this.rootscope.$broadcast("membersform:new")},MembershipsController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("MembershipsController",MembershipsController),MembershipsDirective=function($template,$compile){var link,linkPagination,template;return template=$template.get("admin/admin-membership-paginator.html",!0),linkPagination=function($scope,$el,$attrs,$ctrl){var $pagEl,afterCurrent,atBegin,atEnd,beforeCurrent,getNumPages,renderPagination;return afterCurrent=2,beforeCurrent=4,atBegin=2,atEnd=2,$pagEl=$el.find(".memberships-paginator"),getNumPages=function(){var numPages;return numPages=$scope.count/$scope.paginatedBy,numPages=parseInt(numPages,10)=numPages)return void $pagEl.hide();for(pages=[],options={},options.pages=pages,options.showPrevious=$scope.page>1,options.showNext=!($scope.page===numPages),cpage=$scope.page,i=j=1,ref=numPages;ref>=1?ref>=j:j>=ref;i=ref>=1?++j:--j)i===cpage+afterCurrent&&numPages>cpage+afterCurrent+atEnd?pages.push({classes:"dots",type:"dots"}):i===cpage-beforeCurrent&&cpage>atBegin+beforeCurrent?pages.push({classes:"dots",type:"dots"}):i>cpage+afterCurrent&&numPages-atEnd>=i||cpage-beforeCurrent>i&&i>atBegin||(i===cpage?pages.push({classes:"active",num:i,type:"page-active"}):pages.push({classes:"page",num:i,type:"page"}));return html=template(options),html=$compile(html)($scope),$pagEl.html(html),$pagEl.show()},$scope.$watch("memberships",function(value){return value?renderPagination():void 0}),$el.on("click",".memberships-paginator a.next",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page+1),$ctrl.loadMembers()})}),$el.on("click",".memberships-paginator a.previous",function(event){return event.preventDefault(),$scope.$apply(function(){return $ctrl.selectFilter("page",$scope.page-1),$ctrl.loadMembers()})}),$el.on("click",".memberships-paginator li.page > a",function(event){var pagenum,target;return event.preventDefault(),target=angular.element(event.currentTarget),pagenum=target.data("pagenum"),$scope.$apply(function(){return $ctrl.selectFilter("page",pagenum),$ctrl.loadMembers()})})},link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),linkPagination($scope,$el,$attrs,$ctrl),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgMemberships",["$tgTemplate","$compile",MembershipsDirective]),MembershipsRowAvatarDirective=function($log,$template,$translate){var link,template;return template=$template.get("admin/memberships-row-avatar.html",!0),link=function($scope,$el,$attrs){var member,pending,render;return pending=$translate.instant("ADMIN.MEMBERSHIP.STATUS_PENDING"),render=function(member){var ctx,html;return ctx={full_name:member.full_name?member.full_name:"",email:member.user_email?member.user_email:member.email,imgurl:member.photo?member.photo:"/"+window._version+"/images/unnamed.png",pending:member.is_user_active?"":pending},html=template(ctx),$el.html(html)},null==$attrs.tgMembershipsRowAvatar?$log.error("MembershipsRowAvatarDirective: the directive need a member"):(member=$scope.$eval($attrs.tgMembershipsRowAvatar),render(member),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowAvatar",["$log","$tgTemplate","$translate",MembershipsRowAvatarDirective]),MembershipsRowAdminCheckboxDirective=function($log,$repo,$confirm,$template,$compile){var link,template;return template=$template.get("admin/admin-memberships-row-checkbox.html",!0),link=function($scope,$el,$attrs){var html,member,render;return render=function(member){var ctx,html;return ctx={inputId:"is-admin-"+member.id},html=template(ctx),html=$compile(html)($scope),$el.html(html)},null==$attrs.tgMembershipsRowAdminCheckbox?$log.error("MembershipsRowAdminCheckboxDirective: the directive need a member"):(member=$scope.$eval($attrs.tgMembershipsRowAdminCheckbox),html=render(member),member.is_owner&&$el.find(":checkbox").prop("checked",!0),$el.on("click",":checkbox",function(_this){return function(event){var onError,onSuccess,target;return onSuccess=function(){return $confirm.notify("success")},onError=function(data){return member.revert(),$el.find(":checkbox").prop("checked",member.is_owner),$confirm.notify("error",data.is_owner[0])},target=angular.element(event.currentTarget),member.is_owner=target.prop("checked"),$repo.save(member).then(onSuccess,onError)}}(this)),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowAdminCheckbox",["$log","$tgRepo","$tgConfirm","$tgTemplate","$compile",MembershipsRowAdminCheckboxDirective]),MembershipsRowRoleSelectorDirective=function($log,$repo,$confirm){var link,template;return template=_.template(''),link=function($scope,$el,$attrs){var $ctrl,html,member,render;return render=function(member){var ctx,html;return ctx={roleList:$scope.project.roles,selectedRole:member.role},html=template(ctx),$el.html(html)},null==$attrs.tgMembershipsRowRoleSelector?$log.error("MembershipsRowRoleSelectorDirective: the directive need a member"):($ctrl=$el.controller(),member=$scope.$eval($attrs.tgMembershipsRowRoleSelector),html=render(member),$el.on("change","select",function(_this){return function(event){var newRole,onError,onSuccess,target;return onSuccess=function(){return $confirm.notify("success")},onError=function(){return $confirm.notify("error")},target=angular.element(event.currentTarget),newRole=parseInt(target.val(),10),member.role!==newRole?(member.role=newRole,$repo.save(member).then(onSuccess,onError)):void 0}}(this)),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowRoleSelector",["$log","$tgRepo","$tgConfirm",MembershipsRowRoleSelectorDirective]),MembershipsRowActionsDirective=function($log,$repo,$rs,$confirm,$compile,$translate){var activedTemplate,link,pendingTemplate;return activedTemplate='
\n
\n\n \n',pendingTemplate='\n\n\n \n',link=function($scope,$el,$attrs){var $ctrl,member,render;return render=function(member){var html;return html=member.user?$compile(activedTemplate)($scope):$compile(pendingTemplate)($scope),$el.html(html)},null==$attrs.tgMembershipsRowActions?$log.error("MembershipsRowActionsDirective: the directive need a member"):($ctrl=$el.controller(),member=$scope.$eval($attrs.tgMembershipsRowActions),render(member),$el.on("click",".js-resend",function(event){var onError,onSuccess;return event.preventDefault(),onSuccess=function(){var text;return text=$translate.instant("ADMIN.MEMBERSHIP.SUCCESS_SEND_INVITATION",{email:$scope.member.email}),$confirm.notify("success",text)},onError=function(){var text;return text=$translate.instant("ADMIM.MEMBERSHIP.ERROR_SEND_INVITATION"),$confirm.notify("error",text)},$rs.memberships.resendInvitation($scope.member.id).then(onSuccess,onError)}),$el.on("click",".delete",function(event){var defaultMsg,message,title;return event.preventDefault(),title=$translate.instant("ADMIN.MEMBERSHIP.DELETE_MEMBER"),defaultMsg=$translate.instant("ADMIN.MEMBERSHIP.DEFAULT_DELETE_MESSAGE",{email:member.email}),message=member.user?member.full_name:defaultMsg,$confirm.askOnDelete(title,message).then(function(askResponse){var onError,onSuccess;return onSuccess=function(_this){return function(){var text;return askResponse.finish(),$scope.page>1&&$scope.count-1<=$scope.paginatedBy&&$ctrl.selectFilter("page",$scope.page-1),$ctrl.loadMembers(),text=$translate.instant("ADMIN.MEMBERSHIP.SUCCESS_DELETE"),$confirm.notify("success",null,text)}}(this),onError=function(_this){return function(){var text;return askResponse.finish(!1),text=$translate.instant("ADMIN.MEMBERSHIP.ERROR_DELETE",{message:message}),$confirm.notify("error",null,text)}}(this),$repo.remove(member).then(onSuccess,onError)})}),$scope.$on("$destroy",function(){return $el.off()}))},{link:link}},module.directive("tgMembershipsRowActions",["$log","$tgRepo","$tgResources","$tgConfirm","$compile","$translate",MembershipsRowActionsDirective])}.call(this),function(){var AdminNavigationDirective,module;AdminNavigationDirective=function(){var link;return link=function($scope,$el,$attrs){var section;return section=$attrs.tgAdminNavigation,$el.find(".active").removeClass("active"),$el.find("#adminmenu-"+section+" a").addClass("active"),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaAdmin"),module.directive("tgAdminNavigation",AdminNavigationDirective)}.call(this),function(){var CsvExporterController,CsvExporterIssuesController,CsvExporterTasksController,CsvExporterUserstoriesController,CsvIssueDirective,CsvTaskDirective,CsvUsDirective,ProjectDefaultValuesDirective,ProjectExportDirective,ProjectLogoDirective,ProjectLogoModelDirective,ProjectModulesDirective,ProjectProfileController,ProjectProfileDirective,bindOnce,debounce,groupBy,joinStr,mixOf,module,taiga,toString,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaAdmin"),ProjectProfileController=function(superClass){function ProjectProfileController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_PROFILE.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:loaded",function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_PROFILE.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this))}return extend(ProjectProfileController,superClass),ProjectProfileController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectProfileController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.pointsList=_.sortBy(project.points,"order"),_this.scope.usStatusList=_.sortBy(project.us_statuses,"order"),_this.scope.taskStatusList=_.sortBy(project.task_statuses,"order"),_this.scope.prioritiesList=_.sortBy(project.priorities,"order"),_this.scope.severitiesList=_.sortBy(project.severities,"order"),_this.scope.issueTypesList=_.sortBy(project.issue_types,"order"),_this.scope.issueStatusList=_.sortBy(project.issue_statuses,"order"),_this.scope.$emit("project:loaded",project),project}}(this))},ProjectProfileController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject()},ProjectProfileController.prototype.openDeleteLightbox=function(){return this.rootscope.$broadcast("deletelightbox:new",this.scope.project)},ProjectProfileController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectProfileController",ProjectProfileController),ProjectProfileDirective=function($repo,$confirm,$loading,$navurls,$location,projectService,currentUserService){var link;return link=function($scope,$el,$attrs){var $ctrl,form,submit,submitButton;return $ctrl=$el.controller(),form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.save($scope.project),promise.then(function(){var newUrl;return currentLoading.finish(),$confirm.notify("success"),newUrl=$navurls.resolve("project-admin-project-profile-details",{project:$scope.project.slug}),$location.path(newUrl),$ctrl.loadInitialData(),projectService.fetchProject(),currentUserService.loadProjects()}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgProjectProfile",["$tgRepo","$tgConfirm","$tgLoading","$tgNavUrls","$tgLocation","tgProjectService","tgCurrentUserService",ProjectProfileDirective]),ProjectDefaultValuesDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.save($scope.project),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectDefaultValues",["$tgRepo","$tgConfirm","$tgLoading",ProjectDefaultValuesDirective]),ProjectModulesDirective=function($repo,$confirm,$loading,projectService){var link;return link=function($scope,$el,$attrs){var submit;return submit=function(_this){return function(){var currentLoading,form,promise,target;return form=$el.find("form").checksley(),form.validate()?(target=angular.element(".admin-functionalities .submit-button"),currentLoading=$loading().target(target).start(),promise=$repo.save($scope.project),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:loaded",$scope.project),projectService.fetchProject()}),promise.then(null,function(data){return currentLoading.finish(),$confirm.notify("error",data._error_message)})):void 0}}(this),$el.on("submit","form",function(event){return event.preventDefault(),submit()}),$el.on("click",".admin-functionalities a.button-green",function(event){return event.preventDefault(),submit()}),$scope.$watch("isVideoconferenceActivated",function(isVideoconferenceActivated){return isVideoconferenceActivated?$el.find(".videoconference-attributes").removeClass("hidden"):($el.find(".videoconference-attributes").addClass("hidden"),$scope.project.videoconferences=null,$scope.project.videoconferences_extra_data="")}),$scope.$watch("project",function(project){return null!=project.videoconferences?$scope.isVideoconferenceActivated=!0:$scope.isVideoconferenceActivated=!1})},{link:link}},module.directive("tgProjectModules",["$tgRepo","$tgConfirm","$tgLoading","tgProjectService",ProjectModulesDirective]),ProjectExportDirective=function($window,$rs,$confirm,$translate){var link;return link=function($scope,$el,$attrs){var asyn_message,buttonsEl,dump_ready_text,hideButtons,hideResult,hideSpinner,loading_msg,loading_title,resultEl,resultMessageEl,resultTitleEl,setAsyncMessage,setAsyncTitle,setLoadingMessage,setLoadingTitle,setSyncMessage,setSyncTitle,showButtons,showErrorMode,showExportResultAsyncMode,showExportResultSyncMode,showLoadingMode,showResult,showSpinner,spinnerEl,syn_message;return buttonsEl=$el.find(".admin-project-export-buttons"),showButtons=function(){return buttonsEl.removeClass("hidden")},hideButtons=function(){return buttonsEl.addClass("hidden")},resultEl=$el.find(".admin-project-export-result"),showResult=function(){return resultEl.removeClass("hidden")},hideResult=function(){return resultEl.addClass("hidden")},spinnerEl=$el.find(".spin"),showSpinner=function(){return spinnerEl.removeClass("hidden")},hideSpinner=function(){return spinnerEl.addClass("hidden")},resultTitleEl=$el.find(".result-title"),loading_title=$translate.instant("ADMIN.PROJECT_EXPORT.LOADING_TITLE"),loading_msg=$translate.instant("ADMIN.PROJECT_EXPORT.LOADING_MESSAGE"),dump_ready_text=function(){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.DUMP_READY"))},asyn_message=function(){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.ASYNC_MESSAGE"))},syn_message=function(url){return resultTitleEl.html($translate.instant("ADMIN.PROJECT_EXPORT.SYNC_MESSAGE",{url:url}))},setLoadingTitle=function(){return resultTitleEl.html(loading_title)},setAsyncTitle=function(){return resultTitleEl.html(loading_msg)},setSyncTitle=function(){return resultTitleEl.html(dump_ready_text)},resultMessageEl=$el.find(".result-message "),setLoadingMessage=function(){return resultMessageEl.html(loading_msg)},setAsyncMessage=function(){return resultMessageEl.html(asyn_message)},setSyncMessage=function(url){return resultMessageEl.html(syn_message(url))},showLoadingMode=function(){return showSpinner(),setLoadingTitle(),setLoadingMessage(),hideButtons(),showResult()},showExportResultAsyncMode=function(){return hideSpinner(),setAsyncTitle(),setAsyncMessage()},showExportResultSyncMode=function(url){return hideSpinner(),setSyncTitle(),setSyncMessage(url)},showErrorMode=function(){return hideSpinner(),hideResult(),showButtons()},$el.on("click","a.button-export",debounce(2e3,function(_this){return function(event){var onError,onSuccess;return event.preventDefault(),onSuccess=function(result){var dumpUrl;return 202===result.status?showExportResultAsyncMode():(dumpUrl=result.data.url,showExportResultSyncMode(dumpUrl),$window.open(dumpUrl,"_blank"))},onError=function(result){var errorMsg,ref;return showErrorMode(),errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR"),429===result.status?errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR_BUSY"):(null!=(ref=result.data)?ref._error_message:void 0)&&(errorMsg=$translate.instant("ADMIN.PROJECT_EXPORT.ERROR_BUSY",{message:result.data._error_message})),$confirm.notify("error",errorMsg)},showLoadingMode(),$rs.projects["export"]($scope.projectId).then(onSuccess,onError)}}(this)))},{link:link}},module.directive("tgProjectExport",["$window","$tgResources","$tgConfirm","$translate",ProjectExportDirective]),CsvExporterController=function(superClass){function CsvExporterController(scope,rootscope,urls,confirm,rs,translate){this.scope=scope,this.rootscope=rootscope,this.urls=urls,this.confirm=confirm,this.rs=rs,this.translate=translate,this._generateUuid=bind(this._generateUuid,this),this.setCsvUuid=bind(this.setCsvUuid,this), +this.rootscope.$on("project:loaded",this.setCsvUuid),this.scope.$watch("csvUuid",function(_this){return function(value){return value?_this.scope.csvUrl=_this.urls.resolveAbsolute(_this.type+"-csv",value):_this.scope.csvUrl=""}}(this))}return extend(CsvExporterController,superClass),CsvExporterController.$inject=["$scope","$rootScope","$tgUrls","$tgConfirm","$tgResources","$translate"],CsvExporterController.prototype.setCsvUuid=function(){return this.scope.csvUuid=this.scope.project[this.type+"_csv_uuid"]},CsvExporterController.prototype._generateUuid=function(response){var promise;return null==response&&(response=null),promise=this.rs.projects["regenerate_"+this.type+"_csv_uuid"](this.scope.projectId),promise.then(function(_this){return function(data){var ref;return _this.scope.csvUuid=null!=(ref=data.data)?ref.uuid:void 0}}(this)),promise.then(null,function(_this){return function(){return _this.confirm.notify("error")}}(this)),promise["finally"](function(){return response?response.finish():void 0}),promise},CsvExporterController.prototype.regenerateUuid=function(){var subtitle,title;return this.scope.csvUuid?(title=this.translate.instant("ADMIN.REPORTS.REGENERATE_TITLE"),subtitle=this.translate.instant("ADMIN.REPORTS.REGENERATE_SUBTITLE"),this.confirm.ask(title,subtitle).then(this._generateUuid)):this._generateUuid()},CsvExporterController}(taiga.Controller),CsvExporterUserstoriesController=function(superClass){function CsvExporterUserstoriesController(){return CsvExporterUserstoriesController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterUserstoriesController,superClass),CsvExporterUserstoriesController.prototype.type="userstories",CsvExporterUserstoriesController}(CsvExporterController),CsvExporterTasksController=function(superClass){function CsvExporterTasksController(){return CsvExporterTasksController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterTasksController,superClass),CsvExporterTasksController.prototype.type="tasks",CsvExporterTasksController}(CsvExporterController),CsvExporterIssuesController=function(superClass){function CsvExporterIssuesController(){return CsvExporterIssuesController.__super__.constructor.apply(this,arguments)}return extend(CsvExporterIssuesController,superClass),CsvExporterIssuesController.prototype.type="issues",CsvExporterIssuesController}(CsvExporterController),module.controller("CsvExporterUserstoriesController",CsvExporterUserstoriesController),module.controller("CsvExporterTasksController",CsvExporterTasksController),module.controller("CsvExporterIssuesController",CsvExporterIssuesController),CsvUsDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_US"},{controller:"CsvExporterUserstoriesController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvUs",["$translate",CsvUsDirective]),CsvTaskDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_TASK"},{controller:"CsvExporterTasksController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvTask",["$translate",CsvTaskDirective]),CsvIssueDirective=function($translate){var link;return link=function($scope){return $scope.sectionTitle="ADMIN.CSV.SECTION_TITLE_ISSUE"},{controller:"CsvExporterIssuesController",controllerAs:"ctrl",templateUrl:"admin/project-csv.html",link:link,scope:!0}},module.directive("tgCsvIssue",["$translate",CsvIssueDirective]),ProjectLogoDirective=function($auth,$model,$rs,$confirm){var link;return link=function($scope,$el,$attrs){var onError,onSuccess,showSizeInfo;return showSizeInfo=function(){return $el.find(".size-info").addClass("active")},onSuccess=function(response){var project;return project=$model.make_model("projects",response.data),$scope.project=project,$el.find(".loading-overlay").removeClass("active"),$confirm.notify("success")},onError=function(response){return 413===response.status&&showSizeInfo(),$el.find(".loading-overlay").removeClass("active"),$confirm.notify("error",response.data._error_message)},$el.on("click",".js-change-logo",function(){return $el.find("#logo-field").click()}),$el.on("change","#logo-field",function(event){return $scope.logoAttachment?($el.find(".loading-overlay").addClass("active"),$rs.projects.changeLogo($scope.project.id,$scope.logoAttachment).then(onSuccess,onError)):void 0}),$el.on("click","a.js-use-default-logo",function(event){return $el.find(".loading-overlay").addClass("active"),$rs.projects.removeLogo($scope.project.id).then(onSuccess,onError)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectLogo",["$tgAuth","$tgModel","$tgResources","$tgConfirm",ProjectLogoDirective]),ProjectLogoModelDirective=function($parse){var link;return link=function($scope,$el,$attrs){var model,modelSetter;return model=$parse($attrs.tgProjectLogoModel),modelSetter=model.assign,$el.bind("change",function(){return $scope.$apply(function(){return modelSetter($scope,$el[0].files[0])})})},{link:link}},module.directive("tgProjectLogoModel",["$parse",ProjectLogoModelDirective])}.call(this),function(){var ColorSelectionDirective,DATE_TYPE,MULTILINE_TYPE,ProjectCustomAttributesController,ProjectCustomAttributesDirective,ProjectValuesController,ProjectValuesDirective,ProjectValuesSectionController,TEXT_TYPE,TYPE_CHOICES,bindOnce,debounce,groupBy,joinStr,mixOf,module,taiga,toString,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,bind=function(fn,me){return function(){return fn.apply(me,arguments)}};taiga=this.taiga,mixOf=this.taiga.mixOf,trim=this.taiga.trim,toString=this.taiga.toString,joinStr=this.taiga.joinStr,groupBy=this.taiga.groupBy,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaAdmin"),ProjectValuesSectionController=function(superClass){function ProjectValuesSectionController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,sectionName,title;return sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.PROJECT_VALUES.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(ProjectValuesSectionController,superClass),ProjectValuesSectionController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectValuesSectionController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},ProjectValuesSectionController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject()},ProjectValuesSectionController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectValuesSectionController",ProjectValuesSectionController),ProjectValuesController=function(superClass){function ProjectValuesController(scope,rootscope,repo,confirm,rs){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.moveValue=bind(this.moveValue,this),this.loadValues=bind(this.loadValues,this),this.scope.$on("admin:project-values:move",this.moveValue),this.rootscope.$on("project:loaded",this.loadValues)}return extend(ProjectValuesController,superClass),ProjectValuesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources"],ProjectValuesController.prototype.loadValues=function(){return this.rs[this.scope.resource].listValues(this.scope.projectId,this.scope.type).then(function(_this){return function(values){return _this.scope.values=values,_this.scope.maxValueOrder=_.max(values,"order").order,values}}(this))},ProjectValuesController.prototype.moveValue=function(ctx,itemValue,itemIndex){var r,values;return values=this.scope.values,r=values.indexOf(itemValue),values.splice(r,1),values.splice(itemIndex,0,itemValue),_.each(values,function(value,index){return value.order=index}),this.repo.saveAll(values)},ProjectValuesController}(taiga.Controller),module.controller("ProjectValuesController",ProjectValuesController),ProjectValuesDirective=function($log,$repo,$confirm,$location,animationFrame,$translate,$rootscope){var link,linkDragAndDrop,linkValue;return linkDragAndDrop=function($scope,$el,$attrs){var itemEl,newParentScope,oldParentScope,tdom;return oldParentScope=null,newParentScope=null,itemEl=null,tdom=$el.find(".sortable"),tdom.sortable({handle:".row.table-main.visualization",dropOnEmpty:!0,connectWith:".project-values-body",revert:400,axis:"y"}),tdom.on("sortstop",function(event,ui){var itemIndex,itemValue;return itemEl=ui.item,itemValue=itemEl.scope().value,itemIndex=itemEl.index(),$scope.$broadcast("admin:project-values:move",itemValue,itemIndex)}),$scope.$on("$destroy",function(){return $el.off()})},linkValue=function($scope,$el,$attrs){var $ctrl,cancel,goToBottomList,initializeNewValue,initializeTextTranslations,objName,saveNewValue,saveValue,valueType;return $ctrl=$el.controller(),valueType=$attrs.type,objName=$attrs.objname,initializeNewValue=function(){return $scope.newValue={name:"",is_closed:!1,is_archived:!1}},initializeTextTranslations=function(){return $scope.addNewElementText=$translate.instant("ADMIN.PROJECT_VALUES_"+objName.toUpperCase()+".ACTION_ADD")},initializeNewValue(),initializeTextTranslations(),$rootscope.$on("$translateChangeEnd",function(){return $scope.$evalAsync(initializeTextTranslations)}),goToBottomList=function(_this){return function(focus){var table;return null==focus&&(focus=!1),table=$el.find(".table-main"),$(document.body).scrollTop(table.offset().top+table.height()),focus?$el.find(".new-value input:visible").first().focus():void 0}}(this),saveValue=function(target){var form,formEl,promise,value;return formEl=target.parents("form"),form=formEl.checksley(),form.validate()?(value=formEl.scope().value,promise=$repo.save(value),promise.then(function(_this){return function(){var row;return row=target.parents(".row.table-main"),row.addClass("hidden"),row.siblings(".visualization").removeClass("hidden")}}(this)),promise.then(null,function(data){return form.setErrors(data)})):void 0},saveNewValue=function(target){var form,formEl,promise;return formEl=target.parents("form"),form=formEl.checksley(),form.validate()?($scope.newValue.project=$scope.project.id,$scope.newValue.order=$scope.maxValueOrder?$scope.maxValueOrder+1:1,promise=$repo.create(valueType,$scope.newValue),promise.then(function(_this){return function(data){return target.addClass("hidden"),$scope.values.push(data),$scope.maxValueOrder=data.order,initializeNewValue()}}(this)),promise.then(null,function(data){return form.setErrors(data)})):void 0},cancel=function(target){var formEl,row,value;return row=target.parents(".row.table-main"),formEl=target.parents("form"),value=formEl.scope().value,$scope.$apply(function(){return row.addClass("hidden"),value.revert(),row.siblings(".visualization").removeClass("hidden")})},$el.on("click",".show-add-new",function(event){return event.preventDefault(),$el.find(".new-value").removeClass("hidden"),goToBottomList(!0)}),$el.on("click",".add-new",debounce(2e3,function(event){var target;return event.preventDefault(),target=$el.find(".new-value"),saveNewValue(target)})),$el.on("click",".delete-new",function(event){return event.preventDefault(),$el.find(".new-value").addClass("hidden"),initializeNewValue()}),$el.on("click",".edit-value",function(event){var editionRow,row,target;return event.preventDefault(),target=angular.element(event.currentTarget),row=target.parents(".row.table-main"),row.addClass("hidden"),editionRow=row.siblings(".edition"),editionRow.removeClass("hidden"),editionRow.find("input:visible").first().focus().select()}),$el.on("keyup",".edition input",function(event){var target;return 13===event.keyCode?(target=angular.element(event.currentTarget),saveValue(target)):27===event.keyCode?(target=angular.element(event.currentTarget),cancel(target)):void 0}),$el.on("keyup",".new-value input",function(event){var target;return 13===event.keyCode?(target=$el.find(".new-value"),saveNewValue(target)):27===event.keyCode?($el.find(".new-value").addClass("hidden"),initializeNewValue()):void 0}),$el.on("click",".save",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),saveValue(target)}),$el.on("click",".cancel",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),cancel(target)}),$el.on("click",".delete-value",function(event){var choices,formEl,subtitle,target,text,title,value;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.parents("form"),value=formEl.scope().value,choices={},_.each($scope.values,function(option){return value.id!==option.id?choices[option.id]=option.name:void 0}),subtitle=value.name,0===_.keys(choices).length?$confirm.error($translate.instant("ADMIN.PROJECT_VALUES.ERROR_DELETE_ALL")):(title=$translate.instant("ADMIN.COMMON.TITLE_ACTION_DELETE_VALUE"),text=$translate.instant("ADMIN.PROJECT_VALUES.REPLACEMENT"),$confirm.askChoice(title,subtitle,choices,text).then(function(response){var onError,onSucces;return onSucces=function(){return $ctrl.loadValues()["finally"](function(){return response.finish()})},onError=function(){return $confirm.notify("error")},$repo.remove(value,{moveTo:response.selected}).then(onSucces,onError)}))})},link=function($scope,$el,$attrs){return linkDragAndDrop($scope,$el,$attrs),linkValue($scope,$el,$attrs),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgProjectValues",["$log","$tgRepo","$tgConfirm","$tgLocation","animationFrame","$translate","$rootScope",ProjectValuesDirective]),ColorSelectionDirective=function(){var link;return link=function($scope,$el,$attrs,$model){var $ctrl;return $ctrl=$el.controller(),$scope.$watch($attrs.ngModel,function(element){return $scope.color=element.color}),$el.on("click",".current-color",function(event){var body,target;return event.preventDefault(),event.stopPropagation(),target=angular.element(event.currentTarget),$el.find(".select-color").hide(),target.siblings(".select-color").show(),body=angular.element("body"),body.on("click",function(_this){return function(event){return 0===angular.element(event.target).parent(".select-color").length?($el.find(".select-color").hide(),body.unbind("click")):void 0}}(this))}),$el.on("click",".select-color .color",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),$scope.$apply(function(){return $model.$modelValue.color=target.data("color")}),$el.find(".select-color").hide()}),$el.on("click",".select-color .selected-color",function(event){return event.preventDefault(),$scope.$apply(function(){return $model.$modelValue.color=$scope.color}),$el.find(".select-color").hide()}),$scope.$on("$destroy",function(){return $el.off()})},{link:link,require:"ngModel"}},module.directive("tgColorSelection",ColorSelectionDirective),TEXT_TYPE="text",MULTILINE_TYPE="multiline",DATE_TYPE="date",TYPE_CHOICES=[{key:TEXT_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT"},{key:MULTILINE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI"},{key:DATE_TYPE,name:"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE"}],ProjectCustomAttributesController=function(superClass){function ProjectCustomAttributesController(scope,rootscope,repo,rs,params,q,location,navUrls,appMetaService,translate){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this.moveCustomAttributes=bind(this.moveCustomAttributes,this),this.deleteCustomAttribute=bind(this.deleteCustomAttribute,this),this.saveCustomAttribute=bind(this.saveCustomAttribute,this),this.createCustomAttribute=bind(this.createCustomAttribute,this),this.loadCustomAttributes=bind(this.loadCustomAttributes,this),this.scope.TYPE_CHOICES=TYPE_CHOICES,this.scope.project={},this.rootscope.$on("project:loaded",function(_this){return function(){var description,sectionName,title;return _this.loadCustomAttributes(),sectionName=_this.translate.instant(_this.scope.sectionName),title=_this.translate.instant("ADMIN.CUSTOM_ATTRIBUTES.PAGE_TITLE",{sectionName:sectionName,projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this))}return extend(ProjectCustomAttributesController,superClass),ProjectCustomAttributesController.$inject=["$scope","$rootScope","$tgRepo","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],ProjectCustomAttributesController.prototype.loadCustomAttributes=function(){return this.rs.customAttributes[this.scope.type].list(this.scope.projectId).then(function(_this){return function(customAttributes){return _this.scope.customAttributes=customAttributes,_this.scope.maxOrder=_.max(customAttributes,"order").order,customAttributes}}(this))},ProjectCustomAttributesController.prototype.createCustomAttribute=function(attrValues){return this.repo.create("custom-attributes/"+this.scope.type,attrValues)},ProjectCustomAttributesController.prototype.saveCustomAttribute=function(attrModel){return this.repo.save(attrModel)},ProjectCustomAttributesController.prototype.deleteCustomAttribute=function(attrModel){return this.repo.remove(attrModel)},ProjectCustomAttributesController.prototype.moveCustomAttributes=function(attrModel,newIndex){var customAttributes,r;return customAttributes=this.scope.customAttributes,r=customAttributes.indexOf(attrModel),customAttributes.splice(r,1),customAttributes.splice(newIndex,0,attrModel),_.each(customAttributes,function(val,idx){return val.order=idx}),this.repo.saveAll(customAttributes)},ProjectCustomAttributesController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("ProjectCustomAttributesController",ProjectCustomAttributesController),ProjectCustomAttributesDirective=function($log,$confirm,animationFrame,$translate){var link;return link=function($scope,$el,$attrs){var $ctrl,cancelCreate,cancelUpdate,create,deleteCustomAttribute,hideAddButton,hideCancelButton,hideCreateForm,hideEditForm,resetNewAttr,revertChangesInCustomAttribute,showAddButton,showCancelButton,showCreateForm,showEditForm,sortableEl,update;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()}),sortableEl=$el.find(".js-sortable"),sortableEl.sortable({handle:".js-view-custom-field",dropOnEmpty:!0,revert:400,axis:"y"}),sortableEl.on("sortstop",function(event,ui){var itemAttr,itemEl,itemIndex;return itemEl=ui.item,itemAttr=itemEl.scope().attr,itemIndex=itemEl.index(),$ctrl.moveCustomAttributes(itemAttr,itemIndex)}),showCreateForm=function(){return $el.find(".js-new-custom-field").removeClass("hidden"),$el.find(".js-new-custom-field input:visible").first().focus()},hideCreateForm=function(){return $el.find(".js-new-custom-field").addClass("hidden")},showAddButton=function(){return $el.find(".js-add-custom-field-button").removeClass("hidden")},hideAddButton=function(){return $el.find(".js-add-custom-field-button").addClass("hidden")},showCancelButton=function(){return $el.find(".js-cancel-new-custom-field-button").removeClass("hidden")},hideCancelButton=function(){return $el.find(".js-cancel-new-custom-field-button").addClass("hidden")},resetNewAttr=function(){return $scope.newAttr={}},create=function(formEl){var attr,form,onError,onSucces;return form=formEl.checksley(),form.validate()?(onSucces=function(_this){return function(){return $ctrl.loadCustomAttributes(),hideCreateForm(),resetNewAttr(),$confirm.notify("success")}}(this),onError=function(_this){return function(data){return form.setErrors(data)}}(this),attr=$scope.newAttr,attr.project=$scope.projectId,attr.order=$scope.maxOrder?$scope.maxOrder+1:1,$ctrl.createCustomAttribute(attr).then(onSucces,onError)):void 0},cancelCreate=function(){return hideCreateForm(),resetNewAttr()},$scope.$watch("customAttributes",function(customAttributes){return customAttributes?0===customAttributes.length?(hideCancelButton(),hideAddButton(),showCreateForm()):(hideCreateForm(),showAddButton(),showCancelButton()):void 0}),$el.on("click",".js-add-custom-field-button",function(event){return event.preventDefault(),showCreateForm()}),$el.on("click",".js-create-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),create(formEl)})),$el.on("click",".js-cancel-new-custom-field-button",function(event){return event.preventDefault(),cancelCreate()}),$el.on("keyup",".js-new-custom-field input",function(event){var formEl,target;return 13===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),create(formEl)):27===event.keyCode?cancelCreate():void 0}),showEditForm=function(formEl){return formEl.find(".js-view-custom-field").addClass("hidden"),formEl.find(".js-edit-custom-field").removeClass("hidden"),formEl.find(".js-edit-custom-field input:visible").first().focus().select()},hideEditForm=function(formEl){return formEl.find(".js-edit-custom-field").addClass("hidden"),formEl.find(".js-view-custom-field").removeClass("hidden")},revertChangesInCustomAttribute=function(formEl){return $scope.$apply(function(){return formEl.scope().attr.revert()})},update=function(formEl){var attr,form,onError,onSucces;return form=formEl.checksley(),form.validate()?(onSucces=function(_this){return function(){return $ctrl.loadCustomAttributes(),hideEditForm(formEl),$confirm.notify("success")}}(this),onError=function(_this){return function(data){return form.setErrors(data)}}(this),attr=formEl.scope().attr,$ctrl.saveCustomAttribute(attr).then(onSucces,onError)):void 0},cancelUpdate=function(formEl){return hideEditForm(formEl),revertChangesInCustomAttribute(formEl)},$el.on("click",".js-edit-custom-field-button",function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),showEditForm(formEl)}),$el.on("click",".js-update-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),update(formEl)})),$el.on("click",".js-cancel-edit-custom-field-button",function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),cancelUpdate(formEl)}),$el.on("keyup",".js-edit-custom-field input",function(event){var formEl,target;return 13===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),update(formEl)):27===event.keyCode?(target=angular.element(event.currentTarget),formEl=target.closest("form"),cancelUpdate(formEl)):void 0}),deleteCustomAttribute=function(formEl){var attr,message,text,title;return attr=formEl.scope().attr,message=attr.name,title=$translate.instant("COMMON.CUSTOM_ATTRIBUTES.DELETE"),text=$translate.instant("COMMON.CUSTOM_ATTRIBUTES.CONFIRM_DELETE"),$confirm.ask(title,text,message).then(function(response){var onError,onSucces;return onSucces=function(){return $ctrl.loadCustomAttributes()["finally"](function(){return response.finish()})},onError=function(){return $confirm.notify("error",null,"We have not been able to delete '"+message+"'.")},$ctrl.deleteCustomAttribute(attr).then(onSucces,onError)})},$el.on("click",".js-delete-custom-field-button",debounce(2e3,function(event){var formEl,target;return event.preventDefault(),target=angular.element(event.currentTarget),formEl=target.closest("form"),deleteCustomAttribute(formEl)}))},{link:link}},module.directive("tgProjectCustomAttributes",["$log","$tgConfirm","animationFrame","$translate",ProjectCustomAttributesDirective])}.call(this),function(){var EditRoleDirective,NewRoleDirective,RolePermissionsDirective,RolesController,RolesDirective,bindMethods,bindOnce,debounce,mixOf,module,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};taiga=this.taiga,mixOf=this.taiga.mixOf,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,bindMethods=this.taiga.bindMethods,module=angular.module("taigaAdmin"),RolesController=function(superClass){function RolesController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,this._disableComputable=bind(this._disableComputable,this),this._enableComputable=bind(this._enableComputable,this),bindMethods(this),this.scope.sectionName="ADMIN.MENU.PERMISSIONS",this.scope.project={},this.scope.anyComputableRole=!0,promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.ROLES.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(RolesController,superClass),RolesController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],RolesController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.anyComputableRole=_.some(_.map(project.roles,function(point){return point.computable})),project}}(this))},RolesController.prototype.loadRoles=function(){return this.rs.roles.list(this.scope.projectId).then(function(_this){return function(roles){var public_permission;return roles=roles.map(function(role){return role.external_user=!1,role}),public_permission={name:_this.translate.instant("ADMIN.ROLES.EXTERNAL_USER"),permissions:_this.scope.project.public_permissions,external_user:!0},roles.push(public_permission),_this.scope.roles=roles,_this.scope.role=_this.scope.roles[0],roles}}(this))},RolesController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadRoles()}}(this)),promise},RolesController.prototype.setRole=function(role){return this.scope.role=role,this.scope.$broadcast("role:changed",this.scope.role)},RolesController.prototype["delete"]=function(){var choices,i,len,ref,replacement,role,subtitle,title,warning;for(choices={},ref=this.scope.roles,i=0,len=ref.length;len>i;i++)role=ref[i],role.id!==this.scope.role.id&&(choices[role.id]=role.name);return 0===_.keys(choices).length?this.confirm.error(this.translate.instant("ADMIN.ROLES.ERROR_DELETE_ALL")):(title=this.translate.instant("ADMIN.ROLES.TITLE_DELETE_ROLE"),subtitle=this.scope.role.name,replacement=this.translate.instant("ADMIN.ROLES.REPLACEMENT_ROLE"),warning=this.translate.instant("ADMIN.ROLES.WARNING_DELETE_ROLE"),this.confirm.askChoice(title,subtitle,choices,replacement,warning).then(function(_this){return function(response){var onError,onSuccess;return onSuccess=function(){return _this.loadProject(),_this.loadRoles()["finally"](function(){return response.finish()})},onError=function(){return _this.confirm.notify("error")},_this.repo.remove(_this.scope.role,{moveTo:response.selected}).then(onSuccess,onError)}}(this)))},RolesController.prototype._enableComputable=function(){var onError,onSuccess;return onSuccess=function(_this){return function(){return _this.confirm.notify("success"),_this.loadProject()}}(this),onError=function(_this){return function(){return _this.confirm.notify("error"),_this.scope.role.revert()}}(this),this.repo.save(this.scope.role).then(onSuccess,onError)},RolesController.prototype._disableComputable=function(){var askOnError,askOnSuccess,message,subtitle,title;return askOnSuccess=function(_this){return function(response){var onError,onSuccess;return onSuccess=function(){return response.finish(),_this.confirm.notify("success"),_this.loadProject()},onError=function(){return response.finish(),_this.confirm.notify("error"),_this.scope.role.revert()},_this.repo.save(_this.scope.role).then(onSuccess,onError)}}(this),askOnError=function(_this){return function(response){return _this.scope.role.revert()}}(this),title=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_TITLE"),subtitle=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_SUBTITLE",{roleName:this.scope.role.name}),message=this.translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_MESSAGE"),this.confirm.ask(title,subtitle,message).then(askOnSuccess,askOnError)},RolesController.prototype.toggleComputable=debounce(2e3,function(){return this.scope.role.computable?this._enableComputable():this._disableComputable()}),RolesController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("RolesController",RolesController),EditRoleDirective=function($repo,$confirm){var link;return link=function($scope,$el,$attrs){var submit,toggleView;return toggleView=function(){return $el.find(".total").toggle(),$el.find(".edit-role").toggle()},submit=function(){var promise;return $scope.role.name=$el.find("input").val(),promise=$repo.save($scope.role),promise.then(function(){return $confirm.notify("success")}),promise.then(null,function(data){return $confirm.notify("error")}),toggleView()},$el.on("click","a.icon-edit",function(){return toggleView(),$el.find("input").focus(),$el.find("input").val($scope.role.name)}),$el.on("click","a.save",submit),$el.on("keyup","input",function(event){return 13===event.keyCode?submit():27===event.keyCode?toggleView():void 0}),$scope.$on("role:changed",function(){return $el.find(".edit-role").is(":visible")?toggleView():void 0}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgEditRole",["$tgRepo","$tgConfirm",EditRoleDirective]),RolesDirective=function(){var link;return link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgRoles",RolesDirective),NewRoleDirective=function($tgrepo,$confirm){var DEFAULT_PERMISSIONS,link;return DEFAULT_PERMISSIONS=["view_project","view_milestones","view_us","view_tasks","view_issues"], +link=function($scope,$el,$attrs){var $ctrl;return $ctrl=$el.controller(),$scope.$on("$destroy",function(){return $el.off()}),$el.on("click","a.add-button",function(event){return event.preventDefault(),$el.find(".new").removeClass("hidden"),$el.find(".new").focus(),$el.find(".add-button").hide()}),$el.on("keyup",".new",function(event){var newRole,onError,onSuccess,target;return event.preventDefault(),13===event.keyCode?(target=angular.element(event.currentTarget),newRole={project:$scope.projectId,name:target.val(),permissions:DEFAULT_PERMISSIONS,order:_.max($scope.roles,function(r){return r.order}).order+1,computable:!1},$el.find(".new").addClass("hidden"),$el.find(".new").val(""),onSuccess=function(role){var insertPosition;return insertPosition=$scope.roles.length-1,$scope.roles.splice(insertPosition,0,role),$ctrl.setRole(role),$el.find(".add-button").show(),$ctrl.loadProject()},onError=function(){return $confirm.notify("error")},$tgrepo.create("roles",newRole).then(onSuccess,onError)):27===event.keyCode?(target=angular.element(event.currentTarget),$el.find(".new").addClass("hidden"),$el.find(".new").val(""),$el.find(".add-button").show()):void 0})},{link:link}},module.directive("tgNewRole",["$tgRepo","$tgConfirm",NewRoleDirective]),RolePermissionsDirective=function($rootscope,$repo,$confirm,$compile){var baseTemplate,categoryTemplate,link,resumeTemplate;return resumeTemplate=_.template('
\n
\n
<%- category.activePermissions %>/<%- category.permissions.length %>
\n <% _.each(category.permissions, function(permission) { %>\n
\n <% }) %>\n
\n
'),categoryTemplate=_.template('
\n
\n
\n
\n
\n <% _.each(category.permissions, function(permission) { %>\n
\n \n
\n disabled="disabled" <% } %>\n <% if(permission.active) { %> checked="checked" <% } %>/>\n
\n \n \n
\n
\n <% }) %>\n
\n
\n
'),baseTemplate=_.template('
'),link=function($scope,$el,$attrs){var $ctrl,generateCategoriesFromRole,renderCategory,renderPermissions,renderResume;return $ctrl=$el.controller(),generateCategoriesFromRole=function(role){var categories,isPermissionEditable,issuePermissions,milestonePermissions,setActivePermissions,setActivePermissionsPerCategory,taskPermissions,userStoryPermissions,wikiPermissions;return setActivePermissions=function(permissions){return _.map(permissions,function(x){var ref;return _.extend({},x,{active:(ref=x.key,indexOf.call(role.permissions,ref)>=0)})})},isPermissionEditable=function(permission,role,project){return role.external_user&&!project.is_private&&0===permission.key.indexOf("view_")?!1:!0},setActivePermissionsPerCategory=function(category){return _.map(category,function(cat){return cat.permissions=cat.permissions.map(function(permission){return permission.editable=isPermissionEditable(permission,role,$scope.project),permission}),_.extend({},cat,{activePermissions:_.filter(cat.permissions,"active").length})})},categories=[],milestonePermissions=[{key:"view_milestones",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.VIEW_SPRINTS"},{key:"add_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.ADD_SPRINTS"},{key:"modify_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.MODIFY_SPRINTS"},{key:"delete_milestone",name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.DELETE_SPRINTS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.SPRINTS.NAME",permissions:setActivePermissions(milestonePermissions)}),userStoryPermissions=[{key:"view_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.VIEW_USER_STORIES"},{key:"add_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.ADD_USER_STORIES"},{key:"modify_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.MODIFY_USER_STORIES"},{key:"delete_us",name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.DELETE_USER_STORIES"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.NAME",permissions:setActivePermissions(userStoryPermissions)}),taskPermissions=[{key:"view_tasks",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.VIEW_TASKS"},{key:"add_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.ADD_TASKS"},{key:"modify_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.MODIFY_TASKS"},{key:"delete_task",name:"COMMON.PERMISIONS_CATEGORIES.TASKS.DELETE_TASKS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.TASKS.NAME",permissions:setActivePermissions(taskPermissions)}),issuePermissions=[{key:"view_issues",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.VIEW_ISSUES"},{key:"add_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.ADD_ISSUES"},{key:"modify_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.MODIFY_ISSUES"},{key:"delete_issue",name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.DELETE_ISSUES"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.ISSUES.NAME",permissions:setActivePermissions(issuePermissions)}),wikiPermissions=[{key:"view_wiki_pages",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_PAGES"},{key:"add_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_PAGES"},{key:"modify_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.MODIFY_WIKI_PAGES"},{key:"delete_wiki_page",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_PAGES"},{key:"view_wiki_links",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_LINKS"},{key:"add_wiki_link",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_LINKS"},{key:"delete_wiki_link",name:"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_LINKS"}],categories.push({name:"COMMON.PERMISIONS_CATEGORIES.WIKI.NAME",permissions:setActivePermissions(wikiPermissions)}),setActivePermissionsPerCategory(categories)},renderResume=function(element,category){return element.find(".resume").html($compile(resumeTemplate({category:category}))($scope))},renderCategory=function(category,index){var html;return html=categoryTemplate({category:category,index:index}),html=angular.element(html),renderResume(html,category),$compile(html)($scope)},renderPermissions=function(){var html;return $el.off(),html=baseTemplate(),_.each(generateCategoriesFromRole($scope.role),function(category,index){return html=angular.element(html).append(renderCategory(category,index))}),$el.html(html),$el.on("click",".resume",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),target.next().toggleClass("open")}),$el.on("change",".category-item input",function(event){var getActivePermissions,onError,onSuccess,target;return getActivePermissions=function(){var activePermissions;return activePermissions=_.filter($el.find(".category-item input"),function(t){return angular.element(t).is(":checked")}),activePermissions=_.sortBy(_.map(activePermissions,function(t){var permission;return permission=angular.element(t).parents(".category-item").data("id")})),activePermissions.length&&activePermissions.push("view_project"),activePermissions},target=angular.element(event.currentTarget),$scope.role.permissions=getActivePermissions(),onSuccess=function(){var categories,categoryId;return categories=generateCategoriesFromRole($scope.role),categoryId=target.parents(".category-config").data("id"),renderResume(target.parents(".category-config"),categories[categoryId]),$rootscope.$broadcast("projects:reload"),$confirm.notify("success"),$ctrl.loadProject()},onError=function(){return $confirm.notify("error"),target.prop("checked",!target.prop("checked")),$scope.role.permissions=getActivePermissions()},$scope.role.external_user?($scope.project.public_permissions=$scope.role.permissions,$scope.project.anon_permissions=$scope.role.permissions.filter(function(permission){return 0===permission.indexOf("view_")}),$repo.save($scope.project).then(onSuccess,onError)):$repo.save($scope.role).then(onSuccess,onError)})},$scope.$on("$destroy",function(){return $el.off()}),$scope.$on("role:changed",function(){return renderPermissions()}),bindOnce($scope,$attrs.ngModel,renderPermissions)},{link:link}},module.directive("tgRolePermissions",["$rootScope","$tgRepo","$tgConfirm","$compile",RolePermissionsDirective])}.call(this),function(){var BitbucketController,BitbucketWebhooksDirective,GithubController,GithubWebhooksDirective,GitlabController,GitlabWebhooksDirective,NewWebhookDirective,SelectInputText,ValidOriginIpsDirective,WebhookDirective,WebhooksController,bindMethods,debounce,mixOf,module,taiga,timeout,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindMethods=this.taiga.bindMethods,debounce=this.taiga.debounce,timeout=this.taiga.timeout,module=angular.module("taigaAdmin"),WebhooksController=function(superClass){function WebhooksController(scope,repo,rs,params,location,navUrls,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.location=location,this.navUrls=navUrls,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName="ADMIN.WEBHOOKS.SECTION_NAME",this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.WEBHOOKS.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("webhooks:reload",this.loadWebhooks)}return extend(WebhooksController,superClass),WebhooksController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","$tgLocation","$tgNavUrls","tgAppMetaService","$translate"],WebhooksController.prototype.loadWebhooks=function(){return this.rs.webhooks.list(this.scope.projectId).then(function(_this){return function(webhooks){return _this.scope.webhooks=webhooks}}(this))},WebhooksController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return project.i_am_owner||_this.location.path(_this.navUrls.resolve("permission-denied")),_this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},WebhooksController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadWebhooks()}}(this)),promise},WebhooksController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("WebhooksController",WebhooksController),WebhookDirective=function($rs,$repo,$confirm,$loading,$translate){var link;return link=function($scope,$el,$attrs){var cancel,openHistory,save,showEditMode,showVisualizationMode,updateLogs,updateShowHideHistoryText,webhook;return webhook=$scope.$eval($attrs.tgWebhook),updateLogs=function(){var prettyDate;return prettyDate=$translate.instant("ADMIN.WEBHOOKS.DATE"),$rs.webhooklogs.list(webhook.id).then(function(_this){return function(webhooklogs){var i,len,log,ref;for(i=0,len=webhooklogs.length;len>i;i++)log=webhooklogs[i],log.validStatus=200<=(ref=log.status)&&300>ref,log.prettySentHeaders=_.map(_.pairs(log.request_headers),function(arg){var header,value;return header=arg[0],value=arg[1],header+": "+value}).join("\n"),log.prettySentData=JSON.stringify(log.request_data),log.prettyDate=moment(log.created).format(prettyDate);return webhook.logs_counter=webhooklogs.length,webhook.logs=webhooklogs,updateShowHideHistoryText()}}(this))},updateShowHideHistoryText=function(){var historyElement,text,textElement,title;return textElement=$el.find(".toggle-history"),historyElement=textElement.parents(".single-webhook-wrapper").find(".webhooks-history"),historyElement.hasClass("open")?(text=$translate.instant("ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY"),title=$translate.instant("ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY_TITLE")):(text=$translate.instant("ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY"),title=$translate.instant("ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY_TITLE")),textElement.text(text),textElement.prop("title",title)},showVisualizationMode=function(){return $el.find(".edition-mode").addClass("hidden"),$el.find(".visualization-mode").removeClass("hidden")},showEditMode=function(){return $el.find(".visualization-mode").addClass("hidden"),$el.find(".edition-mode").removeClass("hidden")},openHistory=function(){return $el.find(".webhooks-history").addClass("open")},cancel=function(){return showVisualizationMode(),$scope.$apply(function(){return webhook.revert()})},save=debounce(2e3,function(target){var form,promise;return form=target.parents("form").checksley(),form.validate()?(promise=$repo.save(webhook),promise.then(function(_this){return function(){return showVisualizationMode()}}(this)),promise.then(null,function(data){return $confirm.notify("error"),form.setErrors(data)})):void 0}),$el.on("click",".test-webhook",function(){return openHistory(),$rs.webhooks.test(webhook.id).then(function(_this){return function(){return updateLogs()}}(this))}),$el.on("click",".edit-webhook",function(){return showEditMode()}),$el.on("click",".cancel-existing",function(){return cancel()}),$el.on("click",".edit-existing",function(event){var target;return event.preventDefault(),target=angular.element(event.currentTarget),save(target)}),$el.on("keyup",".edition-mode input",function(event){var target;return 13===event.keyCode?(target=angular.element(event.currentTarget),save(target)):27===event.keyCode?(target=angular.element(event.currentTarget),cancel(target)):void 0}),$el.on("click",".delete-webhook",function(){var message,title;return title=$translate.instant("ADMIN.WEBHOOKS.DELETE"),message=$translate.instant("ADMIN.WEBHOOKS.WEBHOOK_NAME",{name:webhook.name}),$confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSucces;return onSucces=function(){return askResponse.finish(),$scope.$emit("webhooks:reload")},onError=function(){return askResponse.finish(!1),$confirm.notify("error")},$repo.remove(webhook).then(onSucces,onError)}}(this))}),$el.on("click",".toggle-history",function(event){var target;return target=angular.element(event.currentTarget),null==webhook.logs||0===webhook.logs.length?updateLogs().then(function(){return timeout(0,function(){return $el.find(".webhooks-history").toggleClass("open"),updateShowHideHistoryText()})}):($el.find(".webhooks-history").toggleClass("open"),$scope.$apply(function(){return updateShowHideHistoryText()}))}),$el.on("click",".history-single",function(event){var target;return target=angular.element(event.currentTarget),target.toggleClass("history-single-open"),target.siblings(".history-single-response").toggleClass("open")}),$el.on("click",".resend-request",function(event){var log,target;return target=angular.element(event.currentTarget),log=target.data("log"),$rs.webhooklogs.resend(log).then(function(_this){return function(){return updateLogs()}}(this))})},{link:link}},module.directive("tgWebhook",["$tgResources","$tgRepo","$tgConfirm","$tgLoading","$translate",WebhookDirective]),NewWebhookDirective=function($rs,$repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var addWebhookDOMNode,formDOMNode,initializeNewValue,save,webhook;return webhook=$scope.$eval($attrs.tgWebhook),formDOMNode=$el.find(".new-webhook-form"),addWebhookDOMNode=$el.find(".add-webhook"),initializeNewValue=function(){return $scope.newValue={name:"",url:"",key:""}},initializeNewValue(),$scope.$watch("webhooks",function(webhooks){return null!=webhooks?0===webhooks.length?(formDOMNode.removeClass("hidden"),addWebhookDOMNode.addClass("hidden"),formDOMNode.find("input")[0].focus()):(formDOMNode.addClass("hidden"),addWebhookDOMNode.removeClass("hidden")):void 0}),save=debounce(2e3,function(){var form,promise;return form=formDOMNode.checksley(),form.validate()?($scope.newValue.project=$scope.project.id,promise=$repo.create("webhooks",$scope.newValue),promise.then(function(_this){return function(){return $scope.$emit("webhooks:reload"),initializeNewValue()}}(this)),promise.then(null,function(data){return $confirm.notify("error"),form.setErrors(data)})):void 0}),formDOMNode.on("click",".add-new",function(event){return event.preventDefault(),save()}),formDOMNode.on("keyup","input",function(event){return 13===event.keyCode?save():void 0}),formDOMNode.on("click",".cancel-new",function(event){return $scope.$apply(function(){return initializeNewValue()})}),addWebhookDOMNode.on("click",function(event){return formDOMNode.removeClass("hidden"),formDOMNode.find("input")[0].focus()})},{link:link}},module.directive("tgNewWebhook",["$tgResources","$tgRepo","$tgConfirm","$tgLoading",NewWebhookDirective]),GithubController=function(superClass){function GithubController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.GITHUB.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.GITHUB.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this))}return extend(GithubController,superClass),GithubController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],GithubController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"github").then(function(_this){return function(github){return _this.scope.github=github}}(this))},GithubController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},GithubController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},GithubController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("GithubController",GithubController),GitlabController=function(superClass){function GitlabController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.GITLAB.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.GITLAB.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:modules:reload",function(_this){return function(){return _this.loadModules()}}(this))}return extend(GitlabController,superClass),GitlabController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],GitlabController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"gitlab").then(function(_this){return function(gitlab){return _this.scope.gitlab=gitlab}}(this))},GitlabController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},GitlabController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},GitlabController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("GitlabController",GitlabController),BitbucketController=function(superClass){function BitbucketController(scope,repo,rs,params,appMetaService,translate){var promise;this.scope=scope,this.repo=repo,this.rs=rs,this.params=params,this.appMetaService=appMetaService,this.translate=translate,bindMethods(this),this.scope.sectionName=this.translate.instant("ADMIN.BITBUCKET.SECTION_NAME"),this.scope.project={},promise=this.loadInitialData(),promise.then(function(_this){return function(){var description,title;return title=_this.translate.instant("ADMIN.BITBUCKET.PAGE_TITLE",{projectName:_this.scope.project.name}),description=_this.scope.project.description,_this.appMetaService.setAll(title,description)}}(this)),promise.then(null,this.onInitialDataError.bind(this)),this.scope.$on("project:modules:reload",function(_this){return function(){return _this.loadModules()}}(this))}return extend(BitbucketController,superClass),BitbucketController.$inject=["$scope","$tgRepo","$tgResources","$routeParams","tgAppMetaService","$translate"],BitbucketController.prototype.loadModules=function(){return this.rs.modules.list(this.scope.projectId,"bitbucket").then(function(_this){return function(bitbucket){return _this.scope.bitbucket=bitbucket}}(this))},BitbucketController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),project}}(this))},BitbucketController.prototype.loadInitialData=function(){var promise;return promise=this.loadProject(),promise.then(function(_this){return function(){return _this.loadModules()}}(this)),promise},BitbucketController}(mixOf(taiga.Controller,taiga.PageMixin,taiga.FiltersMixin)),module.controller("BitbucketController",BitbucketController),SelectInputText=function(){var link;return link=function($scope,$el,$attrs){return $el.on("click",".select-input-content",function(){return $el.find("input").select(),$el.find(".help-copy").addClass("visible")})},{link:link}},module.directive("tgSelectInputText",SelectInputText),GithubWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.github,"github"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgGithubWebhooks",["$tgRepo","$tgConfirm","$tgLoading",GithubWebhooksDirective]),GitlabWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.gitlab,"gitlab"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:modules:reload")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgGitlabWebhooks",["$tgRepo","$tgConfirm","$tgLoading",GitlabWebhooksDirective]),BitbucketWebhooksDirective=function($repo,$confirm,$loading){var link;return link=function($scope,$el,$attrs){var form,submit,submitButton;return form=$el.find("form").checksley({onlyOneErrorElement:!0}),submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.saveAttribute($scope.bitbucket,"bitbucket"),promise.then(function(){return currentLoading.finish(),$confirm.notify("success"),$scope.$emit("project:modules:reload")}),promise.then(null,function(data){return currentLoading.finish(),form.setErrors(data),data._error_message?$confirm.notify("error",data._error_message):void 0})):void 0}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit)},{link:link}},module.directive("tgBitbucketWebhooks",["$tgRepo","$tgConfirm","$tgLoading",BitbucketWebhooksDirective]),ValidOriginIpsDirective=function(){var link;return link=function($scope,$el,$attrs,$ngModel){return $ngModel.$parsers.push(function(value){return value=$.trim(value),""===value?[]:value.split(",")})},{link:link,restrict:"EA",require:"ngModel"}},module.directive("tgValidOriginIps",ValidOriginIpsDirective)}.call(this),function(){var CreateProject,DeleteProjectDirective,bindOnce,debounce,module,taiga,timeout;taiga=this.taiga,bindOnce=this.taiga.bindOnce,timeout=this.taiga.timeout,debounce=this.taiga.debounce,module=angular.module("taigaProject"),CreateProject=function($rootscope,$repo,$confirm,$location,$navurls,$rs,$projectUrl,$loading,lightboxService,$cacheFactory,$translate,currentUserService){var directive,link;return link=function($scope,$el,attrs){var currentLoading,form,onErrorSubmit,onSuccessSubmit,openLightbox,submit,submitButton;return $scope.data={},$scope.templates=[],currentLoading=null,form=$el.find("form").checksley({onlyOneErrorElement:!0}),onSuccessSubmit=function(response){return $cacheFactory.get("$http").removeAll(),currentLoading.finish(),$rootscope.$broadcast("projects:reload"),$confirm.notify("success",$translate.instant("COMMON.SAVE")),$location.url($projectUrl.get(response)),lightboxService.close($el),currentUserService.loadProjects()},onErrorSubmit=function(response){var error_field,error_step,i,len,ref,selectors;for(currentLoading.finish(),form.setErrors(response),selectors=[],ref=_.keys(response),i=0,len=ref.length;len>i;i++)error_field=ref[i],selectors.push("[name="+error_field+"]");return $el.find(".active").removeClass("active"),error_step=$el.find(selectors.join(",")).first().parents(".wizard-step"),error_step.addClass("active"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(error_step.data("step"))},submit=function(_this){return function(event){var promise;return event.preventDefault(),form.validate()?(currentLoading=$loading().target(submitButton).start(),promise=$repo.create("projects",$scope.data),promise.then(onSuccessSubmit,onErrorSubmit)):void 0}}(this),openLightbox=function(){return $scope.data={},$scope.templates.length?$scope.data.creation_template=_.head(_.filter($scope.templates,function(x){return"scrum"===x.slug})).id:$rs.projects.templates().then(function(_this){return function(result){return $scope.templates=result,$scope.data.creation_template=_.head(_.filter($scope.templates,function(x){return"scrum"===x.slug})).id}}(this)),$el.find(".active").removeClass("active"),$el.find(".create-step1").addClass("active"),lightboxService.open($el),timeout(600,function(){return $el.find(".progress-bar").addClass("step1")})},$el.on("click",".button-next",function(event){var current,field,i,len,next,ref,step,valid;for(event.preventDefault(),current=$el.find(".active"),valid=!0,ref=form.fields,i=0,len=ref.length;len>i;i++)field=ref[i],current.find("[name="+field.element.attr("name")+"]").length&&(valid=field.validate()!==!1&&valid);return valid?(next=current.next(),current.toggleClass("active"),next.toggleClass("active"),step=next.data("step"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(step)):void 0}),$el.on("click",".button-prev",function(event){var current,prev,step;return event.preventDefault(),current=$el.find(".active"),prev=current.prev(),current.toggleClass("active"),prev.toggleClass("active"),step=prev.data("step"),$el.find(".progress-bar").removeClass().addClass("progress-bar").addClass(step)}),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$el.on("click",".close",function(event){return event.preventDefault(),lightboxService.close($el)}),$scope.$on("$destroy",function(){return $el.off()}),openLightbox()},directive={link:link,templateUrl:"project/wizard-create-project.html",scope:{}}},module.directive("tgLbCreateProject",["$rootScope","$tgRepo","$tgConfirm","$location","$tgNavUrls","$tgResources","$projectUrl","$tgLoading","lightboxService","$cacheFactory","$translate","tgCurrentUserService",CreateProject]),DeleteProjectDirective=function($repo,$rootscope,$auth,$location,$navUrls,$confirm,lightboxService,tgLoader,currentUserService){var link;return link=function($scope,$el,$attrs){var projectToDelete,submit;return projectToDelete=null,$scope.$on("deletelightbox:new",function(ctx,project){return lightboxService.open($el),projectToDelete=project}),$scope.$on("$destroy",function(){return $el.off()}),submit=function(){var promise;return tgLoader.start(),lightboxService.close($el),promise=$repo.remove(projectToDelete),promise.then(function(data){return tgLoader.pageLoaded(),$rootscope.$broadcast("projects:reload"),$location.path($navUrls.resolve("home")),$confirm.notify("success"),currentUserService.loadProjects()}),promise.then(null,function(){return $confirm.notify("error"),lightboxService.close($el)})},$el.on("click",".button-red",function(event){return event.preventDefault(),lightboxService.close($el)}),$el.on("click",".button-green",function(event){return event.preventDefault(),submit()})},{link:link}},module.directive("tgLbDeleteProject",["$tgRepo","$rootScope","$tgAuth","$tgLocation","$tgNavUrls","$tgConfirm","lightboxService","tgLoader","tgCurrentUserService",DeleteProjectDirective])}.call(this),function(){var BindHtmlDirective,BindOnceAltDirective,BindOnceBindDirective,BindOnceHrefDirective,BindOnceHtmlDirective,BindOnceRefDirective,BindOnceSrcDirective,BindOnceTitleDirective,BindTitleDirective,bindOnce,module;bindOnce=this.taiga.bindOnce,BindOnceBindDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoBind,function(val){return $el.text(val)})},{link:link}},BindOnceHtmlDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoHtml,function(val){return $el.html(val)})},{link:link}},BindOnceRefDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoRef,function(val){return $el.html("#"+val+" ")})},{link:link}},BindOnceSrcDirective=function(){ +var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoSrc,function(val){return $el.attr("src",val)})},{link:link}},BindOnceHrefDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoHref,function(val){return $el.attr("href",val)})},{link:link}},BindOnceAltDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoAlt,function(val){return $el.attr("alt",val)})},{link:link}},BindOnceTitleDirective=function(){var link;return link=function($scope,$el,$attrs){return bindOnce($scope,$attrs.tgBoTitle,function(val){return $el.attr("title",val)})},{link:link}},BindTitleDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgTitleHtml,function(val){return null!=val?$el.attr("title",val):void 0})},{link:link}},BindHtmlDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$watch($attrs.tgBindHtml,function(val){return null!=val?$el.html(val):void 0})},{link:link}},module=angular.module("taigaBase"),module.directive("tgBoBind",BindOnceBindDirective),module.directive("tgBoHtml",BindOnceHtmlDirective),module.directive("tgBoRef",BindOnceRefDirective),module.directive("tgBoSrc",BindOnceSrcDirective),module.directive("tgBoHref",BindOnceHrefDirective),module.directive("tgBoAlt",BindOnceAltDirective),module.directive("tgBoTitle",BindOnceTitleDirective),module.directive("tgBindTitle",BindTitleDirective),module.directive("tgBindHtml",BindHtmlDirective)}.call(this),function(){var ConfigurationService,module;ConfigurationService=function(){function ConfigurationService(){this.config=window.taigaConfig}return ConfigurationService.prototype.get=function(key,defaultValue){return null==defaultValue&&(defaultValue=null),_.has(this.config,key)?this.config[key]:defaultValue},ConfigurationService}(),module=angular.module("taigaBase"),module.service("$tgConfig",ConfigurationService)}.call(this),function(){var ContribController,module,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;module=angular.module("taigaBase"),ContribController=function(superClass){function ContribController(rootScope,scope,params,repo,rs,confirm){var promise;this.rootScope=rootScope,this.scope=scope,this.params=params,this.repo=repo,this.rs=rs,this.confirm=confirm,this.scope.currentPlugin=_.first(_.where(this.rootScope.adminPlugins,{slug:this.params.plugin})),this.scope.projectSlug=this.params.pslug,promise=this.loadInitialData(),promise.then(null,function(_this){return function(){return _this.confirm.notify("error")}}(this))}return extend(ContribController,superClass),ContribController.$inject=["$rootScope","$scope","$routeParams","$tgRepo","$tgResources","$tgConfirm"],ContribController.prototype.loadProject=function(){return this.rs.projects.getBySlug(this.params.pslug).then(function(_this){return function(project){return _this.scope.projectId=project.id,_this.scope.project=project,_this.scope.$emit("project:loaded",project),_this.scope.$broadcast("project:loaded",project),project}}(this))},ContribController.prototype.loadInitialData=function(){return this.loadProject()},ContribController}(taiga.Controller),module.controller("ContribController",ContribController)}.call(this),function(){var FiltersStorageService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,FiltersStorageService=function(superClass){function FiltersStorageService(storage,params){this.storage=storage,this.params=params}return extend(FiltersStorageService,superClass),FiltersStorageService.$inject=["$tgStorage","$routeParams"],FiltersStorageService.prototype.generateHash=function(components){return null==components&&(components=[]),components=_.map(components,function(x){return JSON.stringify(x)}),hex_sha1(components.join(":"))},FiltersStorageService}(taiga.Service)}.call(this),function(){var HttpService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,HttpService=function(superClass){function HttpService(http,q,storage,rootScope,cacheFactory,translate){this.http=http,this.q=q,this.storage=storage,this.rootScope=rootScope,this.cacheFactory=cacheFactory,this.translate=translate,HttpService.__super__.constructor.call(this),this.cache=this.cacheFactory("httpget")}return extend(HttpService,superClass),HttpService.$inject=["$http","$q","$tgStorage","$rootScope","$cacheFactory","$translate"],HttpService.prototype.headers=function(){var headers,lang,token;return headers={},token=this.storage.get("token"),token&&(headers.Authorization="Bearer "+token),lang=this.translate.preferredLanguage(),lang&&(headers["Accept-Language"]=lang),headers},HttpService.prototype.request=function(options){return options.headers=_.merge({},options.headers||{},this.headers()),this.http(options)},HttpService.prototype.get=function(url,params,options){return options=_.merge({method:"GET",url:url},options),params&&(options.params=params),options.cache=this.cache,this.request(options)["finally"](function(_this){return function(data){return _this.cache.removeAll()}}(this))},HttpService.prototype.post=function(url,data,params,options){return options=_.merge({method:"POST",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype.put=function(url,data,params,options){return options=_.merge({method:"PUT",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype.patch=function(url,data,params,options){return options=_.merge({method:"PATCH",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService.prototype["delete"]=function(url,data,params,options){return options=_.merge({method:"DELETE",url:url},options),data&&(options.data=data),params&&(options.params=params),this.request(options)},HttpService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgHttp",HttpService)}.call(this),function(){var locationFactory,module;locationFactory=function($location,$route,$rootscope){return $location.noreload=function(scope){var lastRoute,un;return lastRoute=$route.current,un=scope.$on("$locationChangeSuccess",function(){return $route.current=lastRoute,un()}),$location},$location.isInCurrentRouteParams=function(name,value){var params;return params=$location.search()||{},params[name]===value},$location},module=angular.module("taigaBase"),module.factory("$tgLocation",["$location","$route","$rootScope",locationFactory])}.call(this),function(){var Model,ModelService,module,provider,taiga,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;Model=function(){function Model(name,data,dataTypes){this._attrs=data,this._name=name,this._dataTypes=dataTypes,this.setAttrs(data),this.initialize()}return Model.prototype.clone=function(){var instance;return instance=new Model(this._name,this._attrs,this._dataTypes),instance._modifiedAttrs=this._modifiedAttrs,instance._isModified=this._isModified,instance},Model.prototype.applyCasts=function(){var attrName,castMethod,castName,ref,results;ref=this._dataTypes,results=[];for(attrName in ref)castName=ref[attrName],castMethod=service.casts[castName],castMethod&&results.push(this._attrs[attrName]=castMethod(this._attrs[attrName]));return results},Model.prototype.getIdAttrName=function(){return"id"},Model.prototype.getName=function(){return this._name},Model.prototype.getAttrs=function(patch){return null==patch&&(patch=!1),null!=this._attrs.version&&(this._modifiedAttrs.version=this._attrs.version),patch?_.extend({},this._modifiedAttrs):_.extend({},this._attrs,this._modifiedAttrs)},Model.prototype.setAttrs=function(attrs){return this._attrs=attrs,this._modifiedAttrs={},this.applyCasts(),this._isModified=!1},Model.prototype.setAttr=function(name,value){return this._modifiedAttrs[name]=value,this._isModified=!0},Model.prototype.initialize=function(){var getter,self,setter;return self=this,getter=function(name){return function(){return"string"==typeof name&&"__"===name.substr(0,2)?self[name]:indexOf.call(_.keys(self._modifiedAttrs),name)<0?self._attrs[name]:self._modifiedAttrs[name]}},setter=function(name){return function(value){return"string"==typeof name&&"__"===name.substr(0,2)?void(self[name]=value):void(self._attrs[name]!==value?(self._modifiedAttrs[name]=value,self._isModified=!0):delete self._modifiedAttrs[name])}},_.each(this._attrs,function(value,name){var options;return options={get:getter(name),set:setter(name),enumerable:!0,configurable:!0},Object.defineProperty(self,name,options)})},Model.prototype.serialize=function(){var data;return data={data:_.clone(this._attrs),name:this._name},JSON.stringify(data)},Model.prototype.isModified=function(){return this._isModified},Model.prototype.isAttributeModified=function(attribute){return null!=this._modifiedAttrs[attribute]},Model.prototype.markSaved=function(){return this._isModified=!1,this._attrs=this.getAttrs(),this._modifiedAttrs={}},Model.prototype.revert=function(){return this._modifiedAttrs={},this._isModified=!1},Model.desSerialize=function(sdata){var ddata,model;return ddata=JSON.parse(sdata),model=new Model(ddata.url,ddata.data)},Model}(),taiga=this.taiga,ModelService=function(superClass){function ModelService(q,urls,storage,http){this.q=q,this.urls=urls,this.storage=storage,this.http=http,ModelService.__super__.constructor.call(this)}return extend(ModelService,superClass),ModelService.$inject=["$q","$tgUrls","$tgStorage","$tgHttp"],ModelService}(taiga.Service),provider=function($q,$http,$gmUrls,$gmStorage){var service;return service={},service.make_model=function(name,data,cls,dataTypes){return null==cls&&(cls=Model),null==dataTypes&&(dataTypes={}),new cls(name,data,dataTypes)},service.cls=Model,service.casts={"int":function(value){return parseInt(value,10)},"float":function(value){return parseFloat(value,10)}},service},module=angular.module("taigaBase"),module.factory("$tgModel",["$q","$http","$tgUrls","$tgStorage",provider])}.call(this),function(){var NavigationUrlsDirective,NavigationUrlsService,bindOnce,module,taiga,trim,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,trim=this.taiga.trim,bindOnce=this.taiga.bindOnce,module=angular.module("taigaBase"),NavigationUrlsService=function(superClass){function NavigationUrlsService(){this.urls={}}return extend(NavigationUrlsService,superClass),NavigationUrlsService.prototype.update=function(urls){return this.urls=_.merge({},this.urls,urls||{})},NavigationUrlsService.prototype.formatUrl=function(url,ctx){var replacer;return null==ctx&&(ctx={}),replacer=function(match){return match=trim(match,":"),ctx[match]||"undefined"},url.replace(/(:\w+)/g,replacer)},NavigationUrlsService.prototype.resolve=function(name,ctx){var url;return url=this.urls[name],url?ctx?this.formatUrl(url,ctx):url:""},NavigationUrlsService}(taiga.Service),module.service("$tgNavUrls",NavigationUrlsService),NavigationUrlsDirective=function($navurls,$auth,$q,$location){var bindOnceP,link,parseNav;return bindOnceP=function($scope,attr){var defered;return defered=$q.defer(),bindOnce($scope,attr,function(v){return defered.resolve(v)}),defered.promise},parseNav=function(data,$scope){var index,name,obj,params,promises,ref,result,values;if(ref=_.map(data.split(":"),trim),name=ref[0],params=ref[1],params)for(result=params.split(/(\w+)=/),result=_.filter(result,function(str){return str.length}),result=_.map(result,function(str){return trim(str.replace(/,$/g,""))}),params=[],index=0;indexi;i++)param=params[i],key=Object.keys(param)[0],value=param[key],options[key]=$scope.$eval(value);return[name,options]})},link=function($scope,$el,$attrs){return $el.is("a")&&$el.attr("href","#"),$el.on("mouseenter",function(event){var target;return target=$(event.currentTarget),target.data("fullUrl")&&$attrs.tgNavGetParams===target.data("params")?void 0:parseNav($attrs.tgNav,$scope).then(function(result){var fullUrl,getURLParams,getURLParamsStr,name,options,url,user;return name=result[0],options=result[1],user=$auth.getUser(),user&&(options.user=user.username),url=$navurls.resolve(name),fullUrl=$navurls.formatUrl(url,options),$attrs.tgNavGetParams&&(getURLParams=JSON.parse($attrs.tgNavGetParams),getURLParamsStr=$.param(getURLParams),fullUrl=fullUrl+"?"+getURLParamsStr,target.data("params",$attrs.tgNavGetParams)),target.data("fullUrl",fullUrl),target.is("a")&&target.attr("href",fullUrl),$el.on("click",function(event){if(!event.metaKey&&!event.ctrlKey&&(event.preventDefault(),target=$(event.currentTarget),!target.hasClass("noclick")))switch(fullUrl=target.data("fullUrl"),event.which){case 1:return $location.url(fullUrl),$scope.$apply();case 2:return window.open(fullUrl)}})})}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgNav",["$tgNavUrls","$tgAuth","$q","$tgLocation",NavigationUrlsDirective])}.call(this),function(){var RepositoryService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,RepositoryService=function(superClass){function RepositoryService(q,model1,storage,http,urls){this.q=q,this.model=model1,this.storage=storage,this.http=http,this.urls=urls,RepositoryService.__super__.constructor.call(this)}return extend(RepositoryService,superClass),RepositoryService.$inject=["$q","$tgModel","$tgStorage","$tgHttp","$tgUrls"],RepositoryService.prototype.resolveUrlForModel=function(model){var idAttrName;return idAttrName=model.getIdAttrName(),this.urls.resolve(model.getName())+"/"+model[idAttrName]},RepositoryService.prototype.resolveUrlForAttributeModel=function(model){return this.urls.resolve(model.getName(),model.parent)},RepositoryService.prototype.create=function(name,data,dataTypes,extraParams){var defered,promise,url;return null==dataTypes&&(dataTypes={}),null==extraParams&&(extraParams={}),defered=this.q.defer(),url=this.urls.resolve(name),promise=this.http.post(url,JSON.stringify(data)),promise.success(function(_this){return function(_data,_status){return defered.resolve(_this.model.make_model(name,_data,null,dataTypes))}}(this)),promise.error(function(_this){return function(data,status){return defered.reject(data)}}(this)),defered.promise},RepositoryService.prototype.remove=function(model,params){var defered,promise,url;return null==params&&(params={}),defered=this.q.defer(),url=this.resolveUrlForModel(model),promise=this.http["delete"](url,{},params),promise.success(function(data,status){return defered.resolve(model)}),promise.error(function(data,status){return defered.reject(model)}),defered.promise},RepositoryService.prototype.saveAll=function(models,patch){var promises;return null==patch&&(patch=!0),promises=_.map(models,function(_this){return function(x){return _this.save(x,!0)}}(this)),this.q.all(promises)},RepositoryService.prototype.save=function(model,patch){var data,defered,promise,url;return null==patch&&(patch=!0),defered=this.q.defer(),!model.isModified()&&patch?(defered.resolve(model),defered.promise):(url=this.resolveUrlForModel(model),data=JSON.stringify(model.getAttrs(patch)),promise=patch?this.http.patch(url,data):this.http.put(url,data),promise.success(function(_this){return function(data,status){return model._isModified=!1,model._attrs=_.extend(model.getAttrs(),data),model._modifiedAttrs={},model.applyCasts(),defered.resolve(model)}}(this)),promise.error(function(data,status){return defered.reject(data)}),defered.promise)},RepositoryService.prototype.saveAttribute=function(model,attribute,patch){var data,defered,promise,url;return null==patch&&(patch=!0),defered=this.q.defer(),!model.isModified()&&patch?(defered.resolve(model),defered.promise):(url=this.resolveUrlForAttributeModel(model),data={},data[attribute]=model.getAttrs(),promise=patch?this.http.patch(url,data):this.http.put(url,data),promise.success(function(_this){return function(data,status){return model._isModified=!1,model._attrs=_.extend(model.getAttrs(),data),model._modifiedAttrs={},model.applyCasts(),defered.resolve(model)}}(this)),promise.error(function(data,status){return defered.reject(data)}),defered.promise)},RepositoryService.prototype.refresh=function(model){var defered,promise,url;return defered=this.q.defer(),url=this.resolveUrlForModel(model),promise=this.http.get(url),promise.success(function(data,status){return model._modifiedAttrs={},model._attrs=data,model._isModified=!1,model.applyCasts(),defered.resolve(model)}),promise.error(function(data,status){return defered.reject(data)}),defered.promise},RepositoryService.prototype.queryMany=function(name,params,options,headers){var httpOptions,url;return null==options&&(options={}),null==headers&&(headers=!1),url=this.urls.resolve(name),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var result;return result=_.map(data.data,function(x){return _this.model.make_model(name,x)}),headers?[result,data.headers]:result}}(this))},RepositoryService.prototype.queryOneAttribute=function(name,id,attribute,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name,id),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var model;return model=_this.model.make_model(name,data.data[attribute]),model.parent=id,model}}(this))},RepositoryService.prototype.queryOne=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){return _this.model.make_model(name,data.data)}}(this))},RepositoryService.prototype.queryOneRaw=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions=_.merge({headers:{}},options),options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),this.http.get(url,params,httpOptions).then(function(_this){return function(data){return data.data}}(this))},RepositoryService.prototype.queryPaginated=function(name,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),httpOptions=_.merge({headers:{}},options),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var headers,result;return headers=data.headers(),result={},result.models=_.map(data.data,function(x){return _this.model.make_model(name,x)}),result.count=parseInt(headers["x-pagination-count"],10),result.current=parseInt(headers["x-pagination-current"]||1,10),result.paginatedBy=parseInt(headers["x-paginated-by"],10),result}}(this))},RepositoryService.prototype.queryOnePaginatedRaw=function(name,id,params,options){var httpOptions,url;return null==options&&(options={}),url=this.urls.resolve(name),id&&(url=url+"/"+id),httpOptions=_.merge({headers:{}},options),this.http.get(url,params,httpOptions).then(function(_this){return function(data){var headers,result;return headers=data.headers(),result={},result.data=data.data,result.count=parseInt(headers["x-pagination-count"],10),result.current=parseInt(headers["x-pagination-current"]||1,10),result.paginatedBy=parseInt(headers["x-paginated-by"],10),result}}(this))},RepositoryService.prototype.resolve=function(options){var cache,params;return params={},null!=options.pslug&&(params.project=options.pslug),null!=options.usref&&(params.us=options.usref),null!=options.taskref&&(params.task=options.taskref),null!=options.issueref&&(params.issue=options.issueref),null!=options.sslug&&(params.milestone=options.sslug),null!=options.wikipage&&(params.wikipage=options.wikipage),cache=!(options.wikipage||options.sslug),this.queryOneRaw("resolver",null,params,{cache:cache})},RepositoryService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgRepo",RepositoryService)}.call(this),function(){var StorageService,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,StorageService=function(superClass){function StorageService($rootScope){StorageService.__super__.constructor.call(this)}return extend(StorageService,superClass),StorageService.$inject=["$rootScope"],StorageService.prototype.get=function(key,_default){var serializedValue;return serializedValue=localStorage.getItem(key),null===serializedValue?_default||null:JSON.parse(serializedValue)},StorageService.prototype.set=function(key,val){return _.isObject(key)?_.each(key,function(_this){return function(val,key){return _this.set(key,val)}}(this)):localStorage.setItem(key,JSON.stringify(val))},StorageService.prototype.contains=function(key){var value;return value=this.get(key),null!==value},StorageService.prototype.remove=function(key){return localStorage.removeItem(key)},StorageService.prototype.clear=function(){return localStorage.clear()},StorageService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgStorage",StorageService)}.call(this),function(){var UrlsService,format,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;format=function(fmt,obj){return obj=_.clone(obj),fmt.replace(/%s/g,function(match){return String(obj.shift())})},taiga=this.taiga,UrlsService=function(superClass){function UrlsService(config){this.config=config,this.urls={},this.mainUrl=this.config.get("api")}return extend(UrlsService,superClass),UrlsService.$inject=["$tgConfig"],UrlsService.prototype.update=function(urls){return this.urls=_.merge(this.urls,urls)},UrlsService.prototype.resolve=function(){var args,name,url;if(args=_.toArray(arguments),0===args.length)throw Error("wrong arguments to setUrls");return name=args.slice(0,1)[0],url=format(this.urls[name],args.slice(1)),format("%s/%s",[_.str.rtrim(this.mainUrl,"/"),_.str.ltrim(url,"/")])},UrlsService.prototype.resolveAbsolute=function(){var url;return url=this.resolve.apply(this,arguments),/^https?:\/\//i.test(url)?url:/^\//.test(url)?window.location.protocol+"//"+window.location.host+url:window.location.protocol+"//"+window.location.host+"/"+url},UrlsService}(taiga.Service),module=angular.module("taigaBase"),module.service("$tgUrls",UrlsService)}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo){var _get,service;return _get=function(objectId,resource){return $repo.queryOne(resource,objectId)},service={userstory:{get:function(objectId){return _get(objectId,"custom-attributes-values/userstory")}},task:{get:function(objectId){return _get(objectId,"custom-attributes-values/task")}},issue:{get:function(objectId){return _get(objectId,"custom-attributes-values/issue")}}},function(instance){return instance.customAttributesValues=service}},module=angular.module("taigaResources"),module.factory("$tgCustomAttributesValuesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($repo){var _list,service;return _list=function(projectId,resource){return $repo.queryMany(resource,{project:projectId})},service={userstory:{list:function(projectId){return _list(projectId,"custom-attributes/userstory")}},task:{list:function(projectId){return _list(projectId,"custom-attributes/task")}},issue:{list:function(projectId){return _list(projectId,"custom-attributes/issue")}}},function(instance){return instance.customAttributes=service}},module=angular.module("taigaResources"),module.factory("$tgCustomAttributesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(type,objectId){return $repo.queryOneRaw("history/"+type,objectId)},service.deleteComment=function(type,objectId,activityId){var params,url;return url=$urls.resolve("history/"+type),url=url+"/"+objectId+"/delete_comment",params={id:activityId},$http.post(url,null,params).then(function(_this){return function(data){return data.data}}(this))},service.undeleteComment=function(type,objectId,activityId){var params,url;return url=$urls.resolve("history/"+type),url=url+"/"+objectId+"/undelete_comment",params={id:activityId},$http.post(url,null,params).then(function(_this){return function(data){return data.data}}(this))},function(instance){return instance.history=service}},module=angular.module("taigaResources"),module.factory("$tgHistoryResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo){var service;return service={},service.get=function(token){return $repo.queryOne("invitations",token)},function(instance){return instance.invitations=service}},module=angular.module("taigaResources"),module.factory("$tgInvitationsResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage,$q){var filtersHashSuffix,hashSuffix,myFiltersHashSuffix,service;return service={},hashSuffix="issues-queryparams",filtersHashSuffix="issues-filters",myFiltersHashSuffix="issues-my-filters",service.get=function(projectId,issueId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("issues",issueId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("issues","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("issues",filters)},service.list=function(projectId,filters,options){var params;return params={project:projectId},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryPaginated("issues",params,options)},service.bulkCreate=function(projectId,data){var params,url;return url=$urls.resolve("bulk-create-issues"),params={project_id:projectId,bulk_issues:data},$http.post(url,params)},service.upvote=function(issueId){var url;return url=$urls.resolve("issue-upvote",issueId),$http.post(url)},service.downvote=function(issueId){var url;return url=$urls.resolve("issue-downvote",issueId),$http.post(url)},service.watch=function(issueId){var url;return url=$urls.resolve("issue-watch",issueId),$http.post(url)},service.unwatch=function(issueId){var url;return url=$urls.resolve("issue-unwatch",issueId),$http.post(url)},service.stats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/issues_stats")},service.filtersData=function(params){return $repo.queryOneRaw("issues-filters",null,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},service.storeQueryParams(projectId,params),$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeFilters=function(projectSlug,params){var hash,ns;return ns=projectSlug+":"+filtersHashSuffix,hash=generateHash([projectSlug,ns]),$storage.set(hash,params)},service.getFilters=function(projectSlug){var hash,ns;return ns=projectSlug+":"+filtersHashSuffix,hash=generateHash([projectSlug,ns]),$storage.get(hash)||{}},service.storeMyFilters=function(projectId,myFilters){var deferred,hash,ns,promise,url;return deferred=$q.defer(),url=$urls.resolve("user-storage"),ns=projectId+":"+myFiltersHashSuffix,hash=generateHash([projectId,ns]),_.isEmpty(myFilters)?(promise=$http["delete"](url+"/"+hash,{key:hash,value:myFilters}),promise.then(function(){return deferred.resolve()}),promise.then(null,function(){return deferred.reject()})):(promise=$http.put(url+"/"+hash,{key:hash,value:myFilters}),promise.then(function(data){return deferred.resolve()}),promise.then(null,function(data){var innerPromise;return innerPromise=$http.post(""+url,{key:hash,value:myFilters}),innerPromise.then(function(){return deferred.resolve()}),innerPromise.then(null,function(){return deferred.reject()})})),deferred.promise},service.getMyFilters=function(projectId){var deferred,hash,ns,promise,url;return deferred=$q.defer(),url=$urls.resolve("user-storage"),ns=projectId+":"+myFiltersHashSuffix,hash=generateHash([projectId,ns]),promise=$http.get(url+"/"+hash),promise.then(function(data){return deferred.resolve(data.data.value)}),promise.then(null,function(data){return deferred.resolve({})}),deferred.promise},function(instance){return instance.issues=service}},module=angular.module("taigaResources"),module.factory("$tgIssuesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($storage){var hashSuffixStatusColumnModes,hashSuffixStatusViewModes,service;return service={},hashSuffixStatusViewModes="kanban-statusviewmodels",hashSuffixStatusColumnModes="kanban-statuscolumnmodels",service.storeStatusViewModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusViewModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusViewModes=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffixStatusViewModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}; +},service.storeStatusColumnModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusColumnModes=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},function(instance){return instance.kanban=service}},module=angular.module("taigaResources"),module.factory("$tgKanbanResourcesProvider",["$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($repo){var service;return service={list:function(){return $repo.queryMany("locales")}},function(instance){return instance.locales=service}},module=angular.module("taigaResources"),module.factory("$tgLocalesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$urls,$http){var service;return service={},service.render=function(projectId,content){var params,url;return(null==content||""===content)&&(content=" "),params={project_id:projectId,content:content},url=$urls.resolve("wiki"),$http.post(url+"/render",params).then(function(_this){return function(data){return data.data}}(this))},function(instance){return instance.mdrender=service}},module=angular.module("taigaResources"),module.factory("$tgMdRenderResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("memberships",id)},service.list=function(projectId,filters,enablePagination){var options,params;return null==enablePagination&&(enablePagination=!0),params={project:projectId},params=_.extend({},params,filters||{}),enablePagination?$repo.queryPaginated("memberships",params):$repo.queryMany("memberships",params,options={enablePagination:enablePagination})},service.listByUser=function(userId,filters){var params;return params={user:userId},params=_.extend({},params,filters||{}),$repo.queryPaginated("memberships",params)},service.resendInvitation=function(id){var url;return url=$urls.resolve("memberships"),$http.post(url+"/"+id+"/resend_invitation",{})},service.bulkCreateMemberships=function(projectId,data,invitation_extra_text){var params,url;return url=$urls.resolve("bulk-create-memberships"),params={project_id:projectId,bulk_memberships:data,invitation_extra_text:invitation_extra_text},$http.post(url,params)},function(instance){return instance.memberships=service}},module=angular.module("taigaResources"),module.factory("$tgMembershipsResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo){var service;return service={},service.list=function(projectId,module){return $repo.queryOneAttribute("project-modules",projectId,module)},function(instance){return instance.modules=service}},module=angular.module("taigaResources"),module.factory("$tgModulesResourcesProvider",["$tgRepo",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("notify-policies",id)},service.list=function(filters){var params;return params=_.extend({},params,filters||{}),$repo.queryMany("notify-policies",params)},function(instance){return instance.notifyPolicies=service}},module=angular.module("taigaResources"),module.factory("$tgNotifyPoliciesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($config,$repo,$http,$urls,$auth,$q,$translate){var service;return service={},service.get=function(projectId){return $repo.queryOne("projects",projectId)},service.getBySlug=function(projectSlug){return $repo.queryOne("projects","by_slug?slug="+projectSlug)},service.list=function(){return $repo.queryMany("projects")},service.listByMember=function(memberId){var params;return params={member:memberId,order_by:"memberships__user_order"},$repo.queryMany("projects",params)},service.templates=function(){return $repo.queryMany("project-templates")},service.usersList=function(projectId){var params;return params={project:projectId},$repo.queryMany("users",params)},service.rolesList=function(projectId){var params;return params={project:projectId},$repo.queryMany("roles",params)},service.stats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/stats")},service.bulkUpdateOrder=function(bulkData){var url;return url=$urls.resolve("bulk-update-projects-order"),$http.post(url,bulkData)},service.regenerate_userstories_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_userstories_csv_uuid",$http.post(url)},service.regenerate_issues_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_issues_csv_uuid",$http.post(url)},service.regenerate_tasks_csv_uuid=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/regenerate_tasks_csv_uuid",$http.post(url)},service.leave=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/leave",$http.post(url)},service.memberStats=function(projectId){return $repo.queryOneRaw("projects",projectId+"/member_stats")},service.tagsColors=function(projectId){return $repo.queryOne("projects",projectId+"/tags_colors")},service["export"]=function(projectId){var url;return url=$urls.resolve("exporter")+"/"+projectId,$http.get(url)},service["import"]=function(file,statusUpdater){var complete,data,defered,errorMsg,failed,maxFileSize,response,uploadComplete,uploadFailed,uploadProgress,xhr;return defered=$q.defer(),maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(errorMsg=$translate.instant("PROJECT.IMPORT.ERROR_MAX_SIZE_EXCEEDED",{fileName:file.name,fileSize:sizeFormat(file.size),maxFileSize:sizeFormat(maxFileSize)}),response={status:413,data:{_error_message:errorMsg}},defered.reject(response),defered.promise):(uploadProgress=function(_this){return function(evt){var message,percent;return percent=Math.round(evt.loaded/evt.total*100),message=$translate.instant("PROJECT.IMPORT.UPLOAD_IN_PROGRESS_MESSAGE",{uploadedSize:sizeFormat(evt.loaded),totalSize:sizeFormat(evt.total)}),statusUpdater("in-progress",null,message,percent)}}(this),uploadComplete=function(_this){return function(evt){return statusUpdater("done",$translate.instant("PROJECT.IMPORT.TITLE"),$translate.instant("PROJECT.IMPORT.DESCRIPTION"))}}(this),uploadFailed=function(_this){return function(evt){return statusUpdater("error")}}(this),complete=function(_this){return function(evt){var ref;response={};try{response.data=JSON.parse(evt.target.responseText)}catch(error){response.data={}}return response.status=evt.target.status,(201===(ref=response.status)||202===ref)&&defered.resolve(response),defered.reject(response)}}(this),failed=function(_this){return function(evt){return defered.reject("fail")}}(this),data=new FormData,data.append("dump",file),xhr=new XMLHttpRequest,xhr.upload.addEventListener("progress",uploadProgress,!1),xhr.upload.addEventListener("load",uploadComplete,!1),xhr.upload.addEventListener("error",uploadFailed,!1),xhr.upload.addEventListener("abort",uploadFailed,!1),xhr.addEventListener("load",complete,!1),xhr.addEventListener("error",failed,!1),xhr.open("POST",$urls.resolve("importer")),xhr.setRequestHeader("Authorization","Bearer "+$auth.getToken()),xhr.setRequestHeader("Accept","application/json"),xhr.send(data),defered.promise)},service.changeLogo=function(projectId,file){var data,defered,maxFileSize,options,response,url;return maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered=$q.defer(),defered.reject(response),defered.promise):(data=new FormData,data.append("logo",file),options={transformRequest:angular.identity,headers:{"Content-Type":void 0}},url=$urls.resolve("projects")+"/"+projectId+"/change_logo",$http.post(url,data,{},options))},service.removeLogo=function(projectId){var url;return url=$urls.resolve("projects")+"/"+projectId+"/remove_logo",$http.post(url)},function(instance){return instance.projects=service}},module=angular.module("taigaResources"),module.factory("$tgProjectsResourcesProvider",["$tgConfig","$tgRepo","$tgHttp","$tgUrls","$tgAuth","$q","$translate",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(id){return $repo.queryOne("roles",id)},service.list=function(projectId){return $repo.queryMany("roles",{project:projectId})},function(instance){return instance.roles=service}},module=angular.module("taigaResources"),module.factory("$tgRolesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$urls,$http,$q){var service;return service={},service["do"]=function(projectId,term){var deferredAbort,params,request,url;return deferredAbort=$q.defer(),url=$urls.resolve("search"),params={url:url,method:"GET",timeout:deferredAbort.promise,cancelable:!0,params:{project:projectId,text:term,get_all:!1}},request=$http.request(params).then(function(data){return data.data}),request.abort=function(){return deferredAbort.resolve()},request["finally"]=function(){return request.abort=angular.noop,deferredAbort=request=null},request},function(instance){return instance.search=service}},module=angular.module("taigaResources"),module.factory("$tgSearchResourcesProvider",["$tgRepo","$tgUrls","$tgHttp","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$model,$storage){var service;return service={},service.get=function(projectId,sprintId){return $repo.queryOne("milestones",sprintId).then(function(sprint){var uses;return uses=sprint.user_stories,uses=_.map(uses,function(u){return $model.make_model("userstories",u)}),sprint._attrs.user_stories=uses,sprint})},service.stats=function(projectId,sprintId){return $repo.queryOneRaw("milestones",sprintId+"/stats")},service.list=function(projectId,filters){var params;return params={project:projectId},params=_.extend({},params,filters||{}),$repo.queryMany("milestones",params,{},!0).then(function(_this){return function(result){var headers,i,len,m,milestones,uses;for(milestones=result[0],headers=result[1],i=0,len=milestones.length;len>i;i++)m=milestones[i],uses=m.user_stories,uses=_.map(uses,function(u){return $model.make_model("userstories",u)}),m._attrs.user_stories=uses;return{milestones:milestones,closed:parseInt(headers("Taiga-Info-Total-Closed-Milestones"),10),open:parseInt(headers("Taiga-Info-Total-Opened-Milestones"),10)}}}(this))},function(instance){return instance.sprints=service}},module=angular.module("taigaResources"),module.factory("$tgSprintsResourcesProvider",["$tgRepo","$tgModel","$tgStorage",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage){var hashSuffix,hashSuffixStatusColumnModes,hashSuffixUsRowModes,service;return service={},hashSuffix="tasks-queryparams",hashSuffixStatusColumnModes="tasks-statuscolumnmodels",hashSuffixUsRowModes="tasks-usrowmodels",service.get=function(projectId,taskId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("tasks",taskId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("tasks","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("tasks",filters)},service.list=function(projectId,sprintId,userStoryId){var params;return null==sprintId&&(sprintId=null),null==userStoryId&&(userStoryId=null),params={project:projectId},sprintId&&(params.milestone=sprintId),userStoryId&&(params.user_story=userStoryId),service.storeQueryParams(projectId,params),$repo.queryMany("tasks",params)},service.bulkCreate=function(projectId,sprintId,usId,data){var params,url;return url=$urls.resolve("bulk-create-tasks"),params={project_id:projectId,sprint_id:sprintId,us_id:usId,bulk_tasks:data},$http.post(url,params).then(function(result){return result.data})},service.upvote=function(taskId){var url;return url=$urls.resolve("task-upvote",taskId),$http.post(url)},service.downvote=function(taskId){var url;return url=$urls.resolve("task-downvote",taskId),$http.post(url)},service.watch=function(taskId){var url;return url=$urls.resolve("task-watch",taskId),$http.post(url)},service.unwatch=function(taskId){var url;return url=$urls.resolve("task-unwatch",taskId),$http.post(url)},service.bulkUpdateTaskTaskboardOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-task-taskboard-order"),params={project_id:projectId,bulk_tasks:data},$http.post(url,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeStatusColumnModes=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getStatusColumnModes=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffixStatusColumnModes,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeUsRowModes=function(projectId,sprintId,params){var hash,ns;return ns=projectId+":"+hashSuffixUsRowModes,hash=generateHash([projectId,sprintId,ns]),$storage.set(hash,params)},service.getUsRowModes=function(projectId,sprintId){var hash,ns;return ns=projectId+":"+hashSuffixUsRowModes,hash=generateHash([projectId,sprintId,ns]),$storage.get(hash)||{}},function(instance){return instance.tasks=service}},module=angular.module("taigaResources"),module.factory("$tgTasksResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($config,$repo,$http,$urls,$q){var service;return service={},service.changeAvatar=function(file){var data,defered,maxFileSize,options,response,url;return maxFileSize=$config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered=$q.defer(),defered.reject(response),defered.promise):(data=new FormData,data.append("avatar",file),options={transformRequest:angular.identity,headers:{"Content-Type":void 0}},url=$urls.resolve("users")+"/change_avatar",$http.post(url,data,{},options))},service.removeAvatar=function(){var url;return url=$urls.resolve("users")+"/remove_avatar",$http.post(url)},service.changePassword=function(currentPassword,newPassword){var data,url;return url=$urls.resolve("users")+"/change_password",data={current_password:currentPassword,password:newPassword},$http.post(url,data)},function(instance){return instance.userSettings=service}},module=angular.module("taigaResources"),module.factory("$tgUserSettingsResourcesProvider",["$tgConfig","$tgRepo","$tgHttp","$tgUrls","$q",resourceProvider])}.call(this),function(){var module,resourceProvider,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,resourceProvider=function($http,$urls){var service;return service={},service.contacts=function(userId,options){var httpOptions,url;return null==options&&(options={}),url=$urls.resolve("user-contacts",userId),httpOptions={headers:{}},options.enablePagination||(httpOptions.headers["x-disable-pagination"]="1"),$http.get(url,{},httpOptions).then(function(result){return result.data})},function(instance){return instance.users=service}},module=angular.module("taigaResources"),module.factory("$tgUsersResourcesProvider",["$tgHttp","$tgUrls","$q",resourceProvider])}.call(this),function(){var generateHash,module,resourceProvider,taiga;taiga=this.taiga,generateHash=taiga.generateHash,resourceProvider=function($repo,$http,$urls,$storage){var hashSuffix,service;return service={},hashSuffix="userstories-queryparams",service.get=function(projectId,usId){var params;return params=service.getQueryParams(projectId),params.project=projectId,$repo.queryOne("userstories",usId,params)},service.getByRef=function(projectId,ref){var params;return params=service.getQueryParams(projectId),params.project=projectId,params.ref=ref,$repo.queryOne("userstories","by_ref",params)},service.listInAllProjects=function(filters){return $repo.queryMany("userstories",filters)},service.filtersData=function(params){return $repo.queryOneRaw("userstories-filters",null,params)},service.listUnassigned=function(projectId,filters){var params;return params={project:projectId,milestone:"null"},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryMany("userstories",params)},service.listAll=function(projectId,filters){var params;return params={project:projectId},params=_.extend({},params,filters||{}),service.storeQueryParams(projectId,params),$repo.queryMany("userstories",params)},service.bulkCreate=function(projectId,status,bulk){var data,url;return data={project_id:projectId,status_id:status,bulk_stories:bulk},url=$urls.resolve("bulk-create-us"),$http.post(url,data)},service.upvote=function(userStoryId){var url;return url=$urls.resolve("userstory-upvote",userStoryId),$http.post(url)},service.downvote=function(userStoryId){var url;return url=$urls.resolve("userstory-downvote",userStoryId),$http.post(url)},service.watch=function(userStoryId){var url;return url=$urls.resolve("userstory-watch",userStoryId),$http.post(url)},service.unwatch=function(userStoryId){var url;return url=$urls.resolve("userstory-unwatch",userStoryId),$http.post(url)},service.bulkUpdateBacklogOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-backlog-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.bulkUpdateSprintOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-sprint-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.bulkUpdateKanbanOrder=function(projectId,data){var params,url;return url=$urls.resolve("bulk-update-us-kanban-order"),params={project_id:projectId,bulk_stories:data},$http.post(url,params)},service.listValues=function(projectId,type){var params;return params={project:projectId},service.storeQueryParams(projectId,params),$repo.queryMany(type,params)},service.storeQueryParams=function(projectId,params){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.set(hash,params)},service.getQueryParams=function(projectId){var hash,ns;return ns=projectId+":"+hashSuffix,hash=generateHash([projectId,ns]),$storage.get(hash)||{}},service.storeShowTags=function(projectId,showTags){var hash;return hash=generateHash([projectId,"showTags"]),$storage.set(hash,showTags)},service.getShowTags=function(projectId){var hash;return hash=generateHash([projectId,"showTags"]),$storage.get(hash)||null},function(instance){return instance.userstories=service}},module=angular.module("taigaResources"),module.factory("$tgUserstoriesResourcesProvider",["$tgRepo","$tgHttp","$tgUrls","$tgStorage",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo,$urls,$http){var service;return service={},service.list=function(webhookId){var params;return params={webhook:webhookId},$repo.queryMany("webhooklogs",params)},service.resend=function(webhooklogId){var url;return url=$urls.resolve("webhooklogs-resend",webhooklogId),$http.post(url)},function(instance){return instance.webhooklogs=service}},module=angular.module("taigaResources"),module.factory("$tgWebhookLogsResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider;resourceProvider=function($repo,$urls,$http){var service;return service={},service.list=function(projectId){var params;return params={project:projectId},$repo.queryMany("webhooks",params)},service.test=function(webhookId){var url;return url=$urls.resolve("webhooks-test",webhookId),$http.post(url)},function(instance){return instance.webhooks=service}},module=angular.module("taigaResources"),module.factory("$tgWebhooksResourcesProvider",["$tgRepo","$tgUrls","$tgHttp",resourceProvider])}.call(this),function(){var module,resourceProvider,taiga;taiga=this.taiga,resourceProvider=function($repo,$http,$urls){var service;return service={},service.get=function(wikiId){return $repo.queryOne("wiki",wikiId)},service.getBySlug=function(projectId,slug){return $repo.queryOne("wiki","by_slug?project="+projectId+"&slug="+slug)},service.listLinks=function(projectId){return $repo.queryMany("wiki-links",{project:projectId})},function(instance){return instance.wiki=service}},module=angular.module("taigaResources"),module.factory("$tgWikiResourcesProvider",["$tgRepo","$tgHttp","$tgUrls",resourceProvider])}.call(this),function(){var UserChangePasswordController,UserChangePasswordDirective,debounce,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,debounce=this.taiga.debounce,module=angular.module("taigaUserSettings"),UserChangePasswordController=function(superClass){function UserChangePasswordController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,auth,translate){this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.translate=translate,this.scope.sectionName=this.translate.instant("CHANGE_PASSWORD.SECTION_NAME"),this.scope.user=this.auth.getUser()}return extend(UserChangePasswordController,superClass),UserChangePasswordController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth","$translate"],UserChangePasswordController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserChangePasswordController",UserChangePasswordController),UserChangePasswordDirective=function($rs,$confirm,$loading,$translate){var link;return link=function($scope,$el,$attrs,ctrl){var submit,submitButton;return submit=debounce(2e3,function(_this){return function(event){var currentLoading,promise;return event.preventDefault(),$scope.newPassword1!==$scope.newPassword2?void $confirm.notify("error",$translate.instant("CHANGE_PASSWORD.ERROR_PASSWORD_MATCH")):(currentLoading=$loading().target(submitButton).start(),promise=$rs.userSettings.changePassword($scope.currentPassword,$scope.newPassword1),promise.then(function(){return currentLoading.finish(),$confirm.notify("success")}),promise.then(null,function(response){return currentLoading.finish(),$confirm.notify("error",response.data._error_message)}))}}(this)),submitButton=$el.find(".submit-button"),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserChangePassword",["$tgResources","$tgConfirm","$tgLoading","$translate",UserChangePasswordDirective])}.call(this),function(){var DeleteUserDirective,bindOnce,debounce,module,taiga;taiga=this.taiga,bindOnce=this.taiga.bindOnce,debounce=this.taiga.debounce,module=angular.module("taigaUserSettings"),DeleteUserDirective=function($repo,$rootscope,$auth,$location,$navUrls,lightboxService){var link;return link=function($scope,$el,$attrs){var submit;return $scope.$on("deletelightbox:new",function(ctx,user){return lightboxService.open($el)}),$scope.$on("$destroy",function(){return $el.off()}),submit=function(){var promise;return promise=$repo.remove($scope.user),promise.then(function(data){return lightboxService.close($el),$auth.logout(),$location.path($navUrls.resolve("login"))}),promise.then(null,function(){return console.log("FAIL")})},$el.on("click",".button-red",function(event){return event.preventDefault(),lightboxService.close($el)}),$el.on("click",".button-green",debounce(2e3,function(event){return event.preventDefault(),submit()}))},{link:link,templateUrl:"user/lightbox/lightbox-delete-account.html"}},module.directive("tgLbDeleteUser",["$tgRepo","$rootScope","$tgAuth","$tgLocation","$tgNavUrls","lightboxService",DeleteUserDirective])}.call(this),function(){var TaigaAvatarModelDirective,UserAvatarDirective,UserProfileDirective,UserSettingsController,debounce,mixOf,module,sizeFormat,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,sizeFormat=this.taiga.sizeFormat,module=angular.module("taigaUserSettings"),debounce=this.taiga.debounce,UserSettingsController=function(superClass){function UserSettingsController(scope,rootscope,config,repo,confirm,rs,params,q,location,navUrls,auth,translate){var maxFileSize,promise,text;this.scope=scope,this.rootscope=rootscope,this.config=config,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.translate=translate,this.scope.sectionName="USER_SETTINGS.MENU.SECTION_TITLE",this.scope.project={},this.scope.user=this.auth.getUser(),this.scope.user||(this.location.path(this.navUrls.resolve("permission-denied")),this.location.replace()),this.scope.lang=this.getLan(),this.scope.theme=this.getTheme(),maxFileSize=this.config.get("maxUploadFileSize",null),maxFileSize&&(text=this.translate.instant("USER_SETTINGS.AVATAR_MAX_SIZE",{maxFileSize:sizeFormat(maxFileSize)}),this.scope.maxFileSizeMsg=text),promise=this.loadInitialData(),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserSettingsController,superClass),UserSettingsController.$inject=["$scope","$rootScope","$tgConfig","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth","$translate"],UserSettingsController.prototype.loadInitialData=function(){return this.scope.availableThemes=this.config.get("themes",[]),this.rs.locales.list().then(function(_this){return function(locales){return _this.scope.locales=locales,locales}}(this))},UserSettingsController.prototype.openDeleteLightbox=function(){return this.rootscope.$broadcast("deletelightbox:new",this.scope.user)},UserSettingsController.prototype.getLan=function(){return this.scope.user.lang||this.translate.preferredLanguage()},UserSettingsController.prototype.getTheme=function(){return this.scope.user.theme||this.config.get("defaultTheme")||"taiga"},UserSettingsController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserSettingsController",UserSettingsController),UserProfileDirective=function($confirm,$auth,$repo,$translate){var link;return link=function($scope,$el,$attrs){var submit;return submit=debounce(2e3,function(_this){return function(event){var changeEmail,form,onError,onSuccess;return event.preventDefault(),form=$el.find("form").checksley(),form.validate()?(changeEmail=$scope.user.isAttributeModified("email"),$scope.user.lang=$scope.lang,$scope.user.theme=$scope.theme,onSuccess=function(data){var text;return $auth.setUser(data),changeEmail?(text=$translate.instant("USER_PROFILE.CHANGE_EMAIL_SUCCESS"),$confirm.success(text)):$confirm.notify("success")},onError=function(data){return form.setErrors(data),$confirm.notify("error",data._error_message)},$repo.save($scope.user).then(onSuccess,onError)):void 0}}(this)),$el.on("submit","form",submit),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserProfile",["$tgConfirm","$tgAuth","$tgRepo","$translate",UserProfileDirective]),UserAvatarDirective=function($auth,$model,$rs,$confirm){var link;return link=function($scope,$el,$attrs){var onError,onSuccess,showSizeInfo;return showSizeInfo=function(){return $el.find(".size-info").removeClass("hidden")},onSuccess=function(response){var user;return user=$model.make_model("users",response.data),$auth.setUser(user),$scope.user=user,$el.find(".loading-overlay").removeClass("active"),$confirm.notify("success")},onError=function(response){return 413===response.status&&showSizeInfo(),$el.find(".loading-overlay").removeClass("active"),$confirm.notify("error",response.data._error_message)},$el.on("click",".js-change-avatar",function(){return $el.find("#avatar-field").click()}),$el.on("change","#avatar-field",function(event){return $scope.avatarAttachment?($el.find(".loading-overlay").addClass("active"),$rs.userSettings.changeAvatar($scope.avatarAttachment).then(onSuccess,onError)):void 0}),$el.on("click","a.js-use-gravatar",function(event){return $el.find(".loading-overlay").addClass("active"),$rs.userSettings.removeAvatar().then(onSuccess,onError)}),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserAvatar",["$tgAuth","$tgModel","$tgResources","$tgConfirm",UserAvatarDirective]),TaigaAvatarModelDirective=function($parse){var link;return link=function($scope,$el,$attrs){var model,modelSetter;return model=$parse($attrs.tgAvatarModel),modelSetter=model.assign,$el.bind("change",function(){return $scope.$apply(function(){return modelSetter($scope,$el[0].files[0])})})},{link:link}},module.directive("tgAvatarModel",["$parse",TaigaAvatarModelDirective])}.call(this),function(){var UserSettingsNavigationDirective,module;UserSettingsNavigationDirective=function(){var link;return link=function($scope,$el,$attrs){var section;return section=$attrs.tgUserSettingsNavigation,$el.find(".active").removeClass("active"),$el.find("#usersettingsmenu-"+section+" a").addClass("active"),$scope.$on("$destroy",function(){return $el.off()})},{link:link}},module=angular.module("taigaUserSettings"),module.directive("tgUserSettingsNavigation",UserSettingsNavigationDirective)}.call(this),function(){var UserNotificationsController,UserNotificationsDirective,UserNotificationsListDirective,bindOnce,mixOf,module,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,mixOf=this.taiga.mixOf,bindOnce=this.taiga.bindOnce,module=angular.module("taigaUserSettings"),UserNotificationsController=function(superClass){function UserNotificationsController(scope,rootscope,repo,confirm,rs,params,q,location,navUrls,auth){ +var promise;this.scope=scope,this.rootscope=rootscope,this.repo=repo,this.confirm=confirm,this.rs=rs,this.params=params,this.q=q,this.location=location,this.navUrls=navUrls,this.auth=auth,this.scope.sectionName="USER_SETTINGS.NOTIFICATIONS.SECTION_NAME",this.scope.user=this.auth.getUser(),promise=this.loadInitialData(),promise.then(null,this.onInitialDataError.bind(this))}return extend(UserNotificationsController,superClass),UserNotificationsController.$inject=["$scope","$rootScope","$tgRepo","$tgConfirm","$tgResources","$routeParams","$q","$tgLocation","$tgNavUrls","$tgAuth"],UserNotificationsController.prototype.loadInitialData=function(){return this.rs.notifyPolicies.list().then(function(_this){return function(notifyPolicies){return _this.scope.notifyPolicies=notifyPolicies,notifyPolicies}}(this))},UserNotificationsController}(mixOf(taiga.Controller,taiga.PageMixin)),module.controller("UserNotificationsController",UserNotificationsController),UserNotificationsDirective=function(){var link;return link=function($scope,$el,$attrs){return $scope.$on("$destroy",function(){return $el.off()})},{link:link}},module.directive("tgUserNotifications",UserNotificationsDirective),UserNotificationsListDirective=function($repo,$confirm,$compile){var link,template;return template=_.template('<% _.each(notifyPolicies, function (notifyPolicy, index) { %>\n
\n
<%- notifyPolicy.project_name %>
\n
\n
\n checked="checked"<% } %>/>\n \n
\n
\n
\n
\n checked="checked"<% } %> />\n \n
\n
\n
\n
\n checked="checked"<% } %> />\n \n
\n
\n
\n<% }) %>'),link=function($scope,$el,$attrs){var render;return render=function(){var ctx,html;return $el.off(),ctx={notifyPolicies:$scope.notifyPolicies},html=template(ctx),$el.html($compile(html)($scope)),$el.on("change","input[type=radio]",function(event){var onError,onSuccess,policy,policyIndex,prev_level,target;return target=angular.element(event.currentTarget),policyIndex=target.parents(".policy-table-row").data("index"),policy=$scope.notifyPolicies[policyIndex],prev_level=policy.notify_level,policy.notify_level=parseInt(target.val(),10),onSuccess=function(){return $confirm.notify("success")},onError=function(){return $confirm.notify("error"),target.parents(".policy-table-row").find("input[value="+prev_level+"]").prop("checked",!0)},$repo.save(policy).then(onSuccess,onError)})},$scope.$on("$destroy",function(){return $el.off()}),bindOnce($scope,$attrs.ngModel,render)},{link:link}},module.directive("tgUserNotificationsList",["$tgRepo","$tgConfirm","$compile",UserNotificationsListDirective])}.call(this),function(){angular.module("taigaComponents",[])}.call(this),function(){var module;module=angular.module("taigaDiscover",[])}.call(this),function(){var module;module=angular.module("taigaExternalApps",[])}.call(this),function(){var module;module=angular.module("taigaHome",[])}.call(this),function(){angular.module("taigaNavigationBar",[])}.call(this),function(){var module;module=angular.module("taigaProfile",[])}.call(this),function(){angular.module("taigaProjects",[])}.call(this),function(){angular.module("taigaResources2",[])}.call(this),function(){angular.module("taigaUserTimeline",[])}.call(this),function(){var AttachmentLinkDirective;AttachmentLinkDirective=function($parse,lightboxFactory){var link;return link=function(scope,el,attrs){var attachment;return attachment=$parse(attrs.tgAttachmentLink)(scope),el.on("click",function(event){return taiga.isImage(attachment.getIn(["file","name"]))?(event.preventDefault(),scope.$apply(function(){return lightboxFactory.create("tg-lb-attachment-preview",{"class":"lightbox lightbox-block"},{file:attachment.get("file")})})):void 0}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentLinkDirective.$inject=["$parse","tgLightboxFactory"],angular.module("taigaComponents").directive("tgAttachmentLink",AttachmentLinkDirective)}.call(this),function(){var AttachmentGalleryDirective;AttachmentGalleryDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachment:"=",onDelete:"&",onUpdate:"&",type:"="},controller:"Attachment",controllerAs:"vm",templateUrl:"components/attachment/attachment-gallery.html",link:link}},AttachmentGalleryDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentGallery",AttachmentGalleryDirective)}.call(this),function(){var AttachmentController;AttachmentController=function(){function AttachmentController(attachmentsService,translate){this.attachmentsService=attachmentsService,this.translate=translate,this.form={},this.form.description=this.attachment.getIn(["file","description"]),this.form.is_deprecated=this.attachment.get(["file","is_deprecated"]),this.title=this.translate.instant("ATTACHMENT.TITLE",{fileName:this.attachment.get("name"),date:moment(this.attachment.get("created_date")).format(this.translate.instant("ATTACHMENT.DATE"))})}return AttachmentController.$inject=["tgAttachmentsService","$translate"],AttachmentController.prototype.editMode=function(mode){var attachment;return attachment=this.attachment.set("editable",mode),this.onUpdate({attachment:attachment})},AttachmentController.prototype["delete"]=function(){return this.onDelete({attachment:this.attachment})},AttachmentController.prototype.save=function(){var attachment;return attachment=this.attachment.set("loading",!0),this.onUpdate({attachment:attachment}),attachment=this.attachment.merge({editable:!1,loading:!1}),attachment=attachment.mergeIn(["file"],{description:this.form.description,is_deprecated:!!this.form.is_deprecated}),this.onUpdate({attachment:attachment})},AttachmentController}(),angular.module("taigaComponents").controller("Attachment",AttachmentController)}.call(this),function(){var AttachmentDirective;AttachmentDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachment:"=",onDelete:"&",onUpdate:"&",type:"="},controller:"Attachment",controllerAs:"vm",templateUrl:"components/attachment/attachment.html",link:link}},AttachmentDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachment",AttachmentDirective)}.call(this),function(){var AttachmentsDropDirective;AttachmentsDropDirective=function($parse){var link;return link=function(scope,el,attrs){var eventAttr;return eventAttr=$parse(attrs.tgAttachmentsDrop),el.on("dragover",function(e){return e.preventDefault(),!1}),el.on("drop",function(e){var dataTransfer;return e.stopPropagation(),e.preventDefault(),dataTransfer=e.dataTransfer||e.originalEvent&&e.originalEvent.dataTransfer,scope.$apply(function(){return eventAttr(scope,{files:dataTransfer.files})})}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentsDropDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgAttachmentsDrop",AttachmentsDropDirective)}.call(this),function(){var AttachmentsFullController,sizeFormat;sizeFormat=this.taiga.sizeFormat,AttachmentsFullController=function(){function AttachmentsFullController(translate,confirm,config,storage,attachmentsFullService){this.translate=translate,this.confirm=confirm,this.config=config,this.storage=storage,this.attachmentsFullService=attachmentsFullService,this.mode=this.storage.get("attachment-mode","list"),this.maxFileSize=this.config.get("maxUploadFileSize",null),this.maxFileSize&&(this.maxFileSize=sizeFormat(this.maxFileSize)),this.maxFileSizeMsg=this.maxFileSize?this.translate.instant("ATTACHMENT.MAX_UPLOAD_SIZE",{maxFileSize:this.maxFileSize}):"",taiga.defineImmutableProperty(this,"attachments",function(_this){return function(){return _this.attachmentsFullService.attachments}}(this)),taiga.defineImmutableProperty(this,"deprecatedsCount",function(_this){return function(){return _this.attachmentsFullService.deprecatedsCount}}(this)),taiga.defineImmutableProperty(this,"attachmentsVisible",function(_this){return function(){return _this.attachmentsFullService.attachmentsVisible}}(this)),taiga.defineImmutableProperty(this,"deprecatedsVisible",function(_this){return function(){return _this.attachmentsFullService.deprecatedsVisible}}(this))}return AttachmentsFullController.$inject=["$translate","$tgConfirm","$tgConfig","$tgStorage","tgAttachmentsFullService"],AttachmentsFullController.prototype.uploadingAttachments=function(){return this.attachmentsFullService.uploadingAttachments},AttachmentsFullController.prototype.addAttachment=function(file){var editable;return editable="list"===this.mode,this.attachmentsFullService.addAttachment(this.projectId,this.objId,this.type,file,editable)},AttachmentsFullController.prototype.setMode=function(mode){return this.mode=mode,this.storage.set("attachment-mode",mode)},AttachmentsFullController.prototype.toggleDeprecatedsVisible=function(){return this.attachmentsFullService.toggleDeprecatedsVisible()},AttachmentsFullController.prototype.addAttachments=function(files){return _.forEach(files,function(_this){return function(file){return _this.addAttachment(file)}}(this))},AttachmentsFullController.prototype.loadAttachments=function(){return this.attachmentsFullService.loadAttachments(this.type,this.objId,this.projectId)},AttachmentsFullController.prototype.deleteAttachment=function(toDeleteAttachment){var message,title;return title=this.translate.instant("ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT"),message=this.translate.instant("ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT",{fileName:toDeleteAttachment.getIn(["file","name"])}),this.confirm.askOnDelete(title,message).then(function(_this){return function(askResponse){var onError,onSuccess;return onError=function(){return message=_this.translate.instant("ATTACHMENT.ERROR_DELETE_ATTACHMENT",{errorMessage:message}),_this.confirm.notify("error",null,message),askResponse.finish(!1)},onSuccess=function(){return askResponse.finish()},_this.attachmentsFullService.deleteAttachment(toDeleteAttachment,_this.type).then(onSuccess,onError)}}(this))},AttachmentsFullController.prototype.reorderAttachment=function(attachment,newIndex){return this.attachmentsFullService.reorderAttachment(this.type,attachment,newIndex)},AttachmentsFullController.prototype.updateAttachment=function(toUpdateAttachment){return this.attachmentsFullService.updateAttachment(toUpdateAttachment,this.type)},AttachmentsFullController}(),angular.module("taigaComponents").controller("AttachmentsFull",AttachmentsFullController)}.call(this),function(){var AttachmentsFullDirective,bindOnce;bindOnce=this.taiga.bindOnce,AttachmentsFullDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return bindOnce(scope,"vm.objId",function(value){return ctrl.loadAttachments()})},{scope:{},bindToController:{type:"@",objId:"=",projectId:"="},controller:"AttachmentsFull",controllerAs:"vm",templateUrl:"components/attachments-full/attachments-full.html",link:link}},AttachmentsFullDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentsFull",AttachmentsFullDirective)}.call(this),function(){var AttachmentsFullService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;AttachmentsFullService=function(superClass){function AttachmentsFullService(attachmentsService,rootScope){this.attachmentsService=attachmentsService,this.rootScope=rootScope,this._attachments=Immutable.List(),this._deprecatedsCount=0,this._attachmentsVisible=Immutable.List(),this._deprecatedsVisible=!1,this.uploadingAttachments=[],taiga.defineImmutableProperty(this,"attachments",function(_this){return function(){return _this._attachments}}(this)),taiga.defineImmutableProperty(this,"deprecatedsCount",function(_this){return function(){return _this._deprecatedsCount}}(this)),taiga.defineImmutableProperty(this,"attachmentsVisible",function(_this){return function(){return _this._attachmentsVisible}}(this)),taiga.defineImmutableProperty(this,"deprecatedsVisible",function(_this){return function(){return _this._deprecatedsVisible}}(this))}return extend(AttachmentsFullService,superClass),AttachmentsFullService.$inject=["tgAttachmentsService","$rootScope"],AttachmentsFullService.prototype.toggleDeprecatedsVisible=function(){return this._deprecatedsVisible=!this._deprecatedsVisible,this.regenerate()},AttachmentsFullService.prototype.regenerate=function(){return this._deprecatedsCount=this._attachments.count(function(it){return it.getIn(["file","is_deprecated"])}),this._deprecatedsVisible?this._attachmentsVisible=this._attachments:this._attachmentsVisible=this._attachments.filter(function(it){return!it.getIn(["file","is_deprecated"])})},AttachmentsFullService.prototype.addAttachment=function(projectId,objId,type,file,editable){return null==editable&&(editable=!0),new Promise(function(_this){return function(resolve,reject){var promise;return _this.attachmentsService.validate(file)?(_this.uploadingAttachments.push(file),promise=_this.attachmentsService.upload(file,objId,projectId,type),promise.then(function(file){var attachment;return _this.uploadingAttachments=_this.uploadingAttachments.filter(function(uploading){return uploading.name!==file.get("name")}),attachment=Immutable.Map(),attachment=attachment.merge({file:file,editable:editable,loading:!1}),_this._attachments=_this._attachments.push(attachment),_this.regenerate(),_this.rootScope.$broadcast("attachment:create"),resolve(attachment)})):reject(file)}}(this))},AttachmentsFullService.prototype.loadAttachments=function(type,objId,projectId){return this.attachmentsService.list(type,objId,projectId).then(function(_this){return function(files){return _this._attachments=files.map(function(file){var attachment;return attachment=Immutable.Map(),attachment.merge({loading:!1,editable:!1,file:file})}),_this.regenerate()}}(this))},AttachmentsFullService.prototype.deleteAttachment=function(toDeleteAttachment,type){var onSuccess;return onSuccess=function(_this){return function(){return _this._attachments=_this._attachments.filter(function(attachment){return attachment!==toDeleteAttachment}),_this.regenerate()}}(this),this.attachmentsService["delete"](type,toDeleteAttachment.getIn(["file","id"])).then(onSuccess)},AttachmentsFullService.prototype.reorderAttachment=function(type,attachment,newIndex){var attachments,oldIndex,promises;return oldIndex=this.attachments.findIndex(function(it){return it===attachment}),oldIndex!==newIndex?(attachments=this.attachments.remove(oldIndex),attachments=attachments.splice(newIndex,0,attachment),attachments=attachments.map(function(x,i){return x.setIn(["file","order"],i+1)}),promises=[],attachments.forEach(function(_this){return function(attachment){var patch;return patch={order:attachment.getIn(["file","order"])},promises.push(_this.attachmentsService.patch(attachment.getIn(["file","id"]),type,patch))}}(this)),Promise.all(promises).then(function(_this){return function(){return _this._attachments=attachments,_this.regenerate()}}(this))):void 0},AttachmentsFullService.prototype.updateAttachment=function(toUpdateAttachment,type){var index,oldAttachment,patch;return index=this._attachments.findIndex(function(attachment){return attachment.getIn(["file","id"])===toUpdateAttachment.getIn(["file","id"])}),oldAttachment=this._attachments.get(index),patch=taiga.patch(oldAttachment.get("file"),toUpdateAttachment.get("file")),toUpdateAttachment.get("loading")?(this._attachments=this._attachments.set(index,toUpdateAttachment),this.regenerate()):this.attachmentsService.patch(toUpdateAttachment.getIn(["file","id"]),type,patch).then(function(_this){return function(){return _this._attachments=_this._attachments.set(index,toUpdateAttachment),_this.regenerate()}}(this))},AttachmentsFullService}(taiga.Service),angular.module("taigaComponents").service("tgAttachmentsFullService",AttachmentsFullService)}.call(this),function(){var AttachmentsSimpleController;AttachmentsSimpleController=function(){function AttachmentsSimpleController(attachmentsService){this.attachmentsService=attachmentsService}return AttachmentsSimpleController.$inject=["tgAttachmentsService"],AttachmentsSimpleController.prototype.addAttachment=function(file){var attachment;return attachment=Immutable.fromJS({file:file,name:file.name,size:file.size}),this.attachmentsService.validate(file)&&(this.attachments=this.attachments.push(attachment),this.onAdd)?this.onAdd({attachment:attachment}):void 0},AttachmentsSimpleController.prototype.addAttachments=function(files){return _.forEach(files,this.addAttachment.bind(this))},AttachmentsSimpleController.prototype.deleteAttachment=function(toDeleteAttachment){return this.attachments=this.attachments.filter(function(attachment){return attachment!==toDeleteAttachment}),this.onDelete?this.onDelete({attachment:toDeleteAttachment}):void 0},AttachmentsSimpleController}(),angular.module("taigaComponents").controller("AttachmentsSimple",AttachmentsSimpleController)}.call(this),function(){var AttachmentsSimpleDirective;AttachmentsSimpleDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{scope:{},bindToController:{attachments:"=",onAdd:"&",onDelete:"&"},controller:"AttachmentsSimple",controllerAs:"vm",templateUrl:"components/attachments-simple/attachments-simple.html",link:link}},AttachmentsSimpleDirective.$inject=[],angular.module("taigaComponents").directive("tgAttachmentsSimple",AttachmentsSimpleDirective)}.call(this),function(){var AttachmentSortableDirective;AttachmentSortableDirective=function($parse){var link;return link=function(scope,el,attrs){var callback;return callback=$parse(attrs.tgAttachmentsSortable),el.sortable({items:"div[tg-bind-scope]",handle:"a.settings.icon.icon-drag-v",containment:".attachments",dropOnEmpty:!0,helper:"clone",scroll:!1,tolerance:"pointer",placeholder:"sortable-placeholder single-attachment"}),el.on("sortstop",function(event,ui){var attachment,newIndex;return attachment=ui.item.scope().attachment,newIndex=ui.item.index(),scope.$apply(function(){return callback(scope,{attachment:attachment,index:newIndex})})}),scope.$on("$destroy",function(){return el.off()})},{link:link}},AttachmentSortableDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgAttachmentsSortable",AttachmentSortableDirective)}.call(this),function(){var AutoSelectDirective;AutoSelectDirective=function($timeout){return{link:function(scope,elm){return $timeout(function(){return elm[0].select()})}}},AutoSelectDirective.$inject=["$timeout"],angular.module("taigaComponents").directive("tgAutoSelect",AutoSelectDirective)}.call(this),function(){var FileChangeDirective;FileChangeDirective=function($parse){var link;return link=function(scope,el,attrs,ctrl){var eventAttr;return eventAttr=$parse(attrs.tgFileChange),el.on("change",function(event){return scope.$apply(function(){return eventAttr(scope,{files:event.currentTarget.files})})}),scope.$on("$destroy",function(){return el.off()})},{require:"ngModel",restrict:"A",link:link}},FileChangeDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgFileChange",FileChangeDirective)}.call(this),function(){var JoyRideDirective,taiga;taiga=this.taiga,JoyRideDirective=function($rootScope,currentUserService,joyRideService,$location,$translate){var link;return link=function(scope,el,attrs,ctrl){var initJoyrRide,intro,unsuscribe;return unsuscribe=null,intro=introJs(),intro.oncomplete(function(){return $("html,body").scrollTop(0)}),intro.onexit(function(){return currentUserService.disableJoyRide()}),initJoyrRide=function(next,config){return config[next.joyride]?(intro.setOptions({exitOnEsc:!1,exitOnOverlayClick:!1,showStepNumbers:!1,nextLabel:$translate.instant("JOYRIDE.NAV.NEXT")+" →",prevLabel:"← "+$translate.instant("JOYRIDE.NAV.BACK"),skipLabel:$translate.instant("JOYRIDE.NAV.SKIP"),doneLabel:$translate.instant("JOYRIDE.NAV.DONE"),disableInteraction:!0}),intro.setOption("steps",joyRideService.get(next.joyride)),intro.start()):void 0},$rootScope.$on("$routeChangeSuccess",function(event,next){return next.joyride&¤tUserService.isAuthenticated()?(intro.oncomplete(function(){return currentUserService.disableJoyRide(next.joyride)}),next.loader?unsuscribe=$rootScope.$on("loader:end",function(){return currentUserService.loadJoyRideConfig().then(function(config){return initJoyrRide(next,config)}),unsuscribe()}):currentUserService.loadJoyRideConfig().then(function(config){return initJoyrRide(next,config)})):(intro.exit(),void(unsuscribe&&unsuscribe()))})},{scope:{},link:link}},JoyRideDirective.$inject=["$rootScope","tgCurrentUserService","tgJoyRideService","$location","$translate"],angular.module("taigaComponents").directive("tgJoyRide",JoyRideDirective)}.call(this),function(){var JoyRideService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;JoyRideService=function(superClass){function JoyRideService(translate,checkPermissionsService){this.translate=translate,this.checkPermissionsService=checkPermissionsService}return extend(JoyRideService,superClass),JoyRideService.$inject=["$translate","tgCheckPermissionsService"],JoyRideService.prototype.getConfig=function(){return{dashboard:function(_this){return function(){var steps;return steps=[{element:".project-list > section:not(.ng-hide)",position:"left",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP1.TITLE"),text:_this.translate.instant("JOYRIDE.DASHBOARD.STEP1.TEXT")}},{element:".working-on-container",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.DASHBOARD.STEP2.TEXT")}},{element:".watching-container",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TITLE"),text:[_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TEXT1"),_this.translate.instant("JOYRIDE.DASHBOARD.STEP3.TEXT2")]}}],$(".project-list .create-project-button").is(":hidden")||steps.push({element:".project-list .create-project-button",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TITLE"),text:[_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TEXT1"),_this.translate.instant("JOYRIDE.DASHBOARD.STEP4.TEXT2")]}}),steps}}(this),backlog:function(_this){return function(){var steps;return steps=[{element:".summary",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TITLE"),text:[_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TEXT1"),_this.translate.instant("JOYRIDE.BACKLOG.STEP1.TEXT2")]}},{element:".backlog-table-empty",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP2.TEXT")}},{element:".sprints",position:"left",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP3.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP3.TEXT")}}],_this.checkPermissionsService.check("add_us")&&steps.push({element:".new-us",position:"rigth",joyride:{title:_this.translate.instant("JOYRIDE.BACKLOG.STEP4.TITLE"),text:_this.translate.instant("JOYRIDE.BACKLOG.STEP4.TEXT")}}),steps}}(this),kanban:function(_this){return function(){var steps;return steps=[{element:".kanban-table-inner",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP1.TITLE"),text:_this.translate.instant("JOYRIDE.KANBAN.STEP1.TEXT")}},{element:".card-placeholder",position:"right",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP2.TITLE"),text:_this.translate.instant("JOYRIDE.KANBAN.STEP2.TEXT")}}],_this.checkPermissionsService.check("add_us")&&steps.push({element:".icon-plus",position:"bottom",joyride:{title:_this.translate.instant("JOYRIDE.KANBAN.STEP3.TITLE"),text:[_this.translate.instant("JOYRIDE.KANBAN.STEP3.TEXT1"),_this.translate.instant("JOYRIDE.KANBAN.STEP3.TEXT2")]}}),steps}}(this)}},JoyRideService.prototype.get=function(name){var joyRide,joyRides;return joyRides=this.getConfig(),joyRide=joyRides[name].call(this),_.map(joyRide,function(item){var html;return html="",item.joyride.title&&(html+="

"+item.joyride.title+"

"),_.isArray(item.joyride.text)?_.forEach(item.joyride.text,function(text){return html+="

"+text+"

"}):html+="

"+item.joyride.text+"

",item.intro=html,item})},JoyRideService}(taiga.Service),angular.module("taigaComponents").service("tgJoyRideService",JoyRideService)}.call(this),function(){var LiveAnnouncementDirective;LiveAnnouncementDirective=function(liveAnnouncementService){var link;return link=function(scope,el,attrs){},{restrict:"AE",scope:{},controllerAs:"vm",controller:function(){return this.close=function(){return liveAnnouncementService.open=!1},Object.defineProperties(this,{open:{get:function(){return liveAnnouncementService.open}},title:{get:function(){return liveAnnouncementService.title}},desc:{get:function(){return liveAnnouncementService.desc}}})},link:link,templateUrl:"components/live-announcement/live-announcement.html"}},LiveAnnouncementDirective.$inject=["tgLiveAnnouncementService"],angular.module("taigaComponents").directive("tgLiveAnnouncement",LiveAnnouncementDirective)}.call(this),function(){var LiveAnnouncementService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;LiveAnnouncementService=function(superClass){function LiveAnnouncementService(){this.open=!1,this.title="",this.desc=""}return extend(LiveAnnouncementService,superClass),LiveAnnouncementService.prototype.show=function(title,desc){return this.open=!0,this.title=title,this.desc=desc},LiveAnnouncementService}(taiga.Service),angular.module("taigaComponents").service("tgLiveAnnouncementService",LiveAnnouncementService)}.call(this),function(){var COLORS,IMAGES,LOGOS,ProjectLogoSrcDirective,modulo=function(a,b){return(+a%(b=+b)+b)%b};IMAGES=["/"+window._version+"/images/project-logos/project-logo-01.png","/"+window._version+"/images/project-logos/project-logo-02.png","/"+window._version+"/images/project-logos/project-logo-03.png","/"+window._version+"/images/project-logos/project-logo-04.png","/"+window._version+"/images/project-logos/project-logo-05.png"],COLORS=["rgba( 153, 214, 220, 1 )","rgba( 213, 156, 156, 1 )","rgba( 214, 161, 212, 1 )","rgba( 164, 162, 219, 1 )","rgba( 152, 224, 168, 1 )"],LOGOS=_.cartesianProduct(IMAGES,COLORS),ProjectLogoSrcDirective=function($parse){var _getDefaultProjectLogo,link;return _getDefaultProjectLogo=function(project){var idx,key,logo;return key=project.get("slug")+"-"+project.get("id"),idx=modulo(murmurhash3_32_gc(key,42),LOGOS.length),logo=LOGOS[idx],{src:logo[0],color:logo[1]}},link=function(scope,el,attrs){return scope.$watch("project",function(project){var logo,projectLogo;return(project=Immutable.fromJS(project))?(projectLogo=project.get("logo_small_url"),projectLogo?(el.attr("src",projectLogo),el.css("background","")):(logo=_getDefaultProjectLogo(project),el.attr("src",logo.src),el.css("background",logo.color))):void 0}),scope.$on("$destroy",function(){return el.off()})},{link:link,scope:{project:"=tgProjectLogoSrc"}}},ProjectLogoSrcDirective.$inject=["$parse"],angular.module("taigaComponents").directive("tgProjectLogoSrc",ProjectLogoSrcDirective)}.call(this),function(){var ProjectMenuController;ProjectMenuController=function(){function ProjectMenuController(projectService,lightboxFactory){this.projectService=projectService,this.lightboxFactory=lightboxFactory,this.project=null,this.menu=Immutable.Map()}return ProjectMenuController.$inject=["tgProjectService","tgLightboxFactory"],ProjectMenuController.prototype.show=function(){return this.project=this.projectService.project,this.active=this._getActiveSection(),this._setVideoConference(),this._setMenuPermissions()},ProjectMenuController.prototype.hide=function(){return this.project=null,this.menu={}},ProjectMenuController.prototype.search=function(){return this.lightboxFactory.create("tg-search-box",{"class":"lightbox lightbox-search"})},ProjectMenuController.prototype._setVideoConference=function(){var videoconferenceUrl;return videoconferenceUrl=this._videoConferenceUrl(),videoconferenceUrl?this.project=this.project.set("videoconferenceUrl",videoconferenceUrl):void 0},ProjectMenuController.prototype._setMenuPermissions=function(){return this.menu=Immutable.Map({backlog:!1,kanban:!1,issues:!1,wiki:!1}),this.project.get("is_backlog_activated")&&-1!==this.project.get("my_permissions").indexOf("view_us")&&(this.menu=this.menu.set("backlog",!0)),this.project.get("is_kanban_activated")&&-1!==this.project.get("my_permissions").indexOf("view_us")&&(this.menu=this.menu.set("kanban",!0)),this.project.get("is_issues_activated")&&-1!==this.project.get("my_permissions").indexOf("view_issues")&&(this.menu=this.menu.set("issues",!0)),this.project.get("is_wiki_activated")&&-1!==this.project.get("my_permissions").indexOf("view_wiki_pages")?this.menu=this.menu.set("wiki",!0):void 0},ProjectMenuController.prototype._getActiveSection=function(){var indexBacklog,indexKanban,oldSectionName,sectionName,sectionsBreadcrumb;return sectionName=this.projectService.section,sectionsBreadcrumb=this.projectService.sectionsBreadcrumb,indexBacklog=sectionsBreadcrumb.lastIndexOf("backlog"),indexKanban=sectionsBreadcrumb.lastIndexOf("kanban"),(-1!==indexBacklog||-1!==indexKanban)&&(oldSectionName=-1===indexKanban||indexBacklog>indexKanban?"backlog":"kanban"),"backlog-kanban"===sectionName&&("backlog"===oldSectionName||"kanban"===oldSectionName?sectionName=oldSectionName:this.project.get("is_backlog_activated")&&!this.project.get("is_kanban_activated")?sectionName="backlog":!this.project.get("is_backlog_activated")&&this.project.get("is_kanban_activated")&&(sectionName="kanban")),sectionName},ProjectMenuController.prototype._videoConferenceUrl=function(){var baseUrl,url;if("appear-in"===this.project.get("videoconferences"))baseUrl="https://appear.in/";else{if("talky"!==this.project.get("videoconferences"))return"jitsi"===this.project.get("videoconferences")?(baseUrl="https://meet.jit.si/",url=this.project.get("slug")+"-"+taiga.slugify(this.project.get("videoconferences_extra_data")),url=url.replace(/-/g,""),baseUrl+url):"custom"===this.project.get("videoconferences")?this.project.get("videoconferences_extra_data"):"";baseUrl="https://talky.io/"}return url=this.project.get("videoconferences_extra_data")?this.project.get("slug")+"-"+this.project.get("videoconferences_extra_data"):this.project.get("slug"), +baseUrl+url},ProjectMenuController}(),angular.module("taigaComponents").controller("ProjectMenu",ProjectMenuController)}.call(this),function(){var ProjectMenuDirective,taiga;taiga=this.taiga,ProjectMenuDirective=function(projectService,lightboxFactory){var link;return link=function(scope,el,attrs,ctrl){var projectChange;return projectChange=function(){return projectService.project?ctrl.show():ctrl.hide()},scope.$watch(function(){return projectService.project},projectChange),scope.vm.fixed=!1,$(window).on("scroll",function(){var position;return position=$(window).scrollTop(),position>100&&scope.vm.fixed===!1?(scope.vm.fixed=!0,scope.$digest()):100>position&&scope.vm.fixed===!0?(scope.vm.fixed=!1,scope.$digest()):void 0})},{scope:{},controller:"ProjectMenu",controllerAs:"vm",templateUrl:"components/project-menu/project-menu.html",link:link}},ProjectMenuDirective.$inject=["tgProjectService","tgLightboxFactory"],angular.module("taigaComponents").directive("tgProjectMenu",ProjectMenuDirective)}.call(this),function(){var TermsOfServiceAndPrivacyPolicyNoticeDirective;TermsOfServiceAndPrivacyPolicyNoticeDirective=function($config){var link;return link=function(scope,el,attrs){return scope.privacyPolicyUrl=$config.get("privacyPolicyUrl"),scope.termsOfServiceUrl=$config.get("termsOfServiceUrl")},{restrict:"AE",scope:{},link:link,templateUrl:"components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html"}},angular.module("taigaComponents").directive("tgTermsOfServiceAndPrivacyPolicyNotice",["$tgConfig",TermsOfServiceAndPrivacyPolicyNoticeDirective])}.call(this),function(){var VoteButtonController;VoteButtonController=function(){function VoteButtonController(currentUserService){this.currentUserService=currentUserService,this.user=this.currentUserService.getUser(),this.isMouseOver=!1,this.loading=!1}return VoteButtonController.$inject=["tgCurrentUserService"],VoteButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},VoteButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},VoteButtonController.prototype.toggleVote=function(){var promise;return this.loading=!0,promise=this.item.is_voter?this._downvote():this._upvote(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},VoteButtonController.prototype._upvote=function(){return this.onUpvote().then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))},VoteButtonController.prototype._downvote=function(){return this.onDownvote()},VoteButtonController}(),angular.module("taigaComponents").controller("VoteButton",VoteButtonController)}.call(this),function(){var VoteButtonDirective;VoteButtonDirective=function(){return{scope:{},controller:"VoteButton",bindToController:{item:"=",onUpvote:"=",onDownvote:"="},controllerAs:"vm",templateUrl:"components/vote-button/vote-button.html"}},angular.module("taigaComponents").directive("tgVoteButton",VoteButtonDirective)}.call(this),function(){var WatchButtonController;WatchButtonController=function(){function WatchButtonController(currentUserService,rootScope){this.currentUserService=currentUserService,this.rootScope=rootScope,this.user=this.currentUserService.getUser(),this.isMouseOver=!1,this.loading=!1}return WatchButtonController.$inject=["tgCurrentUserService","$rootScope"],WatchButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},WatchButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},WatchButtonController.prototype.openWatchers=function(){return this.rootScope.$broadcast("watcher:add",this.item)},WatchButtonController.prototype.getPerms=function(){var name,perms;return this.item?(name=this.item._name,perms={userstories:"modify_us",issues:"modify_issue",tasks:"modify_task"},perms[name]):""},WatchButtonController.prototype.toggleWatch=function(){var promise;return this.loading=!0,promise=this.item.is_watcher?this._unwatch():this._watch(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},WatchButtonController.prototype._watch=function(){return this.onWatch().then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))},WatchButtonController.prototype._unwatch=function(){return this.onUnwatch()},WatchButtonController}(),angular.module("taigaComponents").controller("WatchButton",WatchButtonController)}.call(this),function(){var WatchButtonDirective;WatchButtonDirective=function(){return{scope:{},controller:"WatchButton",bindToController:{item:"=",onWatch:"=",onUnwatch:"="},controllerAs:"vm",templateUrl:function(item,attributes){return"components/watch-button/watch-button-"+attributes.environment+".html"}}},angular.module("taigaComponents").directive("tgWatchButton",WatchButtonDirective)}.call(this),function(){var DiscoverHomeOrderByController;DiscoverHomeOrderByController=function(){function DiscoverHomeOrderByController(translate){this.translate=translate,this.is_open=!1,this.texts={week:this.translate.instant("DISCOVER.FILTERS.WEEK"),month:this.translate.instant("DISCOVER.FILTERS.MONTH"),year:this.translate.instant("DISCOVER.FILTERS.YEAR"),all:this.translate.instant("DISCOVER.FILTERS.ALL_TIME")}}return DiscoverHomeOrderByController.$inject=["$translate"],DiscoverHomeOrderByController.prototype.currentText=function(){return this.texts[this.currentOrderBy]},DiscoverHomeOrderByController.prototype.open=function(){return this.is_open=!0},DiscoverHomeOrderByController.prototype.close=function(){return this.is_open=!1},DiscoverHomeOrderByController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.is_open=!1,this.onChange({orderBy:this.currentOrderBy})},DiscoverHomeOrderByController}(),angular.module("taigaDiscover").controller("DiscoverHomeOrderBy",DiscoverHomeOrderByController)}.call(this),function(){var DiscoverHomeOrderByDirective;DiscoverHomeOrderByDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"DiscoverHomeOrderBy",controllerAs:"vm",bindToController:!0,templateUrl:"discover/components/discover-home-order-by/discover-home-order-by.html",scope:{currentOrderBy:"=orderBy",onChange:"&"},link:link}},DiscoverHomeOrderByDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverHomeOrderBy",DiscoverHomeOrderByDirective)}.call(this),function(){var DiscoverSearchBarController;DiscoverSearchBarController=function(){function DiscoverSearchBarController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this.discoverProjectsService.projectsCount}}(this)),this.discoverProjectsService.fetchStats()}return DiscoverSearchBarController.$inject=["tgDiscoverProjectsService"],DiscoverSearchBarController.prototype.selectFilter=function(filter){return this.onChange({filter:filter,q:this.q})},DiscoverSearchBarController.prototype.submitFilter=function(){return this.onChange({filter:this.filter,q:this.q})},DiscoverSearchBarController}(),angular.module("taigaDiscover").controller("DiscoverSearchBar",DiscoverSearchBarController)}.call(this),function(){var DiscoverSearchBarDirective;DiscoverSearchBarDirective=function(){var link;return link=function(scope,el,attrs,ctrl){},{controller:"DiscoverSearchBar",controllerAs:"vm",templateUrl:"discover/components/discover-search-bar/discover-search-bar.html",bindToController:!0,scope:{q:"=",filter:"=",onChange:"&"},link:link}},DiscoverSearchBarDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearchBar",DiscoverSearchBarDirective)}.call(this),function(){var DiscoverSearchListHeaderController;DiscoverSearchListHeaderController=function(){function DiscoverSearchListHeaderController(){this.like_is_open=0===this.orderBy.indexOf("-total_fans"),this.activity_is_open=0===this.orderBy.indexOf("-total_activity")}return DiscoverSearchListHeaderController.$inject=[],DiscoverSearchListHeaderController.prototype.openLike=function(){return this.like_is_open=!0,this.activity_is_open=!1,this.setOrderBy("-total_fans_last_week")},DiscoverSearchListHeaderController.prototype.openActivity=function(){return this.activity_is_open=!0,this.like_is_open=!1,this.setOrderBy("-total_activity_last_week")},DiscoverSearchListHeaderController.prototype.setOrderBy=function(type){return null==type&&(type=""),type||(this.like_is_open=!1,this.activity_is_open=!1),this.onChange({orderBy:type})},DiscoverSearchListHeaderController}(),angular.module("taigaDiscover").controller("DiscoverSearchListHeader",DiscoverSearchListHeaderController)}.call(this),function(){var DiscoverSearchListHeaderDirective;DiscoverSearchListHeaderDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"DiscoverSearchListHeader",controllerAs:"vm",bindToController:!0,templateUrl:"discover/components/discover-search-list-header/discover-search-list-header.html",scope:{onChange:"&",orderBy:"="},link:link}},DiscoverSearchListHeaderDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearchListHeader",DiscoverSearchListHeaderDirective)}.call(this),function(){var FeaturedProjectsController;FeaturedProjectsController=function(){function FeaturedProjectsController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"featured",function(_this){return function(){return _this.discoverProjectsService.featured}}(this)),this.discoverProjectsService.fetchFeatured()}return FeaturedProjectsController.$inject=["tgDiscoverProjectsService"],FeaturedProjectsController}(),angular.module("taigaDiscover").controller("FeaturedProjects",FeaturedProjectsController)}.call(this),function(){var FeaturedProjectsDirective;FeaturedProjectsDirective=function(){var link;return link=function(scope,el,attrs){},{controller:"FeaturedProjects",controllerAs:"vm",templateUrl:"discover/components/featured-projects/featured-projects.html",scope:{},link:link}},FeaturedProjectsDirective.$inject=[],angular.module("taigaDiscover").directive("tgFeaturedProjects",FeaturedProjectsDirective)}.call(this),function(){var HighlightedDirective;HighlightedDirective=function(){return{templateUrl:"discover/components/highlighted/highlighted.html",scope:{loading:"=",highlighted:"=",orderBy:"="}}},HighlightedDirective.$inject=[],angular.module("taigaDiscover").directive("tgHighlighted",HighlightedDirective)}.call(this),function(){var MostActiveController;MostActiveController=function(){function MostActiveController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"highlighted",function(_this){return function(){return _this.discoverProjectsService.mostActive}}(this)),this.currentOrderBy="week",this.order_by=this.getOrderBy()}return MostActiveController.$inject=["tgDiscoverProjectsService"],MostActiveController.prototype.fetch=function(){return this.loading=!0,this.order_by=this.getOrderBy(),this.discoverProjectsService.fetchMostActive({order_by:this.order_by}).then(function(_this){return function(){return _this.loading=!1}}(this))},MostActiveController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.fetch()},MostActiveController.prototype.getOrderBy=function(type){return"all"===this.currentOrderBy?"-total_activity":"-total_activity_last_"+this.currentOrderBy},MostActiveController}(),angular.module("taigaDiscover").controller("MostActive",MostActiveController)}.call(this),function(){var MostActiveDirective;MostActiveDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return ctrl.fetch()},{controller:"MostActive",controllerAs:"vm",templateUrl:"discover/components/most-active/most-active.html",scope:{},link:link}},MostActiveDirective.$inject=[],angular.module("taigaDiscover").directive("tgMostActive",MostActiveDirective)}.call(this),function(){var MostLikedController;MostLikedController=function(){function MostLikedController(discoverProjectsService){this.discoverProjectsService=discoverProjectsService,taiga.defineImmutableProperty(this,"highlighted",function(_this){return function(){return _this.discoverProjectsService.mostLiked}}(this)),this.currentOrderBy="week",this.order_by=this.getOrderBy()}return MostLikedController.$inject=["tgDiscoverProjectsService"],MostLikedController.prototype.fetch=function(){return this.loading=!0,this.order_by=this.getOrderBy(),this.discoverProjectsService.fetchMostLiked({order_by:this.order_by}).then(function(_this){return function(){return _this.loading=!1}}(this))},MostLikedController.prototype.orderBy=function(type){return this.currentOrderBy=type,this.fetch()},MostLikedController.prototype.getOrderBy=function(){return"all"===this.currentOrderBy?"-total_fans":"-total_fans_last_"+this.currentOrderBy},MostLikedController}(),angular.module("taigaDiscover").controller("MostLiked",MostLikedController)}.call(this),function(){var MostLikedDirective;MostLikedDirective=function(){var link;return link=function(scope,el,attrs,ctrl){return ctrl.fetch()},{controller:"MostLiked",controllerAs:"vm",templateUrl:"discover/components/most-liked/most-liked.html",scope:{},link:link}},MostLikedDirective.$inject=[],angular.module("taigaDiscover").directive("tgMostLiked",MostLikedDirective)}.call(this),function(){var DiscoverHomeController;DiscoverHomeController=function(){function DiscoverHomeController(location,navUrls){this.location=location,this.navUrls=navUrls}return DiscoverHomeController.$inject=["$tgLocation","$tgNavUrls"],DiscoverHomeController.prototype.onSubmit=function(q){var url;return url=this.navUrls.resolve("discover-search"),this.location.search("text",q).path(url)},DiscoverHomeController}(),angular.module("taigaDiscover").controller("DiscoverHome",DiscoverHomeController)}.call(this),function(){var DiscoverSearchController;DiscoverSearchController=function(){function DiscoverSearchController(routeParams,discoverProjectsService,route){this.routeParams=routeParams,this.discoverProjectsService=discoverProjectsService,this.route=route,this.page=1,taiga.defineImmutableProperty(this,"searchResult",function(_this){return function(){return _this.discoverProjectsService.searchResult}}(this)),taiga.defineImmutableProperty(this,"nextSearchPage",function(_this){return function(){return _this.discoverProjectsService.nextSearchPage}}(this)),this.q=this.routeParams.text,this.filter=this.routeParams.filter||"all",this.orderBy=this.routeParams.order_by||"",this.loadingGlobal=!1,this.loadingList=!1,this.loadingPagination=!1}return DiscoverSearchController.$inject=["$routeParams","tgDiscoverProjectsService","$route"],DiscoverSearchController.prototype.fetch=function(){return this.page=1,this.discoverProjectsService.resetSearchList(),this.search()},DiscoverSearchController.prototype.fetchByGlobalSearch=function(){return this.loadingGlobal?void 0:(this.loadingGlobal=!0,this.fetch().then(function(_this){return function(){return _this.loadingGlobal=!1}}(this)))},DiscoverSearchController.prototype.fetchByOrderBy=function(){return this.loadingList?void 0:(this.loadingList=!0,this.fetch().then(function(_this){return function(){return _this.loadingList=!1}}(this)))},DiscoverSearchController.prototype.showMore=function(){return this.loadingPagination?void 0:(this.loadingPagination=!0,this.page++,this.search().then(function(_this){return function(){return _this.loadingPagination=!1}}(this)))},DiscoverSearchController.prototype.search=function(){var filter,params;return filter=this.getFilter(),params={page:this.page,q:this.q,order_by:this.orderBy},_.assign(params,filter),this.discoverProjectsService.fetchSearch(params)},DiscoverSearchController.prototype.getFilter=function(){return"people"===this.filter?{is_looking_for_people:!0}:"scrum"===this.filter?{is_backlog_activated:!0}:"kanban"===this.filter?{is_kanban_activated:!0}:{}},DiscoverSearchController.prototype.onChangeFilter=function(filter,q){return this.filter=filter,this.q=q,this.route.updateParams({filter:this.filter,text:this.q}),this.fetchByGlobalSearch()},DiscoverSearchController.prototype.onChangeOrder=function(orderBy){return this.orderBy=orderBy,this.route.updateParams({order_by:orderBy}),this.fetchByOrderBy()},DiscoverSearchController}(),angular.module("taigaDiscover").controller("DiscoverSearch",DiscoverSearchController)}.call(this),function(){var DiscoverSearchDirective;DiscoverSearchDirective=function(){var link;return link=function(scope,element,attrs,ctrl){return ctrl.fetch()},{controller:"DiscoverSearch",controllerAs:"vm",link:link}},DiscoverSearchDirective.$inject=[],angular.module("taigaDiscover").directive("tgDiscoverSearch",DiscoverSearchDirective)}.call(this),function(){var DiscoverProjectsService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,DiscoverProjectsService=function(superClass){function DiscoverProjectsService(rs,projectsService){this.rs=rs,this.projectsService=projectsService,this._mostLiked=Immutable.List(),this._mostActive=Immutable.List(),this._featured=Immutable.List(),this._searchResult=Immutable.List(),this._projectsCount=0,this.decorate=this.projectsService._decorate.bind(this.projectsService),taiga.defineImmutableProperty(this,"mostLiked",function(_this){return function(){return _this._mostLiked}}(this)),taiga.defineImmutableProperty(this,"mostActive",function(_this){return function(){return _this._mostActive}}(this)),taiga.defineImmutableProperty(this,"featured",function(_this){return function(){return _this._featured}}(this)),taiga.defineImmutableProperty(this,"searchResult",function(_this){return function(){return _this._searchResult}}(this)),taiga.defineImmutableProperty(this,"nextSearchPage",function(_this){return function(){return _this._nextSearchPage}}(this)),taiga.defineImmutableProperty(this,"projectsCount",function(_this){return function(){return _this._projectsCount}}(this))}return extend(DiscoverProjectsService,superClass),DiscoverProjectsService.$inject=["tgResources","tgProjectsService"],DiscoverProjectsService.prototype.fetchMostLiked=function(params){return this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,5),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._mostLiked=projects}}(this))},DiscoverProjectsService.prototype.fetchMostActive=function(params){return this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,5),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._mostActive=projects}}(this))},DiscoverProjectsService.prototype.fetchFeatured=function(){var params;return params={is_featured:!0},this.rs.projects.getProjects(params,!1).then(function(_this){return function(result){var data,projects;return data=result.data.slice(0,4),projects=Immutable.fromJS(data),projects=projects.map(_this.decorate),_this._featured=projects}}(this))},DiscoverProjectsService.prototype.resetSearchList=function(){return this._searchResult=Immutable.List()},DiscoverProjectsService.prototype.fetchStats=function(){return this.rs.stats.discover().then(function(_this){return function(discover){return _this._projectsCount=discover.getIn(["projects","total"])}}(this))},DiscoverProjectsService.prototype.fetchSearch=function(params){return this.rs.projects.getProjects(params).then(function(_this){return function(result){var projects;return _this._nextSearchPage=!!result.headers("X-Pagination-Next"),projects=Immutable.fromJS(result.data),projects=projects.map(_this.decorate),_this._searchResult=_this._searchResult.concat(projects)}}(this))},DiscoverProjectsService}(taiga.Service),angular.module("taigaDiscover").service("tgDiscoverProjectsService",DiscoverProjectsService)}.call(this),function(){var ExternalAppController,taiga,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ExternalAppController=function(superClass){function ExternalAppController(routeParams,externalAppsService,window,currentUserService,location,navUrls,xhrError,loader){var loginUrl,nextUrl;this.routeParams=routeParams,this.externalAppsService=externalAppsService,this.window=window,this.currentUserService=currentUserService,this.location=location,this.navUrls=navUrls,this.xhrError=xhrError,this.loader=loader,this.createApplicationToken=bind(this.createApplicationToken,this),this._getApplicationToken=bind(this._getApplicationToken,this),this._redirect=bind(this._redirect,this),this.loader.start(!1),this._applicationId=this.routeParams.application,this._state=this.routeParams.state,this._getApplicationToken(),this._user=this.currentUserService.getUser(),this._application=null,nextUrl=encodeURIComponent(this.location.url()),loginUrl=this.navUrls.resolve("login"),this.loginWithAnotherUserUrl=loginUrl+"?next="+nextUrl,taiga.defineImmutableProperty(this,"user",function(_this){return function(){return _this._user}}(this)),taiga.defineImmutableProperty(this,"application",function(_this){return function(){return _this._application}}(this))}return extend(ExternalAppController,superClass),ExternalAppController.$inject=["$routeParams","tgExternalAppsService","$window","tgCurrentUserService","$location","$tgNavUrls","tgXhrErrorService","tgLoader"],ExternalAppController.prototype._redirect=function(applicationToken){var nextUrl;return nextUrl=applicationToken.get("next_url"),this.window.open(nextUrl,"_self")},ExternalAppController.prototype._getApplicationToken=function(){return this.externalAppsService.getApplicationToken(this._applicationId,this._state).then(function(_this){return function(data){return _this._application=data.get("application"),data.get("auth_code")?_this._redirect(data):_this.loader.pageLoaded()}}(this))["catch"](function(_this){return function(xhr){return _this.loader.pageLoaded(),_this.xhrError.response(xhr)}}(this))},ExternalAppController.prototype.cancel=function(){return this.window.history.back()},ExternalAppController.prototype.createApplicationToken=function(){return this.externalAppsService.authorizeApplicationToken(this._applicationId,this._state).then(function(_this){return function(data){return _this._redirect(data)}}(this))["catch"](function(_this){return function(xhr){return _this.xhrError.response(xhr)}}(this))},ExternalAppController}(taiga.Controller),angular.module("taigaExternalApps").controller("ExternalApp",ExternalAppController)}.call(this),function(){var ExternalAppsService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;ExternalAppsService=function(superClass){function ExternalAppsService(rs){this.rs=rs}return extend(ExternalAppsService,superClass),ExternalAppsService.$inject=["tgResources"],ExternalAppsService.prototype.getApplicationToken=function(applicationId,state){return this.rs.externalapps.getApplicationToken(applicationId,state)},ExternalAppsService.prototype.authorizeApplicationToken=function(applicationId,state){return this.rs.externalapps.authorizeApplicationToken(applicationId,state)},ExternalAppsService}(taiga.Service),angular.module("taigaExternalApps").service("tgExternalAppsService",ExternalAppsService)}.call(this),function(){var FeedbackService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;FeedbackService=function(superClass){function FeedbackService(lightboxFactory){this.lightboxFactory=lightboxFactory}return extend(FeedbackService,superClass),FeedbackService.$inject=["tgLightboxFactory"],FeedbackService.prototype.sendFeedback=function(){return this.lightboxFactory.create("tg-lb-feedback",{"class":"lightbox lightbox-feedback lightbox-generic-form"})},FeedbackService}(taiga.Service),angular.module("taigaFeedback").service("tgFeedbackService",FeedbackService)}.call(this),function(){var DutyDirective;DutyDirective=function(navurls,$translate){var link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.vm.duty=scope.duty,scope.vm.getDutyType=function(){if(scope.vm.duty){if("userstories"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.USER_STORY");if("tasks"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.TASK");if("issues"===scope.vm.duty.get("_name"))return $translate.instant("COMMON.ISSUE")}}},{templateUrl:"home/duties/duty.html",scope:{duty:"=tgDuty"},link:link}},DutyDirective.$inject=["$tgNavUrls","$translate"],angular.module("taigaHome").directive("tgDuty",DutyDirective)}.call(this),function(){var HomeController;HomeController=function(){function HomeController(currentUserService,location,navUrls){this.currentUserService=currentUserService,this.location=location,this.navUrls=navUrls,this.currentUserService.getUser()||this.location.path(this.navUrls.resolve("discover"))}return HomeController.$inject=["tgCurrentUserService","$location","$tgNavUrls"],HomeController}(),angular.module("taigaHome").controller("Home",HomeController)}.call(this),function(){var HomeService,groupBy,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;groupBy=this.taiga.groupBy,HomeService=function(superClass){function HomeService(navurls,rs,projectsService){this.navurls=navurls,this.rs=rs,this.projectsService=projectsService}return extend(HomeService,superClass),HomeService.$inject=["$tgNavUrls","tgResources","tgProjectsService"],HomeService.prototype._attachProjectInfoToWorkInProgress=function(workInProgress,projectsById){var _attachProjectInfoToDuty,_duties,assignedTo,watching;return _attachProjectInfoToDuty=function(_this){return function(duty,objType){var ctx,project,url;return project=projectsById.get(String(duty.get("project"))),ctx={project:project.get("slug"),ref:duty.get("ref")},url=_this.navurls.resolve("project-"+objType+"-detail",ctx),duty=duty.set("url",url),duty=duty.set("projectName",project.get("name")),duty=duty.set("_name",objType)}}(this),assignedTo=workInProgress.get("assignedTo"),assignedTo.get("userStories")&&(_duties=assignedTo.get("userStories").map(function(duty){return _attachProjectInfoToDuty(duty,"userstories")}),assignedTo=assignedTo.set("userStories",_duties)),assignedTo.get("tasks")&&(_duties=assignedTo.get("tasks").map(function(duty){return _attachProjectInfoToDuty(duty,"tasks")}),assignedTo=assignedTo.set("tasks",_duties)),assignedTo.get("issues")&&(_duties=assignedTo.get("issues").map(function(duty){return _attachProjectInfoToDuty(duty,"issues")}),assignedTo=assignedTo.set("issues",_duties)),watching=workInProgress.get("watching"),watching.get("userStories")&&(_duties=watching.get("userStories").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"userstories")}),watching=watching.set("userStories",_duties)),watching.get("tasks")&&(_duties=watching.get("tasks").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"tasks")}),watching=watching.set("tasks",_duties)),watching.get("issues")&&(_duties=watching.get("issues").filter(function(duty){return!!projectsById.get(String(duty.get("project")))}),_duties=_duties.map(function(duty){return _attachProjectInfoToDuty(duty,"issues")}),watching=watching.set("issues",_duties)),workInProgress=workInProgress.set("assignedTo",assignedTo),workInProgress=workInProgress.set("watching",watching)},HomeService.prototype.getWorkInProgress=function(userId){var assignedIssuesPromise,assignedTasksPromise,assignedTo,assignedUserStoriesPromise,params,params_us,projectsById,projectsPromise,watching,watchingIssuesPromise,watchingTasksPromise,watchingUserStoriesPromise,workInProgress;return projectsById=Immutable.Map(),projectsPromise=this.projectsService.getProjectsByUserId(userId).then(function(projects){return projectsById=Immutable.fromJS(groupBy(projects.toJS(),function(p){return p.id}))}),assignedTo=Immutable.Map(),params={status__is_closed:!1,assigned_to:userId},params_us={is_closed:!1,assigned_to:userId},assignedUserStoriesPromise=this.rs.userstories.listInAllProjects(params_us).then(function(userstories){return assignedTo=assignedTo.set("userStories",userstories)}),assignedTasksPromise=this.rs.tasks.listInAllProjects(params).then(function(tasks){return assignedTo=assignedTo.set("tasks",tasks)}),assignedIssuesPromise=this.rs.issues.listInAllProjects(params).then(function(issues){return assignedTo=assignedTo.set("issues",issues)}),params={status__is_closed:!1,watchers:userId},params_us={is_closed:!1,watchers:userId},watching=Immutable.Map(),watchingUserStoriesPromise=this.rs.userstories.listInAllProjects(params_us).then(function(userstories){return watching=watching.set("userStories",userstories)}),watchingTasksPromise=this.rs.tasks.listInAllProjects(params).then(function(tasks){return watching=watching.set("tasks",tasks)}),watchingIssuesPromise=this.rs.issues.listInAllProjects(params).then(function(issues){return watching=watching.set("issues",issues)}),workInProgress=Immutable.Map(),Promise.all([projectsPromise,assignedUserStoriesPromise,assignedTasksPromise,assignedIssuesPromise,watchingUserStoriesPromise,watchingTasksPromise,watchingIssuesPromise]).then(function(_this){return function(){return workInProgress=workInProgress.set("assignedTo",assignedTo),workInProgress=workInProgress.set("watching",watching),workInProgress=_this._attachProjectInfoToWorkInProgress(workInProgress,projectsById)}}(this))},HomeService}(taiga.Service),angular.module("taigaHome").service("tgHomeService",HomeService)}.call(this),function(){var HomeProjectListDirective;HomeProjectListDirective=function(currentUserService,projectsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),scope.vm.newProject=function(){return projectsService.newProject()}},directive={templateUrl:"home/projects/home-project-list.html",scope:{},link:link}},HomeProjectListDirective.$inject=["tgCurrentUserService","tgProjectsService"],angular.module("taigaHome").directive("tgHomeProjectList",HomeProjectListDirective)}.call(this),function(){var WorkingOnController;WorkingOnController=function(){function WorkingOnController(homeService){this.homeService=homeService,this.assignedTo=Immutable.Map(),this.watching=Immutable.Map()}return WorkingOnController.$inject=["tgHomeService"],WorkingOnController.prototype._setAssignedTo=function(workInProgress){var issues,tasks,userStories;return userStories=workInProgress.get("assignedTo").get("userStories"),tasks=workInProgress.get("assignedTo").get("tasks"),issues=workInProgress.get("assignedTo").get("issues"),this.assignedTo=userStories.concat(tasks).concat(issues),this.assignedTo.size>0?this.assignedTo=this.assignedTo.sortBy(function(elem){return elem.get("modified_date")}).reverse():void 0; +},WorkingOnController.prototype._setWatching=function(workInProgress){var issues,tasks,userStories;return userStories=workInProgress.get("watching").get("userStories"),tasks=workInProgress.get("watching").get("tasks"),issues=workInProgress.get("watching").get("issues"),this.watching=userStories.concat(tasks).concat(issues),this.watching.size>0?this.watching=this.watching.sortBy(function(elem){return elem.get("modified_date")}).reverse():void 0},WorkingOnController.prototype.getWorkInProgress=function(userId){return this.homeService.getWorkInProgress(userId).then(function(_this){return function(workInProgress){return _this._setAssignedTo(workInProgress),_this._setWatching(workInProgress)}}(this))},WorkingOnController}(),angular.module("taigaHome").controller("WorkingOn",WorkingOnController)}.call(this),function(){var WorkingOnDirective;WorkingOnDirective=function(homeService,currentUserService){var link;return link=function(scope,el,attrs,ctrl){var user,userId;return user=currentUserService.getUser(),user?(userId=user.get("id"),ctrl.getWorkInProgress(userId)):void 0},{controller:"WorkingOn",controllerAs:"vm",templateUrl:"home/working-on/working-on.html",scope:{},link:link}},WorkingOnDirective.$inject=["tgHomeService","tgCurrentUserService"],angular.module("taigaHome").directive("tgWorkingOn",WorkingOnDirective)}.call(this),function(){var DropdownProjectListDirective;DropdownProjectListDirective=function(currentUserService,projectsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),scope.vm.newProject=function(){return projectsService.newProject()}},directive={templateUrl:"navigation-bar/dropdown-project-list/dropdown-project-list.html",scope:{},link:link}},DropdownProjectListDirective.$inject=["tgCurrentUserService","tgProjectsService"],angular.module("taigaNavigationBar").directive("tgDropdownProjectList",DropdownProjectListDirective)}.call(this),function(){var DropdownUserDirective;DropdownUserDirective=function(authService,configService,locationService,navUrlsService,feedbackService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.vm.isFeedbackEnabled=configService.get("feedbackEnabled"),taiga.defineImmutableProperty(scope.vm,"user",function(){return authService.userData}),scope.vm.logout=function(){return authService.logout(),locationService.url(navUrlsService.resolve("discover")),locationService.search({})},scope.vm.sendFeedback=function(){return feedbackService.sendFeedback()}},directive={templateUrl:"navigation-bar/dropdown-user/dropdown-user.html",scope:{},link:link}},DropdownUserDirective.$inject=["$tgAuth","$tgConfig","$tgLocation","$tgNavUrls","tgFeedbackService"],angular.module("taigaNavigationBar").directive("tgDropdownUser",DropdownUserDirective)}.call(this),function(){var NavigationBarDirective;NavigationBarDirective=function(currentUserService,navigationBarService,locationService,navUrlsService){var directive,link;return link=function(scope,el,attrs,ctrl){return scope.vm={},scope.$on("$routeChangeSuccess",function(){return"/"===locationService.path()?scope.vm.active=!0:scope.vm.active=!1}),taiga.defineImmutableProperty(scope.vm,"projects",function(){return currentUserService.projects.get("recents")}),taiga.defineImmutableProperty(scope.vm,"isAuthenticated",function(){return currentUserService.isAuthenticated()}),taiga.defineImmutableProperty(scope.vm,"isEnabledHeader",function(){return navigationBarService.isEnabledHeader()}),scope.vm.login=function(){var nextUrl;return nextUrl=encodeURIComponent(locationService.url()),locationService.url(navUrlsService.resolve("login")),locationService.search({next:nextUrl})},scope.vm.register=function(){var nextUrl;return nextUrl=encodeURIComponent(locationService.url()),locationService.url(navUrlsService.resolve("register")),locationService.search({next:nextUrl})}},directive={templateUrl:"navigation-bar/navigation-bar.html",scope:{},link:link}},NavigationBarDirective.$inject=["tgCurrentUserService","tgNavigationBarService","$tgLocation","$tgNavUrls"],angular.module("taigaNavigationBar").directive("tgNavigationBar",NavigationBarDirective)}.call(this),function(){var NavigationBarService,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;NavigationBarService=function(superClass){function NavigationBarService(){this.disableHeader()}return extend(NavigationBarService,superClass),NavigationBarService.prototype.enableHeader=function(){return this.enabledHeader=!0},NavigationBarService.prototype.disableHeader=function(){return this.enabledHeader=!1},NavigationBarService.prototype.isEnabledHeader=function(){return this.enabledHeader},NavigationBarService}(taiga.Service),angular.module("taigaNavigationBar").service("tgNavigationBarService",NavigationBarService)}.call(this),function(){var ProfileBarController;ProfileBarController=function(){function ProfileBarController(userService){this.userService=userService,this.loadStats()}return ProfileBarController.$inject=["tgUserService"],ProfileBarController.prototype.loadStats=function(){return this.userService.getStats(this.user.get("id")).then(function(_this){return function(stats){return _this.stats=stats}}(this))},ProfileBarController}(),angular.module("taigaProfile").controller("ProfileBar",ProfileBarController)}.call(this),function(){var ProfileBarDirective;ProfileBarDirective=function(){return{templateUrl:"profile/profile-bar/profile-bar.html",controller:"ProfileBar",controllerAs:"vm",scope:{user:"=user",isCurrentUser:"=iscurrentuser"},bindToController:!0}},angular.module("taigaProfile").directive("tgProfileBar",ProfileBarDirective)}.call(this),function(){var ProfileContactsController;ProfileContactsController=function(){function ProfileContactsController(userService,currentUserService){this.userService=userService,this.currentUserService=currentUserService,this.currentUser=this.currentUserService.getUser(),this.isCurrentUser=!1,this.currentUser&&this.currentUser.get("id")===this.user.get("id")&&(this.isCurrentUser=!0)}return ProfileContactsController.$inject=["tgUserService","tgCurrentUserService"],ProfileContactsController.prototype.loadContacts=function(){return this.userService.getContacts(this.user.get("id")).then(function(_this){return function(contacts){return _this.contacts=contacts}}(this))},ProfileContactsController}(),angular.module("taigaProfile").controller("ProfileContacts",ProfileContactsController)}.call(this),function(){var ProfileContactsDirective;ProfileContactsDirective=function(){var link;return link=function(scope,elm,attrs,ctrl){return ctrl.loadContacts()},{templateUrl:"profile/profile-contacts/profile-contacts.html",scope:{user:"="},controllerAs:"vm",controller:"ProfileContacts",link:link,bindToController:!0}},angular.module("taigaProfile").directive("tgProfileContacts",ProfileContactsDirective)}.call(this),function(){var FavItemDirective;FavItemDirective=function(){var link,templateUrl;return link=function(scope,el,attrs,ctrl){return scope.vm={item:scope.item}},templateUrl=function(el,attrs){return"project"===attrs.itemType?"profile/profile-favs/items/project.html":"profile/profile-favs/items/ticket.html"},{scope:{item:"=tgFavItem"},link:link,templateUrl:templateUrl}},angular.module("taigaProfile").directive("tgFavItem",FavItemDirective)}.call(this),function(){var FavsBaseController,ProfileLikedController,ProfileVotedController,ProfileWatchedController,debounceLeading,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;debounceLeading=this.taiga.debounceLeading,FavsBaseController=function(){function FavsBaseController(){this._init()}return FavsBaseController.prototype._init=function(){return this.enableFilterByAll=!0,this.enableFilterByProjects=!0,this.enableFilterByUserStories=!0,this.enableFilterByTasks=!0,this.enableFilterByIssues=!0,this.enableFilterByTextQuery=!0,this._resetList(),this.q=null,this.type=null},FavsBaseController.prototype._resetList=function(){return this.items=Immutable.List(),this.scrollDisabled=!1,this._page=1},FavsBaseController.prototype._enableLoadingSpinner=function(){return this.isLoading=!0},FavsBaseController.prototype._disableLoadingSpinner=function(){return this.isLoading=!1},FavsBaseController.prototype._enableScroll=function(){return this.scrollDisabled=!1},FavsBaseController.prototype._disableScroll=function(){return this.scrollDisabled=!0},FavsBaseController.prototype._checkIfHasMorePages=function(hasNext){return hasNext?(this._page+=1,this._enableScroll()):this._disableScroll()},FavsBaseController.prototype._checkIfHasNoResults=function(){return this.hasNoResults=0===this.items.size},FavsBaseController.prototype.loadItems=function(){return this._enableLoadingSpinner(),this._disableScroll(),this._getItems(this.user.get("id"),this._page,this.type,this.q).then(function(_this){return function(response){return _this.items=_this.items.concat(response.get("data")),_this._checkIfHasMorePages(response.get("next")),_this._checkIfHasNoResults(),_this._disableLoadingSpinner(),_this.items}}(this))["catch"](function(_this){return function(){return _this._disableLoadingSpinner(),_this.items}}(this))},FavsBaseController.prototype.filterByTextQuery=debounceLeading(500,function(){return this._resetList(),this.loadItems()}),FavsBaseController.prototype.showAll=function(){return null!==this.type?(this.type=null,this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showProjectsOnly=function(){return"project"!==this.type?(this.type="project",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showUserStoriesOnly=function(){return"userstory"!==this.type?(this.type="userstory",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showTasksOnly=function(){return"task"!==this.type?(this.type="task",this._resetList(),this.loadItems()):void 0},FavsBaseController.prototype.showIssuesOnly=function(){return"issue"!==this.type?(this.type="issue",this._resetList(),this.loadItems()):void 0},FavsBaseController}(),ProfileLikedController=function(superClass){function ProfileLikedController(userService){this.userService=userService,ProfileLikedController.__super__.constructor.call(this),this.enableFilterByAll=!1,this.enableFilterByProjects=!1,this.enableFilterByUserStories=!1,this.enableFilterByTasks=!1,this.enableFilterByIssues=!1,this.enableFilterByTextQuery=!0,this._getItems=this.userService.getLiked}return extend(ProfileLikedController,superClass),ProfileLikedController.$inject=["tgUserService"],ProfileLikedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileLiked",ProfileLikedController),ProfileVotedController=function(superClass){function ProfileVotedController(userService){this.userService=userService,ProfileVotedController.__super__.constructor.call(this),this.enableFilterByAll=!0,this.enableFilterByProjects=!1,this.enableFilterByUserStories=!0,this.enableFilterByTasks=!0,this.enableFilterByIssues=!0,this.enableFilterByTextQuery=!0,this._getItems=this.userService.getVoted}return extend(ProfileVotedController,superClass),ProfileVotedController.$inject=["tgUserService"],ProfileVotedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileVoted",ProfileVotedController),ProfileWatchedController=function(superClass){function ProfileWatchedController(userService){this.userService=userService,ProfileWatchedController.__super__.constructor.call(this),this._getItems=this.userService.getWatched}return extend(ProfileWatchedController,superClass),ProfileWatchedController.$inject=["tgUserService"],ProfileWatchedController}(FavsBaseController),angular.module("taigaProfile").controller("ProfileWatched",ProfileWatchedController)}.call(this),function(){var ProfileLikedDirective,ProfileVotedDirective,ProfileWatchedDirective,base;base={scope:{},bindToController:{user:"=",type:"@",q:"@",scrollDisabled:"@",isLoading:"@",hasNoResults:"@"},controller:null,controllerAs:"vm",templateUrl:"profile/profile-favs/profile-favs.html"},ProfileLikedDirective=function(){return _.extend({},base,{controller:"ProfileLiked"})},angular.module("taigaProfile").directive("tgProfileLiked",ProfileLikedDirective),ProfileVotedDirective=function(){return _.extend({},base,{controller:"ProfileVoted"})},angular.module("taigaProfile").directive("tgProfileVoted",ProfileVotedDirective),ProfileWatchedDirective=function(){return _.extend({},base,{controller:"ProfileWatched"})},angular.module("taigaProfile").directive("tgProfileWatched",ProfileWatchedDirective)}.call(this),function(){var ProfileHints;ProfileHints=function(){function ProfileHints(translate){var hintKey;this.translate=translate,hintKey=Math.floor(Math.random()*this.HINTS.length)+1,this.hint=this.HINTS[hintKey-1],this.hint.linkText=this.hint.linkText||"HINTS.LINK",this.hint.title=this.translate.instant("HINTS.HINT"+hintKey+"_TITLE"),this.hint.text=this.translate.instant("HINTS.HINT"+hintKey+"_TEXT")}return ProfileHints.prototype.HINTS=[{url:"https://taiga.io/support/import-export-projects/"},{url:"https://taiga.io/support/custom-fields/"},{},{}],ProfileHints}(),ProfileHints.$inject=["$translate"],angular.module("taigaProfile").controller("ProfileHints",ProfileHints)}.call(this),function(){var ProfileHints;ProfileHints=function($translate){return{scope:{},controller:"ProfileHints",controllerAs:"vm",templateUrl:"profile/profile-hints/profile-hints.html"}},ProfileHints.$inject=["$translate"],angular.module("taigaProfile").directive("tgProfileHints",ProfileHints)}.call(this),function(){var ProfileProjectsController;ProfileProjectsController=function(){function ProfileProjectsController(projectsService,userService){this.projectsService=projectsService,this.userService=userService}return ProfileProjectsController.$inject=["tgProjectsService","tgUserService"],ProfileProjectsController.prototype.loadProjects=function(){return this.projectsService.getProjectsByUserId(this.user.get("id")).then(function(_this){return function(projects){return _this.userService.attachUserContactsToProjects(_this.user.get("id"),projects)}}(this)).then(function(_this){return function(projects){return _this.projects=projects}}(this))},ProfileProjectsController}(),angular.module("taigaProfile").controller("ProfileProjects",ProfileProjectsController)}.call(this),function(){var ProfileProjectsDirective;ProfileProjectsDirective=function(){var link;return link=function(scope,elm,attr,ctrl){return ctrl.loadProjects()},{templateUrl:"profile/profile-projects/profile-projects.html",scope:{user:"="},link:link,bindToController:!0,controllerAs:"vm",controller:"ProfileProjects"}},angular.module("taigaProfile").directive("tgProfileProjects",ProfileProjectsDirective)}.call(this),function(){var ProfileTabDirective;ProfileTabDirective=function(){var link;return link=function(scope,element,attrs,ctrl,transclude){return scope.tab={},attrs.$observe("tgProfileTab",function(name){return scope.tab.name=name}),attrs.$observe("tabTitle",function(title){return scope.tab.title=title}),scope.tab.icon=attrs.tabIcon,scope.tab.active=!!attrs.tabActive,scope.$eval(attrs.tabDisabled)!==!0?ctrl.addTab(scope.tab):void 0},{templateUrl:"profile/profile-tab/profile-tab.html",scope:{},require:"^tgProfileTabs",link:link,transclude:!0}},angular.module("taigaProfile").directive("tgProfileTab",ProfileTabDirective)}.call(this),function(){var ProfileTabsController;ProfileTabsController=function(){function ProfileTabsController(){this.tabs=[]}return ProfileTabsController.prototype.addTab=function(tab){return this.tabs.push(tab)},ProfileTabsController.prototype.toggleTab=function(tab){return _.map(this.tabs,function(tab){return tab.active=!1}),tab.active=!0},ProfileTabsController}(),angular.module("taigaProfile").controller("ProfileTabs",ProfileTabsController)}.call(this),function(){var ProfileTabsDirective;ProfileTabsDirective=function(){return{scope:{},controller:"ProfileTabs",controllerAs:"vm",templateUrl:"profile/profile-tabs/profile-tabs.html",transclude:!0}},angular.module("taigaProfile").directive("tgProfileTabs",ProfileTabsDirective)}.call(this),function(){var ProfileController;ProfileController=function(){function ProfileController(appMetaService,currentUserService,routeParams,userService,xhrError,translate){this.appMetaService=appMetaService,this.currentUserService=currentUserService,this.routeParams=routeParams,this.userService=userService,this.xhrError=xhrError,this.translate=translate,this.isCurrentUser=!1,this.routeParams.slug?this.userService.getUserByUserName(this.routeParams.slug).then(function(_this){return function(user){return user.get("is_active")?(_this.user=user,_this.isCurrentUser=!1,_this._setMeta(_this.user),user):_this.xhrError.notFound()}}(this))["catch"](function(_this){return function(xhr){return _this.xhrError.response(xhr)}}(this)):(this.user=this.currentUserService.getUser(),this.isCurrentUser=!0,this._setMeta(this.user))}return ProfileController.$inject=["tgAppMetaService","tgCurrentUserService","$routeParams","tgUserService","tgXhrErrorService","$translate"],ProfileController.prototype._setMeta=function(user){var ctx,description,title;return ctx={userFullName:user.get("full_name_display"),userUsername:user.get("username")},title=this.translate.instant("USER.PROFILE.PAGE_TITLE",ctx),description=user.get("bio"),this.appMetaService.setAll(title,description)},ProfileController}(),angular.module("taigaProfile").controller("Profile",ProfileController)}.call(this),function(){var LikeProjectButtonController;LikeProjectButtonController=function(){function LikeProjectButtonController(confirm,likeButtonService){this.confirm=confirm,this.likeButtonService=likeButtonService,this.isMouseOver=!1,this.loading=!1}return LikeProjectButtonController.$inject=["$tgConfirm","tgLikeProjectButtonService"],LikeProjectButtonController.prototype.showTextWhenMouseIsOver=function(){return this.isMouseOver=!0},LikeProjectButtonController.prototype.showTextWhenMouseIsLeave=function(){return this.isMouseOver=!1},LikeProjectButtonController.prototype.toggleLike=function(){var promise;return this.loading=!0,promise=this.project.get("is_fan")?this._unlike():this._like(),promise["finally"](function(_this){return function(){return _this.loading=!1}}(this)),promise},LikeProjectButtonController.prototype._like=function(){return this.likeButtonService.like(this.project.get("id")).then(function(_this){return function(){return _this.showTextWhenMouseIsLeave()}}(this))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))},LikeProjectButtonController.prototype._unlike=function(){return this.likeButtonService.unlike(this.project.get("id"))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))},LikeProjectButtonController}(),angular.module("taigaProjects").controller("LikeProjectButton",LikeProjectButtonController)}.call(this),function(){var LikeProjectButtonDirective;LikeProjectButtonDirective=function(){return{scope:{},controller:"LikeProjectButton",bindToController:{project:"="},controllerAs:"vm",templateUrl:"projects/components/like-project-button/like-project-button.html"}},angular.module("taigaProjects").directive("tgLikeProjectButton",LikeProjectButtonDirective)}.call(this),function(){var LikeProjectButtonService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,LikeProjectButtonService=function(superClass){function LikeProjectButtonService(rs,currentUserService,projectService){this.rs=rs,this.currentUserService=currentUserService,this.projectService=projectService}return extend(LikeProjectButtonService,superClass),LikeProjectButtonService.$inject=["tgResources","tgCurrentUserService","tgProjectService"],LikeProjectButtonService.prototype._getProjectIndex=function(projectId){return this.currentUserService.projects.get("all").findIndex(function(project){return project.get("id")===projectId})},LikeProjectButtonService.prototype._updateProjects=function(projectId,isFan){var projectIndex,projects;return projectIndex=this._getProjectIndex(projectId),-1!==projectIndex?(projects=this.currentUserService.projects.get("all").update(projectIndex,function(project){var totalFans;return totalFans=project.get("total_fans"),isFan?totalFans++:totalFans--,project.merge({is_fan:isFan,total_fans:totalFans})}),this.currentUserService.setProjects(projects)):void 0},LikeProjectButtonService.prototype._updateCurrentProject=function(isFan){var project,totalFans;return totalFans=this.projectService.project.get("total_fans"),isFan?totalFans++:totalFans--,project=this.projectService.project.merge({is_fan:isFan,total_fans:totalFans}),this.projectService.setProject(project)},LikeProjectButtonService.prototype.like=function(projectId){return this.rs.projects.likeProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,!0),_this._updateCurrentProject(!0)}}(this))},LikeProjectButtonService.prototype.unlike=function(projectId){return this.rs.projects.unlikeProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,!1),_this._updateCurrentProject(!1)}}(this))},LikeProjectButtonService}(taiga.Service),angular.module("taigaProjects").service("tgLikeProjectButtonService",LikeProjectButtonService)}.call(this),function(){var SortProjectsDirective;SortProjectsDirective=function(currentUserService){var directive,link;return link=function(scope,el,attrs,ctrl){var itemEl;return itemEl=null,el.sortable({dropOnEmpty:!0,revert:200,axis:"y",opacity:.95,placeholder:"placeholder",cancel:".project-name"}),el.on("sortstop",function(event,ui){var i,index,len,project,sortData,sorted_project_ids,value;for(itemEl=ui.item,project=itemEl.scope().project,index=itemEl.index(),sorted_project_ids=_.map(scope.projects.toJS(),function(p){return p.id}),sorted_project_ids=_.without(sorted_project_ids,project.get("id")),sorted_project_ids.splice(index,0,project.get("id")),sortData=[],index=i=0,len=sorted_project_ids.length;len>i;index=++i)value=sorted_project_ids[index],sortData.push({project_id:value,order:index});return currentUserService.bulkUpdateProjectsOrder(sortData)})},directive={scope:{projects:"=tgSortProjects"},link:link}},angular.module("taigaProjects").directive("tgSortProjects",["tgCurrentUserService",SortProjectsDirective])}.call(this),function(){var WatchProjectButtonController;WatchProjectButtonController=function(){function WatchProjectButtonController(confirm,watchButtonService){this.confirm=confirm,this.watchButtonService=watchButtonService,this.showWatchOptions=!1,this.loading=!1}return WatchProjectButtonController.$inject=["$tgConfirm","tgWatchProjectButtonService"],WatchProjectButtonController.prototype.toggleWatcherOptions=function(){return this.showWatchOptions=!this.showWatchOptions},WatchProjectButtonController.prototype.closeWatcherOptions=function(){return this.showWatchOptions=!1},WatchProjectButtonController.prototype.watch=function(notifyLevel){return notifyLevel!==this.project.get("notify_level")?(this.loading=!0,this.closeWatcherOptions(),this.watchButtonService.watch(this.project.get("id"),notifyLevel)["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))["finally"](function(_this){return function(){return _this.loading=!1}}(this))):void 0},WatchProjectButtonController.prototype.unwatch=function(){return this.loading=!0,this.closeWatcherOptions(),this.watchButtonService.unwatch(this.project.get("id"))["catch"](function(_this){return function(){return _this.confirm.notify("error")}}(this))["finally"](function(_this){return function(){return _this.loading=!1}}(this))},WatchProjectButtonController}(),angular.module("taigaProjects").controller("WatchProjectButton",WatchProjectButtonController)}.call(this),function(){var WatchProjectButtonDirective;WatchProjectButtonDirective=function(){return{scope:{},controller:"WatchProjectButton",bindToController:{project:"="},controllerAs:"vm",templateUrl:"projects/components/watch-project-button/watch-project-button.html"}},angular.module("taigaProjects").directive("tgWatchProjectButton",WatchProjectButtonDirective)}.call(this),function(){var WatchProjectButtonService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,WatchProjectButtonService=function(superClass){function WatchProjectButtonService(rs,currentUserService,projectService){this.rs=rs,this.currentUserService=currentUserService,this.projectService=projectService}return extend(WatchProjectButtonService,superClass),WatchProjectButtonService.$inject=["tgResources","tgCurrentUserService","tgProjectService"],WatchProjectButtonService.prototype._getProjectIndex=function(projectId){return this.currentUserService.projects.get("all").findIndex(function(project){return project.get("id")===projectId})},WatchProjectButtonService.prototype._updateProjects=function(projectId,notifyLevel,isWatcher){var projectIndex,projects;return projectIndex=this._getProjectIndex(projectId),-1!==projectIndex?(projects=this.currentUserService.projects.get("all").update(projectIndex,function(_this){return function(project){var totalWatchers;return totalWatchers=project.get("total_watchers"),!_this.projectService.project.get("is_watcher")&&isWatcher?totalWatchers++:_this.projectService.project.get("is_watcher")&&!isWatcher&&totalWatchers--,project.merge({is_watcher:isWatcher,total_watchers:totalWatchers,notify_level:notifyLevel})}}(this)),this.currentUserService.setProjects(projects)):void 0},WatchProjectButtonService.prototype._updateCurrentProject=function(notifyLevel,isWatcher){var project,totalWatchers;return totalWatchers=this.projectService.project.get("total_watchers"),!this.projectService.project.get("is_watcher")&&isWatcher?totalWatchers++:this.projectService.project.get("is_watcher")&&!isWatcher&&totalWatchers--,project=this.projectService.project.merge({is_watcher:isWatcher,notify_level:notifyLevel,total_watchers:totalWatchers}),this.projectService.setProject(project)},WatchProjectButtonService.prototype.watch=function(projectId,notifyLevel){return this.rs.projects.watchProject(projectId,notifyLevel).then(function(_this){return function(){return _this._updateProjects(projectId,notifyLevel,!0),_this._updateCurrentProject(notifyLevel,!0)}}(this))},WatchProjectButtonService.prototype.unwatch=function(projectId){return this.rs.projects.unwatchProject(projectId).then(function(_this){return function(){return _this._updateProjects(projectId,null,!1),_this._updateCurrentProject(null,!1)}}(this))},WatchProjectButtonService}(taiga.Service),angular.module("taigaProjects").service("tgWatchProjectButtonService",WatchProjectButtonService)}.call(this),function(){var ProjectsListingController;ProjectsListingController=function(){function ProjectsListingController(currentUserService,projectsService){this.currentUserService=currentUserService,this.projectsService=projectsService,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this.currentUserService.projects.get("all")}}(this))}return ProjectsListingController.$inject=["tgCurrentUserService","tgProjectsService"],ProjectsListingController.prototype.newProject=function(){return this.projectsService.newProject()},ProjectsListingController}(),angular.module("taigaProjects").controller("ProjectsListing",ProjectsListingController)}.call(this),function(){var ProjectController;ProjectController=function(){function ProjectController(routeParams,appMetaService,auth,translate,projectService){var projectSlug;this.routeParams=routeParams,this.appMetaService=appMetaService,this.auth=auth,this.translate=translate,this.projectService=projectService,projectSlug=this.routeParams.pslug,this.user=this.auth.userData,taiga.defineImmutableProperty(this,"project",function(_this){return function(){return _this.projectService.project}}(this)),taiga.defineImmutableProperty(this,"members",function(_this){return function(){return _this.projectService.activeMembers}}(this)),this.appMetaService.setfn(this._setMeta.bind(this))}return ProjectController.$inject=["$routeParams","tgAppMetaService","$tgAuth","$translate","tgProjectService"],ProjectController.prototype._setMeta=function(project){var ctx,metas;return this.project?(metas={},ctx={projectName:this.project.get("name")},metas.title=this.translate.instant("PROJECT.PAGE_TITLE",ctx),metas.description=this.project.get("description"),metas):null},ProjectController}(),angular.module("taigaProjects").controller("Project",ProjectController)}.call(this),function(){var ProjectsService,groupBy,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,groupBy=this.taiga.groupBy,ProjectsService=function(superClass){function ProjectsService(rs,projectUrl,lightboxFactory){this.rs=rs,this.projectUrl=projectUrl,this.lightboxFactory=lightboxFactory}return extend(ProjectsService,superClass),ProjectsService.$inject=["tgResources","$projectUrl","tgLightboxFactory"],ProjectsService.prototype.getProjectBySlug=function(projectSlug){return this.rs.projects.getProjectBySlug(projectSlug).then(function(_this){return function(project){return _this._decorate(project)}}(this))},ProjectsService.prototype.getProjectStats=function(projectId){return this.rs.projects.getProjectStats(projectId)},ProjectsService.prototype.getProjectsByUserId=function(userId,paginate){return this.rs.projects.getProjectsByUserId(userId,paginate).then(function(_this){return function(projects){return projects.map(_this._decorate.bind(_this))}}(this))},ProjectsService.prototype._decorate=function(project){var colorized_tags,tags,url;return url=this.projectUrl.get(project.toJS()),project=project.set("url",url),colorized_tags=[],project.get("tags")&&(tags=project.get("tags").sort(),colorized_tags=tags.map(function(tag){var color;return color=project.get("tags_colors").get(tag),Immutable.fromJS({name:tag,color:color})}),project=project.set("colorized_tags",colorized_tags)),project},ProjectsService.prototype.newProject=function(){return this.lightboxFactory.create("tg-lb-create-project",{"class":"wizard-create-project"})},ProjectsService.prototype.bulkUpdateProjectsOrder=function(sortData){return this.rs.projects.bulkUpdateOrder(sortData)},ProjectsService}(taiga.Service),angular.module("taigaProjects").service("tgProjectsService",ProjectsService)}.call(this),function(){var Resource,module,sizeFormat,taiga;taiga=this.taiga,sizeFormat=this.taiga.sizeFormat,Resource=function(urlsService,http,config,$rootScope,$q,storage){var service;return service={},service.list=function(type,objectId,projectId){var httpOptions,params,url,urlname;return urlname="attachments/"+type,params={object_id:objectId,project:projectId},httpOptions={headers:{"x-disable-pagination":"1"}},url=urlsService.resolve(urlname),http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service["delete"]=function(type,id){var url,urlname;return urlname="attachments/"+type, +url=urlsService.resolve(urlname)+("/"+id),http["delete"](url)},service.patch=function(type,id,patch){var url,urlname;return urlname="attachments/"+type,url=urlsService.resolve(urlname)+("/"+id),http.patch(url,patch)},service.create=function(type,projectId,objectId,file){var data,defered,maxFileSize,response,token,uploadComplete,uploadFailed,uploadProgress,url,urlname,xhr;return urlname="attachments/"+type,url=urlsService.resolve(urlname),defered=$q.defer(),void 0===file?(defered.reject(null),defered.promise):(maxFileSize=config.get("maxUploadFileSize",null),maxFileSize&&file.size>maxFileSize?(response={status:413,data:{_error_message:"'"+file.name+"' ("+sizeFormat(file.size)+") is too heavy for our oompa loompas, try it with a smaller than ("+sizeFormat(maxFileSize)+")"}},defered.reject(response),defered.promise):(uploadProgress=function(_this){return function(evt){return $rootScope.$apply(function(){return file.status="in-progress",file.size=sizeFormat(evt.total),file.progressMessage="upload "+sizeFormat(evt.loaded)+" of "+sizeFormat(evt.total),file.progressPercent=Math.round(evt.loaded/evt.total*100)+"%"})}}(this),uploadComplete=function(_this){return function(evt){return $rootScope.$apply(function(){var attachment,ref,status;file.status="done",status=evt.target.status;try{attachment=JSON.parse(evt.target.responseText)}catch(error){attachment={}}return status>=200&&400>status?(attachment=Immutable.fromJS(attachment),defered.resolve(attachment)):(response={status:status,data:{_error_message:null!=(ref=data.attached_file)?ref[0]:void 0}},defered.reject(response))})}}(this),uploadFailed=function(_this){return function(evt){return $rootScope.$apply(function(){return file.status="error",defered.reject("fail")})}}(this),data=new FormData,data.append("project",projectId),data.append("object_id",objectId),data.append("attached_file",file),xhr=new XMLHttpRequest,xhr.upload.addEventListener("progress",uploadProgress,!1),xhr.addEventListener("load",uploadComplete,!1),xhr.addEventListener("error",uploadFailed,!1),token=storage.get("token"),xhr.open("POST",url),xhr.setRequestHeader("Authorization","Bearer "+token),xhr.setRequestHeader("Accept","application/json"),xhr.send(data),defered.promise))},function(){return{attachments:service}}},Resource.$inject=["$tgUrls","$tgHttp","$tgConfig","$rootScope","$q","$tgStorage"],module=angular.module("taigaResources2"),module.factory("tgAttachmentsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.getApplicationToken=function(applicationId,state){var url;return url=urlsService.resolve("applications"),url=url+"/"+applicationId+"/token?state="+state,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.authorizeApplicationToken=function(applicationId,state){var data,url;return url=urlsService.resolve("application-tokens"),url+="/authorize",data={state:state,application:applicationId},http.post(url,data).then(function(result){return Immutable.fromJS(result.data)})},function(){return{externalapps:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgExternalAppsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("issues"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{issues:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgIssuesResource",Resource)}.call(this),function(){var Resource,module,pagination;pagination=function(){},Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getProjects=function(params,pagination){var httpOptions,url;return null==params&&(params={}),null==pagination&&(pagination=!0),url=urlsService.resolve("projects"),httpOptions={},pagination||(httpOptions={headers:{"x-lazy-pagination":!0}}),http.get(url,params,httpOptions)},service.getProjectBySlug=function(projectSlug){var url;return url=urlsService.resolve("projects"),url=url+"/by_slug?slug="+projectSlug,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.getProjectsByUserId=function(userId,paginate){var httpOptions,params,url;return null==paginate&&(paginate=!1),url=urlsService.resolve("projects"),httpOptions={},paginate||(httpOptions.headers={"x-disable-pagination":"1"}),params={member:userId,order_by:"memberships__user_order"},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getProjectStats=function(projectId){var url;return url=urlsService.resolve("projects"),url=url+"/"+projectId,http.get(url).then(function(result){return Immutable.fromJS(result.data)})},service.bulkUpdateOrder=function(bulkData){var url;return url=urlsService.resolve("bulk-update-projects-order"),http.post(url,bulkData)},service.getTimeline=function(projectId,page){var params,url;return params={page:page,only_relevant:!0},url=urlsService.resolve("timeline-project"),url=url+"/"+projectId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.likeProject=function(projectId){var url;return url=urlsService.resolve("project-like",projectId),http.post(url)},service.unlikeProject=function(projectId){var url;return url=urlsService.resolve("project-unlike",projectId),http.post(url)},service.watchProject=function(projectId,notifyLevel){var data,url;return data={notify_level:notifyLevel},url=urlsService.resolve("project-watch",projectId),http.post(url,data)},service.unwatchProject=function(projectId){var url;return url=urlsService.resolve("project-unwatch",projectId),http.post(url)},function(){return{projects:service}}},Resource.$inject=["$tgUrls","$tgHttp","tgPaginateResponseService"],module=angular.module("taigaResources2"),module.factory("tgProjectsResources",Resource)}.call(this),function(){var Resources,services;services=["tgProjectsResources","tgUserResources","tgUsersResources","tgUserstoriesResource","tgTasksResource","tgIssuesResource","tgExternalAppsResource","tgAttachmentsResource","tgStatsResource"],Resources=function($injector){var i,j,len,len1,ref,service,serviceFn,serviceName,serviceProperty;for(i=0,len=services.length;len>i;i++)for(serviceName=services[i],serviceFn=$injector.get(serviceName),service=$injector.invoke(serviceFn),ref=Object.keys(service),j=0,len1=ref.length;len1>j;j++)serviceProperty=ref[j],this[serviceProperty]&&console.warm("repeated resource "+serviceProperty),this[serviceProperty]=service[serviceProperty];return this},Resources.$inject=["$injector"],angular.module("taigaResources2").service("tgResources",Resources)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.discover=function(applicationId,state){var url;return url=urlsService.resolve("stats-discover"),http.get(url).then(function(result){return Immutable.fromJS(result.data)})},function(){return{stats:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgStatsResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("tasks"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{tasks:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgTasksResource",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getUserStorage=function(key){var httpOptions,url;return url=urlsService.resolve("user-storage"),key&&(url+="/"+key),httpOptions={},http.get(url,{}).then(function(response){return response.data.value})},service.setUserStorage=function(key,value){var params,url;return url=urlsService.resolve("user-storage")+"/"+key,params={key:key,value:value},http.put(url,params)},service.createUserStorage=function(key,value){var params,url;return url=urlsService.resolve("user-storage"),params={key:key,value:value},http.post(url,params)},function(){return{user:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgUserResources",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http,paginateResponseService){var service;return service={},service.getUserByUsername=function(username){var httpOptions,params,url;return url=urlsService.resolve("by_username"),httpOptions={headers:{"x-disable-pagination":"1"}},params={username:username},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getStats=function(userId){var httpOptions,url;return url=urlsService.resolve("user-stats",userId),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,{},httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getContacts=function(userId){var httpOptions,url;return url=urlsService.resolve("user-contacts",userId),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,{},httpOptions).then(function(result){return Immutable.fromJS(result.data)})},service.getLiked=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-liked",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),params.only_relevant=!0,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getVoted=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-voted",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getWatched=function(userId,page,type,q){var params,url;return url=urlsService.resolve("user-watched",userId),params={},null!=page&&(params.page=page),null!=type&&(params.type=type),null!=q&&(params.q=q),http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getProfileTimeline=function(userId,page){var params,url;return params={page:page},url=urlsService.resolve("timeline-profile"),url=url+"/"+userId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},service.getUserTimeline=function(userId,page){var params,url;return params={page:page,only_relevant:!0},url=urlsService.resolve("timeline-user"),url=url+"/"+userId,http.get(url,params,{headers:{"x-lazy-pagination":!0}}).then(function(result){return result=Immutable.fromJS(result),paginateResponseService(result)})},function(){return{users:service}}},Resource.$inject=["$tgUrls","$tgHttp","tgPaginateResponseService"],module=angular.module("taigaResources2"),module.factory("tgUsersResources",Resource)}.call(this),function(){var Resource,module;Resource=function(urlsService,http){var service;return service={},service.listInAllProjects=function(params){var httpOptions,url;return url=urlsService.resolve("userstories"),httpOptions={headers:{"x-disable-pagination":"1"}},http.get(url,params,httpOptions).then(function(result){return Immutable.fromJS(result.data)})},function(){return{userstories:service}}},Resource.$inject=["$tgUrls","$tgHttp"],module=angular.module("taigaResources2"),module.factory("tgUserstoriesResource",Resource)}.call(this),function(){var AppMetaService,taiga,truncate;taiga=this.taiga,truncate=taiga.truncate,AppMetaService=function(){function AppMetaService(rootScope){this.rootScope=rootScope}return AppMetaService.$inject=["$rootScope"],AppMetaService.prototype._set=function(key,value){var meta;if(key)return"title"===key?(meta=$("title"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.text(value||"")):0===key.indexOf("og:")?(meta=$("meta[property='"+key+"']"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.attr("content",value||"")):(meta=$("meta[name='"+key+"']"),0===meta.length&&(meta=$(""),$("head").append(meta)),meta.attr("content",value||""))},AppMetaService.prototype.setTitle=function(title){return this._set("title",title)},AppMetaService.prototype.setDescription=function(description){return this._set("description",truncate(description,250))},AppMetaService.prototype.setTwitterMetas=function(title,description){return this._set("twitter:card","summary"),this._set("twitter:site","@taigaio"),this._set("twitter:title",title),this._set("twitter:description",truncate(description,300)),this._set("twitter:image",window.location.origin+"/"+window._version+"/images/logo-color.png")},AppMetaService.prototype.setOpenGraphMetas=function(title,description){return this._set("og:type","object"),this._set("og:site_name","Taiga - Love your projects"),this._set("og:title",title),this._set("og:description",truncate(description,300)),this._set("og:image",window.location.origin+"/"+window._version+"/images/logo-color.png"),this._set("og:url",window.location.href)},AppMetaService.prototype.setAll=function(title,description){return this.setTitle(title),this.setDescription(description),this.setTwitterMetas(title,description),this.setOpenGraphMetas(title,description)},AppMetaService.prototype.addMobileViewport=function(){return $("head").append('')},AppMetaService.prototype.removeMobileViewport=function(){return $('meta[name="viewport"]').remove()},AppMetaService.prototype.setfn=function(fn){return this.listener&&this._listener(),this._listener=this.rootScope.$watchCollection(fn,function(_this){return function(metas){return metas?(_this.setAll(metas.title,metas.description),_this._listener()):void 0}}(this))},AppMetaService}(),angular.module("taigaCommon").service("tgAppMetaService",AppMetaService)}.call(this),function(){var AttachmentsService,sizeFormat;sizeFormat=this.taiga.sizeFormat,AttachmentsService=function(){function AttachmentsService(confirm,config,translate,rs){this.confirm=confirm,this.config=config,this.translate=translate,this.rs=rs,this.maxFileSize=this.getMaxFileSize(),this.maxFileSize&&(this.maxFileSizeFormated=sizeFormat(this.maxFileSize))}return AttachmentsService.$inject=["$tgConfirm","$tgConfig","$translate","tgResources"],AttachmentsService.prototype.sizeError=function(file){var message;return message=this.translate.instant("ATTACHMENT.ERROR_MAX_SIZE_EXCEEDED",{fileName:file.name,fileSize:sizeFormat(file.size),maxFileSize:this.maxFileSizeFormated}),this.confirm.notify("error",message)},AttachmentsService.prototype.validate=function(file){return this.maxFileSize&&file.size>this.maxFileSize?(this.sizeError(file),!1):!0},AttachmentsService.prototype.getMaxFileSize=function(){return this.config.get("maxUploadFileSize",null)},AttachmentsService.prototype.list=function(type,objId,projectId){return this.rs.attachments.list(type,objId,projectId).then(function(_this){return function(attachments){return attachments.sortBy(function(attachment){return attachment.get("order")})}}(this))},AttachmentsService.prototype["delete"]=function(type,id){return this.rs.attachments["delete"](type,id)},AttachmentsService.prototype.saveError=function(file,data){var message;return message="",file&&(message=this.translate.instant("ATTACHMENT.ERROR_UPLOAD_ATTACHMENT",{fileName:file.name,errorMessage:data.data._error_message})),this.confirm.notify("error",message)},AttachmentsService.prototype.upload=function(file,objId,projectId,type){var promise;return promise=this.rs.attachments.create(type,projectId,objId,file),promise.then(null,this.saveError.bind(this,file)),promise},AttachmentsService.prototype.patch=function(id,type,patch){var promise;return promise=this.rs.attachments.patch(type,id,patch),promise.then(null,this.saveError.bind(this,null)),promise},AttachmentsService}(),angular.module("taigaCommon").service("tgAttachmentsService",AttachmentsService)}.call(this),function(){var ChekcPermissionsService,taiga;taiga=this.taiga,ChekcPermissionsService=function(){function ChekcPermissionsService(projectService){this.projectService=projectService}return ChekcPermissionsService.$inject=["tgProjectService"],ChekcPermissionsService.prototype.check=function(permission){return-1!==this.projectService.project.get("my_permissions").indexOf(permission)},ChekcPermissionsService}(),angular.module("taigaCommon").service("tgCheckPermissionsService",ChekcPermissionsService)}.call(this),function(){var CurrentUserService,groupBy,taiga;taiga=this.taiga,groupBy=this.taiga.groupBy,CurrentUserService=function(){function CurrentUserService(projectsService,storageService,rs){this.projectsService=projectsService,this.storageService=storageService,this.rs=rs,this._user=null,this._projects=Immutable.Map(),this._projectsById=Immutable.Map(),this._joyride=null,taiga.defineImmutableProperty(this,"projects",function(_this){return function(){return _this._projects}}(this)),taiga.defineImmutableProperty(this,"projectsById",function(_this){return function(){return _this._projectsById}}(this))}return CurrentUserService.$inject=["tgProjectsService","$tgStorage","tgResources"],CurrentUserService.prototype.isAuthenticated=function(){return null!==this.getUser()?!0:!1},CurrentUserService.prototype.getUser=function(){var userData;return this._user||(userData=this.storageService.get("userInfo"),userData&&(userData=Immutable.fromJS(userData),this.setUser(userData))),this._user},CurrentUserService.prototype.removeUser=function(){return this._user=null,this._projects=Immutable.Map(),this._projectsById=Immutable.Map(),this._joyride=null},CurrentUserService.prototype.setUser=function(user){return this._user=user,this._loadUserInfo()},CurrentUserService.prototype.bulkUpdateProjectsOrder=function(sortData){return this.projectsService.bulkUpdateProjectsOrder(sortData).then(function(_this){return function(){return _this.loadProjects()}}(this))},CurrentUserService.prototype.loadProjects=function(){return this.projectsService.getProjectsByUserId(this._user.get("id")).then(function(_this){return function(projects){return _this.setProjects(projects)}}(this))},CurrentUserService.prototype.disableJoyRide=function(section){return section?this._joyride[section]=!1:this._joyride={backlog:!1,kanban:!1,dashboard:!1},this.rs.user.setUserStorage("joyride",this._joyride)},CurrentUserService.prototype.loadJoyRideConfig=function(){return new Promise(function(_this){return function(resolve){return null!==_this._joyride?void resolve(_this._joyride):_this.rs.user.getUserStorage("joyride").then(function(config){return _this._joyride=config,resolve(_this._joyride)})["catch"](function(){return _this._joyride={backlog:!0,kanban:!0,dashboard:!0},_this.rs.user.createUserStorage("joyride",_this._joyride),resolve(_this._joyride)})}}(this))},CurrentUserService.prototype._loadUserInfo=function(){return Promise.all([this.loadProjects()])},CurrentUserService.prototype.setProjects=function(projects){return this._projects=this._projects.set("all",projects),this._projects=this._projects.set("recents",projects.slice(0,10)),this._projectsById=Immutable.fromJS(groupBy(projects.toJS(),function(p){return p.id})),this.projects},CurrentUserService}(),angular.module("taigaCommon").service("tgCurrentUserService",CurrentUserService)}.call(this),function(){var LightboxFactory;LightboxFactory=function(){function LightboxFactory(rootScope,compile){this.rootScope=rootScope,this.compile=compile}return LightboxFactory.$inject=["$rootScope","$compile"],LightboxFactory.prototype.create=function(name,attrs,scopeAttrs){var elm,html,scope;scope=this.rootScope.$new(),scope=_.merge(scope,scopeAttrs),elm=$("
").attr(name,!0).attr("tg-bind-scope",!0),attrs&&elm.attr(attrs),elm.addClass("remove-on-close"),html=this.compile(elm)(scope),$(document.body).append(html)},LightboxFactory}(),angular.module("taigaCommon").service("tgLightboxFactory",LightboxFactory)}.call(this),function(){var PaginateResponse;PaginateResponse=function(){return function(result){var paginateResponse;return paginateResponse=Immutable.Map({data:result.get("data"),next:!!result.get("headers")("x-pagination-next"),prev:!!result.get("headers")("x-pagination-prev"),current:result.get("headers")("x-pagination-current"),count:result.get("headers")("x-pagination-count")})}},angular.module("taigaCommon").factory("tgPaginateResponseService",PaginateResponse)}.call(this),function(){var ProjectService,taiga;taiga=this.taiga,ProjectService=function(){function ProjectService(projectsService,xhrError){this.projectsService=projectsService,this.xhrError=xhrError,this._project=null,this._section=null,this._sectionsBreadcrumb=Immutable.List(),this._activeMembers=Immutable.List(),taiga.defineImmutableProperty(this,"project",function(_this){return function(){return _this._project}}(this)),taiga.defineImmutableProperty(this,"section",function(_this){return function(){return _this._section}}(this)),taiga.defineImmutableProperty(this,"sectionsBreadcrumb",function(_this){return function(){return _this._sectionsBreadcrumb}}(this)),taiga.defineImmutableProperty(this,"activeMembers",function(_this){return function(){return _this._activeMembers}}(this))}return ProjectService.$inject=["tgProjectsService","tgXhrErrorService"],ProjectService.prototype.setSection=function(section){return this._section=section,section?this._sectionsBreadcrumb=this._sectionsBreadcrumb.push(this._section):this._sectionsBreadcrumb=Immutable.List()},ProjectService.prototype.setProjectBySlug=function(pslug){return new Promise(function(_this){return function(resolve,reject){return _this.project&&_this.project.get("slug")===pslug?resolve():_this.projectsService.getProjectBySlug(pslug).then(function(project){return _this.setProject(project),resolve()})["catch"](function(xhr){return _this.xhrError.response(xhr)})}}(this))},ProjectService.prototype.setProject=function(project){return this._project=project,this._activeMembers=this._project.get("members").filter(function(member){return member.get("is_active")})},ProjectService.prototype.cleanProject=function(){return this._project=null,this._activeMembers=Immutable.List(),this._section=null,this._sectionsBreadcrumb=Immutable.List()},ProjectService.prototype.hasPermission=function(permission){return-1!==this._project.get("my_permissions").indexOf(permission)},ProjectService.prototype.fetchProject=function(){var pslug;return pslug=this.project.get("slug"),this.projectsService.getProjectBySlug(pslug).then(function(_this){return function(project){return _this.setProject(project)}}(this))},ProjectService}(),angular.module("taigaCommon").service("tgProjectService",ProjectService)}.call(this),function(){var ScopeEvent;ScopeEvent=function(){function ScopeEvent(){}return ScopeEvent.prototype.scopes={},ScopeEvent.prototype._searchDuplicatedScopes=function(id){return _.find(Object.keys(this.scopes),function(_this){return function(key){return _this.scopes[key].$id===id}}(this))},ScopeEvent.prototype._create=function(name,scope){var duplicatedScopeName;if(duplicatedScopeName=this._searchDuplicatedScopes(scope.$id))throw new Error('scopeEvent: this scope is already register with the name "'+duplicatedScopeName+'"');if(this.scopes[name])throw new Error('scopeEvent: "'+name+'" already in use');return scope._tgEmitter=new EventEmitter2,scope.$on("$destroy",function(_this){return function(){return scope._tgEmitter.removeAllListeners(),delete _this.scopes[name]}}(this)),this.scopes[name]=scope},ScopeEvent.prototype.emitter=function(name,scope){if(scope)scope=this._create(name,scope);else{if(!this.scopes[name])throw new Error('scopeEvent: "'+name+"\" scope doesn't exist'");scope=this.scopes[name]}return scope._tgEmitter},ScopeEvent}(),angular.module("taigaCommon").service("tgScopeEvent",ScopeEvent)}.call(this),function(){var ThemeService,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,ThemeService=function(superClass){function ThemeService(){return ThemeService.__super__.constructor.apply(this,arguments)}return extend(ThemeService,superClass),ThemeService}(taiga.Service=function(){return{use:function(themeName){var stylesheetEl;return stylesheetEl=$("link[rel='stylesheet']:first"),0===stylesheetEl.length&&(stylesheetEl=$(""),$("head").append(stylesheetEl)),stylesheetEl.attr("href","/"+window._version+"/styles/theme-"+themeName+".css")}}}),angular.module("taigaCommon").service("tgThemeService",ThemeService)}.call(this),function(){var UserService,bindMethods,taiga,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;taiga=this.taiga,bindMethods=taiga.bindMethods,UserService=function(superClass){function UserService(rs){this.rs=rs,bindMethods(this)}return extend(UserService,superClass),UserService.$inject=["tgResources"],UserService.prototype.getUserByUserName=function(username){return this.rs.users.getUserByUsername(username)},UserService.prototype.getContacts=function(userId){return this.rs.users.getContacts(userId)},UserService.prototype.getLiked=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getLiked(userId,pageNumber,objectType,textQuery)},UserService.prototype.getVoted=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getVoted(userId,pageNumber,objectType,textQuery)},UserService.prototype.getWatched=function(userId,pageNumber,objectType,textQuery){return this.rs.users.getWatched(userId,pageNumber,objectType,textQuery)},UserService.prototype.getStats=function(userId){return this.rs.users.getStats(userId)},UserService.prototype.attachUserContactsToProjects=function(userId,projects){return this.getContacts(userId).then(function(contacts){return projects=projects.map(function(project){var contactsFiltered;return contactsFiltered=contacts.filter(function(contact){var contactId;return contactId=contact.get("id"),-1!==project.get("members").indexOf(contactId)}),project=project.set("contacts",contactsFiltered)})})},UserService}(taiga.Service),angular.module("taigaCommon").service("tgUserService",UserService)}.call(this),function(){var xhrError,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;xhrError=function(superClass){function xhrError(q,location,navUrls){this.q=q,this.location=location,this.navUrls=navUrls}return extend(xhrError,superClass),xhrError.$inject=["$q","$location","$tgNavUrls"],xhrError.prototype.notFound=function(){return this.location.path(this.navUrls.resolve("not-found")),this.location.replace()},xhrError.prototype.permissionDenied=function(){return this.location.path(this.navUrls.resolve("permission-denied")),this.location.replace()},xhrError.prototype.response=function(xhr){return xhr&&(404===xhr.status?this.notFound():403===xhr.status&&this.permissionDenied()),this.q.reject(xhr)},xhrError}(taiga.Service),angular.module("taigaCommon").service("tgXhrErrorService",xhrError)}.call(this),function(){var UserTimelineAttachmentDirective;UserTimelineAttachmentDirective=function(template,$compile){var isImage,link,validFileExtensions;return validFileExtensions=[".jpg",".jpeg",".bmp",".gif",".png"],isImage=function(url){return url=url.toLowerCase(),_.some(validFileExtensions,function(extension){return-1!==url.indexOf(extension,url-extension.length)})},link=function(scope,el){var is_image,templateHtml;return is_image=isImage(scope.attachment.get("url")),templateHtml=is_image?template.get("user-timeline/user-timeline-attachment/user-timeline-attachment-image.html"):template.get("user-timeline/user-timeline-attachment/user-timeline-attachment.html"),el.html(templateHtml),$compile(el.contents())(scope),el.find("img").error(function(){return this.remove()})},{link:link,scope:{attachment:"=tgUserTimelineAttachment"}}},UserTimelineAttachmentDirective.$inject=["$tgTemplate","$compile"],angular.module("taigaUserTimeline").directive("tgUserTimelineAttachment",UserTimelineAttachmentDirective)}.call(this),function(){var UserTimelineItemTitle,unslugify;unslugify=this.taiga.unslugify,UserTimelineItemTitle=function(){function UserTimelineItemTitle(translate,sce){this.translate=translate,this.sce=sce}return UserTimelineItemTitle.$inject=["$translate","$sce"],UserTimelineItemTitle.prototype._fieldTranslationKey={status:"COMMON.FIELDS.STATUS",subject:"COMMON.FIELDS.SUBJECT",description_diff:"COMMON.FIELDS.DESCRIPTION",points:"COMMON.FIELDS.POINTS",assigned_to:"COMMON.FIELDS.ASSIGNED_TO",severity:"ISSUES.FIELDS.SEVERITY",priority:"ISSUES.FIELDS.PRIORITY",type:"ISSUES.FIELDS.TYPE",is_iocaine:"TASK.FIELDS.IS_IOCAINE",is_blocked:"COMMON.FIELDS.IS_BLOCKED"},UserTimelineItemTitle.prototype._params={username:function(timeline,event){var title_attr,url,user;return user=timeline.getIn(["data","user"]),user.get("is_profile_visible")?(title_attr=this.translate.instant("COMMON.SEE_USER_PROFILE",{username:user.get("username")}),url="user-profile:username=timeline.getIn(['data', 'user', 'username'])",this._getLink(url,user.get("name"),title_attr)):this._getUsernameSpan(user.get("name"))},field_name:function(timeline,event){var field_name;return field_name=timeline.getIn(["data","value_diff","key"]),this.translate.instant(this._fieldTranslationKey[field_name])},project_name:function(timeline,event){var url;return url="project:project=timeline.getIn(['data', 'project', 'slug'])",this._getLink(url,timeline.getIn(["data","project","name"]))},new_value:function(timeline,event){var new_value,value;return _.isArray(timeline.getIn(["data","value_diff","value"]).toJS())?(value=timeline.getIn(["data","value_diff","value"]).get(1),null===value&&"assigned_to"===timeline.getIn(["data","value_diff","key"])&&(value=this.translate.instant("ACTIVITY.VALUES.UNASSIGNED")),new_value=value):new_value=timeline.getIn(["data","value_diff","value"]).first().get(1),_.escape(new_value)},sprint_name:function(timeline,event){var url;return url="project-taskboard:project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['data', 'milestone', 'slug'])",this._getLink(url,timeline.getIn(["data","milestone","name"]))},us_name:function(timeline,event){var event_us,obj,text,url;return obj=this._getTimelineObj(timeline,event).get("userstory"),event_us={obj:"parent_userstory"},url=this._getDetailObjUrl(event_us),text="#"+obj.get("ref")+" "+obj.get("subject"),this._getLink(url,text)},obj_name:function(timeline,event){var obj,text,url;return obj=this._getTimelineObj(timeline,event),url=this._getDetailObjUrl(event),text="wikipage"===event.obj?unslugify(obj.get("slug")):"milestone"===event.obj?obj.get("name"):"#"+obj.get("ref")+" "+obj.get("subject"),this._getLink(url,text)},role_name:function(timeline,event){ +return _.escape(timeline.getIn(["data","value_diff","value"]).keySeq().first())}},UserTimelineItemTitle.prototype._translateTitleParams=function(param,timeline,event){return this._params[param].call(this,timeline,event)},UserTimelineItemTitle.prototype._getTimelineObj=function(timeline,event){return timeline.getIn(["data",event.obj])},UserTimelineItemTitle.prototype._getDetailObjUrl=function(event){var url;return url={issue:["project-issues-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],wikipage:["project-wiki-page",":project=timeline.getIn(['data', 'project', 'slug']),slug=timeline.getIn(['obj', 'slug'])"],task:["project-tasks-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],userstory:["project-userstories-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])"],parent_userstory:["project-userstories-detail",":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'userstory', 'ref'])"],milestone:["project-taskboard",":project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['obj', 'slug'])"]},url[event.obj][0]+url[event.obj][1]},UserTimelineItemTitle.prototype._getLink=function(url,text,title){return title=title||text,$("").attr("tg-nav",url).text(text).attr("title",title).prop("outerHTML")},UserTimelineItemTitle.prototype._getUsernameSpan=function(text){var title;return title=title||text,$("").addClass("username").text(text).prop("outerHTML")},UserTimelineItemTitle.prototype._getParams=function(timeline,event,timeline_type){var params;return params={},timeline_type.translate_params.forEach(function(_this){return function(param){return params[param]=_this._translateTitleParams(param,timeline,event)}}(this)),params},UserTimelineItemTitle.prototype.getTitle=function(timeline,event,type){var params,paramsKeys,translation;return params=this._getParams(timeline,event,type),paramsKeys={},Object.keys(params).forEach(function(key){return paramsKeys[key]="{{"+key+"}}"}),translation=this.translate.instant(type.key,paramsKeys),Object.keys(params).forEach(function(key){var find;return find="{{"+key+"}}",translation=translation.replace(new RegExp(find,"g"),params[key])}),translation},UserTimelineItemTitle}(),angular.module("taigaUserTimeline").service("tgUserTimelineItemTitle",UserTimelineItemTitle)}.call(this),function(){var UserTimelineType,timelineType;timelineType=function(timeline,event){var types;return types=[{check:function(timeline,event){return"membership"===event.obj},key:"TIMELINE.NEW_MEMBER",translate_params:["project_name"],member:function(timeline){return Immutable.Map({user:timeline.getIn(["data","user"]),role:timeline.getIn(["data","role"])})}},{check:function(timeline,event){return"project"===event.obj&&"create"===event.type},key:"TIMELINE.NEW_PROJECT",translate_params:["username","project_name"],description:function(timeline){return timeline.getIn(["data","project","description"])}},{check:function(timeline,event){return"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"attachments"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.UPLOAD_ATTACHMENT",translate_params:["username","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"create"===event.type},key:"TIMELINE.US_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"issue"===event.obj&&"create"===event.type},key:"TIMELINE.ISSUE_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"wikipage"===event.obj&&"create"===event.type},key:"TIMELINE.WIKI_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"create"===event.type&&!timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"create"===event.type&&timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_CREATED_WITH_US",translate_params:["username","project_name","obj_name","us_name"]},{check:function(timeline,event){return"milestone"===event.obj&&"create"===event.type},key:"TIMELINE.MILESTONE_CREATED",translate_params:["username","project_name","obj_name"]},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"userstory"===event.obj},key:"TIMELINE.NEW_COMMENT_US",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"issue"===event.obj},key:"TIMELINE.NEW_COMMENT_ISSUE",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.getIn(["data","comment"])&&"task"===event.obj},key:"TIMELINE.NEW_COMMENT_TASK",translate_params:["username","obj_name"],description:function(timeline){var text;return text=timeline.getIn(["data","comment_html"]),$($.parseHTML(text)).text()}},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&timeline.hasIn(["data","value_diff","value","backlog_order"])&&"change"===event.type},key:"TIMELINE.US_MOVED",translate_params:["username","obj_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type&&"userstory"===event.obj?null===timeline.getIn(["data","value_diff","value","milestone"]).get(1):!1},key:"TIMELINE.US_REMOVED_FROM_MILESTONE",translate_params:["username","obj_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"moveInBacklog"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type&&"userstory"===event.obj},key:"TIMELINE.US_ADDED_MILESTONE",translate_params:["username","obj_name","sprint_name"]},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"blocked"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type?timeline.getIn(["data","value_diff","value","is_blocked"]).get(1)===!0:!1},key:"TIMELINE.BLOCKED",translate_params:["username","obj_name"],description:function(timeline){var text;return timeline.hasIn(["data","value_diff","value","blocked_note_html"])?(text=timeline.getIn(["data","value_diff","value","blocked_note_html"]).get(1),$($.parseHTML(text)).text()):!1}},{check:function(timeline,event){return timeline.hasIn(["data","value_diff"])&&"blocked"===timeline.getIn(["data","value_diff","key"])&&"change"===event.type?timeline.getIn(["data","value_diff","value","is_blocked"]).get(1)===!1:!1},key:"TIMELINE.UNBLOCKED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"milestone"===event.obj&&"change"===event.type},key:"TIMELINE.MILESTONE_UPDATED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"wikipage"===event.obj&&"change"===event.type},key:"TIMELINE.WIKI_UPDATED",translate_params:["username","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"points"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.US_UPDATED_POINTS",translate_params:["username","field_name","obj_name","new_value","role_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.US_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"userstory"===event.obj&&"change"===event.type},key:"TIMELINE.US_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"issue"===event.obj&&"change"===event.type&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.ISSUE_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"issue"===event.obj&&"change"===event.type},key:"TIMELINE.ISSUE_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&!timeline.getIn(["data","task","userstory"])&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.TASK_UPDATED",translate_params:["username","field_name","obj_name"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&timeline.getIn(["data","task","userstory"])&&timeline.hasIn(["data","value_diff"])&&"description_diff"===timeline.getIn(["data","value_diff","key"])},key:"TIMELINE.TASK_UPDATED_WITH_US",translate_params:["username","field_name","obj_name","us_name"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&!timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_UPDATED_WITH_NEW_VALUE",translate_params:["username","field_name","obj_name","new_value"]},{check:function(timeline,event){return"task"===event.obj&&"change"===event.type&&timeline.getIn(["data","task","userstory"])},key:"TIMELINE.TASK_UPDATED_WITH_US_NEW_VALUE",translate_params:["username","field_name","obj_name","us_name","new_value"]},{check:function(timeline,event){return"user"===event.obj&&"create"===event.type},key:"TIMELINE.NEW_USER",translate_params:["username"]}],_.find(types,function(obj){return obj.check(timeline,event)})},UserTimelineType=function(){function UserTimelineType(){}return UserTimelineType.prototype.getType=function(timeline,event){return timelineType(timeline,event)},UserTimelineType}(),angular.module("taigaUserTimeline").service("tgUserTimelineItemType",UserTimelineType)}.call(this),function(){var UserTimelineItemDirective;UserTimelineItemDirective=function(){return{templateUrl:"user-timeline/user-timeline-item/user-timeline-item.html",scope:{timeline:"=tgUserTimelineItem"}}},angular.module("taigaUserTimeline").directive("tgUserTimelineItem",UserTimelineItemDirective)}.call(this),function(){var UserTimelinePaginationSequence;UserTimelinePaginationSequence=function(){var obj;return obj={},obj.generate=function(config){var getContent,items,next,page;return page=1,items=Immutable.List(),config.minItems=config.minItems||20,next=function(){return items=Immutable.List(),getContent()},getContent=function(){return config.fetch(page).then(function(response){var data;return page++,data=response.get("data"),config.filter&&(data=config.filter(data)),config.map&&(data=data.map(config.map)),items=items.concat(data),items.size\n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: app.coffee\n */\n\n(function() {\n var configure, i18nInit, init, module, modules, pluginsWithModule, taiga;\n\n this.taiga = taiga = {};\n\n this.taigaContribPlugins = this.taigaContribPlugins || window.taigaContribPlugins || [];\n\n taiga.generateHash = function(components) {\n if (components == null) {\n components = [];\n }\n components = _.map(components, function(x) {\n return JSON.stringify(x);\n });\n return hex_sha1(components.join(\":\"));\n };\n\n taiga.generateUniqueSessionIdentifier = function() {\n var date, randomNumber;\n date = (new Date()).getTime();\n randomNumber = Math.floor(Math.random() * 0x9000000);\n return taiga.generateHash([date, randomNumber]);\n };\n\n taiga.sessionId = taiga.generateUniqueSessionIdentifier();\n\n configure = function($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider, $compileProvider, $translateProvider, $translatePartialLoaderProvider, $animateProvider) {\n var authHttpIntercept, decorators, defaultHeaders, loaderIntercept, originalWhen, preferedLangCode, userInfo, versionCheckHttpIntercept;\n $animateProvider.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/);\n originalWhen = $routeProvider.when;\n $routeProvider.when = function(path, route) {\n route.resolve || (route.resolve = {});\n angular.extend(route.resolve, {\n languageLoad: [\n \"$q\", \"$translate\", function($q, $translate) {\n var deferred;\n deferred = $q.defer();\n $translate().then(function() {\n return deferred.resolve();\n });\n return deferred.promise;\n }\n ]\n });\n return originalWhen.call($routeProvider, path, route);\n };\n $routeProvider.when(\"/\", {\n templateUrl: \"home/home.html\",\n controller: \"Home\",\n controllerAs: \"vm\",\n loader: true,\n title: \"HOME.PAGE_TITLE\",\n loader: true,\n description: \"HOME.PAGE_DESCRIPTION\",\n joyride: \"dashboard\"\n });\n $routeProvider.when(\"/discover\", {\n templateUrl: \"discover/discover-home/discover-home.html\",\n controller: \"DiscoverHome\",\n controllerAs: \"vm\",\n title: \"PROJECT.NAVIGATION.DISCOVER\",\n loader: true\n });\n $routeProvider.when(\"/discover/search\", {\n templateUrl: \"discover/discover-search/discover-search.html\",\n title: \"PROJECT.NAVIGATION.DISCOVER\",\n loader: true,\n controller: \"DiscoverSearch\",\n controllerAs: \"vm\",\n reloadOnSearch: false\n });\n $routeProvider.when(\"/projects/\", {\n templateUrl: \"projects/listing/projects-listing.html\",\n access: {\n requiresLogin: true\n },\n title: \"PROJECTS.PAGE_TITLE\",\n description: \"PROJECTS.PAGE_DESCRIPTION\",\n loader: true,\n controller: \"ProjectsListing\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/project/:pslug/\", {\n templateUrl: \"projects/project/project.html\",\n loader: true,\n controller: \"Project\",\n controllerAs: \"vm\",\n section: \"project-timeline\"\n });\n $routeProvider.when(\"/project/:pslug/search\", {\n templateUrl: \"search/search.html\",\n reloadOnSearch: false,\n section: \"search\",\n loader: true\n });\n $routeProvider.when(\"/project/:pslug/backlog\", {\n templateUrl: \"backlog/backlog.html\",\n loader: true,\n section: \"backlog\",\n joyride: \"backlog\"\n });\n $routeProvider.when(\"/project/:pslug/kanban\", {\n templateUrl: \"kanban/kanban.html\",\n loader: true,\n section: \"kanban\",\n joyride: \"kanban\"\n });\n $routeProvider.when(\"/project/:pslug/taskboard/:sslug\", {\n templateUrl: \"taskboard/taskboard.html\",\n loader: true,\n section: \"backlog\"\n });\n $routeProvider.when(\"/project/:pslug/us/:usref\", {\n templateUrl: \"us/us-detail.html\",\n loader: true,\n section: \"backlog-kanban\"\n });\n $routeProvider.when(\"/project/:pslug/task/:taskref\", {\n templateUrl: \"task/task-detail.html\",\n loader: true,\n section: \"backlog-kanban\"\n });\n $routeProvider.when(\"/project/:pslug/wiki\", {\n redirectTo: function(params) {\n return \"/project/\" + params.pslug + \"/wiki/home\";\n }\n });\n $routeProvider.when(\"/project/:pslug/wiki/:slug\", {\n templateUrl: \"wiki/wiki.html\",\n loader: true,\n section: \"wiki\"\n });\n $routeProvider.when(\"/project/:pslug/team\", {\n templateUrl: \"team/team.html\",\n loader: true,\n section: \"team\"\n });\n $routeProvider.when(\"/project/:pslug/issues\", {\n templateUrl: \"issue/issues.html\",\n loader: true,\n section: \"issues\"\n });\n $routeProvider.when(\"/project/:pslug/issue/:issueref\", {\n templateUrl: \"issue/issues-detail.html\",\n loader: true,\n section: \"issues\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/details\", {\n templateUrl: \"admin/admin-project-profile.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/default-values\", {\n templateUrl: \"admin/admin-project-default-values.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/modules\", {\n templateUrl: \"admin/admin-project-modules.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/export\", {\n templateUrl: \"admin/admin-project-export.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-profile/reports\", {\n templateUrl: \"admin/admin-project-reports.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/status\", {\n templateUrl: \"admin/admin-project-values-status.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/points\", {\n templateUrl: \"admin/admin-project-values-points.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/priorities\", {\n templateUrl: \"admin/admin-project-values-priorities.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/severities\", {\n templateUrl: \"admin/admin-project-values-severities.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/types\", {\n templateUrl: \"admin/admin-project-values-types.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/project-values/custom-fields\", {\n templateUrl: \"admin/admin-project-values-custom-fields.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/memberships\", {\n templateUrl: \"admin/admin-memberships.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/roles\", {\n templateUrl: \"admin/admin-roles.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/webhooks\", {\n templateUrl: \"admin/admin-third-parties-webhooks.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/github\", {\n templateUrl: \"admin/admin-third-parties-github.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/gitlab\", {\n templateUrl: \"admin/admin-third-parties-gitlab.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/third-parties/bitbucket\", {\n templateUrl: \"admin/admin-third-parties-bitbucket.html\",\n section: \"admin\"\n });\n $routeProvider.when(\"/project/:pslug/admin/contrib/:plugin\", {\n templateUrl: \"contrib/main.html\"\n });\n $routeProvider.when(\"/user-settings/user-profile\", {\n templateUrl: \"user/user-profile.html\"\n });\n $routeProvider.when(\"/user-settings/user-change-password\", {\n templateUrl: \"user/user-change-password.html\"\n });\n $routeProvider.when(\"/user-settings/mail-notifications\", {\n templateUrl: \"user/mail-notifications.html\"\n });\n $routeProvider.when(\"/change-email/:email_token\", {\n templateUrl: \"user/change-email.html\"\n });\n $routeProvider.when(\"/cancel-account/:cancel_token\", {\n templateUrl: \"user/cancel-account.html\"\n });\n $routeProvider.when(\"/profile\", {\n templateUrl: \"profile/profile.html\",\n loader: true,\n access: {\n requiresLogin: true\n },\n controller: \"Profile\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/profile/:slug\", {\n templateUrl: \"profile/profile.html\",\n loader: true,\n controller: \"Profile\",\n controllerAs: \"vm\"\n });\n $routeProvider.when(\"/login\", {\n templateUrl: \"auth/login.html\",\n title: \"LOGIN.PAGE_TITLE\",\n description: \"LOGIN.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/register\", {\n templateUrl: \"auth/register.html\",\n title: \"REGISTER.PAGE_TITLE\",\n description: \"REGISTER.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/forgot-password\", {\n templateUrl: \"auth/forgot-password.html\",\n title: \"FORGOT_PASSWORD.PAGE_TITLE\",\n description: \"FORGOT_PASSWORD.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/change-password/:token\", {\n templateUrl: \"auth/change-password-from-recovery.html\",\n title: \"CHANGE_PASSWORD.PAGE_TITLE\",\n description: \"CHANGE_PASSWORD.PAGE_TITLE\",\n disableHeader: true\n });\n $routeProvider.when(\"/invitation/:token\", {\n templateUrl: \"auth/invitation.html\",\n title: \"INVITATION.PAGE_TITLE\",\n description: \"INVITATION.PAGE_DESCRIPTION\",\n disableHeader: true\n });\n $routeProvider.when(\"/external-apps\", {\n templateUrl: \"external-apps/external-app.html\",\n title: \"EXTERNAL_APP.PAGE_TITLE\",\n description: \"EXTERNAL_APP.PAGE_DESCRIPTION\",\n controller: \"ExternalApp\",\n controllerAs: \"vm\",\n disableHeader: true,\n mobileViewport: true\n });\n $routeProvider.when(\"/error\", {\n templateUrl: \"error/error.html\"\n });\n $routeProvider.when(\"/not-found\", {\n templateUrl: \"error/not-found.html\"\n });\n $routeProvider.when(\"/permission-denied\", {\n templateUrl: \"error/permission-denied.html\"\n });\n $routeProvider.otherwise({\n redirectTo: \"/not-found\"\n });\n $locationProvider.html5Mode({\n enabled: true,\n requireBase: false\n });\n defaultHeaders = {\n \"Content-Type\": \"application/json\",\n \"Accept-Language\": window.taigaConfig.defaultLanguage || \"en\",\n \"X-Session-Id\": taiga.sessionId\n };\n $httpProvider.defaults.headers[\"delete\"] = defaultHeaders;\n $httpProvider.defaults.headers.patch = defaultHeaders;\n $httpProvider.defaults.headers.post = defaultHeaders;\n $httpProvider.defaults.headers.put = defaultHeaders;\n $httpProvider.defaults.headers.get = {\n \"X-Session-Id\": taiga.sessionId\n };\n $httpProvider.useApplyAsync(true);\n $tgEventsProvider.setSessionId(taiga.sessionId);\n authHttpIntercept = function($q, $location, $navUrls, $lightboxService) {\n var httpResponseError;\n httpResponseError = function(response) {\n var nextUrl;\n if (response.status === 0 || (response.status === -1 && !response.config.cancelable)) {\n $lightboxService.closeAll();\n $location.path($navUrls.resolve(\"error\"));\n $location.replace();\n } else if (response.status === 401 && $location.url().indexOf('/login') === -1) {\n nextUrl = encodeURIComponent($location.url());\n $location.url($navUrls.resolve(\"login\")).search(\"next=\" + nextUrl);\n }\n return $q.reject(response);\n };\n return {\n responseError: httpResponseError\n };\n };\n $provide.factory(\"authHttpIntercept\", [\"$q\", \"$location\", \"$tgNavUrls\", \"lightboxService\", authHttpIntercept]);\n $httpProvider.interceptors.push(\"authHttpIntercept\");\n loaderIntercept = function($q, loaderService) {\n return {\n request: function(config) {\n loaderService.logRequest();\n return config;\n },\n requestError: function(rejection) {\n loaderService.logResponse();\n return $q.reject(rejection);\n },\n responseError: function(rejection) {\n loaderService.logResponse();\n return $q.reject(rejection);\n },\n response: function(response) {\n loaderService.logResponse();\n return response;\n }\n };\n };\n $provide.factory(\"loaderIntercept\", [\"$q\", \"tgLoader\", loaderIntercept]);\n $httpProvider.interceptors.push(\"loaderIntercept\");\n versionCheckHttpIntercept = function($q) {\n var httpResponseError;\n httpResponseError = function(response) {\n var $injector;\n if (response.status === 400 && response.data.version) {\n $injector = angular.element(\"body\").injector();\n $injector.invoke([\n \"$tgConfirm\", \"$translate\", (function(_this) {\n return function($confirm, $translate) {\n var versionErrorMsg;\n versionErrorMsg = $translate.instant(\"ERROR.VERSION_ERROR\");\n return $confirm.notify(\"error\", versionErrorMsg, null, 10000);\n };\n })(this)\n ]);\n }\n return $q.reject(response);\n };\n return {\n responseError: httpResponseError\n };\n };\n $provide.factory(\"versionCheckHttpIntercept\", [\"$q\", versionCheckHttpIntercept]);\n $httpProvider.interceptors.push(\"versionCheckHttpIntercept\");\n window.checksley.updateValidators({\n linewidth: function(val, width) {\n var lines, valid;\n lines = taiga.nl2br(val).split(\"
\");\n valid = _.every(lines, function(line) {\n return line.length < width;\n });\n return valid;\n }\n });\n $compileProvider.debugInfoEnabled(window.taigaConfig.debugInfo || false);\n if (localStorage.userInfo) {\n userInfo = JSON.parse(localStorage.userInfo);\n }\n preferedLangCode = (userInfo != null ? userInfo.lang : void 0) || window.taigaConfig.defaultLanguage || \"en\";\n $translatePartialLoaderProvider.addPart('taiga');\n $translateProvider.useLoader('$translatePartialLoader', {\n urlTemplate: '/' + window._version + '/locales/{part}/locale-{lang}.json'\n }).useSanitizeValueStrategy('escapeParameters').addInterpolation('$translateMessageFormatInterpolation').preferredLanguage(preferedLangCode);\n $translateProvider.fallbackLanguage(preferedLangCode);\n decorators = window.getDecorators();\n return _.each(decorators, function(decorator) {\n return $provide.decorator(decorator.provider, decorator.decorator);\n });\n };\n\n i18nInit = function(lang, $translate) {\n var messages;\n moment.locale(lang);\n messages = {\n defaultMessage: $translate.instant(\"COMMON.FORM_ERRORS.DEFAULT_MESSAGE\"),\n type: {\n email: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_EMAIL\"),\n url: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_URL\"),\n urlstrict: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_URLSTRICT\"),\n number: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_NUMBER\"),\n digits: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_DIGITS\"),\n dateIso: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_DATEISO\"),\n alphanum: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_ALPHANUM\"),\n phone: $translate.instant(\"COMMON.FORM_ERRORS.TYPE_PHONE\")\n },\n notnull: $translate.instant(\"COMMON.FORM_ERRORS.NOTNULL\"),\n notblank: $translate.instant(\"COMMON.FORM_ERRORS.NOT_BLANK\"),\n required: $translate.instant(\"COMMON.FORM_ERRORS.REQUIRED\"),\n regexp: $translate.instant(\"COMMON.FORM_ERRORS.REGEXP\"),\n min: $translate.instant(\"COMMON.FORM_ERRORS.MIN\"),\n max: $translate.instant(\"COMMON.FORM_ERRORS.MAX\"),\n range: $translate.instant(\"COMMON.FORM_ERRORS.RANGE\"),\n minlength: $translate.instant(\"COMMON.FORM_ERRORS.MIN_LENGTH\"),\n maxlength: $translate.instant(\"COMMON.FORM_ERRORS.MAX_LENGTH\"),\n rangelength: $translate.instant(\"COMMON.FORM_ERRORS.RANGE_LENGTH\"),\n mincheck: $translate.instant(\"COMMON.FORM_ERRORS.MIN_CHECK\"),\n maxcheck: $translate.instant(\"COMMON.FORM_ERRORS.MAX_CHECK\"),\n rangecheck: $translate.instant(\"COMMON.FORM_ERRORS.RANGE_CHECK\"),\n equalto: $translate.instant(\"COMMON.FORM_ERRORS.EQUAL_TO\")\n };\n return checksley.updateMessages('default', messages);\n };\n\n init = function($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService, projectService, loaderService, navigationBarService) {\n var un, user;\n $log.debug(\"Initialize application\");\n $rootscope.contribPlugins = this.taigaContribPlugins;\n $rootscope.adminPlugins = _.where(this.taigaContribPlugins, {\n \"type\": \"admin\"\n });\n $rootscope.$on(\"$translateChangeEnd\", function(e, ctx) {\n var lang;\n lang = ctx.language;\n return i18nInit(lang, $translate);\n });\n Promise.setScheduler(function(cb) {\n return $rootscope.$evalAsync(cb);\n });\n $events.setupConnection();\n if ($auth.isAuthenticated()) {\n user = $auth.getUser();\n }\n $analytics.initialize();\n un = $rootscope.$on('$routeChangeStart', function(event, next) {\n if (next.loader) {\n loaderService.start(true);\n }\n return un();\n });\n return $rootscope.$on('$routeChangeSuccess', function(event, next) {\n var description, title;\n if (next.loader) {\n loaderService.start(true);\n }\n if (next.access && next.access.requiresLogin) {\n if (!$auth.isAuthenticated()) {\n $location.path($navUrls.resolve(\"login\"));\n }\n }\n projectService.setSection(next.section);\n if (next.params.pslug) {\n projectService.setProjectBySlug(next.params.pslug);\n } else {\n projectService.cleanProject();\n }\n if (next.title || next.description) {\n title = $translate.instant(next.title || \"\");\n description = $translate.instant(next.description || \"\");\n appMetaService.setAll(title, description);\n }\n if (next.mobileViewport) {\n appMetaService.addMobileViewport();\n } else {\n appMetaService.removeMobileViewport();\n }\n if (next.disableHeader) {\n return navigationBarService.disableHeader();\n } else {\n return navigationBarService.enableHeader();\n }\n });\n };\n\n pluginsWithModule = _.filter(this.taigaContribPlugins, function(plugin) {\n return plugin.module;\n });\n\n angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 500);\n\n modules = [\"taigaBase\", \"taigaCommon\", \"taigaResources\", \"taigaResources2\", \"taigaAuth\", \"taigaEvents\", \"taigaHome\", \"taigaNavigationBar\", \"taigaProjects\", \"taigaRelatedTasks\", \"taigaBacklog\", \"taigaTaskboard\", \"taigaKanban\", \"taigaIssues\", \"taigaUserStories\", \"taigaTasks\", \"taigaTeam\", \"taigaWiki\", \"taigaSearch\", \"taigaAdmin\", \"taigaProject\", \"taigaUserSettings\", \"taigaFeedback\", \"taigaPlugins\", \"taigaIntegrations\", \"taigaComponents\", \"taigaProfile\", \"taigaHome\", \"taigaUserTimeline\", \"taigaExternalApps\", \"taigaDiscover\", \"templates\", \"ngSanitize\", \"ngRoute\", \"ngAnimate\", \"ngAria\", \"pascalprecht.translate\", \"infinite-scroll\", \"tgRepeat\"].concat(_.map(pluginsWithModule, function(plugin) {\n return plugin.module;\n }));\n\n module = angular.module(\"taiga\", modules);\n\n module.config([\"$routeProvider\", \"$locationProvider\", \"$httpProvider\", \"$provide\", \"$tgEventsProvider\", \"$compileProvider\", \"$translateProvider\", \"$translatePartialLoaderProvider\", \"$animateProvider\", configure]);\n\n module.run([\"$log\", \"$rootScope\", \"$tgAuth\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"tgProjectService\", \"tgLoader\", \"tgNavigationBarService\", \"$route\", init]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: classes.coffee\n */\n\n(function() {\n var TaigaBase, TaigaController, TaigaService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n TaigaBase = (function() {\n function TaigaBase() {}\n\n return TaigaBase;\n\n })();\n\n TaigaService = (function(superClass) {\n extend(TaigaService, superClass);\n\n function TaigaService() {\n return TaigaService.__super__.constructor.apply(this, arguments);\n }\n\n return TaigaService;\n\n })(TaigaBase);\n\n TaigaController = (function(superClass) {\n extend(TaigaController, superClass);\n\n function TaigaController() {\n this.onInitialDataError = bind(this.onInitialDataError, this);\n return TaigaController.__super__.constructor.apply(this, arguments);\n }\n\n TaigaController.prototype.onInitialDataError = function(xhr) {\n if (xhr) {\n if (xhr.status === 404) {\n this.location.path(this.navUrls.resolve(\"not-found\"));\n this.location.replace();\n } else if (xhr.status === 403) {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n this.location.replace();\n }\n }\n return this.q.reject(xhr);\n };\n\n return TaigaController;\n\n })(TaigaBase);\n\n this.taiga.Base = TaigaBase;\n\n this.taiga.Service = TaigaService;\n\n this.taiga.Controller = TaigaController;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: utils.coffee\n */\n\n(function() {\n var bindMethods, bindOnce, cancelTimeout, debounce, debounceLeading, defineImmutableProperty, groupBy, isImage, joinStr, mixOf, nl2br, patch, replaceTags, scopeDefer, sizeFormat, slugify, startswith, stripTags, taiga, timeout, toString, toggleText, trim, truncate, unslugify,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },\n slice = [].slice,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n nl2br = (function(_this) {\n return function(str) {\n var breakTag;\n breakTag = '
';\n return (str + '').replace(/([^>\\r\\n]?)(\\r\\n|\\n\\r|\\r|\\n)/g, '$1' + breakTag + '$2');\n };\n })(this);\n\n bindMethods = (function(_this) {\n return function(object) {\n var dependencies, methods;\n dependencies = _.keys(object);\n methods = [];\n _.forIn(object, function(value, key) {\n if (indexOf.call(dependencies, key) < 0) {\n return methods.push(key);\n }\n });\n return _.bindAll(object, methods);\n };\n })(this);\n\n bindOnce = (function(_this) {\n return function(scope, attr, continuation) {\n var delBind, val;\n val = scope.$eval(attr);\n if (val !== void 0) {\n return continuation(val);\n }\n delBind = null;\n return delBind = scope.$watch(attr, function(val) {\n if (val === void 0) {\n return;\n }\n continuation(val);\n if (delBind) {\n return delBind();\n }\n });\n };\n })(this);\n\n mixOf = function() {\n var Mixed, base, i, method, mixin, mixins, name, ref;\n base = arguments[0], mixins = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n Mixed = (function(superClass) {\n extend(Mixed, superClass);\n\n function Mixed() {\n return Mixed.__super__.constructor.apply(this, arguments);\n }\n\n return Mixed;\n\n })(base);\n for (i = mixins.length - 1; i >= 0; i += -1) {\n mixin = mixins[i];\n ref = mixin.prototype;\n for (name in ref) {\n method = ref[name];\n Mixed.prototype[name] = method;\n }\n }\n return Mixed;\n };\n\n trim = function(data, char) {\n return _.str.trim(data, char);\n };\n\n slugify = function(data) {\n return _.str.slugify(data);\n };\n\n unslugify = function(data) {\n if (data) {\n return _.str.capitalize(data.replace(/-/g, ' '));\n }\n return data;\n };\n\n toggleText = function(element, texts) {\n var nextTextPosition, text;\n nextTextPosition = element.data('nextTextPosition');\n if ((nextTextPosition == null) || nextTextPosition >= texts.length) {\n nextTextPosition = 0;\n }\n text = texts[nextTextPosition];\n element.data('nextTextPosition', nextTextPosition + 1);\n return element.text(text);\n };\n\n groupBy = function(coll, pred) {\n var i, item, len, result;\n result = {};\n for (i = 0, len = coll.length; i < len; i++) {\n item = coll[i];\n result[pred(item)] = item;\n }\n return result;\n };\n\n timeout = function(wait, continuation) {\n return window.setTimeout(continuation, wait);\n };\n\n cancelTimeout = function(timeoutVar) {\n return window.clearTimeout(timeoutVar);\n };\n\n scopeDefer = function(scope, func) {\n return _.defer((function(_this) {\n return function() {\n return scope.$apply(func);\n };\n })(this));\n };\n\n toString = function(value) {\n if (_.isNumber(value)) {\n return value + \"\";\n } else if (_.isString(value)) {\n return value;\n } else if (_.isPlainObject(value)) {\n return JSON.stringify(value);\n } else if (_.isUndefined(value)) {\n return \"\";\n }\n return value.toString();\n };\n\n joinStr = function(str, coll) {\n return _.str.join(str, coll);\n };\n\n debounce = function(wait, func) {\n return _.debounce(func, wait, {\n leading: true,\n trailing: false\n });\n };\n\n debounceLeading = function(wait, func) {\n return _.debounce(func, wait, {\n leading: false,\n trailing: true\n });\n };\n\n startswith = function(str1, str2) {\n return _.str.startsWith(str1, str2);\n };\n\n truncate = function(str, maxLength, suffix) {\n var out;\n if (suffix == null) {\n suffix = \"...\";\n }\n if ((typeof str !== \"string\") && !(str instanceof String)) {\n return str;\n }\n out = str.slice(0);\n if (out.length > maxLength) {\n out = out.substring(0, maxLength + 1);\n out = out.substring(0, Math.min(out.length, out.lastIndexOf(\" \")));\n out = out + suffix;\n }\n return out;\n };\n\n sizeFormat = function(input, precision) {\n var number, size, units;\n if (precision == null) {\n precision = 1;\n }\n if (isNaN(parseFloat(input)) || !isFinite(input)) {\n return \"-\";\n }\n if (input === 0) {\n return \"0 bytes\";\n }\n units = [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"];\n number = Math.floor(Math.log(input) / Math.log(1024));\n if (number > 5) {\n number = 5;\n }\n size = (input / Math.pow(1024, number)).toFixed(precision);\n return size + \" \" + units[number];\n };\n\n stripTags = function(str, exception) {\n var pattern;\n if (exception) {\n pattern = new RegExp('<(?!' + exception + '\\s*\\/?)[^>]+>', 'gi');\n return String(str).replace(pattern, '');\n } else {\n return String(str).replace(/<\\/?[^>]+>/g, '');\n }\n };\n\n replaceTags = function(str, tags, replace) {\n var pattern;\n pattern = new RegExp('<(' + tags + ')>', 'gi');\n str = str.replace(pattern, '<' + replace + '>');\n pattern = new RegExp('<\\/(' + tags + ')>', 'gi');\n str = str.replace(pattern, '');\n return str;\n };\n\n defineImmutableProperty = (function(_this) {\n return function(obj, name, fn) {\n return Object.defineProperty(obj, name, {\n get: function() {\n var fn_result;\n if (!_.isFunction(fn)) {\n throw \"defineImmutableProperty third param must be a function\";\n }\n fn_result = fn();\n if (fn_result && _.isObject(fn_result)) {\n if (fn_result.size === void 0) {\n throw \"defineImmutableProperty must return immutable data\";\n }\n }\n return fn_result;\n }\n });\n };\n })(this);\n\n _.mixin({\n removeKeys: function(obj, keys) {\n return _.chain([keys]).flatten().reduce(function(obj, key) {\n delete obj[key];\n return obj;\n }, obj).value();\n },\n cartesianProduct: function() {\n return _.reduceRight(arguments, function(a, b) {\n return _.flatten(_.map(a, function(x) {\n return _.map(b, function(y) {\n return [y].concat(x);\n });\n }), true);\n }, [[]]);\n }\n });\n\n isImage = function(name) {\n return name.match(/\\.(jpe?g|png|gif|gifv|webm)/i) !== null;\n };\n\n patch = function(oldImmutable, newImmutable) {\n var pathObj;\n pathObj = {};\n newImmutable.forEach(function(newValue, key) {\n if (newValue !== oldImmutable.get(key)) {\n if (newValue.toJS) {\n return pathObj[key] = newValue.toJS();\n } else {\n return pathObj[key] = newValue;\n }\n }\n });\n return pathObj;\n };\n\n taiga = this.taiga;\n\n taiga.nl2br = nl2br;\n\n taiga.bindMethods = bindMethods;\n\n taiga.bindOnce = bindOnce;\n\n taiga.mixOf = mixOf;\n\n taiga.trim = trim;\n\n taiga.slugify = slugify;\n\n taiga.unslugify = unslugify;\n\n taiga.toggleText = toggleText;\n\n taiga.groupBy = groupBy;\n\n taiga.timeout = timeout;\n\n taiga.cancelTimeout = cancelTimeout;\n\n taiga.scopeDefer = scopeDefer;\n\n taiga.toString = toString;\n\n taiga.joinStr = joinStr;\n\n taiga.truncate = truncate;\n\n taiga.debounce = debounce;\n\n taiga.debounceLeading = debounceLeading;\n\n taiga.startswith = startswith;\n\n taiga.sizeFormat = sizeFormat;\n\n taiga.stripTags = stripTags;\n\n taiga.replaceTags = replaceTags;\n\n taiga.defineImmutableProperty = defineImmutableProperty;\n\n taiga.isImage = isImage;\n\n taiga.patch = patch;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/controllerMixins.coffee\n */\n\n(function() {\n var FiltersMixin, PageMixin, groupBy, joinStr, taiga, toString, trim;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n joinStr = this.taiga.joinStr;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n PageMixin = (function() {\n function PageMixin() {}\n\n PageMixin.prototype.fillUsersAndRoles = function(users, roles) {\n var activeUsers, computableRoles;\n activeUsers = _.filter(users, (function(_this) {\n return function(user) {\n return user.is_active;\n };\n })(this));\n this.scope.activeUsers = _.sortBy(activeUsers, \"full_name_display\");\n this.scope.activeUsersById = groupBy(this.scope.activeUsers, function(e) {\n return e.id;\n });\n this.scope.users = _.sortBy(users, \"full_name_display\");\n this.scope.usersById = groupBy(this.scope.users, function(e) {\n return e.id;\n });\n this.scope.roles = _.sortBy(roles, \"order\");\n computableRoles = _(this.scope.project.members).map(\"role\").uniq().value();\n return this.scope.computableRoles = _(roles).filter(\"computable\").filter(function(x) {\n return _.contains(computableRoles, x.id);\n }).value();\n };\n\n PageMixin.prototype.loadUsersAndRoles = function() {\n var promise;\n promise = this.q.all([this.rs.projects.usersList(this.scope.projectId), this.rs.projects.rolesList(this.scope.projectId)]);\n return promise.then((function(_this) {\n return function(results) {\n var roles, users;\n users = results[0], roles = results[1];\n _this.fillUsersAndRoles(users, roles);\n return results;\n };\n })(this));\n };\n\n return PageMixin;\n\n })();\n\n taiga.PageMixin = PageMixin;\n\n FiltersMixin = (function() {\n function FiltersMixin() {}\n\n FiltersMixin.prototype.selectFilter = function(name, value, load) {\n var existing, location, params;\n if (load == null) {\n load = false;\n }\n params = this.location.search();\n if (params[name] !== void 0 && name !== \"page\") {\n existing = _.map(taiga.toString(params[name]).split(\",\"), function(x) {\n return trim(x);\n });\n existing.push(taiga.toString(value));\n existing = _.compact(existing);\n value = joinStr(\",\", _.uniq(existing));\n }\n if (!this.location.isInCurrentRouteParams(name, value)) {\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n }\n };\n\n FiltersMixin.prototype.replaceFilter = function(name, value, load) {\n var location;\n if (load == null) {\n load = false;\n }\n if (!this.location.isInCurrentRouteParams(name, value)) {\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n }\n };\n\n FiltersMixin.prototype.replaceAllFilters = function(filters, load) {\n var location;\n if (load == null) {\n load = false;\n }\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(filters);\n };\n\n FiltersMixin.prototype.unselectFilter = function(name, value, load) {\n var location, newValues, params, parsedValues;\n if (load == null) {\n load = false;\n }\n params = this.location.search();\n if (params[name] === void 0) {\n return;\n }\n if (value === void 0 || value === null) {\n delete params[name];\n }\n parsedValues = _.map(taiga.toString(params[name]).split(\",\"), function(x) {\n return trim(x);\n });\n newValues = _.reject(parsedValues, function(x) {\n return x === taiga.toString(value);\n });\n newValues = _.compact(newValues);\n if (_.isEmpty(newValues)) {\n value = null;\n } else {\n value = joinStr(\",\", _.uniq(newValues));\n }\n location = load ? this.location : this.location.noreload(this.scope);\n return location.search(name, value);\n };\n\n return FiltersMixin;\n\n })();\n\n taiga.FiltersMixin = FiltersMixin;\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaAdmin\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/auth.coffee\n */\n\n(function() {\n var AuthService, CancelAccountDirective, ChangeEmailDirective, ChangePasswordFromRecoveryDirective, ForgotPasswordDirective, InvitationDirective, LoginDirective, PublicRegisterMessageDirective, RegisterDirective, debounce, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAuth\", [\"taigaResources\"]);\n\n AuthService = (function(superClass) {\n extend(AuthService, superClass);\n\n AuthService.$inject = [\"$rootScope\", \"$tgStorage\", \"$tgModel\", \"$tgResources\", \"$tgHttp\", \"$tgUrls\", \"$tgConfig\", \"$translate\", \"tgCurrentUserService\", \"tgThemeService\"];\n\n function AuthService(rootscope, storage, model, rs, http, urls, config, translate, currentUserService, themeService) {\n var userModel;\n this.rootscope = rootscope;\n this.storage = storage;\n this.model = model;\n this.rs = rs;\n this.http = http;\n this.urls = urls;\n this.config = config;\n this.translate = translate;\n this.currentUserService = currentUserService;\n this.themeService = themeService;\n AuthService.__super__.constructor.call(this);\n userModel = this.getUser();\n this._currentTheme = this._getUserTheme();\n this.setUserdata(userModel);\n }\n\n AuthService.prototype.setUserdata = function(userModel) {\n if (userModel) {\n this.userData = Immutable.fromJS(userModel.getAttrs());\n return this.currentUserService.setUser(this.userData);\n } else {\n return this.userData = null;\n }\n };\n\n AuthService.prototype._getUserTheme = function() {\n var ref;\n return ((ref = this.rootscope.user) != null ? ref.theme : void 0) || this.config.get(\"defaultTheme\") || \"taiga\";\n };\n\n AuthService.prototype._setTheme = function() {\n var newTheme;\n newTheme = this._getUserTheme();\n if (this._currentTheme !== newTheme) {\n this._currentTheme = newTheme;\n return this.themeService.use(this._currentTheme);\n }\n };\n\n AuthService.prototype._setLocales = function() {\n var lang, ref;\n lang = ((ref = this.rootscope.user) != null ? ref.lang : void 0) || this.config.get(\"defaultLanguage\") || \"en\";\n this.translate.preferredLanguage(lang);\n return this.translate.use(lang);\n };\n\n AuthService.prototype.getUser = function() {\n var user, userData;\n if (this.rootscope.user) {\n return this.rootscope.user;\n }\n userData = this.storage.get(\"userInfo\");\n if (userData) {\n user = this.model.make_model(\"users\", userData);\n this.rootscope.user = user;\n this._setLocales();\n this._setTheme();\n return user;\n } else {\n this._setTheme();\n }\n return null;\n };\n\n AuthService.prototype.setUser = function(user) {\n this.rootscope.auth = user;\n this.storage.set(\"userInfo\", user.getAttrs());\n this.rootscope.user = user;\n this.setUserdata(user);\n this._setLocales();\n return this._setTheme();\n };\n\n AuthService.prototype.clear = function() {\n this.rootscope.auth = null;\n this.rootscope.user = null;\n return this.storage.remove(\"userInfo\");\n };\n\n AuthService.prototype.setToken = function(token) {\n return this.storage.set(\"token\", token);\n };\n\n AuthService.prototype.getToken = function() {\n return this.storage.get(\"token\");\n };\n\n AuthService.prototype.removeToken = function() {\n return this.storage.remove(\"token\");\n };\n\n AuthService.prototype.isAuthenticated = function() {\n if (this.getUser() !== null) {\n return true;\n }\n return false;\n };\n\n AuthService.prototype.login = function(data, type) {\n var url;\n url = this.urls.resolve(\"auth\");\n data = _.clone(data, false);\n data.type = type ? type : \"normal\";\n this.removeToken();\n return this.http.post(url, data).then((function(_this) {\n return function(data, status) {\n var user;\n user = _this.model.make_model(\"users\", data.data);\n _this.setToken(user.auth_token);\n _this.setUser(user);\n return user;\n };\n })(this));\n };\n\n AuthService.prototype.logout = function() {\n this.removeToken();\n this.clear();\n this.currentUserService.removeUser();\n this._setTheme();\n return this._setLocales();\n };\n\n AuthService.prototype.register = function(data, type, existing) {\n var url;\n url = this.urls.resolve(\"auth-register\");\n data = _.clone(data, false);\n data.type = type ? type : \"public\";\n if (type === \"private\") {\n data.existing = existing ? existing : false;\n }\n this.removeToken();\n return this.http.post(url, data).then((function(_this) {\n return function(response) {\n var user;\n user = _this.model.make_model(\"users\", response.data);\n _this.setToken(user.auth_token);\n _this.setUser(user);\n return user;\n };\n })(this));\n };\n\n AuthService.prototype.getInvitation = function(token) {\n return this.rs.invitations.get(token);\n };\n\n AuthService.prototype.acceptInvitiationWithNewUser = function(data) {\n return this.register(data, \"private\", false);\n };\n\n AuthService.prototype.acceptInvitiationWithExistingUser = function(data) {\n return this.register(data, \"private\", true);\n };\n\n AuthService.prototype.forgotPassword = function(data) {\n var url;\n url = this.urls.resolve(\"users-password-recovery\");\n data = _.clone(data, false);\n this.removeToken();\n return this.http.post(url, data);\n };\n\n AuthService.prototype.changePasswordFromRecovery = function(data) {\n var url;\n url = this.urls.resolve(\"users-change-password-from-recovery\");\n data = _.clone(data, false);\n this.removeToken();\n return this.http.post(url, data);\n };\n\n AuthService.prototype.changeEmail = function(data) {\n var url;\n url = this.urls.resolve(\"users-change-email\");\n data = _.clone(data, false);\n return this.http.post(url, data);\n };\n\n AuthService.prototype.cancelAccount = function(data) {\n var url;\n url = this.urls.resolve(\"users-cancel-account\");\n data = _.clone(data, false);\n return this.http.post(url, data);\n };\n\n return AuthService;\n\n })(taiga.Service);\n\n module.service(\"$tgAuth\", AuthService);\n\n PublicRegisterMessageDirective = function($config, $navUrls, $routeParams, templates) {\n var template, templateFn;\n template = templates.get(\"auth/login-text.html\", true);\n templateFn = function() {\n var nextUrl, publicRegisterEnabled, url;\n publicRegisterEnabled = $config.get(\"publicRegisterEnabled\");\n if (!publicRegisterEnabled) {\n return \"\";\n }\n url = $navUrls.resolve(\"register\");\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"register\")) {\n nextUrl = encodeURIComponent($routeParams['next']);\n console.log(\"-----\", nextUrl);\n url += \"?next=\" + nextUrl;\n }\n return template({\n url: url\n });\n };\n return {\n restrict: \"AE\",\n scope: {},\n template: templateFn\n };\n };\n\n module.directive(\"tgPublicRegisterMessage\", [\"$tgConfig\", \"$tgNavUrls\", \"$routeParams\", \"$tgTemplate\", PublicRegisterMessageDirective]);\n\n LoginDirective = function($auth, $confirm, $location, $config, $routeParams, $navUrls, $events, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onError, onSuccess, submit;\n form = new checksley.Form($el.find(\"form.login-form\"));\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"login\")) {\n $scope.nextUrl = decodeURIComponent($routeParams['next']);\n } else {\n $scope.nextUrl = $navUrls.resolve(\"home\");\n }\n onSuccess = function(response) {\n $events.setupConnection();\n return $location.url($scope.nextUrl);\n };\n onError = function(response) {\n return $confirm.notify(\"light-error\", $translate.instant(\"LOGIN_FORM.ERROR_AUTH_INCORRECT\"));\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var data, loginFormType, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n data = {\n \"username\": $el.find(\"form.login-form input[name=username]\").val(),\n \"password\": $el.find(\"form.login-form input[name=password]\").val()\n };\n loginFormType = $config.get(\"loginFormType\", \"normal\");\n promise = $auth.login(data, loginFormType);\n return promise.then(onSuccess, onError);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n window.prerenderReady = true;\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLogin\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgConfig\", \"$routeParams\", \"$tgNavUrls\", \"$tgEvents\", \"$translate\", LoginDirective]);\n\n RegisterDirective = function($auth, $confirm, $location, $navUrls, $config, $routeParams, $analytics, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n if (!$config.get(\"publicRegisterEnabled\")) {\n $location.path($navUrls.resolve(\"not-found\"));\n $location.replace();\n }\n $scope.data = {};\n form = $el.find(\"form\").checksley({\n onlyOneErrorElement: true\n });\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"register\")) {\n $scope.nextUrl = decodeURIComponent($routeParams['next']);\n } else {\n $scope.nextUrl = $navUrls.resolve(\"home\");\n }\n onSuccessSubmit = function(response) {\n $analytics.trackEvent(\"auth\", \"register\", \"user registration\", 1);\n $confirm.notify(\"success\", $translate.instant(\"LOGIN_FORM.SUCCESS\"));\n return $location.url($scope.nextUrl);\n };\n onErrorSubmit = function(response) {\n var text;\n if (response.data._error_message) {\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n $confirm.notify(\"light-error\", text);\n }\n return form.setErrors(response.data);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.register($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return window.prerenderReady = true;\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRegister\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfig\", \"$routeParams\", \"$tgAnalytics\", \"$translate\", RegisterDirective]);\n\n ForgotPasswordDirective = function($auth, $confirm, $location, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"FORGOT_PASSWORD_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"FORGOT_PASSWORD_FORM.ERROR\");\n return $confirm.notify(\"light-error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.forgotPassword($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return window.prerenderReady = true;\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgForgotPassword\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", \"$translate\", ForgotPasswordDirective]);\n\n ChangePasswordFromRecoveryDirective = function($auth, $confirm, $location, $params, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit, text;\n $scope.data = {};\n if ($params.token != null) {\n $scope.tokenInParams = true;\n $scope.data.token = $params.token;\n } else {\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.ERROR\");\n $confirm.notify(\"light-error\", text);\n }\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n text = $translate.instant(\"CHANGE_PASSWORD_RECOVERY_FORM.ERROR\");\n return $confirm.notify(\"light-error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.changePasswordFromRecovery($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangePasswordFromRecovery\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$translate\", ChangePasswordFromRecoveryDirective]);\n\n InvitationDirective = function($auth, $confirm, $location, $params, $navUrls, $analytics, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var loginForm, onErrorSubmitLogin, onErrorSubmitRegister, onSuccessSubmitLogin, onSuccessSubmitRegister, promise, registerForm, submitLogin, submitRegister, token;\n token = $params.token;\n promise = $auth.getInvitation(token);\n promise.then(function(invitation) {\n return $scope.invitation = invitation;\n });\n promise.then(null, function(response) {\n var text;\n $location.path($navUrls.resolve(\"login\"));\n text = $translate.instant(\"INVITATION_LOGIN_FORM.NOT_FOUND\");\n return $confirm.notify(\"light-error\", text);\n });\n $scope.dataLogin = {\n token: token\n };\n loginForm = $el.find(\"form.login-form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmitLogin = function(response) {\n var text;\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with existing user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n text = $translate.instant(\"INVITATION_LOGIN_FORM.SUCCESS\", {\n \"project_name\": $scope.invitation.project_name\n });\n return $confirm.notify(\"success\", text);\n };\n onErrorSubmitLogin = function(response) {\n return $confirm.notify(\"light-error\", response.data._error_message);\n };\n submitLogin = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!loginForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithExistingUser($scope.dataLogin);\n return promise.then(onSuccessSubmitLogin, onErrorSubmitLogin);\n };\n })(this));\n $el.on(\"submit\", \"form.login-form\", submitLogin);\n $el.on(\"click\", \".button-login\", submitLogin);\n $scope.dataRegister = {\n token: token\n };\n registerForm = $el.find(\"form.register-form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmitRegister = function(response) {\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with new user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n return $confirm.notify(\"success\", \"You've successfully joined this project\", \"Welcome to \" + (_.escape($scope.invitation.project_name)));\n };\n onErrorSubmitRegister = function(response) {\n var text;\n if (response.data._error_message) {\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n $confirm.notify(\"light-error\", text);\n }\n return registerForm.setErrors(response.data);\n };\n submitRegister = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!registerForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithNewUser($scope.dataRegister);\n return promise.then(onSuccessSubmitRegister, onErrorSubmitRegister);\n };\n })(this));\n $el.on(\"submit\", \"form.register-form\", submitRegister);\n $el.on(\"click\", \".button-register\", submitRegister);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgInvitation\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\", InvitationDirective]);\n\n ChangeEmailDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.email_token = $params.email_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n if ($auth.isAuthenticated()) {\n $repo.queryOne(\"users\", $auth.getUser().id).then((function(_this) {\n return function(data) {\n $auth.setUser(data);\n return $location.path($navUrls.resolve(\"home\"));\n };\n })(this));\n } else {\n $location.path($navUrls.resolve(\"login\"));\n }\n text = $translate.instant(\"CHANGE_EMAIL_FORM.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n return $confirm.notify(\"light-error\", text);\n };\n submit = function() {\n var promise;\n if (!form.validate()) {\n return;\n }\n promise = $auth.changeEmail($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n $el.on(\"submit\", function(event) {\n event.preventDefault();\n return submit();\n });\n $el.on(\"click\", \"a.button-change-email\", function(event) {\n event.preventDefault();\n return submit();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangeEmail\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$translate\", ChangeEmailDirective]);\n\n CancelAccountDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.cancel_token = $params.cancel_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n var text;\n $auth.logout();\n $location.path($navUrls.resolve(\"home\"));\n text = $translate.instant(\"CANCEL_ACCOUNT.SUCCESS\");\n return $confirm.success(text);\n };\n onErrorSubmit = function(response) {\n var text;\n text = $translate.instant(\"COMMON.GENERIC_ERROR\", {\n error: response.data._error_message\n });\n return $confirm.notify(\"error\", text);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.cancelAccount($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCancelAccount\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", CancelAccountDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaBacklog\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base.coffee\n */\n\n(function() {\n var TaigaMainDirective, bindOnce, groupBy, init, module, taiga, urls;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\", []);\n\n TaigaMainDirective = function($rootscope, $window) {\n var link;\n link = function($scope, $el, $attrs) {\n return $window.onresize = function() {\n return $rootscope.$broadcast(\"resize\");\n };\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMain\", [\"$rootScope\", \"$window\", TaigaMainDirective]);\n\n urls = {\n \"home\": \"/\",\n \"projects\": \"/projects\",\n \"error\": \"/error\",\n \"not-found\": \"/not-found\",\n \"permission-denied\": \"/permission-denied\",\n \"discover\": \"/discover\",\n \"discover-search\": \"/discover/search\",\n \"login\": \"/login\",\n \"forgot-password\": \"/forgot-password\",\n \"change-password\": \"/change-password/:token\",\n \"change-email\": \"/change-email/:token\",\n \"cancel-account\": \"/cancel-account/:token\",\n \"register\": \"/register\",\n \"invitation\": \"/invitation/:token\",\n \"create-project\": \"/create-project\",\n \"profile\": \"/profile\",\n \"user-profile\": \"/profile/:username\",\n \"project\": \"/project/:project\",\n \"project-backlog\": \"/project/:project/backlog\",\n \"project-taskboard\": \"/project/:project/taskboard/:sprint\",\n \"project-kanban\": \"/project/:project/kanban\",\n \"project-issues\": \"/project/:project/issues\",\n \"project-search\": \"/project/:project/search\",\n \"project-userstories-detail\": \"/project/:project/us/:ref\",\n \"project-tasks-detail\": \"/project/:project/task/:ref\",\n \"project-issues-detail\": \"/project/:project/issue/:ref\",\n \"project-wiki\": \"/project/:project/wiki\",\n \"project-wiki-page\": \"/project/:project/wiki/:slug\",\n \"project-team\": \"/project/:project/team\",\n \"project-admin-home\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-details\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-default-values\": \"/project/:project/admin/project-profile/default-values\",\n \"project-admin-project-profile-modules\": \"/project/:project/admin/project-profile/modules\",\n \"project-admin-project-profile-export\": \"/project/:project/admin/project-profile/export\",\n \"project-admin-project-profile-reports\": \"/project/:project/admin/project-profile/reports\",\n \"project-admin-project-values-status\": \"/project/:project/admin/project-values/status\",\n \"project-admin-project-values-points\": \"/project/:project/admin/project-values/points\",\n \"project-admin-project-values-priorities\": \"/project/:project/admin/project-values/priorities\",\n \"project-admin-project-values-severities\": \"/project/:project/admin/project-values/severities\",\n \"project-admin-project-values-types\": \"/project/:project/admin/project-values/types\",\n \"project-admin-project-values-custom-fields\": \"/project/:project/admin/project-values/custom-fields\",\n \"project-admin-memberships\": \"/project/:project/admin/memberships\",\n \"project-admin-roles\": \"/project/:project/admin/roles\",\n \"project-admin-third-parties-webhooks\": \"/project/:project/admin/third-parties/webhooks\",\n \"project-admin-third-parties-github\": \"/project/:project/admin/third-parties/github\",\n \"project-admin-third-parties-gitlab\": \"/project/:project/admin/third-parties/gitlab\",\n \"project-admin-third-parties-bitbucket\": \"/project/:project/admin/third-parties/bitbucket\",\n \"project-admin-contrib\": \"/project/:project/admin/contrib/:plugin\",\n \"user-settings-user-profile\": \"/user-settings/user-profile\",\n \"user-settings-user-change-password\": \"/user-settings/user-change-password\",\n \"user-settings-user-avatar\": \"/user-settings/user-avatar\",\n \"user-settings-mail-notifications\": \"/user-settings/mail-notifications\"\n };\n\n init = function($log, $navurls) {\n $log.debug(\"Initialize navigation urls\");\n return $navurls.update(urls);\n };\n\n module.run([\"$log\", \"$tgNavUrls\", init]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common.coffee\n */\n\n(function() {\n var AnimationFrame, Capslock, CheckPermissionDirective, ClassPermissionDirective, DataPickerConfig, LimitLineLengthDirective, ProjectUrl, Qqueue, SelectedText, Template, ToggleCommentDirective, module, taiga,\n slice = [].slice;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\", []);\n\n DataPickerConfig = function($translate) {\n return {\n get: function() {\n return {\n i18n: {\n previousMonth: $translate.instant(\"COMMON.PICKERDATE.PREV_MONTH\"),\n nextMonth: $translate.instant(\"COMMON.PICKERDATE.NEXT_MONTH\"),\n months: [$translate.instant(\"COMMON.PICKERDATE.MONTHS.JAN\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.FEB\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.MAR\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.APR\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.MAY\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.JUN\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.JUL\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.AUG\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.SEP\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.OCT\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.NOV\"), $translate.instant(\"COMMON.PICKERDATE.MONTHS.DEC\")],\n weekdays: [$translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.SUN\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.MON\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.TUE\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.WED\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.THU\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.FRI\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS.SAT\")],\n weekdaysShort: [$translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.SUN\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.MON\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.TUE\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.WED\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.THU\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.FRI\"), $translate.instant(\"COMMON.PICKERDATE.WEEK_DAYS_SHORT.SAT\")]\n },\n isRTL: $translate.instant(\"COMMON.PICKERDATE.IS_RTL\") === \"true\",\n firstDay: parseInt($translate.instant(\"COMMON.PICKERDATE.FIRST_DAY_OF_WEEK\"), 10),\n format: $translate.instant(\"COMMON.PICKERDATE.FORMAT\")\n };\n }\n };\n };\n\n module.factory(\"tgDatePickerConfigService\", [\"$translate\", DataPickerConfig]);\n\n SelectedText = function($window, $document) {\n var get;\n get = function() {\n if ($window.getSelection) {\n return $window.getSelection().toString();\n } else if ($document.selection) {\n return $document.selection.createRange().text;\n }\n return \"\";\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$selectedText\", [\"$window\", \"$document\", SelectedText]);\n\n CheckPermissionDirective = function(projectService) {\n var link, render;\n render = function($el, project, permission) {\n if (project && permission) {\n if (project.get('my_permissions').indexOf(permission) > -1) {\n return $el.removeClass('hidden');\n }\n }\n };\n link = function($scope, $el, $attrs) {\n var permission, unObserve, unwatch;\n $el.addClass('hidden');\n permission = $attrs.tgCheckPermission;\n unwatch = $scope.$watch(function() {\n return projectService.project;\n }, function() {\n if (!projectService.project) {\n return;\n }\n render($el, projectService.project, permission);\n return unwatch();\n });\n unObserve = $attrs.$observe(\"tgCheckPermission\", function(permission) {\n if (!permission) {\n return;\n }\n render($el, projectService.project, permission);\n return unObserve();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n CheckPermissionDirective.$inject = [\"tgProjectService\"];\n\n module.directive(\"tgCheckPermission\", CheckPermissionDirective);\n\n ClassPermissionDirective = function() {\n var link, name;\n name = \"tgClassPermission\";\n link = function($scope, $el, $attrs) {\n var checkPermissions, tgClassPermissionWatchAction, unbindWatcher;\n checkPermissions = function(project, className, permission) {\n var negation;\n negation = permission[0] === \"!\";\n if (negation) {\n permission = permission.slice(1);\n }\n if (negation && project.my_permissions.indexOf(permission) === -1) {\n return $el.addClass(className);\n } else if (!negation && project.my_permissions.indexOf(permission) !== -1) {\n return $el.addClass(className);\n } else {\n return $el.removeClass(className);\n }\n };\n tgClassPermissionWatchAction = function(project) {\n var className, classes, permission, results;\n if (project) {\n unbindWatcher();\n classes = $scope.$eval($attrs[name]);\n results = [];\n for (className in classes) {\n permission = classes[className];\n results.push(checkPermissions(project, className, permission));\n }\n return results;\n }\n };\n return unbindWatcher = $scope.$watch(\"project\", tgClassPermissionWatchAction);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgClassPermission\", ClassPermissionDirective);\n\n AnimationFrame = function() {\n var add, animationFrame, performAnimation, tail;\n animationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;\n performAnimation = (function(_this) {\n return function(time) {\n var fn;\n fn = tail.shift();\n fn();\n if (tail.length) {\n return animationFrame(performAnimation);\n }\n };\n })(this);\n tail = [];\n add = function() {\n var fn, i, len, results;\n results = [];\n for (i = 0, len = arguments.length; i < len; i++) {\n fn = arguments[i];\n tail.push(fn);\n if (tail.length === 1) {\n results.push(animationFrame(performAnimation));\n } else {\n results.push(void 0);\n }\n }\n return results;\n };\n return {\n add: add\n };\n };\n\n module.factory(\"animationFrame\", AnimationFrame);\n\n ToggleCommentDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.find(\"textarea\").on(\"focus\", function() {\n return $el.addClass(\"active\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgToggleComment\", ToggleCommentDirective);\n\n ProjectUrl = function($navurls) {\n var get;\n get = function(project) {\n var ctx;\n ctx = {\n project: project.slug\n };\n if (project.is_backlog_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-backlog\", ctx);\n }\n if (project.is_kanban_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-kanban\", ctx);\n }\n if (project.is_wiki_activated && project.my_permissions.indexOf(\"view_wiki_pages\") > -1) {\n return $navurls.resolve(\"project-wiki\", ctx);\n }\n if (project.is_issues_activated && project.my_permissions.indexOf(\"view_issues\") > -1) {\n return $navurls.resolve(\"project-issues\", ctx);\n }\n return $navurls.resolve(\"project\", ctx);\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$projectUrl\", [\"$tgNavUrls\", ProjectUrl]);\n\n LimitLineLengthDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var maxColsPerLine;\n maxColsPerLine = parseInt($el.attr(\"cols\"));\n return $el.on(\"keyup\", function(event) {\n var code, lines;\n code = event.keyCode;\n lines = $el.val().split(\"\\n\");\n _.each(lines, function(line, index) {\n return lines[index] = line.substring(0, maxColsPerLine - 2);\n });\n return $el.val(lines.join(\"\\n\"));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLimitLineLength\", LimitLineLengthDirective);\n\n Qqueue = function($q) {\n var deferred, lastPromise, qqueue;\n deferred = $q.defer();\n deferred.resolve();\n lastPromise = deferred.promise;\n qqueue = {\n bindAdd: (function(_this) {\n return function(fn) {\n return function() {\n var args;\n args = 1 <= arguments.length ? slice.call(arguments, 0) : [];\n return lastPromise = lastPromise.then(function() {\n return fn.apply(_this, args);\n });\n };\n return qqueue;\n };\n })(this),\n add: (function(_this) {\n return function(fn) {\n if (!lastPromise) {\n lastPromise = fn();\n } else {\n lastPromise = lastPromise.then(fn);\n }\n return qqueue;\n };\n })(this)\n };\n return qqueue;\n };\n\n module.factory(\"$tgQqueue\", [\"$q\", Qqueue]);\n\n Template = function($templateCache) {\n return {\n get: (function(_this) {\n return function(name, lodash) {\n var tmp;\n if (lodash == null) {\n lodash = false;\n }\n tmp = $templateCache.get(name);\n if (lodash) {\n tmp = _.template(tmp);\n }\n return tmp;\n };\n })(this)\n };\n };\n\n module.factory(\"$tgTemplate\", [\"$templateCache\", Template]);\n\n Capslock = function($translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var hideIcon, open, showIcon, warningIcon;\n open = false;\n warningIcon = $('
').addClass('icon').addClass('icon-capslock').attr('title', $translate.instant('COMMON.CAPSLOCK_WARNING'));\n hideIcon = function() {\n return warningIcon.fadeOut(function() {\n open = false;\n return $(this).remove();\n });\n };\n showIcon = function(e) {\n var element;\n if (open) {\n return;\n }\n element = e.currentTarget;\n $(element).parent().append(warningIcon);\n $('.icon-capslock').fadeIn();\n return open = true;\n };\n $el.on('blur', function(e) {\n return hideIcon();\n });\n $el.on('keyup.capslock, focus', function(e) {\n if ($el.val() === $el.val().toLowerCase()) {\n return hideIcon(e);\n } else {\n return showIcon(e);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off('.capslock');\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCapslock\", [\"$translate\", Capslock]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/events.coffee\n */\n\n(function() {\n var EventsProvider, EventsService, bindMethods, module, startswith, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n startswith = this.taiga.startswith;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaEvents\", []);\n\n EventsService = (function() {\n function EventsService(win, log, config, auth, liveAnnouncementService1, rootScope) {\n this.win = win;\n this.log = log;\n this.config = config;\n this.auth = auth;\n this.liveAnnouncementService = liveAnnouncementService1;\n this.rootScope = rootScope;\n this.processMessage = bind(this.processMessage, this);\n bindMethods(this);\n }\n\n EventsService.prototype.initialize = function(sessionId) {\n this.sessionId = sessionId;\n this.subscriptions = {};\n this.connected = false;\n this.error = false;\n this.pendingMessages = [];\n this.missedHeartbeats = 0;\n this.heartbeatInterval = null;\n if (this.win.WebSocket === void 0) {\n return this.log.info(\"WebSockets not supported on your browser\");\n }\n };\n\n EventsService.prototype.setupConnection = function() {\n var loc, path, scheme, url;\n this.stopExistingConnection();\n url = this.config.get(\"eventsUrl\");\n if (!url) {\n return;\n }\n if (!startswith(url, \"ws:\") && !startswith(url, \"wss:\")) {\n loc = this.win.location;\n scheme = loc.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n path = _.str.ltrim(url, \"/\");\n url = scheme + \"//\" + loc.host + \"/\" + path;\n }\n this.ws = new this.win.WebSocket(url);\n this.ws.addEventListener(\"open\", this.onOpen);\n this.ws.addEventListener(\"message\", this.onMessage);\n this.ws.addEventListener(\"error\", this.onError);\n return this.ws.addEventListener(\"close\", this.onClose);\n };\n\n EventsService.prototype.stopExistingConnection = function() {\n if (this.ws === void 0) {\n return;\n }\n this.ws.removeEventListener(\"open\", this.onOpen);\n this.ws.removeEventListener(\"close\", this.onClose);\n this.ws.removeEventListener(\"error\", this.onError);\n this.ws.removeEventListener(\"message\", this.onMessage);\n this.stopHeartBeatMessages();\n this.ws.close();\n return delete this.ws;\n };\n\n EventsService.prototype.notifications = function() {\n return this.subscribe(null, 'notifications', (function(_this) {\n return function(data) {\n _this.liveAnnouncementService.show(data.title, data.desc);\n return _this.rootScope.$digest();\n };\n })(this));\n };\n\n EventsService.prototype.startHeartBeatMessages = function() {\n var heartbeatIntervalTime, maxMissedHeartbeats;\n if (this.heartbeatInterval) {\n return;\n }\n maxMissedHeartbeats = this.config.get(\"eventsMaxMissedHeartbeats\", 5);\n heartbeatIntervalTime = this.config.get(\"eventsHeartbeatIntervalTime\", 60000);\n this.missedHeartbeats = 0;\n this.heartbeatInterval = setInterval((function(_this) {\n return function() {\n var e, error1;\n try {\n if (_this.missedHeartbeats >= maxMissedHeartbeats) {\n throw new Error(\"Too many missed heartbeats PINGs.\");\n }\n _this.missedHeartbeats++;\n _this.sendMessage({\n cmd: \"ping\"\n });\n return _this.log.debug(\"HeartBeat send PING\");\n } catch (error1) {\n e = error1;\n _this.log.error(\"HeartBeat error: \" + e.message);\n return _this.stopHeartBeatMessages();\n }\n };\n })(this), heartbeatIntervalTime);\n return this.log.debug(\"HeartBeat enabled\");\n };\n\n EventsService.prototype.stopHeartBeatMessages = function() {\n if (!this.heartbeatInterval) {\n return;\n }\n clearInterval(this.heartbeatInterval);\n this.heartbeatInterval = null;\n return this.log.debug(\"HeartBeat disabled\");\n };\n\n EventsService.prototype.processHeartBeatPongMessage = function(data) {\n this.missedHeartbeats = 0;\n return this.log.debug(\"HeartBeat recived PONG\");\n };\n\n EventsService.prototype.serialize = function(message) {\n if (_.isObject(message)) {\n return JSON.stringify(message);\n }\n return message;\n };\n\n EventsService.prototype.sendMessage = function(message) {\n var i, len, messages, msg, results;\n this.pendingMessages.push(message);\n if (!this.connected) {\n return;\n }\n messages = _.map(this.pendingMessages, this.serialize);\n this.pendingMessages = [];\n results = [];\n for (i = 0, len = messages.length; i < len; i++) {\n msg = messages[i];\n results.push(this.ws.send(msg));\n }\n return results;\n };\n\n EventsService.prototype.processMessage = function(data) {\n var routingKey, subscription;\n routingKey = data.routing_key;\n if (this.subscriptions[routingKey] == null) {\n return;\n }\n subscription = this.subscriptions[routingKey];\n if (subscription.scope) {\n return subscription.scope.$apply(function() {\n return subscription.callback(data.data);\n });\n } else {\n return subscription.callback(data.data);\n }\n };\n\n EventsService.prototype.subscribe = function(scope, routingKey, callback) {\n var message, subscription;\n if (this.error) {\n return;\n }\n this.log.debug(\"Subscribe to: \" + routingKey);\n subscription = {\n scope: scope,\n routingKey: routingKey,\n callback: _.debounce(callback, 500, {\n \"leading\": true,\n \"trailing\": false\n })\n };\n message = {\n \"cmd\": \"subscribe\",\n \"routing_key\": routingKey\n };\n this.subscriptions[routingKey] = subscription;\n this.sendMessage(message);\n if (scope) {\n return scope.$on(\"$destroy\", (function(_this) {\n return function() {\n return _this.unsubscribe(routingKey);\n };\n })(this));\n }\n };\n\n EventsService.prototype.unsubscribe = function(routingKey) {\n var message;\n if (this.error) {\n return;\n }\n this.log.debug(\"Unsubscribe from: \" + routingKey);\n message = {\n \"cmd\": \"unsubscribe\",\n \"routing_key\": routingKey\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onOpen = function() {\n var message, token;\n this.connected = true;\n this.startHeartBeatMessages();\n this.notifications();\n this.log.debug(\"WebSocket connection opened\");\n token = this.auth.getToken();\n message = {\n cmd: \"auth\",\n data: {\n token: token,\n sessionId: this.sessionId\n }\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onMessage = function(event) {\n var data;\n this.log.debug(\"WebSocket message received: \" + event.data);\n data = JSON.parse(event.data);\n if (data.cmd === \"pong\") {\n return this.processHeartBeatPongMessage(data);\n } else {\n return this.processMessage(data);\n }\n };\n\n EventsService.prototype.onError = function(error) {\n this.log.error(\"WebSocket error: \" + error);\n return this.error = true;\n };\n\n EventsService.prototype.onClose = function() {\n this.log.debug(\"WebSocket closed.\");\n this.connected = false;\n return this.stopHeartBeatMessages();\n };\n\n return EventsService;\n\n })();\n\n EventsProvider = (function() {\n function EventsProvider() {}\n\n EventsProvider.prototype.setSessionId = function(sessionId) {\n return this.sessionId = sessionId;\n };\n\n EventsProvider.prototype.$get = function($win, $log, $conf, $auth, liveAnnouncementService, $rootScope) {\n var service;\n service = new EventsService($win, $log, $conf, $auth, liveAnnouncementService, $rootScope);\n service.initialize(this.sessionId);\n return service;\n };\n\n EventsProvider.prototype.$get.$inject = [\"$window\", \"$log\", \"$tgConfig\", \"$tgAuth\", \"tgLiveAnnouncementService\", \"$rootScope\"];\n\n return EventsProvider;\n\n })();\n\n module.provider(\"$tgEvents\", EventsProvider);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/feedback.coffee\n */\n\n(function() {\n var FeedbackDirective, bindOnce, debounce, groupBy, mixOf, module, taiga, trim;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounce = this.taiga.debounce;\n\n trim = this.taiga.trim;\n\n module = angular.module(\"taigaFeedback\", []);\n\n FeedbackDirective = function($lightboxService, $repo, $confirm, $loading, feedbackService) {\n var directive, link;\n link = function($scope, $el, $attrs) {\n var form, openLightbox, submit, submitButton;\n form = $el.find(\"form\").checksley();\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"feedback\", $scope.feedback);\n promise.then(function(data) {\n currentLoading.finish();\n $lightboxService.close($el);\n return $confirm.notify(\"success\", \"\\\\o/ we'll be happy to read your\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n openLightbox = function() {\n $scope.feedback = {};\n $lightboxService.open($el);\n return $el.find(\"textarea\").focus();\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return openLightbox();\n };\n directive = {\n link: link,\n templateUrl: \"common/lightbox-feedback.html\",\n scope: {}\n };\n return directive;\n };\n\n module.directive(\"tgLbFeedback\", [\"lightboxService\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"tgFeedbackService\", FeedbackDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/integrations.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIntegrations\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIssues\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaKanban\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaPlugins\", [\"ngRoute\"]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/projects.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaProject\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/related-tasks.coffee\n */\n\n(function() {\n var RelatedTaskAssignedToInlineEditionDirective, RelatedTaskCreateButtonDirective, RelatedTaskCreateFormDirective, RelatedTaskRowDirective, RelatedTasksDirective, debounce, module, taiga, trim;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaRelatedTasks\", []);\n\n RelatedTaskRowDirective = function($repo, $compile, $confirm, $rootscope, $loading, $template, $translate) {\n var link, templateEdit, templateView;\n templateView = $template.get(\"task/related-task-row.html\", true);\n templateEdit = $template.get(\"task/related-task-row-edit.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var renderEdit, renderView, saveTask;\n saveTask = debounce(2000, function(task) {\n var currentLoading, promise;\n task.subject = $el.find('input').val();\n currentLoading = $loading().target($el.find('.task-name')).start();\n promise = $repo.save(task);\n promise.then((function(_this) {\n return function() {\n currentLoading.finish();\n return $rootscope.$broadcast(\"related-tasks:update\");\n };\n })(this));\n promise.then(null, (function(_this) {\n return function() {\n currentLoading.finish();\n $el.find('input').val(task.subject);\n return $confirm.notify(\"error\");\n };\n })(this));\n return promise;\n });\n renderEdit = function(task) {\n $el.html($compile(templateEdit({\n task: task\n }))($scope));\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return saveTask($model.$modelValue).then(function() {\n return renderView($model.$modelValue);\n });\n } else if (event.keyCode === 27) {\n return renderView($model.$modelValue);\n }\n });\n $el.on(\"click\", \".icon-floppy\", function(event) {\n return saveTask($model.$modelValue).then(function() {\n return renderView($model.$modelValue);\n });\n });\n return $el.on(\"click\", \".cancel-edit\", function(event) {\n return renderView($model.$modelValue);\n });\n };\n renderView = function(task) {\n var perms;\n $el.off();\n perms = {\n modify_task: $scope.project.my_permissions.indexOf(\"modify_task\") !== -1,\n delete_task: $scope.project.my_permissions.indexOf(\"delete_task\") !== -1\n };\n $el.html($compile(templateView({\n task: task,\n perms: perms\n }))($scope));\n $el.on(\"click\", \".icon-edit\", function() {\n renderEdit($model.$modelValue);\n return $el.find('input').focus().select();\n });\n return $el.on(\"click\", \".delete-task\", function(event) {\n var message, title;\n title = $translate.instant(\"TASK.TITLE_DELETE_ACTION\");\n task = $model.$modelValue;\n message = task.subject;\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var promise;\n promise = $repo.remove(task);\n promise.then(function() {\n askResponse.finish();\n return $scope.$emit(\"related-tasks:delete\");\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n });\n });\n };\n $scope.$watch($attrs.ngModel, function(val) {\n if (!val) {\n return;\n }\n return renderView(val);\n });\n $scope.$on(\"related-tasks:assigned-to-changed\", function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n $scope.$on(\"related-tasks:status-changed\", function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgRelatedTaskRow\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$rootScope\", \"$tgLoading\", \"$tgTemplate\", \"$translate\", RelatedTaskRowDirective]);\n\n RelatedTaskCreateFormDirective = function($repo, $compile, $confirm, $tgmodel, $loading, $analytics, $template) {\n var link, newTask, template;\n template = $template.get(\"task/related-task-create-form.html\", true);\n newTask = {\n subject: \"\",\n assigned_to: null\n };\n link = function($scope, $el, $attrs) {\n var close, createTask, render;\n createTask = debounce(2000, function(task) {\n var currentLoading, promise;\n task.subject = $el.find('input').val();\n task.assigned_to = $scope.newTask.assigned_to;\n task.status = $scope.newTask.status;\n $scope.newTask.status = $scope.project.default_task_status;\n $scope.newTask.assigned_to = null;\n currentLoading = $loading().target($el.find('.task-name')).start();\n promise = $repo.create(\"tasks\", task);\n promise.then(function() {\n $analytics.trackEvent(\"task\", \"create\", \"create task on userstory\", 1);\n currentLoading.finish();\n return $scope.$emit(\"related-tasks:add\");\n });\n promise.then(null, function() {\n $el.find('input').val(task.subject);\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n return promise;\n });\n close = function() {\n $el.off();\n $el.html(\"\");\n return $scope.newRelatedTaskFormOpen = false;\n };\n render = function() {\n $scope.newRelatedTaskFormOpen = true;\n $el.html($compile(template())($scope));\n $el.find('input').focus().select();\n $el.addClass('active');\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return createTask(newTask).then(function() {\n return render();\n });\n } else if (event.keyCode === 27) {\n return $scope.$apply(function() {\n return close();\n });\n }\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n return $scope.$apply(function() {\n return close();\n });\n });\n return $el.on(\"click\", \".icon-floppy\", function(event) {\n return createTask(newTask).then(function() {\n return close();\n });\n });\n };\n taiga.bindOnce($scope, \"us\", function(val) {\n newTask[\"status\"] = $scope.project.default_task_status;\n newTask[\"project\"] = $scope.project.id;\n newTask[\"user_story\"] = $scope.us.id;\n $scope.newTask = $tgmodel.make_model(\"tasks\", newTask);\n return $el.html(\"\");\n });\n $scope.$on(\"related-tasks:show-form\", function() {\n return render();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateForm\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", \"$tgLoading\", \"$tgAnalytics\", \"$tgTemplate\", RelatedTaskCreateFormDirective]);\n\n RelatedTaskCreateButtonDirective = function($repo, $compile, $confirm, $tgmodel, $template) {\n var link, template;\n template = $template.get(\"common/components/add-button.html\", true);\n link = function($scope, $el, $attrs) {\n $scope.$watch(\"project\", function(val) {\n if (!val) {\n return;\n }\n $el.off();\n if ($scope.project.my_permissions.indexOf(\"add_task\") !== -1) {\n $el.html($compile(template())($scope));\n } else {\n $el.html(\"\");\n }\n return $el.on(\"click\", \".add-button\", function(event) {\n return $scope.$emit(\"related-tasks:add-new-clicked\");\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateButton\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", \"$tgTemplate\", RelatedTaskCreateButtonDirective]);\n\n RelatedTasksDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var loadTasks;\n loadTasks = function() {\n return $rs.tasks.list($scope.projectId, null, $scope.usId).then((function(_this) {\n return function(tasks) {\n $scope.tasks = _.sortBy(tasks, 'ref');\n return tasks;\n };\n })(this));\n };\n $scope.$on(\"related-tasks:add\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:delete\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:add-new-clicked\", function() {\n return $scope.$broadcast(\"related-tasks:show-form\");\n });\n taiga.bindOnce($scope, \"us\", function(val) {\n return loadTasks();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTasks\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", RelatedTasksDirective]);\n\n RelatedTaskAssignedToInlineEditionDirective = function($repo, $rootscope, $translate) {\n var link, template;\n template = _.template(\"\\\" alt=\\\"<%- name %>\\\"/>\\n
<%- name %>
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, autoSave, notAutoSave, task, updateRelatedTask;\n updateRelatedTask = function(task) {\n var ctx, member;\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = $scope.usersById[task.assigned_to];\n if (member) {\n ctx.imgurl = member.photo;\n ctx.name = member.full_name_display;\n }\n $el.find(\".avatar\").html(template(ctx));\n return $el.find(\".task-assignedto\").attr('title', ctx.name);\n };\n $ctrl = $el.controller();\n task = $scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition);\n notAutoSave = $scope.$eval($attrs.notAutoSave);\n autoSave = !notAutoSave;\n updateRelatedTask(task);\n $el.on(\"click\", \".task-assignedto\", function(event) {\n return $rootscope.$broadcast(\"assigned-to:add\", task);\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_task\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"assigned-to:added\", debounce(2000, (function(_this) {\n return function(ctx, userId, updatedRelatedTask) {\n if (updatedRelatedTask.id === task.id) {\n updatedRelatedTask.assigned_to = userId;\n if (autoSave) {\n $repo.save(updatedRelatedTask).then(function() {\n return $scope.$emit(\"related-tasks:assigned-to-changed\");\n });\n }\n return updateRelatedTask(updatedRelatedTask);\n }\n };\n })(this)));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskAssignedToInlineEdition\", [\"$tgRepo\", \"$rootScope\", \"$translate\", RelatedTaskAssignedToInlineEditionDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources.coffee\n */\n\n(function() {\n var ResourcesService, initResources, initUrls, module, taiga, urls,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ResourcesService = (function(superClass) {\n extend(ResourcesService, superClass);\n\n function ResourcesService() {\n return ResourcesService.__super__.constructor.apply(this, arguments);\n }\n\n return ResourcesService;\n\n })(taiga.Service);\n\n urls = {\n \"auth\": \"/auth\",\n \"auth-register\": \"/auth/register\",\n \"invitations\": \"/invitations\",\n \"users\": \"/users\",\n \"by_username\": \"/users/by_username\",\n \"users-password-recovery\": \"/users/password_recovery\",\n \"users-change-password-from-recovery\": \"/users/change_password_from_recovery\",\n \"users-change-password\": \"/users/change_password\",\n \"users-change-email\": \"/users/change_email\",\n \"users-cancel-account\": \"/users/cancel\",\n \"user-stats\": \"/users/%s/stats\",\n \"user-liked\": \"/users/%s/liked\",\n \"user-voted\": \"/users/%s/voted\",\n \"user-watched\": \"/users/%s/watched\",\n \"user-contacts\": \"/users/%s/contacts\",\n \"permissions\": \"/permissions\",\n \"notify-policies\": \"/notify-policies\",\n \"user-storage\": \"/user-storage\",\n \"memberships\": \"/memberships\",\n \"bulk-create-memberships\": \"/memberships/bulk_create\",\n \"roles\": \"/roles\",\n \"permissions\": \"/permissions\",\n \"resolver\": \"/resolver\",\n \"projects\": \"/projects\",\n \"project-templates\": \"/project-templates\",\n \"project-modules\": \"/projects/%s/modules\",\n \"bulk-update-projects-order\": \"/projects/bulk_update_order\",\n \"project-like\": \"/projects/%s/like\",\n \"project-unlike\": \"/projects/%s/unlike\",\n \"project-watch\": \"/projects/%s/watch\",\n \"project-unwatch\": \"/projects/%s/unwatch\",\n \"userstory-statuses\": \"/userstory-statuses\",\n \"points\": \"/points\",\n \"task-statuses\": \"/task-statuses\",\n \"issue-statuses\": \"/issue-statuses\",\n \"issue-types\": \"/issue-types\",\n \"priorities\": \"/priorities\",\n \"severities\": \"/severities\",\n \"milestones\": \"/milestones\",\n \"userstories\": \"/userstories\",\n \"bulk-create-us\": \"/userstories/bulk_create\",\n \"bulk-update-us-backlog-order\": \"/userstories/bulk_update_backlog_order\",\n \"bulk-update-us-sprint-order\": \"/userstories/bulk_update_sprint_order\",\n \"bulk-update-us-kanban-order\": \"/userstories/bulk_update_kanban_order\",\n \"userstories-filters\": \"/userstories/filters_data\",\n \"userstory-upvote\": \"/userstories/%s/upvote\",\n \"userstory-downvote\": \"/userstories/%s/downvote\",\n \"userstory-watch\": \"/userstories/%s/watch\",\n \"userstory-unwatch\": \"/userstories/%s/unwatch\",\n \"tasks\": \"/tasks\",\n \"bulk-create-tasks\": \"/tasks/bulk_create\",\n \"bulk-update-task-taskboard-order\": \"/tasks/bulk_update_taskboard_order\",\n \"task-upvote\": \"/tasks/%s/upvote\",\n \"task-downvote\": \"/tasks/%s/downvote\",\n \"task-watch\": \"/tasks/%s/watch\",\n \"task-unwatch\": \"/tasks/%s/unwatch\",\n \"issues\": \"/issues\",\n \"bulk-create-issues\": \"/issues/bulk_create\",\n \"issues-filters\": \"/issues/filters_data\",\n \"issue-upvote\": \"/issues/%s/upvote\",\n \"issue-downvote\": \"/issues/%s/downvote\",\n \"issue-watch\": \"/issues/%s/watch\",\n \"issue-unwatch\": \"/issues/%s/unwatch\",\n \"wiki\": \"/wiki\",\n \"wiki-restore\": \"/wiki/%s/restore\",\n \"wiki-links\": \"/wiki-links\",\n \"history/us\": \"/history/userstory\",\n \"history/issue\": \"/history/issue\",\n \"history/task\": \"/history/task\",\n \"history/wiki\": \"/history/wiki\",\n \"attachments/us\": \"/userstories/attachments\",\n \"attachments/issue\": \"/issues/attachments\",\n \"attachments/task\": \"/tasks/attachments\",\n \"attachments/wiki_page\": \"/wiki/attachments\",\n \"custom-attributes/userstory\": \"/userstory-custom-attributes\",\n \"custom-attributes/issue\": \"/issue-custom-attributes\",\n \"custom-attributes/task\": \"/task-custom-attributes\",\n \"custom-attributes-values/userstory\": \"/userstories/custom-attributes-values\",\n \"custom-attributes-values/issue\": \"/issues/custom-attributes-values\",\n \"custom-attributes-values/task\": \"/tasks/custom-attributes-values\",\n \"webhooks\": \"/webhooks\",\n \"webhooks-test\": \"/webhooks/%s/test\",\n \"webhooklogs\": \"/webhooklogs\",\n \"webhooklogs-resend\": \"/webhooklogs/%s/resend\",\n \"userstories-csv\": \"/userstories/csv?uuid=%s\",\n \"tasks-csv\": \"/tasks/csv?uuid=%s\",\n \"issues-csv\": \"/issues/csv?uuid=%s\",\n \"timeline-profile\": \"/timeline/profile\",\n \"timeline-user\": \"/timeline/user\",\n \"timeline-project\": \"/timeline/project\",\n \"search\": \"/search\",\n \"exporter\": \"/exporter\",\n \"importer\": \"/importer/load_dump\",\n \"feedback\": \"/feedback\",\n \"locales\": \"/locales\",\n \"applications\": \"/applications\",\n \"application-tokens\": \"/application-tokens\",\n \"stats-discover\": \"/stats/discover\"\n };\n\n initUrls = function($log, $urls) {\n $log.debug(\"Initialize api urls\");\n return $urls.update(urls);\n };\n\n initResources = function($log, $rs) {\n var i, len, provider, providers, results;\n $log.debug(\"Initialize resources\");\n providers = _.toArray(arguments).slice(2);\n results = [];\n for (i = 0, len = providers.length; i < len; i++) {\n provider = providers[i];\n results.push(provider($rs));\n }\n return results;\n };\n\n module = angular.module(\"taigaResources\", [\"taigaBase\"]);\n\n module.service(\"$tgResources\", ResourcesService);\n\n module.run([\"$log\", \"$tgUrls\", initUrls]);\n\n module.run([\"$log\", \"$tgResources\", \"$tgProjectsResourcesProvider\", \"$tgCustomAttributesResourcesProvider\", \"$tgCustomAttributesValuesResourcesProvider\", \"$tgMembershipsResourcesProvider\", \"$tgNotifyPoliciesResourcesProvider\", \"$tgInvitationsResourcesProvider\", \"$tgRolesResourcesProvider\", \"$tgUserSettingsResourcesProvider\", \"$tgSprintsResourcesProvider\", \"$tgUserstoriesResourcesProvider\", \"$tgTasksResourcesProvider\", \"$tgIssuesResourcesProvider\", \"$tgWikiResourcesProvider\", \"$tgSearchResourcesProvider\", \"$tgMdRenderResourcesProvider\", \"$tgHistoryResourcesProvider\", \"$tgKanbanResourcesProvider\", \"$tgModulesResourcesProvider\", \"$tgWebhooksResourcesProvider\", \"$tgWebhookLogsResourcesProvider\", \"$tgLocalesResourcesProvider\", \"$tgUsersResourcesProvider\", initResources]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/search.coffee\n */\n\n(function() {\n var SearchBoxDirective, SearchController, SearchDirective, bindOnce, debounce, debounceLeading, groupBy, mixOf, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounceLeading = this.taiga.debounceLeading;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaSearch\", []);\n\n SearchController = (function(superClass) {\n extend(SearchController, superClass);\n\n SearchController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$translate\"];\n\n function SearchController(scope1, repo, rs, params, q, location, appMetaService, navUrls, translate) {\n var loadSearchData, promise;\n this.scope = scope1;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.translate = translate;\n this.scope.sectionName = \"Search\";\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"SEARCH.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"SEARCH.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.searchTerm = null;\n loadSearchData = debounceLeading(100, (function(_this) {\n return function(t) {\n return _this.loadSearchData(t);\n };\n })(this));\n bindOnce(this.scope, \"projectId\", (function(_this) {\n return function(projectId) {\n if (!_this.scope.searchResults && _this.scope.searchTerm) {\n return _this.loadSearchData();\n }\n };\n })(this));\n this.scope.$watch(\"searchTerm\", (function(_this) {\n return function(term) {\n if (term !== void 0 && _this.scope.projectId) {\n return _this.loadSearchData(term);\n }\n };\n })(this));\n }\n\n SearchController.prototype.loadFilters = function() {\n var defered;\n defered = this.q.defer();\n defered.resolve();\n return defered.promise;\n };\n\n SearchController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issueStatusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.taskStatusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n SearchController.prototype.loadSearchData = function(term) {\n if (term == null) {\n term = \"\";\n }\n this.scope.loading = true;\n return this._loadSearchData(term).then((function(_this) {\n return function(data) {\n _this.scope.searchResults = data;\n return _this.scope.loading = false;\n };\n })(this));\n };\n\n SearchController.prototype._loadSearchData = function(term) {\n if (term == null) {\n term = \"\";\n }\n if (this._promise) {\n this._promise.abort();\n }\n this._promise = this.rs.search[\"do\"](this.scope.projectId, term);\n return this._promise;\n };\n\n SearchController.prototype.loadInitialData = function() {\n return this.loadProject().then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n return _this.fillUsersAndRoles(project.members, project.roles);\n };\n })(this));\n };\n\n return SearchController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"SearchController\", SearchController);\n\n SearchBoxDirective = function(projectService, $lightboxService, $navurls, $location, $route) {\n var link;\n link = function($scope, $el, $attrs) {\n var openLightbox, project, submit;\n project = null;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var form, text, url;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n text = $el.find(\"#search-text\").val();\n url = $navurls.resolve(\"project-search\", {\n project: project.get(\"slug\")\n });\n return $scope.$apply(function() {\n $lightboxService.close($el);\n $location.path(url);\n $location.search(\"text\", text).path(url);\n return $route.reload();\n });\n };\n })(this));\n openLightbox = function() {\n project = projectService.project;\n return $lightboxService.open($el).then(function() {\n return $el.find(\"#search-text\").focus();\n });\n };\n $el.on(\"submit\", \"form\", submit);\n return openLightbox();\n };\n return {\n templateUrl: \"search/lightbox-search.html\",\n link: link\n };\n };\n\n SearchBoxDirective.$inject = [\"tgProjectService\", \"lightboxService\", \"$tgNavUrls\", \"$tgLocation\", \"$route\"];\n\n module.directive(\"tgSearchBox\", SearchBoxDirective);\n\n SearchDirective = function($log, $compile, $templatecache, $routeparams, $location) {\n var link, linkTable;\n linkTable = function($scope, $el, $attrs, $ctrl) {\n var activeSectionName, applyAutoTab, getActiveSection, lastSearchResults, markSectionTabActive, renderFilterTabs, renderTableContent, tabsDom, templates;\n applyAutoTab = true;\n activeSectionName = \"userstories\";\n tabsDom = $el.find(\".search-filter\");\n lastSearchResults = null;\n getActiveSection = function(data) {\n var i, len, maxVal, name, ref, selectedSection, value;\n maxVal = 0;\n selectedSection = {};\n selectedSection.name = \"userstories\";\n selectedSection.value = [];\n if (!applyAutoTab) {\n selectedSection.name = activeSectionName;\n selectedSection.value = data[activeSectionName];\n return selectedSection;\n }\n if (data) {\n ref = [\"userstories\", \"issues\", \"tasks\", \"wikipages\"];\n for (i = 0, len = ref.length; i < len; i++) {\n name = ref[i];\n value = data[name];\n if (value.length > maxVal) {\n maxVal = value.length;\n selectedSection.name = name;\n selectedSection.value = value;\n break;\n }\n }\n }\n if (maxVal === 0) {\n return selectedSection;\n }\n return selectedSection;\n };\n renderFilterTabs = function(data) {\n var name, results, value;\n results = [];\n for (name in data) {\n value = data[name];\n tabsDom.find(\"li.\" + name).show();\n results.push(tabsDom.find(\"li.\" + name + \" .num\").html(value.length));\n }\n return results;\n };\n markSectionTabActive = function(section) {\n tabsDom.find(\"a.active\").removeClass(\"active\");\n tabsDom.find(\"li.\" + section.name + \" a\").addClass(\"active\");\n applyAutoTab = false;\n return activeSectionName = section.name;\n };\n templates = {\n issues: $templatecache.get(\"search-issues\"),\n tasks: $templatecache.get(\"search-tasks\"),\n userstories: $templatecache.get(\"search-userstories\"),\n wikipages: $templatecache.get(\"search-wikipages\")\n };\n renderTableContent = function(section) {\n var element, oldElements, oldScope, scope, template;\n oldElements = $el.find(\".search-result-table\").children();\n oldScope = oldElements.scope();\n if (oldScope) {\n oldScope.$destroy();\n oldElements.remove();\n }\n scope = $scope.$new();\n scope[section.name] = section.value;\n template = angular.element.parseHTML(trim(templates[section.name]));\n element = $compile(template)(scope);\n return $el.find(\".search-result-table\").html(element);\n };\n $scope.$watch(\"searchResults\", function(data) {\n var activeSection;\n lastSearchResults = data;\n if (!lastSearchResults) {\n return;\n }\n activeSection = getActiveSection(data);\n renderFilterTabs(data);\n renderTableContent(activeSection);\n return markSectionTabActive(activeSection);\n });\n $scope.$watch(\"searchTerm\", function(searchTerm) {\n if (searchTerm !== void 0) {\n return $location.search(\"text\", searchTerm);\n }\n });\n return $el.on(\"click\", \".search-filter li > a\", function(event) {\n var section, sectionData, sectionName, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n sectionName = target.parent().data(\"name\");\n sectionData = !lastSearchResults ? [] : lastSearchResults[sectionName];\n section = {\n name: sectionName,\n value: sectionData\n };\n return $scope.$apply(function() {\n renderTableContent(section);\n return markSectionTabActive(section);\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, searchText;\n $ctrl = $el.controller();\n linkTable($scope, $el, $attrs, $ctrl);\n searchText = $routeparams.text;\n return $scope.$watch(\"projectId\", function(projectId) {\n if (projectId != null) {\n return $scope.searchTerm = searchText;\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSearch\", [\"$log\", \"$compile\", \"$templateCache\", \"$routeParams\", \"$tgLocation\", SearchDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTaskboard\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/tasks.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTasks\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/team.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTeam\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserSettings\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/userstories.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserStories\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaWiki\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/analytics.coffee\n */\n\n(function() {\n var AnalyticsService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n AnalyticsService = (function(superClass) {\n extend(AnalyticsService, superClass);\n\n AnalyticsService.$inject = [\"$rootScope\", \"$log\", \"$tgConfig\", \"$window\", \"$document\", \"$location\"];\n\n function AnalyticsService(rootscope, log, config, win, doc, location) {\n var conf;\n this.rootscope = rootscope;\n this.log = log;\n this.config = config;\n this.win = win;\n this.doc = doc;\n this.location = location;\n this.initialized = false;\n conf = this.config.get(\"analytics\", {});\n this.accountId = conf.accountId;\n this.pageEvent = conf.pageEvent || \"$routeChangeSuccess\";\n this.trackRoutes = conf.trackRoutes || true;\n this.ignoreFirstPageLoad = conf.ignoreFirstPageLoad || false;\n }\n\n AnalyticsService.prototype.initialize = function() {\n if (!this.accountId) {\n this.log.debug(\"Analytics: no acount id provided. Disabling.\");\n return;\n }\n this.injectAnalytics();\n this.win.ga(\"create\", this.accountId, \"auto\");\n this.win.ga(\"require\", \"displayfeatures\");\n if (this.trackRoutes && (!this.ignoreFirstPageLoad)) {\n this.win.ga(\"send\", \"pageview\", this.getUrl());\n }\n if (this.trackRoutes) {\n this.rootscope.$on(this.pageEvent, (function(_this) {\n return function() {\n return _this.trackPage(_this.getUrl(), \"Taiga\");\n };\n })(this));\n }\n return this.initialized = true;\n };\n\n AnalyticsService.prototype.getUrl = function() {\n return this.location.path();\n };\n\n AnalyticsService.prototype.injectAnalytics = function() {\n var fn;\n fn = (function(i,s,o,g,r,a,m){i[\"GoogleAnalyticsObject\"]=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);});\n return fn(window, document, \"script\", \"//www.google-analytics.com/analytics.js\", \"ga\");\n };\n\n AnalyticsService.prototype.trackPage = function(url, title) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n title = title || this.doc[0].title;\n return this.win.ga(\"send\", \"pageview\", {\n \"page\": url,\n \"title\": title\n });\n };\n\n AnalyticsService.prototype.trackEvent = function(category, action, label, value) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n return this.win.ga(\"send\", \"event\", category, action, label, value);\n };\n\n return AnalyticsService;\n\n })(taiga.Service);\n\n module.service(\"$tgAnalytics\", AnalyticsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: bind-scope.coffee\n */\n\n(function() {\n var BindScope, module;\n\n module = angular.module(\"taigaCommon\");\n\n BindScope = function(config) {\n var link;\n if (!config.debugInfo) {\n jQuery.fn.scope = function() {\n return this.data('scope');\n };\n }\n link = function($scope, $el) {\n if (!config.debugInfo) {\n return $el.data('scope', $scope).addClass('tg-scope');\n }\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBindScope\", [\"$tgConfig\", BindScope]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: compile-html.directive.coffee\n */\n\n(function() {\n var CompileHtmlDirective;\n\n CompileHtmlDirective = function($compile) {\n var link;\n link = function(scope, element, attrs) {\n return scope.$watch(attrs.tgCompileHtml, function(newValue, oldValue) {\n element.html(newValue);\n return $compile(element.contents())(scope);\n });\n };\n return {\n link: link\n };\n };\n\n CompileHtmlDirective.$inject = [\"$compile\"];\n\n angular.module(\"taigaCommon\").directive(\"tgCompileHtml\", CompileHtmlDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/components.coffee\n */\n\n(function() {\n var AssignedToDirective, BlockButtonDirective, CreatedByDisplayDirective, DateRangeDirective, DateSelectorDirective, DeleteButtonDirective, EditableDescriptionDirective, EditableSubjectDirective, EditableWysiwyg, ListItemAssignedtoDirective, ListItemIssueStatusDirective, ListItemPriorityDirective, ListItemSeverityDirective, ListItemTaskStatusDirective, ListItemTypeDirective, ListItemUsStatusDirective, SprintProgressBarDirective, TgMainTitleDirective, TgProgressBarDirective, WatchersDirective, bindOnce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n DateRangeDirective = function($translate) {\n var link, renderRange;\n renderRange = function($el, first, second) {\n var endDate, initDate, prettyDate;\n prettyDate = $translate.instant(\"BACKLOG.SPRINTS.DATE\");\n initDate = moment(first).format(prettyDate);\n endDate = moment(second).format(prettyDate);\n return $el.html(initDate + \"-\" + endDate);\n };\n link = function($scope, $el, $attrs) {\n var first, ref, second;\n ref = $attrs.tgDateRange.split(\",\"), first = ref[0], second = ref[1];\n return bindOnce($scope, first, function(valFirst) {\n return bindOnce($scope, second, function(valSecond) {\n return renderRange($el, valFirst, valSecond);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgDateRange\", [\"$translate\", DateRangeDirective]);\n\n DateSelectorDirective = function($rootscope, datePickerConfigService) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var initialize, selectedDate, unbind;\n selectedDate = null;\n initialize = function() {\n var datePickerConfig;\n datePickerConfig = datePickerConfigService.get();\n _.merge(datePickerConfig, {\n field: $el[0],\n onSelect: (function(_this) {\n return function(date) {\n return selectedDate = date;\n };\n })(this),\n onOpen: (function(_this) {\n return function() {\n if (selectedDate != null) {\n return $el.picker.setDate(selectedDate);\n }\n };\n })(this)\n });\n return $el.picker = new Pikaday(datePickerConfig);\n };\n unbind = $rootscope.$on(\"$translateChangeEnd\", (function(_this) {\n return function(ctx) {\n return initialize();\n };\n })(this));\n $scope.$watch($attrs.ngModel, function(val) {\n if ((val != null) && !$el.picker) {\n initialize();\n }\n if (val != null) {\n return $el.picker.setDate(val);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return unbind();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgDateSelector\", [\"$rootScope\", \"tgDatePickerConfigService\", DateSelectorDirective]);\n\n SprintProgressBarDirective = function() {\n var link, renderProgress;\n renderProgress = function($el, percentage, visual_percentage) {\n if ($el.hasClass(\".current-progress\")) {\n return $el.css(\"width\", percentage + \"%\");\n } else {\n $el.find(\".current-progress\").css(\"width\", visual_percentage + \"%\");\n return $el.find(\".number\").html(percentage + \" %\");\n }\n };\n link = function($scope, $el, $attrs) {\n bindOnce($scope, $attrs.tgSprintProgressbar, function(sprint) {\n var closedPoints, percentage, totalPoints, visual_percentage;\n closedPoints = sprint.closed_points;\n totalPoints = sprint.total_points;\n percentage = 0;\n if (totalPoints !== 0) {\n percentage = Math.round(100 * (closedPoints / totalPoints));\n }\n visual_percentage = 0;\n if (totalPoints !== 0) {\n visual_percentage = Math.round(98 * (closedPoints / totalPoints));\n }\n return renderProgress($el, percentage, visual_percentage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSprintProgressbar\", SprintProgressBarDirective);\n\n CreatedByDisplayDirective = function($template, $compile, $translate, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, $attrs.ngModel, function(model) {\n var ref;\n if (model != null) {\n $scope.owner = model.owner_extra_info || {\n full_name_display: $translate.instant(\"COMMON.EXTERNAL_USER\"),\n photo: \"/\" + window._version + \"/images/user-noimage.png\"\n };\n $scope.url = ((ref = $scope.owner) != null ? ref.is_active : void 0) ? $navUrls.resolve(\"user-profile\", {\n username: $scope.owner.username\n }) : \"\";\n return $scope.date = moment(model.created_date).format($translate.instant(\"COMMON.DATETIME\"));\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n scope: true,\n templateUrl: \"common/components/created-by.html\"\n };\n };\n\n module.directive(\"tgCreatedByDisplay\", [\"$tgTemplate\", \"$compile\", \"$translate\", \"$tgNavUrls\", CreatedByDisplayDirective]);\n\n WatchersDirective = function($rootscope, $confirm, $repo, $qqueue, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"common/components/watchers.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var deleteWatcher, isEditable, renderWatchers, save;\n isEditable = function() {\n var ref, ref1;\n return ((ref = $scope.project) != null ? (ref1 = ref.my_permissions) != null ? ref1.indexOf($attrs.requiredPerm) : void 0 : void 0) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(watchers) {\n var item, promise;\n item = $model.$modelValue.clone();\n item.watchers = watchers;\n $model.$setViewValue(item);\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n watchers = _.map(watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n renderWatchers(watchers);\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n $model.$modelValue.revert();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n deleteWatcher = $qqueue.bindAdd((function(_this) {\n return function(watcherIds) {\n var item, promise;\n item = $model.$modelValue.clone();\n item.watchers = watcherIds;\n $model.$setViewValue(item);\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n var watchers;\n watchers = _.map(item.watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n renderWatchers(watchers);\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n item.revert();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n renderWatchers = function(watchers) {\n var ctx, html;\n ctx = {\n watchers: watchers,\n isEditable: isEditable()\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n $el.on(\"click\", \".js-delete-watcher\", function(event) {\n var message, target, title, watcherId;\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n watcherId = target.data(\"watcher-id\");\n title = $translate.instant(\"COMMON.WATCHERS.TITLE_LIGHTBOX_DELETE_WARTCHER\");\n message = $scope.usersById[watcherId].full_name_display;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var watcherIds;\n askResponse.finish();\n watcherIds = _.clone($model.$modelValue.watchers, false);\n watcherIds = _.pull(watcherIds, watcherId);\n return deleteWatcher(watcherIds);\n };\n })(this));\n });\n $scope.$on(\"watcher:added\", function(ctx, watcherId) {\n var watchers;\n watchers = _.clone($model.$modelValue.watchers, false);\n watchers.push(watcherId);\n watchers = _.uniq(watchers);\n return save(watchers);\n });\n $scope.$watch($attrs.ngModel, function(item) {\n var watchers;\n if (item == null) {\n return;\n }\n watchers = _.map(item.watchers, function(watcherId) {\n return $scope.usersById[watcherId];\n });\n return renderWatchers(watchers);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgWatchers\", [\"$rootScope\", \"$tgConfirm\", \"$tgRepo\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", \"$translate\", WatchersDirective]);\n\n AssignedToDirective = function($rootscope, $confirm, $repo, $loading, $qqueue, $template, $translate, $compile, $currentUserService) {\n var link, template;\n template = $template.get(\"common/components/assigned-to.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, renderAssignedTo, save;\n isEditable = function() {\n var ref, ref1;\n return ((ref = $scope.project) != null ? (ref1 = ref.my_permissions) != null ? ref1.indexOf($attrs.requiredPerm) : void 0 : void 0) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(userId) {\n var currentLoading, promise;\n $model.$modelValue.assigned_to = userId;\n currentLoading = $loading().target($el).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n currentLoading.finish();\n renderAssignedTo($model.$modelValue);\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n $model.$modelValue.revert();\n $confirm.notify(\"error\");\n return currentLoading.finish();\n });\n return promise;\n };\n })(this));\n renderAssignedTo = function(assignedObject) {\n var ctx, fullName, html, isIocaine, isUnassigned, photo;\n if ((assignedObject != null ? assignedObject.assigned_to : void 0) != null) {\n fullName = assignedObject.assigned_to_extra_info.full_name_display;\n photo = assignedObject.assigned_to_extra_info.photo;\n isUnassigned = false;\n } else {\n fullName = $translate.instant(\"COMMON.ASSIGNED_TO.ASSIGN\");\n photo = \"/\" + window._version + \"/images/unnamed.png\";\n isUnassigned = true;\n }\n isIocaine = assignedObject != null ? assignedObject.is_iocaine : void 0;\n ctx = {\n fullName: fullName,\n photo: photo,\n isUnassigned: isUnassigned,\n isEditable: isEditable(),\n isIocaine: isIocaine,\n fullNameVisible: !(isUnassigned && !$currentUserService.isAuthenticated())\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n $el.on(\"click\", \".user-assigned\", function(event) {\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n return $scope.$apply(function() {\n return $rootscope.$broadcast(\"assigned-to:add\", $model.$modelValue);\n });\n });\n $el.on(\"click\", \".assign-to-me\", function(event) {\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n $model.$modelValue.assigned_to = $currentUserService.getUser().get('id');\n return save($currentUserService.getUser().get('id'));\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var title;\n event.preventDefault();\n if (!isEditable()) {\n return;\n }\n title = $translate.instant(\"COMMON.ASSIGNED_TO.CONFIRM_UNASSIGNED\");\n return $confirm.ask(title).then((function(_this) {\n return function(response) {\n response.finish();\n $model.$modelValue.assigned_to = null;\n return save(null);\n };\n })(this));\n });\n $scope.$on(\"assigned-to:added\", function(ctx, userId, item) {\n if (item.id !== $model.$modelValue.id) {\n return;\n }\n return save(userId);\n });\n $scope.$watch($attrs.ngModel, function(instance) {\n return renderAssignedTo(instance);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgAssignedTo\", [\"$rootScope\", \"$tgConfirm\", \"$tgRepo\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$translate\", \"$compile\", \"tgCurrentUserService\", AssignedToDirective]);\n\n BlockButtonDirective = function($rootscope, $loading, $template) {\n var link, template;\n template = $template.get(\"common/components/block-button.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n $scope.$watch($attrs.ngModel, function(item) {\n if (!item) {\n return;\n }\n if (isEditable()) {\n $el.find('.item-block').addClass('editable');\n }\n if (item.is_blocked) {\n $el.find('.item-block').removeClass('is-active');\n return $el.find('.item-unblock').addClass('is-active');\n } else {\n $el.find('.item-block').addClass('is-active');\n return $el.find('.item-unblock').removeClass('is-active');\n }\n });\n $el.on(\"click\", \".item-block\", function(event) {\n event.preventDefault();\n return $rootscope.$broadcast(\"block\", $model.$modelValue);\n });\n $el.on(\"click\", \".item-unblock\", function(event) {\n var currentLoading, finish;\n event.preventDefault();\n currentLoading = $loading().target($el.find(\".item-unblock\")).start();\n finish = function() {\n return currentLoading.finish();\n };\n return $rootscope.$broadcast(\"unblock\", $model.$modelValue, finish);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgBlockButton\", [\"$rootScope\", \"$tgLoading\", \"$tgTemplate\", BlockButtonDirective]);\n\n DeleteButtonDirective = function($log, $repo, $confirm, $location, $template) {\n var link, template;\n template = $template.get(\"common/components/delete-button.html\");\n link = function($scope, $el, $attrs, $model) {\n if (!$attrs.onDeleteGoToUrl) {\n return $log.error(\"DeleteButtonDirective requires on-delete-go-to-url set in scope.\");\n }\n if (!$attrs.onDeleteTitle) {\n return $log.error(\"DeleteButtonDirective requires on-delete-title set in scope.\");\n }\n $el.on(\"click\", \".button-delete\", function(event) {\n var subtitle, title;\n title = $attrs.onDeleteTitle;\n subtitle = $model.$modelValue.subject;\n return $confirm.askOnDelete(title, subtitle).then((function(_this) {\n return function(askResponse) {\n var promise;\n promise = $repo.remove($model.$modelValue);\n promise.then(function() {\n var url;\n askResponse.finish();\n url = $scope.$eval($attrs.onDeleteGoToUrl);\n return $location.path(url);\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgDeleteButton\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"$tgTemplate\", DeleteButtonDirective]);\n\n EditableSubjectDirective = function($rootscope, $repo, $confirm, $loading, $qqueue, $template) {\n var link, template;\n template = $template.get(\"common/components/editable-subject.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, save;\n $scope.$on(\"object:updated\", function() {\n $el.find('.edit-subject').hide();\n return $el.find('.view-subject').show();\n });\n isEditable = function() {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(subject) {\n var currentLoading, promise;\n $model.$modelValue.subject = subject;\n currentLoading = $loading().target($el.find('.save-container')).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $el.find('.edit-subject').hide();\n return $el.find('.view-subject').show();\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n return promise;\n };\n })(this));\n $el.click(function() {\n if (!isEditable()) {\n return;\n }\n $el.find('.edit-subject').show();\n $el.find('.view-subject').hide();\n return $el.find('input').focus();\n });\n $el.on(\"click\", \".save\", function(e) {\n var subject;\n e.preventDefault();\n subject = $scope.item.subject;\n return save(subject);\n });\n $el.on(\"keyup\", \"input\", function(event) {\n var subject;\n if (event.keyCode === 13) {\n subject = $scope.item.subject;\n return save(subject);\n } else if (event.keyCode === 27) {\n $scope.$apply((function(_this) {\n return function() {\n return $model.$modelValue.revert();\n };\n })(this));\n $el.find('div.edit-subject').hide();\n return $el.find('div.view-subject').show();\n }\n });\n $el.find('div.edit-subject').hide();\n $el.find('div.view-subject span.edit').hide();\n $scope.$watch($attrs.ngModel, function(value) {\n if (!value) {\n return;\n }\n $scope.item = value;\n if (!isEditable()) {\n return $el.find('.view-subject .edit').remove();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgEditableSubject\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", EditableSubjectDirective]);\n\n EditableDescriptionDirective = function($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) {\n var link, noDescriptionMegEditMode, noDescriptionMegReadMode, template;\n template = $template.get(\"common/components/editable-description.html\");\n noDescriptionMegEditMode = $template.get(\"common/components/editable-description-msg-edit-mode.html\");\n noDescriptionMegReadMode = $template.get(\"common/components/editable-description-msg-read-mode.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, save;\n $el.find('.edit-description').hide();\n $el.find('.view-description .edit').hide();\n $scope.$on(\"object:updated\", function() {\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n });\n isEditable = function() {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(description) {\n var currentLoading, promise;\n $model.$modelValue.description = description;\n currentLoading = $loading().target($el.find('.save-container')).start();\n promise = $repo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n })(this));\n $el.on(\"mouseup\", \".view-description\", function(event) {\n var target;\n target = angular.element(event.target);\n if (!isEditable()) {\n return;\n }\n if (target.is('a')) {\n return;\n }\n if ($selectedText.get().length) {\n return;\n }\n $el.find('.edit-description').show();\n $el.find('.view-description').hide();\n return $el.find('textarea').focus();\n });\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"click\", \".save\", function(e) {\n var description;\n e.preventDefault();\n description = $scope.item.description;\n return save(description);\n });\n $el.on(\"keydown\", \"textarea\", function(event) {\n if (event.keyCode === 27) {\n $scope.$apply((function(_this) {\n return function() {\n return $scope.item.revert();\n };\n })(this));\n $el.find('.edit-description').hide();\n return $el.find('.view-description').show();\n }\n });\n $scope.$watch($attrs.ngModel, function(value) {\n if (!value) {\n return;\n }\n $scope.item = value;\n if (isEditable()) {\n $el.find('.view-description .edit').show();\n $el.find('.view-description .us-content').addClass('editable');\n return $scope.noDescriptionMsg = $compile(noDescriptionMegEditMode)($scope);\n } else {\n return $scope.noDescriptionMsg = $compile(noDescriptionMegReadMode)($scope);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n template: template\n };\n };\n\n module.directive(\"tgEditableDescription\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$compile\", \"$tgLoading\", \"$selectedText\", \"$tgQqueue\", \"$tgTemplate\", EditableDescriptionDirective]);\n\n EditableWysiwyg = function(attachmentsService, attachmentsFullService) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var isInEditMode, uploadFile;\n isInEditMode = function() {\n return $el.find('textarea').is(':visible');\n };\n uploadFile = function(file, type) {\n if (!attachmentsService.validate(file)) {\n return;\n }\n return attachmentsFullService.addAttachment($model.$modelValue.project, $model.$modelValue.id, type, file).then(function(result) {\n if (taiga.isImage(result.getIn(['file', 'name']))) {\n return '![' + result.getIn(['file', 'name']) + '](' + result.getIn(['file', 'url']) + ')';\n } else {\n return '[' + result.getIn(['file', 'name']) + '](' + result.getIn(['file', 'url']) + ')';\n }\n });\n };\n $el.on('dragover', function(e) {\n var textarea;\n textarea = $el.find('textarea').focus();\n return false;\n });\n return $el.on('drop', function(e) {\n var dataTransfer, promises, textarea, type;\n e.stopPropagation();\n e.preventDefault();\n if (isInEditMode()) {\n dataTransfer = e.dataTransfer || (e.originalEvent && e.originalEvent.dataTransfer);\n textarea = $el.find('textarea');\n textarea.addClass('in-progress');\n type = $model.$modelValue['_name'];\n if (type === \"userstories\") {\n type = \"us\";\n } else if (type === \"tasks\") {\n type = \"task\";\n } else if (type === \"issues\") {\n type = \"issue\";\n } else if (type === \"wiki\") {\n type = \"wiki_page\";\n }\n promises = _.map(dataTransfer.files, function(file) {\n return uploadFile(file, type);\n });\n return Promise.all(promises).then(function(result) {\n textarea = $el.find('textarea');\n $.markItUp({\n replaceWith: result.join(' ')\n });\n return textarea.removeClass('in-progress');\n });\n }\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgEditableWysiwyg\", [\"tgAttachmentsService\", \"tgAttachmentsFullService\", EditableWysiwyg]);\n\n ListItemUsStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var us;\n us = $scope.$eval($attrs.tgListitemUsStatus);\n return bindOnce($scope, \"usStatusById\", function(usStatusById) {\n return $el.html(usStatusById[us.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemUsStatus\", ListItemUsStatusDirective);\n\n ListItemTaskStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var task;\n task = $scope.$eval($attrs.tgListitemTaskStatus);\n return bindOnce($scope, \"taskStatusById\", function(taskStatusById) {\n return $el.html(taskStatusById[task.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemTaskStatus\", ListItemTaskStatusDirective);\n\n ListItemAssignedtoDirective = function($template, $translate) {\n var link, template;\n template = $template.get(\"common/components/list-item-assigned-to-avatar.html\", true);\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, \"usersById\", function(usersById) {\n var ctx, item, member;\n item = $scope.$eval($attrs.tgListitemAssignedto);\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = usersById[item.assigned_to];\n if (member) {\n ctx.imgurl = member.photo;\n ctx.name = member.full_name_display;\n }\n return $el.html(template(ctx));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemAssignedto\", [\"$tgTemplate\", \"$translate\", ListItemAssignedtoDirective]);\n\n ListItemIssueStatusDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemIssueStatus);\n return bindOnce($scope, \"issueStatusById\", function(issueStatusById) {\n return $el.html(issueStatusById[issue.status].name);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgListitemIssueStatus\", ListItemIssueStatusDirective);\n\n ListItemTypeDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(issueTypeById, issue) {\n var domNode, type;\n type = issueTypeById[issue.type];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", type.color);\n return domNode.attr(\"title\", type.name);\n };\n bindOnce($scope, \"issueTypeById\", function(issueTypeById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemType);\n return render(issueTypeById, issue);\n });\n return $scope.$watch($attrs.tgListitemType, function(issue) {\n return render($scope.issueTypeById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemType\", ListItemTypeDirective);\n\n ListItemPriorityDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(priorityById, issue) {\n var domNode, priority;\n priority = priorityById[issue.priority];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", priority.color);\n return domNode.attr(\"title\", priority.name);\n };\n bindOnce($scope, \"priorityById\", function(priorityById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemPriority);\n return render(priorityById, issue);\n });\n return $scope.$watch($attrs.tgListitemPriority, function(issue) {\n return render($scope.priorityById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemPriority\", ListItemPriorityDirective);\n\n ListItemSeverityDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var render;\n render = function(severityById, issue) {\n var domNode, severity;\n severity = severityById[issue.severity];\n domNode = $el.find(\".level\");\n domNode.css(\"background-color\", severity.color);\n return domNode.attr(\"title\", severity.name);\n };\n bindOnce($scope, \"severityById\", function(severityById) {\n var issue;\n issue = $scope.$eval($attrs.tgListitemSeverity);\n return render(severityById, issue);\n });\n return $scope.$watch($attrs.tgListitemSeverity, function(issue) {\n return render($scope.severityById, issue);\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/level.html\"\n };\n };\n\n module.directive(\"tgListitemSeverity\", ListItemSeverityDirective);\n\n TgProgressBarDirective = function($template) {\n var link, render, template;\n template = $template.get(\"common/components/progress-bar.html\", true);\n render = function(el, percentage) {\n return el.html(template({\n percentage: percentage\n }));\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch($attrs.tgProgressBar, function(percentage) {\n percentage = _.max([0, percentage]);\n percentage = _.min([100, percentage]);\n return render($el, percentage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProgressBar\", [\"$tgTemplate\", TgProgressBarDirective]);\n\n TgMainTitleDirective = function($translate) {\n var link;\n link = function($scope, $el, $attrs) {\n $attrs.$observe(\"i18nSectionName\", function(i18nSectionName) {\n return $scope.sectionName = i18nSectionName;\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n templateUrl: \"common/components/main-title.html\",\n scope: {\n projectName: \"=projectName\"\n }\n };\n };\n\n module.directive(\"tgMainTitle\", [\"$translate\", TgMainTitleDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/confirm.coffee\n */\n\n(function() {\n var ConfirmService, NOTIFICATION_MSG, bindMethods, cancelTimeout, debounce, module, taiga, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n timeout = this.taiga.timeout;\n\n cancelTimeout = this.taiga.cancelTimeout;\n\n debounce = this.taiga.debounce;\n\n bindMethods = this.taiga.bindMethods;\n\n NOTIFICATION_MSG = {\n \"success\": {\n title: \"NOTIFICATION.OK\",\n message: \"NOTIFICATION.SAVED\"\n },\n \"error\": {\n title: \"NOTIFICATION.WARNING\",\n message: \"NOTIFICATION.WARNING_TEXT\"\n },\n \"light-error\": {\n title: \"NOTIFICATION.WARNING\",\n message: \"NOTIFICATION.WARNING_TEXT\"\n }\n };\n\n ConfirmService = (function(superClass) {\n extend(ConfirmService, superClass);\n\n ConfirmService.$inject = [\"$q\", \"lightboxService\", \"$tgLoading\", \"$translate\"];\n\n function ConfirmService(q, lightboxService, loading, translate) {\n this.q = q;\n this.lightboxService = lightboxService;\n this.loading = loading;\n this.translate = translate;\n bindMethods(this);\n }\n\n ConfirmService.prototype.hide = function(el) {\n if (el) {\n this.lightboxService.close(el);\n return el.off(\".confirm-dialog\");\n }\n };\n\n ConfirmService.prototype.ask = function(title, subtitle, message, lightboxSelector) {\n var defered, el;\n if (lightboxSelector == null) {\n lightboxSelector = \".lightbox-generic-ask\";\n }\n defered = this.q.defer();\n el = angular.element(lightboxSelector);\n el.find(\"h2.title\").text(title);\n el.find(\"span.subtitle\").text(subtitle);\n el.find(\"span.message\").text(message);\n el.on(\"click.confirm-dialog\", \"a.button-green\", debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n currentLoading = _this.loading().target(target).start();\n return defered.resolve({\n finish: function(ok) {\n if (ok == null) {\n ok = true;\n }\n currentLoading.finish();\n if (ok) {\n return _this.hide(el);\n }\n }\n });\n };\n })(this)));\n el.on(\"click.confirm-dialog\", \"a.button-red\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.reject();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.askOnDelete = function(title, message) {\n return this.ask(title, this.translate.instant(\"NOTIFICATION.ASK_DELETE\"), message);\n };\n\n ConfirmService.prototype.askChoice = function(title, subtitle, choices, replacement, warning, lightboxSelector) {\n var choicesField, defered, el;\n if (lightboxSelector == null) {\n lightboxSelector = \".lightbox-ask-choice\";\n }\n defered = this.q.defer();\n el = angular.element(lightboxSelector);\n el.find(\".title\").text(title);\n el.find(\".subtitle\").text(subtitle);\n if (replacement) {\n el.find(\".replacement\").text(replacement);\n } else {\n el.find(\".replacement\").remove();\n }\n if (warning) {\n el.find(\".warning\").text(warning);\n } else {\n el.find(\".warning\").remove();\n }\n choicesField = el.find(\".choices\");\n choicesField.html('');\n _.each(choices, function(value, key) {\n value = _.escape(value);\n return choicesField.append(angular.element(\"\"));\n });\n el.on(\"click.confirm-dialog\", \"a.button-green\", debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n currentLoading = _this.loading().target(target).start();\n return defered.resolve({\n selected: choicesField.val(),\n finish: function(ok) {\n if (ok == null) {\n ok = true;\n }\n currentLoading.finish();\n if (ok) {\n return _this.hide(el);\n }\n }\n });\n };\n })(this)));\n el.on(\"click.confirm-dialog\", \"a.button-red\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.reject();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.error = function(message) {\n var defered, el;\n defered = this.q.defer();\n el = angular.element(\".lightbox-generic-error\");\n el.find(\"h2.title\").html(message);\n el.on(\"click.confirm-dialog\", \"a.button-green\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n el.on(\"click.confirm-dialog\", \"a.close\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.success = function(title, message) {\n var defered, el;\n defered = this.q.defer();\n el = angular.element(\".lightbox-generic-success\");\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n el.on(\"click.confirm-dialog\", \"a.button-green\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n el.on(\"click.confirm-dialog\", \"a.close\", (function(_this) {\n return function(event) {\n event.preventDefault();\n defered.resolve();\n return _this.hide(el);\n };\n })(this));\n this.lightboxService.open(el);\n return defered.promise;\n };\n\n ConfirmService.prototype.loader = function(title, message) {\n var el;\n el = angular.element(\".lightbox-generic-loading\");\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n return {\n start: (function(_this) {\n return function() {\n return _this.lightboxService.open(el);\n };\n })(this),\n stop: (function(_this) {\n return function() {\n return _this.lightboxService.close(el);\n };\n })(this),\n update: (function(_this) {\n return function(status, title, message, percent) {\n if (title) {\n el.find(\"h2.title\").html(title);\n }\n if (message) {\n el.find(\"p.message\").html(message);\n }\n if (percent) {\n el.find(\".spin\").addClass(\"hidden\");\n el.find(\".progress-bar-wrapper\").removeClass(\"hidden\");\n el.find(\".progress-bar-wrapper > .bar\").width(percent + '%');\n return el.find(\".progress-bar-wrapper > span\").html(percent + '%').css('left', (percent - 9) + '%');\n } else {\n el.find(\".spin\").removeClass(\"hidden\");\n return el.find(\".progress-bar-wrapper\").addClass(\"hidden\");\n }\n };\n })(this)\n };\n };\n\n ConfirmService.prototype.notify = function(type, message, title, time) {\n var body, el, selector;\n selector = \".notification-message-\" + type;\n el = angular.element(selector);\n if (el.hasClass(\"active\")) {\n return;\n }\n if (title) {\n el.find(\"h4\").html(title);\n } else {\n el.find(\"h4\").html(this.translate.instant(NOTIFICATION_MSG[type].title));\n }\n if (message) {\n el.find(\"p\").html(message);\n } else {\n el.find(\"p\").html(this.translate.instant(NOTIFICATION_MSG[type].message));\n }\n body = angular.element(\"body\");\n body.find(\".notification-message .notification-light\").removeClass('active').addClass('inactive');\n body.find(selector).removeClass('inactive').addClass('active');\n if (this.tsem) {\n cancelTimeout(this.tsem);\n }\n if (!time) {\n time = type === 'error' || type === 'light-error' ? 3500 : 1500;\n }\n this.tsem = timeout(time, (function(_this) {\n return function() {\n body.find(selector).removeClass('active').addClass('inactive');\n return delete _this.tsem;\n };\n })(this));\n return el.on(\"click\", \".icon-delete, .close\", (function(_this) {\n return function(event) {\n return body.find(selector).removeClass('active').addClass('inactive');\n };\n })(this));\n };\n\n return ConfirmService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaCommon\");\n\n module.service(\"$tgConfirm\", ConfirmService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/custom-field-values.coffee\n */\n\n(function() {\n var CustomAttributeValueDirective, CustomAttributesValuesController, CustomAttributesValuesDirective, DATE_TYPE, MULTILINE_TYPE, TEXT_TYPE, TYPE_CHOICES, bindMethods, bindOnce, debounce, generateHash, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n bindMethods = this.taiga.bindMethods;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n generateHash = taiga.generateHash;\n\n module = angular.module(\"taigaCommon\");\n\n TEXT_TYPE = \"text\";\n\n MULTILINE_TYPE = \"multiline\";\n\n DATE_TYPE = \"date\";\n\n TYPE_CHOICES = [\n {\n key: TEXT_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT\"\n }, {\n key: MULTILINE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI\"\n }, {\n key: DATE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE\"\n }\n ];\n\n CustomAttributesValuesController = (function(superClass) {\n extend(CustomAttributesValuesController, superClass);\n\n CustomAttributesValuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$q\"];\n\n function CustomAttributesValuesController(scope, rootscope, repo, rs, confirm, q) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.confirm = confirm;\n this.q = q;\n bindMethods(this);\n this.type = null;\n this.objectId = null;\n this.projectId = null;\n this.customAttributes = [];\n this.customAttributesValues = null;\n }\n\n CustomAttributesValuesController.prototype.initialize = function(type, objectId) {\n this.project = this.scope.project;\n this.type = type;\n this.objectId = objectId;\n return this.projectId = this.scope.projectId;\n };\n\n CustomAttributesValuesController.prototype.loadCustomAttributesValues = function() {\n if (!this.objectId) {\n return this.customAttributesValues;\n }\n return this.rs.customAttributesValues[this.type].get(this.objectId).then((function(_this) {\n return function(customAttributesValues) {\n _this.customAttributes = _this.project[_this.type + \"_custom_attributes\"];\n _this.customAttributesValues = customAttributesValues;\n return customAttributesValues;\n };\n })(this));\n };\n\n CustomAttributesValuesController.prototype.getAttributeValue = function(attribute) {\n var attributeValue;\n attributeValue = _.clone(attribute, false);\n attributeValue.value = this.customAttributesValues.attributes_values[attribute.id];\n return attributeValue;\n };\n\n CustomAttributesValuesController.prototype.updateAttributeValue = function(attributeValue) {\n var attributesValues, onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"custom-attributes-values:edit\");\n };\n })(this);\n onError = (function(_this) {\n return function(response) {\n _this.confirm.notify(\"error\");\n return _this.q.reject();\n };\n })(this);\n attributesValues = _.clone(this.customAttributesValues.attributes_values, true);\n attributesValues[attributeValue.id] = attributeValue.value;\n this.customAttributesValues.attributes_values = attributesValues;\n this.customAttributesValues.id = this.objectId;\n return this.repo.save(this.customAttributesValues).then(onSuccess, onError);\n };\n\n return CustomAttributesValuesController;\n\n })(taiga.Controller);\n\n CustomAttributesValuesDirective = function($templates, $storage) {\n var collapsedHash, link, template, templateFn;\n template = $templates.get(\"custom-attributes/custom-attributes-values.html\", true);\n collapsedHash = function(type) {\n return generateHash([\"custom-attributes-collapsed\", type]);\n };\n link = function($scope, $el, $attrs, $ctrls) {\n var $ctrl, $model;\n $ctrl = $ctrls[0];\n $model = $ctrls[1];\n bindOnce($scope, $attrs.ngModel, function(value) {\n $ctrl.initialize($attrs.type, value.id);\n return $ctrl.loadCustomAttributesValues();\n });\n $el.on(\"click\", \".custom-fields-header a\", function() {\n var collapsed, hash;\n hash = collapsedHash($attrs.type);\n collapsed = !($storage.get(hash) || false);\n $storage.set(hash, collapsed);\n if (collapsed) {\n $el.find(\".custom-fields-header a\").removeClass(\"open\");\n return $el.find(\".custom-fields-body\").removeClass(\"open\");\n } else {\n $el.find(\".custom-fields-header a\").addClass(\"open\");\n return $el.find(\".custom-fields-body\").addClass(\"open\");\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n templateFn = function($el, $attrs) {\n var collapsed;\n collapsed = $storage.get(collapsedHash($attrs.type)) || false;\n return template({\n requiredEditionPerm: $attrs.requiredEditionPerm,\n collapsed: collapsed\n });\n };\n return {\n require: [\"tgCustomAttributesValues\", \"ngModel\"],\n controller: CustomAttributesValuesController,\n controllerAs: \"ctrl\",\n restrict: \"AE\",\n scope: true,\n link: link,\n template: templateFn\n };\n };\n\n module.directive(\"tgCustomAttributesValues\", [\"$tgTemplate\", \"$tgStorage\", \"$translate\", CustomAttributesValuesDirective]);\n\n CustomAttributeValueDirective = function($template, $selectedText, $compile, $translate, datePickerConfigService) {\n var link, template, templateEdit;\n template = $template.get(\"custom-attributes/custom-attribute-value.html\", true);\n templateEdit = $template.get(\"custom-attributes/custom-attribute-value-edit.html\", true);\n link = function($scope, $el, $attrs, $ctrl) {\n var attributeValue, isEditable, prettyDate, render, setFocusAndSelectOnInputField, submit;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n render = function(attributeValue, edit) {\n var ctx, datePickerConfig, editable, html, value;\n if (edit == null) {\n edit = false;\n }\n if (attributeValue.type === DATE_TYPE && attributeValue.value) {\n value = moment(attributeValue.value, \"YYYY-MM-DD\").format(prettyDate);\n } else {\n value = attributeValue.value;\n }\n editable = isEditable();\n ctx = {\n id: attributeValue.id,\n name: attributeValue.name,\n description: attributeValue.description,\n value: value,\n isEditable: editable,\n type: attributeValue.type\n };\n if (editable && (edit || !value)) {\n html = templateEdit(ctx);\n html = $compile(html)($scope);\n $el.html(html);\n if (attributeValue.type === DATE_TYPE) {\n datePickerConfig = datePickerConfigService.get();\n _.merge(datePickerConfig, {\n field: $el.find(\"input[name=value]\")[0],\n onSelect: (function(_this) {\n return function(date) {\n var selectedDate;\n return selectedDate = date;\n };\n })(this),\n onOpen: (function(_this) {\n return function() {\n if (typeof selectedDate !== \"undefined\" && selectedDate !== null) {\n return $el.picker.setDate(selectedDate);\n }\n };\n })(this)\n });\n return $el.picker = new Pikaday(datePickerConfig);\n }\n } else {\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n }\n };\n isEditable = function() {\n var permissions, requiredEditionPerm;\n permissions = $scope.project.my_permissions;\n requiredEditionPerm = $attrs.requiredEditionPerm;\n return permissions.indexOf(requiredEditionPerm) > -1;\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n attributeValue.value = $el.find(\"input[name=value], textarea[name='value']\").val();\n if (attributeValue.type === DATE_TYPE) {\n if (moment(attributeValue.value, prettyDate).isValid()) {\n attributeValue.value = moment(attributeValue.value, prettyDate).format(\"YYYY-MM-DD\");\n } else {\n attributeValue.value = \"\";\n }\n }\n return $scope.$apply(function() {\n return $ctrl.updateAttributeValue(attributeValue).then(function() {\n return render(attributeValue, false);\n });\n });\n };\n })(this));\n setFocusAndSelectOnInputField = function() {\n return $el.find(\"input[name='value'], textarea[name='value']\").focus().select();\n };\n attributeValue = $scope.$eval($attrs.tgCustomAttributeValue);\n render(attributeValue);\n $el.on(\"click\", \".js-value-view-mode\", function() {\n if (!isEditable()) {\n return;\n }\n if ($selectedText.get().length) {\n return;\n }\n render(attributeValue, true);\n return setFocusAndSelectOnInputField();\n });\n $el.on(\"click\", \"a.icon-edit\", function(event) {\n event.preventDefault();\n render(attributeValue, true);\n return setFocusAndSelectOnInputField();\n });\n $el.on(\"keyup\", \"input[name=value], textarea[name='value']\", function(event) {\n if (event.keyCode === 13 && event.currentTarget.type !== \"textarea\") {\n return submit(event);\n } else if (event.keyCode === 27) {\n return render(attributeValue, false);\n }\n });\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \"a.icon-floppy\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"^tgCustomAttributesValues\",\n restrict: \"AE\"\n };\n };\n\n module.directive(\"tgCustomAttributeValue\", [\"$tgTemplate\", \"$selectedText\", \"$compile\", \"$translate\", \"tgDatePickerConfigService\", CustomAttributeValueDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/estimation.coffee\n */\n\n(function() {\n var EstimationsService, LbUsEstimationDirective, UsEstimationDirective, groupBy, module, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaCommon\");\n\n LbUsEstimationDirective = function($tgEstimationsService, $rootScope, $repo, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $scope.$watch($attrs.ngModel, function(us) {\n var estimationProcess;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return $scope.$apply(function() {\n return $model.$setViewValue(us);\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, template;\n ctx = {\n totalPoints: this.calculateTotalPoints(),\n roles: this.calculateRoles(),\n editable: this.isEditable\n };\n mainTemplate = \"common/estimation/us-estimation-points-per-role.html\";\n template = $template.get(mainTemplate, true);\n html = template(ctx);\n html = $compile(html)($scope);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgLbUsEstimation\", [\"$tgEstimationsService\", \"$rootScope\", \"$tgRepo\", \"$tgTemplate\", \"$compile\", LbUsEstimationDirective]);\n\n UsEstimationDirective = function($tgEstimationsService, $rootScope, $repo, $qqueue, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $scope.$watch($attrs.ngModel, function(us) {\n var estimationProcess;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return this.save(roleId, pointId).then(function() {\n return $rootScope.$broadcast(\"object:updated\");\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, template;\n ctx = {\n totalPoints: this.calculateTotalPoints(),\n roles: this.calculateRoles(),\n editable: this.isEditable\n };\n mainTemplate = \"common/estimation/us-estimation-points-per-role.html\";\n template = $template.get(mainTemplate, true);\n html = template(ctx);\n html = $compile(html)($scope);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsEstimation\", [\"$tgEstimationsService\", \"$rootScope\", \"$tgRepo\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsEstimationDirective]);\n\n EstimationsService = function($template, $qqueue, $repo, $confirm, $q) {\n var EstimationProcess, create, pointsTemplate;\n pointsTemplate = $template.get(\"common/estimation/us-estimation-points.html\", true);\n EstimationProcess = (function() {\n function EstimationProcess($el1, us1, project1) {\n this.$el = $el1;\n this.us = us1;\n this.project = project1;\n this.bindClickEvents = bind(this.bindClickEvents, this);\n this.isEditable = this.project.my_permissions.indexOf(\"modify_us\") !== -1;\n this.roles = this.project.roles;\n this.points = this.project.points;\n this.pointsById = groupBy(this.points, function(x) {\n return x.id;\n });\n this.onSelectedPointForRole = function(roleId, pointId) {};\n this.render = function() {};\n }\n\n EstimationProcess.prototype.save = function(roleId, pointId) {\n var deferred;\n deferred = $q.defer();\n $qqueue.add((function(_this) {\n return function() {\n var onError, onSuccess;\n onSuccess = function() {\n return deferred.resolve();\n };\n onError = function() {\n $confirm.notify(\"error\");\n _this.us.revert();\n _this.render();\n return deferred.reject();\n };\n return $repo.save(_this.us).then(onSuccess, onError);\n };\n })(this));\n return deferred.promise;\n };\n\n EstimationProcess.prototype.calculateTotalPoints = function() {\n var notNullValues, values;\n values = _.map(this.us.points, (function(_this) {\n return function(v, k) {\n var ref;\n return (ref = _this.pointsById[v]) != null ? ref.value : void 0;\n };\n })(this));\n if (values.length === 0) {\n return \"0\";\n }\n notNullValues = _.filter(values, function(v) {\n return v != null;\n });\n if (notNullValues.length === 0) {\n return \"?\";\n }\n return _.reduce(notNullValues, function(acc, num) {\n return acc + num;\n });\n };\n\n EstimationProcess.prototype.calculateRoles = function() {\n var computableRoles, roles;\n computableRoles = _.filter(this.project.roles, \"computable\");\n roles = _.map(computableRoles, (function(_this) {\n return function(role) {\n var pointId, pointObj;\n pointId = _this.us.points[role.id];\n pointObj = _this.pointsById[pointId];\n role = _.clone(role, true);\n role.points = (pointObj != null) && (pointObj.name != null) ? pointObj.name : \"?\";\n return role;\n };\n })(this));\n return roles;\n };\n\n EstimationProcess.prototype.bindClickEvents = function() {\n this.$el.on(\"click\", \".total.clickable\", (function(_this) {\n return function(event) {\n var roleId, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n roleId = target.data(\"role-id\");\n _this.renderPointsSelector(roleId, target);\n target.siblings().removeClass('active');\n return target.addClass('active');\n };\n })(this));\n return this.$el.on(\"click\", \".point\", (function(_this) {\n return function(event) {\n var pointId, points, roleId, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n roleId = target.data(\"role-id\");\n pointId = target.data(\"point-id\");\n _this.$el.find(\".popover\").popover().close();\n points = _.clone(_this.us.points, true);\n points[roleId] = pointId;\n _this.us.points = points;\n _this.render();\n return _this.onSelectedPointForRole(roleId, pointId);\n };\n })(this));\n };\n\n EstimationProcess.prototype.renderPointsSelector = function(roleId, target) {\n var horizontalList, html, maxPointLength, points, pop;\n points = _.map(this.points, (function(_this) {\n return function(point) {\n point = _.clone(point, true);\n point.selected = _this.us.points[roleId] === point.id ? false : true;\n return point;\n };\n })(this));\n maxPointLength = 5;\n horizontalList = _.some(points, (function(_this) {\n return function(point) {\n return point.name.length > maxPointLength;\n };\n })(this));\n html = pointsTemplate({\n \"points\": points,\n roleId: roleId,\n horizontal: horizontalList\n });\n this.$el.find(\".popover\").popover().close();\n this.$el.find(\".pop-points-open\").remove();\n if (target != null) {\n this.$el.find(target).append(html);\n } else {\n this.$el.append(html);\n }\n this.$el.find(\".pop-points-open\").popover().open(function() {\n return $(this).removeClass(\"active\").closest(\"li\").removeClass(\"active\");\n });\n this.$el.find(\".pop-points-open\").show();\n pop = this.$el.find(\".pop-points-open\");\n if (pop.offset().top + pop.height() > document.body.clientHeight) {\n return pop.addClass('pop-bottom');\n }\n };\n\n return EstimationProcess;\n\n })();\n create = function($el, us, project) {\n var estimationProcess;\n $el.unbind(\"click\");\n estimationProcess = new EstimationProcess($el, us, project);\n if (estimationProcess.isEditable) {\n estimationProcess.bindClickEvents();\n }\n return estimationProcess;\n };\n return {\n create: create\n };\n };\n\n module.factory(\"$tgEstimationsService\", [\"$tgTemplate\", \"$tgQqueue\", \"$tgRepo\", \"$tgConfirm\", \"$q\", EstimationsService]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/filters.coffee\n */\n\n(function() {\n var defaultFilter, module, momentFormat, momentFromNow, sizeFormat, taiga, unslugify, yesNoFilter;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n defaultFilter = function() {\n return function(value, defaultValue) {\n if (value === [null, void 0]) {\n return defaultValue;\n }\n return value;\n };\n };\n\n module.filter(\"default\", defaultFilter);\n\n yesNoFilter = function($translate) {\n return function(value) {\n if (value) {\n return $translate.instant(\"COMMON.YES\");\n }\n return $translate.instant(\"COMMON.NO\");\n };\n };\n\n module.filter(\"yesNo\", [\"$translate\", yesNoFilter]);\n\n unslugify = function() {\n return taiga.unslugify;\n };\n\n module.filter(\"unslugify\", unslugify);\n\n momentFormat = function() {\n return function(input, format) {\n if (input) {\n return moment(input).format(format);\n }\n return \"\";\n };\n };\n\n module.filter(\"momentFormat\", momentFormat);\n\n momentFromNow = function() {\n return function(input, without_suffix) {\n if (input) {\n return moment(input).fromNow(without_suffix || false);\n }\n return \"\";\n };\n };\n\n module.filter(\"momentFromNow\", momentFromNow);\n\n sizeFormat = (function(_this) {\n return function() {\n return _this.taiga.sizeFormat;\n };\n })(this);\n\n module.filter(\"sizeFormat\", sizeFormat);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/history.coffee\n */\n\n(function() {\n var HistoryController, HistoryDirective, IGNORED_FIELDS, bindOnce, debounce, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaCommon\");\n\n IGNORED_FIELDS = {\n \"userstories.userstory\": [\"watchers\", \"kanban_order\", \"backlog_order\", \"sprint_order\", \"finish_date\", \"tribe_gig\"],\n \"tasks.task\": [\"watchers\", \"us_order\", \"taskboard_order\"],\n \"issues.issue\": [\"watchers\"]\n };\n\n HistoryController = (function(superClass) {\n extend(HistoryController, superClass);\n\n HistoryController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\"];\n\n function HistoryController(scope, repo, rs) {\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n }\n\n HistoryController.prototype.initialize = function(type, objectId) {\n this.type = type;\n return this.objectId = objectId;\n };\n\n HistoryController.prototype.loadHistory = function(type, objectId) {\n return this.rs.history.get(type, objectId).then((function(_this) {\n return function(history) {\n var changeModel, historyEntry, historyResult, i, j, len, len1;\n for (i = 0, len = history.length; i < len; i++) {\n historyResult = history[i];\n if (historyResult.values_diff.description_diff != null) {\n historyResult.values_diff.description = historyResult.values_diff.description_diff;\n }\n delete historyResult.values_diff.description_html;\n delete historyResult.values_diff.description_diff;\n if (historyResult.values_diff.blocked_note_diff != null) {\n historyResult.values_diff.blocked_note = historyResult.values_diff.blocked_note_diff;\n }\n delete historyResult.values_diff.blocked_note_html;\n delete historyResult.values_diff.blocked_note_diff;\n }\n for (j = 0, len1 = history.length; j < len1; j++) {\n historyEntry = history[j];\n changeModel = historyEntry.key.split(\":\")[0];\n if (IGNORED_FIELDS[changeModel] != null) {\n historyEntry.values_diff = _.removeKeys(historyEntry.values_diff, IGNORED_FIELDS[changeModel]);\n }\n }\n _this.scope.history = _.filter(history, function(item) {\n return Object.keys(item.values_diff).length > 0;\n });\n return _this.scope.comments = _.filter(history, function(item) {\n return item.comment !== \"\";\n });\n };\n })(this));\n };\n\n HistoryController.prototype.deleteComment = function(type, objectId, activityId) {\n return this.rs.history.deleteComment(type, objectId, activityId).then((function(_this) {\n return function() {\n return _this.loadHistory(type, objectId);\n };\n })(this));\n };\n\n HistoryController.prototype.undeleteComment = function(type, objectId, activityId) {\n return this.rs.history.undeleteComment(type, objectId, activityId).then((function(_this) {\n return function() {\n return _this.loadHistory(type, objectId);\n };\n })(this));\n };\n\n return HistoryController;\n\n })(taiga.Controller);\n\n HistoryDirective = function($log, $loading, $qqueue, $template, $confirm, $translate, $compile, $navUrls, $rootScope) {\n var link, templateActivity, templateBase, templateBaseEntries, templateChangeAttachment, templateChangeDiff, templateChangeGeneric, templateChangeList, templateChangePoints, templateDeletedComment, templateFn;\n templateChangeDiff = $template.get(\"common/history/history-change-diff.html\", true);\n templateChangePoints = $template.get(\"common/history/history-change-points.html\", true);\n templateChangeGeneric = $template.get(\"common/history/history-change-generic.html\", true);\n templateChangeAttachment = $template.get(\"common/history/history-change-attachment.html\", true);\n templateChangeList = $template.get(\"common/history/history-change-list.html\", true);\n templateDeletedComment = $template.get(\"common/history/history-deleted-comment.html\", true);\n templateActivity = $template.get(\"common/history/history-activity.html\", true);\n templateBaseEntries = $template.get(\"common/history/history-base-entries.html\", true);\n templateBase = $template.get(\"common/history/history-base.html\", true);\n link = function($scope, $el, $attrs, $ctrl) {\n var countChanges, formatChange, getHumanizedFieldName, getPrettyDateFormat, objectId, renderActivity, renderAttachmentEntry, renderChange, renderChangeEntries, renderChangeEntry, renderChangesHelperText, renderComment, renderComments, renderCustomAttributesEntry, renderHistory, save, showAllActivity, showAllComments, type;\n type = $attrs.type;\n objectId = null;\n showAllComments = false;\n showAllActivity = false;\n getPrettyDateFormat = function() {\n return $translate.instant(\"ACTIVITY.DATETIME\");\n };\n bindOnce($scope, $attrs.ngModel, function(model) {\n type = $attrs.type;\n objectId = model.id;\n $ctrl.initialize(type, objectId);\n return $ctrl.loadHistory(type, objectId);\n });\n getHumanizedFieldName = function(field) {\n var humanizedFieldNames;\n humanizedFieldNames = {\n subject: $translate.instant(\"ACTIVITY.FIELDS.SUBJECT\"),\n name: $translate.instant(\"ACTIVITY.FIELDS.NAME\"),\n description: $translate.instant(\"ACTIVITY.FIELDS.DESCRIPTION\"),\n content: $translate.instant(\"ACTIVITY.FIELDS.CONTENT\"),\n status: $translate.instant(\"ACTIVITY.FIELDS.STATUS\"),\n is_closed: $translate.instant(\"ACTIVITY.FIELDS.IS_CLOSED\"),\n finish_date: $translate.instant(\"ACTIVITY.FIELDS.FINISH_DATE\"),\n type: $translate.instant(\"ACTIVITY.FIELDS.TYPE\"),\n priority: $translate.instant(\"ACTIVITY.FIELDS.PRIORITY\"),\n severity: $translate.instant(\"ACTIVITY.FIELDS.SEVERITY\"),\n assigned_to: $translate.instant(\"ACTIVITY.FIELDS.ASSIGNED_TO\"),\n watchers: $translate.instant(\"ACTIVITY.FIELDS.WATCHERS\"),\n milestone: $translate.instant(\"ACTIVITY.FIELDS.MILESTONE\"),\n user_story: $translate.instant(\"ACTIVITY.FIELDS.USER_STORY\"),\n project: $translate.instant(\"ACTIVITY.FIELDS.PROJECT\"),\n is_blocked: $translate.instant(\"ACTIVITY.FIELDS.IS_BLOCKED\"),\n blocked_note: $translate.instant(\"ACTIVITY.FIELDS.BLOCKED_NOTE\"),\n points: $translate.instant(\"ACTIVITY.FIELDS.POINTS\"),\n client_requirement: $translate.instant(\"ACTIVITY.FIELDS.CLIENT_REQUIREMENT\"),\n team_requirement: $translate.instant(\"ACTIVITY.FIELDS.TEAM_REQUIREMENT\"),\n is_iocaine: $translate.instant(\"ACTIVITY.FIELDS.IS_IOCAINE\"),\n tags: $translate.instant(\"ACTIVITY.FIELDS.TAGS\"),\n attachments: $translate.instant(\"ACTIVITY.FIELDS.ATTACHMENTS\"),\n is_deprecated: $translate.instant(\"ACTIVITY.FIELDS.IS_DEPRECATED\"),\n blocked_note: $translate.instant(\"ACTIVITY.FIELDS.BLOCKED_NOTE\"),\n is_blocked: $translate.instant(\"ACTIVITY.FIELDS.IS_BLOCKED\"),\n order: $translate.instant(\"ACTIVITY.FIELDS.ORDER\"),\n backlog_order: $translate.instant(\"ACTIVITY.FIELDS.BACKLOG_ORDER\"),\n sprint_order: $translate.instant(\"ACTIVITY.FIELDS.SPRINT_ORDER\"),\n kanban_order: $translate.instant(\"ACTIVITY.FIELDS.KANBAN_ORDER\"),\n taskboard_order: $translate.instant(\"ACTIVITY.FIELDS.TASKBOARD_ORDER\"),\n us_order: $translate.instant(\"ACTIVITY.FIELDS.US_ORDER\")\n };\n return humanizedFieldNames[field] || field;\n };\n countChanges = function(comment) {\n return _.keys(comment.values_diff).length;\n };\n formatChange = function(change) {\n if (_.isArray(change)) {\n if (change.length === 0) {\n return $translate.instant(\"ACTIVITY.VALUES.EMPTY\");\n }\n return change.join(\", \");\n }\n if (change === \"\") {\n return $translate.instant(\"ACTIVITY.VALUES.EMPTY\");\n }\n if ((change == null) || change === false) {\n return $translate.instant(\"ACTIVITY.VALUES.NO\");\n }\n if (change === true) {\n return $translate.instant(\"ACTIVITY.VALUES.YES\");\n }\n return change;\n };\n renderAttachmentEntry = function(value) {\n var attachments;\n attachments = _.map(value, function(changes, type) {\n if (type === \"new\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.NEW_ATTACHMENT\"),\n diff: change.filename\n });\n });\n } else if (type === \"deleted\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.DELETED_ATTACHMENT\"),\n diff: change.filename\n });\n });\n } else {\n return _.map(changes, function(change) {\n var diff, name;\n name = $translate.instant(\"ACTIVITY.UPDATED_ATTACHMENT\", {\n filename: change.filename\n });\n diff = _.map(change.changes, function(values, name) {\n return {\n name: getHumanizedFieldName(name),\n from: formatChange(values[0]),\n to: formatChange(values[1])\n };\n });\n return templateChangeAttachment({\n name: name,\n diff: diff\n });\n });\n }\n });\n return _.flatten(attachments).join(\"\\n\");\n };\n renderCustomAttributesEntry = function(value) {\n var customAttributes;\n customAttributes = _.map(value, function(changes, type) {\n if (type === \"new\") {\n return _.map(changes, function(change) {\n var html;\n html = templateChangeGeneric({\n name: change.name,\n from: formatChange(\"\"),\n to: formatChange(change.value)\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n });\n } else if (type === \"deleted\") {\n return _.map(changes, function(change) {\n return templateChangeDiff({\n name: $translate.instant(\"ACTIVITY.DELETED_CUSTOM_ATTRIBUTE\"),\n diff: change.name\n });\n });\n } else {\n return _.map(changes, function(change) {\n var customAttrsChanges;\n customAttrsChanges = _.map(change.changes, function(values) {\n return templateChangeGeneric({\n name: change.name,\n from: formatChange(values[0]),\n to: formatChange(values[1])\n });\n });\n return _.flatten(customAttrsChanges).join(\"\\n\");\n });\n }\n });\n return _.flatten(customAttributes).join(\"\\n\");\n };\n renderChangeEntry = function(field, value) {\n var added, from, html, name, removed, to;\n if (field === \"description\") {\n return templateChangeDiff({\n name: getHumanizedFieldName(\"description\"),\n diff: value[1]\n });\n } else if (field === \"blocked_note\") {\n return templateChangeDiff({\n name: getHumanizedFieldName(\"blocked_note\"),\n diff: value[1]\n });\n } else if (field === \"points\") {\n html = templateChangePoints({\n points: value\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n } else if (field === \"attachments\") {\n return renderAttachmentEntry(value);\n } else if (field === \"custom_attributes\") {\n return renderCustomAttributesEntry(value);\n } else if (field === \"tags\" || field === \"watchers\") {\n name = getHumanizedFieldName(field);\n removed = _.difference(value[0], value[1]);\n added = _.difference(value[1], value[0]);\n html = templateChangeList({\n name: name,\n removed: removed,\n added: added\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n } else if (field === \"assigned_to\") {\n name = getHumanizedFieldName(field);\n from = formatChange(value[0] || $translate.instant(\"ACTIVITY.VALUES.UNASSIGNED\"));\n to = formatChange(value[1] || $translate.instant(\"ACTIVITY.VALUES.UNASSIGNED\"));\n return templateChangeGeneric({\n name: name,\n from: from,\n to: to\n });\n } else {\n name = getHumanizedFieldName(field);\n from = formatChange(value[0]);\n to = formatChange(value[1]);\n return templateChangeGeneric({\n name: name,\n from: from,\n to: to\n });\n }\n };\n renderChangeEntries = function(change) {\n return _.map(change.values_diff, function(value, field) {\n return renderChangeEntry(field, value);\n });\n };\n renderChangesHelperText = function(change) {\n var size;\n size = countChanges(change);\n return $translate.instant(\"ACTIVITY.SIZE_CHANGE\", {\n size: size\n }, 'messageformat');\n };\n renderComment = function(comment) {\n var html, ref, ref1, ref2;\n if (comment.delete_comment_date || ((ref = comment.delete_comment_user) != null ? ref.name : void 0)) {\n html = templateDeletedComment({\n deleteCommentDate: comment.delete_comment_date ? moment(comment.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: comment.delete_comment_user.name,\n deleteComment: comment.comment_html,\n activityId: comment.id,\n canRestoreComment: $scope.user && (comment.delete_comment_user.pk === $scope.user.id || $scope.project.my_permissions.indexOf(\"modify_project\") > -1)\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n }\n html = templateActivity({\n avatar: comment.user.photo,\n userFullName: comment.user.name,\n userProfileUrl: comment.user.is_active ? $navUrls.resolve(\"user-profile\", {\n username: comment.user.username\n }) : \"\",\n creationDate: moment(comment.created_at).format(getPrettyDateFormat()),\n comment: comment.comment_html,\n changesText: renderChangesHelperText(comment),\n changes: renderChangeEntries(comment),\n mode: \"comment\",\n deleteCommentActionTitle: $translate.instant(\"COMMENTS.DELETE\"),\n deleteCommentDate: comment.delete_comment_date ? moment(comment.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: ((ref1 = comment.delete_comment_user) != null ? ref1.name : void 0) ? comment.delete_comment_user.name : void 0,\n activityId: comment.id,\n canDeleteComment: comment.user.pk === ((ref2 = $scope.user) != null ? ref2.id : void 0) || $scope.project.my_permissions.indexOf(\"modify_project\") > -1\n });\n html = $compile(html)($scope);\n return html[0].outerHTML;\n };\n renderChange = function(change) {\n var ref;\n return templateActivity({\n avatar: change.user.photo,\n userFullName: change.user.name,\n userProfileUrl: change.user.is_active ? $navUrls.resolve(\"user-profile\", {\n username: change.user.username\n }) : \"\",\n creationDate: moment(change.created_at).format(getPrettyDateFormat()),\n comment: change.comment_html,\n changes: renderChangeEntries(change),\n changesText: \"\",\n mode: \"activity\",\n deleteCommentDate: change.delete_comment_date ? moment(change.delete_comment_date).format(getPrettyDateFormat()) : void 0,\n deleteCommentUser: ((ref = change.delete_comment_user) != null ? ref.name : void 0) ? change.delete_comment_user.name : void 0,\n activityId: change.id\n });\n };\n renderHistory = function(entries, totalEntries) {\n var html, showMore;\n if (entries.length === totalEntries) {\n showMore = 0;\n } else {\n showMore = totalEntries - entries.length;\n }\n html = templateBaseEntries({\n entries: entries,\n showMore: showMore\n });\n html = $compile(html)($scope);\n return html;\n };\n renderComments = function() {\n var comments, html, totalComments;\n comments = $scope.comments || [];\n totalComments = comments.length;\n if (!showAllComments) {\n comments = _.last(comments, 4);\n }\n comments = _.map(comments, function(x) {\n return renderComment(x);\n });\n html = renderHistory(comments, totalComments);\n return $el.find(\".comments-list\").html(html);\n };\n renderActivity = function() {\n var changes, html, totalChanges;\n changes = $scope.history || [];\n totalChanges = changes.length;\n if (!showAllActivity) {\n changes = _.last(changes, 4);\n }\n changes = _.map(changes, function(x) {\n return renderChange(x);\n });\n html = renderHistory(changes, totalChanges);\n return $el.find(\".changes-list\").html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(target) {\n var currentLoading, model, onError, onSuccess;\n $scope.$broadcast(\"markdown-editor:submit\");\n $el.find(\".comment-list\").addClass(\"activeanimation\");\n currentLoading = $loading().target(target).start();\n onSuccess = function() {\n $rootScope.$broadcast(\"comment:new\");\n return $ctrl.loadHistory(type, objectId)[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n onError = function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n };\n model = $scope.$eval($attrs.ngModel);\n return $ctrl.repo.save(model).then(onSuccess, onError);\n };\n })(this));\n $scope.$watch(\"comments\", renderComments);\n $scope.$watch(\"history\", renderActivity);\n $scope.$on(\"object:updated\", function() {\n return $ctrl.loadHistory(type, objectId);\n });\n $el.on(\"click\", \".add-comment button.button-green\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return save(target);\n }));\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href && href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"click\", \".show-more\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n if (target.parent().is(\".changes-list\")) {\n showAllActivity = !showAllActivity;\n return renderActivity();\n } else {\n showAllComments = !showAllComments;\n return renderComments();\n }\n });\n $el.on(\"click\", \".show-deleted-comment\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.parents('.activity-single').find('.hide-deleted-comment').show();\n target.parents('.activity-single').find('.show-deleted-comment').hide();\n return target.parents('.activity-single').find('.comment-body').show();\n });\n $el.on(\"click\", \".hide-deleted-comment\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.parents('.activity-single').find('.hide-deleted-comment').hide();\n target.parents('.activity-single').find('.show-deleted-comment').show();\n return target.parents('.activity-single').find('.comment-body').hide();\n });\n $el.on(\"click\", \".changes-title\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return target.parent().find(\".change-entry\").toggleClass(\"active\");\n });\n $el.on(\"focus\", \".add-comment textarea\", function(event) {\n return $(this).addClass('active');\n });\n $el.on(\"click\", \".history-tabs li a\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n $el.find(\".history-tabs li a\").removeClass(\"active\");\n target.addClass(\"active\");\n $el.find(\".history section\").addClass(\"hidden\");\n return $el.find(\".history section.\" + (target.data('section-class'))).removeClass(\"hidden\");\n });\n $el.on(\"click\", \".comment-delete\", debounce(2000, function(event) {\n var activityId, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n activityId = target.data('activity-id');\n return $ctrl.deleteComment(type, objectId, activityId);\n }));\n $el.on(\"click\", \".comment-restore\", debounce(2000, function(event) {\n var activityId, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n activityId = target.data('activity-id');\n return $ctrl.undeleteComment(type, objectId, activityId);\n }));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n templateFn = function($el, $attrs) {\n var html;\n html = templateBase({\n ngmodel: $attrs.ngModel,\n type: $attrs.type,\n mode: $attrs.mode\n });\n return html;\n };\n return {\n controller: HistoryController,\n template: templateFn,\n restrict: \"AE\",\n link: link\n };\n };\n\n module.directive(\"tgHistory\", [\"$log\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$tgConfirm\", \"$translate\", \"$compile\", \"$tgNavUrls\", \"$rootScope\", HistoryDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/importer.coffee\n */\n\n(function() {\n var ImportProjectButtonDirective, module;\n\n module = angular.module(\"taigaCommon\");\n\n ImportProjectButtonDirective = function($rs, $confirm, $location, $navUrls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n $el.on(\"click\", \".import-project-button\", function(event) {\n event.preventDefault();\n $el.find(\"input.import-file\").val(\"\");\n return $el.find(\"input.import-file\").trigger(\"click\");\n });\n return $el.on(\"change\", \"input.import-file\", function(event) {\n var file, loader, onError, onSuccess;\n event.preventDefault();\n file = event.target.files[0];\n if (!file) {\n return;\n }\n loader = $confirm.loader($translate.instant(\"PROJECT.IMPORT.UPLOADING_FILE\"));\n onSuccess = function(result) {\n var ctx, message, msg, title;\n loader.stop();\n if (result.status === 202) {\n title = $translate.instant(\"PROJECT.IMPORT.ASYNC_IN_PROGRESS_TITLE\");\n message = $translate.instant(\"PROJECT.IMPORT.ASYNC_IN_PROGRESS_MESSAGE\");\n return $confirm.success(title, message);\n } else {\n ctx = {\n project: result.data.slug\n };\n $location.path($navUrls.resolve(\"project-admin-project-profile-details\", ctx));\n msg = $translate.instant(\"PROJECT.IMPORT.SYNC_SUCCESS\");\n return $confirm.notify(\"success\", msg);\n }\n };\n onError = function(result) {\n var errorMsg, ref;\n loader.stop();\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR\");\n if (result.status === 429) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_TOO_MANY_REQUEST\");\n } else if ((ref = result.data) != null ? ref._error_message : void 0) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_MESSAGE\", {\n error_message: result.data._error_message\n });\n }\n return $confirm.notify(\"error\", errorMsg);\n };\n loader.start();\n return $rs.projects[\"import\"](file, loader.update).then(onSuccess, onError);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgImportProjectButton\", [\"$tgResources\", \"$tgConfirm\", \"$location\", \"$tgNavUrls\", \"$translate\", ImportProjectButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/lightboxes.coffee\n */\n\n(function() {\n var AssignedToLightboxDirective, AttachmentPreviewLightboxDirective, BlockLightboxDirective, BlockingMessageInputDirective, CreateBulkUserstoriesDirective, CreateEditUserstoryDirective, LightboxDirective, LightboxKeyboardNavigationService, LightboxService, WatchersLightboxDirective, bindOnce, debounce, module, sizeFormat, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n module = angular.module(\"taigaCommon\");\n\n bindOnce = this.taiga.bindOnce;\n\n timeout = this.taiga.timeout;\n\n debounce = this.taiga.debounce;\n\n sizeFormat = this.taiga.sizeFormat;\n\n LightboxService = (function(superClass) {\n extend(LightboxService, superClass);\n\n function LightboxService(animationFrame, q) {\n this.animationFrame = animationFrame;\n this.q = q;\n }\n\n LightboxService.prototype.open = function($el) {\n var defered, docEl, lightboxContent;\n defered = this.q.defer();\n lightboxContent = $el.children().not(\".close\");\n lightboxContent.hide();\n this.animationFrame.add(function() {\n return $el.css('display', 'flex');\n });\n this.animationFrame.add(function() {\n $el.addClass(\"open\");\n return $el.one(\"transitionend\", (function(_this) {\n return function() {\n return $el.find('input,textarea').first().focus();\n };\n })(this));\n });\n this.animationFrame.add((function(_this) {\n return function() {\n lightboxContent.show();\n return defered.resolve();\n };\n })(this));\n docEl = angular.element(document);\n docEl.on(\"keydown.lightbox\", (function(_this) {\n return function(e) {\n var code;\n code = e.keyCode ? e.keyCode : e.which;\n if (code === 27) {\n return _this.close($el);\n }\n };\n })(this));\n return defered.promise;\n };\n\n LightboxService.prototype.close = function($el) {\n var docEl, scope;\n docEl = angular.element(document);\n docEl.off(\".lightbox\");\n docEl.off(\".keyboard-navigation\");\n $el.one(\"transitionend\", (function(_this) {\n return function() {\n $el.removeAttr('style');\n return $el.removeClass(\"open\").removeClass('close');\n };\n })(this));\n $el.addClass('close');\n if ($el.hasClass(\"remove-on-close\")) {\n scope = $el.data(\"scope\");\n scope.$destroy();\n return $el.remove();\n }\n };\n\n LightboxService.prototype.closeAll = function() {\n var docEl, i, len, lightboxEl, ref, results;\n docEl = angular.element(document);\n ref = docEl.find(\".lightbox.open\");\n results = [];\n for (i = 0, len = ref.length; i < len; i++) {\n lightboxEl = ref[i];\n results.push(this.close($(lightboxEl)));\n }\n return results;\n };\n\n return LightboxService;\n\n })(taiga.Service);\n\n module.service(\"lightboxService\", [\"animationFrame\", \"$q\", LightboxService]);\n\n LightboxKeyboardNavigationService = (function(superClass) {\n extend(LightboxKeyboardNavigationService, superClass);\n\n function LightboxKeyboardNavigationService() {\n return LightboxKeyboardNavigationService.__super__.constructor.apply(this, arguments);\n }\n\n LightboxKeyboardNavigationService.prototype.stop = function() {\n var docEl;\n docEl = angular.element(document);\n return docEl.off(\".keyboard-navigation\");\n };\n\n LightboxKeyboardNavigationService.prototype.dispatch = function($el, code) {\n var activeElement, next, prev;\n activeElement = $el.find(\".selected\");\n if (code === 13) {\n if ($el.find(\".user-list-single\").length === 1) {\n return $el.find('.user-list-single:first').trigger(\"click\");\n } else {\n return activeElement.trigger(\"click\");\n }\n } else if (code === 40) {\n if (!activeElement.length) {\n return $el.find('.user-list-single:not(\".is-active\"):first').addClass('selected');\n } else {\n next = activeElement.next('.user-list-single');\n if (next.length) {\n activeElement.removeClass('selected');\n return next.addClass('selected');\n }\n }\n } else if (code === 38) {\n if (!activeElement.length) {\n return $el.find('.user-list-single:last').addClass('selected');\n } else {\n prev = activeElement.prev('.user-list-single:not(\".is-active\")');\n if (prev.length) {\n activeElement.removeClass('selected');\n return prev.addClass('selected');\n }\n }\n }\n };\n\n LightboxKeyboardNavigationService.prototype.init = function($el) {\n var docEl;\n this.stop();\n docEl = angular.element(document);\n return docEl.on(\"keydown.keyboard-navigation\", (function(_this) {\n return function(event) {\n var code;\n code = event.keyCode ? event.keyCode : event.which;\n if (code === 40 || code === 38 || code === 13) {\n event.preventDefault();\n return _this.dispatch($el, code);\n }\n };\n })(this));\n };\n\n return LightboxKeyboardNavigationService;\n\n })(taiga.Service);\n\n module.service(\"lightboxKeyboardNavigationService\", LightboxKeyboardNavigationService);\n\n LightboxDirective = function(lightboxService) {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n };\n return {\n restrict: \"C\",\n link: link\n };\n };\n\n module.directive(\"lightbox\", [\"lightboxService\", LightboxDirective]);\n\n BlockLightboxDirective = function($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue, $translate) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var block, title, unblock;\n title = $translate.instant($attrs.title);\n $el.find(\"h2.title\").text(title);\n unblock = $qqueue.bindAdd((function(_this) {\n return function(item, finishCallback) {\n var promise;\n promise = $tgrepo.save(item);\n promise.then(function() {\n $confirm.notify(\"success\");\n $rootscope.$broadcast(\"object:updated\");\n $model.$setViewValue(item);\n return finishCallback();\n });\n promise.then(null, function() {\n $confirm.notify(\"error\");\n item.revert();\n return $model.$setViewValue(item);\n });\n promise[\"finally\"](function() {\n return finishCallback();\n });\n return promise;\n };\n })(this));\n block = $qqueue.bindAdd((function(_this) {\n return function(item) {\n var currentLoading, promise;\n $model.$setViewValue(item);\n currentLoading = $loading().target($el.find(\".button-green\")).start();\n promise = $tgrepo.save($model.$modelValue);\n promise.then(function() {\n $confirm.notify(\"success\");\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n $confirm.notify(\"error\");\n item.revert();\n return $model.$setViewValue(item);\n });\n return promise[\"finally\"](function() {\n currentLoading.finish();\n return lightboxService.close($el);\n });\n };\n })(this));\n $scope.$on(\"block\", function() {\n $el.find(\".reason\").val($model.$modelValue.blocked_note);\n return lightboxService.open($el);\n });\n $scope.$on(\"unblock\", (function(_this) {\n return function(event, model, finishCallback) {\n var item;\n item = $model.$modelValue.clone();\n item.is_blocked = false;\n item.blocked_note = \"\";\n return unblock(item, finishCallback);\n };\n })(this));\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return $el.on(\"click\", \".button-green\", function(event) {\n var item;\n event.preventDefault();\n item = $model.$modelValue.clone();\n item.is_blocked = true;\n item.blocked_note = $el.find(\".reason\").val();\n return block(item);\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-block.html\",\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgLbBlock\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"lightboxService\", \"$tgLoading\", \"$tgQqueue\", \"$translate\", BlockLightboxDirective]);\n\n BlockingMessageInputDirective = function($log, $template, $compile) {\n var link, template, templateFn;\n template = $template.get(\"common/lightbox/lightbox-blocking-message-input.html\", true);\n link = function($scope, $el, $attrs, $model) {\n if (!$attrs.watch) {\n return $log.error(\"No watch attribute on tg-blocking-message-input directive\");\n }\n return $scope.$watch($attrs.watch, function(value) {\n if (value === !void 0 && value === true) {\n return $el.find(\".blocked-note\").removeClass(\"hidden\");\n } else {\n return $el.find(\".blocked-note\").addClass(\"hidden\");\n }\n });\n };\n templateFn = function($el, $attrs) {\n return template({\n ngmodel: $attrs.ngModel\n });\n };\n return {\n template: templateFn,\n link: link,\n require: \"ngModel\",\n restrict: \"EA\"\n };\n };\n\n module.directive(\"tgBlockingMessageInput\", [\"$log\", \"$tgTemplate\", \"$compile\", BlockingMessageInputDirective]);\n\n CreateEditUserstoryDirective = function($repo, $model, $rs, $rootScope, lightboxService, $loading, $translate, $confirm, $q, attachmentsService) {\n var link;\n link = function($scope, $el, attrs) {\n var attachmentsToAdd, attachmentsToDelete, createAttachments, deleteAttachments, resetAttachments, submit, submitButton;\n $scope.createEditUs = {};\n $scope.isNew = true;\n attachmentsToAdd = Immutable.List();\n attachmentsToDelete = Immutable.List();\n resetAttachments = function() {\n attachmentsToAdd = Immutable.List();\n return attachmentsToDelete = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n $scope.deleteAttachment = function(attachment) {\n return attachmentsToDelete = attachmentsToDelete.push(attachment);\n };\n $scope.$on(\"usform:new\", function(ctx, projectId, status, statusList) {\n $scope.isNew = true;\n $scope.usStatusList = statusList;\n $scope.attachments = Immutable.List();\n resetAttachments();\n $scope.us = $model.make_model(\"userstories\", {\n project: projectId,\n points: {},\n status: status,\n is_archived: false,\n tags: []\n });\n $el.find(\".button-green\").html($translate.instant(\"COMMON.CREATE\"));\n $el.find(\".title\").html($translate.instant(\"LIGHTBOX.CREATE_EDIT_US.NEW_US\"));\n $el.find(\".tag-input\").val(\"\");\n $el.find(\".blocked-note\").addClass(\"hidden\");\n $el.find(\"label.blocked\").removeClass(\"selected\");\n $el.find(\"label.team-requirement\").removeClass(\"selected\");\n $el.find(\"label.client-requirement\").removeClass(\"selected\");\n return lightboxService.open($el);\n });\n $scope.$on(\"usform:edit\", function(ctx, us, attachments) {\n $scope.us = us;\n $scope.attachments = Immutable.fromJS(attachments);\n $scope.isNew = false;\n resetAttachments();\n $el.find(\".button-green\").html($translate.instant(\"COMMON.SAVE\"));\n $el.find(\".title\").html($translate.instant(\"LIGHTBOX.CREATE_EDIT_US.EDIT_US\"));\n $el.find(\".tag-input\").val(\"\");\n if (us.is_blocked) {\n $el.find(\".blocked-note\").removeClass(\"hidden\");\n $el.find(\"label.blocked\").addClass(\"selected\");\n } else {\n $el.find(\".blocked-note\").addClass(\"hidden\");\n $el.find(\"label.blocked\").removeClass(\"selected\");\n }\n if (us.team_requirement) {\n $el.find(\"label.team-requirement\").addClass(\"selected\");\n } else {\n $el.find(\"label.team-requirement\").removeClass(\"selected\");\n }\n if (us.client_requirement) {\n $el.find(\"label.client-requirement\").addClass(\"selected\");\n } else {\n $el.find(\"label.client-requirement\").removeClass(\"selected\");\n }\n return lightboxService.open($el);\n });\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.us.project, 'us');\n });\n return $q.all(promises);\n };\n deleteAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToDelete.toJS(), function(attachment) {\n return attachmentsService[\"delete\"](\"us\", attachment.id);\n });\n return $q.all(promises);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n if ($scope.isNew) {\n promise = $repo.create(\"userstories\", $scope.us);\n broadcastEvent = \"usform:new:success\";\n } else {\n promise = $repo.save($scope.us);\n broadcastEvent = \"usform:edit:success\";\n }\n promise.then(function(data) {\n deleteAttachments(data).then((function(_this) {\n return function() {\n return createAttachments(data);\n };\n })(this));\n return data;\n });\n promise.then(function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n return $rootScope.$broadcast(broadcastEvent, data);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n $scope.$apply(function() {\n return $scope.us.revert();\n });\n return lightboxService.close($el);\n });\n $el.keydown(function(event) {\n var code;\n code = event.keyCode ? event.keyCode : event.which;\n if (code === 27) {\n lightboxService.close($el);\n return $scope.$apply(function() {\n return $scope.us.revert();\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateEditUserstory\", [\"$tgRepo\", \"$tgModel\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$translate\", \"$tgConfirm\", \"$q\", \"tgAttachmentsService\", CreateEditUserstoryDirective]);\n\n CreateBulkUserstoriesDirective = function($repo, $rs, $rootscope, lightboxService, $loading) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.$on(\"usform:bulk\", function(ctx, projectId, status) {\n $scope[\"new\"] = {\n projectId: projectId,\n statusId: status,\n bulk: \"\"\n };\n return lightboxService.open($el);\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley({\n onlyOneErrorElement: true\n });\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $rs.userstories.bulkCreate($scope[\"new\"].projectId, $scope[\"new\"].statusId, $scope[\"new\"].bulk);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"usform:bulk:success\", result);\n return lightboxService.close($el);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateBulkUserstories\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", CreateBulkUserstoriesDirective]);\n\n AssignedToLightboxDirective = function(lightboxService, lightboxKeyboardNavigationService, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs) {\n var closeLightbox, filterUsers, normalizeString, render, selectedItem, selectedUser, usersTemplate;\n selectedUser = null;\n selectedItem = null;\n usersTemplate = $template.get(\"common/lightbox/lightbox-assigned-to-users.html\", true);\n normalizeString = function(string) {\n var normalizedString;\n normalizedString = string;\n normalizedString = normalizedString.replace(\"Á\", \"A\").replace(\"Ä\", \"A\").replace(\"À\", \"A\");\n normalizedString = normalizedString.replace(\"É\", \"E\").replace(\"Ë\", \"E\").replace(\"È\", \"E\");\n normalizedString = normalizedString.replace(\"Í\", \"I\").replace(\"Ï\", \"I\").replace(\"Ì\", \"I\");\n normalizedString = normalizedString.replace(\"Ó\", \"O\").replace(\"Ö\", \"O\").replace(\"Ò\", \"O\");\n normalizedString = normalizedString.replace(\"Ú\", \"U\").replace(\"Ü\", \"U\").replace(\"Ù\", \"U\");\n return normalizedString;\n };\n filterUsers = function(text, user) {\n var username;\n username = user.full_name_display.toUpperCase();\n username = normalizeString(username);\n text = text.toUpperCase();\n text = normalizeString(text);\n return _.contains(username, text);\n };\n render = function(selected, text) {\n var ctx, html, users;\n users = _.clone($scope.activeUsers, true);\n if (selected != null) {\n users = _.reject(users, {\n \"id\": selected.id\n });\n }\n if (text != null) {\n users = _.filter(users, _.partial(filterUsers, text));\n }\n ctx = {\n selected: selected,\n users: _.first(users, 5),\n showMore: users.length > 5\n };\n html = usersTemplate(ctx);\n html = $compile(html)($scope);\n return $el.find(\".assigned-to-list\").html(html);\n };\n closeLightbox = function() {\n lightboxKeyboardNavigationService.stop();\n return lightboxService.close($el);\n };\n $scope.$on(\"assigned-to:add\", function(ctx, item) {\n var assignedToId;\n selectedItem = item;\n assignedToId = item.assigned_to;\n selectedUser = $scope.usersById[assignedToId];\n render(selectedUser);\n return lightboxService.open($el).then(function() {\n $el.find('input').focus();\n return lightboxKeyboardNavigationService.init($el);\n });\n });\n $scope.$watch(\"usersSearch\", function(searchingText) {\n if (searchingText != null) {\n render(selectedUser, searchingText);\n return $el.find('input').focus();\n }\n });\n $el.on(\"click\", \".user-list-single\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n closeLightbox();\n return $scope.$apply(function() {\n $scope.$broadcast(\"assigned-to:added\", target.data(\"user-id\"), selectedItem);\n return $scope.usersSearch = null;\n });\n });\n $el.on(\"click\", \".remove-assigned-to\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n closeLightbox();\n return $scope.$apply(function() {\n $scope.usersSearch = null;\n return $scope.$broadcast(\"assigned-to:added\", null, selectedItem);\n });\n });\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n closeLightbox();\n return $scope.$apply(function() {\n return $scope.usersSearch = null;\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-assigned-to.html\",\n link: link\n };\n };\n\n module.directive(\"tgLbAssignedto\", [\"lightboxService\", \"lightboxKeyboardNavigationService\", \"$tgTemplate\", \"$compile\", AssignedToLightboxDirective]);\n\n WatchersLightboxDirective = function($repo, lightboxService, lightboxKeyboardNavigationService, $template, $compile) {\n var link;\n link = function($scope, $el, $attrs) {\n var closeLightbox, getFilteredUsers, render, selectedItem, usersTemplate;\n selectedItem = null;\n usersTemplate = $template.get(\"common/lightbox/lightbox-assigned-to-users.html\", true);\n getFilteredUsers = function(text) {\n var _filterUsers, users;\n if (text == null) {\n text = \"\";\n }\n _filterUsers = function(text, user) {\n var username;\n if (selectedItem && _.find(selectedItem.watchers, function(x) {\n return x === user.id;\n })) {\n return false;\n }\n username = user.full_name_display.toUpperCase();\n text = text.toUpperCase();\n return _.contains(username, text);\n };\n users = _.clone($scope.activeUsers, true);\n users = _.filter(users, _.partial(_filterUsers, text));\n return users;\n };\n render = function(users) {\n var ctx, html;\n ctx = {\n selected: false,\n users: _.first(users, 5),\n showMore: users.length > 5\n };\n html = usersTemplate(ctx);\n html = $compile(html)($scope);\n return $el.find(\".ticket-watchers\").html(html);\n };\n closeLightbox = function() {\n lightboxKeyboardNavigationService.stop();\n return lightboxService.close($el);\n };\n $scope.$on(\"watcher:add\", function(ctx, item) {\n var users;\n selectedItem = item;\n users = getFilteredUsers();\n render(users);\n return lightboxService.open($el).then(function() {\n $el.find(\"input\").focus();\n return lightboxKeyboardNavigationService.init($el);\n });\n });\n $scope.$watch(\"usersSearch\", function(searchingText) {\n var users;\n if (searchingText == null) {\n return;\n }\n users = getFilteredUsers(searchingText);\n render(users);\n return $el.find(\"input\").focus();\n });\n $el.on(\"click\", \".user-list-single\", debounce(2000, function(event) {\n var target;\n closeLightbox();\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return $scope.$apply(function() {\n $scope.usersSearch = null;\n return $scope.$broadcast(\"watcher:added\", target.data(\"user-id\"));\n });\n }));\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n closeLightbox();\n return $scope.$apply(function() {\n return $scope.usersSearch = null;\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n templateUrl: \"common/lightbox/lightbox-users.html\",\n link: link\n };\n };\n\n module.directive(\"tgLbWatchers\", [\"$tgRepo\", \"lightboxService\", \"lightboxKeyboardNavigationService\", \"$tgTemplate\", \"$compile\", WatchersLightboxDirective]);\n\n AttachmentPreviewLightboxDirective = function(lightboxService, $template, $compile) {\n var link;\n link = function($scope, $el, attrs) {\n return lightboxService.open($el);\n };\n return {\n templateUrl: 'common/lightbox/lightbox-attachment-preview.html',\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgLbAttachmentPreview\", [\"lightboxService\", \"$tgTemplate\", \"$compile\", AttachmentPreviewLightboxDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/loader.coffee\n */\n\n(function() {\n var Loader, LoaderDirective, module, sizeFormat, taiga, timeout;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaCommon\");\n\n LoaderDirective = function(tgLoader, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n tgLoader.onStart(function() {\n $(document.body).addClass(\"loader-active\");\n return $el.addClass(\"active\");\n });\n return tgLoader.onEnd(function() {\n $(document.body).removeClass(\"loader-active\");\n return $el.removeClass(\"active\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLoader\", [\"tgLoader\", \"$rootScope\", LoaderDirective]);\n\n Loader = function($rootscope) {\n var autoClose, config, lastResponseDate, open, pageLoaded, requestCount, start, startLoadTime;\n config = {\n minTime: 300\n };\n open = false;\n startLoadTime = 0;\n requestCount = 0;\n lastResponseDate = 0;\n pageLoaded = function(force) {\n var diff, endTime, timeoutValue;\n if (force == null) {\n force = false;\n }\n if (startLoadTime) {\n timeoutValue = 0;\n if (!force) {\n endTime = new Date().getTime();\n diff = endTime - startLoadTime;\n if (diff < config.minTime) {\n timeoutValue = config.minTime - diff;\n }\n }\n timeout(timeoutValue, function() {\n $rootscope.$broadcast(\"loader:end\");\n open = false;\n return window.prerenderReady = true;\n });\n }\n startLoadTime = 0;\n requestCount = 0;\n return lastResponseDate = 0;\n };\n autoClose = function() {\n var intervalAuto;\n return intervalAuto = setInterval((function() {\n if (lastResponseDate && requestCount === 0) {\n pageLoaded();\n return clearInterval(intervalAuto);\n }\n }), 50);\n };\n start = function() {\n startLoadTime = new Date().getTime();\n $rootscope.$broadcast(\"loader:start\");\n return open = true;\n };\n return {\n pageLoaded: pageLoaded,\n start: function(auto) {\n if (auto == null) {\n auto = false;\n }\n if (!open) {\n start();\n if (auto) {\n return autoClose();\n }\n }\n },\n onStart: function(fn) {\n return $rootscope.$on(\"loader:start\", fn);\n },\n onEnd: function(fn) {\n return $rootscope.$on(\"loader:end\", fn);\n },\n logRequest: function() {\n return requestCount++;\n },\n logResponse: function() {\n requestCount--;\n return lastResponseDate = new Date().getTime();\n }\n };\n };\n\n Loader.$inject = [\"$rootScope\"];\n\n module.factory(\"tgLoader\", Loader);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/lightboxes.coffee\n */\n\n(function() {\n var LoadingDirective, TgLoadingService, module,\n slice = [].slice;\n\n module = angular.module(\"taigaCommon\");\n\n TgLoadingService = function($compile) {\n var spinner;\n spinner = \"loading...\";\n return function() {\n var service;\n service = {\n settings: {\n target: null,\n scope: null,\n classes: [],\n timeout: 0,\n template: null\n },\n target: function(target) {\n service.settings.target = target;\n return service;\n },\n scope: function(scope) {\n service.settings.scope = scope;\n return service;\n },\n template: function(template) {\n service.settings.template = template;\n return service;\n },\n removeClasses: function() {\n var classess;\n classess = 1 <= arguments.length ? slice.call(arguments, 0) : [];\n service.settings.classes = classess;\n return service;\n },\n timeout: function(timeout) {\n service.settings.timeout = timeout;\n return service;\n },\n start: function() {\n var target, timeoutId;\n target = service.settings.target;\n service.settings.classes.map(function(className) {\n return target.removeClass(className);\n });\n timeoutId = setTimeout((function() {\n if (!target.hasClass('loading')) {\n if (!service.settings.template) {\n service.settings.template = target.html();\n }\n target.addClass('loading');\n return target.html(spinner);\n }\n }), service.settings.timeout);\n service.settings.timeoutId = timeoutId;\n return service;\n },\n finish: function() {\n var removeClasses, target, timeoutId;\n target = service.settings.target;\n timeoutId = service.settings.timeoutId;\n if (timeoutId) {\n clearTimeout(timeoutId);\n removeClasses = service.settings.classes;\n removeClasses.map(function(className) {\n return service.settings.target.addClass(className);\n });\n target.html(service.settings.template);\n target.removeClass('loading');\n if (service.settings.scope) {\n $compile(target.contents())(service.settings.scope);\n }\n }\n return service;\n }\n };\n return service;\n };\n };\n\n TgLoadingService.$inject = [\"$compile\"];\n\n module.factory(\"$tgLoading\", TgLoadingService);\n\n LoadingDirective = function($loading) {\n var link;\n link = function($scope, $el, attr) {\n var currentLoading, template;\n currentLoading = null;\n template = $el.html();\n return $scope.$watch(attr.tgLoading, (function(_this) {\n return function(showLoading) {\n if (showLoading) {\n return currentLoading = $loading().target($el).timeout(100).template(template).scope($scope).start();\n } else if (currentLoading) {\n return currentLoading.finish();\n }\n };\n })(this));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLoading\", [\"$tgLoading\", LoadingDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/popovers.coffee\n */\n\n(function() {\n var RelatedTaskStatusDirective, UsStatusDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaCommon\");\n\n UsStatusDirective = function($repo, $template) {\n\n /*\n Print the status of a US and a popover to change it.\n - tg-us-status: The user story\n - on-update: Method call after US is updated\n \n Example:\n \n div.status(tg-us-status=\"us\" on-update=\"ctrl.loadSprintState()\")\n a.us-status(href=\"\", title=\"Status Name\")\n \n NOTE: This directive need 'usStatusById' and 'project'.\n */\n var link, template;\n template = $template.get(\"common/popover/popover-us-status.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, render, us;\n $ctrl = $el.controller();\n render = function(us) {\n var usStatusById, usStatusDom, usStatusDomParent;\n usStatusDomParent = $el.find(\".us-status\");\n usStatusDom = $el.find(\".us-status .us-status-bind\");\n usStatusById = $scope.usStatusById;\n if (usStatusById[us.status]) {\n usStatusDom.text(usStatusById[us.status].name);\n return usStatusDomParent.css(\"color\", usStatusById[us.status].color);\n }\n };\n $el.on(\"click\", \".us-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", debounce(2000, function(event) {\n var target, us;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n us = $scope.$eval($attrs.tgUsStatus);\n us.status = target.data(\"status-id\");\n render(us);\n $el.find(\".pop-status\").popover().close();\n return $scope.$apply(function() {\n return $repo.save(us).then(function() {\n return $scope.$eval($attrs.onUpdate);\n });\n });\n }));\n $scope.$on(\"userstories:loaded\", function() {\n return render($scope.$eval($attrs.tgUsStatus));\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n us = $scope.$eval($attrs.tgUsStatus);\n render(us);\n return bindOnce($scope, \"project\", function(project) {\n var html;\n html = template({\n \"statuses\": project.us_statuses\n });\n $el.append(html);\n if ($scope.project.my_permissions.indexOf(\"modify_us\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUsStatus\", [\"$tgRepo\", \"$tgTemplate\", UsStatusDirective]);\n\n RelatedTaskStatusDirective = function($repo, $template) {\n\n /*\n Print the status of a related task and a popover to change it.\n - tg-related-task-status: The related task\n - on-update: Method call after US is updated\n \n Example:\n \n div.status(tg-related-task-status=\"task\" on-update=\"ctrl.loadSprintState()\")\n a.task-status(href=\"\", title=\"Status Name\")\n \n NOTE: This directive need 'taskStatusById' and 'project'.\n */\n var link, selectionTemplate, updateTaskStatus;\n selectionTemplate = $template.get(\"common/popover/popover-related-task-status.html\", true);\n updateTaskStatus = function($el, task, taskStatusById) {\n var taskStatusDom, taskStatusDomParent;\n taskStatusDomParent = $el.find(\".us-status\");\n taskStatusDom = $el.find(\".task-status .task-status-bind\");\n if (taskStatusById[task.status]) {\n taskStatusDom.text(taskStatusById[task.status].name);\n return taskStatusDomParent.css('color', taskStatusById[task.status].color);\n }\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, autoSave, notAutoSave, task;\n $ctrl = $el.controller();\n task = $scope.$eval($attrs.tgRelatedTaskStatus);\n notAutoSave = $scope.$eval($attrs.notAutoSave);\n autoSave = !notAutoSave;\n $el.on(\"click\", \".task-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n task.status = target.data(\"status-id\");\n $el.find(\".pop-status\").popover().close();\n updateTaskStatus($el, task, $scope.taskStatusById);\n if (autoSave) {\n return $scope.$apply(function() {\n return $repo.save(task).then(function() {\n $scope.$eval($attrs.onUpdate);\n return $scope.$emit(\"related-tasks:status-changed\");\n });\n });\n }\n }));\n taiga.bindOnce($scope, \"project\", function(project) {\n $el.append(selectionTemplate({\n 'statuses': project.task_statuses\n }));\n updateTaskStatus($el, task, $scope.taskStatusById);\n if (project.my_permissions.indexOf(\"modify_task\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskStatus\", [\"$tgRepo\", \"$tgTemplate\", RelatedTaskStatusDirective]);\n\n $.fn.popover = function() {\n var $el, close, closeAll, closePopover, isVisible, open;\n $el = this;\n isVisible = (function(_this) {\n return function() {\n var docViewBottom, docViewLeft, docViewRight, docViewTop, docViewWidth, elemBottom, elemLeft, elemRight, elemTop, elemWidth;\n $el.css({\n \"display\": \"block\",\n \"visibility\": \"hidden\"\n });\n docViewTop = $(window).scrollTop();\n docViewBottom = docViewTop + $(window).height();\n docViewWidth = $(window).width();\n docViewRight = docViewWidth;\n docViewLeft = 0;\n elemTop = $el.offset().top;\n elemBottom = elemTop + $el.height();\n elemWidth = $el.width();\n elemLeft = $el.offset().left;\n elemRight = $el.offset().left + elemWidth;\n $el.css({\n \"display\": \"none\",\n \"visibility\": \"visible\"\n });\n return (elemBottom <= docViewBottom) && (elemTop >= docViewTop) && (elemLeft >= docViewLeft) && (elemRight <= docViewRight);\n };\n })(this);\n closePopover = (function(_this) {\n return function(onClose) {\n if (onClose) {\n onClose.call($el);\n }\n $el.fadeOut(function() {\n return $el.removeClass(\"active\").removeClass(\"fix\");\n });\n return $el.off(\"popup:close\");\n };\n })(this);\n closeAll = (function(_this) {\n return function() {\n return $(\".popover.active\").each(function() {\n return $(this).trigger(\"popup:close\");\n });\n };\n })(this);\n open = (function(_this) {\n return function(onClose) {\n if ($el.hasClass(\"active\")) {\n return close();\n } else {\n closeAll();\n if (!isVisible()) {\n $el.addClass(\"fix\");\n }\n $el.fadeIn(function() {\n $el.addClass(\"active\");\n $(document.body).off(\"popover\");\n return $(document.body).one(\"click.popover\", function() {\n return closeAll();\n });\n });\n return $el.on(\"popup:close\", function(e) {\n return closePopover(onClose);\n });\n }\n };\n })(this);\n close = (function(_this) {\n return function() {\n return $el.trigger(\"popup:close\");\n };\n })(this);\n return {\n open: open,\n close: close,\n closeAll: closeAll\n };\n };\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/raven-logger.coffee\n */\n\n(function() {\n var ExceptionHandlerFactory, module, taiga;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n ExceptionHandlerFactory = function($log, config) {\n var ravenConfig;\n this.config = config;\n ravenConfig = this.config.get(\"ravenConfig\", null);\n if (ravenConfig) {\n $log.debug(\"Using the RavenJS exception handler.\");\n Raven.config(ravenConfig).install();\n return function(exception, cause) {\n $log.error.apply($log, arguments);\n return Raven.captureException(exception);\n };\n } else {\n $log.debug(\"Using the default logging exception handler.\");\n return function(exception, cause) {\n return $log.error.apply($log, arguments);\n };\n }\n };\n\n module.factory(\"$exceptionHandler\", [\"$log\", \"$tgConfig\", ExceptionHandlerFactory]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/tags.coffee\n */\n\n(function() {\n var ColorizeTagsDirective, LbTagLineDirective, TagLineDirective, TagsDirective, bindOnce, module, taiga, trim,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n TagsDirective = function() {\n var formatter, link, parser;\n formatter = function(v) {\n if (_.isArray(v)) {\n return v.join(\", \");\n }\n return \"\";\n };\n parser = function(v) {\n var result;\n if (!v) {\n return [];\n }\n result = _(v.split(\",\")).map(function(x) {\n return _.str.trim(x);\n });\n return result.value();\n };\n link = function($scope, $el, $attrs, $ctrl) {\n $ctrl.$formatters.push(formatter);\n $ctrl.$parsers.push(parser);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n require: \"ngModel\",\n link: link\n };\n };\n\n module.directive(\"tgTags\", TagsDirective);\n\n ColorizeTagsDirective = function() {\n var link, templates;\n templates = {\n backlog: _.template(\"<% _.each(tags, function(tag) { %>\\n \\\"><%- tag.name %>\\n<% }) %>\"),\n kanban: _.template(\"<% _.each(tags, function(tag) { %>\\n
\\\" title=\\\"<%- tag.name %>\\\" />\\n<% }) %>\"),\n taskboard: _.template(\"<% _.each(tags, function(tag) { %>\\n \\\" title=\\\"<%- tag.name %>\\\" />\\n<% }) %>\")\n };\n link = function($scope, $el, $attrs, $ctrl) {\n var render;\n render = function(srcTags) {\n var html, tags, template;\n template = templates[$attrs.tgColorizeTagsType];\n srcTags.sort();\n tags = _.map(srcTags, function(tag) {\n var color;\n color = $scope.project.tags_colors[tag];\n return {\n name: tag,\n color: color\n };\n });\n html = template({\n tags: tags\n });\n return $el.html(html);\n };\n $scope.$watch($attrs.tgColorizeTags, function(tags) {\n if (tags != null) {\n return render(tags);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgColorizeTags\", ColorizeTagsDirective);\n\n LbTagLineDirective = function($rs, $template, $compile) {\n var COMMA_KEY, ENTER_KEY, link, templateTags;\n ENTER_KEY = 13;\n COMMA_KEY = 188;\n templateTags = $template.get(\"common/tag/lb-tag-line-tags.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addValue, deleteValue, hideSaveButton, renderTags, resetInput, saveInputTag, showSaveButton;\n renderTags = function(tags, tagsColors) {\n var ctx, html;\n ctx = {\n tags: _.map(tags, function(t) {\n return {\n name: t,\n color: tagsColors[t]\n };\n })\n };\n _.map(ctx.tags, (function(_this) {\n return function(tag) {\n if (tag.color) {\n return tag.style = \"border-left: 5px solid \" + tag.color;\n }\n };\n })(this));\n html = $compile(templateTags(ctx))($scope);\n return $el.find(\"div.tags-container\").html(html);\n };\n showSaveButton = function() {\n return $el.find(\".save\").removeClass(\"hidden\");\n };\n hideSaveButton = function() {\n return $el.find(\".save\").addClass(\"hidden\");\n };\n resetInput = function() {\n $el.find(\"input\").val(\"\");\n return $el.find(\"input\").autocomplete(\"close\");\n };\n addValue = function(value) {\n var tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue, false);\n if (tags == null) {\n tags = [];\n }\n if (indexOf.call(tags, value) < 0) {\n tags.push(value);\n }\n $scope.$apply(function() {\n return $model.$setViewValue(tags);\n });\n return hideSaveButton();\n };\n deleteValue = function(value) {\n var tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue, false);\n tags = _.pull(tags, value);\n return $scope.$apply(function() {\n return $model.$setViewValue(tags);\n });\n };\n saveInputTag = function() {\n var value;\n value = $el.find(\"input\").val();\n addValue(value);\n return resetInput();\n };\n $el.on(\"keypress\", \"input\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if (event.keyCode === ENTER_KEY) {\n event.preventDefault();\n return saveInputTag();\n } else if (String.fromCharCode(event.keyCode) === ',') {\n event.preventDefault();\n return saveInputTag();\n } else {\n if (target.val().length) {\n return showSaveButton();\n } else {\n return hideSaveButton();\n }\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n event.preventDefault();\n return saveInputTag();\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var target, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n value = target.siblings(\".tag-name\").text();\n return deleteValue(value);\n });\n bindOnce($scope, \"project\", function(project) {\n var positioningFunction;\n positioningFunction = function(position, elements) {\n var menu;\n menu = elements.element.element;\n menu.css(\"width\", elements.target.width);\n menu.css(\"top\", position.top);\n return menu.css(\"left\", position.left);\n };\n return $el.find(\"input\").autocomplete({\n source: _.keys(project.tags_colors),\n position: {\n my: \"left top\",\n using: positioningFunction\n },\n select: function(event, ui) {\n addValue(ui.item.value);\n return ui.item.value = \"\";\n }\n });\n });\n $scope.$watch($attrs.ngModel, function(tags) {\n var ref, tagsColors;\n tagsColors = ((ref = $scope.project) != null ? ref.tags_colors : void 0) || [];\n return renderTags(tags, tagsColors);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\",\n templateUrl: \"common/tag/lb-tag-line.html\"\n };\n };\n\n module.directive(\"tgLbTagLine\", [\"$tgResources\", \"$tgTemplate\", \"$compile\", LbTagLineDirective]);\n\n TagLineDirective = function($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compile) {\n var COMMA_KEY, ENTER_KEY, ESC_KEY, link, templateTags;\n ENTER_KEY = 13;\n ESC_KEY = 27;\n COMMA_KEY = 188;\n templateTags = $template.get(\"common/tag/tags-line-tags.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addValue, deleteValue, hideAddTagButton, hideAddTagButtonText, hideInput, hideSaveButton, isEditable, renderInReadModeOnly, renderTags, resetInput, saveInputTag, showAddTagButton, showAddTagButtonText, showInput, showSaveButton;\n isEditable = function() {\n if ($attrs.requiredPerm != null) {\n return $scope.project.my_permissions.indexOf($attrs.requiredPerm) !== -1;\n }\n return true;\n };\n renderTags = function(tags, tagsColors) {\n var ctx, html;\n ctx = {\n tags: _.map(tags, function(t) {\n return {\n name: t,\n color: tagsColors[t]\n };\n }),\n isEditable: isEditable()\n };\n html = $compile(templateTags(ctx))($scope);\n return $el.find(\"div.tags-container\").html(html);\n };\n renderInReadModeOnly = function() {\n $el.find(\".add-tag\").remove();\n $el.find(\"input\").remove();\n return $el.find(\".save\").remove();\n };\n showAddTagButton = function() {\n return $el.find(\".add-tag\").removeClass(\"hidden\");\n };\n hideAddTagButton = function() {\n return $el.find(\".add-tag\").addClass(\"hidden\");\n };\n showAddTagButtonText = function() {\n return $el.find(\".add-tag-text\").removeClass(\"hidden\");\n };\n hideAddTagButtonText = function() {\n return $el.find(\".add-tag-text\").addClass(\"hidden\");\n };\n showSaveButton = function() {\n return $el.find(\".save\").removeClass(\"hidden\");\n };\n hideSaveButton = function() {\n return $el.find(\".save\").addClass(\"hidden\");\n };\n showInput = function() {\n return $el.find(\"input\").removeClass(\"hidden\").focus();\n };\n hideInput = function() {\n return $el.find(\"input\").addClass(\"hidden\").blur();\n };\n resetInput = function() {\n $el.find(\"input\").val(\"\");\n return $el.find(\"input\").autocomplete(\"close\");\n };\n addValue = $qqueue.bindAdd(function(value) {\n var model, onError, onSuccess, tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue.tags, false);\n if (tags == null) {\n tags = [];\n }\n if (indexOf.call(tags, value) < 0) {\n tags.push(value);\n }\n model = $model.$modelValue.clone();\n model.tags = tags;\n $model.$setViewValue(model);\n onSuccess = function() {\n return $rootScope.$broadcast(\"object:updated\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n model.revert();\n return $model.$setViewValue(model);\n };\n hideSaveButton();\n return $repo.save(model).then(onSuccess, onError);\n });\n deleteValue = $qqueue.bindAdd(function(value) {\n var model, onError, onSuccess, tags;\n value = trim(value.toLowerCase());\n if (value.length === 0) {\n return;\n }\n tags = _.clone($model.$modelValue.tags, false);\n tags = _.pull(tags, value);\n model = $model.$modelValue.clone();\n model.tags = tags;\n $model.$setViewValue(model);\n onSuccess = function() {\n return $rootScope.$broadcast(\"object:updated\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n model.revert();\n return $model.$setViewValue(model);\n };\n return $repo.save(model).then(onSuccess, onError);\n });\n saveInputTag = function() {\n var value;\n value = $el.find(\"input\").val();\n addValue(value);\n return resetInput();\n };\n $el.on(\"keypress\", \"input\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if (event.keyCode === ENTER_KEY) {\n return saveInputTag();\n } else if (String.fromCharCode(event.keyCode) === ',') {\n event.preventDefault();\n return saveInputTag();\n } else {\n if (target.val().length) {\n return showSaveButton();\n } else {\n return hideSaveButton();\n }\n }\n });\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === ESC_KEY) {\n resetInput();\n hideInput();\n hideSaveButton();\n return showAddTagButton();\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n event.preventDefault();\n return saveInputTag();\n });\n $el.on(\"click\", \".add-tag\", function(event) {\n event.preventDefault();\n hideAddTagButton();\n return showInput();\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n var target, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n value = target.siblings(\".tag-name\").text();\n return deleteValue(value);\n });\n bindOnce($scope, \"project.tags_colors\", function(tags_colors) {\n var positioningFunction;\n if (!isEditable()) {\n renderInReadModeOnly();\n return;\n }\n showAddTagButton();\n positioningFunction = function(position, elements) {\n var menu;\n menu = elements.element.element;\n menu.css(\"width\", elements.target.width);\n menu.css(\"top\", position.top);\n return menu.css(\"left\", position.left);\n };\n return $el.find(\"input\").autocomplete({\n source: _.keys(tags_colors),\n position: {\n my: \"left top\",\n using: positioningFunction\n },\n select: function(event, ui) {\n addValue(ui.item.value);\n return ui.item.value = \"\";\n }\n });\n });\n $scope.$watch($attrs.ngModel, function(model) {\n var ref, ref1, tagsColors;\n if (!model) {\n return;\n }\n if ((ref = model.tags) != null ? ref.length : void 0) {\n hideAddTagButtonText();\n } else {\n showAddTagButtonText();\n }\n tagsColors = ((ref1 = $scope.project) != null ? ref1.tags_colors : void 0) || [];\n return renderTags(model.tags, tagsColors);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\",\n templateUrl: \"common/tag/tag-line.html\"\n };\n };\n\n module.directive(\"tgTagLine\", [\"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", TagLineDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/wisiwyg.coffee\n */\n\n(function() {\n var MarkitupDirective, bindOnce, module, taiga,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaCommon\");\n\n MarkitupDirective = function($rootscope, $rs, $selectedText, $template, $compile, $translate) {\n var link, previewTemplate;\n previewTemplate = $template.get(\"common/wysiwyg/wysiwyg-markitup-preview.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var addLine, cancelablePromise, closePreviewMode, element, markdownTitle, prepareUrlFormatting, preview, previewDomNode, renderMarkItUp, setCaretPosition, unbind, urlFormatting;\n element = angular.element($el);\n previewDomNode = $(\"
\", {\n \"class\": \"preview\"\n });\n closePreviewMode = function() {\n element.parents(\".markdown\").find(\".preview\").remove();\n return element.parents(\".markItUp\").show();\n };\n $scope.$on(\"markdown-editor:submit\", function() {\n return closePreviewMode();\n });\n cancelablePromise = null;\n preview = function() {\n var markItUpDomNode, markdownDomNode;\n markdownDomNode = element.parents(\".markdown\");\n markItUpDomNode = element.parents(\".markItUp\");\n return $rs.mdrender.render($scope.projectId, $model.$modelValue).then(function(data) {\n var html, markdown;\n html = previewTemplate({\n data: data.data\n });\n html = $compile(html)($scope);\n markdownDomNode.append(html);\n markItUpDomNode.hide();\n markdown = element.closest(\".markdown\");\n return markdown.on(\"mouseup.preview\", \".preview\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.target);\n if (!target.is('a') && $selectedText.get().length) {\n return;\n }\n markdown.off(\".preview\");\n return closePreviewMode();\n });\n });\n };\n setCaretPosition = function(textarea, caretPosition) {\n var line, range, scrollRelation, totalLines;\n if (textarea.createTextRange) {\n range = textarea.createTextRange();\n range.move(\"character\", caretPosition);\n range.select();\n } else if (textarea.selectionStart) {\n textarea.focus();\n textarea.setSelectionRange(caretPosition, caretPosition);\n }\n totalLines = textarea.value.split(\"\\n\").length;\n line = textarea.value.slice(0, +(caretPosition - 1) + 1 || 9e9).split(\"\\n\").length;\n scrollRelation = line / totalLines;\n return $el.scrollTop((scrollRelation * $el[0].scrollHeight) - ($el.height() / 2));\n };\n addLine = function(textarea, nline, replace) {\n var cursorPosition, j, key, len, line, lines;\n lines = textarea.value.split(\"\\n\");\n if (replace) {\n lines[nline] = replace + lines[nline];\n } else {\n lines[nline] = \"\";\n }\n cursorPosition = 0;\n for (key = j = 0, len = lines.length; j < len; key = ++j) {\n line = lines[key];\n cursorPosition += line.length + 1 || 1;\n if (key === nline) {\n break;\n }\n }\n textarea.value = lines.join(\"\\n\");\n if (replace) {\n return cursorPosition - lines[nline].length + replace.length - 1;\n } else {\n return cursorPosition;\n }\n };\n prepareUrlFormatting = function(markItUp) {\n var indices, regex, result;\n regex = /(<<<|>>>)/gi;\n result = 0;\n indices = [];\n while ((result = regex.exec(markItUp.textarea.value))) {\n indices.push(result.index);\n }\n return markItUp.donotparse = indices;\n };\n urlFormatting = function(markItUp) {\n var endIndex, ref, ref1, regex, result, startIndex, url, value;\n regex = /<<>>/gi;\n endIndex = 0;\n while (true) {\n result = regex.exec(markItUp.textarea.value);\n if (!result) {\n break;\n }\n if (ref1 = result.index, indexOf.call(markItUp.donotparse, ref1) < 0) {\n endIndex = result.index;\n break;\n }\n }\n value = markItUp.textarea.value;\n url = value.substring(startIndex, endIndex).replace('<<<', '').replace('>>>', '');\n url = url.replace('(', '%28').replace(')', '%29');\n url = url.replace('[', '%5B').replace(']', '%5D');\n value = value.substring(0, startIndex) + url + value.substring(endIndex + 3, value.length);\n markItUp.textarea.value = value;\n return markItUp.donotparse = void 0;\n };\n markdownTitle = function(markItUp, char) {\n var heading, i, j, n, ref;\n heading = \"\";\n n = $.trim(markItUp.selection || markItUp.placeHolder).length;\n for (i = j = 0, ref = n - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {\n heading += char;\n }\n return \"\\n\" + heading + \"\\n\";\n };\n renderMarkItUp = function() {\n var markdownSettings;\n markdownSettings = {\n nameSpace: \"markdown\",\n onShiftEnter: {\n keepDefault: false,\n openWith: \"\\n\\n\"\n },\n onEnter: {\n keepDefault: false,\n replaceWith: function() {\n if (!$('.textcomplete-dropdown').is(':visible')) {\n return \"\\n\";\n }\n },\n afterInsert: function(data) {\n var cursorLine, emptyListItem, lastLine, lines, markdownCaretPositon, match, newLineContent, nline, replace;\n lines = data.textarea.value.split(\"\\n\");\n if (data.caretPosition > 0) {\n cursorLine = data.textarea.value.slice(0, +(data.caretPosition - 1) + 1 || 9e9).split(\"\\n\").length;\n } else {\n cursorLine = 1;\n }\n newLineContent = data.textarea.value.slice(data.caretPosition).split(\"\\n\")[0];\n lastLine = lines[cursorLine - 1];\n match = lastLine.match(/^(\\s*- ).*/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*)\\-\\s$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = \"\" + match[1];\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n match = lastLine.match(/^(\\s*\\* ).*/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*\\* )$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = \"\" + match[1];\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n match = lastLine.match(/^(\\s*)(\\d+)\\.\\s/);\n if (match) {\n emptyListItem = lastLine.match(/^(\\s*)(\\d+)\\.\\s$/);\n if (emptyListItem) {\n nline = cursorLine - 1;\n replace = null;\n } else {\n nline = cursorLine;\n replace = (match[1] + (parseInt(match[2], 10) + 1)) + \". \";\n }\n markdownCaretPositon = addLine(data.textarea, nline, replace);\n }\n if (markdownCaretPositon) {\n return setCaretPosition(data.textarea, markdownCaretPositon);\n }\n }\n },\n markupSet: [\n {\n name: $translate.instant(\"COMMON.WYSIWYG.H1_BUTTON\"),\n key: \"1\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H1_SAMPLE_TEXT\"),\n closeWith: function(markItUp) {\n return markdownTitle(markItUp, \"=\");\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.H2_BUTTON\"),\n key: \"2\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H2_SAMPLE_TEXT\"),\n closeWith: function(markItUp) {\n return markdownTitle(markItUp, \"-\");\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.H3_BUTTON\"),\n key: \"3\",\n openWith: \"### \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.H3_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.BOLD_BUTTON\"),\n key: \"B\",\n openWith: \"**\",\n closeWith: \"**\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.BOLD_BUTTON_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT\"),\n key: \"I\",\n openWith: \"_\",\n closeWith: \"_\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.ITALIC_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.STRIKE_BUTTON\"),\n key: \"S\",\n openWith: \"~~\",\n closeWith: \"~~\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.STRIKE_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.BULLETED_LIST_BUTTON\"),\n openWith: \"- \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.BULLETED_LIST_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.NUMERIC_LIST_BUTTON\"),\n openWith: function(markItUp) {\n return markItUp.line + \". \";\n },\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.NUMERIC_LIST_SAMPLE_TEXT\")\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.PICTURE_BUTTON\"),\n key: \"P\",\n openWith: \"![\",\n closeWith: '](<<<[![Url:!:http://]!]>>> \"[![Title]!]\")',\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.PICTURE_SAMPLE_TEXT\"),\n beforeInsert: function(markItUp) {\n return prepareUrlFormatting(markItUp);\n },\n afterInsert: function(markItUp) {\n return urlFormatting(markItUp);\n }\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.LINK_BUTTON\"),\n key: \"L\",\n openWith: \"[\",\n closeWith: '](<<<[![Url:!:http://]!]>>> \"[![Title]!]\")',\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.LINK_SAMPLE_TEXT\"),\n beforeInsert: function(markItUp) {\n return prepareUrlFormatting(markItUp);\n },\n afterInsert: function(markItUp) {\n return urlFormatting(markItUp);\n }\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.QUOTE_BLOCK_BUTTON\"),\n openWith: \"> \",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.QUOTE_BLOCK_SAMPLE_TEXT\")\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.CODE_BLOCK_BUTTON\"),\n openWith: \"```\\n\",\n placeHolder: $translate.instant(\"COMMON.WYSIWYG.CODE_BLOCK_SAMPLE_TEXT\"),\n closeWith: \"\\n```\"\n }, {\n separator: \"---------------\"\n }, {\n name: $translate.instant(\"COMMON.WYSIWYG.PREVIEW_BUTTON\"),\n call: preview,\n className: \"preview-icon\"\n }\n ],\n afterInsert: function(event) {\n var target;\n target = angular.element(event.textarea);\n return $model.$setViewValue(target.val());\n }\n };\n return element.markItUpRemove().markItUp(markdownSettings).textcomplete([\n {\n cache: true,\n match: /(^|\\s)#([a-z0-9]+)$/i,\n search: function(term, callback) {\n var filter, searchProps, searchTypes;\n term = taiga.slugify(term);\n searchTypes = ['issues', 'tasks', 'userstories'];\n searchProps = ['ref', 'subject'];\n filter = (function(_this) {\n return function(item) {\n var j, len, prop;\n for (j = 0, len = searchProps.length; j < len; j++) {\n prop = searchProps[j];\n if (taiga.slugify(item[prop]).indexOf(term) >= 0) {\n return true;\n }\n }\n return false;\n };\n })(this);\n if (cancelablePromise) {\n cancelablePromise.abort();\n }\n cancelablePromise = $rs.search[\"do\"]($scope.projectId, term);\n cancelablePromise.then((function(_this) {\n return function(res) {\n var j, len, results, type;\n if (res.count < 1 || res.count === res.wikipages.length) {\n return callback([]);\n } else {\n results = [];\n for (j = 0, len = searchTypes.length; j < len; j++) {\n type = searchTypes[j];\n if (res[type] && res[type].length > 0) {\n results.push(callback(res[type].filter(filter), true));\n } else {\n results.push(void 0);\n }\n }\n return results;\n }\n };\n })(this));\n return callback([]);\n },\n replace: function(res) {\n return \"$1\\#\" + res.ref + \" \";\n },\n template: function(res, term) {\n return \"\\#\" + res.ref + \" - \" + res.subject;\n }\n }, {\n cache: true,\n match: /(^|\\s)@([a-z0-9\\-\\._]{2,})$/i,\n search: function(term, callback) {\n var searchProps, username;\n username = taiga.slugify(term);\n searchProps = ['username', 'full_name', 'full_name_display'];\n if ($scope.project.members.length < 1) {\n return callback([]);\n } else {\n return callback($scope.project.members.filter((function(_this) {\n return function(user) {\n var j, len, prop;\n for (j = 0, len = searchProps.length; j < len; j++) {\n prop = searchProps[j];\n if (taiga.slugify(user[prop]).indexOf(username) >= 0) {\n return true;\n }\n }\n return false;\n };\n })(this)));\n }\n },\n replace: function(user) {\n return \"$1@\" + user.username + \" \";\n },\n template: function(user) {\n return user.username + \" - \" + user.full_name_display;\n }\n }, {\n cache: true,\n match: /(^|\\s)\\[\\[([a-z0-9\\-]+)$/i,\n search: function(term, callback) {\n term = taiga.slugify(term);\n return $rs.search[\"do\"]($scope.projectId, term).then((function(_this) {\n return function(res) {\n if (res.count < 1) {\n callback([]);\n }\n if (res.count < 1 || !res.wikipages || res.wikipages.length <= 0) {\n callback([]);\n } else {\n callback(res.wikipages.filter(function(page) {\n return taiga.slugify(page['slug']).indexOf(term) >= 0;\n }), true);\n }\n return callback([]);\n };\n })(this));\n },\n replace: function(res) {\n return \"$1[[\" + res.slug + \"]]\";\n },\n template: function(res, term) {\n return res.slug;\n }\n }\n ], {\n debounce: 200\n });\n };\n renderMarkItUp();\n unbind = $rootscope.$on(\"$translateChangeEnd\", renderMarkItUp);\n element.on(\"keypress\", function(event) {\n return $scope.$apply();\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return unbind();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgMarkitup\", [\"$rootScope\", \"$tgResources\", \"$selectedText\", \"$tgTemplate\", \"$compile\", \"$translate\", MarkitupDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/main.coffee\n */\n\n(function() {\n var BacklogFiltersDirective, bindOnce, debounceLeading, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n debounceLeading = this.taiga.debounceLeading;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogFiltersDirective = function($q, $log, $location, $templates) {\n var link, template, templateSelected;\n template = $templates.get(\"backlog/filters.html\", true);\n templateSelected = $templates.get(\"backlog/filter-selected.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, currentFiltersType, getFiltersType, initializeSelectedFilters, reloadUserstories, renderFilters, renderSelectedFilters, selectQFilter, selectedFilters, showCategories, showFilters, toggleFilterSelection;\n currentFiltersType = '';\n $ctrl = $el.closest(\".wrapper\").controller();\n selectedFilters = [];\n showFilters = function(title, type) {\n $el.find(\".filters-cats\").hide();\n $el.find(\".filter-list\").removeClass(\"hidden\");\n $el.find(\"h2.breadcrumb\").removeClass(\"hidden\");\n $el.find(\"h2 a.subfilter span.title\").html(title);\n $el.find(\"h2 a.subfilter span.title\").prop(\"data-type\", type);\n return currentFiltersType = getFiltersType();\n };\n showCategories = function() {\n $el.find(\".filters-cats\").show();\n $el.find(\".filter-list\").addClass(\"hidden\");\n return $el.find(\"h2.breadcrumb\").addClass(\"hidden\");\n };\n initializeSelectedFilters = function() {\n var i, len, name, ref, val, values;\n showCategories();\n selectedFilters = [];\n ref = $scope.filters;\n for (name in ref) {\n values = ref[name];\n for (i = 0, len = values.length; i < len; i++) {\n val = values[i];\n if (val.selected) {\n selectedFilters.push(val);\n }\n }\n }\n return renderSelectedFilters();\n };\n renderSelectedFilters = function() {\n var html;\n _.map(selectedFilters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = templateSelected({\n filters: selectedFilters\n });\n return $el.find(\".filters-applied\").html(html);\n };\n renderFilters = function(filters) {\n var html;\n _.map(filters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = template({\n filters: filters\n });\n return $el.find(\".filter-list\").html(html);\n };\n getFiltersType = function() {\n return $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n };\n reloadUserstories = function() {\n currentFiltersType = getFiltersType();\n return $q.all([$ctrl.loadUserstories(), $ctrl.generateFilters()]).then(function() {\n var currentFilters;\n currentFilters = $scope.filters[currentFiltersType];\n return renderFilters(_.reject(currentFilters, \"selected\"));\n });\n };\n toggleFilterSelection = function(type, id) {\n var filter, filters;\n currentFiltersType = getFiltersType();\n filters = $scope.filters[type];\n filter = _.find(filters, {\n id: id\n });\n filter.selected = !filter.selected;\n if (filter.selected) {\n selectedFilters.push(filter);\n $scope.$apply(function() {\n return $ctrl.selectFilter(type, id);\n });\n } else {\n selectedFilters = _.reject(selectedFilters, function(selected) {\n return filter.type === selected.type && filter.id === selected.id;\n });\n $ctrl.unselectFilter(type, id);\n }\n renderSelectedFilters(selectedFilters);\n if (type === currentFiltersType) {\n renderFilters(_.reject(filters, \"selected\"));\n }\n return reloadUserstories();\n };\n selectQFilter = debounceLeading(100, function(value) {\n if (value === void 0) {\n return;\n }\n if (value.length === 0) {\n $ctrl.replaceFilter(\"q\", null);\n } else {\n $ctrl.replaceFilter(\"q\", value);\n }\n return reloadUserstories();\n });\n $scope.$watch(\"filtersQ\", selectQFilter);\n $scope.$on(\"backlog:loaded\", function(ctx) {\n return initializeSelectedFilters();\n });\n $scope.$on(\"filters:update\", function(ctx) {\n return $ctrl.generateFilters().then(function() {\n var filters;\n filters = $scope.filters[currentFiltersType];\n if (currentFiltersType) {\n return renderFilters(_.reject(filters, \"selected\"));\n }\n });\n });\n $el.on(\"click\", \".filters-cats > ul > li > a\", function(event) {\n var tags, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n tags = $scope.filters[target.data(\"type\")];\n renderFilters(_.reject(tags, \"selected\"));\n return showFilters(target.attr(\"title\"), target.data('type'));\n });\n $el.on(\"click\", \".filters-inner > .filters-step-cat > .breadcrumb > .back\", function(event) {\n event.preventDefault();\n return showCategories();\n });\n $el.on(\"click\", \".filters-applied a\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n id = target.data(\"id\");\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n return $el.on(\"click\", \".filter-list .single-filter\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n if (target.hasClass(\"active\")) {\n target.removeClass(\"active\");\n } else {\n target.addClass(\"active\");\n }\n id = target.data(\"id\");\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogFilters\", [\"$q\", \"$log\", \"$tgLocation\", \"$tgTemplate\", BacklogFiltersDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/lightboxes.coffee\n */\n\n(function() {\n var CreateEditSprint, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaBacklog\");\n\n CreateEditSprint = function($repo, $confirm, $rs, $rootscope, lightboxService, $loading, $translate) {\n var link;\n link = function($scope, $el, attrs) {\n var createSprint, getLastSprint, hasErrors, remove, resetSprint, submit;\n hasErrors = false;\n createSprint = true;\n resetSprint = function() {\n return $scope.sprint = {\n project: null,\n name: null,\n estimated_start: null,\n estimated_finish: null\n };\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, newSprint, prettyDate, promise, submitButton, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n submitButton = $el.find(\".submit-button\");\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n hasErrors = true;\n $el.find(\".last-sprint-name\").addClass(\"disappear\");\n return;\n }\n hasErrors = false;\n newSprint = angular.copy($scope.sprint);\n broadcastEvent = null;\n if (createSprint) {\n newSprint.estimated_start = moment(newSprint.estimated_start, prettyDate).format(\"YYYY-MM-DD\");\n newSprint.estimated_finish = moment(newSprint.estimated_finish, prettyDate).format(\"YYYY-MM-DD\");\n promise = $repo.create(\"milestones\", newSprint);\n broadcastEvent = \"sprintform:create:success\";\n } else {\n newSprint.setAttr(\"estimated_start\", moment(newSprint.estimated_start, prettyDate).format(\"YYYY-MM-DD\"));\n newSprint.setAttr(\"estimated_finish\", moment(newSprint.estimated_finish, prettyDate).format(\"YYYY-MM-DD\"));\n promise = $repo.save(newSprint);\n broadcastEvent = \"sprintform:edit:success\";\n }\n currentLoading = $loading().target(submitButton).start();\n promise.then(function(data) {\n currentLoading.finish();\n if (createSprint) {\n $scope.sprintsCounter += 1;\n }\n $rootscope.$broadcast(broadcastEvent, data);\n return lightboxService.close($el);\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"light-error\", data._error_message);\n } else if (data.__all__) {\n return $confirm.notify(\"light-error\", data.__all__[0]);\n }\n });\n };\n })(this));\n remove = function() {\n var message, title;\n title = $translate.instant(\"LIGHTBOX.DELETE_SPRINT.TITLE\");\n message = $scope.sprint.name;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onSuccess = function() {\n askResponse.finish();\n $scope.milestonesCounter -= 1;\n lightboxService.close($el);\n return $rootscope.$broadcast(\"sprintform:remove:success\", $scope.sprint);\n };\n onError = function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n };\n return $repo.remove($scope.sprint).then(onSuccess, onError);\n };\n })(this));\n };\n getLastSprint = function() {\n var openSprints, sortedSprints;\n openSprints = _.filter($scope.sprints, function(sprint) {\n return !sprint.closed;\n });\n sortedSprints = _.sortBy(openSprints, function(sprint) {\n return moment(sprint.estimated_finish, 'YYYY-MM-DD').format('X');\n });\n return sortedSprints[sortedSprints.length - 1];\n };\n $scope.$on(\"sprintform:create\", function(event, projectId) {\n var estimatedFinish, estimatedStart, form, lastSprint, lastSprintNameDom, prettyDate, text;\n resetSprint();\n form = $el.find(\"form\").checksley();\n form.reset();\n createSprint = true;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n $scope.sprint.project = projectId;\n $scope.sprint.name = null;\n $scope.sprint.slug = null;\n lastSprint = getLastSprint();\n estimatedStart = moment();\n if (lastSprint) {\n estimatedStart = moment(lastSprint.estimated_finish);\n } else if ($scope.sprint.estimated_start) {\n estimatedStart = moment($scope.sprint.estimated_start);\n }\n $scope.sprint.estimated_start = estimatedStart.format(prettyDate);\n estimatedFinish = moment().add(2, \"weeks\");\n if (lastSprint) {\n estimatedFinish = moment(lastSprint.estimated_finish).add(2, \"weeks\");\n } else if ($scope.sprint.estimated_finish) {\n estimatedFinish = moment($scope.sprint.estimated_finish);\n }\n $scope.sprint.estimated_finish = estimatedFinish.format(prettyDate);\n lastSprintNameDom = $el.find(\".last-sprint-name\");\n if ((lastSprint != null ? lastSprint.name : void 0) != null) {\n text = $translate.instant(\"LIGHTBOX.ADD_EDIT_SPRINT.LAST_SPRINT_NAME\", {\n lastSprint: lastSprint.name\n });\n lastSprintNameDom.html(text);\n }\n $el.find(\".delete-sprint\").addClass(\"hidden\");\n text = $translate.instant(\"LIGHTBOX.ADD_EDIT_SPRINT.TITLE\");\n $el.find(\".title\").text(text);\n text = $translate.instant(\"COMMON.CREATE\");\n $el.find(\".button-green\").text(text);\n lightboxService.open($el);\n $el.find(\".sprint-name\").focus();\n return $el.find(\".last-sprint-name\").removeClass(\"disappear\");\n });\n $scope.$on(\"sprintform:edit\", function(ctx, sprint) {\n var editSprint, prettyDate, save;\n resetSprint();\n createSprint = false;\n prettyDate = $translate.instant(\"COMMON.PICKERDATE.FORMAT\");\n $scope.$apply(function() {\n $scope.sprint = sprint;\n $scope.sprint.estimated_start = moment($scope.sprint.estimated_start).format(prettyDate);\n return $scope.sprint.estimated_finish = moment($scope.sprint.estimated_finish).format(prettyDate);\n });\n $el.find(\".delete-sprint\").removeClass(\"hidden\");\n editSprint = $translate.instant(\"BACKLOG.EDIT_SPRINT\");\n $el.find(\".title\").text(editSprint);\n save = $translate.instant(\"COMMON.SAVE\");\n $el.find(\".button-green\").text(save);\n lightboxService.open($el);\n $el.find(\".sprint-name\").focus().select();\n return $el.find(\".last-sprint-name\").addClass(\"disappear\");\n });\n $el.on(\"keyup\", \".sprint-name\", function(event) {\n if ($el.find(\".sprint-name\").val().length > 0 || hasErrors) {\n return $el.find(\".last-sprint-name\").addClass(\"disappear\");\n } else {\n return $el.find(\".last-sprint-name\").removeClass(\"disappear\");\n }\n });\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".delete-sprint .icon-delete\", function(event) {\n event.preventDefault();\n return remove();\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return resetSprint();\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateEditSprint\", [\"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$translate\", CreateEditSprint]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/main.coffee\n */\n\n(function() {\n var BacklogController, BacklogDirective, BurndownBacklogGraphDirective, TgBacklogProgressBarDirective, ToggleBurndownVisibility, UsPointsDirective, UsRolePointsSelectorDirective, bindMethods, bindOnce, generateHash, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n generateHash = this.taiga.generateHash;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogController = (function(superClass) {\n extend(BacklogController, superClass);\n\n BacklogController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\", \"$tgLoading\", \"tgResources\"];\n\n function BacklogController(scope1, rootscope, repo, confirm, rs, params1, q, location, appMetaService, navUrls, events, analytics, translate, loading, rs2) {\n var promise;\n this.scope = scope1;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params1;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n this.loading = loading;\n this.rs2 = rs2;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"BACKLOG.SECTION_NAME\");\n this.showTags = false;\n this.activeFilters = false;\n this.scope.showGraphPlaceholder = null;\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"BACKLOG.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"BACKLOG.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n _this.appMetaService.setAll(title, description);\n if (_this.rs.userstories.getShowTags(_this.scope.projectId)) {\n _this.showTags = true;\n return _this.scope.$broadcast(\"showTags\", _this.showTags);\n }\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n BacklogController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"usform:bulk:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.loadProjectStats();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"bulk create userstory on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"sprintform:create:success\", (function(_this) {\n return function() {\n _this.loadSprints();\n _this.loadProjectStats();\n return _this.analytics.trackEvent(\"sprint\", \"create\", \"create sprint on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"usform:new:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.loadProjectStats();\n _this.rootscope.$broadcast(\"filters:update\");\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"create userstory on backlog\", 1);\n };\n })(this));\n this.scope.$on(\"sprintform:edit:success\", (function(_this) {\n return function() {\n return _this.loadProjectStats();\n };\n })(this));\n this.scope.$on(\"sprintform:remove:success\", (function(_this) {\n return function(event, sprint) {\n _this.loadSprints();\n _this.loadProjectStats();\n _this.loadUserstories();\n if (sprint.closed) {\n _this.loadClosedSprints();\n }\n return _this.rootscope.$broadcast(\"filters:update\");\n };\n })(this));\n this.scope.$on(\"usform:edit:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.rootscope.$broadcast(\"filters:update\");\n };\n })(this));\n this.scope.$on(\"sprint:us:move\", this.moveUs);\n this.scope.$on(\"sprint:us:moved\", this.loadSprints);\n this.scope.$on(\"sprint:us:moved\", this.loadProjectStats);\n this.scope.$on(\"backlog:load-closed-sprints\", this.loadClosedSprints);\n return this.scope.$on(\"backlog:unload-closed-sprints\", this.unloadClosedSprints);\n };\n\n BacklogController.prototype.initializeSubscription = function() {\n var routingKey1, routingKey2;\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n _this.loadUserstories();\n return _this.loadSprints();\n };\n })(this));\n routingKey2 = \"changes.project.\" + this.scope.projectId + \".milestones\";\n return this.events.subscribe(this.scope, routingKey2, (function(_this) {\n return function(message) {\n return _this.loadSprints();\n };\n })(this));\n };\n\n BacklogController.prototype.toggleShowTags = function() {\n return this.scope.$apply((function(_this) {\n return function() {\n _this.showTags = !_this.showTags;\n return _this.rs.userstories.storeShowTags(_this.scope.projectId, _this.showTags);\n };\n })(this));\n };\n\n BacklogController.prototype.toggleActiveFilters = function() {\n return this.activeFilters = !this.activeFilters;\n };\n\n BacklogController.prototype.loadProjectStats = function() {\n return this.rs.projects.stats(this.scope.projectId).then((function(_this) {\n return function(stats) {\n var totalPoints;\n _this.scope.stats = stats;\n totalPoints = stats.total_points ? stats.total_points : stats.defined_points;\n if (totalPoints) {\n _this.scope.stats.completedPercentage = Math.round(100 * stats.closed_points / totalPoints);\n } else {\n _this.scope.stats.completedPercentage = 0;\n }\n _this.scope.showGraphPlaceholder = !((stats.total_points != null) && (stats.total_milestones != null));\n return stats;\n };\n })(this));\n };\n\n BacklogController.prototype.unloadClosedSprints = function() {\n return this.scope.$apply((function(_this) {\n return function() {\n _this.scope.closedSprints = [];\n return _this.rootscope.$broadcast(\"closed-sprints:reloaded\", []);\n };\n })(this));\n };\n\n BacklogController.prototype.loadClosedSprints = function() {\n var params;\n params = {\n closed: true\n };\n return this.rs.sprints.list(this.scope.projectId, params).then((function(_this) {\n return function(result) {\n var j, len, sprint, sprints;\n sprints = result.milestones;\n _this.scope.totalClosedMilestones = result.closed;\n for (j = 0, len = sprints.length; j < len; j++) {\n sprint = sprints[j];\n sprint.user_stories = _.sortBy(sprint.user_stories, \"sprint_order\");\n }\n _this.scope.closedSprints = sprints;\n _this.scope.closedSprintsById = groupBy(sprints, function(x) {\n return x.id;\n });\n _this.rootscope.$broadcast(\"closed-sprints:reloaded\", sprints);\n return sprints;\n };\n })(this));\n };\n\n BacklogController.prototype.loadSprints = function() {\n var params;\n params = {\n closed: false\n };\n return this.rs.sprints.list(this.scope.projectId, params).then((function(_this) {\n return function(result) {\n var j, len, sprint, sprints;\n sprints = result.milestones;\n _this.scope.totalMilestones = sprints;\n _this.scope.totalClosedMilestones = result.closed;\n _this.scope.totalOpenMilestones = result.open;\n _this.scope.totalMilestones = _this.scope.totalOpenMilestones + _this.scope.totalClosedMilestones;\n for (j = 0, len = sprints.length; j < len; j++) {\n sprint = sprints[j];\n sprint.user_stories = _.sortBy(sprint.user_stories, \"sprint_order\");\n }\n _this.scope.sprints = sprints;\n _this.scope.openSprints = _.filter(sprints, function(sprint) {\n return !sprint.closed;\n }).reverse();\n if (!_this.scope.closedSprints) {\n _this.scope.closedSprints = [];\n }\n _this.scope.sprintsCounter = sprints.length;\n _this.scope.sprintsById = groupBy(sprints, function(x) {\n return x.id;\n });\n _this.rootscope.$broadcast(\"sprints:loaded\", sprints);\n _this.scope.currentSprint = _this.findCurrentSprint();\n return sprints;\n };\n })(this));\n };\n\n BacklogController.prototype.restoreFilters = function() {\n var selectedStatuses, selectedTags;\n selectedTags = this.scope.oldSelectedTags;\n selectedStatuses = this.scope.oldSelectedStatuses;\n if (!selectedStatuses && !selectedStatuses) {\n return;\n }\n this.scope.filtersQ = this.scope.filtersQOld;\n this.replaceFilter(\"q\", this.scope.filtersQ);\n _.each([selectedTags, selectedStatuses], (function(_this) {\n return function(filterGrp) {\n return _.each(filterGrp, function(item) {\n var filter, filters;\n filters = _this.scope.filters[item.type];\n filter = _.find(filters, {\n id: item.id\n });\n filter.selected = true;\n return _this.selectFilter(item.type, item.id);\n });\n };\n })(this));\n return this.loadUserstories();\n };\n\n BacklogController.prototype.resetFilters = function() {\n var selectedStatuses, selectedTags;\n selectedTags = _.filter(this.scope.filters.tags, \"selected\");\n selectedStatuses = _.filter(this.scope.filters.status, \"selected\");\n this.scope.oldSelectedTags = selectedTags;\n this.scope.oldSelectedStatuses = selectedStatuses;\n this.scope.filtersQOld = this.scope.filtersQ;\n this.scope.filtersQ = void 0;\n this.replaceFilter(\"q\", this.scope.filtersQ);\n _.each([selectedTags, selectedStatuses], (function(_this) {\n return function(filterGrp) {\n return _.each(filterGrp, function(item) {\n var filter, filters;\n filters = _this.scope.filters[item.type];\n filter = _.find(filters, {\n id: item.id\n });\n filter.selected = false;\n return _this.unselectFilter(item.type, item.id);\n });\n };\n })(this));\n return this.loadUserstories();\n };\n\n BacklogController.prototype.loadUserstories = function() {\n var promise;\n this.scope.httpParams = this.getUrlFilters();\n this.rs.userstories.storeQueryParams(this.scope.projectId, this.scope.httpParams);\n promise = this.rs.userstories.listUnassigned(this.scope.projectId, this.scope.httpParams);\n return promise.then((function(_this) {\n return function(userstories) {\n _this.scope.userstories = _.sortBy(userstories, \"backlog_order\");\n _this.setSearchDataFilters();\n scopeDefer(_this.scope, function() {\n return _this.scope.$broadcast(\"userstories:loaded\");\n });\n return userstories;\n };\n })(this));\n };\n\n BacklogController.prototype.loadBacklog = function() {\n return this.q.all([this.loadProjectStats(), this.loadSprints(), this.loadUserstories()]);\n };\n\n BacklogController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_backlog_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.closedMilestones = !!project.total_closed_milestones;\n _this.scope.$emit('project:loaded', project);\n _this.scope.points = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"id\");\n return project;\n };\n })(this));\n };\n\n BacklogController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.initializeSubscription();\n };\n })(this));\n return promise.then((function(_this) {\n return function() {\n return _this.loadBacklog();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.generateFilters();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.scope.$emit(\"backlog:loaded\");\n };\n })(this));\n };\n\n BacklogController.prototype.prepareBulkUpdateData = function(uses, field) {\n if (field == null) {\n field = \"backlog_order\";\n }\n return _.map(uses, function(x) {\n return {\n \"us_id\": x.id,\n \"order\": x[field]\n };\n });\n };\n\n BacklogController.prototype.resortUserStories = function(uses, field) {\n var index, item, items, j, len;\n if (field == null) {\n field = \"backlog_order\";\n }\n items = [];\n for (index = j = 0, len = uses.length; j < len; index = ++j) {\n item = uses[index];\n item[field] = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n BacklogController.prototype.moveUs = function(ctx, usList, newUsIndex, newSprintId) {\n var data, items, j, l, len, len1, len2, m, movedFromClosedSprint, movedToClosedSprint, newSprint, oldSprintId, project, promise, promises, sprint, us, userstories;\n oldSprintId = usList[0].milestone;\n project = usList[0].project;\n movedFromClosedSprint = false;\n movedToClosedSprint = false;\n sprint = this.scope.sprintsById[oldSprintId];\n if (!sprint && this.scope.closedSprintsById) {\n sprint = this.scope.closedSprintsById[oldSprintId];\n if (sprint) {\n movedFromClosedSprint = true;\n }\n }\n newSprint = this.scope.sprintsById[newSprintId];\n if (!newSprint && newSprintId) {\n newSprint = this.scope.closedSprintsById[newSprintId];\n if (newSprint) {\n movedToClosedSprint = true;\n }\n }\n if (newSprintId === oldSprintId) {\n items = null;\n userstories = null;\n if (newSprintId === null) {\n userstories = this.scope.userstories;\n } else {\n userstories = newSprint.user_stories;\n }\n this.scope.$apply(function() {\n var args, j, key, len, r, us;\n for (key = j = 0, len = usList.length; j < len; key = ++j) {\n us = usList[key];\n r = userstories.indexOf(us);\n userstories.splice(r, 1);\n }\n args = [newUsIndex, 0].concat(usList);\n return Array.prototype.splice.apply(userstories, args);\n });\n if (newSprintId === null) {\n items = this.resortUserStories(userstories, \"backlog_order\");\n data = this.prepareBulkUpdateData(items, \"backlog_order\");\n this.rs.userstories.bulkUpdateBacklogOrder(project, data).then((function(_this) {\n return function() {\n var j, len, results, us;\n results = [];\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n };\n })(this));\n } else {\n items = this.resortUserStories(userstories, \"sprint_order\");\n data = this.prepareBulkUpdateData(items, \"sprint_order\");\n this.rs.userstories.bulkUpdateSprintOrder(project, data).then((function(_this) {\n return function() {\n var j, len, results, us;\n results = [];\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n };\n })(this));\n }\n return promise;\n }\n if (newSprintId === null) {\n for (j = 0, len = usList.length; j < len; j++) {\n us = usList[j];\n us.milestone = null;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, key, l, len1, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(_this.scope.userstories, args);\n results = [];\n for (key = l = 0, len1 = usList.length; l < len1; key = ++l) {\n us = usList[key];\n r = sprint.user_stories.indexOf(us);\n results.push(sprint.user_stories.splice(r, 1));\n }\n return results;\n };\n })(this));\n promise = this.repo.save(us);\n promise = promise.then((function(_this) {\n return function() {\n items = _this.resortUserStories(_this.scope.userstories, \"backlog_order\");\n data = _this.prepareBulkUpdateData(items, \"backlog_order\");\n return _this.rs.userstories.bulkUpdateBacklogOrder(us.project, data).then(function() {\n _this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId);\n if (movedFromClosedSprint) {\n return _this.rootscope.$broadcast(\"backlog:load-closed-sprints\");\n }\n });\n };\n })(this));\n promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n return promise;\n }\n if (oldSprintId === null) {\n for (l = 0, len1 = usList.length; l < len1; l++) {\n us = usList[l];\n us.milestone = newSprintId;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, key, len2, m, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(newSprint.user_stories, args);\n results = [];\n for (key = m = 0, len2 = usList.length; m < len2; key = ++m) {\n us = usList[key];\n r = _this.scope.userstories.indexOf(us);\n results.push(_this.scope.userstories.splice(r, 1));\n }\n return results;\n };\n })(this));\n } else {\n for (m = 0, len2 = usList.length; m < len2; m++) {\n us = usList[m];\n us.milestone = newSprintId;\n }\n this.scope.$apply((function(_this) {\n return function() {\n var args, len3, n, r, results;\n args = [newUsIndex, 0].concat(usList);\n Array.prototype.splice.apply(newSprint.user_stories, args);\n results = [];\n for (n = 0, len3 = usList.length; n < len3; n++) {\n us = usList[n];\n r = sprint.user_stories.indexOf(us);\n results.push(sprint.user_stories.splice(r, 1));\n }\n return results;\n };\n })(this));\n }\n promises = _.map(usList, (function(_this) {\n return function(us) {\n return _this.repo.save(us);\n };\n })(this));\n promise = this.q.all(promises).then((function(_this) {\n return function() {\n items = _this.resortUserStories(newSprint.user_stories, \"sprint_order\");\n data = _this.prepareBulkUpdateData(items, \"sprint_order\");\n _this.rs.userstories.bulkUpdateSprintOrder(project, data).then(function(result) {\n return _this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId);\n });\n _this.rs.userstories.bulkUpdateBacklogOrder(project, data).then(function() {\n var len3, n, results;\n results = [];\n for (n = 0, len3 = usList.length; n < len3; n++) {\n us = usList[n];\n results.push(_this.rootscope.$broadcast(\"sprint:us:moved\", us, oldSprintId, newSprintId));\n }\n return results;\n });\n if (movedToClosedSprint || movedFromClosedSprint) {\n return _this.scope.$broadcast(\"backlog:load-closed-sprints\");\n }\n };\n })(this));\n promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n return promise;\n };\n\n BacklogController.prototype.isFilterSelected = function(type, id) {\n if ((this.searchdata[type] != null) && this.searchdata[type][id]) {\n return true;\n }\n return false;\n };\n\n BacklogController.prototype.setSearchDataFilters = function() {\n var name, results, urlfilters, val, value;\n urlfilters = this.getUrlFilters();\n if (urlfilters.q) {\n this.scope.filtersQ = this.scope.filtersQ || urlfilters.q;\n }\n this.searchdata = {};\n results = [];\n for (name in urlfilters) {\n value = urlfilters[name];\n if (this.searchdata[name] == null) {\n this.searchdata[name] = {};\n }\n results.push((function() {\n var j, len, ref1, results1;\n ref1 = taiga.toString(value).split(\",\");\n results1 = [];\n for (j = 0, len = ref1.length; j < len; j++) {\n val = ref1[j];\n results1.push(this.searchdata[name][val] = true);\n }\n return results1;\n }).call(this));\n }\n return results;\n };\n\n BacklogController.prototype.getUrlFilters = function() {\n return _.pick(this.location.search(), \"status\", \"tags\", \"q\");\n };\n\n BacklogController.prototype.generateFilters = function() {\n var loadFilters, urlfilters;\n urlfilters = this.getUrlFilters();\n this.scope.filters = {};\n loadFilters = {};\n loadFilters.project = this.scope.projectId;\n loadFilters.tags = urlfilters.tags;\n loadFilters.status = urlfilters.status;\n loadFilters.q = urlfilters.q;\n loadFilters.milestone = 'null';\n return this.rs.userstories.filtersData(loadFilters).then((function(_this) {\n return function(data) {\n var choicesFiltersFormat, selectedStatuses, selectedTags, tagsFilterFormat;\n choicesFiltersFormat = function(choices, type, byIdObject) {\n return _.map(choices, function(t) {\n t.type = type;\n return t;\n });\n };\n tagsFilterFormat = function(tags) {\n return _.map(tags, function(t) {\n t.id = t.name;\n t.type = 'tags';\n return t;\n });\n };\n _this.scope.filters.status = choicesFiltersFormat(data.statuses, \"status\", _this.scope.usStatusById);\n _this.scope.filters.tags = tagsFilterFormat(data.tags);\n selectedTags = _.filter(_this.scope.filters.tags, \"selected\");\n selectedTags = _.map(selectedTags, \"id\");\n selectedStatuses = _.filter(_this.scope.filters.status, \"selected\");\n selectedStatuses = _.map(selectedStatuses, \"id\");\n _this.markSelectedFilters(_this.scope.filters, urlfilters);\n return _this.rs.userstories.storeQueryParams(_this.scope.projectId, {\n \"status\": selectedStatuses,\n \"tags\": selectedTags,\n \"project\": _this.scope.projectId,\n \"milestone\": null\n });\n };\n })(this));\n };\n\n BacklogController.prototype.markSelectedFilters = function(filters, urlfilters) {\n var isSelected, j, key, len, name, obj, ref1, ref2, results, searchdata, val, value;\n searchdata = {};\n ref1 = _.omit(urlfilters, \"page\", \"orderBy\");\n for (name in ref1) {\n value = ref1[name];\n if (searchdata[name] == null) {\n searchdata[name] = {};\n }\n ref2 = (\"\" + value).split(\",\");\n for (j = 0, len = ref2.length; j < len; j++) {\n val = ref2[j];\n searchdata[name][val] = true;\n }\n }\n isSelected = function(type, id) {\n if ((searchdata[type] != null) && searchdata[type][id]) {\n return true;\n }\n return false;\n };\n results = [];\n for (key in filters) {\n value = filters[key];\n results.push((function() {\n var l, len1, results1;\n results1 = [];\n for (l = 0, len1 = value.length; l < len1; l++) {\n obj = value[l];\n results1.push(obj.selected = isSelected(obj.type, obj.id) ? true : void 0);\n }\n return results1;\n })());\n }\n return results;\n };\n\n BacklogController.prototype.updateUserStoryStatus = function() {\n this.setSearchDataFilters();\n return this.generateFilters().then((function(_this) {\n return function() {\n _this.rootscope.$broadcast(\"filters:update\");\n return _this.loadProjectStats();\n };\n })(this));\n };\n\n BacklogController.prototype.editUserStory = function(projectId, ref, $event) {\n var currentLoading, target;\n target = $($event.target);\n currentLoading = this.loading().target(target).removeClasses(\"icon-edit\").timeout(200).start();\n return this.rs.userstories.getByRef(projectId, ref).then((function(_this) {\n return function(us) {\n return _this.rs2.attachments.list(\"us\", us.id, projectId).then(function(attachments) {\n _this.rootscope.$broadcast(\"usform:edit\", us, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n };\n\n BacklogController.prototype.deleteUserStory = function(us) {\n var message, title;\n title = this.translate.instant(\"US.TITLE_DELETE_ACTION\");\n message = us.subject;\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var promise;\n _this.scope.userstories = _.without(_this.scope.userstories, us);\n promise = _this.repo.remove(us);\n promise.then(function() {\n askResponse.finish();\n return _this.loadBacklog();\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return _this.confirm.notify(\"error\");\n });\n };\n })(this));\n };\n\n BacklogController.prototype.addNewUs = function(type) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"usform:new\", this.scope.projectId, this.scope.project.default_us_status, this.scope.usStatusList);\n case \"bulk\":\n return this.rootscope.$broadcast(\"usform:bulk\", this.scope.projectId, this.scope.project.default_us_status);\n }\n };\n\n BacklogController.prototype.addNewSprint = function() {\n return this.rootscope.$broadcast(\"sprintform:create\", this.scope.projectId);\n };\n\n BacklogController.prototype.findCurrentSprint = function() {\n var currentDate;\n currentDate = new Date().getTime();\n return _.find(this.scope.sprints, function(sprint) {\n var end, start;\n start = moment(sprint.estimated_start, 'YYYY-MM-DD').format('x');\n end = moment(sprint.estimated_finish, 'YYYY-MM-DD').format('x');\n return currentDate >= start && currentDate <= end;\n });\n };\n\n return BacklogController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"BacklogController\", BacklogController);\n\n BacklogDirective = function($repo, $rootscope, $translate) {\n var doomLineTemplate, link, linkDoomLine, linkFilters, linkToolbar, showHideFilter, showHideTags;\n doomLineTemplate = _.template(\"
<%- text %>
\");\n linkDoomLine = function($scope, $el, $attrs, $ctrl) {\n var addDoomLineDom, getUsItems, reloadDoomLine, removeDoomlineDom;\n reloadDoomLine = function() {\n var current_sum, domElement, i, j, len, ref1, results, stats, total_points, us;\n if (($scope.stats != null) && ($scope.stats.total_points != null) && $scope.stats.total_points !== 0) {\n removeDoomlineDom();\n stats = $scope.stats;\n total_points = stats.total_points;\n current_sum = stats.assigned_points;\n if (!$scope.userstories) {\n return;\n }\n ref1 = $scope.userstories;\n results = [];\n for (i = j = 0, len = ref1.length; j < len; i = ++j) {\n us = ref1[i];\n current_sum += us.total_points;\n if (current_sum > total_points) {\n domElement = $el.find('.backlog-table-body .us-item-row')[i];\n addDoomLineDom(domElement);\n break;\n } else {\n results.push(void 0);\n }\n }\n return results;\n }\n };\n removeDoomlineDom = function() {\n return $el.find(\".doom-line\").remove();\n };\n addDoomLineDom = function(element) {\n var text;\n text = $translate.instant(\"BACKLOG.DOOMLINE\");\n return $(element).before(doomLineTemplate({\n \"text\": text\n }));\n };\n getUsItems = function() {\n var rowElements;\n rowElements = $el.find('.backlog-table-body .us-item-row');\n return _.map(rowElements, function(x) {\n return angular.element(x);\n });\n };\n $scope.$on(\"userstories:loaded\", reloadDoomLine);\n return $scope.$watch(\"stats\", reloadDoomLine);\n };\n linkToolbar = function($scope, $el, $attrs, $ctrl) {\n var checkSelected, getUsToMove, lastChecked, moveToCurrentSprint, moveToLatestSprint, moveUssToSprint, shiftPressed;\n getUsToMove = function() {\n var ussDom;\n ussDom = $el.find(\".backlog-table-body input:checkbox:checked\");\n return _.map(ussDom, function(item) {\n var itemScope;\n item = $(item).closest('.tg-scope');\n itemScope = item.scope();\n itemScope.us.milestone = $scope.sprints[0].id;\n return itemScope.us;\n });\n };\n moveUssToSprint = function(selectedUss, sprint) {\n var extraPoints, totalExtraPoints, ussCurrent;\n ussCurrent = _($scope.userstories);\n $scope.userstories = ussCurrent.without.apply(ussCurrent, selectedUss).value();\n extraPoints = _.map(selectedUss, function(v, k) {\n return v.total_points;\n });\n totalExtraPoints = _.reduce(extraPoints, function(acc, num) {\n return acc + num;\n });\n sprint.user_stories = _.union(sprint.user_stories, selectedUss);\n sprint.total_points += totalExtraPoints;\n $repo.saveAll(selectedUss).then(function() {\n $ctrl.loadSprints();\n return $ctrl.loadProjectStats();\n });\n return $el.find(\".move-to-sprint\").hide();\n };\n moveToCurrentSprint = function(selectedUss) {\n return moveUssToSprint(selectedUss, $scope.currentSprint);\n };\n moveToLatestSprint = function(selectedUss) {\n return moveUssToSprint(selectedUss, $scope.sprints[0]);\n };\n shiftPressed = false;\n lastChecked = null;\n checkSelected = function(target) {\n var moveToSprintDom, selectedUsDom;\n lastChecked = target.closest(\".us-item-row\");\n target.closest('.us-item-row').toggleClass('ui-multisortable-multiple');\n moveToSprintDom = $el.find(\".move-to-sprint\");\n selectedUsDom = $el.find(\".backlog-table-body input:checkbox:checked\");\n if (selectedUsDom.length > 0 && $scope.sprints.length > 0) {\n return moveToSprintDom.show();\n } else {\n return moveToSprintDom.hide();\n }\n };\n $(window).on(\"keydown.shift-pressed keyup.shift-pressed\", function(event) {\n shiftPressed = !!event.shiftKey;\n return true;\n });\n $el.on(\"change\", \".backlog-table-body input:checkbox\", function(event) {\n var current, elements, nextAll, prevAll, target;\n if (lastChecked && shiftPressed) {\n elements = [];\n current = $(event.currentTarget).closest(\".us-item-row\");\n nextAll = lastChecked.nextAll();\n prevAll = lastChecked.prevAll();\n if (_.some(nextAll, function(next) {\n return next === current[0];\n })) {\n elements = lastChecked.nextUntil(current);\n } else if (_.some(prevAll, function(prev) {\n return prev === current[0];\n })) {\n elements = lastChecked.prevUntil(current);\n }\n _.map(elements, function(elm) {\n var input;\n input = $(elm).find(\"input:checkbox\");\n input.prop('checked', true);\n return checkSelected(input);\n });\n }\n target = angular.element(event.currentTarget);\n target.closest(\".us-item-row\").toggleClass('is-checked');\n return checkSelected(target);\n });\n $el.on(\"click\", \"#move-to-latest-sprint\", (function(_this) {\n return function(event) {\n var ussToMove;\n ussToMove = getUsToMove();\n return $scope.$apply(_.partial(moveToLatestSprint, ussToMove));\n };\n })(this));\n $el.on(\"click\", \"#move-to-current-sprint\", (function(_this) {\n return function(event) {\n var ussToMove;\n ussToMove = getUsToMove();\n return $scope.$apply(_.partial(moveToCurrentSprint, ussToMove));\n };\n })(this));\n return $el.on(\"click\", \"#show-tags\", function(event) {\n event.preventDefault();\n $ctrl.toggleShowTags();\n return showHideTags($ctrl);\n });\n };\n showHideTags = function($ctrl) {\n var elm, text;\n elm = angular.element(\"#show-tags\");\n if ($ctrl.showTags) {\n elm.addClass(\"active\");\n text = $translate.instant(\"BACKLOG.TAGS.HIDE\");\n return elm.text(text);\n } else {\n elm.removeClass(\"active\");\n text = $translate.instant(\"BACKLOG.TAGS.SHOW\");\n return elm.text(text);\n }\n };\n showHideFilter = function($scope, $el, $ctrl) {\n var hideText, showText, sidebar, target;\n sidebar = $el.find(\"sidebar.filters-bar\");\n sidebar.one(\"transitionend\", function() {\n return timeout(150, function() {\n $rootscope.$broadcast(\"resize\");\n return $('.burndown').css(\"visibility\", \"visible\");\n });\n });\n target = angular.element(\"#show-filters-button\");\n $('.burndown').css(\"visibility\", \"hidden\");\n sidebar.toggleClass(\"active\");\n target.toggleClass(\"active\");\n hideText = $translate.instant(\"BACKLOG.FILTERS.HIDE\");\n showText = $translate.instant(\"BACKLOG.FILTERS.SHOW\");\n toggleText(target, [hideText, showText]);\n if (!sidebar.hasClass(\"active\")) {\n $ctrl.resetFilters();\n } else {\n $ctrl.restoreFilters();\n }\n return $ctrl.toggleActiveFilters();\n };\n linkFilters = function($scope, $el, $attrs, $ctrl) {\n $scope.filtersSearch = {};\n return $el.on(\"click\", \"#show-filters-button\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n return showHideFilter($scope, $el, $ctrl);\n });\n });\n };\n link = function($scope, $el, $attrs, $rootscope) {\n var $ctrl, filters;\n $ctrl = $el.controller();\n linkToolbar($scope, $el, $attrs, $ctrl);\n linkFilters($scope, $el, $attrs, $ctrl);\n linkDoomLine($scope, $el, $attrs, $ctrl);\n $el.find(\".backlog-table-body\").disableSelection();\n filters = $ctrl.getUrlFilters();\n if (filters.status || filters.tags || filters.q) {\n showHideFilter($scope, $el, $ctrl);\n }\n $scope.$on(\"showTags\", function() {\n return showHideTags($ctrl);\n });\n return $scope.$on(\"$destroy\", function() {\n $el.off();\n return $(window).off(\".shift-pressed\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklog\", [\"$tgRepo\", \"$rootScope\", \"$translate\", BacklogDirective]);\n\n UsRolePointsSelectorDirective = function($rootscope, $template, $compile, $translate) {\n var link, selectionTemplate;\n selectionTemplate = $template.get(\"backlog/us-role-points-popover.html\", true);\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var numberOfRoles, roles;\n roles = _.filter(project.roles, \"computable\");\n numberOfRoles = _.size(roles);\n if (numberOfRoles > 1) {\n return $el.append($compile(selectionTemplate({\n \"roles\": roles\n }))($scope));\n } else {\n $el.find(\".icon-arrow-bottom\").remove();\n return $el.find(\".header-points\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"uspoints:select\", function(ctx, roleId, roleName) {\n $el.find(\".popover\").popover().close();\n return $el.find(\".header-points\").html(roleName + \"/Total\");\n });\n $scope.$on(\"uspoints:clear-selection\", function(ctx, roleId) {\n var text;\n $el.find(\".popover\").popover().close();\n text = $translate.instant(\"COMMON.FIELDS.POINTS\");\n return $el.find(\".header-points\").text(text);\n });\n $el.on(\"click\", function(event) {\n var target;\n target = angular.element(event.target);\n if (target.is(\"span\") || target.is(\"div\")) {\n event.stopPropagation();\n }\n return $el.find(\".popover\").popover().open();\n });\n $el.on(\"click\", \".clear-selection\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $rootscope.$broadcast(\"uspoints:clear-selection\");\n });\n $el.on(\"click\", \".role\", function(event) {\n var rolScope, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n rolScope = target.scope();\n return $rootscope.$broadcast(\"uspoints:select\", target.data(\"role-id\"), target.text());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUsRolePointsSelector\", [\"$rootScope\", \"$tgTemplate\", \"$compile\", UsRolePointsSelectorDirective]);\n\n UsPointsDirective = function($tgEstimationsService, $repo, $tgTemplate) {\n var link, rolesTemplate;\n rolesTemplate = $tgTemplate.get(\"common/estimation/us-points-roles-popover.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, bindClickElements, estimationProcess, filteringRoleId, renderRolesSelector, selectedRoleId, updatingSelectedRoleId;\n $ctrl = $el.controller();\n updatingSelectedRoleId = null;\n selectedRoleId = null;\n filteringRoleId = null;\n estimationProcess = null;\n $scope.$on(\"uspoints:select\", function(ctx, roleId, roleName) {\n var us;\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n selectedRoleId = roleId;\n return estimationProcess.render();\n });\n $scope.$on(\"uspoints:clear-selection\", function(ctx) {\n var us;\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n selectedRoleId = null;\n return estimationProcess.render();\n });\n $scope.$watch($attrs.tgBacklogUsPoints, function(us) {\n var roles;\n if (us) {\n estimationProcess = $tgEstimationsService.create($el, us, $scope.project);\n roles = estimationProcess.calculateRoles();\n if (roles.length === 0) {\n $el.find(\".icon-arrow-bottom\").remove();\n $el.find(\"a.us-points\").addClass(\"not-clickable\");\n } else if (roles.length === 1) {\n selectedRoleId = _.keys(us.points)[0];\n }\n if (estimationProcess.isEditable) {\n bindClickElements();\n }\n estimationProcess.onSelectedPointForRole = function(roleId, pointId) {\n return this.save(roleId, pointId).then(function() {\n return $ctrl.loadProjectStats();\n });\n };\n estimationProcess.render = function() {\n var ctx, html, mainTemplate, pointId, pointObj, template, text, title, totalPoints;\n totalPoints = this.calculateTotalPoints();\n if ((selectedRoleId == null) || roles.length === 1) {\n text = totalPoints;\n title = totalPoints;\n } else {\n pointId = this.us.points[selectedRoleId];\n pointObj = this.pointsById[pointId];\n text = pointObj.name + \" / \" + totalPoints + \"\";\n title = pointObj.name + \" / \" + totalPoints;\n }\n ctx = {\n totalPoints: totalPoints,\n roles: this.calculateRoles(),\n editable: this.isEditable,\n text: text,\n title: title\n };\n mainTemplate = \"common/estimation/us-estimation-total.html\";\n template = $tgTemplate.get(mainTemplate, true);\n html = template(ctx);\n return this.$el.html(html);\n };\n return estimationProcess.render();\n }\n });\n renderRolesSelector = function() {\n var html, roles;\n roles = estimationProcess.calculateRoles();\n html = rolesTemplate({\n \"roles\": roles\n });\n $el.append(html);\n return $el.find(\".pop-role\").popover().open(function() {\n return $(this).remove();\n });\n };\n bindClickElements = function() {\n $el.on(\"click\", \"a.us-points span\", function(event) {\n var us;\n event.preventDefault();\n event.stopPropagation();\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n updatingSelectedRoleId = selectedRoleId;\n if (selectedRoleId != null) {\n return estimationProcess.renderPointsSelector(selectedRoleId);\n } else {\n return renderRolesSelector();\n }\n });\n return $el.on(\"click\", \".role\", function(event) {\n var popRolesDom, target, us;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n us = $scope.$eval($attrs.tgBacklogUsPoints);\n updatingSelectedRoleId = target.data(\"role-id\");\n popRolesDom = $el.find(\".pop-role\");\n popRolesDom.find(\"a\").removeClass(\"active\");\n popRolesDom.find(\"a[data-role-id='\" + updatingSelectedRoleId + \"']\").addClass(\"active\");\n return estimationProcess.renderPointsSelector(updatingSelectedRoleId);\n });\n };\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogUsPoints\", [\"$tgEstimationsService\", \"$tgRepo\", \"$tgTemplate\", UsPointsDirective]);\n\n ToggleBurndownVisibility = function($storage) {\n var hide, link, show;\n hide = function() {\n $(\".js-burndown-graph\").removeClass(\"shown\");\n $(\".js-toggle-burndown-visibility-button\").removeClass(\"active\");\n return $(\".js-burndown-graph\").removeClass(\"open\");\n };\n show = function(firstLoad) {\n $(\".js-toggle-burndown-visibility-button\").addClass(\"active\");\n if (firstLoad) {\n return $(\".js-burndown-graph\").addClass(\"shown\");\n } else {\n return $(\".js-burndown-graph\").addClass(\"open\");\n }\n };\n link = function($scope, $el, $attrs) {\n var firstLoad, hash, toggleGraph;\n firstLoad = true;\n hash = generateHash([\"is-burndown-grpahs-collapsed\"]);\n $scope.isBurndownGraphCollapsed = $storage.get(hash) || false;\n toggleGraph = function() {\n if ($scope.isBurndownGraphCollapsed) {\n hide(firstLoad);\n } else {\n show(firstLoad);\n }\n return firstLoad = false;\n };\n $scope.$watch(\"showGraphPlaceholder\", function() {\n if ($scope.showGraphPlaceholder != null) {\n $scope.isBurndownGraphCollapsed = $scope.isBurndownGraphCollapsed || $scope.showGraphPlaceholder;\n return toggleGraph();\n }\n });\n $el.on(\"click\", \".js-toggle-burndown-visibility-button\", function() {\n $scope.isBurndownGraphCollapsed = !$scope.isBurndownGraphCollapsed;\n $storage.set(hash, $scope.isBurndownGraphCollapsed);\n return toggleGraph();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgToggleBurndownVisibility\", [\"$tgStorage\", ToggleBurndownVisibility]);\n\n BurndownBacklogGraphDirective = function($translate) {\n var link, redrawChart;\n redrawChart = function(element, dataToDraw) {\n var client_increment_line, colors, data, evolution_line, j, milestonesRange, optimal_line, options, ref1, results, team_increment_line, width, zero_line;\n width = element.width();\n element.height(width / 6);\n milestonesRange = (function() {\n results = [];\n for (var j = 0, ref1 = dataToDraw.milestones.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; 0 <= ref1 ? j++ : j--){ results.push(j); }\n return results;\n }).apply(this);\n data = [];\n zero_line = _.map(dataToDraw.milestones, function(ml) {\n return 0;\n });\n data.push({\n data: _.zip(milestonesRange, zero_line),\n lines: {\n fillColor: \"rgba(0,0,0,0)\"\n },\n points: {\n show: false\n }\n });\n optimal_line = _.map(dataToDraw.milestones, function(ml) {\n return ml.optimal;\n });\n data.push({\n data: _.zip(milestonesRange, optimal_line),\n lines: {\n fillColor: \"rgba(120,120,120,0.2)\"\n }\n });\n evolution_line = _.filter(_.map(dataToDraw.milestones, function(ml) {\n return ml.evolution;\n }), function(evolution) {\n return evolution != null;\n });\n data.push({\n data: _.zip(milestonesRange, evolution_line),\n lines: {\n fillColor: \"rgba(102,153,51,0.3)\"\n }\n });\n client_increment_line = _.map(dataToDraw.milestones, function(ml) {\n return -ml[\"team-increment\"] - ml[\"client-increment\"];\n });\n data.push({\n data: _.zip(milestonesRange, client_increment_line),\n lines: {\n fillColor: \"rgba(255,51,51,0.3)\"\n }\n });\n team_increment_line = _.map(dataToDraw.milestones, function(ml) {\n return -ml[\"team-increment\"];\n });\n data.push({\n data: _.zip(milestonesRange, team_increment_line),\n lines: {\n fillColor: \"rgba(153,51,51,0.3)\"\n }\n });\n colors = [\"rgba(0,0,0,1)\", \"rgba(120,120,120,0.2)\", \"rgba(102,153,51,1)\", \"rgba(153,51,51,1)\", \"rgba(255,51,51,1)\"];\n options = {\n grid: {\n borderWidth: {\n top: 0,\n right: 1,\n left: 0,\n bottom: 0\n },\n borderColor: \"#ccc\",\n hoverable: true\n },\n xaxis: {\n ticks: dataToDraw.milestones.length,\n axisLabel: $translate.instant(\"BACKLOG.CHART.XAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: \"Verdana, Arial, Helvetica, Tahoma, sans-serif\",\n axisLabelPadding: 5,\n tickFormatter: function(val, axis) {\n return \"\";\n }\n },\n yaxis: {\n axisLabel: $translate.instant(\"BACKLOG.CHART.YAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: \"Verdana, Arial, Helvetica, Tahoma, sans-serif\",\n axisLabelPadding: 5\n },\n series: {\n shadowSize: 0,\n lines: {\n show: true,\n fill: true\n },\n points: {\n show: true,\n fill: true,\n radius: 4,\n lineWidth: 2\n }\n },\n colors: colors,\n tooltip: true,\n tooltipOpts: {\n content: function(label, xval, yval, flotItem) {\n var ctx;\n if (flotItem.seriesIndex === 1) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.OPTIMAL\", ctx);\n } else if (flotItem.seriesIndex === 2) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.REAL\", ctx);\n } else if (flotItem.seriesIndex === 3) {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.INCREMENT_CLIENT\", ctx);\n } else {\n ctx = {\n sprintName: dataToDraw.milestones[xval].name,\n value: Math.abs(yval)\n };\n return $translate.instant(\"BACKLOG.CHART.INCREMENT_TEAM\", ctx);\n }\n }\n }\n };\n element.empty();\n return element.plot(data, options).data(\"plot\");\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch(\"stats\", function(value) {\n if ($scope.stats != null) {\n redrawChart(element, $scope.stats);\n return $scope.$on(\"resize\", function() {\n return redrawChart(element, $scope.stats);\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBurndownBacklogGraph\", [\"$translate\", BurndownBacklogGraphDirective]);\n\n TgBacklogProgressBarDirective = function($template, $compile) {\n var adjustPercentaje, link, render, template;\n template = $template.get(\"backlog/progress-bar.html\", true);\n render = function(scope, el, projectPointsPercentaje, closedPointsPercentaje) {\n var html;\n html = template({\n projectPointsPercentaje: projectPointsPercentaje,\n closedPointsPercentaje: closedPointsPercentaje\n });\n html = $compile(html)(scope);\n return el.html(html);\n };\n adjustPercentaje = function(percentage) {\n var adjusted;\n adjusted = _.max([0, percentage]);\n adjusted = _.min([100, adjusted]);\n return Math.round(adjusted);\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$watch($attrs.tgBacklogProgressBar, function(stats) {\n var closedPoints, closedPointsPercentaje, definedPoints, projectPointsPercentaje, totalPoints;\n if (stats != null) {\n totalPoints = stats.total_points ? stats.total_points : stats.defined_points;\n definedPoints = stats.defined_points;\n closedPoints = stats.closed_points;\n if (definedPoints > totalPoints) {\n projectPointsPercentaje = totalPoints * 100 / definedPoints;\n closedPointsPercentaje = closedPoints * 100 / definedPoints;\n } else {\n projectPointsPercentaje = 100;\n closedPointsPercentaje = closedPoints * 100 / totalPoints;\n }\n projectPointsPercentaje = adjustPercentaje(projectPointsPercentaje - 3);\n closedPointsPercentaje = adjustPercentaje(closedPointsPercentaje - 3);\n return render($scope, $el, projectPointsPercentaje, closedPointsPercentaje);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogProgressBar\", [\"$tgTemplate\", \"$compile\", TgBacklogProgressBarDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/sortable.coffee\n */\n\n(function() {\n var BacklogEmptySortableDirective, BacklogSortableDirective, SprintSortableDirective, bindOnce, deleteElement, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaBacklog\");\n\n deleteElement = function(el) {\n el.scope().$destroy();\n el.off();\n return el.remove();\n };\n\n BacklogSortableDirective = function($repo, $rs, $rootscope, $tgConfirm, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var getUsIndex;\n getUsIndex = (function(_this) {\n return function(us) {\n return $(us).index(\".backlog-table-body .row\");\n };\n })(this);\n bindOnce($scope, \"project\", function(project) {\n var filterError;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n filterError = function() {\n var text;\n text = $translate.instant(\"BACKLOG.SORTABLE_FILTER_ERROR\");\n return $tgConfirm.notify(\"error\", text);\n };\n $el.sortable({\n items: \".us-item-row\",\n cancel: \".popover\",\n connectWith: \".sprint\",\n dropOnEmpty: true,\n placeholder: \"row us-item-row us-item-drag sortable-placeholder\",\n scroll: true,\n disableHorizontalScroll: true,\n tolerance: \"pointer\",\n revert: false,\n start: function() {\n return $(document.body).addClass(\"drag-active\");\n },\n stop: function() {\n $(document.body).removeClass(\"drag-active\");\n if ($el.hasClass(\"active-filters\")) {\n $el.sortable(\"cancel\");\n return filterError();\n }\n }\n });\n $el.on(\"multiplesortreceive\", function(event, ui) {\n var itemIndex, itemUs;\n if ($el.hasClass(\"active-filters\")) {\n ui.source.sortable(\"cancel\");\n filterError();\n return;\n }\n itemUs = ui.item.scope().us;\n itemIndex = getUsIndex(ui.item);\n deleteElement(ui.item);\n $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, null);\n return ui.item.find('a').removeClass('noclick');\n });\n $el.on(\"multiplesortstop\", function(event, ui) {\n var index, items, us;\n if ($(ui.items[0]).parent().length === 0) {\n return;\n }\n if ($el.hasClass(\"active-filters\")) {\n return;\n }\n items = _.sortBy(ui.items, function(item) {\n return $(item).index();\n });\n index = _.min(_.map(items, function(item) {\n return getUsIndex(item);\n }));\n us = _.map(items, function(item) {\n var itemUs;\n item = $(item);\n itemUs = item.scope().us;\n setTimeout(((function(_this) {\n return function() {\n return item.find('a').removeClass('noclick');\n };\n })(this)), 300);\n return itemUs;\n });\n return $scope.$emit(\"sprint:us:move\", us, index, null);\n });\n return $el.on(\"sortstart\", function(event, ui) {\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n BacklogEmptySortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n $el.sortable({\n items: \".us-item-row\",\n dropOnEmpty: true\n });\n return $el.on(\"sortreceive\", function(event, ui) {\n var itemIndex, itemUs;\n itemUs = ui.item.scope().us;\n itemIndex = ui.item.index();\n deleteElement(ui.item);\n $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, null);\n return ui.item.find('a').removeClass('noclick');\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n SprintSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n $el.sortable({\n scroll: true,\n dropOnEmpty: true,\n items: \".sprint-table .milestone-us-item-row\",\n disableHorizontalScroll: true,\n connectWith: \".sprint,.backlog-table-body,.empty-backlog\",\n placeholder: \"row us-item-row sortable-placeholder\",\n forcePlaceholderSize: true\n });\n $el.on(\"multiplesortreceive\", function(event, ui) {\n var index, items, us;\n items = _.sortBy(ui.items, function(item) {\n return $(item).index();\n });\n index = _.min(_.map(items, function(item) {\n return $(item).index();\n }));\n us = _.map(items, function(item) {\n var itemUs;\n item = $(item);\n itemUs = item.scope().us;\n deleteElement(item);\n return itemUs;\n });\n return $scope.$emit(\"sprint:us:move\", us, index, $scope.sprint.id);\n });\n $el.on(\"multiplesortstop\", function(event, ui) {\n var itemIndex, itemUs;\n if (ui.item.parent().length === 0) {\n return;\n }\n itemUs = ui.item.scope().us;\n itemIndex = ui.item.index();\n setTimeout(((function(_this) {\n return function() {\n return ui.item.find('a').removeClass('noclick');\n };\n })(this)), 300);\n return $scope.$emit(\"sprint:us:move\", [itemUs], itemIndex, $scope.sprint.id);\n });\n return $el.on(\"sortstart\", function(event, ui) {\n return ui.item.find('a').addClass('noclick');\n });\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"$tgConfirm\", \"$translate\", BacklogSortableDirective]);\n\n module.directive(\"tgBacklogEmptySortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", BacklogEmptySortableDirective]);\n\n module.directive(\"tgSprintSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", SprintSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog/sprints.coffee\n */\n\n(function() {\n var BacklogSprintDirective, BacklogSprintHeaderDirective, ToggleExcludeClosedSprintsVisualization, module, taiga;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaBacklog\");\n\n BacklogSprintDirective = function($repo, $rootscope) {\n var link, slideOptions, sprintTableMinHeight, toggleSprint;\n sprintTableMinHeight = 50;\n slideOptions = {\n duration: 500,\n easing: 'linear'\n };\n toggleSprint = (function(_this) {\n return function($el) {\n var sprintArrow, sprintTable;\n sprintTable = $el.find(\".sprint-table\");\n sprintArrow = $el.find(\".icon-arrow-up\");\n sprintArrow.toggleClass('active');\n return sprintTable.toggleClass('open');\n };\n })(this);\n link = function($scope, $el, $attrs) {\n $scope.$watch($attrs.tgBacklogSprint, function(sprint) {\n sprint = $scope.$eval($attrs.tgBacklogSprint);\n if (sprint.closed) {\n return $el.addClass(\"sprint-closed\");\n } else {\n return toggleSprint($el);\n }\n });\n $el.on(\"click\", \".sprint-name > .icon-arrow-up\", function(event) {\n event.preventDefault();\n toggleSprint($el);\n return $el.find(\".sprint-table\").slideToggle(slideOptions);\n });\n $el.on(\"click\", \".sprint-name > .icon-edit\", function(event) {\n var sprint;\n event.preventDefault();\n sprint = $scope.$eval($attrs.tgBacklogSprint);\n return $rootscope.$broadcast(\"sprintform:edit\", sprint);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogSprint\", [\"$tgRepo\", \"$rootScope\", BacklogSprintDirective]);\n\n BacklogSprintHeaderDirective = function($navUrls, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"backlog/sprint-header.html\");\n link = function($scope, $el, $attrs, $model) {\n var isEditable, isVisible, prettyDate, render;\n prettyDate = $translate.instant(\"BACKLOG.SPRINTS.DATE\");\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_milestone\") !== -1;\n };\n isVisible = function() {\n return $scope.project.my_permissions.indexOf(\"view_milestones\") !== -1;\n };\n render = function(sprint) {\n var compiledTemplate, ctx, estimatedDateRange, finish, start, taskboardUrl, templateScope;\n taskboardUrl = $navUrls.resolve(\"project-taskboard\", {\n project: $scope.project.slug,\n sprint: sprint.slug\n });\n start = moment(sprint.estimated_start).format(prettyDate);\n finish = moment(sprint.estimated_finish).format(prettyDate);\n estimatedDateRange = start + \"-\" + finish;\n ctx = {\n name: sprint.name,\n taskboardUrl: taskboardUrl,\n estimatedDateRange: estimatedDateRange,\n closedPoints: sprint.closed_points || 0,\n totalPoints: sprint.total_points || 0,\n isVisible: isVisible(),\n isEditable: isEditable()\n };\n templateScope = $scope.$new();\n _.assign(templateScope, ctx);\n compiledTemplate = $compile(template)(templateScope);\n return $el.html(compiledTemplate);\n };\n $scope.$watch($attrs.ngModel, function(sprint) {\n return render(sprint);\n });\n $scope.$on(\"sprintform:edit:success\", function() {\n return render($model.$modelValue);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgBacklogSprintHeader\", [\"$tgNavUrls\", \"$tgTemplate\", \"$compile\", \"$translate\", BacklogSprintHeaderDirective]);\n\n ToggleExcludeClosedSprintsVisualization = function($rootscope, $loading, $translate) {\n var excludeClosedSprints, link;\n excludeClosedSprints = true;\n link = function($scope, $el, $attrs) {\n var currentLoading, loadingElm;\n loadingElm = $(\"
\");\n $el.after(loadingElm);\n currentLoading = null;\n $el.on(\"click\", function(event) {\n event.preventDefault();\n excludeClosedSprints = !excludeClosedSprints;\n currentLoading = $loading().target(loadingElm).start();\n if (excludeClosedSprints) {\n return $rootscope.$broadcast(\"backlog:unload-closed-sprints\");\n } else {\n return $rootscope.$broadcast(\"backlog:load-closed-sprints\");\n }\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return $scope.$on(\"closed-sprints:reloaded\", (function(_this) {\n return function(ctx, sprints) {\n var key, text;\n currentLoading.finish();\n if (sprints.length > 0) {\n key = \"BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS\";\n } else {\n key = \"BACKLOG.SPRINTS.ACTION_SHOW_CLOSED_SPRINTS\";\n }\n text = $translate.instant(key);\n return $el.find(\".text\").text(text);\n };\n })(this));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBacklogToggleClosedSprintsVisualization\", [\"$rootScope\", \"$tgLoading\", \"$translate\", ToggleExcludeClosedSprintsVisualization]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/charts.coffee\n */\n\n(function() {\n var SprintGraphDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaTaskboard\");\n\n SprintGraphDirective = function($translate) {\n var link, redrawChart;\n redrawChart = function(element, dataToDraw) {\n var data, days, options, width;\n width = element.width();\n element.height(240);\n days = _.map(dataToDraw, function(x) {\n return moment(x.day);\n });\n data = [];\n data.unshift({\n data: _.zip(days, _.map(dataToDraw, function(d) {\n return d.optimal_points;\n })),\n lines: {\n fillColor: \"rgba(120,120,120,0.2)\"\n }\n });\n data.unshift({\n data: _.zip(days, _.map(dataToDraw, function(d) {\n return d.open_points;\n })),\n lines: {\n fillColor: \"rgba(102,153,51,0.3)\"\n }\n });\n options = {\n grid: {\n borderWidth: {\n top: 0,\n right: 1,\n left: 0,\n bottom: 0\n },\n borderColor: '#ccc',\n hoverable: true\n },\n xaxis: {\n tickSize: [1, \"day\"],\n min: days[0],\n max: _.last(days),\n mode: \"time\",\n daysNames: days,\n axisLabel: $translate.instant(\"TASKBOARD.CHARTS.XAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',\n axisLabelPadding: 5\n },\n yaxis: {\n min: 0,\n axisLabel: $translate.instant(\"TASKBOARD.CHARTS.YAXIS_LABEL\"),\n axisLabelUseCanvas: true,\n axisLabelFontSizePixels: 12,\n axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',\n axisLabelPadding: 5\n },\n series: {\n shadowSize: 0,\n lines: {\n show: true,\n fill: true\n },\n points: {\n show: true,\n fill: true,\n radius: 4,\n lineWidth: 2\n }\n },\n colors: [\"rgba(102,153,51,1)\", \"rgba(120,120,120,0.2)\"],\n tooltip: true,\n tooltipOpts: {\n content: function(label, xval, yval, flotItem) {\n var formattedDate, roundedValue;\n formattedDate = moment(xval).format($translate.instant(\"TASKBOARD.CHARTS.DATE\"));\n roundedValue = Math.round(yval);\n if (flotItem.seriesIndex === 1) {\n return $translate.instant(\"TASKBOARD.CHARTS.OPTIMAL\", {\n formattedDate: formattedDate,\n roundedValue: roundedValue\n });\n } else {\n return $translate.instant(\"TASKBOARD.CHARTS.REAL\", {\n formattedDate: formattedDate,\n roundedValue: roundedValue\n });\n }\n }\n }\n };\n element.empty();\n return element.plot(data, options).data(\"plot\");\n };\n link = function($scope, $el, $attrs) {\n var element;\n element = angular.element($el);\n $scope.$on(\"resize\", function() {\n if ($scope.stats) {\n return redrawChart(element, $scope.stats.days);\n }\n });\n $scope.$on(\"taskboard:graph:toggle-visibility\", function() {\n $el.parent().toggleClass('open');\n return timeout(100, function() {\n if ($scope.stats) {\n return redrawChart(element, $scope.stats.days);\n }\n });\n });\n $scope.$watch('stats', function(value) {\n if ($scope.stats == null) {\n return;\n }\n return redrawChart(element, $scope.stats.days);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSprintGraph\", [\"$translate\", SprintGraphDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/lightboxes.coffee\n */\n\n(function() {\n var CreateBulkTasksDirective, CreateEditTaskDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n CreateEditTaskDirective = function($repo, $model, $rs, $rootscope, $loading, lightboxService, $translate, $q, attachmentsService) {\n var link;\n link = function($scope, $el, attrs) {\n var attachmentsToAdd, attachmentsToDelete, createAttachments, deleteAttachments, resetAttachments, submit, submitButton;\n $scope.isNew = true;\n attachmentsToAdd = Immutable.List();\n attachmentsToDelete = Immutable.List();\n resetAttachments = function() {\n attachmentsToAdd = Immutable.List();\n return attachmentsToDelete = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n $scope.deleteAttachment = function(attachment) {\n return attachmentsToDelete = attachmentsToDelete.push(attachment);\n };\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.task.project, 'task');\n });\n return $q.all(promises);\n };\n deleteAttachments = function(obj) {\n var promises;\n console.log(attachmentsToDelete.toJS());\n promises = _.map(attachmentsToDelete.toJS(), function(attachment) {\n return attachmentsService[\"delete\"](\"task\", attachment.id);\n });\n return $q.all(promises);\n };\n $scope.$on(\"taskform:new\", function(ctx, sprintId, usId) {\n var create, newTask;\n $scope.task = {\n project: $scope.projectId,\n milestone: sprintId,\n user_story: usId,\n is_archived: false,\n status: $scope.project.default_task_status,\n assigned_to: null,\n tags: []\n };\n $scope.isNew = true;\n $scope.attachments = Immutable.List();\n resetAttachments();\n create = $translate.instant(\"COMMON.CREATE\");\n $el.find(\".button-green\").html(create);\n newTask = $translate.instant(\"LIGHTBOX.CREATE_EDIT_TASK.TITLE\");\n $el.find(\".title\").html(newTask + \" \");\n $el.find(\".tag-input\").val(\"\");\n return lightboxService.open($el);\n });\n $scope.$on(\"taskform:edit\", function(ctx, task, attachments) {\n var edit, save;\n $scope.task = task;\n $scope.isNew = false;\n $scope.attachments = Immutable.fromJS(attachments);\n resetAttachments();\n save = $translate.instant(\"COMMON.SAVE\");\n edit = $translate.instant(\"LIGHTBOX.CREATE_EDIT_TASK.ACTION_EDIT\");\n $el.find(\".button-green\").html(save);\n $el.find(\".title\").html(edit + \" \");\n $el.find(\".tag-input\").val(\"\");\n return lightboxService.open($el);\n });\n submitButton = $el.find(\".submit-button\");\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var broadcastEvent, currentLoading, form, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n if ($scope.isNew) {\n promise = $repo.create(\"tasks\", $scope.task);\n broadcastEvent = \"taskform:new:success\";\n } else {\n promise = $repo.save($scope.task);\n broadcastEvent = \"taskform:edit:success\";\n }\n promise.then(function(data) {\n createAttachments(data);\n deleteAttachments(data);\n return data;\n });\n currentLoading = $loading().target(submitButton).start();\n return promise.then(function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n return $rootscope.$broadcast(broadcastEvent, data);\n });\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n CreateBulkTasksDirective = function($repo, $rs, $rootscope, $loading, lightboxService) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.form = {\n data: \"\",\n usId: null\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, data, form, projectId, promise, sprintId, usId;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n data = $scope.form.data;\n projectId = $scope.projectId;\n sprintId = $scope.form.sprintId;\n usId = $scope.form.usId;\n promise = $rs.tasks.bulkCreate(projectId, sprintId, usId, data);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"taskform:bulk:success\", result);\n return lightboxService.close($el);\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return console.log(\"FAIL\");\n });\n };\n })(this));\n $scope.$on(\"taskform:bulk\", function(ctx, sprintId, usId) {\n lightboxService.open($el);\n return $scope.form = {\n data: \"\",\n sprintId: sprintId,\n usId: usId\n };\n });\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaTaskboard\");\n\n module.directive(\"tgLbCreateEditTask\", [\"$tgRepo\", \"$tgModel\", \"$tgResources\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", \"$translate\", \"$q\", \"tgAttachmentsService\", CreateEditTaskDirective]);\n\n module.directive(\"tgLbCreateBulkTasks\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", CreateBulkTasksDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard.coffee\n */\n\n(function() {\n var TaskboardController, TaskboardDirective, TaskboardSquishColumnDirective, TaskboardTaskDirective, TaskboardUserDirective, bindMethods, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n toggleText = this.taiga.toggleText;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n scopeDefer = this.taiga.scopeDefer;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaTaskboard\");\n\n TaskboardController = (function(superClass) {\n extend(TaskboardController, superClass);\n\n TaskboardController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"tgAppMetaService\", \"$tgLocation\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function TaskboardController(scope, rootscope, repo, confirm, rs1, params1, q, appMetaService, location, navUrls, events, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs1;\n this.params = params1;\n this.q = q;\n this.appMetaService = appMetaService;\n this.location = location;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"TASKBOARD.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n return _this._setMeta();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TaskboardController.prototype._setMeta = function() {\n var description, prettyDate, title;\n prettyDate = this.translate.instant(\"BACKLOG.SPRINTS.DATE\");\n title = this.translate.instant(\"TASKBOARD.PAGE_TITLE\", {\n projectName: this.scope.project.name,\n sprintName: this.scope.sprint.name\n });\n description = this.translate.instant(\"TASKBOARD.PAGE_DESCRIPTION\", {\n projectName: this.scope.project.name,\n sprintName: this.scope.sprint.name,\n startDate: moment(this.scope.sprint.estimated_start).format(prettyDate),\n endDate: moment(this.scope.sprint.estimated_finish).format(prettyDate),\n completedPercentage: this.scope.stats.completedPercentage || \"0\",\n completedPoints: this.scope.stats.completedPointsSum || \"--\",\n totalPoints: this.scope.stats.totalPointsSum || \"--\",\n openTasks: this.scope.stats.openTasks || \"--\",\n totalTasks: this.scope.stats.total_tasks || \"--\"\n });\n return this.appMetaService.setAll(title, description);\n };\n\n TaskboardController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"taskform:bulk:success\", (function(_this) {\n return function() {\n _this.loadTaskboard();\n return _this.analytics.trackEvent(\"task\", \"create\", \"bulk create task on taskboard\", 1);\n };\n })(this));\n this.scope.$on(\"taskform:new:success\", (function(_this) {\n return function() {\n _this.loadTaskboard();\n return _this.analytics.trackEvent(\"task\", \"create\", \"create task on taskboard\", 1);\n };\n })(this));\n this.scope.$on(\"taskform:edit:success\", (function(_this) {\n return function() {\n return _this.loadTaskboard();\n };\n })(this));\n this.scope.$on(\"taskboard:task:move\", this.taskMove);\n return this.scope.$on(\"assigned-to:added\", (function(_this) {\n return function(ctx, userId, task) {\n var promise;\n task.assigned_to = userId;\n promise = _this.repo.save(task);\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n })(this));\n };\n\n TaskboardController.prototype.initializeSubscription = function() {\n var routingKey, routingKey1;\n routingKey = \"changes.project.\" + this.scope.projectId + \".tasks\";\n this.events.subscribe(this.scope, routingKey, (function(_this) {\n return function(message) {\n return _this.loadTaskboard();\n };\n })(this));\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n return this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n _this.refreshTagsColors();\n _this.loadSprintStats();\n return _this.loadSprint();\n };\n })(this));\n };\n\n TaskboardController.prototype.loadProject = function() {\n return this.rs.projects.get(this.scope.projectId).then((function(_this) {\n return function(project) {\n if (!project.is_backlog_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.project = project;\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(e) {\n return e.id;\n });\n _this.scope.roleById = groupBy(project.roles, function(e) {\n return e.id;\n });\n _this.scope.taskStatusList = _.sortBy(project.task_statuses, \"order\");\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.scope.usStatusById = groupBy(project.us_statuses, function(e) {\n return e.id;\n });\n _this.scope.$emit('project:loaded', project);\n _this.fillUsersAndRoles(project.members, project.roles);\n return project;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadSprintStats = function() {\n return this.rs.sprints.stats(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(stats) {\n var completedPointsSum, remainingPointsSum, remainingTasks, totalPointsSum;\n totalPointsSum = _.reduce(_.values(stats.total_points), (function(res, n) {\n return res + n;\n }), 0);\n completedPointsSum = _.reduce(_.values(stats.completed_points), (function(res, n) {\n return res + n;\n }), 0);\n remainingPointsSum = totalPointsSum - completedPointsSum;\n remainingTasks = stats.total_tasks - stats.completed_tasks;\n _this.scope.stats = stats;\n _this.scope.stats.totalPointsSum = totalPointsSum;\n _this.scope.stats.completedPointsSum = completedPointsSum;\n _this.scope.stats.remainingPointsSum = remainingPointsSum;\n _this.scope.stats.remainingTasks = remainingTasks;\n if (stats.totalPointsSum) {\n _this.scope.stats.completedPercentage = Math.round(100 * stats.completedPointsSum / stats.totalPointsSum);\n } else {\n _this.scope.stats.completedPercentage = 0;\n }\n _this.scope.stats.openTasks = stats.total_tasks - stats.completed_tasks;\n return stats;\n };\n })(this));\n };\n\n TaskboardController.prototype.refreshTagsColors = function() {\n return this.rs.projects.tagsColors(this.scope.projectId).then((function(_this) {\n return function(tags_colors) {\n return _this.scope.project.tags_colors = tags_colors;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadSprint = function() {\n return this.rs.sprints.get(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n _this.scope.userstories = _.sortBy(sprint.user_stories, \"sprint_order\");\n return sprint;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadTasks = function() {\n return this.rs.tasks.list(this.scope.projectId, this.scope.sprintId).then((function(_this) {\n return function(tasks) {\n var i, j, k, len, len1, len2, ref, ref1, ref2, status, task, us, usId;\n _this.scope.tasks = _.sortBy(tasks, 'taskboard_order');\n _this.scope.usTasks = {};\n ref = _.union(_this.scope.userstories, [\n {\n id: null\n }\n ]);\n for (i = 0, len = ref.length; i < len; i++) {\n us = ref[i];\n _this.scope.usTasks[us.id] = {};\n ref1 = _this.scope.taskStatusList;\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n status = ref1[j];\n _this.scope.usTasks[us.id][status.id] = [];\n }\n }\n ref2 = _this.scope.tasks;\n for (k = 0, len2 = ref2.length; k < len2; k++) {\n task = ref2[k];\n if ((_this.scope.usTasks[task.user_story] != null) && (_this.scope.usTasks[task.user_story][task.status] != null)) {\n _this.scope.usTasks[task.user_story][task.status].push(task);\n }\n }\n if (tasks.length === 0) {\n if (_this.scope.userstories.length > 0) {\n usId = _this.scope.userstories[0].id;\n } else {\n usId = null;\n }\n _this.scope.usTasks[usId][_this.scope.taskStatusList[0].id].push({\n isPlaceholder: true\n });\n }\n return tasks;\n };\n })(this));\n };\n\n TaskboardController.prototype.loadTaskboard = function() {\n return this.q.all([\n this.refreshTagsColors(), this.loadSprintStats(), this.loadSprint().then((function(_this) {\n return function() {\n return _this.loadTasks();\n };\n })(this))\n ]);\n };\n\n TaskboardController.prototype.loadInitialData = function() {\n var params, promise;\n params = {\n pslug: this.params.pslug,\n sslug: this.params.sslug\n };\n promise = this.repo.resolve(params).then((function(_this) {\n return function(data) {\n _this.scope.projectId = data.project;\n _this.scope.sprintId = data.milestone;\n _this.initializeSubscription();\n return data;\n };\n })(this));\n return promise.then((function(_this) {\n return function() {\n return _this.loadProject();\n };\n })(this)).then((function(_this) {\n return function() {\n return _this.loadTaskboard();\n };\n })(this));\n };\n\n TaskboardController.prototype.refreshTasksOrder = function(tasks) {\n var data, items;\n items = this.resortTasks(tasks);\n data = this.prepareBulkUpdateData(items);\n return this.rs.tasks.bulkUpdateTaskTaskboardOrder(this.scope.project.id, data);\n };\n\n TaskboardController.prototype.resortTasks = function(tasks) {\n var i, index, item, items, len;\n items = [];\n for (index = i = 0, len = tasks.length; i < len; index = ++i) {\n item = tasks[index];\n item[\"taskboard_order\"] = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n TaskboardController.prototype.prepareBulkUpdateData = function(uses) {\n return _.map(uses, function(x) {\n return {\n \"task_id\": x.id,\n \"order\": x[\"taskboard_order\"]\n };\n });\n };\n\n TaskboardController.prototype.taskMove = function(ctx, task, usId, statusId, order) {\n var promise, r, tasks;\n r = this.scope.usTasks[task.user_story][task.status].indexOf(task);\n this.scope.usTasks[task.user_story][task.status].splice(r, 1);\n tasks = this.scope.usTasks[usId][statusId];\n tasks.splice(order, 0, task);\n task.user_story = usId;\n task.status = statusId;\n task.taskboard_order = order;\n promise = this.repo.save(task);\n this.rootscope.$broadcast(\"sprint:task:moved\", task);\n promise.then((function(_this) {\n return function() {\n _this.refreshTasksOrder(tasks);\n return _this.loadSprintStats();\n };\n })(this));\n return promise.then(null, (function(_this) {\n return function() {\n return console.log(\"FAIL TASK SAVE\");\n };\n })(this));\n };\n\n TaskboardController.prototype.addNewTask = function(type, us) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"taskform:new\", this.scope.sprintId, us != null ? us.id : void 0);\n case \"bulk\":\n return this.rootscope.$broadcast(\"taskform:bulk\", this.scope.sprintId, us != null ? us.id : void 0);\n }\n };\n\n TaskboardController.prototype.editTaskAssignedTo = function(task) {\n return this.rootscope.$broadcast(\"assigned-to:add\", task);\n };\n\n return TaskboardController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TaskboardController\", TaskboardController);\n\n TaskboardDirective = function($rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, tableBodyDom;\n $ctrl = $el.controller();\n $el.on(\"click\", \".toggle-analytics-visibility\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.toggleClass('active');\n return $rootscope.$broadcast(\"taskboard:graph:toggle-visibility\");\n });\n tableBodyDom = $el.find(\".taskboard-table-body\");\n tableBodyDom.on(\"scroll\", function(event) {\n var tableHeaderDom, target;\n target = angular.element(event.currentTarget);\n tableHeaderDom = $el.find(\".taskboard-table-header .taskboard-table-inner\");\n return tableHeaderDom.css(\"left\", -1 * target.scrollLeft());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboard\", [\"$rootScope\", TaskboardDirective]);\n\n TaskboardTaskDirective = function($rootscope, $loading, $rs, $rs2) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $el.disableSelection();\n $scope.$watch(\"task\", function(task) {\n if (task.is_blocked && !$el.hasClass(\"blocked\")) {\n return $el.addClass(\"blocked\");\n } else if (!task.is_blocked && $el.hasClass(\"blocked\")) {\n return $el.removeClass(\"blocked\");\n }\n });\n return $el.find(\".icon-edit\").on(\"click\", function(event) {\n if ($el.find('.icon-edit').hasClass('noclick')) {\n return;\n }\n return $scope.$apply(function() {\n var currentLoading, target, task;\n target = $(event.target);\n currentLoading = $loading().target(target).timeout(200).removeClasses(\"icon-edit\").start();\n task = $scope.task;\n return $rs.tasks.getByRef(task.project, task.ref).then((function(_this) {\n return function(editingTask) {\n return $rs2.attachments.list(\"task\", editingTask.id, editingTask.project).then(function(attachments) {\n $rootscope.$broadcast(\"taskform:edit\", editingTask, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardTask\", [\"$rootScope\", \"$tgLoading\", \"$tgResources\", \"tgResources\", TaskboardTaskDirective]);\n\n TaskboardSquishColumnDirective = function(rs) {\n var avatarWidth, link, maxColumnWidth;\n avatarWidth = 40;\n maxColumnWidth = 300;\n link = function($scope, $el, $attrs) {\n var getCeilWidth, recalculateStatusColumnWidth, recalculateTaskboardWidth, refreshTaskboardTableWidth, setStatusColumnWidth;\n $scope.$on(\"sprint:task:moved\", (function(_this) {\n return function() {\n return recalculateTaskboardWidth();\n };\n })(this));\n bindOnce($scope, \"usTasks\", function(project) {\n $scope.statusesFolded = rs.tasks.getStatusColumnModes($scope.project.id);\n $scope.usFolded = rs.tasks.getUsRowModes($scope.project.id, $scope.sprintId);\n return recalculateTaskboardWidth();\n });\n $scope.foldStatus = function(status) {\n $scope.statusesFolded[status.id] = !!!$scope.statusesFolded[status.id];\n rs.tasks.storeStatusColumnModes($scope.projectId, $scope.statusesFolded);\n return recalculateTaskboardWidth();\n };\n $scope.foldUs = function(us) {\n if (!us) {\n $scope.usFolded[null] = !!!$scope.usFolded[null];\n } else {\n $scope.usFolded[us.id] = !!!$scope.usFolded[us.id];\n }\n rs.tasks.storeUsRowModes($scope.projectId, $scope.sprintId, $scope.usFolded);\n return recalculateTaskboardWidth();\n };\n getCeilWidth = (function(_this) {\n return function(usId, statusId) {\n var tasks, tasksMatrixSize, width;\n tasks = $scope.usTasks[usId][statusId].length;\n if ($scope.statusesFolded[statusId]) {\n if (tasks && $scope.usFolded[usId]) {\n tasksMatrixSize = Math.round(Math.sqrt(tasks));\n width = avatarWidth * tasksMatrixSize;\n } else {\n width = avatarWidth;\n }\n return width;\n }\n return 0;\n };\n })(this);\n setStatusColumnWidth = (function(_this) {\n return function(statusId, width) {\n var column;\n column = $el.find(\".squish-status-\" + statusId);\n if (width) {\n return column.css('max-width', width);\n } else {\n return column.css(\"max-width\", maxColumnWidth);\n }\n };\n })(this);\n refreshTaskboardTableWidth = (function(_this) {\n return function() {\n var columnWidths, columns, totalWidth;\n columnWidths = [];\n columns = $el.find(\".task-colum-name\");\n columnWidths = _.map(columns, function(column) {\n return $(column).outerWidth(true);\n });\n totalWidth = _.reduce(columnWidths, function(total, width) {\n return total + width;\n });\n return $el.find('.taskboard-table-inner').css(\"width\", totalWidth);\n };\n })(this);\n recalculateStatusColumnWidth = (function(_this) {\n return function(statusId) {\n var statusFoldedWidth;\n statusFoldedWidth = getCeilWidth(null, statusId);\n _.forEach($scope.userstories, function(us) {\n var width;\n width = getCeilWidth(us.id, statusId);\n if (width > statusFoldedWidth) {\n return statusFoldedWidth = width;\n }\n });\n return setStatusColumnWidth(statusId, statusFoldedWidth);\n };\n })(this);\n return recalculateTaskboardWidth = (function(_this) {\n return function() {\n _.forEach($scope.taskStatusList, function(status) {\n return recalculateStatusColumnWidth(status.id);\n });\n refreshTaskboardTableWidth();\n };\n })(this);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardSquishColumn\", [\"$tgResources\", TaskboardSquishColumnDirective]);\n\n TaskboardUserDirective = function($log, $translate) {\n var clickable, link;\n clickable = false;\n link = function($scope, $el, $attrs) {\n var username_label;\n username_label = $el.parent().find(\"a.task-assigned\");\n username_label.addClass(\"not-clickable\");\n $scope.$watch('task.assigned_to', function(assigned_to) {\n var user;\n user = $scope.usersById[assigned_to];\n if (user === void 0) {\n _.assign($scope, {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\",\n clickable: clickable\n });\n } else {\n _.assign($scope, {\n name: user.full_name_display,\n imgurl: user.photo,\n clickable: clickable\n });\n }\n return username_label.text($scope.name);\n });\n return bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_task\") > -1) {\n clickable = true;\n $el.find(\".avatar-assigned-to\").on(\"click\", (function(_this) {\n return function(event) {\n var $ctrl;\n if ($el.find('a').hasClass('noclick')) {\n return;\n }\n $ctrl = $el.controller();\n return $ctrl.editTaskAssignedTo($scope.task);\n };\n })(this));\n username_label.removeClass(\"not-clickable\");\n return username_label.on(\"click\", function(event) {\n var $ctrl;\n if ($el.find('a').hasClass('noclick')) {\n return;\n }\n $ctrl = $el.controller();\n return $ctrl.editTaskAssignedTo($scope.task);\n });\n }\n });\n };\n return {\n link: link,\n templateUrl: \"taskboard/taskboard-user.html\",\n scope: {\n \"usersById\": \"=users\",\n \"project\": \"=\",\n \"task\": \"=\"\n }\n };\n };\n\n module.directive(\"tgTaskboardUserAvatar\", [\"$log\", \"$translate\", TaskboardUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard/sortable.coffee\n */\n\n(function() {\n var TaskboardSortableDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n module = angular.module(\"taigaBacklog\");\n\n TaskboardSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var deleteElement, itemEl, newParentScope, oldParentScope, tdom;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el;\n deleteElement = function(itemEl) {\n itemEl.scope().$destroy();\n itemEl.off();\n return itemEl.remove();\n };\n tdom.sortable({\n handle: \".taskboard-task-inner\",\n dropOnEmpty: true,\n connectWith: \".taskboard-tasks-box\",\n revert: 400\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemTask, newStatusId, newUsId, oldStatusId, oldUsId, parentEl;\n parentEl = ui.item.parent();\n itemEl = ui.item;\n itemTask = itemEl.scope().task;\n itemIndex = itemEl.index();\n newParentScope = parentEl.scope();\n oldUsId = oldParentScope.us ? oldParentScope.us.id : null;\n oldStatusId = oldParentScope.st.id;\n newUsId = newParentScope.us ? newParentScope.us.id : null;\n newStatusId = newParentScope.st.id;\n if (newStatusId !== oldStatusId || newUsId !== oldUsId) {\n deleteElement(itemEl);\n }\n $scope.$apply(function() {\n return $rootscope.$broadcast(\"taskboard:task:move\", itemTask, newUsId, newStatusId, itemIndex);\n });\n return ui.item.find('a').removeClass('noclick');\n });\n return tdom.on(\"sortstart\", function(event, ui) {\n oldParentScope = ui.item.parent().scope();\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgTaskboardSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", TaskboardSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban/main.coffee\n */\n\n(function() {\n var KanbanArchivedStatusHeaderDirective, KanbanArchivedStatusIntroDirective, KanbanController, KanbanDirective, KanbanSquishColumnDirective, KanbanUserDirective, KanbanUserstoryDirective, KanbanWipLimitDirective, bindMethods, bindOnce, defaultViewMode, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText, viewModes,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaKanban\");\n\n defaultViewMode = \"maximized\";\n\n viewModes = [\"maximized\", \"minimized\"];\n\n KanbanController = (function(superClass) {\n extend(KanbanController, superClass);\n\n KanbanController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function KanbanController(scope, rootscope, repo, confirm, rs1, params1, q, location, appMetaService, navUrls, events, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs1;\n this.params = params1;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"KANBAN.SECTION_NAME\");\n this.scope.statusViewModes = {};\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"KANBAN.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"KANBAN.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n KanbanController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"usform:new:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n _this.refreshTagsColors();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"create userstory on kanban\", 1);\n };\n })(this));\n this.scope.$on(\"usform:bulk:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.analytics.trackEvent(\"userstory\", \"create\", \"bulk create userstory on kanban\", 1);\n };\n })(this));\n this.scope.$on(\"usform:edit:success\", (function(_this) {\n return function() {\n _this.loadUserstories();\n return _this.refreshTagsColors();\n };\n })(this));\n this.scope.$on(\"assigned-to:added\", this.onAssignedToChanged);\n this.scope.$on(\"kanban:us:move\", this.moveUs);\n this.scope.$on(\"kanban:show-userstories-for-status\", this.loadUserStoriesForStatus);\n return this.scope.$on(\"kanban:hide-userstories-for-status\", this.hideUserStoriesForStatus);\n };\n\n KanbanController.prototype.addNewUs = function(type, statusId) {\n switch (type) {\n case \"standard\":\n return this.rootscope.$broadcast(\"usform:new\", this.scope.projectId, statusId, this.scope.usStatusList);\n case \"bulk\":\n return this.rootscope.$broadcast(\"usform:bulk\", this.scope.projectId, statusId);\n }\n };\n\n KanbanController.prototype.changeUsAssignedTo = function(us) {\n return this.rootscope.$broadcast(\"assigned-to:add\", us);\n };\n\n KanbanController.prototype.onAssignedToChanged = function(ctx, userid, us) {\n var promise;\n us.assigned_to = userid;\n promise = this.repo.save(us);\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n\n KanbanController.prototype.refreshTagsColors = function() {\n return this.rs.projects.tagsColors(this.scope.projectId).then((function(_this) {\n return function(tags_colors) {\n return _this.scope.project.tags_colors = tags_colors;\n };\n })(this));\n };\n\n KanbanController.prototype.loadUserstories = function() {\n var params, promise;\n params = {\n status__is_archived: false\n };\n promise = this.rs.userstories.listAll(this.scope.projectId, params).then((function(_this) {\n return function(userstories) {\n var i, j, k, len, len1, len2, ref, ref1, ref2, status, us, usByStatus, us_archived;\n _this.scope.userstories = userstories;\n usByStatus = _.groupBy(userstories, \"status\");\n us_archived = [];\n ref = _this.scope.usStatusList;\n for (i = 0, len = ref.length; i < len; i++) {\n status = ref[i];\n if (usByStatus[status.id] == null) {\n usByStatus[status.id] = [];\n }\n if (_this.scope.usByStatus != null) {\n ref1 = _this.scope.usByStatus[status.id];\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n us = ref1[j];\n if (us.status !== status.id) {\n us_archived.push(us);\n }\n }\n }\n if (status.is_archived && (_this.scope.usByStatus != null) && _this.scope.usByStatus[status.id].length !== 0) {\n ref2 = _this.scope.usByStatus[status.id].concat(us_archived);\n for (k = 0, len2 = ref2.length; k < len2; k++) {\n us = ref2[k];\n if (us.status === status.id) {\n usByStatus[status.id].push(us);\n }\n }\n }\n usByStatus[status.id] = _.sortBy(usByStatus[status.id], \"kanban_order\");\n }\n if (userstories.length === 0) {\n status = _this.scope.usStatusList[0];\n usByStatus[status.id].push({\n isPlaceholder: true\n });\n }\n _this.scope.usByStatus = usByStatus;\n scopeDefer(_this.scope, function() {\n return _this.scope.$broadcast(\"userstories:loaded\", userstories);\n });\n return userstories;\n };\n })(this));\n promise.then((function(_this) {\n return function() {\n return _this.scope.$broadcast(\"redraw:wip\");\n };\n })(this));\n return promise;\n };\n\n KanbanController.prototype.loadUserStoriesForStatus = function(ctx, statusId) {\n var params;\n params = {\n status: statusId\n };\n return this.rs.userstories.listAll(this.scope.projectId, params).then((function(_this) {\n return function(userstories) {\n _this.scope.usByStatus[statusId] = _.sortBy(userstories, \"kanban_order\");\n _this.scope.$broadcast(\"kanban:shown-userstories-for-status\", statusId, userstories);\n return userstories;\n };\n })(this));\n };\n\n KanbanController.prototype.hideUserStoriesForStatus = function(ctx, statusId) {\n this.scope.usByStatus[statusId] = [];\n return this.scope.$broadcast(\"kanban:hidden-userstories-for-status\", statusId);\n };\n\n KanbanController.prototype.loadKanban = function() {\n return this.q.all([this.refreshTagsColors(), this.loadUserstories()]);\n };\n\n KanbanController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_kanban_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.projectId = project.id;\n _this.scope.points = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(project.points, function(x) {\n return x.id;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.generateStatusViewModes();\n _this.scope.$emit(\"project:loaded\", project);\n return project;\n };\n })(this));\n };\n\n KanbanController.prototype.initializeSubscription = function() {\n var routingKey1;\n routingKey1 = \"changes.project.\" + this.scope.projectId + \".userstories\";\n return this.events.subscribe(this.scope, routingKey1, (function(_this) {\n return function(message) {\n return _this.loadUserstories();\n };\n })(this));\n };\n\n KanbanController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.initializeSubscription();\n return _this.loadKanban();\n };\n })(this));\n };\n\n KanbanController.prototype.generateStatusViewModes = function() {\n var i, len, mode, ref, status, storedStatusViewModes;\n storedStatusViewModes = this.rs.kanban.getStatusViewModes(this.scope.projectId);\n this.scope.statusViewModes = {};\n ref = this.scope.usStatusList;\n for (i = 0, len = ref.length; i < len; i++) {\n status = ref[i];\n mode = storedStatusViewModes[status.id] || defaultViewMode;\n this.scope.statusViewModes[status.id] = mode;\n }\n return this.storeStatusViewModes();\n };\n\n KanbanController.prototype.storeStatusViewModes = function() {\n return this.rs.kanban.storeStatusViewModes(this.scope.projectId, this.scope.statusViewModes);\n };\n\n KanbanController.prototype.updateStatusViewMode = function(statusId, newViewMode) {\n this.scope.statusViewModes[statusId] = newViewMode;\n return this.storeStatusViewModes();\n };\n\n KanbanController.prototype.isMaximized = function(statusId) {\n var mode;\n mode = this.scope.statusViewModes[statusId] || defaultViewMode;\n return mode === 'maximized';\n };\n\n KanbanController.prototype.isMinimized = function(statusId) {\n var mode;\n mode = this.scope.statusViewModes[statusId] || defaultViewMode;\n return mode === 'minimized';\n };\n\n KanbanController.prototype.prepareBulkUpdateData = function(uses, field) {\n if (field == null) {\n field = \"kanban_order\";\n }\n return _.map(uses, function(x) {\n return {\n \"us_id\": x.id,\n \"order\": x[field]\n };\n });\n };\n\n KanbanController.prototype.resortUserStories = function(uses) {\n var i, index, item, items, len;\n items = [];\n for (index = i = 0, len = uses.length; i < len; index = ++i) {\n item = uses[index];\n item.kanban_order = index;\n if (item.isModified()) {\n items.push(item);\n }\n }\n return items;\n };\n\n KanbanController.prototype.moveUs = function(ctx, us, oldStatusId, newStatusId, index) {\n var itemsToSave, promise, r;\n if (oldStatusId !== newStatusId) {\n r = this.scope.usByStatus[oldStatusId].indexOf(us);\n this.scope.usByStatus[oldStatusId].splice(r, 1);\n this.scope.usByStatus[newStatusId].splice(index, 0, us);\n us.status = newStatusId;\n } else {\n r = this.scope.usByStatus[newStatusId].indexOf(us);\n this.scope.usByStatus[newStatusId].splice(r, 1);\n this.scope.usByStatus[newStatusId].splice(index, 0, us);\n }\n itemsToSave = this.resortUserStories(this.scope.usByStatus[newStatusId]);\n this.scope.usByStatus[newStatusId] = _.sortBy(this.scope.usByStatus[newStatusId], \"kanban_order\");\n promise = this.repo.save(us);\n promise = promise.then((function(_this) {\n return function() {\n var data;\n itemsToSave = _.reject(itemsToSave, {\n \"id\": us.id\n });\n data = _this.prepareBulkUpdateData(itemsToSave);\n return _this.rs.userstories.bulkUpdateKanbanOrder(us.project, data).then(function() {\n return itemsToSave;\n });\n };\n })(this));\n return promise;\n };\n\n return KanbanController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"KanbanController\", KanbanController);\n\n KanbanDirective = function($repo, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var tableBodyDom;\n tableBodyDom = $el.find(\".kanban-table-body\");\n tableBodyDom.on(\"scroll\", function(event) {\n var tableHeaderDom, target;\n target = angular.element(event.currentTarget);\n tableHeaderDom = $el.find(\".kanban-table-header .kanban-table-inner\");\n return tableHeaderDom.css(\"left\", -1 * target.scrollLeft());\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanban\", [\"$tgRepo\", \"$rootScope\", KanbanDirective]);\n\n KanbanArchivedStatusHeaderDirective = function($rootscope, $translate) {\n var hideArchivedText, link, showArchivedText;\n showArchivedText = $translate.instant(\"KANBAN.ACTION_SHOW_ARCHIVED\");\n hideArchivedText = $translate.instant(\"KANBAN.ACTION_HIDE_ARCHIVED\");\n link = function($scope, $el, $attrs) {\n var hidden, status;\n status = $scope.$eval($attrs.tgKanbanArchivedStatusHeader);\n hidden = true;\n $scope[\"class\"] = \"icon-open-eye\";\n $scope.title = showArchivedText;\n $el.on(\"click\", function(event) {\n hidden = !hidden;\n return $scope.$apply(function() {\n if (hidden) {\n $scope[\"class\"] = \"icon-open-eye\";\n $scope.title = showArchivedText;\n return $rootscope.$broadcast(\"kanban:hide-userstories-for-status\", status.id);\n } else {\n $scope[\"class\"] = \"icon-closed-eye\";\n $scope.title = hideArchivedText;\n return $rootscope.$broadcast(\"kanban:show-userstories-for-status\", status.id);\n }\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanArchivedStatusHeader\", [\"$rootScope\", \"$translate\", KanbanArchivedStatusHeaderDirective]);\n\n KanbanArchivedStatusIntroDirective = function($translate) {\n var link, userStories;\n userStories = [];\n link = function($scope, $el, $attrs) {\n var hiddenUserStoriexText, status, updateIntroText;\n hiddenUserStoriexText = $translate.instant(\"KANBAN.HIDDEN_USER_STORIES\");\n status = $scope.$eval($attrs.tgKanbanArchivedStatusIntro);\n $el.text(hiddenUserStoriexText);\n updateIntroText = function() {\n if (userStories.length > 0) {\n return $el.text(\"\");\n } else {\n return $el.text(hiddenUserStoriexText);\n }\n };\n $scope.$on(\"kanban:us:move\", function(ctx, itemUs, oldStatusId, newStatusId, itemIndex) {\n var r;\n if (status.id === newStatusId) {\n if (status.id === oldStatusId) {\n r = userStories.indexOf(itemUs);\n userStories.splice(r, 1);\n userStories.splice(itemIndex, 0, itemUs);\n } else {\n itemUs.isArchived = true;\n userStories.splice(itemIndex, 0, itemUs);\n }\n } else if (status.id === oldStatusId) {\n itemUs.isArchived = false;\n r = userStories.indexOf(itemUs);\n userStories.splice(r, 1);\n }\n return updateIntroText();\n });\n $scope.$on(\"kanban:shown-userstories-for-status\", function(ctx, statusId, userStoriesLoaded) {\n if (statusId === status.id) {\n userStories = _.filter(userStoriesLoaded, function(us) {\n return us.status === status.id;\n });\n return updateIntroText();\n }\n });\n $scope.$on(\"kanban:hidden-userstories-for-status\", function(ctx, statusId) {\n if (statusId === status.id) {\n userStories = [];\n return updateIntroText();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanArchivedStatusIntro\", [\"$translate\", KanbanArchivedStatusIntroDirective]);\n\n KanbanUserstoryDirective = function($rootscope, $loading, $rs, $rs2) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n $el.disableSelection();\n $scope.$watch(\"us\", function(us) {\n if (us.is_blocked && !$el.hasClass(\"blocked\")) {\n return $el.addClass(\"blocked\");\n } else if (!us.is_blocked && $el.hasClass(\"blocked\")) {\n return $el.removeClass(\"blocked\");\n }\n });\n $el.on('click', '.icon-edit', function(event) {\n var currentLoading, target, us;\n if ($el.find(\".icon-edit\").hasClass(\"noclick\")) {\n return;\n }\n target = $(event.target);\n currentLoading = $loading().target(target).timeout(200).removeClasses(\"icon-edit\").start();\n us = $model.$modelValue;\n return $rs.userstories.getByRef(us.project, us.ref).then((function(_this) {\n return function(editingUserStory) {\n return $rs2.attachments.list(\"us\", us.id, us.project).then(function(attachments) {\n $rootscope.$broadcast(\"usform:edit\", editingUserStory, attachments.toJS());\n return currentLoading.finish();\n });\n };\n })(this));\n });\n $scope.getTemplateUrl = function() {\n if ($scope.us.isPlaceholder) {\n return \"common/components/kanban-placeholder.html\";\n } else {\n return \"kanban/kanban-task.html\";\n }\n };\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n template: '',\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgKanbanUserstory\", [\"$rootScope\", \"$tgLoading\", \"$tgResources\", \"tgResources\", KanbanUserstoryDirective]);\n\n KanbanSquishColumnDirective = function(rs) {\n var link;\n link = function($scope, $el, $attrs) {\n var updateTableWidth;\n $scope.$on(\"project:loaded\", function(event, project) {\n $scope.folds = rs.kanban.getStatusColumnModes(project.id);\n return updateTableWidth();\n });\n $scope.foldStatus = function(status) {\n $scope.folds[status.id] = !!!$scope.folds[status.id];\n rs.kanban.storeStatusColumnModes($scope.projectId, $scope.folds);\n updateTableWidth();\n };\n return updateTableWidth = function() {\n var columnWidths, totalWidth;\n columnWidths = _.map($scope.usStatusList, function(status) {\n if ($scope.folds[status.id]) {\n return 40;\n } else {\n return 310;\n }\n });\n totalWidth = _.reduce(columnWidths, function(total, width) {\n return total + width;\n });\n return $el.find('.kanban-table-inner').css(\"width\", totalWidth);\n };\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanSquishColumn\", [\"$tgResources\", KanbanSquishColumnDirective]);\n\n KanbanWipLimitDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var redrawWipLimit, status;\n $el.disableSelection();\n status = $scope.$eval($attrs.tgKanbanWipLimit);\n redrawWipLimit = (function(_this) {\n return function() {\n $el.find(\".kanban-wip-limit\").remove();\n return timeout(200, function() {\n var element;\n element = $el.find(\".kanban-task\")[status.wip_limit];\n if (element) {\n return angular.element(element).before(\"
\");\n }\n });\n };\n })(this);\n if (status && !status.is_archived) {\n $scope.$on(\"redraw:wip\", redrawWipLimit);\n $scope.$on(\"kanban:us:move\", redrawWipLimit);\n $scope.$on(\"usform:new:success\", redrawWipLimit);\n $scope.$on(\"usform:bulk:success\", redrawWipLimit);\n }\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanWipLimit\", KanbanWipLimitDirective);\n\n KanbanUserDirective = function($log, $compile, $translate) {\n var clickable, link, template;\n template = _.template(\"
\\n class=\\\"not-clickable\\\"<% } %>>\\n \\\" alt=\\\"<%- name %>\\\" class=\\\"avatar\\\">\\n \\n
\");\n clickable = false;\n link = function($scope, $el, $attrs, $model) {\n var render, username_label, wtid;\n username_label = $el.parent().find(\"a.task-assigned\");\n username_label.addClass(\"not-clickable\");\n if (!$attrs.tgKanbanUserAvatar) {\n return $log.error(\"KanbanUserDirective: no attr is defined\");\n }\n wtid = $scope.$watch($attrs.tgKanbanUserAvatar, function(v) {\n var user;\n if ($scope.usersById == null) {\n $log.error(\"KanbanUserDirective requires userById set in scope.\");\n return wtid();\n } else {\n user = $scope.usersById[v];\n return render(user);\n }\n });\n render = function(user) {\n var ctx, html;\n if (user === void 0) {\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\",\n clickable: clickable\n };\n } else {\n ctx = {\n name: user.full_name_display,\n imgurl: user.photo,\n clickable: clickable\n };\n }\n html = $compile(template(ctx))($scope);\n $el.html(html);\n return username_label.text(ctx.name);\n };\n bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_us\") > -1) {\n clickable = true;\n $el.on(\"click\", (function(_this) {\n return function(event) {\n var $ctrl, us;\n if ($el.find(\"a\").hasClass(\"noclick\")) {\n return;\n }\n us = $model.$modelValue;\n $ctrl = $el.controller();\n return $ctrl.changeUsAssignedTo(us);\n };\n })(this));\n username_label.removeClass(\"not-clickable\");\n return username_label.on(\"click\", function(event) {\n var $ctrl, us;\n if ($el.find(\"a\").hasClass(\"noclick\")) {\n return;\n }\n us = $model.$modelValue;\n $ctrl = $el.controller();\n return $ctrl.changeUsAssignedTo(us);\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgKanbanUserAvatar\", [\"$log\", \"$compile\", \"$translate\", KanbanUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban/sortable.coffee\n */\n\n(function() {\n var KanbanSortableDirective, bindOnce, groupBy, mixOf, module, scopeDefer, taiga, timeout, toggleText;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toggleText = this.taiga.toggleText;\n\n scopeDefer = this.taiga.scopeDefer;\n\n bindOnce = this.taiga.bindOnce;\n\n groupBy = this.taiga.groupBy;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaKanban\");\n\n KanbanSortableDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n bindOnce($scope, \"project\", function(project) {\n var deleteElement, itemEl, newParentScope, oldParentScope, tdom;\n if (!(project.my_permissions.indexOf(\"modify_us\") > -1)) {\n return;\n }\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el;\n deleteElement = function(itemEl) {\n itemEl.scope().$destroy();\n itemEl.off();\n return itemEl.remove();\n };\n tdom.sortable({\n handle: \".kanban-task-inner\",\n dropOnEmpty: true,\n connectWith: \".kanban-uses-box\",\n revert: 400\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemUs, newStatusId, oldStatusId, parentEl;\n parentEl = ui.item.parent();\n itemEl = ui.item;\n itemUs = itemEl.scope().us;\n itemIndex = itemEl.index();\n newParentScope = parentEl.scope();\n newStatusId = newParentScope.s.id;\n oldStatusId = oldParentScope.s.id;\n if (newStatusId !== oldStatusId) {\n deleteElement(itemEl);\n }\n $scope.$apply(function() {\n return $rootscope.$broadcast(\"kanban:us:move\", itemUs, itemUs.status, newStatusId, itemIndex);\n });\n return ui.item.find('a').removeClass('noclick');\n });\n return tdom.on(\"sortstart\", function(event, ui) {\n oldParentScope = ui.item.parent().scope();\n return ui.item.find('a').addClass('noclick');\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgKanbanSortable\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", KanbanSortableDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/detail.coffee\n */\n\n(function() {\n var IssueDetailController, IssuePriorityButtonDirective, IssueSeverityButtonDirective, IssueStatusButtonDirective, IssueStatusDisplayDirective, IssueTypeButtonDirective, PromoteIssueToUsButtonDirective, bindMethods, bindOnce, groupBy, joinStr, mixOf, module, taiga, toString,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaIssues\");\n\n IssueDetailController = (function(superClass) {\n extend(IssueDetailController, superClass);\n\n IssueDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgAnalytics\", \"$tgNavUrls\", \"$translate\"];\n\n function IssueDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, analytics, navUrls, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.analytics = analytics;\n this.navUrls = navUrls;\n this.translate = translate;\n bindMethods(this);\n this.scope.issueRef = this.params.issueref;\n this.scope.sectionName = this.translate.instant(\"ISSUES.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n IssueDetailController.prototype._setMeta = function() {\n var description, ref, ref1, ref2, ref3, title;\n title = this.translate.instant(\"ISSUE.PAGE_TITLE\", {\n issueRef: \"#\" + this.scope.issue.ref,\n issueSubject: this.scope.issue.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"ISSUE.PAGE_DESCRIPTION\", {\n issueStatus: ((ref = this.scope.statusById[this.scope.issue.status]) != null ? ref.name : void 0) || \"--\",\n issueType: ((ref1 = this.scope.typeById[this.scope.issue.type]) != null ? ref1.name : void 0) || \"--\",\n issueSeverity: ((ref2 = this.scope.severityById[this.scope.issue.severity]) != null ? ref2.name : void 0) || \"--\",\n issuePriority: ((ref3 = this.scope.priorityById[this.scope.issue.priority]) != null ? ref3.name : void 0) || \"--\",\n issueDescription: angular.element(this.scope.issue.description_html || \"\").text()\n });\n return this.appMetaService.setAll(title, description);\n };\n\n IssueDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on issue\", 1);\n };\n })(this));\n this.scope.$on(\"promote-issue-to-us:success\", (function(_this) {\n return function() {\n _this.analytics.trackEvent(\"issue\", \"promoteToUserstory\", \"promote issue to userstory\", 1);\n _this.rootscope.$broadcast(\"object:updated\");\n return _this.loadIssue();\n };\n })(this));\n this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadIssue();\n };\n })(this));\n return this.scope.$on(\"custom-attributes-values:edit\", (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this));\n };\n\n IssueDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n if (this.scope.project.is_issues_activated) {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-issues\", ctx);\n } else {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n }\n };\n\n IssueDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.issue_statuses;\n _this.scope.statusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.typeById = groupBy(project.issue_types, function(x) {\n return x.id;\n });\n _this.scope.typeList = _.sortBy(project.issue_types, \"order\");\n _this.scope.severityList = project.severities;\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.priorityList = project.priorities;\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n IssueDetailController.prototype.loadIssue = function() {\n return this.rs.issues.getByRef(this.scope.projectId, this.params.issueref).then((function(_this) {\n return function(issue) {\n var ctx, ref, ref1;\n _this.scope.issue = issue;\n _this.scope.issueId = issue.id;\n _this.scope.commentModel = issue;\n if (((ref = _this.scope.issue.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.issue.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-issues-detail\", ctx);\n }\n if (((ref1 = _this.scope.issue.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.issue.neighbors.next.ref\n };\n return _this.scope.nextUrl = _this.navUrls.resolve(\"project-issues-detail\", ctx);\n }\n };\n })(this));\n };\n\n IssueDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadIssue();\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n IssueDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.upvote(this.scope.issueId).then(onSuccess, onError);\n };\n\n IssueDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.downvote(this.scope.issueId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n IssueDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.watch(this.scope.issueId).then(onSuccess, onError);\n };\n\n IssueDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadIssue();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.issues.unwatch(this.scope.issueId).then(onSuccess, onError);\n };\n\n return IssueDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"IssueDetailController\", IssueDetailController);\n\n IssueStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(issue) {\n var html, status;\n status = $scope.statusById[issue.status];\n html = template({\n is_closed: status.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue != null) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueStatusDisplay\", [\"$tgTemplate\", \"$compile\", IssueStatusDisplayDirective]);\n\n IssueStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issues-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, status;\n status = $scope.statusById[issue.status];\n html = template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(statusId) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.status = statusId;\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n return save(target.data(\"status-id\"));\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueStatusButtonDirective]);\n\n IssueTypeButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-type-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, type;\n type = $scope.typeById[issue.type];\n html = template({\n type: type,\n typees: $scope.typeList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(type) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.type = type;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".type-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-type\").popover().open();\n });\n $el.on(\"click\", \".type\", function(event) {\n var target, type;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n type = target.data(\"type-id\");\n return save(type);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueTypeButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueTypeButtonDirective]);\n\n IssueSeverityButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-severity-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, severity;\n severity = $scope.severityById[issue.severity];\n html = template({\n severity: severity,\n severityes: $scope.severityList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(severity) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.severity = severity;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".severity-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-severity\").popover().open();\n });\n $el.on(\"click\", \".severity\", function(event) {\n var severity, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n severity = target.data(\"severity-id\");\n return save(severity);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssueSeverityButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssueSeverityButtonDirective]);\n\n IssuePriorityButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"issue/issue-priority-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_issue\") !== -1;\n };\n render = (function(_this) {\n return function(issue) {\n var html, priority;\n priority = $scope.priorityById[issue.priority];\n html = template({\n priority: priority,\n priorityes: $scope.priorityList,\n editable: isEditable()\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(priority) {\n var currentLoading, issue, onError, onSuccess;\n $.fn.popover().closeAll();\n issue = $model.$modelValue.clone();\n issue.priority = priority;\n currentLoading = $loading().target($el.find(\".level-name\")).start();\n onSuccess = function() {\n $model.$setViewValue(issue);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n issue.revert();\n $model.$setViewValue(issue);\n return currentLoading.finish();\n };\n return $repo.save(issue).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".priority-data\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-priority\").popover().open();\n });\n $el.on(\"click\", \".priority\", function(event) {\n var priority, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n priority = target.data(\"priority-id\");\n return save(priority);\n });\n $scope.$watch($attrs.ngModel, function(issue) {\n if (issue) {\n return render(issue);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgIssuePriorityButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", IssuePriorityButtonDirective]);\n\n PromoteIssueToUsButtonDirective = function($rootScope, $repo, $confirm, $qqueue, $translate) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var save;\n save = $qqueue.bindAdd((function(_this) {\n return function(issue, askResponse) {\n var data, onError, onSuccess;\n data = {\n generated_from_issue: issue.id,\n project: issue.project,\n subject: issue.subject,\n description: issue.description,\n tags: issue.tags,\n is_blocked: issue.is_blocked,\n blocked_note: issue.blocked_note\n };\n onSuccess = function() {\n askResponse.finish();\n $confirm.notify(\"success\");\n return $rootScope.$broadcast(\"promote-issue-to-us:success\");\n };\n onError = function() {\n askResponse.finish();\n return $confirm.notify(\"error\");\n };\n return $repo.create(\"userstories\", data).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \"a\", function(event) {\n var issue, message, subtitle, title;\n event.preventDefault();\n issue = $model.$modelValue;\n title = $translate.instant(\"ISSUES.CONFIRM_PROMOTE.TITLE\");\n message = $translate.instant(\"ISSUES.CONFIRM_PROMOTE.MESSAGE\");\n subtitle = issue.subject;\n return $confirm.ask(title, subtitle, message).then((function(_this) {\n return function(response) {\n return save(issue, response);\n };\n })(this));\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n restrict: \"AE\",\n require: \"ngModel\",\n templateUrl: \"issue/promote-issue-to-us-button.html\",\n link: link\n };\n };\n\n module.directive(\"tgPromoteIssueToUsButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgQqueue\", \"$translate\", PromoteIssueToUsButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/lightboxes.coffee\n */\n\n(function() {\n var CreateBulkIssuesDirective, CreateIssueDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaIssues\");\n\n CreateIssueDirective = function($repo, $confirm, $rootscope, lightboxService, $loading, $q, attachmentsService) {\n var link;\n link = function($scope, $el, $attrs) {\n var attachmentsToAdd, createAttachments, form, resetAttachments, submit, submitButton;\n form = $el.find(\"form\").checksley();\n $scope.issue = {};\n $scope.attachments = Immutable.List();\n $scope.$on(\"issueform:new\", function(ctx, project) {\n var attachmentsToAdd;\n attachmentsToAdd = Immutable.List();\n $el.find(\".tag-input\").val(\"\");\n lightboxService.open($el);\n return $scope.issue = {\n project: project.id,\n subject: \"\",\n status: project.default_issue_status,\n type: project.default_issue_type,\n priority: project.default_priority,\n severity: project.default_severity,\n tags: []\n };\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n createAttachments = function(obj) {\n var promises;\n promises = _.map(attachmentsToAdd.toJS(), function(attachment) {\n return attachmentsService.upload(attachment.file, obj.id, $scope.issue.project, 'issue');\n });\n return $q.all(promises);\n };\n attachmentsToAdd = Immutable.List();\n resetAttachments = function() {\n return attachmentsToAdd = Immutable.List();\n };\n $scope.addAttachment = function(attachment) {\n return attachmentsToAdd = attachmentsToAdd.push(attachment);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"issues\", $scope.issue);\n promise.then(function(data) {\n return createAttachments(data);\n });\n promise.then(function(data) {\n currentLoading.finish();\n $rootscope.$broadcast(\"issueform:new:success\", data);\n lightboxService.close($el);\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateIssue\", [\"$tgRepo\", \"$tgConfirm\", \"$rootScope\", \"lightboxService\", \"$tgLoading\", \"$q\", \"tgAttachmentsService\", CreateIssueDirective]);\n\n CreateBulkIssuesDirective = function($repo, $rs, $confirm, $rootscope, $loading, lightboxService) {\n var link;\n link = function($scope, $el, attrs) {\n var submit, submitButton;\n $scope.$on(\"issueform:bulk\", function(ctx, projectId, status) {\n lightboxService.open($el);\n return $scope[\"new\"] = {\n projectId: projectId,\n bulk: \"\"\n };\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, data, form, projectId, promise;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n data = $scope[\"new\"].bulk;\n projectId = $scope[\"new\"].projectId;\n promise = $rs.issues.bulkCreate(projectId, data);\n promise.then(function(result) {\n currentLoading.finish();\n $rootscope.$broadcast(\"issueform:new:success\", result);\n lightboxService.close($el);\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateBulkIssues\", [\"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$rootScope\", \"$tgLoading\", \"lightboxService\", CreateBulkIssuesDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/list.coffee\n */\n\n(function() {\n var IssueAssignedToInlineEditionDirective, IssueStatusInlineEditionDirective, IssuesController, IssuesDirective, IssuesFiltersDirective, bindOnce, debounceLeading, groupBy, joinStr, mixOf, module, startswith, taiga, toString, trim,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounceLeading = this.taiga.debounceLeading;\n\n startswith = this.taiga.startswith;\n\n module = angular.module(\"taigaIssues\");\n\n IssuesController = (function(superClass) {\n extend(IssuesController, superClass);\n\n IssuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$tgUrls\", \"$routeParams\", \"$q\", \"$tgLocation\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgEvents\", \"$tgAnalytics\", \"$translate\"];\n\n function IssuesController(scope, rootscope, repo, confirm, rs, urls, params, q, location, appMetaService, navUrls, events, analytics, translate) {\n var filters, promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.urls = urls;\n this.params = params;\n this.q = q;\n this.location = location;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.events = events;\n this.analytics = analytics;\n this.translate = translate;\n this.loadIssues = bind(this.loadIssues, this);\n this.scope.sectionName = \"Issues\";\n this.scope.filters = {};\n if (_.isEmpty(this.location.search())) {\n filters = this.rs.issues.getFilters(this.params.pslug);\n filters.page = 1;\n this.location.search(filters);\n this.location.replace();\n return;\n }\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ISSUES.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"ISSUES.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"issueform:new:success\", (function(_this) {\n return function() {\n _this.analytics.trackEvent(\"issue\", \"create\", \"create issue on issues list\", 1);\n return _this.loadIssues();\n };\n })(this));\n }\n\n IssuesController.prototype.initializeSubscription = function() {\n var routingKey;\n routingKey = \"changes.project.\" + this.scope.projectId + \".issues\";\n return this.events.subscribe(this.scope, routingKey, (function(_this) {\n return function(message) {\n return _this.loadIssues();\n };\n })(this));\n };\n\n IssuesController.prototype.storeFilters = function() {\n return this.rs.issues.storeFilters(this.params.pslug, this.location.search());\n };\n\n IssuesController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_issues_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issueStatusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.issueStatusList = _.sortBy(project.issue_statuses, \"order\");\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.severityList = _.sortBy(project.severities, \"order\");\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n _this.scope.priorityList = _.sortBy(project.priorities, \"order\");\n _this.scope.issueTypes = _.sortBy(project.issue_types, \"order\");\n _this.scope.issueTypeById = groupBy(project.issue_types, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n IssuesController.prototype.getUrlFilters = function() {\n var filters;\n filters = _.pick(this.location.search(), \"page\", \"tags\", \"status\", \"types\", \"q\", \"severities\", \"priorities\", \"assignedTo\", \"createdBy\", \"orderBy\");\n if (!filters.page) {\n filters.page = 1;\n }\n return filters;\n };\n\n IssuesController.prototype.getUrlFilter = function(name) {\n var filters;\n filters = _.pick(this.location.search(), name);\n return filters[name];\n };\n\n IssuesController.prototype.loadMyFilters = function() {\n return this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n return _.map(filters, function(value, key) {\n return {\n id: key,\n name: key,\n type: \"myFilters\",\n selected: false\n };\n });\n };\n })(this));\n };\n\n IssuesController.prototype.removeNotExistingFiltersFromUrl = function() {\n var currentSearch, existingValues, filterName, filterValue, splittedValues, urlfilters;\n currentSearch = this.location.search();\n urlfilters = this.getUrlFilters();\n for (filterName in urlfilters) {\n filterValue = urlfilters[filterName];\n if (filterName === \"page\" || filterName === \"orderBy\" || filterName === \"q\") {\n continue;\n }\n if (filterName === \"tags\") {\n splittedValues = _.map((\"\" + filterValue).split(\",\"));\n } else {\n splittedValues = _.map((\"\" + filterValue).split(\",\"), function(x) {\n if (x === \"null\") {\n return null;\n } else {\n return parseInt(x);\n }\n });\n }\n existingValues = _.intersection(splittedValues, _.map(this.scope.filters[filterName], \"id\"));\n if (splittedValues.length !== existingValues.length) {\n this.location.search(filterName, existingValues.join());\n }\n }\n if (currentSearch !== this.location.search()) {\n return this.location.replace();\n }\n };\n\n IssuesController.prototype.markSelectedFilters = function(filters, urlfilters) {\n var isSelected, j, key, len, name, obj, ref, ref1, results, searchdata, val, value;\n searchdata = {};\n ref = _.omit(urlfilters, \"page\", \"orderBy\");\n for (name in ref) {\n value = ref[name];\n if (searchdata[name] == null) {\n searchdata[name] = {};\n }\n ref1 = (\"\" + value).split(\",\");\n for (j = 0, len = ref1.length; j < len; j++) {\n val = ref1[j];\n searchdata[name][val] = true;\n }\n }\n isSelected = function(type, id) {\n if ((searchdata[type] != null) && searchdata[type][id]) {\n return true;\n }\n return false;\n };\n results = [];\n for (key in filters) {\n value = filters[key];\n results.push((function() {\n var k, len1, results1;\n results1 = [];\n for (k = 0, len1 = value.length; k < len1; k++) {\n obj = value[k];\n results1.push(obj.selected = isSelected(obj.type, obj.id) ? true : void 0);\n }\n return results1;\n })());\n }\n return results;\n };\n\n IssuesController.prototype.loadFilters = function() {\n var loadFilters, promise, urlfilters;\n urlfilters = this.getUrlFilters();\n if (urlfilters.q) {\n this.scope.filtersQ = urlfilters.q;\n }\n promise = this.loadMyFilters().then((function(_this) {\n return function(myFilters) {\n _this.scope.filters.myFilters = myFilters;\n return myFilters;\n };\n })(this));\n loadFilters = {};\n loadFilters.project = this.scope.projectId;\n loadFilters.tags = urlfilters.tags;\n loadFilters.status = urlfilters.status;\n loadFilters.q = urlfilters.q;\n loadFilters.types = urlfilters.types;\n loadFilters.severities = urlfilters.severities;\n loadFilters.priorities = urlfilters.priorities;\n loadFilters.assigned_to = urlfilters.assignedTo;\n loadFilters.owner = urlfilters.createdBy;\n promise = promise.then((function(_this) {\n return function() {\n return _this.rs.issues.filtersData(loadFilters);\n };\n })(this));\n return promise.then((function(_this) {\n return function(data) {\n var choicesFiltersFormat, tagsFilterFormat, usersFiltersFormat;\n usersFiltersFormat = function(users, type, unknownOption) {\n var reformatedUsers, unknownItem;\n reformatedUsers = _.map(users, function(t) {\n t.type = type;\n t.name = t.full_name ? t.full_name : unknownOption;\n return t;\n });\n unknownItem = _.remove(reformatedUsers, function(u) {\n return !u.id;\n });\n reformatedUsers = _.sortBy(reformatedUsers, function(u) {\n return u.name.toUpperCase();\n });\n if (unknownItem.length > 0) {\n reformatedUsers.unshift(unknownItem[0]);\n }\n return reformatedUsers;\n };\n choicesFiltersFormat = function(choices, type, byIdObject) {\n return _.map(choices, function(t) {\n t.type = type;\n return t;\n });\n };\n tagsFilterFormat = function(tags) {\n return _.map(tags, function(t) {\n t.id = t.name;\n t.type = 'tags';\n return t;\n });\n };\n _this.scope.filters.status = choicesFiltersFormat(data.statuses, \"status\", _this.scope.issueStatusById);\n _this.scope.filters.severities = choicesFiltersFormat(data.severities, \"severities\", _this.scope.severityById);\n _this.scope.filters.priorities = choicesFiltersFormat(data.priorities, \"priorities\", _this.scope.priorityById);\n _this.scope.filters.assignedTo = usersFiltersFormat(data.assigned_to, \"assignedTo\", \"Unassigned\");\n _this.scope.filters.createdBy = usersFiltersFormat(data.owners, \"createdBy\", \"Unknown\");\n _this.scope.filters.types = choicesFiltersFormat(data.types, \"types\", _this.scope.issueTypeById);\n _this.scope.filters.tags = tagsFilterFormat(data.tags);\n _this.removeNotExistingFiltersFromUrl();\n _this.markSelectedFilters(_this.scope.filters, urlfilters);\n return _this.rootscope.$broadcast(\"filters:loaded\", _this.scope.filters);\n };\n })(this));\n };\n\n IssuesController.prototype.loadIssuesRequests = 0;\n\n IssuesController.prototype.loadIssues = function() {\n var name, promise, ref, values;\n this.scope.urlFilters = this.getUrlFilters();\n this.scope.httpParams = {};\n ref = this.scope.urlFilters;\n for (name in ref) {\n values = ref[name];\n if (name === \"severities\") {\n name = \"severity\";\n } else if (name === \"orderBy\") {\n name = \"order_by\";\n } else if (name === \"priorities\") {\n name = \"priority\";\n } else if (name === \"assignedTo\") {\n name = \"assigned_to\";\n } else if (name === \"createdBy\") {\n name = \"owner\";\n } else if (name === \"status\") {\n name = \"status\";\n } else if (name === \"types\") {\n name = \"type\";\n }\n this.scope.httpParams[name] = values;\n }\n promise = this.rs.issues.list(this.scope.projectId, this.scope.httpParams);\n this.loadIssuesRequests += 1;\n promise.index = this.loadIssuesRequests;\n promise.then((function(_this) {\n return function(data) {\n if (promise.index === _this.loadIssuesRequests) {\n _this.scope.issues = data.models;\n _this.scope.page = data.current;\n _this.scope.count = data.count;\n _this.scope.paginatedBy = data.paginatedBy;\n }\n return data;\n };\n })(this));\n return promise;\n };\n\n IssuesController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.initializeSubscription();\n _this.loadFilters();\n return _this.loadIssues();\n };\n })(this));\n };\n\n IssuesController.prototype.saveCurrentFiltersTo = function(newFilter) {\n var deferred;\n deferred = this.q.defer();\n this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n filters[newFilter] = _this.location.search();\n return _this.rs.issues.storeMyFilters(_this.scope.projectId, filters).then(function() {\n return deferred.resolve();\n });\n };\n })(this));\n return deferred.promise;\n };\n\n IssuesController.prototype.deleteMyFilter = function(filter) {\n var deferred;\n deferred = this.q.defer();\n this.rs.issues.getMyFilters(this.scope.projectId).then((function(_this) {\n return function(filters) {\n delete filters[filter];\n return _this.rs.issues.storeMyFilters(_this.scope.projectId, filters).then(function() {\n return deferred.resolve();\n });\n };\n })(this));\n return deferred.promise;\n };\n\n IssuesController.prototype.addNewIssue = function() {\n return this.rootscope.$broadcast(\"issueform:new\", this.scope.project);\n };\n\n IssuesController.prototype.addIssuesInBulk = function() {\n return this.rootscope.$broadcast(\"issueform:bulk\", this.scope.projectId);\n };\n\n return IssuesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"IssuesController\", IssuesController);\n\n IssuesDirective = function($log, $location, $template, $compile) {\n var link, linkOrdering, linkPagination, template;\n template = $template.get(\"issue/issue-paginator.html\", true);\n linkPagination = function($scope, $el, $attrs, $ctrl) {\n var $pagEl, afterCurrent, atBegin, atEnd, beforeCurrent, getNumPages, renderPagination;\n afterCurrent = 2;\n beforeCurrent = 4;\n atBegin = 2;\n atEnd = 2;\n $pagEl = $el.find(\".issues-paginator\");\n getNumPages = function() {\n var numPages;\n numPages = $scope.count / $scope.paginatedBy;\n if (parseInt(numPages, 10) < numPages) {\n numPages = parseInt(numPages, 10) + 1;\n } else {\n numPages = parseInt(numPages, 10);\n }\n return numPages;\n };\n renderPagination = function() {\n var cpage, html, i, j, numPages, options, pages, ref;\n numPages = getNumPages();\n if (numPages <= 1) {\n $pagEl.hide();\n return;\n }\n $pagEl.show();\n pages = [];\n options = {};\n options.pages = pages;\n options.showPrevious = $scope.page > 1;\n options.showNext = !($scope.page === numPages);\n cpage = $scope.page;\n for (i = j = 1, ref = numPages; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\n if (i === (cpage + afterCurrent) && numPages > (cpage + afterCurrent + atEnd)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i === (cpage - beforeCurrent) && cpage > (atBegin + beforeCurrent)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i > (cpage + afterCurrent) && i <= (numPages - atEnd)) {\n\n } else if (i < (cpage - beforeCurrent) && i > atBegin) {\n\n } else if (i === cpage) {\n pages.push({\n classes: \"active\",\n num: i,\n type: \"page-active\"\n });\n } else {\n pages.push({\n classes: \"page\",\n num: i,\n type: \"page\"\n });\n }\n }\n html = template(options);\n html = $compile(html)($scope);\n return $pagEl.html(html);\n };\n $scope.$watch(\"issues\", function(value) {\n if (!value) {\n return;\n }\n return renderPagination();\n });\n $el.on(\"click\", \".issues-paginator a.next\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page + 1);\n return $ctrl.loadIssues();\n });\n });\n $el.on(\"click\", \".issues-paginator a.previous\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n return $ctrl.loadIssues();\n });\n });\n return $el.on(\"click\", \".issues-paginator li.page > a\", function(event) {\n var pagenum, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n pagenum = target.data(\"pagenum\");\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", pagenum);\n return $ctrl.loadIssues();\n });\n });\n };\n linkOrdering = function($scope, $el, $attrs, $ctrl) {\n var colHeadElement, currentOrder, icon;\n currentOrder = $ctrl.getUrlFilter(\"orderBy\") || \"created_date\";\n if (currentOrder) {\n icon = startswith(currentOrder, \"-\") ? \"icon-arrow-up\" : \"icon-arrow-bottom\";\n colHeadElement = $el.find(\".row.title > div[data-fieldname='\" + (trim(currentOrder, \"-\")) + \"']\");\n colHeadElement.html((colHeadElement.html()) + \"\");\n }\n return $el.on(\"click\", \".row.title > div\", function(event) {\n var finalOrder, newOrder, target;\n target = angular.element(event.currentTarget);\n currentOrder = $ctrl.getUrlFilter(\"orderBy\");\n newOrder = target.data(\"fieldname\");\n finalOrder = currentOrder === newOrder ? \"-\" + newOrder : newOrder;\n return $scope.$apply(function() {\n $ctrl.replaceFilter(\"orderBy\", finalOrder);\n $ctrl.storeFilters();\n return $ctrl.loadIssues().then(function() {\n $el.find(\".row.title > div > span.icon\").remove();\n icon = startswith(finalOrder, \"-\") ? \"icon-arrow-up\" : \"icon-arrow-bottom\";\n return target.html((target.html()) + \"\");\n });\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n linkOrdering($scope, $el, $attrs, $ctrl);\n linkPagination($scope, $el, $attrs, $ctrl);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssues\", [\"$log\", \"$tgLocation\", \"$tgTemplate\", \"$compile\", IssuesDirective]);\n\n IssuesFiltersDirective = function($q, $log, $location, $rs, $confirm, $loading, $template, $translate, $compile, $auth) {\n var link, template, templateSelected;\n template = $template.get(\"issue/issues-filters.html\", true);\n templateSelected = $template.get(\"issue/issues-filters-selected.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, getFiltersType, initializeSelectedFilters, reloadIssues, renderFilters, renderSelectedFilters, selectQFilter, selectedFilters, showCategories, showFilters, toggleFilterSelection, unwatchIssues;\n $ctrl = $el.closest(\".wrapper\").controller();\n selectedFilters = [];\n showFilters = function(title, type) {\n $el.find(\".filters-cats\").hide();\n $el.find(\".filter-list\").removeClass(\"hidden\");\n $el.find(\"h2.breadcrumb\").removeClass(\"hidden\");\n $el.find(\"h2 a.subfilter span.title\").html(title);\n return $el.find(\"h2 a.subfilter span.title\").prop(\"data-type\", type);\n };\n showCategories = function() {\n $el.find(\".filters-cats\").show();\n $el.find(\".filter-list\").addClass(\"hidden\");\n return $el.find(\"h2.breadcrumb\").addClass(\"hidden\");\n };\n initializeSelectedFilters = function(filters) {\n var j, len, name, val, values;\n selectedFilters = [];\n for (name in filters) {\n values = filters[name];\n for (j = 0, len = values.length; j < len; j++) {\n val = values[j];\n if (val.selected) {\n selectedFilters.push(val);\n }\n }\n }\n return renderSelectedFilters(selectedFilters);\n };\n renderSelectedFilters = function(selectedFilters) {\n var html;\n _.filter(selectedFilters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = templateSelected({\n filters: selectedFilters\n });\n html = $compile(html)($scope);\n $el.find(\".filters-applied\").html(html);\n if ($auth.isAuthenticated() && selectedFilters.length > 0) {\n return $el.find(\".save-filters\").show();\n } else {\n return $el.find(\".save-filters\").hide();\n }\n };\n renderFilters = function(filters) {\n var html;\n _.filter(filters, (function(_this) {\n return function(f) {\n if (f.color) {\n return f.style = \"border-left: 3px solid \" + f.color;\n }\n };\n })(this));\n html = template({\n filters: filters\n });\n html = $compile(html)($scope);\n return $el.find(\".filter-list\").html(html);\n };\n getFiltersType = function() {\n return $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n };\n reloadIssues = function() {\n var currentFiltersType;\n currentFiltersType = getFiltersType();\n return $q.all([$ctrl.loadIssues(), $ctrl.loadFilters()]).then(function() {\n var filters;\n filters = $scope.filters[currentFiltersType];\n return renderFilters(_.reject(filters, \"selected\"));\n });\n };\n toggleFilterSelection = function(type, id) {\n var currentFiltersType, filter, filterId, filters;\n if (type === \"myFilters\") {\n $rs.issues.getMyFilters($scope.projectId).then(function(data) {\n var filters, myFilters;\n myFilters = data;\n filters = myFilters[id];\n filters.page = 1;\n $ctrl.replaceAllFilters(filters);\n $ctrl.storeFilters();\n $ctrl.loadIssues();\n $ctrl.markSelectedFilters($scope.filters, filters);\n return initializeSelectedFilters($scope.filters);\n });\n return null;\n }\n filters = $scope.filters[type];\n filterId = type === 'tags' ? taiga.toString(id) : id;\n filter = _.find(filters, {\n id: filterId\n });\n filter.selected = !filter.selected;\n if (id === null) {\n id = \"null\";\n }\n if (filter.selected) {\n selectedFilters.push(filter);\n $ctrl.selectFilter(type, id);\n $ctrl.selectFilter(\"page\", 1);\n $ctrl.storeFilters();\n } else {\n selectedFilters = _.reject(selectedFilters, function(f) {\n return f.id === filter.id && f.type === filter.type;\n });\n $ctrl.unselectFilter(type, id);\n $ctrl.selectFilter(\"page\", 1);\n $ctrl.storeFilters();\n }\n reloadIssues();\n renderSelectedFilters(selectedFilters);\n currentFiltersType = getFiltersType();\n if (type === currentFiltersType) {\n return renderFilters(_.reject(filters, \"selected\"));\n }\n };\n $scope.$on(\"filters:loaded\", function(ctx, filters) {\n return initializeSelectedFilters(filters);\n });\n $scope.$on(\"filters:issueupdate\", function(ctx, filters) {\n var html;\n html = template({\n filters: filters.status\n });\n html = $compile(html)($scope);\n return $el.find(\".filter-list\").html(html);\n });\n selectQFilter = debounceLeading(100, function(value, oldValue) {\n if (value === void 0 || value === oldValue) {\n return;\n }\n $ctrl.replaceFilter(\"page\", null, true);\n if (value.length === 0) {\n $ctrl.replaceFilter(\"q\", null);\n $ctrl.storeFilters();\n } else {\n $ctrl.replaceFilter(\"q\", value);\n $ctrl.storeFilters();\n }\n return reloadIssues();\n });\n unwatchIssues = $scope.$watch(\"issues\", function(newValue) {\n if (!_.isUndefined(newValue)) {\n $scope.$watch(\"filtersQ\", selectQFilter);\n return unwatchIssues();\n }\n });\n $el.on(\"click\", \".filters-cats > ul > li > a\", function(event) {\n var tags, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n tags = $scope.filters[target.data(\"type\")];\n renderFilters(_.reject(tags, \"selected\"));\n return showFilters(target.attr(\"title\"), target.data(\"type\"));\n });\n $el.on(\"click\", \".filters-inner > .filters-step-cat > .breadcrumb > .back\", function(event) {\n event.preventDefault();\n return showCategories($el);\n });\n $el.on(\"click\", \".filters-applied a\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n id = target.data(\"id\") || null;\n type = target.data(\"type\");\n return toggleFilterSelection(type, id);\n });\n $el.on(\"click\", \".filter-list .single-filter\", function(event) {\n var id, target, type;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n target.toggleClass(\"active\");\n id = target.data(\"id\") || null;\n type = target.data(\"type\");\n if (type === \"myFilters\") {\n target.removeClass(\"active\");\n }\n return toggleFilterSelection(type, id);\n });\n $el.on(\"click\", \".filter-list .single-filter .icon-delete\", function(event) {\n var customFilterName, message, target, title;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n customFilterName = target.parent().data('id');\n title = $translate.instant(\"ISSUES.FILTERS.CONFIRM_DELETE.TITLE\");\n message = $translate.instant(\"ISSUES.FILTERS.CONFIRM_DELETE.MESSAGE\", {\n customFilterName: customFilterName\n });\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var promise;\n promise = $ctrl.deleteMyFilter(customFilterName);\n promise.then(function() {\n promise = $ctrl.loadMyFilters();\n promise.then(function(filters) {\n askResponse.finish();\n $scope.filters.myFilters = filters;\n return renderFilters($scope.filters.myFilters);\n });\n return promise.then(null, function() {\n return askResponse.finish();\n });\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n });\n });\n $el.on(\"click\", \".save-filters\", function(event) {\n event.preventDefault();\n renderFilters($scope.filters[\"myFilters\"]);\n showFilters(\"My filters\", \"myFilters\");\n $el.find('.save-filters').hide();\n $el.find('.my-filter-name').removeClass(\"hidden\");\n $el.find('.my-filter-name').focus();\n return $scope.$apply();\n });\n return $el.on(\"keyup\", \".my-filter-name\", function(event) {\n var currentLoading, newFilter, promise, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newFilter = target.val();\n currentLoading = $loading().target($el.find(\".new\")).start();\n promise = $ctrl.saveCurrentFiltersTo(newFilter);\n promise.then(function() {\n var loadPromise;\n loadPromise = $ctrl.loadMyFilters();\n loadPromise.then(function(filters) {\n var currentfilterstype;\n currentLoading.finish();\n $scope.filters.myFilters = filters;\n currentfilterstype = $el.find(\"h2 a.subfilter span.title\").prop('data-type');\n if (currentfilterstype === \"myFilters\") {\n renderFilters($scope.filters.myFilters);\n }\n $el.find('.my-filter-name').addClass(\"hidden\");\n return $el.find('.save-filters').show();\n });\n return loadPromise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\", \"Error loading custom filters\");\n });\n });\n return promise.then(null, function() {\n currentLoading.finish();\n $el.find(\".my-filter-name\").val(newFilter).focus().select();\n return $confirm.notify(\"error\", \"Filter not saved\");\n });\n } else if (event.keyCode === 27) {\n $el.find('.my-filter-name').val('');\n $el.find('.my-filter-name').addClass(\"hidden\");\n return $el.find('.save-filters').show();\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssuesFilters\", [\"$q\", \"$log\", \"$tgLocation\", \"$tgResources\", \"$tgConfirm\", \"$tgLoading\", \"$tgTemplate\", \"$translate\", \"$compile\", \"$tgAuth\", IssuesFiltersDirective]);\n\n IssueStatusInlineEditionDirective = function($repo, $template, $rootscope) {\n\n /*\n Print the status of an Issue and a popover to change it.\n - tg-issue-status-inline-edition: The issue\n \n Example:\n \n div.status(tg-issue-status-inline-edition=\"issue\")\n a.issue-status(href=\"\")\n \n NOTE: This directive need 'issueStatusById' and 'project'.\n */\n var link, selectionTemplate, updateIssueStatus;\n selectionTemplate = $template.get(\"issue/issue-status-inline-edition-selection.html\", true);\n updateIssueStatus = function($el, issue, issueStatusById) {\n var issueStatusDom, issueStatusDomParent, status;\n issueStatusDomParent = $el.find(\".issue-status\");\n issueStatusDom = $el.find(\".issue-status .issue-status-bind\");\n status = issueStatusById[issue.status];\n if (status) {\n issueStatusDom.text(status.name);\n issueStatusDom.prop(\"title\", status.name);\n return issueStatusDomParent.css('color', status.color);\n }\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, issue;\n $ctrl = $el.controller();\n issue = $scope.$eval($attrs.tgIssueStatusInlineEdition);\n $el.on(\"click\", \".issue-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var filter, j, len, ref, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n ref = $scope.filters.status;\n for (j = 0, len = ref.length; j < len; j++) {\n filter = ref[j];\n if (filter.id === issue.status) {\n filter.count--;\n }\n }\n issue.status = target.data(\"status-id\");\n $el.find(\".pop-status\").popover().close();\n updateIssueStatus($el, issue, $scope.issueStatusById);\n return $scope.$apply(function() {\n var k, len1, ref1;\n $repo.save(issue).then(function() {\n return $ctrl.loadIssues();\n });\n ref1 = $scope.filters.status;\n for (k = 0, len1 = ref1.length; k < len1; k++) {\n filter = ref1[k];\n if (filter.id === issue.status) {\n filter.count++;\n }\n }\n return $rootscope.$broadcast(\"filters:issueupdate\", $scope.filters);\n });\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n $el.append(selectionTemplate({\n 'statuses': project.issue_statuses\n }));\n updateIssueStatus($el, issue, $scope.issueStatusById);\n if (project.my_permissions.indexOf(\"modify_issue\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$watch($attrs.tgIssueStatusInlineEdition, (function(_this) {\n return function(val) {\n return updateIssueStatus($el, val, $scope.issueStatusById);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssueStatusInlineEdition\", [\"$tgRepo\", \"$tgTemplate\", \"$rootScope\", IssueStatusInlineEditionDirective]);\n\n IssueAssignedToInlineEditionDirective = function($repo, $rootscope, $translate) {\n var link, template;\n template = _.template(\"\\\" alt=\\\"<%- name %>\\\"/>\\n
<%- name %>
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, issue, updateIssue;\n updateIssue = function(issue) {\n var ctx, member;\n ctx = {\n name: $translate.instant(\"COMMON.ASSIGNED_TO.NOT_ASSIGNED\"),\n imgurl: \"/\" + window._version + \"/images/unnamed.png\"\n };\n member = $scope.usersById[issue.assigned_to];\n if (member) {\n ctx.name = member.full_name_display;\n ctx.imgurl = member.photo;\n }\n $el.find(\".avatar\").html(template(ctx));\n return $el.find(\".issue-assignedto\").attr('title', ctx.name);\n };\n $ctrl = $el.controller();\n issue = $scope.$eval($attrs.tgIssueAssignedToInlineEdition);\n updateIssue(issue);\n $el.on(\"click\", \".issue-assignedto\", function(event) {\n return $rootscope.$broadcast(\"assigned-to:add\", issue);\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_issue\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"assigned-to:added\", (function(_this) {\n return function(ctx, userId, updatedIssue) {\n if (updatedIssue.id === issue.id) {\n updatedIssue.assigned_to = userId;\n $repo.save(updatedIssue);\n return updateIssue(updatedIssue);\n }\n };\n })(this));\n $scope.$watch($attrs.tgIssueAssignedToInlineEdition, (function(_this) {\n return function(val) {\n return updateIssue(val);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgIssueAssignedToInlineEdition\", [\"$tgRepo\", \"$rootScope\", \"$translate\", IssueAssignedToInlineEditionDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/userstories/detail.coffee\n */\n\n(function() {\n var UsClientRequirementButtonDirective, UsStatusButtonDirective, UsStatusDisplayDirective, UsTeamRequirementButtonDirective, UserStoryDetailController, bindMethods, bindOnce, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaUserStories\");\n\n UserStoryDetailController = (function(superClass) {\n extend(UserStoryDetailController, superClass);\n\n UserStoryDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function UserStoryDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.usRef = this.params.usref;\n this.scope.sectionName = this.translate.instant(\"US.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserStoryDetailController.prototype._setMeta = function() {\n var closedTasks, description, progressPercentage, ref, title, totalTasks;\n totalTasks = this.scope.tasks.length;\n closedTasks = _.filter(this.scope.tasks, (function(_this) {\n return function(t) {\n return _this.scope.taskStatusById[t.status].is_closed;\n };\n })(this)).length;\n progressPercentage = totalTasks > 0 ? Math.round(100 * closedTasks / totalTasks) : 0;\n title = this.translate.instant(\"US.PAGE_TITLE\", {\n userStoryRef: \"#\" + this.scope.us.ref,\n userStorySubject: this.scope.us.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"US.PAGE_DESCRIPTION\", {\n userStoryStatus: ((ref = this.scope.statusById[this.scope.us.status]) != null ? ref.name : void 0) || \"--\",\n userStoryPoints: this.scope.us.total_points,\n userStoryDescription: angular.element(this.scope.us.description_html || \"\").text(),\n userStoryClosedTasks: closedTasks,\n userStoryTotalTasks: totalTasks,\n userStoryProgressPercentage: progressPercentage\n });\n return this.appMetaService.setAll(title, description);\n };\n\n UserStoryDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"related-tasks:update\", (function(_this) {\n return function() {\n return _this.scope.tasks = _.clone(_this.scope.tasks, false);\n };\n })(this));\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on userstory\", 1);\n };\n })(this));\n return this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadUs();\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n if (this.scope.project.is_backlog_activated) {\n if (this.scope.us.milestone) {\n ctx.sprint = this.scope.sprint.slug;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-taskboard\", ctx);\n } else {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-backlog\", ctx);\n }\n } else if (this.scope.project.is_kanban_activated) {\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-kanban\", ctx);\n }\n };\n\n UserStoryDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.us_statuses;\n _this.scope.statusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n _this.scope.taskStatusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.pointsById = groupBy(_this.scope.pointsList, function(e) {\n return e.id;\n });\n return project;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadUs = function() {\n var httpParams, kanbanStaus, milestone, noMilestone;\n httpParams = _.pick(this.location.search(), \"milestone\", \"no-milestone\", \"kanban-status\");\n milestone = httpParams.milestone;\n if (milestone) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n milestone: milestone,\n order_by: \"sprint_order\"\n });\n }\n noMilestone = httpParams[\"no-milestone\"];\n if (noMilestone) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n milestone: \"null\",\n order_by: \"backlog_order\"\n });\n }\n kanbanStaus = httpParams[\"kanban-status\"];\n if (kanbanStaus) {\n this.rs.userstories.storeQueryParams(this.scope.projectId, {\n status: kanbanStaus,\n order_by: \"kanban_order\"\n });\n }\n return this.rs.userstories.getByRef(this.scope.projectId, this.params.usref).then((function(_this) {\n return function(us) {\n var ctx, ref, ref1;\n _this.scope.us = us;\n _this.scope.usId = us.id;\n _this.scope.commentModel = us;\n if (((ref = _this.scope.us.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.us.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n if (((ref1 = _this.scope.us.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.us.neighbors.next.ref\n };\n _this.scope.nextUrl = _this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n return us;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadSprint = function() {\n if (this.scope.us.milestone) {\n return this.rs.sprints.get(this.scope.us.project, this.scope.us.milestone).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n return sprint;\n };\n })(this));\n }\n };\n\n UserStoryDetailController.prototype.loadTasks = function() {\n return this.rs.tasks.list(this.scope.projectId, null, this.scope.usId).then((function(_this) {\n return function(tasks) {\n _this.scope.tasks = tasks;\n return tasks;\n };\n })(this));\n };\n\n UserStoryDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadUs().then(function() {\n return _this.q.all([_this.loadSprint(), _this.loadTasks()]);\n });\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n UserStoryDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.upvote(this.scope.usId).then(onSuccess, onError);\n };\n\n UserStoryDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.downvote(this.scope.usId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n UserStoryDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.watch(this.scope.usId).then(onSuccess, onError);\n };\n\n UserStoryDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadUs();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.userstories.unwatch(this.scope.usId).then(onSuccess, onError);\n };\n\n return UserStoryDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserStoryDetailController\", UserStoryDetailController);\n\n UsStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(us) {\n var html, status;\n status = $scope.statusById[us.status];\n html = template({\n is_closed: us.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(us) {\n if (us != null) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsStatusDisplay\", [\"$tgTemplate\", \"$compile\", UsStatusDisplayDirective]);\n\n UsStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $template) {\n var link, template;\n template = $template.get(\"us/us-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = (function(_this) {\n return function(us) {\n var html, status;\n status = $scope.statusById[us.status];\n html = template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n });\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(status) {\n var currentLoading, onError, onSuccess, us;\n us = $model.$modelValue.clone();\n us.status = status;\n $.fn.popover().closeAll();\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(us);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n return currentLoading.finish();\n };\n return $repo.save(us).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var status, target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n status = target.data(\"status-id\");\n return save(status);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", UsStatusButtonDirective]);\n\n UsTeamRequirementButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"us/us-team-requirement-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var canEdit, render, save;\n canEdit = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = function(us) {\n var ctx, html;\n ctx = {\n canEdit: canEdit(),\n isRequired: us.team_requirement\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(team_requirement) {\n var currentLoading, promise, us;\n us = $model.$modelValue.clone();\n us.team_requirement = team_requirement;\n currentLoading = $loading().target($el.find(\"label\")).start();\n promise = $tgrepo.save(us);\n promise.then(function() {\n $model.$setViewValue(us);\n currentLoading.finish();\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n currentLoading.finish();\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n $el.on(\"click\", \".team-requirement\", function(event) {\n var team_requirement;\n if (!canEdit()) {\n return;\n }\n team_requirement = !$model.$modelValue.team_requirement;\n return save(team_requirement);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsTeamRequirementButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsTeamRequirementButtonDirective]);\n\n UsClientRequirementButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) {\n var link, template;\n template = $template.get(\"us/us-client-requirement-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var canEdit, render, save;\n canEdit = function() {\n return $scope.project.my_permissions.indexOf(\"modify_us\") !== -1;\n };\n render = function(us) {\n var ctx, html;\n ctx = {\n canEdit: canEdit(),\n isRequired: us.client_requirement\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(client_requirement) {\n var currentLoading, promise, us;\n us = $model.$modelValue.clone();\n us.client_requirement = client_requirement;\n currentLoading = $loading().target($el.find(\"label\")).start();\n promise = $tgrepo.save(us);\n promise.then(function() {\n $model.$setViewValue(us);\n currentLoading.finish();\n return $rootscope.$broadcast(\"object:updated\");\n });\n return promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n $el.on(\"click\", \".client-requirement\", function(event) {\n var client_requirement;\n if (!canEdit()) {\n return;\n }\n client_requirement = !$model.$modelValue.client_requirement;\n return save(client_requirement);\n });\n $scope.$watch($attrs.ngModel, function(us) {\n if (us) {\n return render(us);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgUsClientRequirementButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$tgTemplate\", \"$compile\", UsClientRequirementButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/tasks/detail.coffee\n */\n\n(function() {\n var TaskDetailController, TaskIsIocaineButtonDirective, TaskStatusButtonDirective, TaskStatusDisplayDirective, bindMethods, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaTasks\");\n\n TaskDetailController = (function(superClass) {\n extend(TaskDetailController, superClass);\n\n TaskDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function TaskDetailController(scope, rootscope, repo, confirm, rs, params, q, location, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n bindMethods(this);\n this.scope.taskRef = this.params.taskref;\n this.scope.sectionName = this.translate.instant(\"TASK.SECTION_NAME\");\n this.initializeEventHandlers();\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n _this._setMeta();\n return _this.initializeOnDeleteGoToUrl();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TaskDetailController.prototype._setMeta = function() {\n var description, ref, title;\n title = this.translate.instant(\"TASK.PAGE_TITLE\", {\n taskRef: \"#\" + this.scope.task.ref,\n taskSubject: this.scope.task.subject,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"TASK.PAGE_DESCRIPTION\", {\n taskStatus: ((ref = this.scope.statusById[this.scope.task.status]) != null ? ref.name : void 0) || \"--\",\n taskDescription: angular.element(this.scope.task.description_html || \"\").text()\n });\n return this.appMetaService.setAll(title, description);\n };\n\n TaskDetailController.prototype.initializeEventHandlers = function() {\n this.scope.$on(\"attachment:create\", (function(_this) {\n return function() {\n return _this.analytics.trackEvent(\"attachment\", \"create\", \"create attachment on task\", 1);\n };\n })(this));\n this.scope.$on(\"custom-attributes-values:edit\", (function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this));\n return this.scope.$on(\"comment:new\", (function(_this) {\n return function() {\n return _this.loadTask();\n };\n })(this));\n };\n\n TaskDetailController.prototype.initializeOnDeleteGoToUrl = function() {\n var ctx;\n ctx = {\n project: this.scope.project.slug\n };\n this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project\", ctx);\n if (this.scope.project.is_backlog_activated) {\n if (this.scope.task.milestone) {\n ctx.sprint = this.scope.sprint.slug;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-taskboard\", ctx);\n } else if (this.scope.task.us) {\n ctx.ref = this.scope.us.ref;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n } else if (this.scope.project.is_kanban_activated) {\n if (this.scope.us) {\n ctx.ref = this.scope.us.ref;\n return this.scope.onDeleteGoToUrl = this.navUrls.resolve(\"project-userstories-detail\", ctx);\n }\n }\n };\n\n TaskDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.statusList = project.task_statuses;\n _this.scope.statusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n TaskDetailController.prototype.loadTask = function() {\n return this.rs.tasks.getByRef(this.scope.projectId, this.params.taskref).then((function(_this) {\n return function(task) {\n var ctx, ref, ref1;\n _this.scope.task = task;\n _this.scope.taskId = task.id;\n _this.scope.commentModel = task;\n if (((ref = _this.scope.task.neighbors.previous) != null ? ref.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.task.neighbors.previous.ref\n };\n _this.scope.previousUrl = _this.navUrls.resolve(\"project-tasks-detail\", ctx);\n }\n if (((ref1 = _this.scope.task.neighbors.next) != null ? ref1.ref : void 0) != null) {\n ctx = {\n project: _this.scope.project.slug,\n ref: _this.scope.task.neighbors.next.ref\n };\n _this.scope.nextUrl = _this.navUrls.resolve(\"project-tasks-detail\", ctx);\n }\n return task;\n };\n })(this));\n };\n\n TaskDetailController.prototype.loadSprint = function() {\n if (this.scope.task.milestone) {\n return this.rs.sprints.get(this.scope.task.project, this.scope.task.milestone).then((function(_this) {\n return function(sprint) {\n _this.scope.sprint = sprint;\n return sprint;\n };\n })(this));\n }\n };\n\n TaskDetailController.prototype.loadUserStory = function() {\n if (this.scope.task.user_story) {\n return this.rs.userstories.get(this.scope.task.project, this.scope.task.user_story).then((function(_this) {\n return function(us) {\n _this.scope.us = us;\n return us;\n };\n })(this));\n }\n };\n\n TaskDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.loadTask().then(function() {\n return _this.q.all([_this.loadSprint(), _this.loadUserStory()]);\n });\n };\n })(this));\n };\n\n\n /*\n * Note: This methods (onUpvote() and onDownvote()) are related to tg-vote-button.\n * See app/modules/components/vote-button for more info\n */\n\n TaskDetailController.prototype.onUpvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.upvote(this.scope.taskId).then(onSuccess, onError);\n };\n\n TaskDetailController.prototype.onDownvote = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.downvote(this.scope.taskId).then(onSuccess, onError);\n };\n\n\n /*\n * Note: This methods (onWatch() and onUnwatch()) are related to tg-watch-button.\n * See app/modules/components/watch-button for more info\n */\n\n TaskDetailController.prototype.onWatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.watch(this.scope.taskId).then(onSuccess, onError);\n };\n\n TaskDetailController.prototype.onUnwatch = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.loadTask();\n return _this.rootscope.$broadcast(\"object:updated\");\n };\n })(this);\n onError = (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this);\n return this.rs.tasks.unwatch(this.scope.taskId).then(onSuccess, onError);\n };\n\n return TaskDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TaskDetailController\", TaskDetailController);\n\n TaskStatusDisplayDirective = function($template, $compile) {\n var link, template;\n template = $template.get(\"common/components/status-display.html\", true);\n link = function($scope, $el, $attrs) {\n var render;\n render = function(task) {\n var html, status;\n status = $scope.statusById[task.status];\n html = template({\n is_closed: status.is_closed,\n status: status\n });\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(task) {\n if (task != null) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskStatusDisplay\", [\"$tgTemplate\", \"$compile\", TaskStatusDisplayDirective]);\n\n TaskStatusButtonDirective = function($rootScope, $repo, $confirm, $loading, $qqueue, $compile, $translate, $template) {\n var link, template;\n template = $template.get(\"us/us-status-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_task\") !== -1;\n };\n render = (function(_this) {\n return function(task) {\n var html, status;\n status = $scope.statusById[task.status];\n html = $compile(template({\n status: status,\n statuses: $scope.statusList,\n editable: isEditable()\n }))($scope);\n return $el.html(html);\n };\n })(this);\n save = $qqueue.bindAdd((function(_this) {\n return function(status) {\n var currentLoading, onError, onSuccess, task;\n task = $model.$modelValue.clone();\n task.status = status;\n currentLoading = $loading().target($el).start();\n onSuccess = function() {\n $model.$setViewValue(task);\n $rootScope.$broadcast(\"object:updated\");\n return currentLoading.finish();\n };\n onError = function() {\n $confirm.notify(\"error\");\n return currentLoading.finish();\n };\n return $repo.save(task).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"click\", \".js-edit-status\", function(event) {\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n return $el.find(\".pop-status\").popover().open();\n });\n $el.on(\"click\", \".status\", function(event) {\n var target;\n event.preventDefault();\n event.stopPropagation();\n if (!isEditable()) {\n return;\n }\n target = angular.element(event.currentTarget);\n $.fn.popover().closeAll();\n return save(target.data(\"status-id\"));\n });\n $scope.$watch($attrs.ngModel, function(task) {\n if (task) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskStatusButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$compile\", \"$translate\", \"$tgTemplate\", TaskStatusButtonDirective]);\n\n TaskIsIocaineButtonDirective = function($rootscope, $tgrepo, $confirm, $loading, $qqueue, $compile, $template) {\n var link, template;\n template = $template.get(\"issue/iocaine-button.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var isEditable, render, save;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_task\") !== -1;\n };\n render = function(task) {\n var ctx, html;\n if (!isEditable() && !task.is_iocaine) {\n $el.html(\"\");\n return;\n }\n ctx = {\n isIocaine: task.is_iocaine,\n isEditable: isEditable()\n };\n html = $compile(template(ctx))($scope);\n return $el.html(html);\n };\n save = $qqueue.bindAdd((function(_this) {\n return function(is_iocaine) {\n var currentLoading, promise, task;\n task = $model.$modelValue.clone();\n task.is_iocaine = is_iocaine;\n currentLoading = $loading().target($el.find('label')).start();\n promise = $tgrepo.save(task);\n promise.then(function() {\n $model.$setViewValue(task);\n return $rootscope.$broadcast(\"object:updated\");\n });\n promise.then(null, function() {\n return $confirm.notify(\"error\");\n });\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n };\n })(this));\n $el.on(\"click\", \".is-iocaine\", function(event) {\n var is_iocaine;\n if (!isEditable()) {\n return;\n }\n is_iocaine = !$model.$modelValue.is_iocaine;\n return save(is_iocaine);\n });\n $scope.$watch($attrs.ngModel, function(task) {\n if (task) {\n return render(task);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgTaskIsIocaineButton\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgQqueue\", \"$compile\", \"$tgTemplate\", TaskIsIocaineButtonDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/team/main.coffee\n */\n\n(function() {\n var LeaveProjectDirective, TeamController, TeamFiltersDirective, TeamMemberCurrentUserDirective, TeamMemberStatsDirective, TeamMembersDirective, membersFilter, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n module = angular.module(\"taigaTeam\");\n\n TeamController = (function(superClass) {\n extend(TeamController, superClass);\n\n TeamController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$location\", \"$tgNavUrls\", \"tgAppMetaService\", \"$tgAuth\", \"$translate\", \"tgProjectService\"];\n\n function TeamController(scope, rootscope, repo, rs, params, q, location, navUrls, appMetaService, auth, translate, projectService) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.auth = auth;\n this.translate = translate;\n this.projectService = projectService;\n this.scope.sectionName = \"TEAM.SECTION_NAME\";\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"TEAM.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.translate.instant(\"TEAM.PAGE_DESCRIPTION\", {\n projectName: _this.scope.project.name,\n projectDescription: _this.scope.project.description\n });\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n TeamController.prototype.setRole = function(role) {\n if (role) {\n return this.scope.filtersRole = role;\n } else {\n return this.scope.filtersRole = null;\n }\n };\n\n TeamController.prototype.loadMembers = function() {\n var i, len, member, ref, user;\n user = this.auth.getUser();\n this.scope.totals = {};\n ref = this.scope.activeUsers;\n for (i = 0, len = ref.length; i < len; i++) {\n member = ref[i];\n this.scope.totals[member.id] = 0;\n }\n this.scope.currentUser = _.find(this.scope.activeUsers, {\n id: user != null ? user.id : void 0\n });\n return this.scope.memberships = _.reject(this.scope.activeUsers, {\n id: user != null ? user.id : void 0\n });\n };\n\n TeamController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issuesEnabled = project.is_issues_activated;\n _this.scope.tasksEnabled = project.is_kanban_activated || project.is_backlog_activated;\n _this.scope.wikiEnabled = project.is_wiki_activated;\n return project;\n };\n })(this));\n };\n\n TeamController.prototype.loadMemberStats = function() {\n return this.rs.projects.memberStats(this.scope.projectId).then((function(_this) {\n return function(stats) {\n var totals;\n totals = {};\n _.forEach(_this.scope.totals, function(total, userId) {\n var vals;\n vals = _.map(stats, function(memberStats, statsKey) {\n return memberStats[userId];\n });\n total = _.reduce(vals, function(sum, el) {\n return sum + el;\n });\n return _this.scope.totals[userId] = total;\n });\n _this.scope.stats = _this._processStats(stats);\n return _this.scope.stats.totals = _this.scope.totals;\n };\n })(this));\n };\n\n TeamController.prototype._processStat = function(stat) {\n var max, min, singleStat;\n max = _.max(stat);\n min = _.min(stat);\n singleStat = _.map(stat, function(value, key) {\n if (value === min) {\n return [key, 0.1];\n }\n if (value === max) {\n return [key, 1];\n }\n return [key, (value * 0.5) / max];\n });\n singleStat = _.object(singleStat);\n return singleStat;\n };\n\n TeamController.prototype._processStats = function(stats) {\n var key, value;\n for (key in stats) {\n value = stats[key];\n stats[key] = this._processStat(value);\n }\n return stats;\n };\n\n TeamController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n _this.loadMembers();\n return _this.loadMemberStats();\n };\n })(this));\n };\n\n return TeamController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"TeamController\", TeamController);\n\n TeamFiltersDirective = function() {\n return {\n templateUrl: \"team/team-filter.html\"\n };\n };\n\n module.directive(\"tgTeamFilters\", [TeamFiltersDirective]);\n\n TeamMemberStatsDirective = function() {\n return {\n templateUrl: \"team/team-member-stats.html\",\n scope: {\n stats: \"=\",\n userId: \"=user\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamMemberStats\", TeamMemberStatsDirective);\n\n TeamMemberCurrentUserDirective = function() {\n return {\n templateUrl: \"team/team-member-current-user.html\",\n scope: {\n projectId: \"=projectid\",\n currentUser: \"=currentuser\",\n stats: \"=\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamCurrentUser\", TeamMemberCurrentUserDirective);\n\n TeamMembersDirective = function() {\n var template;\n template = \"team/team-members.html\";\n return {\n templateUrl: template,\n scope: {\n memberships: \"=\",\n filtersQ: \"=filtersq\",\n filtersRole: \"=filtersrole\",\n stats: \"=\",\n issuesEnabled: \"=issuesenabled\",\n tasksEnabled: \"=tasksenabled\",\n wikiEnabled: \"=wikienabled\"\n }\n };\n };\n\n module.directive(\"tgTeamMembers\", TeamMembersDirective);\n\n LeaveProjectDirective = function($repo, $confirm, $location, $rs, $navurls, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.leave = function() {\n var confirm_leave_project_text, leave_project_text;\n leave_project_text = $translate.instant(\"TEAM.ACTION_LEAVE_PROJECT\");\n confirm_leave_project_text = $translate.instant(\"TEAM.CONFIRM_LEAVE_PROJECT\");\n return $confirm.ask(leave_project_text, confirm_leave_project_text).then((function(_this) {\n return function(response) {\n var promise;\n promise = $rs.projects.leave($attrs.projectid);\n promise.then(function() {\n response.finish();\n $confirm.notify(\"success\");\n return $location.path($navurls.resolve(\"home\"));\n });\n return promise.then(null, function(response) {\n response.finish();\n return $confirm.notify('error', response.data._error_message);\n });\n };\n })(this));\n };\n };\n return {\n scope: {},\n templateUrl: \"team/leave-project.html\",\n link: link\n };\n };\n\n module.directive(\"tgLeaveProject\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"$tgResources\", \"$tgNavUrls\", \"$translate\", LeaveProjectDirective]);\n\n membersFilter = function() {\n return function(members, filtersQ, filtersRole) {\n return _.filter(members, function(m) {\n return (!filtersRole || m.role === filtersRole.id) && (!filtersQ || m.full_name.search(new RegExp(filtersQ, \"i\")) >= 0);\n });\n };\n };\n\n module.filter('membersFilter', membersFilter);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki/detail.coffee\n */\n\n(function() {\n var EditableWikiContentDirective, WikiDetailController, WikiSummaryDirective, bindOnce, debounce, groupBy, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaWiki\");\n\n WikiDetailController = (function(superClass) {\n extend(WikiDetailController, superClass);\n\n WikiDetailController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgModel\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$filter\", \"$log\", \"tgAppMetaService\", \"$tgNavUrls\", \"$tgAnalytics\", \"$translate\"];\n\n function WikiDetailController(scope, rootscope, repo, model, confirm, rs, params, q, location, filter, log, appMetaService, navUrls, analytics, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.model = model;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.filter = filter;\n this.log = log;\n this.appMetaService = appMetaService;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.translate = translate;\n this.scope.projectSlug = this.params.pslug;\n this.scope.wikiSlug = this.params.slug;\n this.scope.wikiTitle = this.scope.wikiSlug;\n this.scope.sectionName = \"Wiki\";\n this.scope.linksVisible = false;\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n return _this._setMeta();\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n WikiDetailController.prototype._setMeta = function() {\n var description, ref, ref1, ref2, title;\n title = this.translate.instant(\"WIKI.PAGE_TITLE\", {\n wikiPageName: this.scope.wikiTitle,\n projectName: this.scope.project.name\n });\n description = this.translate.instant(\"WIKI.PAGE_DESCRIPTION\", {\n wikiPageContent: angular.element(((ref = this.scope.wiki) != null ? ref.html : void 0) || \"\").text(),\n totalEditions: ((ref1 = this.scope.wiki) != null ? ref1.editions : void 0) || 0,\n lastModifiedDate: moment((ref2 = this.scope.wiki) != null ? ref2.modified_date : void 0).format(this.translate.instant(\"WIKI.DATETIME\"))\n });\n return this.appMetaService.setAll(title, description);\n };\n\n WikiDetailController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.is_wiki_activated) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadWiki = function() {\n var promise;\n promise = this.rs.wiki.getBySlug(this.scope.projectId, this.params.slug);\n promise.then((function(_this) {\n return function(wiki) {\n _this.scope.wiki = wiki;\n _this.scope.wikiId = wiki.id;\n return _this.scope.wiki;\n };\n })(this));\n return promise.then(null, (function(_this) {\n return function(xhr) {\n var data;\n _this.scope.wikiId = null;\n if (_this.scope.project.my_permissions.indexOf(\"add_wiki_page\") === -1) {\n return null;\n }\n data = {\n project: _this.scope.projectId,\n slug: _this.scope.wikiSlug,\n content: \"\"\n };\n _this.scope.wiki = _this.model.make_model(\"wiki\", data);\n return _this.scope.wiki;\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadWikiLinks = function() {\n return this.rs.wiki.listLinks(this.scope.projectId).then((function(_this) {\n return function(wikiLinks) {\n var selectedWikiLink;\n _this.scope.wikiLinks = wikiLinks;\n selectedWikiLink = _.find(wikiLinks, {\n href: _this.scope.wikiSlug\n });\n if (selectedWikiLink != null) {\n return _this.scope.wikiTitle = selectedWikiLink.title;\n }\n };\n })(this));\n };\n\n WikiDetailController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise.then((function(_this) {\n return function(project) {\n _this.fillUsersAndRoles(project.members, project.roles);\n return _this.q.all([_this.loadWikiLinks(), _this.loadWiki()]).then(_this.checkLinksPerms.bind(_this));\n };\n })(this));\n };\n\n WikiDetailController.prototype.checkLinksPerms = function() {\n if (this.scope.project.my_permissions.indexOf(\"modify_wiki_link\") !== -1 || (this.scope.project.my_permissions.indexOf(\"view_wiki_links\") !== -1 && this.scope.wikiLinks.length)) {\n return this.scope.linksVisible = true;\n }\n };\n\n WikiDetailController.prototype[\"delete\"] = function() {\n var message, title;\n title = this.translate.instant(\"WIKI.DELETE_LIGHTBOX_TITLE\");\n message = this.scope.wikiTitle;\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onSuccess = function() {\n var ctx;\n askResponse.finish();\n ctx = {\n project: _this.scope.projectSlug\n };\n _this.location.path(_this.navUrls.resolve(\"project-wiki\", ctx));\n return _this.confirm.notify(\"success\");\n };\n onError = function() {\n askResponse.finish(false);\n return _this.confirm.notify(\"error\");\n };\n return _this.repo.remove(_this.scope.wiki).then(onSuccess, onError);\n };\n })(this));\n };\n\n return WikiDetailController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"WikiDetailController\", WikiDetailController);\n\n WikiSummaryDirective = function($log, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"wiki/wiki-summary.html\", true);\n link = function($scope, $el, $attrs, $model) {\n var render;\n render = function(wiki) {\n var ctx, html, user;\n if ($scope.usersById == null) {\n $log.error(\"WikiSummaryDirective requires userById set in scope.\");\n } else {\n user = $scope.usersById[wiki.last_modifier];\n }\n if (user === void 0) {\n user = {\n name: \"unknown\",\n imgUrl: \"/\" + window._version + \"/images/user-noimage.png\"\n };\n } else {\n user = {\n name: user.full_name_display,\n imgUrl: user.photo\n };\n }\n ctx = {\n totalEditions: wiki.editions,\n lastModifiedDate: moment(wiki.modified_date).format($translate.instant(\"WIKI.DATETIME\")),\n user: user\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n $scope.$watch($attrs.ngModel, function(wikiPage) {\n if (!wikiPage) {\n return;\n }\n return render(wikiPage);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgWikiSummary\", [\"$log\", \"$tgTemplate\", \"$compile\", \"$translate\", WikiSummaryDirective]);\n\n EditableWikiContentDirective = function($window, $document, $repo, $confirm, $loading, $analytics, $qqueue) {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var cancelEdition, disableEdition, getSelectedText, isEditable, save, switchToEditMode, switchToReadMode;\n isEditable = function() {\n return $scope.project.my_permissions.indexOf(\"modify_wiki_page\") !== -1;\n };\n switchToEditMode = function() {\n $el.find('.edit-wiki-content').show();\n $el.find('.view-wiki-content').hide();\n return $el.find('textarea').focus();\n };\n switchToReadMode = function() {\n $el.find('.edit-wiki-content').hide();\n return $el.find('.view-wiki-content').show();\n };\n disableEdition = function() {\n $el.find(\".view-wiki-content .edit\").remove();\n return $el.find(\".edit-wiki-content\").remove();\n };\n cancelEdition = function() {\n if (!$model.$modelValue.id) {\n return;\n }\n $scope.$apply((function(_this) {\n return function() {\n return $model.$modelValue.revert();\n };\n })(this));\n return switchToReadMode();\n };\n getSelectedText = function() {\n if ($window.getSelection) {\n return $window.getSelection().toString();\n } else if ($document.selection) {\n return $document.selection.createRange().text;\n }\n return null;\n };\n save = $qqueue.bindAdd(function(wiki) {\n var currentLoading, onError, onSuccess, promise;\n onSuccess = function(wikiPage) {\n if (wiki.id == null) {\n $analytics.trackEvent(\"wikipage\", \"create\", \"create wiki page\", 1);\n }\n $model.$setViewValue(wikiPage.clone());\n $confirm.notify(\"success\");\n return switchToReadMode();\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n currentLoading = $loading().removeClasses(\"icon-floppy\").target($el.find('.icon-floppy')).start();\n if (wiki.id != null) {\n promise = $repo.save(wiki).then(onSuccess, onError);\n } else {\n promise = $repo.create(\"wiki\", wiki).then(onSuccess, onError);\n }\n return promise[\"finally\"](function() {\n return currentLoading.finish();\n });\n });\n $el.on(\"click\", \"a\", function(event) {\n var href, target;\n target = angular.element(event.target);\n href = target.attr('href');\n if (href.indexOf(\"#\") === 0) {\n event.preventDefault();\n return $('body').scrollTop($(href).offset().top);\n }\n });\n $el.on(\"mousedown\", \".view-wiki-content\", function(event) {\n var target;\n target = angular.element(event.target);\n if (!isEditable()) {\n return;\n }\n if (event.button === 2) {\n\n }\n });\n $el.on(\"mouseup\", \".view-wiki-content\", function(event) {\n var target;\n target = angular.element(event.target);\n if (getSelectedText()) {\n return;\n }\n if (!isEditable()) {\n return;\n }\n if (target.is('a')) {\n return;\n }\n if (target.is('pre')) {\n return;\n }\n return switchToEditMode();\n });\n $el.on(\"click\", \".save\", debounce(2000, function() {\n return save($scope.wiki);\n }));\n $el.on(\"click\", \".cancel\", function() {\n return cancelEdition();\n });\n $el.on(\"keydown\", \"textarea\", function(event) {\n if (event.keyCode === 27) {\n return cancelEdition();\n }\n });\n $scope.$watch($attrs.ngModel, function(wikiPage) {\n if (!wikiPage) {\n return;\n }\n if (isEditable()) {\n $el.addClass('editable');\n if ((wikiPage.id == null) || $.trim(wikiPage.content).length === 0) {\n return switchToEditMode();\n }\n } else {\n return disableEdition();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\",\n templateUrl: \"wiki/editable-wiki-content.html\"\n };\n };\n\n module.directive(\"tgEditableWikiContent\", [\"$window\", \"$document\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgAnalytics\", \"$tgQqueue\", EditableWikiContentDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki/detail.coffee\n */\n\n(function() {\n var WikiNavDirective, bindOnce, groupBy, mixOf, module, taiga;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaWiki\");\n\n WikiNavDirective = function($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $loading, $template, $compile, $translate) {\n var link, template;\n template = $template.get(\"wiki/wiki-nav.html\", true);\n link = function($scope, $el, $attrs) {\n var $ctrl, render;\n $ctrl = $el.controller();\n if ($attrs.ngModel == null) {\n return $log.error(\"WikiNavDirective: no ng-model attr is defined\");\n }\n render = function(wikiLinks) {\n var addWikiLinkPermission, deleteWikiLinkPermission, html;\n addWikiLinkPermission = $scope.project.my_permissions.indexOf(\"add_wiki_link\") > -1;\n deleteWikiLinkPermission = $scope.project.my_permissions.indexOf(\"delete_wiki_link\") > -1;\n html = template({\n wikiLinks: wikiLinks,\n projectSlug: $scope.projectSlug,\n addWikiLinkPermission: addWikiLinkPermission,\n deleteWikiLinkPermission: deleteWikiLinkPermission\n });\n html = $compile(html)($scope);\n $el.off();\n $el.html(html);\n $el.on(\"click\", \".wiki-link .link-title\", function(event) {\n var linkId, linkSlug, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n linkId = target.parents('.wiki-link').data('id');\n linkSlug = $scope.wikiLinks[linkId].href;\n return $scope.$apply(function() {\n var ctx;\n ctx = {\n project: $scope.projectSlug,\n slug: linkSlug\n };\n return $location.path($navUrls.resolve(\"project-wiki-page\", ctx));\n });\n });\n $el.on(\"click\", \".add-button\", function(event) {\n event.preventDefault();\n $el.find(\".new\").removeClass(\"hidden\");\n $el.find(\".new input\").focus();\n return $el.find(\".add-button\").hide();\n });\n $el.on(\"click\", \".wiki-link .icon-delete\", function(event) {\n var linkId, message, target, title;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n linkId = target.parents('.wiki-link').data('id');\n title = $translate.instant(\"WIKI.DELETE_LIGHTBOX_TITLE\");\n message = $scope.wikiLinks[linkId].title;\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var promise;\n promise = $tgrepo.remove($scope.wikiLinks[linkId]);\n promise.then(function() {\n promise = $ctrl.loadWikiLinks();\n promise.then(function() {\n askResponse.finish();\n return render($scope.wikiLinks);\n });\n return promise.then(null, function() {\n return askResponse.finish();\n });\n });\n return promise.then(null, function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n });\n return $el.on(\"keyup\", \".new input\", function(event) {\n var currentLoading, newLink, promise, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newLink = target.val();\n currentLoading = $loading().target($el.find(\".new\")).start();\n promise = $tgrepo.create(\"wiki-links\", {\n project: $scope.projectId,\n title: newLink\n });\n promise.then(function() {\n var loadPromise;\n $analytics.trackEvent(\"wikilink\", \"create\", \"create wiki link\", 1);\n loadPromise = $ctrl.loadWikiLinks();\n loadPromise.then(function() {\n currentLoading.finish();\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n $el.find(\".add-button\").show();\n return render($scope.wikiLinks);\n });\n return loadPromise.then(null, function() {\n currentLoading.finish();\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n $el.find(\".add-button\").show();\n return $confirm.notify(\"error\", \"Error loading wiki links\");\n });\n });\n return promise.then(null, function(error) {\n var ref;\n currentLoading.finish();\n $el.find(\".new input\").val(newLink);\n $el.find(\".new input\").focus().select();\n if ((error != null ? (ref = error.__all__) != null ? ref[0] : void 0 : void 0) != null) {\n return $confirm.notify(\"error\", \"The link already exists\");\n } else {\n return $confirm.notify(\"error\");\n }\n });\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new input\").val('');\n return $el.find(\".add-button\").show();\n }\n });\n };\n return bindOnce($scope, $attrs.ngModel, render);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgWikiNav\", [\"$tgRepo\", \"$log\", \"$tgLocation\", \"$tgConfirm\", \"$tgNavUrls\", \"$tgAnalytics\", \"$tgLoading\", \"$tgTemplate\", \"$compile\", \"$translate\", WikiNavDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/lightboxes.coffee\n */\n\n(function() {\n var CreateMembersDirective, MAX_MEMBERSHIP_FIELDSETS, debounce, module, taiga;\n\n taiga = this.taiga;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaKanban\");\n\n MAX_MEMBERSHIP_FIELDSETS = 4;\n\n CreateMembersDirective = function($rs, $rootScope, $confirm, $loading, lightboxService, $compile) {\n var extraTextTemplate, link, template;\n extraTextTemplate = \"
\\n \\n
\";\n template = _.template(\"
\\n
\\n data-required=\\\"true\\\" <% } %> data-type=\\\"email\\\" />\\n
\\n
\\n \\n \\n
\\n
\");\n link = function($scope, $el, $attrs) {\n var createFieldSet, resetForm, submit, submitButton;\n createFieldSet = function(required) {\n var ctx;\n if (required == null) {\n required = true;\n }\n ctx = {\n roleList: $scope.project.roles,\n required: required\n };\n return $compile(template(ctx))($scope);\n };\n resetForm = function() {\n var fieldSet, invitations;\n $el.find(\"form textarea\").remove();\n $el.find(\"form .add-member-wrapper\").remove();\n invitations = $el.find(\".add-member-forms\");\n invitations.html($compile(extraTextTemplate)($scope));\n fieldSet = createFieldSet();\n return invitations.prepend(fieldSet);\n };\n $scope.$on(\"membersform:new\", function() {\n resetForm();\n return lightboxService.open($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $el.on(\"click\", \".delete-fieldset\", function(event) {\n var fieldSet, lastActionButton, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n fieldSet = target.closest('.add-member-wrapper');\n fieldSet.remove();\n lastActionButton = $el.find(\".add-member-wrapper fieldset:last > a\");\n if (lastActionButton.hasClass(\"icon-delete delete-fieldset\")) {\n return lastActionButton.removeClass(\"icon-delete delete-fieldset\").addClass(\"icon-plus add-fieldset\");\n }\n });\n $el.on(\"click\", \".add-fieldset\", function(event) {\n var fieldSet, newFieldSet, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n fieldSet = target.closest('.add-member-wrapper');\n target.removeClass(\"icon-plus add-fieldset\").addClass(\"icon-delete delete-fieldset\");\n newFieldSet = createFieldSet(false);\n fieldSet.after(newFieldSet);\n $scope.$digest();\n if ($el.find(\".add-member-wrapper\").length === MAX_MEMBERSHIP_FIELDSETS) {\n return $el.find(\".add-member-wrapper fieldset:last > a\").removeClass(\"icon-plus add-fieldset\").addClass(\"icon-delete delete-fieldset\");\n }\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, form, invitation_extra_text, invitations, memberWrappers, onError, onSuccess, promise;\n event.preventDefault();\n currentLoading = $loading().target(submitButton).start();\n onSuccess = function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n $confirm.notify(\"success\");\n return $rootScope.$broadcast(\"membersform:new:success\");\n };\n onError = function(data) {\n currentLoading.finish();\n lightboxService.close($el);\n $confirm.notify(\"error\");\n return $rootScope.$broadcast(\"membersform:new:error\");\n };\n form = $el.find(\"form\").checksley();\n form.destroy();\n form.initialize();\n if (!form.validate()) {\n return;\n }\n memberWrappers = $el.find(\"form .add-member-wrapper\");\n memberWrappers = _.filter(memberWrappers, function(mw) {\n return angular.element(mw).find(\"input\").hasClass('checksley-ok');\n });\n invitations = _.map(memberWrappers, function(mw) {\n var email, memberWrapper, role;\n memberWrapper = angular.element(mw);\n email = memberWrapper.find(\"input\");\n role = memberWrapper.find(\"select\");\n return {\n email: email.val(),\n role_id: role.val()\n };\n });\n if (invitations.length) {\n invitation_extra_text = $el.find(\"form textarea\").val();\n promise = $rs.memberships.bulkCreateMemberships($scope.project.id, invitations, invitation_extra_text);\n return promise.then(onSuccess, onError);\n }\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbCreateMembers\", [\"$tgResources\", \"$rootScope\", \"$tgConfirm\", \"$tgLoading\", \"lightboxService\", \"$compile\", CreateMembersDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/memberships.coffee\n */\n\n(function() {\n var MembershipsController, MembershipsDirective, MembershipsRowActionsDirective, MembershipsRowAdminCheckboxDirective, MembershipsRowAvatarDirective, MembershipsRowRoleSelectorDirective, bindMethods, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaAdmin\");\n\n MembershipsController = (function(superClass) {\n extend(MembershipsController, superClass);\n\n MembershipsController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAnalytics\", \"tgAppMetaService\", \"$translate\"];\n\n function MembershipsController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, analytics, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.analytics = analytics;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.project = {};\n this.scope.filters = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.MEMBERSHIPS.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"membersform:new:success\", (function(_this) {\n return function() {\n _this.loadMembers();\n return _this.analytics.trackEvent(\"membership\", \"create\", \"create memberships on admin\", 1);\n };\n })(this));\n }\n\n MembershipsController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n MembershipsController.prototype.loadMembers = function() {\n var httpFilters;\n httpFilters = this.getUrlFilters();\n return this.rs.memberships.list(this.scope.projectId, httpFilters).then((function(_this) {\n return function(data) {\n _this.scope.memberships = _.filter(data.models, function(membership) {\n return membership.user === null || membership.is_user_active;\n });\n _this.scope.page = data.current;\n _this.scope.count = data.count;\n _this.scope.paginatedBy = data.paginatedBy;\n return data;\n };\n })(this));\n };\n\n MembershipsController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadMembers();\n };\n })(this));\n return promise;\n };\n\n MembershipsController.prototype.getUrlFilters = function() {\n var filters;\n filters = _.pick(this.location.search(), \"page\");\n if (!filters.page) {\n filters.page = 1;\n }\n return filters;\n };\n\n MembershipsController.prototype.addNewMembers = function() {\n return this.rootscope.$broadcast(\"membersform:new\");\n };\n\n return MembershipsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"MembershipsController\", MembershipsController);\n\n MembershipsDirective = function($template, $compile) {\n var link, linkPagination, template;\n template = $template.get(\"admin/admin-membership-paginator.html\", true);\n linkPagination = function($scope, $el, $attrs, $ctrl) {\n var $pagEl, afterCurrent, atBegin, atEnd, beforeCurrent, getNumPages, renderPagination;\n afterCurrent = 2;\n beforeCurrent = 4;\n atBegin = 2;\n atEnd = 2;\n $pagEl = $el.find(\".memberships-paginator\");\n getNumPages = function() {\n var numPages;\n numPages = $scope.count / $scope.paginatedBy;\n if (parseInt(numPages, 10) < numPages) {\n numPages = parseInt(numPages, 10) + 1;\n } else {\n numPages = parseInt(numPages, 10);\n }\n return numPages;\n };\n renderPagination = function() {\n var cpage, html, i, j, numPages, options, pages, ref;\n numPages = getNumPages();\n if (numPages <= 1) {\n $pagEl.hide();\n return;\n }\n pages = [];\n options = {};\n options.pages = pages;\n options.showPrevious = $scope.page > 1;\n options.showNext = !($scope.page === numPages);\n cpage = $scope.page;\n for (i = j = 1, ref = numPages; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\n if (i === (cpage + afterCurrent) && numPages > (cpage + afterCurrent + atEnd)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i === (cpage - beforeCurrent) && cpage > (atBegin + beforeCurrent)) {\n pages.push({\n classes: \"dots\",\n type: \"dots\"\n });\n } else if (i > (cpage + afterCurrent) && i <= (numPages - atEnd)) {\n\n } else if (i < (cpage - beforeCurrent) && i > atBegin) {\n\n } else if (i === cpage) {\n pages.push({\n classes: \"active\",\n num: i,\n type: \"page-active\"\n });\n } else {\n pages.push({\n classes: \"page\",\n num: i,\n type: \"page\"\n });\n }\n }\n html = template(options);\n html = $compile(html)($scope);\n $pagEl.html(html);\n return $pagEl.show();\n };\n $scope.$watch(\"memberships\", function(value) {\n if (!value) {\n return;\n }\n return renderPagination();\n });\n $el.on(\"click\", \".memberships-paginator a.next\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page + 1);\n return $ctrl.loadMembers();\n });\n });\n $el.on(\"click\", \".memberships-paginator a.previous\", function(event) {\n event.preventDefault();\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n return $ctrl.loadMembers();\n });\n });\n return $el.on(\"click\", \".memberships-paginator li.page > a\", function(event) {\n var pagenum, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n pagenum = target.data(\"pagenum\");\n return $scope.$apply(function() {\n $ctrl.selectFilter(\"page\", pagenum);\n return $ctrl.loadMembers();\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n linkPagination($scope, $el, $attrs, $ctrl);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMemberships\", [\"$tgTemplate\", \"$compile\", MembershipsDirective]);\n\n MembershipsRowAvatarDirective = function($log, $template, $translate) {\n var link, template;\n template = $template.get(\"admin/memberships-row-avatar.html\", true);\n link = function($scope, $el, $attrs) {\n var member, pending, render;\n pending = $translate.instant(\"ADMIN.MEMBERSHIP.STATUS_PENDING\");\n render = function(member) {\n var ctx, html;\n ctx = {\n full_name: member.full_name ? member.full_name : \"\",\n email: member.user_email ? member.user_email : member.email,\n imgurl: member.photo ? member.photo : \"/\" + window._version + \"/images/unnamed.png\",\n pending: !member.is_user_active ? pending : \"\"\n };\n html = template(ctx);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowAvatar == null) {\n return $log.error(\"MembershipsRowAvatarDirective: the directive need a member\");\n }\n member = $scope.$eval($attrs.tgMembershipsRowAvatar);\n render(member);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowAvatar\", [\"$log\", \"$tgTemplate\", '$translate', MembershipsRowAvatarDirective]);\n\n MembershipsRowAdminCheckboxDirective = function($log, $repo, $confirm, $template, $compile) {\n var link, template;\n template = $template.get(\"admin/admin-memberships-row-checkbox.html\", true);\n link = function($scope, $el, $attrs) {\n var html, member, render;\n render = function(member) {\n var ctx, html;\n ctx = {\n inputId: \"is-admin-\" + member.id\n };\n html = template(ctx);\n html = $compile(html)($scope);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowAdminCheckbox == null) {\n return $log.error(\"MembershipsRowAdminCheckboxDirective: the directive need a member\");\n }\n member = $scope.$eval($attrs.tgMembershipsRowAdminCheckbox);\n html = render(member);\n if (member.is_owner) {\n $el.find(\":checkbox\").prop(\"checked\", true);\n }\n $el.on(\"click\", \":checkbox\", (function(_this) {\n return function(event) {\n var onError, onSuccess, target;\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function(data) {\n member.revert();\n $el.find(\":checkbox\").prop(\"checked\", member.is_owner);\n return $confirm.notify(\"error\", data.is_owner[0]);\n };\n target = angular.element(event.currentTarget);\n member.is_owner = target.prop(\"checked\");\n return $repo.save(member).then(onSuccess, onError);\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowAdminCheckbox\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgTemplate\", \"$compile\", MembershipsRowAdminCheckboxDirective]);\n\n MembershipsRowRoleSelectorDirective = function($log, $repo, $confirm) {\n var link, template;\n template = _.template(\"\");\n link = function($scope, $el, $attrs) {\n var $ctrl, html, member, render;\n render = function(member) {\n var ctx, html;\n ctx = {\n roleList: $scope.project.roles,\n selectedRole: member.role\n };\n html = template(ctx);\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowRoleSelector == null) {\n return $log.error(\"MembershipsRowRoleSelectorDirective: the directive need a member\");\n }\n $ctrl = $el.controller();\n member = $scope.$eval($attrs.tgMembershipsRowRoleSelector);\n html = render(member);\n $el.on(\"change\", \"select\", (function(_this) {\n return function(event) {\n var newRole, onError, onSuccess, target;\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n target = angular.element(event.currentTarget);\n newRole = parseInt(target.val(), 10);\n if (member.role !== newRole) {\n member.role = newRole;\n return $repo.save(member).then(onSuccess, onError);\n }\n };\n })(this));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowRoleSelector\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", MembershipsRowRoleSelectorDirective]);\n\n MembershipsRowActionsDirective = function($log, $repo, $rs, $confirm, $compile, $translate) {\n var activedTemplate, link, pendingTemplate;\n activedTemplate = \"
\\n
\\n\\n \\n\";\n pendingTemplate = \"\\n\\n\\n \\n\";\n link = function($scope, $el, $attrs) {\n var $ctrl, member, render;\n render = function(member) {\n var html;\n if (member.user) {\n html = $compile(activedTemplate)($scope);\n } else {\n html = $compile(pendingTemplate)($scope);\n }\n return $el.html(html);\n };\n if ($attrs.tgMembershipsRowActions == null) {\n return $log.error(\"MembershipsRowActionsDirective: the directive need a member\");\n }\n $ctrl = $el.controller();\n member = $scope.$eval($attrs.tgMembershipsRowActions);\n render(member);\n $el.on(\"click\", \".js-resend\", function(event) {\n var onError, onSuccess;\n event.preventDefault();\n onSuccess = function() {\n var text;\n text = $translate.instant(\"ADMIN.MEMBERSHIP.SUCCESS_SEND_INVITATION\", {\n email: $scope.member.email\n });\n return $confirm.notify(\"success\", text);\n };\n onError = function() {\n var text;\n text = $translate.instant(\"ADMIM.MEMBERSHIP.ERROR_SEND_INVITATION\");\n return $confirm.notify(\"error\", text);\n };\n return $rs.memberships.resendInvitation($scope.member.id).then(onSuccess, onError);\n });\n $el.on(\"click\", \".delete\", function(event) {\n var defaultMsg, message, title;\n event.preventDefault();\n title = $translate.instant(\"ADMIN.MEMBERSHIP.DELETE_MEMBER\");\n defaultMsg = $translate.instant(\"ADMIN.MEMBERSHIP.DEFAULT_DELETE_MESSAGE\", {\n email: member.email\n });\n message = member.user ? member.full_name : defaultMsg;\n return $confirm.askOnDelete(title, message).then(function(askResponse) {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n var text;\n askResponse.finish();\n if ($scope.page > 1 && ($scope.count - 1) <= $scope.paginatedBy) {\n $ctrl.selectFilter(\"page\", $scope.page - 1);\n }\n $ctrl.loadMembers();\n text = $translate.instant(\"ADMIN.MEMBERSHIP.SUCCESS_DELETE\");\n return $confirm.notify(\"success\", null, text);\n };\n })(this);\n onError = (function(_this) {\n return function() {\n var text;\n askResponse.finish(false);\n text = $translate.instant(\"ADMIN.MEMBERSHIP.ERROR_DELETE\", {\n message: message\n });\n return $confirm.notify(\"error\", null, text);\n };\n })(this);\n return $repo.remove(member).then(onSuccess, onError);\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMembershipsRowActions\", [\"$log\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$compile\", \"$translate\", MembershipsRowActionsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/nav.coffee\n */\n\n(function() {\n var AdminNavigationDirective, module;\n\n AdminNavigationDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var section;\n section = $attrs.tgAdminNavigation;\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\"#adminmenu-\" + section + \" a\").addClass(\"active\");\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaAdmin\");\n\n module.directive(\"tgAdminNavigation\", AdminNavigationDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/project-profile.coffee\n */\n\n(function() {\n var CsvExporterController, CsvExporterIssuesController, CsvExporterTasksController, CsvExporterUserstoriesController, CsvIssueDirective, CsvTaskDirective, CsvUsDirective, ProjectDefaultValuesDirective, ProjectExportDirective, ProjectLogoDirective, ProjectLogoModelDirective, ProjectModulesDirective, ProjectProfileController, ProjectProfileDirective, bindOnce, debounce, groupBy, joinStr, mixOf, module, taiga, toString, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAdmin\");\n\n ProjectProfileController = (function(superClass) {\n extend(ProjectProfileController, superClass);\n\n ProjectProfileController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectProfileController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_PROFILE.PAGE_TITLE\", {\n sectionName: sectionName,\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:loaded\", (function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_PROFILE.PAGE_TITLE\", {\n sectionName: sectionName,\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n }\n\n ProjectProfileController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.pointsList = _.sortBy(project.points, \"order\");\n _this.scope.usStatusList = _.sortBy(project.us_statuses, \"order\");\n _this.scope.taskStatusList = _.sortBy(project.task_statuses, \"order\");\n _this.scope.prioritiesList = _.sortBy(project.priorities, \"order\");\n _this.scope.severitiesList = _.sortBy(project.severities, \"order\");\n _this.scope.issueTypesList = _.sortBy(project.issue_types, \"order\");\n _this.scope.issueStatusList = _.sortBy(project.issue_statuses, \"order\");\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ProjectProfileController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise;\n };\n\n ProjectProfileController.prototype.openDeleteLightbox = function() {\n return this.rootscope.$broadcast(\"deletelightbox:new\", this.scope.project);\n };\n\n return ProjectProfileController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectProfileController\", ProjectProfileController);\n\n ProjectProfileDirective = function($repo, $confirm, $loading, $navurls, $location, projectService, currentUserService) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, form, submit, submitButton;\n $ctrl = $el.controller();\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n var newUrl;\n currentLoading.finish();\n $confirm.notify(\"success\");\n newUrl = $navurls.resolve(\"project-admin-project-profile-details\", {\n project: $scope.project.slug\n });\n $location.path(newUrl);\n $ctrl.loadInitialData();\n projectService.fetchProject();\n return currentUserService.loadProjects();\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectProfile\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$tgNavUrls\", \"$tgLocation\", \"tgProjectService\", \"tgCurrentUserService\", ProjectProfileDirective]);\n\n ProjectDefaultValuesDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectDefaultValues\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", ProjectDefaultValuesDirective]);\n\n ProjectModulesDirective = function($repo, $confirm, $loading, projectService) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n submit = (function(_this) {\n return function() {\n var currentLoading, form, promise, target;\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n target = angular.element(\".admin-functionalities .submit-button\");\n currentLoading = $loading().target(target).start();\n promise = $repo.save($scope.project);\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n $scope.$emit(\"project:loaded\", $scope.project);\n return projectService.fetchProject();\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n return $confirm.notify(\"error\", data._error_message);\n });\n };\n })(this);\n $el.on(\"submit\", \"form\", function(event) {\n event.preventDefault();\n return submit();\n });\n $el.on(\"click\", \".admin-functionalities a.button-green\", function(event) {\n event.preventDefault();\n return submit();\n });\n $scope.$watch(\"isVideoconferenceActivated\", function(isVideoconferenceActivated) {\n if (isVideoconferenceActivated) {\n return $el.find(\".videoconference-attributes\").removeClass(\"hidden\");\n } else {\n $el.find(\".videoconference-attributes\").addClass(\"hidden\");\n $scope.project.videoconferences = null;\n return $scope.project.videoconferences_extra_data = \"\";\n }\n });\n return $scope.$watch(\"project\", function(project) {\n if (project.videoconferences != null) {\n return $scope.isVideoconferenceActivated = true;\n } else {\n return $scope.isVideoconferenceActivated = false;\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectModules\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"tgProjectService\", ProjectModulesDirective]);\n\n ProjectExportDirective = function($window, $rs, $confirm, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var asyn_message, buttonsEl, dump_ready_text, hideButtons, hideResult, hideSpinner, loading_msg, loading_title, resultEl, resultMessageEl, resultTitleEl, setAsyncMessage, setAsyncTitle, setLoadingMessage, setLoadingTitle, setSyncMessage, setSyncTitle, showButtons, showErrorMode, showExportResultAsyncMode, showExportResultSyncMode, showLoadingMode, showResult, showSpinner, spinnerEl, syn_message;\n buttonsEl = $el.find(\".admin-project-export-buttons\");\n showButtons = function() {\n return buttonsEl.removeClass(\"hidden\");\n };\n hideButtons = function() {\n return buttonsEl.addClass(\"hidden\");\n };\n resultEl = $el.find(\".admin-project-export-result\");\n showResult = function() {\n return resultEl.removeClass(\"hidden\");\n };\n hideResult = function() {\n return resultEl.addClass(\"hidden\");\n };\n spinnerEl = $el.find(\".spin\");\n showSpinner = function() {\n return spinnerEl.removeClass(\"hidden\");\n };\n hideSpinner = function() {\n return spinnerEl.addClass(\"hidden\");\n };\n resultTitleEl = $el.find(\".result-title\");\n loading_title = $translate.instant(\"ADMIN.PROJECT_EXPORT.LOADING_TITLE\");\n loading_msg = $translate.instant(\"ADMIN.PROJECT_EXPORT.LOADING_MESSAGE\");\n dump_ready_text = function() {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.DUMP_READY\"));\n };\n asyn_message = function() {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.ASYNC_MESSAGE\"));\n };\n syn_message = function(url) {\n return resultTitleEl.html($translate.instant(\"ADMIN.PROJECT_EXPORT.SYNC_MESSAGE\", {\n url: url\n }));\n };\n setLoadingTitle = function() {\n return resultTitleEl.html(loading_title);\n };\n setAsyncTitle = function() {\n return resultTitleEl.html(loading_msg);\n };\n setSyncTitle = function() {\n return resultTitleEl.html(dump_ready_text);\n };\n resultMessageEl = $el.find(\".result-message \");\n setLoadingMessage = function() {\n return resultMessageEl.html(loading_msg);\n };\n setAsyncMessage = function() {\n return resultMessageEl.html(asyn_message);\n };\n setSyncMessage = function(url) {\n return resultMessageEl.html(syn_message(url));\n };\n showLoadingMode = function() {\n showSpinner();\n setLoadingTitle();\n setLoadingMessage();\n hideButtons();\n return showResult();\n };\n showExportResultAsyncMode = function() {\n hideSpinner();\n setAsyncTitle();\n return setAsyncMessage();\n };\n showExportResultSyncMode = function(url) {\n hideSpinner();\n setSyncTitle();\n return setSyncMessage(url);\n };\n showErrorMode = function() {\n hideSpinner();\n hideResult();\n return showButtons();\n };\n return $el.on(\"click\", \"a.button-export\", debounce(2000, (function(_this) {\n return function(event) {\n var onError, onSuccess;\n event.preventDefault();\n onSuccess = function(result) {\n var dumpUrl;\n if (result.status === 202) {\n return showExportResultAsyncMode();\n } else {\n dumpUrl = result.data.url;\n showExportResultSyncMode(dumpUrl);\n return $window.open(dumpUrl, \"_blank\");\n }\n };\n onError = function(result) {\n var errorMsg, ref;\n showErrorMode();\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR\");\n if (result.status === 429) {\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR_BUSY\");\n } else if ((ref = result.data) != null ? ref._error_message : void 0) {\n errorMsg = $translate.instant(\"ADMIN.PROJECT_EXPORT.ERROR_BUSY\", {\n message: result.data._error_message\n });\n }\n return $confirm.notify(\"error\", errorMsg);\n };\n showLoadingMode();\n return $rs.projects[\"export\"]($scope.projectId).then(onSuccess, onError);\n };\n })(this)));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectExport\", [\"$window\", \"$tgResources\", \"$tgConfirm\", \"$translate\", ProjectExportDirective]);\n\n CsvExporterController = (function(superClass) {\n extend(CsvExporterController, superClass);\n\n CsvExporterController.$inject = [\"$scope\", \"$rootScope\", \"$tgUrls\", \"$tgConfirm\", \"$tgResources\", \"$translate\"];\n\n function CsvExporterController(scope, rootscope, urls, confirm, rs, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.urls = urls;\n this.confirm = confirm;\n this.rs = rs;\n this.translate = translate;\n this._generateUuid = bind(this._generateUuid, this);\n this.setCsvUuid = bind(this.setCsvUuid, this);\n this.rootscope.$on(\"project:loaded\", this.setCsvUuid);\n this.scope.$watch(\"csvUuid\", (function(_this) {\n return function(value) {\n if (value) {\n return _this.scope.csvUrl = _this.urls.resolveAbsolute(_this.type + \"-csv\", value);\n } else {\n return _this.scope.csvUrl = \"\";\n }\n };\n })(this));\n }\n\n CsvExporterController.prototype.setCsvUuid = function() {\n return this.scope.csvUuid = this.scope.project[this.type + \"_csv_uuid\"];\n };\n\n CsvExporterController.prototype._generateUuid = function(response) {\n var promise;\n if (response == null) {\n response = null;\n }\n promise = this.rs.projects[\"regenerate_\" + this.type + \"_csv_uuid\"](this.scope.projectId);\n promise.then((function(_this) {\n return function(data) {\n var ref;\n return _this.scope.csvUuid = (ref = data.data) != null ? ref.uuid : void 0;\n };\n })(this));\n promise.then(null, (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n promise[\"finally\"](function() {\n if (response) {\n return response.finish();\n }\n });\n return promise;\n };\n\n CsvExporterController.prototype.regenerateUuid = function() {\n var subtitle, title;\n if (this.scope.csvUuid) {\n title = this.translate.instant(\"ADMIN.REPORTS.REGENERATE_TITLE\");\n subtitle = this.translate.instant(\"ADMIN.REPORTS.REGENERATE_SUBTITLE\");\n return this.confirm.ask(title, subtitle).then(this._generateUuid);\n } else {\n return this._generateUuid();\n }\n };\n\n return CsvExporterController;\n\n })(taiga.Controller);\n\n CsvExporterUserstoriesController = (function(superClass) {\n extend(CsvExporterUserstoriesController, superClass);\n\n function CsvExporterUserstoriesController() {\n return CsvExporterUserstoriesController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterUserstoriesController.prototype.type = \"userstories\";\n\n return CsvExporterUserstoriesController;\n\n })(CsvExporterController);\n\n CsvExporterTasksController = (function(superClass) {\n extend(CsvExporterTasksController, superClass);\n\n function CsvExporterTasksController() {\n return CsvExporterTasksController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterTasksController.prototype.type = \"tasks\";\n\n return CsvExporterTasksController;\n\n })(CsvExporterController);\n\n CsvExporterIssuesController = (function(superClass) {\n extend(CsvExporterIssuesController, superClass);\n\n function CsvExporterIssuesController() {\n return CsvExporterIssuesController.__super__.constructor.apply(this, arguments);\n }\n\n CsvExporterIssuesController.prototype.type = \"issues\";\n\n return CsvExporterIssuesController;\n\n })(CsvExporterController);\n\n module.controller(\"CsvExporterUserstoriesController\", CsvExporterUserstoriesController);\n\n module.controller(\"CsvExporterTasksController\", CsvExporterTasksController);\n\n module.controller(\"CsvExporterIssuesController\", CsvExporterIssuesController);\n\n CsvUsDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_US\";\n };\n return {\n controller: \"CsvExporterUserstoriesController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvUs\", [\"$translate\", CsvUsDirective]);\n\n CsvTaskDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_TASK\";\n };\n return {\n controller: \"CsvExporterTasksController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvTask\", [\"$translate\", CsvTaskDirective]);\n\n CsvIssueDirective = function($translate) {\n var link;\n link = function($scope) {\n return $scope.sectionTitle = \"ADMIN.CSV.SECTION_TITLE_ISSUE\";\n };\n return {\n controller: \"CsvExporterIssuesController\",\n controllerAs: \"ctrl\",\n templateUrl: \"admin/project-csv.html\",\n link: link,\n scope: true\n };\n };\n\n module.directive(\"tgCsvIssue\", [\"$translate\", CsvIssueDirective]);\n\n ProjectLogoDirective = function($auth, $model, $rs, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var onError, onSuccess, showSizeInfo;\n showSizeInfo = function() {\n return $el.find(\".size-info\").addClass(\"active\");\n };\n onSuccess = function(response) {\n var project;\n project = $model.make_model(\"projects\", response.data);\n $scope.project = project;\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('success');\n };\n onError = function(response) {\n if (response.status === 413) {\n showSizeInfo();\n }\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('error', response.data._error_message);\n };\n $el.on(\"click\", \".js-change-logo\", function() {\n return $el.find(\"#logo-field\").click();\n });\n $el.on(\"change\", \"#logo-field\", function(event) {\n if ($scope.logoAttachment) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.projects.changeLogo($scope.project.id, $scope.logoAttachment).then(onSuccess, onError);\n }\n });\n $el.on(\"click\", \"a.js-use-default-logo\", function(event) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.projects.removeLogo($scope.project.id).then(onSuccess, onError);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectLogo\", [\"$tgAuth\", \"$tgModel\", \"$tgResources\", \"$tgConfirm\", ProjectLogoDirective]);\n\n ProjectLogoModelDirective = function($parse) {\n var link;\n link = function($scope, $el, $attrs) {\n var model, modelSetter;\n model = $parse($attrs.tgProjectLogoModel);\n modelSetter = model.assign;\n return $el.bind('change', function() {\n return $scope.$apply(function() {\n return modelSetter($scope, $el[0].files[0]);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive('tgProjectLogoModel', ['$parse', ProjectLogoModelDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/project-profile.coffee\n */\n\n(function() {\n var ColorSelectionDirective, DATE_TYPE, MULTILINE_TYPE, ProjectCustomAttributesController, ProjectCustomAttributesDirective, ProjectValuesController, ProjectValuesDirective, ProjectValuesSectionController, TEXT_TYPE, TYPE_CHOICES, bindOnce, debounce, groupBy, joinStr, mixOf, module, taiga, toString, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n trim = this.taiga.trim;\n\n toString = this.taiga.toString;\n\n joinStr = this.taiga.joinStr;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaAdmin\");\n\n ProjectValuesSectionController = (function(superClass) {\n extend(ProjectValuesSectionController, superClass);\n\n ProjectValuesSectionController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectValuesSectionController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, sectionName, title;\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.PROJECT_VALUES.PAGE_TITLE\", {\n \"sectionName\": sectionName,\n \"projectName\": _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n ProjectValuesSectionController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ProjectValuesSectionController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n return promise;\n };\n\n return ProjectValuesSectionController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectValuesSectionController\", ProjectValuesSectionController);\n\n ProjectValuesController = (function(superClass) {\n extend(ProjectValuesController, superClass);\n\n ProjectValuesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\"];\n\n function ProjectValuesController(scope, rootscope, repo, confirm, rs) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.moveValue = bind(this.moveValue, this);\n this.loadValues = bind(this.loadValues, this);\n this.scope.$on(\"admin:project-values:move\", this.moveValue);\n this.rootscope.$on(\"project:loaded\", this.loadValues);\n }\n\n ProjectValuesController.prototype.loadValues = function() {\n return this.rs[this.scope.resource].listValues(this.scope.projectId, this.scope.type).then((function(_this) {\n return function(values) {\n _this.scope.values = values;\n _this.scope.maxValueOrder = _.max(values, \"order\").order;\n return values;\n };\n })(this));\n };\n\n ProjectValuesController.prototype.moveValue = function(ctx, itemValue, itemIndex) {\n var r, values;\n values = this.scope.values;\n r = values.indexOf(itemValue);\n values.splice(r, 1);\n values.splice(itemIndex, 0, itemValue);\n _.each(values, function(value, index) {\n return value.order = index;\n });\n return this.repo.saveAll(values);\n };\n\n return ProjectValuesController;\n\n })(taiga.Controller);\n\n module.controller(\"ProjectValuesController\", ProjectValuesController);\n\n ProjectValuesDirective = function($log, $repo, $confirm, $location, animationFrame, $translate, $rootscope) {\n var link, linkDragAndDrop, linkValue;\n linkDragAndDrop = function($scope, $el, $attrs) {\n var itemEl, newParentScope, oldParentScope, tdom;\n oldParentScope = null;\n newParentScope = null;\n itemEl = null;\n tdom = $el.find(\".sortable\");\n tdom.sortable({\n handle: \".row.table-main.visualization\",\n dropOnEmpty: true,\n connectWith: \".project-values-body\",\n revert: 400,\n axis: \"y\"\n });\n tdom.on(\"sortstop\", function(event, ui) {\n var itemIndex, itemValue;\n itemEl = ui.item;\n itemValue = itemEl.scope().value;\n itemIndex = itemEl.index();\n return $scope.$broadcast(\"admin:project-values:move\", itemValue, itemIndex);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n linkValue = function($scope, $el, $attrs) {\n var $ctrl, cancel, goToBottomList, initializeNewValue, initializeTextTranslations, objName, saveNewValue, saveValue, valueType;\n $ctrl = $el.controller();\n valueType = $attrs.type;\n objName = $attrs.objname;\n initializeNewValue = function() {\n return $scope.newValue = {\n \"name\": \"\",\n \"is_closed\": false,\n \"is_archived\": false\n };\n };\n initializeTextTranslations = function() {\n return $scope.addNewElementText = $translate.instant(\"ADMIN.PROJECT_VALUES_\" + (objName.toUpperCase()) + \".ACTION_ADD\");\n };\n initializeNewValue();\n initializeTextTranslations();\n $rootscope.$on(\"$translateChangeEnd\", function() {\n return $scope.$evalAsync(initializeTextTranslations);\n });\n goToBottomList = (function(_this) {\n return function(focus) {\n var table;\n if (focus == null) {\n focus = false;\n }\n table = $el.find(\".table-main\");\n $(document.body).scrollTop(table.offset().top + table.height());\n if (focus) {\n return $el.find(\".new-value input:visible\").first().focus();\n }\n };\n })(this);\n saveValue = function(target) {\n var form, formEl, promise, value;\n formEl = target.parents(\"form\");\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n value = formEl.scope().value;\n promise = $repo.save(value);\n promise.then((function(_this) {\n return function() {\n var row;\n row = target.parents(\".row.table-main\");\n row.addClass(\"hidden\");\n return row.siblings(\".visualization\").removeClass('hidden');\n };\n })(this));\n return promise.then(null, function(data) {\n return form.setErrors(data);\n });\n };\n saveNewValue = function(target) {\n var form, formEl, promise;\n formEl = target.parents(\"form\");\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n $scope.newValue.project = $scope.project.id;\n $scope.newValue.order = $scope.maxValueOrder ? $scope.maxValueOrder + 1 : 1;\n promise = $repo.create(valueType, $scope.newValue);\n promise.then((function(_this) {\n return function(data) {\n target.addClass(\"hidden\");\n $scope.values.push(data);\n $scope.maxValueOrder = data.order;\n return initializeNewValue();\n };\n })(this));\n return promise.then(null, function(data) {\n return form.setErrors(data);\n });\n };\n cancel = function(target) {\n var formEl, row, value;\n row = target.parents(\".row.table-main\");\n formEl = target.parents(\"form\");\n value = formEl.scope().value;\n return $scope.$apply(function() {\n row.addClass(\"hidden\");\n value.revert();\n return row.siblings(\".visualization\").removeClass('hidden');\n });\n };\n $el.on(\"click\", \".show-add-new\", function(event) {\n event.preventDefault();\n $el.find(\".new-value\").removeClass('hidden');\n return goToBottomList(true);\n });\n $el.on(\"click\", \".add-new\", debounce(2000, function(event) {\n var target;\n event.preventDefault();\n target = $el.find(\".new-value\");\n return saveNewValue(target);\n }));\n $el.on(\"click\", \".delete-new\", function(event) {\n event.preventDefault();\n $el.find(\".new-value\").addClass(\"hidden\");\n return initializeNewValue();\n });\n $el.on(\"click\", \".edit-value\", function(event) {\n var editionRow, row, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n row = target.parents(\".row.table-main\");\n row.addClass(\"hidden\");\n editionRow = row.siblings(\".edition\");\n editionRow.removeClass('hidden');\n return editionRow.find('input:visible').first().focus().select();\n });\n $el.on(\"keyup\", \".edition input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n return saveValue(target);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n return cancel(target);\n }\n });\n $el.on(\"keyup\", \".new-value input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = $el.find(\".new-value\");\n return saveNewValue(target);\n } else if (event.keyCode === 27) {\n $el.find(\".new-value\").addClass(\"hidden\");\n return initializeNewValue();\n }\n });\n $el.on(\"click\", \".save\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return saveValue(target);\n });\n $el.on(\"click\", \".cancel\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return cancel(target);\n });\n return $el.on(\"click\", \".delete-value\", function(event) {\n var choices, formEl, subtitle, target, text, title, value;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.parents(\"form\");\n value = formEl.scope().value;\n choices = {};\n _.each($scope.values, function(option) {\n if (value.id !== option.id) {\n return choices[option.id] = option.name;\n }\n });\n subtitle = value.name;\n if (_.keys(choices).length === 0) {\n return $confirm.error($translate.instant(\"ADMIN.PROJECT_VALUES.ERROR_DELETE_ALL\"));\n }\n title = $translate.instant(\"ADMIN.COMMON.TITLE_ACTION_DELETE_VALUE\");\n text = $translate.instant(\"ADMIN.PROJECT_VALUES.REPLACEMENT\");\n return $confirm.askChoice(title, subtitle, choices, text).then(function(response) {\n var onError, onSucces;\n onSucces = function() {\n return $ctrl.loadValues()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n return $repo.remove(value, {\n \"moveTo\": response.selected\n }).then(onSucces, onError);\n });\n });\n };\n link = function($scope, $el, $attrs) {\n linkDragAndDrop($scope, $el, $attrs);\n linkValue($scope, $el, $attrs);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectValues\", [\"$log\", \"$tgRepo\", \"$tgConfirm\", \"$tgLocation\", \"animationFrame\", \"$translate\", \"$rootScope\", ProjectValuesDirective]);\n\n ColorSelectionDirective = function() {\n var link;\n link = function($scope, $el, $attrs, $model) {\n var $ctrl;\n $ctrl = $el.controller();\n $scope.$watch($attrs.ngModel, function(element) {\n return $scope.color = element.color;\n });\n $el.on(\"click\", \".current-color\", function(event) {\n var body, target;\n event.preventDefault();\n event.stopPropagation();\n target = angular.element(event.currentTarget);\n $el.find(\".select-color\").hide();\n target.siblings(\".select-color\").show();\n body = angular.element(\"body\");\n return body.on(\"click\", (function(_this) {\n return function(event) {\n if (angular.element(event.target).parent(\".select-color\").length === 0) {\n $el.find(\".select-color\").hide();\n return body.unbind(\"click\");\n }\n };\n })(this));\n });\n $el.on(\"click\", \".select-color .color\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n $scope.$apply(function() {\n return $model.$modelValue.color = target.data(\"color\");\n });\n return $el.find(\".select-color\").hide();\n });\n $el.on(\"click\", \".select-color .selected-color\", function(event) {\n event.preventDefault();\n $scope.$apply(function() {\n return $model.$modelValue.color = $scope.color;\n });\n return $el.find(\".select-color\").hide();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link,\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgColorSelection\", ColorSelectionDirective);\n\n TEXT_TYPE = \"text\";\n\n MULTILINE_TYPE = \"multiline\";\n\n DATE_TYPE = \"date\";\n\n TYPE_CHOICES = [\n {\n key: TEXT_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT\"\n }, {\n key: MULTILINE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI\"\n }, {\n key: DATE_TYPE,\n name: \"ADMIN.CUSTOM_FIELDS.FIELD_TYPE_DATE\"\n }\n ];\n\n ProjectCustomAttributesController = (function(superClass) {\n extend(ProjectCustomAttributesController, superClass);\n\n ProjectCustomAttributesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function ProjectCustomAttributesController(scope, rootscope, repo, rs, params, q, location, navUrls, appMetaService, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this.moveCustomAttributes = bind(this.moveCustomAttributes, this);\n this.deleteCustomAttribute = bind(this.deleteCustomAttribute, this);\n this.saveCustomAttribute = bind(this.saveCustomAttribute, this);\n this.createCustomAttribute = bind(this.createCustomAttribute, this);\n this.loadCustomAttributes = bind(this.loadCustomAttributes, this);\n this.scope.TYPE_CHOICES = TYPE_CHOICES;\n this.scope.project = {};\n this.rootscope.$on(\"project:loaded\", (function(_this) {\n return function() {\n var description, sectionName, title;\n _this.loadCustomAttributes();\n sectionName = _this.translate.instant(_this.scope.sectionName);\n title = _this.translate.instant(\"ADMIN.CUSTOM_ATTRIBUTES.PAGE_TITLE\", {\n \"sectionName\": sectionName,\n \"projectName\": _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n }\n\n ProjectCustomAttributesController.prototype.loadCustomAttributes = function() {\n return this.rs.customAttributes[this.scope.type].list(this.scope.projectId).then((function(_this) {\n return function(customAttributes) {\n _this.scope.customAttributes = customAttributes;\n _this.scope.maxOrder = _.max(customAttributes, \"order\").order;\n return customAttributes;\n };\n })(this));\n };\n\n ProjectCustomAttributesController.prototype.createCustomAttribute = function(attrValues) {\n return this.repo.create(\"custom-attributes/\" + this.scope.type, attrValues);\n };\n\n ProjectCustomAttributesController.prototype.saveCustomAttribute = function(attrModel) {\n return this.repo.save(attrModel);\n };\n\n ProjectCustomAttributesController.prototype.deleteCustomAttribute = function(attrModel) {\n return this.repo.remove(attrModel);\n };\n\n ProjectCustomAttributesController.prototype.moveCustomAttributes = function(attrModel, newIndex) {\n var customAttributes, r;\n customAttributes = this.scope.customAttributes;\n r = customAttributes.indexOf(attrModel);\n customAttributes.splice(r, 1);\n customAttributes.splice(newIndex, 0, attrModel);\n _.each(customAttributes, function(val, idx) {\n return val.order = idx;\n });\n return this.repo.saveAll(customAttributes);\n };\n\n return ProjectCustomAttributesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"ProjectCustomAttributesController\", ProjectCustomAttributesController);\n\n ProjectCustomAttributesDirective = function($log, $confirm, animationFrame, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl, cancelCreate, cancelUpdate, create, deleteCustomAttribute, hideAddButton, hideCancelButton, hideCreateForm, hideEditForm, resetNewAttr, revertChangesInCustomAttribute, showAddButton, showCancelButton, showCreateForm, showEditForm, sortableEl, update;\n $ctrl = $el.controller();\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n sortableEl = $el.find(\".js-sortable\");\n sortableEl.sortable({\n handle: \".js-view-custom-field\",\n dropOnEmpty: true,\n revert: 400,\n axis: \"y\"\n });\n sortableEl.on(\"sortstop\", function(event, ui) {\n var itemAttr, itemEl, itemIndex;\n itemEl = ui.item;\n itemAttr = itemEl.scope().attr;\n itemIndex = itemEl.index();\n return $ctrl.moveCustomAttributes(itemAttr, itemIndex);\n });\n showCreateForm = function() {\n $el.find(\".js-new-custom-field\").removeClass(\"hidden\");\n return $el.find(\".js-new-custom-field input:visible\").first().focus();\n };\n hideCreateForm = function() {\n return $el.find(\".js-new-custom-field\").addClass(\"hidden\");\n };\n showAddButton = function() {\n return $el.find(\".js-add-custom-field-button\").removeClass(\"hidden\");\n };\n hideAddButton = function() {\n return $el.find(\".js-add-custom-field-button\").addClass(\"hidden\");\n };\n showCancelButton = function() {\n return $el.find(\".js-cancel-new-custom-field-button\").removeClass(\"hidden\");\n };\n hideCancelButton = function() {\n return $el.find(\".js-cancel-new-custom-field-button\").addClass(\"hidden\");\n };\n resetNewAttr = function() {\n return $scope.newAttr = {};\n };\n create = function(formEl) {\n var attr, form, onError, onSucces;\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n onSucces = (function(_this) {\n return function() {\n $ctrl.loadCustomAttributes();\n hideCreateForm();\n resetNewAttr();\n return $confirm.notify(\"success\");\n };\n })(this);\n onError = (function(_this) {\n return function(data) {\n return form.setErrors(data);\n };\n })(this);\n attr = $scope.newAttr;\n attr.project = $scope.projectId;\n attr.order = $scope.maxOrder ? $scope.maxOrder + 1 : 1;\n return $ctrl.createCustomAttribute(attr).then(onSucces, onError);\n };\n cancelCreate = function() {\n hideCreateForm();\n return resetNewAttr();\n };\n $scope.$watch(\"customAttributes\", function(customAttributes) {\n if (!customAttributes) {\n return;\n }\n if (customAttributes.length === 0) {\n hideCancelButton();\n hideAddButton();\n return showCreateForm();\n } else {\n hideCreateForm();\n showAddButton();\n return showCancelButton();\n }\n });\n $el.on(\"click\", \".js-add-custom-field-button\", function(event) {\n event.preventDefault();\n return showCreateForm();\n });\n $el.on(\"click\", \".js-create-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return create(formEl);\n }));\n $el.on(\"click\", \".js-cancel-new-custom-field-button\", function(event) {\n event.preventDefault();\n return cancelCreate();\n });\n $el.on(\"keyup\", \".js-new-custom-field input\", function(event) {\n var formEl, target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return create(formEl);\n } else if (event.keyCode === 27) {\n return cancelCreate();\n }\n });\n showEditForm = function(formEl) {\n formEl.find(\".js-view-custom-field\").addClass(\"hidden\");\n formEl.find(\".js-edit-custom-field\").removeClass(\"hidden\");\n return formEl.find(\".js-edit-custom-field input:visible\").first().focus().select();\n };\n hideEditForm = function(formEl) {\n formEl.find(\".js-edit-custom-field\").addClass(\"hidden\");\n return formEl.find(\".js-view-custom-field\").removeClass(\"hidden\");\n };\n revertChangesInCustomAttribute = function(formEl) {\n return $scope.$apply(function() {\n return formEl.scope().attr.revert();\n });\n };\n update = function(formEl) {\n var attr, form, onError, onSucces;\n form = formEl.checksley();\n if (!form.validate()) {\n return;\n }\n onSucces = (function(_this) {\n return function() {\n $ctrl.loadCustomAttributes();\n hideEditForm(formEl);\n return $confirm.notify(\"success\");\n };\n })(this);\n onError = (function(_this) {\n return function(data) {\n return form.setErrors(data);\n };\n })(this);\n attr = formEl.scope().attr;\n return $ctrl.saveCustomAttribute(attr).then(onSucces, onError);\n };\n cancelUpdate = function(formEl) {\n hideEditForm(formEl);\n return revertChangesInCustomAttribute(formEl);\n };\n $el.on(\"click\", \".js-edit-custom-field-button\", function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return showEditForm(formEl);\n });\n $el.on(\"click\", \".js-update-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return update(formEl);\n }));\n $el.on(\"click\", \".js-cancel-edit-custom-field-button\", function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return cancelUpdate(formEl);\n });\n $el.on(\"keyup\", \".js-edit-custom-field input\", function(event) {\n var formEl, target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return update(formEl);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return cancelUpdate(formEl);\n }\n });\n deleteCustomAttribute = function(formEl) {\n var attr, message, text, title;\n attr = formEl.scope().attr;\n message = attr.name;\n title = $translate.instant(\"COMMON.CUSTOM_ATTRIBUTES.DELETE\");\n text = $translate.instant(\"COMMON.CUSTOM_ATTRIBUTES.CONFIRM_DELETE\");\n return $confirm.ask(title, text, message).then(function(response) {\n var onError, onSucces;\n onSucces = function() {\n return $ctrl.loadCustomAttributes()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return $confirm.notify(\"error\", null, \"We have not been able to delete '\" + message + \"'.\");\n };\n return $ctrl.deleteCustomAttribute(attr).then(onSucces, onError);\n });\n };\n return $el.on(\"click\", \".js-delete-custom-field-button\", debounce(2000, function(event) {\n var formEl, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n formEl = target.closest(\"form\");\n return deleteCustomAttribute(formEl);\n }));\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectCustomAttributes\", [\"$log\", \"$tgConfirm\", \"animationFrame\", \"$translate\", ProjectCustomAttributesDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/memberships.coffee\n */\n\n(function() {\n var EditRoleDirective, NewRoleDirective, RolePermissionsDirective, RolesController, RolesDirective, bindMethods, bindOnce, debounce, mixOf, module, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaAdmin\");\n\n RolesController = (function(superClass) {\n extend(RolesController, superClass);\n\n RolesController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function RolesController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n this._disableComputable = bind(this._disableComputable, this);\n this._enableComputable = bind(this._enableComputable, this);\n bindMethods(this);\n this.scope.sectionName = \"ADMIN.MENU.PERMISSIONS\";\n this.scope.project = {};\n this.scope.anyComputableRole = true;\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.ROLES.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n RolesController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.anyComputableRole = _.some(_.map(project.roles, function(point) {\n return point.computable;\n }));\n return project;\n };\n })(this));\n };\n\n RolesController.prototype.loadRoles = function() {\n return this.rs.roles.list(this.scope.projectId).then((function(_this) {\n return function(roles) {\n var public_permission;\n roles = roles.map(function(role) {\n role.external_user = false;\n return role;\n });\n public_permission = {\n \"name\": _this.translate.instant(\"ADMIN.ROLES.EXTERNAL_USER\"),\n \"permissions\": _this.scope.project.public_permissions,\n \"external_user\": true\n };\n roles.push(public_permission);\n _this.scope.roles = roles;\n _this.scope.role = _this.scope.roles[0];\n return roles;\n };\n })(this));\n };\n\n RolesController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadRoles();\n };\n })(this));\n return promise;\n };\n\n RolesController.prototype.setRole = function(role) {\n this.scope.role = role;\n return this.scope.$broadcast(\"role:changed\", this.scope.role);\n };\n\n RolesController.prototype[\"delete\"] = function() {\n var choices, i, len, ref, replacement, role, subtitle, title, warning;\n choices = {};\n ref = this.scope.roles;\n for (i = 0, len = ref.length; i < len; i++) {\n role = ref[i];\n if (role.id !== this.scope.role.id) {\n choices[role.id] = role.name;\n }\n }\n if (_.keys(choices).length === 0) {\n return this.confirm.error(this.translate.instant(\"ADMIN.ROLES.ERROR_DELETE_ALL\"));\n }\n title = this.translate.instant(\"ADMIN.ROLES.TITLE_DELETE_ROLE\");\n subtitle = this.scope.role.name;\n replacement = this.translate.instant(\"ADMIN.ROLES.REPLACEMENT_ROLE\");\n warning = this.translate.instant(\"ADMIN.ROLES.WARNING_DELETE_ROLE\");\n return this.confirm.askChoice(title, subtitle, choices, replacement, warning).then((function(_this) {\n return function(response) {\n var onError, onSuccess;\n onSuccess = function() {\n _this.loadProject();\n return _this.loadRoles()[\"finally\"](function() {\n return response.finish();\n });\n };\n onError = function() {\n return _this.confirm.notify('error');\n };\n return _this.repo.remove(_this.scope.role, {\n moveTo: response.selected\n }).then(onSuccess, onError);\n };\n })(this));\n };\n\n RolesController.prototype._enableComputable = function() {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.confirm.notify(\"success\");\n return _this.loadProject();\n };\n })(this);\n onError = (function(_this) {\n return function() {\n _this.confirm.notify(\"error\");\n return _this.scope.role.revert();\n };\n })(this);\n return this.repo.save(this.scope.role).then(onSuccess, onError);\n };\n\n RolesController.prototype._disableComputable = function() {\n var askOnError, askOnSuccess, message, subtitle, title;\n askOnSuccess = (function(_this) {\n return function(response) {\n var onError, onSuccess;\n onSuccess = function() {\n response.finish();\n _this.confirm.notify(\"success\");\n return _this.loadProject();\n };\n onError = function() {\n response.finish();\n _this.confirm.notify(\"error\");\n return _this.scope.role.revert();\n };\n return _this.repo.save(_this.scope.role).then(onSuccess, onError);\n };\n })(this);\n askOnError = (function(_this) {\n return function(response) {\n return _this.scope.role.revert();\n };\n })(this);\n title = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_TITLE\");\n subtitle = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_SUBTITLE\", {\n roleName: this.scope.role.name\n });\n message = this.translate.instant(\"ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_MESSAGE\");\n return this.confirm.ask(title, subtitle, message).then(askOnSuccess, askOnError);\n };\n\n RolesController.prototype.toggleComputable = debounce(2000, function() {\n if (!this.scope.role.computable) {\n return this._disableComputable();\n } else {\n return this._enableComputable();\n }\n });\n\n return RolesController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"RolesController\", RolesController);\n\n EditRoleDirective = function($repo, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit, toggleView;\n toggleView = function() {\n $el.find('.total').toggle();\n return $el.find('.edit-role').toggle();\n };\n submit = function() {\n var promise;\n $scope.role.name = $el.find(\"input\").val();\n promise = $repo.save($scope.role);\n promise.then(function() {\n return $confirm.notify(\"success\");\n });\n promise.then(null, function(data) {\n return $confirm.notify(\"error\");\n });\n return toggleView();\n };\n $el.on(\"click\", \"a.icon-edit\", function() {\n toggleView();\n $el.find(\"input\").focus();\n return $el.find(\"input\").val($scope.role.name);\n });\n $el.on(\"click\", \"a.save\", submit);\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return submit();\n } else if (event.keyCode === 27) {\n return toggleView();\n }\n });\n $scope.$on(\"role:changed\", function() {\n if ($el.find('.edit-role').is(\":visible\")) {\n return toggleView();\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgEditRole\", [\"$tgRepo\", \"$tgConfirm\", EditRoleDirective]);\n\n RolesDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRoles\", RolesDirective);\n\n NewRoleDirective = function($tgrepo, $confirm) {\n var DEFAULT_PERMISSIONS, link;\n DEFAULT_PERMISSIONS = [\"view_project\", \"view_milestones\", \"view_us\", \"view_tasks\", \"view_issues\"];\n link = function($scope, $el, $attrs) {\n var $ctrl;\n $ctrl = $el.controller();\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $el.on(\"click\", \"a.add-button\", function(event) {\n event.preventDefault();\n $el.find(\".new\").removeClass(\"hidden\");\n $el.find(\".new\").focus();\n return $el.find(\".add-button\").hide();\n });\n return $el.on(\"keyup\", \".new\", function(event) {\n var newRole, onError, onSuccess, target;\n event.preventDefault();\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n newRole = {\n project: $scope.projectId,\n name: target.val(),\n permissions: DEFAULT_PERMISSIONS,\n order: _.max($scope.roles, function(r) {\n return r.order;\n }).order + 1,\n computable: false\n };\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new\").val('');\n onSuccess = function(role) {\n var insertPosition;\n insertPosition = $scope.roles.length - 1;\n $scope.roles.splice(insertPosition, 0, role);\n $ctrl.setRole(role);\n $el.find(\".add-button\").show();\n return $ctrl.loadProject();\n };\n onError = function() {\n return $confirm.notify(\"error\");\n };\n return $tgrepo.create(\"roles\", newRole).then(onSuccess, onError);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n $el.find(\".new\").addClass(\"hidden\");\n $el.find(\".new\").val('');\n return $el.find(\".add-button\").show();\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNewRole\", [\"$tgRepo\", \"$tgConfirm\", NewRoleDirective]);\n\n RolePermissionsDirective = function($rootscope, $repo, $confirm, $compile) {\n var baseTemplate, categoryTemplate, link, resumeTemplate;\n resumeTemplate = _.template(\"
\\\">
\\n
\\n
<%- category.activePermissions %>/<%- category.permissions.length %>
\\n <% _.each(category.permissions, function(permission) { %>\\n
active<% } %>\\\"\\n title=\\\"{{ '<%- permission.name %>' | translate }}\\\">
\\n <% }) %>\\n
\\n
\");\n categoryTemplate = _.template(\"
\\\">\\n
\\n
\\n
\\n
\\n <% _.each(category.permissions, function(permission) { %>\\n
\\\">\\n \\\">\\n
\\n disabled=\\\"disabled\\\" <% } %>\\n <% if(permission.active) { %> checked=\\\"checked\\\" <% } %>/>\\n
\\n \\n \\n
\\n
\\n <% }) %>\\n
\\n
\\n
\");\n baseTemplate = _.template(\"
\");\n link = function($scope, $el, $attrs) {\n var $ctrl, generateCategoriesFromRole, renderCategory, renderPermissions, renderResume;\n $ctrl = $el.controller();\n generateCategoriesFromRole = function(role) {\n var categories, isPermissionEditable, issuePermissions, milestonePermissions, setActivePermissions, setActivePermissionsPerCategory, taskPermissions, userStoryPermissions, wikiPermissions;\n setActivePermissions = function(permissions) {\n return _.map(permissions, function(x) {\n var ref;\n return _.extend({}, x, {\n active: (ref = x[\"key\"], indexOf.call(role.permissions, ref) >= 0)\n });\n });\n };\n isPermissionEditable = function(permission, role, project) {\n if (role.external_user && !project.is_private && permission.key.indexOf(\"view_\") === 0) {\n return false;\n } else {\n return true;\n }\n };\n setActivePermissionsPerCategory = function(category) {\n return _.map(category, function(cat) {\n cat.permissions = cat.permissions.map(function(permission) {\n permission.editable = isPermissionEditable(permission, role, $scope.project);\n return permission;\n });\n return _.extend({}, cat, {\n activePermissions: _.filter(cat[\"permissions\"], \"active\").length\n });\n });\n };\n categories = [];\n milestonePermissions = [\n {\n key: \"view_milestones\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.VIEW_SPRINTS\"\n }, {\n key: \"add_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.ADD_SPRINTS\"\n }, {\n key: \"modify_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.MODIFY_SPRINTS\"\n }, {\n key: \"delete_milestone\",\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.DELETE_SPRINTS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.SPRINTS.NAME\",\n permissions: setActivePermissions(milestonePermissions)\n });\n userStoryPermissions = [\n {\n key: \"view_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.VIEW_USER_STORIES\"\n }, {\n key: \"add_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.ADD_USER_STORIES\"\n }, {\n key: \"modify_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.MODIFY_USER_STORIES\"\n }, {\n key: \"delete_us\",\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.DELETE_USER_STORIES\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.USER_STORIES.NAME\",\n permissions: setActivePermissions(userStoryPermissions)\n });\n taskPermissions = [\n {\n key: \"view_tasks\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.VIEW_TASKS\"\n }, {\n key: \"add_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.ADD_TASKS\"\n }, {\n key: \"modify_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.MODIFY_TASKS\"\n }, {\n key: \"delete_task\",\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.DELETE_TASKS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.TASKS.NAME\",\n permissions: setActivePermissions(taskPermissions)\n });\n issuePermissions = [\n {\n key: \"view_issues\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.VIEW_ISSUES\"\n }, {\n key: \"add_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.ADD_ISSUES\"\n }, {\n key: \"modify_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.MODIFY_ISSUES\"\n }, {\n key: \"delete_issue\",\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.DELETE_ISSUES\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.ISSUES.NAME\",\n permissions: setActivePermissions(issuePermissions)\n });\n wikiPermissions = [\n {\n key: \"view_wiki_pages\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_PAGES\"\n }, {\n key: \"add_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_PAGES\"\n }, {\n key: \"modify_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.MODIFY_WIKI_PAGES\"\n }, {\n key: \"delete_wiki_page\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_PAGES\"\n }, {\n key: \"view_wiki_links\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.VIEW_WIKI_LINKS\"\n }, {\n key: \"add_wiki_link\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.ADD_WIKI_LINKS\"\n }, {\n key: \"delete_wiki_link\",\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.DELETE_WIKI_LINKS\"\n }\n ];\n categories.push({\n name: \"COMMON.PERMISIONS_CATEGORIES.WIKI.NAME\",\n permissions: setActivePermissions(wikiPermissions)\n });\n return setActivePermissionsPerCategory(categories);\n };\n renderResume = function(element, category) {\n return element.find(\".resume\").html($compile(resumeTemplate({\n category: category\n }))($scope));\n };\n renderCategory = function(category, index) {\n var html;\n html = categoryTemplate({\n category: category,\n index: index\n });\n html = angular.element(html);\n renderResume(html, category);\n return $compile(html)($scope);\n };\n renderPermissions = function() {\n var html;\n $el.off();\n html = baseTemplate();\n _.each(generateCategoriesFromRole($scope.role), function(category, index) {\n return html = angular.element(html).append(renderCategory(category, index));\n });\n $el.html(html);\n $el.on(\"click\", \".resume\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return target.next().toggleClass(\"open\");\n });\n return $el.on(\"change\", \".category-item input\", function(event) {\n var getActivePermissions, onError, onSuccess, target;\n getActivePermissions = function() {\n var activePermissions;\n activePermissions = _.filter($el.find(\".category-item input\"), function(t) {\n return angular.element(t).is(\":checked\");\n });\n activePermissions = _.sortBy(_.map(activePermissions, function(t) {\n var permission;\n return permission = angular.element(t).parents(\".category-item\").data(\"id\");\n }));\n if (activePermissions.length) {\n activePermissions.push(\"view_project\");\n }\n return activePermissions;\n };\n target = angular.element(event.currentTarget);\n $scope.role.permissions = getActivePermissions();\n onSuccess = function() {\n var categories, categoryId;\n categories = generateCategoriesFromRole($scope.role);\n categoryId = target.parents(\".category-config\").data(\"id\");\n renderResume(target.parents(\".category-config\"), categories[categoryId]);\n $rootscope.$broadcast(\"projects:reload\");\n $confirm.notify(\"success\");\n return $ctrl.loadProject();\n };\n onError = function() {\n $confirm.notify(\"error\");\n target.prop(\"checked\", !target.prop(\"checked\"));\n return $scope.role.permissions = getActivePermissions();\n };\n if ($scope.role.external_user) {\n $scope.project.public_permissions = $scope.role.permissions;\n $scope.project.anon_permissions = $scope.role.permissions.filter(function(permission) {\n return permission.indexOf(\"view_\") === 0;\n });\n return $repo.save($scope.project).then(onSuccess, onError);\n } else {\n return $repo.save($scope.role).then(onSuccess, onError);\n }\n });\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n $scope.$on(\"role:changed\", function() {\n return renderPermissions();\n });\n return bindOnce($scope, $attrs.ngModel, renderPermissions);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRolePermissions\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$compile\", RolePermissionsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/admin/third-parties.coffee\n */\n\n(function() {\n var BitbucketController, BitbucketWebhooksDirective, GithubController, GithubWebhooksDirective, GitlabController, GitlabWebhooksDirective, NewWebhookDirective, SelectInputText, ValidOriginIpsDirective, WebhookDirective, WebhooksController, bindMethods, debounce, mixOf, module, taiga, timeout,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindMethods = this.taiga.bindMethods;\n\n debounce = this.taiga.debounce;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaAdmin\");\n\n WebhooksController = (function(superClass) {\n extend(WebhooksController, superClass);\n\n WebhooksController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$tgLocation\", \"$tgNavUrls\", \"tgAppMetaService\", \"$translate\"];\n\n function WebhooksController(scope, repo, rs, params, location, navUrls, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.location = location;\n this.navUrls = navUrls;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = \"ADMIN.WEBHOOKS.SECTION_NAME\";\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.WEBHOOKS.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"webhooks:reload\", this.loadWebhooks);\n }\n\n WebhooksController.prototype.loadWebhooks = function() {\n return this.rs.webhooks.list(this.scope.projectId).then((function(_this) {\n return function(webhooks) {\n return _this.scope.webhooks = webhooks;\n };\n })(this));\n };\n\n WebhooksController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n if (!project.i_am_owner) {\n _this.location.path(_this.navUrls.resolve(\"permission-denied\"));\n }\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n WebhooksController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadWebhooks();\n };\n })(this));\n return promise;\n };\n\n return WebhooksController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"WebhooksController\", WebhooksController);\n\n WebhookDirective = function($rs, $repo, $confirm, $loading, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var cancel, openHistory, save, showEditMode, showVisualizationMode, updateLogs, updateShowHideHistoryText, webhook;\n webhook = $scope.$eval($attrs.tgWebhook);\n updateLogs = function() {\n var prettyDate;\n prettyDate = $translate.instant(\"ADMIN.WEBHOOKS.DATE\");\n return $rs.webhooklogs.list(webhook.id).then((function(_this) {\n return function(webhooklogs) {\n var i, len, log, ref;\n for (i = 0, len = webhooklogs.length; i < len; i++) {\n log = webhooklogs[i];\n log.validStatus = (200 <= (ref = log.status) && ref < 300);\n log.prettySentHeaders = _.map(_.pairs(log.request_headers), function(arg) {\n var header, value;\n header = arg[0], value = arg[1];\n return header + \": \" + value;\n }).join(\"\\n\");\n log.prettySentData = JSON.stringify(log.request_data);\n log.prettyDate = moment(log.created).format(prettyDate);\n }\n webhook.logs_counter = webhooklogs.length;\n webhook.logs = webhooklogs;\n return updateShowHideHistoryText();\n };\n })(this));\n };\n updateShowHideHistoryText = function() {\n var historyElement, text, textElement, title;\n textElement = $el.find(\".toggle-history\");\n historyElement = textElement.parents(\".single-webhook-wrapper\").find(\".webhooks-history\");\n if (historyElement.hasClass(\"open\")) {\n text = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY\");\n title = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_HIDE_HISTORY_TITLE\");\n } else {\n text = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY\");\n title = $translate.instant(\"ADMIN.WEBHOOKS.ACTION_SHOW_HISTORY_TITLE\");\n }\n textElement.text(text);\n return textElement.prop(\"title\", title);\n };\n showVisualizationMode = function() {\n $el.find(\".edition-mode\").addClass(\"hidden\");\n return $el.find(\".visualization-mode\").removeClass(\"hidden\");\n };\n showEditMode = function() {\n $el.find(\".visualization-mode\").addClass(\"hidden\");\n return $el.find(\".edition-mode\").removeClass(\"hidden\");\n };\n openHistory = function() {\n return $el.find(\".webhooks-history\").addClass(\"open\");\n };\n cancel = function() {\n showVisualizationMode();\n return $scope.$apply(function() {\n return webhook.revert();\n });\n };\n save = debounce(2000, function(target) {\n var form, promise;\n form = target.parents(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n promise = $repo.save(webhook);\n promise.then((function(_this) {\n return function() {\n return showVisualizationMode();\n };\n })(this));\n return promise.then(null, function(data) {\n $confirm.notify(\"error\");\n return form.setErrors(data);\n });\n });\n $el.on(\"click\", \".test-webhook\", function() {\n openHistory();\n return $rs.webhooks.test(webhook.id).then((function(_this) {\n return function() {\n return updateLogs();\n };\n })(this));\n });\n $el.on(\"click\", \".edit-webhook\", function() {\n return showEditMode();\n });\n $el.on(\"click\", \".cancel-existing\", function() {\n return cancel();\n });\n $el.on(\"click\", \".edit-existing\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return save(target);\n });\n $el.on(\"keyup\", \".edition-mode input\", function(event) {\n var target;\n if (event.keyCode === 13) {\n target = angular.element(event.currentTarget);\n return save(target);\n } else if (event.keyCode === 27) {\n target = angular.element(event.currentTarget);\n return cancel(target);\n }\n });\n $el.on(\"click\", \".delete-webhook\", function() {\n var message, title;\n title = $translate.instant(\"ADMIN.WEBHOOKS.DELETE\");\n message = $translate.instant(\"ADMIN.WEBHOOKS.WEBHOOK_NAME\", {\n name: webhook.name\n });\n return $confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSucces;\n onSucces = function() {\n askResponse.finish();\n return $scope.$emit(\"webhooks:reload\");\n };\n onError = function() {\n askResponse.finish(false);\n return $confirm.notify(\"error\");\n };\n return $repo.remove(webhook).then(onSucces, onError);\n };\n })(this));\n });\n $el.on(\"click\", \".toggle-history\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n if ((webhook.logs == null) || webhook.logs.length === 0) {\n return updateLogs().then(function() {\n return timeout(0, function() {\n $el.find(\".webhooks-history\").toggleClass(\"open\");\n return updateShowHideHistoryText();\n });\n });\n } else {\n $el.find(\".webhooks-history\").toggleClass(\"open\");\n return $scope.$apply(function() {\n return updateShowHideHistoryText();\n });\n }\n });\n $el.on(\"click\", \".history-single\", function(event) {\n var target;\n target = angular.element(event.currentTarget);\n target.toggleClass(\"history-single-open\");\n return target.siblings(\".history-single-response\").toggleClass(\"open\");\n });\n return $el.on(\"click\", \".resend-request\", function(event) {\n var log, target;\n target = angular.element(event.currentTarget);\n log = target.data(\"log\");\n return $rs.webhooklogs.resend(log).then((function(_this) {\n return function() {\n return updateLogs();\n };\n })(this));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgWebhook\", [\"$tgResources\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", \"$translate\", WebhookDirective]);\n\n NewWebhookDirective = function($rs, $repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var addWebhookDOMNode, formDOMNode, initializeNewValue, save, webhook;\n webhook = $scope.$eval($attrs.tgWebhook);\n formDOMNode = $el.find(\".new-webhook-form\");\n addWebhookDOMNode = $el.find(\".add-webhook\");\n initializeNewValue = function() {\n return $scope.newValue = {\n \"name\": \"\",\n \"url\": \"\",\n \"key\": \"\"\n };\n };\n initializeNewValue();\n $scope.$watch(\"webhooks\", function(webhooks) {\n if (webhooks != null) {\n if (webhooks.length === 0) {\n formDOMNode.removeClass(\"hidden\");\n addWebhookDOMNode.addClass(\"hidden\");\n return formDOMNode.find(\"input\")[0].focus();\n } else {\n formDOMNode.addClass(\"hidden\");\n return addWebhookDOMNode.removeClass(\"hidden\");\n }\n }\n });\n save = debounce(2000, function() {\n var form, promise;\n form = formDOMNode.checksley();\n if (!form.validate()) {\n return;\n }\n $scope.newValue.project = $scope.project.id;\n promise = $repo.create(\"webhooks\", $scope.newValue);\n promise.then((function(_this) {\n return function() {\n $scope.$emit(\"webhooks:reload\");\n return initializeNewValue();\n };\n })(this));\n return promise.then(null, function(data) {\n $confirm.notify(\"error\");\n return form.setErrors(data);\n });\n });\n formDOMNode.on(\"click\", \".add-new\", function(event) {\n event.preventDefault();\n return save();\n });\n formDOMNode.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return save();\n }\n });\n formDOMNode.on(\"click\", \".cancel-new\", function(event) {\n return $scope.$apply(function() {\n return initializeNewValue();\n });\n });\n return addWebhookDOMNode.on(\"click\", function(event) {\n formDOMNode.removeClass(\"hidden\");\n return formDOMNode.find(\"input\")[0].focus();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNewWebhook\", [\"$tgResources\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", NewWebhookDirective]);\n\n GithubController = (function(superClass) {\n extend(GithubController, superClass);\n\n GithubController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function GithubController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.GITHUB.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.GITHUB.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n GithubController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"github\").then((function(_this) {\n return function(github) {\n return _this.scope.github = github;\n };\n })(this));\n };\n\n GithubController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n GithubController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return GithubController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"GithubController\", GithubController);\n\n GitlabController = (function(superClass) {\n extend(GitlabController, superClass);\n\n GitlabController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function GitlabController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.GITLAB.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.GITLAB.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:modules:reload\", (function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n }\n\n GitlabController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"gitlab\").then((function(_this) {\n return function(gitlab) {\n return _this.scope.gitlab = gitlab;\n };\n })(this));\n };\n\n GitlabController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n GitlabController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return GitlabController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"GitlabController\", GitlabController);\n\n BitbucketController = (function(superClass) {\n extend(BitbucketController, superClass);\n\n BitbucketController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"tgAppMetaService\", \"$translate\"];\n\n function BitbucketController(scope, repo, rs, params, appMetaService, translate) {\n var promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.appMetaService = appMetaService;\n this.translate = translate;\n bindMethods(this);\n this.scope.sectionName = this.translate.instant(\"ADMIN.BITBUCKET.SECTION_NAME\");\n this.scope.project = {};\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n var description, title;\n title = _this.translate.instant(\"ADMIN.BITBUCKET.PAGE_TITLE\", {\n projectName: _this.scope.project.name\n });\n description = _this.scope.project.description;\n return _this.appMetaService.setAll(title, description);\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.$on(\"project:modules:reload\", (function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n }\n\n BitbucketController.prototype.loadModules = function() {\n return this.rs.modules.list(this.scope.projectId, \"bitbucket\").then((function(_this) {\n return function(bitbucket) {\n return _this.scope.bitbucket = bitbucket;\n };\n })(this));\n };\n\n BitbucketController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n BitbucketController.prototype.loadInitialData = function() {\n var promise;\n promise = this.loadProject();\n promise.then((function(_this) {\n return function() {\n return _this.loadModules();\n };\n })(this));\n return promise;\n };\n\n return BitbucketController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n module.controller(\"BitbucketController\", BitbucketController);\n\n SelectInputText = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.on(\"click\", \".select-input-content\", function() {\n $el.find(\"input\").select();\n return $el.find(\".help-copy\").addClass(\"visible\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSelectInputText\", SelectInputText);\n\n GithubWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.github, \"github\");\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify(\"success\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgGithubWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", GithubWebhooksDirective]);\n\n GitlabWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.gitlab, \"gitlab\");\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n return $scope.$emit(\"project:modules:reload\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgGitlabWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", GitlabWebhooksDirective]);\n\n BitbucketWebhooksDirective = function($repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.saveAttribute($scope.bitbucket, \"bitbucket\");\n promise.then(function() {\n currentLoading.finish();\n $confirm.notify(\"success\");\n return $scope.$emit(\"project:modules:reload\");\n });\n return promise.then(null, function(data) {\n currentLoading.finish();\n form.setErrors(data);\n if (data._error_message) {\n return $confirm.notify(\"error\", data._error_message);\n }\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n return $el.on(\"submit\", \"form\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgBitbucketWebhooks\", [\"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", BitbucketWebhooksDirective]);\n\n ValidOriginIpsDirective = function() {\n var link;\n link = function($scope, $el, $attrs, $ngModel) {\n return $ngModel.$parsers.push(function(value) {\n value = $.trim(value);\n if (value === \"\") {\n return [];\n }\n return value.split(\",\");\n });\n };\n return {\n link: link,\n restrict: \"EA\",\n require: \"ngModel\"\n };\n };\n\n module.directive(\"tgValidOriginIps\", ValidOriginIpsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/attachments.coffee\n */\n\n(function() {\n var CreateProject, DeleteProjectDirective, bindOnce, debounce, module, taiga, timeout;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n timeout = this.taiga.timeout;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaProject\");\n\n CreateProject = function($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, $loading, lightboxService, $cacheFactory, $translate, currentUserService) {\n var directive, link;\n link = function($scope, $el, attrs) {\n var currentLoading, form, onErrorSubmit, onSuccessSubmit, openLightbox, submit, submitButton;\n $scope.data = {};\n $scope.templates = [];\n currentLoading = null;\n form = $el.find(\"form\").checksley({\n \"onlyOneErrorElement\": true\n });\n onSuccessSubmit = function(response) {\n $cacheFactory.get('$http').removeAll();\n currentLoading.finish();\n $rootscope.$broadcast(\"projects:reload\");\n $confirm.notify(\"success\", $translate.instant(\"COMMON.SAVE\"));\n $location.url($projectUrl.get(response));\n lightboxService.close($el);\n return currentUserService.loadProjects();\n };\n onErrorSubmit = function(response) {\n var error_field, error_step, i, len, ref, selectors;\n currentLoading.finish();\n form.setErrors(response);\n selectors = [];\n ref = _.keys(response);\n for (i = 0, len = ref.length; i < len; i++) {\n error_field = ref[i];\n selectors.push(\"[name=\" + error_field + \"]\");\n }\n $el.find(\".active\").removeClass(\"active\");\n error_step = $el.find(selectors.join(\",\")).first().parents(\".wizard-step\");\n error_step.addClass(\"active\");\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(error_step.data(\"step\"));\n };\n submit = (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $repo.create(\"projects\", $scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this);\n openLightbox = function() {\n $scope.data = {};\n if (!$scope.templates.length) {\n $rs.projects.templates().then((function(_this) {\n return function(result) {\n $scope.templates = result;\n return $scope.data.creation_template = _.head(_.filter($scope.templates, function(x) {\n return x.slug === \"scrum\";\n })).id;\n };\n })(this));\n } else {\n $scope.data.creation_template = _.head(_.filter($scope.templates, function(x) {\n return x.slug === \"scrum\";\n })).id;\n }\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\".create-step1\").addClass(\"active\");\n lightboxService.open($el);\n return timeout(600, function() {\n return $el.find(\".progress-bar\").addClass('step1');\n });\n };\n $el.on(\"click\", \".button-next\", function(event) {\n var current, field, i, len, next, ref, step, valid;\n event.preventDefault();\n current = $el.find(\".active\");\n valid = true;\n ref = form.fields;\n for (i = 0, len = ref.length; i < len; i++) {\n field = ref[i];\n if (current.find(\"[name=\" + (field.element.attr('name')) + \"]\").length) {\n valid = field.validate() !== false && valid;\n }\n }\n if (!valid) {\n return;\n }\n next = current.next();\n current.toggleClass('active');\n next.toggleClass('active');\n step = next.data('step');\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(step);\n });\n $el.on(\"click\", \".button-prev\", function(event) {\n var current, prev, step;\n event.preventDefault();\n current = $el.find(\".active\");\n prev = current.prev();\n current.toggleClass('active');\n prev.toggleClass('active');\n step = prev.data('step');\n return $el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(step);\n });\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".close\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return openLightbox();\n };\n directive = {\n link: link,\n templateUrl: \"project/wizard-create-project.html\",\n scope: {}\n };\n return directive;\n };\n\n module.directive(\"tgLbCreateProject\", [\"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$location\", \"$tgNavUrls\", \"$tgResources\", \"$projectUrl\", \"$tgLoading\", \"lightboxService\", \"$cacheFactory\", \"$translate\", \"tgCurrentUserService\", CreateProject]);\n\n DeleteProjectDirective = function($repo, $rootscope, $auth, $location, $navUrls, $confirm, lightboxService, tgLoader, currentUserService) {\n var link;\n link = function($scope, $el, $attrs) {\n var projectToDelete, submit;\n projectToDelete = null;\n $scope.$on(\"deletelightbox:new\", function(ctx, project) {\n lightboxService.open($el);\n return projectToDelete = project;\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n submit = function() {\n var promise;\n tgLoader.start();\n lightboxService.close($el);\n promise = $repo.remove(projectToDelete);\n promise.then(function(data) {\n tgLoader.pageLoaded();\n $rootscope.$broadcast(\"projects:reload\");\n $location.path($navUrls.resolve(\"home\"));\n $confirm.notify(\"success\");\n return currentUserService.loadProjects();\n });\n return promise.then(null, function() {\n $confirm.notify(\"error\");\n return lightboxService.close($el);\n });\n };\n $el.on(\"click\", \".button-red\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n return $el.on(\"click\", \".button-green\", function(event) {\n event.preventDefault();\n return submit();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbDeleteProject\", [\"$tgRepo\", \"$rootScope\", \"$tgAuth\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfirm\", \"lightboxService\", \"tgLoader\", \"tgCurrentUserService\", DeleteProjectDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/bind.coffee\n */\n\n(function() {\n var BindHtmlDirective, BindOnceAltDirective, BindOnceBindDirective, BindOnceHrefDirective, BindOnceHtmlDirective, BindOnceRefDirective, BindOnceSrcDirective, BindOnceTitleDirective, BindTitleDirective, bindOnce, module;\n\n bindOnce = this.taiga.bindOnce;\n\n BindOnceBindDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoBind, function(val) {\n return $el.text(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHtml, function(val) {\n return $el.html(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceRefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoRef, function(val) {\n return $el.html(\"#\" + val + \" \");\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceSrcDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoSrc, function(val) {\n return $el.attr(\"src\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHrefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHref, function(val) {\n return $el.attr(\"href\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceAltDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoAlt, function(val) {\n return $el.attr(\"alt\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoTitle, function(val) {\n return $el.attr(\"title\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgTitleHtml, function(val) {\n if (val != null) {\n return $el.attr(\"title\", val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n BindHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgBindHtml, function(val) {\n if (val != null) {\n return $el.html(val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaBase\");\n\n module.directive(\"tgBoBind\", BindOnceBindDirective);\n\n module.directive(\"tgBoHtml\", BindOnceHtmlDirective);\n\n module.directive(\"tgBoRef\", BindOnceRefDirective);\n\n module.directive(\"tgBoSrc\", BindOnceSrcDirective);\n\n module.directive(\"tgBoHref\", BindOnceHrefDirective);\n\n module.directive(\"tgBoAlt\", BindOnceAltDirective);\n\n module.directive(\"tgBoTitle\", BindOnceTitleDirective);\n\n module.directive(\"tgBindTitle\", BindTitleDirective);\n\n module.directive(\"tgBindHtml\", BindHtmlDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/conf.coffee\n */\n\n(function() {\n var ConfigurationService, module;\n\n ConfigurationService = (function() {\n function ConfigurationService() {\n this.config = window.taigaConfig;\n }\n\n ConfigurationService.prototype.get = function(key, defaultValue) {\n if (defaultValue == null) {\n defaultValue = null;\n }\n if (_.has(this.config, key)) {\n return this.config[key];\n }\n return defaultValue;\n };\n\n return ConfigurationService;\n\n })();\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgConfig\", ConfigurationService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/contrib.coffee\n */\n\n(function() {\n var ContribController, module,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n module = angular.module(\"taigaBase\");\n\n ContribController = (function(superClass) {\n extend(ContribController, superClass);\n\n ContribController.$inject = [\"$rootScope\", \"$scope\", \"$routeParams\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\"];\n\n function ContribController(rootScope, scope, params, repo, rs, confirm) {\n var promise;\n this.rootScope = rootScope;\n this.scope = scope;\n this.params = params;\n this.repo = repo;\n this.rs = rs;\n this.confirm = confirm;\n this.scope.currentPlugin = _.first(_.where(this.rootScope.adminPlugins, {\n \"slug\": this.params.plugin\n }));\n this.scope.projectSlug = this.params.pslug;\n promise = this.loadInitialData();\n promise.then(null, (function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n }\n\n ContribController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.$broadcast('project:loaded', project);\n return project;\n };\n })(this));\n };\n\n ContribController.prototype.loadInitialData = function() {\n return this.loadProject();\n };\n\n return ContribController;\n\n })(taiga.Controller);\n\n module.controller(\"ContribController\", ContribController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/filters.coffee\n */\n\n(function() {\n var FiltersStorageService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n FiltersStorageService = (function(superClass) {\n extend(FiltersStorageService, superClass);\n\n FiltersStorageService.$inject = [\"$tgStorage\", \"$routeParams\"];\n\n function FiltersStorageService(storage, params) {\n this.storage = storage;\n this.params = params;\n }\n\n FiltersStorageService.prototype.generateHash = function(components) {\n if (components == null) {\n components = [];\n }\n components = _.map(components, function(x) {\n return JSON.stringify(x);\n });\n return hex_sha1(components.join(\":\"));\n };\n\n return FiltersStorageService;\n\n })(taiga.Service);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var HttpService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n HttpService = (function(superClass) {\n extend(HttpService, superClass);\n\n HttpService.$inject = [\"$http\", \"$q\", \"$tgStorage\", \"$rootScope\", \"$cacheFactory\", \"$translate\"];\n\n function HttpService(http, q, storage, rootScope, cacheFactory, translate) {\n this.http = http;\n this.q = q;\n this.storage = storage;\n this.rootScope = rootScope;\n this.cacheFactory = cacheFactory;\n this.translate = translate;\n HttpService.__super__.constructor.call(this);\n this.cache = this.cacheFactory(\"httpget\");\n }\n\n HttpService.prototype.headers = function() {\n var headers, lang, token;\n headers = {};\n token = this.storage.get('token');\n if (token) {\n headers[\"Authorization\"] = \"Bearer \" + token;\n }\n lang = this.translate.preferredLanguage();\n if (lang) {\n headers[\"Accept-Language\"] = lang;\n }\n return headers;\n };\n\n HttpService.prototype.request = function(options) {\n options.headers = _.merge({}, options.headers || {}, this.headers());\n return this.http(options);\n };\n\n HttpService.prototype.get = function(url, params, options) {\n options = _.merge({\n method: \"GET\",\n url: url\n }, options);\n if (params) {\n options.params = params;\n }\n options.cache = this.cache;\n return this.request(options)[\"finally\"]((function(_this) {\n return function(data) {\n return _this.cache.removeAll();\n };\n })(this));\n };\n\n HttpService.prototype.post = function(url, data, params, options) {\n options = _.merge({\n method: \"POST\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.put = function(url, data, params, options) {\n options = _.merge({\n method: \"PUT\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.patch = function(url, data, params, options) {\n options = _.merge({\n method: \"PATCH\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype[\"delete\"] = function(url, data, params, options) {\n options = _.merge({\n method: \"DELETE\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n return HttpService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgHttp\", HttpService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/location.coffee\n */\n\n(function() {\n var locationFactory, module;\n\n locationFactory = function($location, $route, $rootscope) {\n $location.noreload = function(scope) {\n var lastRoute, un;\n lastRoute = $route.current;\n un = scope.$on(\"$locationChangeSuccess\", function() {\n $route.current = lastRoute;\n return un();\n });\n return $location;\n };\n $location.isInCurrentRouteParams = function(name, value) {\n var params;\n params = $location.search() || {};\n return params[name] === value;\n };\n return $location;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgLocation\", [\"$location\", \"$route\", \"$rootScope\", locationFactory]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/model.coffee\n */\n\n(function() {\n var Model, ModelService, module, provider, taiga,\n indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n Model = (function() {\n function Model(name, data, dataTypes) {\n this._attrs = data;\n this._name = name;\n this._dataTypes = dataTypes;\n this.setAttrs(data);\n this.initialize();\n }\n\n Model.prototype.clone = function() {\n var instance;\n instance = new Model(this._name, this._attrs, this._dataTypes);\n instance._modifiedAttrs = this._modifiedAttrs;\n instance._isModified = this._isModified;\n return instance;\n };\n\n Model.prototype.applyCasts = function() {\n var attrName, castMethod, castName, ref, results;\n ref = this._dataTypes;\n results = [];\n for (attrName in ref) {\n castName = ref[attrName];\n castMethod = service.casts[castName];\n if (!castMethod) {\n continue;\n }\n results.push(this._attrs[attrName] = castMethod(this._attrs[attrName]));\n }\n return results;\n };\n\n Model.prototype.getIdAttrName = function() {\n return \"id\";\n };\n\n Model.prototype.getName = function() {\n return this._name;\n };\n\n Model.prototype.getAttrs = function(patch) {\n if (patch == null) {\n patch = false;\n }\n if (this._attrs.version != null) {\n this._modifiedAttrs.version = this._attrs.version;\n }\n if (patch) {\n return _.extend({}, this._modifiedAttrs);\n }\n return _.extend({}, this._attrs, this._modifiedAttrs);\n };\n\n Model.prototype.setAttrs = function(attrs) {\n this._attrs = attrs;\n this._modifiedAttrs = {};\n this.applyCasts();\n return this._isModified = false;\n };\n\n Model.prototype.setAttr = function(name, value) {\n this._modifiedAttrs[name] = value;\n return this._isModified = true;\n };\n\n Model.prototype.initialize = function() {\n var getter, self, setter;\n self = this;\n getter = function(name) {\n return function() {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n return self[name];\n }\n if (indexOf.call(_.keys(self._modifiedAttrs), name) < 0) {\n return self._attrs[name];\n }\n return self._modifiedAttrs[name];\n };\n };\n setter = function(name) {\n return function(value) {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n self[name] = value;\n return;\n }\n if (self._attrs[name] !== value) {\n self._modifiedAttrs[name] = value;\n self._isModified = true;\n } else {\n delete self._modifiedAttrs[name];\n }\n };\n };\n return _.each(this._attrs, function(value, name) {\n var options;\n options = {\n get: getter(name),\n set: setter(name),\n enumerable: true,\n configurable: true\n };\n return Object.defineProperty(self, name, options);\n });\n };\n\n Model.prototype.serialize = function() {\n var data;\n data = {\n \"data\": _.clone(this._attrs),\n \"name\": this._name\n };\n return JSON.stringify(data);\n };\n\n Model.prototype.isModified = function() {\n return this._isModified;\n };\n\n Model.prototype.isAttributeModified = function(attribute) {\n return this._modifiedAttrs[attribute] != null;\n };\n\n Model.prototype.markSaved = function() {\n this._isModified = false;\n this._attrs = this.getAttrs();\n return this._modifiedAttrs = {};\n };\n\n Model.prototype.revert = function() {\n this._modifiedAttrs = {};\n return this._isModified = false;\n };\n\n Model.desSerialize = function(sdata) {\n var ddata, model;\n ddata = JSON.parse(sdata);\n model = new Model(ddata.url, ddata.data);\n return model;\n };\n\n return Model;\n\n })();\n\n taiga = this.taiga;\n\n ModelService = (function(superClass) {\n extend(ModelService, superClass);\n\n ModelService.$inject = [\"$q\", \"$tgUrls\", \"$tgStorage\", \"$tgHttp\"];\n\n function ModelService(q, urls, storage, http) {\n this.q = q;\n this.urls = urls;\n this.storage = storage;\n this.http = http;\n ModelService.__super__.constructor.call(this);\n }\n\n return ModelService;\n\n })(taiga.Service);\n\n provider = function($q, $http, $gmUrls, $gmStorage) {\n var service;\n service = {};\n service.make_model = function(name, data, cls, dataTypes) {\n if (cls == null) {\n cls = Model;\n }\n if (dataTypes == null) {\n dataTypes = {};\n }\n return new cls(name, data, dataTypes);\n };\n service.cls = Model;\n service.casts = {\n int: function(value) {\n return parseInt(value, 10);\n },\n float: function(value) {\n return parseFloat(value, 10);\n }\n };\n return service;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgModel\", [\"$q\", \"$http\", \"$tgUrls\", \"$tgStorage\", provider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/navurl.coffee\n */\n\n(function() {\n var NavigationUrlsDirective, NavigationUrlsService, bindOnce, module, taiga, trim,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\");\n\n NavigationUrlsService = (function(superClass) {\n extend(NavigationUrlsService, superClass);\n\n function NavigationUrlsService() {\n this.urls = {};\n }\n\n NavigationUrlsService.prototype.update = function(urls) {\n return this.urls = _.merge({}, this.urls, urls || {});\n };\n\n NavigationUrlsService.prototype.formatUrl = function(url, ctx) {\n var replacer;\n if (ctx == null) {\n ctx = {};\n }\n replacer = function(match) {\n match = trim(match, \":\");\n return ctx[match] || \"undefined\";\n };\n return url.replace(/(:\\w+)/g, replacer);\n };\n\n NavigationUrlsService.prototype.resolve = function(name, ctx) {\n var url;\n url = this.urls[name];\n if (!url) {\n return \"\";\n }\n if (ctx) {\n return this.formatUrl(url, ctx);\n }\n return url;\n };\n\n return NavigationUrlsService;\n\n })(taiga.Service);\n\n module.service(\"$tgNavUrls\", NavigationUrlsService);\n\n NavigationUrlsDirective = function($navurls, $auth, $q, $location) {\n var bindOnceP, link, parseNav;\n bindOnceP = function($scope, attr) {\n var defered;\n defered = $q.defer();\n bindOnce($scope, attr, function(v) {\n return defered.resolve(v);\n });\n return defered.promise;\n };\n parseNav = function(data, $scope) {\n var index, name, obj, params, promises, ref, result, values;\n ref = _.map(data.split(\":\"), trim), name = ref[0], params = ref[1];\n if (params) {\n result = params.split(/(\\w+)=/);\n result = _.filter(result, function(str) {\n return str.length;\n });\n result = _.map(result, function(str) {\n return trim(str.replace(/,$/g, ''));\n });\n params = [];\n index = 0;\n while (index < result.length) {\n obj = {};\n obj[result[index]] = result[index + 1];\n params.push(obj);\n index = index + 2;\n }\n } else {\n params = [];\n }\n values = _.map(params, function(param) {\n return _.values(param)[0];\n });\n promises = _.map(values, function(x) {\n return bindOnceP($scope, x);\n });\n return $q.all(promises).then(function() {\n var i, key, len, options, param, value;\n options = {};\n for (i = 0, len = params.length; i < len; i++) {\n param = params[i];\n key = Object.keys(param)[0];\n value = param[key];\n options[key] = $scope.$eval(value);\n }\n return [name, options];\n });\n };\n link = function($scope, $el, $attrs) {\n if ($el.is(\"a\")) {\n $el.attr(\"href\", \"#\");\n }\n $el.on(\"mouseenter\", function(event) {\n var target;\n target = $(event.currentTarget);\n if (!target.data(\"fullUrl\") || $attrs.tgNavGetParams !== target.data(\"params\")) {\n return parseNav($attrs.tgNav, $scope).then(function(result) {\n var fullUrl, getURLParams, getURLParamsStr, name, options, url, user;\n name = result[0], options = result[1];\n user = $auth.getUser();\n if (user) {\n options.user = user.username;\n }\n url = $navurls.resolve(name);\n fullUrl = $navurls.formatUrl(url, options);\n if ($attrs.tgNavGetParams) {\n getURLParams = JSON.parse($attrs.tgNavGetParams);\n getURLParamsStr = $.param(getURLParams);\n fullUrl = fullUrl + \"?\" + getURLParamsStr;\n target.data(\"params\", $attrs.tgNavGetParams);\n }\n target.data(\"fullUrl\", fullUrl);\n if (target.is(\"a\")) {\n target.attr(\"href\", fullUrl);\n }\n return $el.on(\"click\", function(event) {\n if (event.metaKey || event.ctrlKey) {\n return;\n }\n event.preventDefault();\n target = $(event.currentTarget);\n if (target.hasClass('noclick')) {\n return;\n }\n fullUrl = target.data(\"fullUrl\");\n switch (event.which) {\n case 1:\n $location.url(fullUrl);\n return $scope.$apply();\n case 2:\n return window.open(fullUrl);\n }\n });\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNav\", [\"$tgNavUrls\", \"$tgAuth\", \"$q\", \"$tgLocation\", NavigationUrlsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/repository.coffee\n */\n\n(function() {\n var RepositoryService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n RepositoryService = (function(superClass) {\n extend(RepositoryService, superClass);\n\n RepositoryService.$inject = [\"$q\", \"$tgModel\", \"$tgStorage\", \"$tgHttp\", \"$tgUrls\"];\n\n function RepositoryService(q, model1, storage, http, urls) {\n this.q = q;\n this.model = model1;\n this.storage = storage;\n this.http = http;\n this.urls = urls;\n RepositoryService.__super__.constructor.call(this);\n }\n\n RepositoryService.prototype.resolveUrlForModel = function(model) {\n var idAttrName;\n idAttrName = model.getIdAttrName();\n return (this.urls.resolve(model.getName())) + \"/\" + model[idAttrName];\n };\n\n RepositoryService.prototype.resolveUrlForAttributeModel = function(model) {\n return this.urls.resolve(model.getName(), model.parent);\n };\n\n RepositoryService.prototype.create = function(name, data, dataTypes, extraParams) {\n var defered, promise, url;\n if (dataTypes == null) {\n dataTypes = {};\n }\n if (extraParams == null) {\n extraParams = {};\n }\n defered = this.q.defer();\n url = this.urls.resolve(name);\n promise = this.http.post(url, JSON.stringify(data));\n promise.success((function(_this) {\n return function(_data, _status) {\n return defered.resolve(_this.model.make_model(name, _data, null, dataTypes));\n };\n })(this));\n promise.error((function(_this) {\n return function(data, status) {\n return defered.reject(data);\n };\n })(this));\n return defered.promise;\n };\n\n RepositoryService.prototype.remove = function(model, params) {\n var defered, promise, url;\n if (params == null) {\n params = {};\n }\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http[\"delete\"](url, {}, params);\n promise.success(function(data, status) {\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(model);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAll = function(models, patch) {\n var promises;\n if (patch == null) {\n patch = true;\n }\n promises = _.map(models, (function(_this) {\n return function(x) {\n return _this.save(x, true);\n };\n })(this));\n return this.q.all(promises);\n };\n\n RepositoryService.prototype.save = function(model, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForModel(model);\n data = JSON.stringify(model.getAttrs(patch));\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAttribute = function(model, attribute, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForAttributeModel(model);\n data = {};\n data[attribute] = model.getAttrs();\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.refresh = function(model) {\n var defered, promise, url;\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http.get(url);\n promise.success(function(data, status) {\n model._modifiedAttrs = {};\n model._attrs = data;\n model._isModified = false;\n model.applyCasts();\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.queryMany = function(name, params, options, headers) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n if (headers == null) {\n headers = false;\n }\n url = this.urls.resolve(name);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var result;\n result = _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n if (headers) {\n return [result, data.headers];\n }\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneAttribute = function(name, id, attribute, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name, id);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var model;\n model = _this.model.make_model(name, data.data[attribute]);\n model.parent = id;\n return model;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOne = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return _this.model.make_model(name, data.data);\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneRaw = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = _.merge({\n headers: {}\n }, options);\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryPaginated = function(name, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n httpOptions = _.merge({\n headers: {}\n }, options);\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var headers, result;\n headers = data.headers();\n result = {};\n result.models = _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n result.count = parseInt(headers[\"x-pagination-count\"], 10);\n result.current = parseInt(headers[\"x-pagination-current\"] || 1, 10);\n result.paginatedBy = parseInt(headers[\"x-paginated-by\"], 10);\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOnePaginatedRaw = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = url + \"/\" + id;\n }\n httpOptions = _.merge({\n headers: {}\n }, options);\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var headers, result;\n headers = data.headers();\n result = {};\n result.data = data.data;\n result.count = parseInt(headers[\"x-pagination-count\"], 10);\n result.current = parseInt(headers[\"x-pagination-current\"] || 1, 10);\n result.paginatedBy = parseInt(headers[\"x-paginated-by\"], 10);\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.resolve = function(options) {\n var cache, params;\n params = {};\n if (options.pslug != null) {\n params.project = options.pslug;\n }\n if (options.usref != null) {\n params.us = options.usref;\n }\n if (options.taskref != null) {\n params.task = options.taskref;\n }\n if (options.issueref != null) {\n params.issue = options.issueref;\n }\n if (options.sslug != null) {\n params.milestone = options.sslug;\n }\n if (options.wikipage != null) {\n params.wikipage = options.wikipage;\n }\n cache = !(options.wikipage || options.sslug);\n return this.queryOneRaw(\"resolver\", null, params, {\n cache: cache\n });\n };\n\n return RepositoryService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgRepo\", RepositoryService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/storage.coffee\n */\n\n(function() {\n var StorageService, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n StorageService = (function(superClass) {\n extend(StorageService, superClass);\n\n StorageService.$inject = [\"$rootScope\"];\n\n function StorageService($rootScope) {\n StorageService.__super__.constructor.call(this);\n }\n\n StorageService.prototype.get = function(key, _default) {\n var serializedValue;\n serializedValue = localStorage.getItem(key);\n if (serializedValue === null) {\n return _default || null;\n }\n return JSON.parse(serializedValue);\n };\n\n StorageService.prototype.set = function(key, val) {\n if (_.isObject(key)) {\n return _.each(key, (function(_this) {\n return function(val, key) {\n return _this.set(key, val);\n };\n })(this));\n } else {\n return localStorage.setItem(key, JSON.stringify(val));\n }\n };\n\n StorageService.prototype.contains = function(key) {\n var value;\n value = this.get(key);\n return value !== null;\n };\n\n StorageService.prototype.remove = function(key) {\n return localStorage.removeItem(key);\n };\n\n StorageService.prototype.clear = function() {\n return localStorage.clear();\n };\n\n return StorageService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgStorage\", StorageService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var UrlsService, format, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n format = function(fmt, obj) {\n obj = _.clone(obj);\n return fmt.replace(/%s/g, function(match) {\n return String(obj.shift());\n });\n };\n\n taiga = this.taiga;\n\n UrlsService = (function(superClass) {\n extend(UrlsService, superClass);\n\n UrlsService.$inject = [\"$tgConfig\"];\n\n function UrlsService(config) {\n this.config = config;\n this.urls = {};\n this.mainUrl = this.config.get(\"api\");\n }\n\n UrlsService.prototype.update = function(urls) {\n return this.urls = _.merge(this.urls, urls);\n };\n\n UrlsService.prototype.resolve = function() {\n var args, name, url;\n args = _.toArray(arguments);\n if (args.length === 0) {\n throw Error(\"wrong arguments to setUrls\");\n }\n name = args.slice(0, 1)[0];\n url = format(this.urls[name], args.slice(1));\n return format(\"%s/%s\", [_.str.rtrim(this.mainUrl, \"/\"), _.str.ltrim(url, \"/\")]);\n };\n\n UrlsService.prototype.resolveAbsolute = function() {\n var url;\n url = this.resolve.apply(this, arguments);\n if (/^https?:\\/\\//i.test(url)) {\n return url;\n }\n if (/^\\//.test(url)) {\n return window.location.protocol + \"//\" + window.location.host + url;\n }\n return window.location.protocol + \"//\" + window.location.host + \"/\" + url;\n };\n\n return UrlsService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service('$tgUrls', UrlsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/custom-field-values.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo) {\n var _get, service;\n _get = function(objectId, resource) {\n return $repo.queryOne(resource, objectId);\n };\n service = {\n userstory: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/userstory\");\n }\n },\n task: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/task\");\n }\n },\n issue: {\n get: function(objectId) {\n return _get(objectId, \"custom-attributes-values/issue\");\n }\n }\n };\n return function(instance) {\n return instance.customAttributesValues = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgCustomAttributesValuesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($repo) {\n var _list, service;\n _list = function(projectId, resource) {\n return $repo.queryMany(resource, {\n project: projectId\n });\n };\n service = {\n userstory: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/userstory\");\n }\n },\n task: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/task\");\n }\n },\n issue: {\n list: function(projectId) {\n return _list(projectId, \"custom-attributes/issue\");\n }\n }\n };\n return function(instance) {\n return instance.customAttributes = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgCustomAttributesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/history.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(type, objectId) {\n return $repo.queryOneRaw(\"history/\" + type, objectId);\n };\n service.deleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = url + \"/\" + objectId + \"/delete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n service.undeleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = url + \"/\" + objectId + \"/undelete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n return function(instance) {\n return instance.history = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgHistoryResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo) {\n var service;\n service = {};\n service.get = function(token) {\n return $repo.queryOne(\"invitations\", token);\n };\n return function(instance) {\n return instance.invitations = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgInvitationsResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/issues.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage, $q) {\n var filtersHashSuffix, hashSuffix, myFiltersHashSuffix, service;\n service = {};\n hashSuffix = \"issues-queryparams\";\n filtersHashSuffix = \"issues-filters\";\n myFiltersHashSuffix = \"issues-my-filters\";\n service.get = function(projectId, issueId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"issues\", issueId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"issues\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"issues\", filters);\n };\n service.list = function(projectId, filters, options) {\n var params;\n params = {\n project: projectId\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryPaginated(\"issues\", params, options);\n };\n service.bulkCreate = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-create-issues\");\n params = {\n project_id: projectId,\n bulk_issues: data\n };\n return $http.post(url, params);\n };\n service.upvote = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-upvote\", issueId);\n return $http.post(url);\n };\n service.downvote = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-downvote\", issueId);\n return $http.post(url);\n };\n service.watch = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-watch\", issueId);\n return $http.post(url);\n };\n service.unwatch = function(issueId) {\n var url;\n url = $urls.resolve(\"issue-unwatch\", issueId);\n return $http.post(url);\n };\n service.stats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/issues_stats\");\n };\n service.filtersData = function(params) {\n return $repo.queryOneRaw(\"issues-filters\", null, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeFilters = function(projectSlug, params) {\n var hash, ns;\n ns = projectSlug + \":\" + filtersHashSuffix;\n hash = generateHash([projectSlug, ns]);\n return $storage.set(hash, params);\n };\n service.getFilters = function(projectSlug) {\n var hash, ns;\n ns = projectSlug + \":\" + filtersHashSuffix;\n hash = generateHash([projectSlug, ns]);\n return $storage.get(hash) || {};\n };\n service.storeMyFilters = function(projectId, myFilters) {\n var deferred, hash, ns, promise, url;\n deferred = $q.defer();\n url = $urls.resolve(\"user-storage\");\n ns = projectId + \":\" + myFiltersHashSuffix;\n hash = generateHash([projectId, ns]);\n if (_.isEmpty(myFilters)) {\n promise = $http[\"delete\"](url + \"/\" + hash, {\n key: hash,\n value: myFilters\n });\n promise.then(function() {\n return deferred.resolve();\n });\n promise.then(null, function() {\n return deferred.reject();\n });\n } else {\n promise = $http.put(url + \"/\" + hash, {\n key: hash,\n value: myFilters\n });\n promise.then(function(data) {\n return deferred.resolve();\n });\n promise.then(null, function(data) {\n var innerPromise;\n innerPromise = $http.post(\"\" + url, {\n key: hash,\n value: myFilters\n });\n innerPromise.then(function() {\n return deferred.resolve();\n });\n return innerPromise.then(null, function() {\n return deferred.reject();\n });\n });\n }\n return deferred.promise;\n };\n service.getMyFilters = function(projectId) {\n var deferred, hash, ns, promise, url;\n deferred = $q.defer();\n url = $urls.resolve(\"user-storage\");\n ns = projectId + \":\" + myFiltersHashSuffix;\n hash = generateHash([projectId, ns]);\n promise = $http.get(url + \"/\" + hash);\n promise.then(function(data) {\n return deferred.resolve(data.data.value);\n });\n promise.then(null, function(data) {\n return deferred.resolve({});\n });\n return deferred.promise;\n };\n return function(instance) {\n return instance.issues = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgIssuesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/kanban.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($storage) {\n var hashSuffixStatusColumnModes, hashSuffixStatusViewModes, service;\n service = {};\n hashSuffixStatusViewModes = \"kanban-statusviewmodels\";\n hashSuffixStatusColumnModes = \"kanban-statuscolumnmodels\";\n service.storeStatusViewModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusViewModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusViewModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusViewModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeStatusColumnModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusColumnModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n return function(instance) {\n return instance.kanban = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgKanbanResourcesProvider\", [\"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/locales.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($repo) {\n var service;\n service = {\n list: function() {\n return $repo.queryMany(\"locales\");\n }\n };\n return function(instance) {\n return instance.locales = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgLocalesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/mdrender.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.render = function(projectId, content) {\n var params, url;\n if ((content == null) || content === \"\") {\n content = ' ';\n }\n params = {\n project_id: projectId,\n content: content\n };\n url = $urls.resolve(\"wiki\");\n return $http.post(url + \"/render\", params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n return function(instance) {\n return instance.mdrender = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgMdRenderResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"memberships\", id);\n };\n service.list = function(projectId, filters, enablePagination) {\n var options, params;\n if (enablePagination == null) {\n enablePagination = true;\n }\n params = {\n project: projectId\n };\n params = _.extend({}, params, filters || {});\n if (enablePagination) {\n return $repo.queryPaginated(\"memberships\", params);\n }\n return $repo.queryMany(\"memberships\", params, options = {\n enablePagination: enablePagination\n });\n };\n service.listByUser = function(userId, filters) {\n var params;\n params = {\n user: userId\n };\n params = _.extend({}, params, filters || {});\n return $repo.queryPaginated(\"memberships\", params);\n };\n service.resendInvitation = function(id) {\n var url;\n url = $urls.resolve(\"memberships\");\n return $http.post(url + \"/\" + id + \"/resend_invitation\", {});\n };\n service.bulkCreateMemberships = function(projectId, data, invitation_extra_text) {\n var params, url;\n url = $urls.resolve(\"bulk-create-memberships\");\n params = {\n project_id: projectId,\n bulk_memberships: data,\n invitation_extra_text: invitation_extra_text\n };\n return $http.post(url, params);\n };\n return function(instance) {\n return instance.memberships = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgMembershipsResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo) {\n var service;\n service = {};\n service.list = function(projectId, module) {\n return $repo.queryOneAttribute(\"project-modules\", projectId, module);\n };\n return function(instance) {\n return instance.modules = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgModulesResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"notify-policies\", id);\n };\n service.list = function(filters) {\n var params;\n params = _.extend({}, params, filters || {});\n return $repo.queryMany(\"notify-policies\", params);\n };\n return function(instance) {\n return instance.notifyPolicies = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgNotifyPoliciesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($config, $repo, $http, $urls, $auth, $q, $translate) {\n var service;\n service = {};\n service.get = function(projectId) {\n return $repo.queryOne(\"projects\", projectId);\n };\n service.getBySlug = function(projectSlug) {\n return $repo.queryOne(\"projects\", \"by_slug?slug=\" + projectSlug);\n };\n service.list = function() {\n return $repo.queryMany(\"projects\");\n };\n service.listByMember = function(memberId) {\n var params;\n params = {\n \"member\": memberId,\n \"order_by\": \"memberships__user_order\"\n };\n return $repo.queryMany(\"projects\", params);\n };\n service.templates = function() {\n return $repo.queryMany(\"project-templates\");\n };\n service.usersList = function(projectId) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(\"users\", params);\n };\n service.rolesList = function(projectId) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(\"roles\", params);\n };\n service.stats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/stats\");\n };\n service.bulkUpdateOrder = function(bulkData) {\n var url;\n url = $urls.resolve(\"bulk-update-projects-order\");\n return $http.post(url, bulkData);\n };\n service.regenerate_userstories_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_userstories_csv_uuid\";\n return $http.post(url);\n };\n service.regenerate_issues_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_issues_csv_uuid\";\n return $http.post(url);\n };\n service.regenerate_tasks_csv_uuid = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/regenerate_tasks_csv_uuid\";\n return $http.post(url);\n };\n service.leave = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/leave\";\n return $http.post(url);\n };\n service.memberStats = function(projectId) {\n return $repo.queryOneRaw(\"projects\", projectId + \"/member_stats\");\n };\n service.tagsColors = function(projectId) {\n return $repo.queryOne(\"projects\", projectId + \"/tags_colors\");\n };\n service[\"export\"] = function(projectId) {\n var url;\n url = ($urls.resolve(\"exporter\")) + \"/\" + projectId;\n return $http.get(url);\n };\n service[\"import\"] = function(file, statusUpdater) {\n var complete, data, defered, errorMsg, failed, maxFileSize, response, uploadComplete, uploadFailed, uploadProgress, xhr;\n defered = $q.defer();\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n errorMsg = $translate.instant(\"PROJECT.IMPORT.ERROR_MAX_SIZE_EXCEEDED\", {\n fileName: file.name,\n fileSize: sizeFormat(file.size),\n maxFileSize: sizeFormat(maxFileSize)\n });\n response = {\n status: 413,\n data: {\n _error_message: errorMsg\n }\n };\n defered.reject(response);\n return defered.promise;\n }\n uploadProgress = (function(_this) {\n return function(evt) {\n var message, percent;\n percent = Math.round((evt.loaded / evt.total) * 100);\n message = $translate.instant(\"PROJECT.IMPORT.UPLOAD_IN_PROGRESS_MESSAGE\", {\n uploadedSize: sizeFormat(evt.loaded),\n totalSize: sizeFormat(evt.total)\n });\n return statusUpdater(\"in-progress\", null, message, percent);\n };\n })(this);\n uploadComplete = (function(_this) {\n return function(evt) {\n return statusUpdater(\"done\", $translate.instant(\"PROJECT.IMPORT.TITLE\"), $translate.instant(\"PROJECT.IMPORT.DESCRIPTION\"));\n };\n })(this);\n uploadFailed = (function(_this) {\n return function(evt) {\n return statusUpdater(\"error\");\n };\n })(this);\n complete = (function(_this) {\n return function(evt) {\n var error, ref;\n response = {};\n try {\n response.data = JSON.parse(evt.target.responseText);\n } catch (error) {\n response.data = {};\n }\n response.status = evt.target.status;\n if ((ref = response.status) === 201 || ref === 202) {\n defered.resolve(response);\n }\n return defered.reject(response);\n };\n })(this);\n failed = (function(_this) {\n return function(evt) {\n return defered.reject(\"fail\");\n };\n })(this);\n data = new FormData();\n data.append('dump', file);\n xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.upload.addEventListener(\"load\", uploadComplete, false);\n xhr.upload.addEventListener(\"error\", uploadFailed, false);\n xhr.upload.addEventListener(\"abort\", uploadFailed, false);\n xhr.addEventListener(\"load\", complete, false);\n xhr.addEventListener(\"error\", failed, false);\n xhr.open(\"POST\", $urls.resolve(\"importer\"));\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + ($auth.getToken()));\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send(data);\n return defered.promise;\n };\n service.changeLogo = function(projectId, file) {\n var data, defered, maxFileSize, options, response, url;\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered = $q.defer();\n defered.reject(response);\n return defered.promise;\n }\n data = new FormData();\n data.append('logo', file);\n options = {\n transformRequest: angular.identity,\n headers: {\n 'Content-Type': void 0\n }\n };\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/change_logo\";\n return $http.post(url, data, {}, options);\n };\n service.removeLogo = function(projectId) {\n var url;\n url = ($urls.resolve(\"projects\")) + \"/\" + projectId + \"/remove_logo\";\n return $http.post(url);\n };\n return function(instance) {\n return instance.projects = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgProjectsResourcesProvider\", [\"$tgConfig\", \"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgAuth\", \"$q\", \"$translate\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(id) {\n return $repo.queryOne(\"roles\", id);\n };\n service.list = function(projectId) {\n return $repo.queryMany(\"roles\", {\n project: projectId\n });\n };\n return function(instance) {\n return instance.roles = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgRolesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/search.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $urls, $http, $q) {\n var service;\n service = {};\n service[\"do\"] = function(projectId, term) {\n var deferredAbort, params, request, url;\n deferredAbort = $q.defer();\n url = $urls.resolve(\"search\");\n params = {\n url: url,\n method: \"GET\",\n timeout: deferredAbort.promise,\n cancelable: true,\n params: {\n project: projectId,\n text: term,\n get_all: false\n }\n };\n request = $http.request(params).then(function(data) {\n return data.data;\n });\n request.abort = function() {\n return deferredAbort.resolve();\n };\n request[\"finally\"] = function() {\n request.abort = angular.noop;\n return deferredAbort = request = null;\n };\n return request;\n };\n return function(instance) {\n return instance.search = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgSearchResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/sprints.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $model, $storage) {\n var service;\n service = {};\n service.get = function(projectId, sprintId) {\n return $repo.queryOne(\"milestones\", sprintId).then(function(sprint) {\n var uses;\n uses = sprint.user_stories;\n uses = _.map(uses, function(u) {\n return $model.make_model(\"userstories\", u);\n });\n sprint._attrs.user_stories = uses;\n return sprint;\n });\n };\n service.stats = function(projectId, sprintId) {\n return $repo.queryOneRaw(\"milestones\", sprintId + \"/stats\");\n };\n service.list = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId\n };\n params = _.extend({}, params, filters || {});\n return $repo.queryMany(\"milestones\", params, {}, true).then((function(_this) {\n return function(result) {\n var headers, i, len, m, milestones, uses;\n milestones = result[0];\n headers = result[1];\n for (i = 0, len = milestones.length; i < len; i++) {\n m = milestones[i];\n uses = m.user_stories;\n uses = _.map(uses, function(u) {\n return $model.make_model(\"userstories\", u);\n });\n m._attrs.user_stories = uses;\n }\n return {\n milestones: milestones,\n closed: parseInt(headers(\"Taiga-Info-Total-Closed-Milestones\"), 10),\n open: parseInt(headers(\"Taiga-Info-Total-Opened-Milestones\"), 10)\n };\n };\n })(this));\n };\n return function(instance) {\n return instance.sprints = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgSprintsResourcesProvider\", [\"$tgRepo\", \"$tgModel\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/tasks.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage) {\n var hashSuffix, hashSuffixStatusColumnModes, hashSuffixUsRowModes, service;\n service = {};\n hashSuffix = \"tasks-queryparams\";\n hashSuffixStatusColumnModes = \"tasks-statuscolumnmodels\";\n hashSuffixUsRowModes = \"tasks-usrowmodels\";\n service.get = function(projectId, taskId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"tasks\", taskId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"tasks\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"tasks\", filters);\n };\n service.list = function(projectId, sprintId, userStoryId) {\n var params;\n if (sprintId == null) {\n sprintId = null;\n }\n if (userStoryId == null) {\n userStoryId = null;\n }\n params = {\n project: projectId\n };\n if (sprintId) {\n params.milestone = sprintId;\n }\n if (userStoryId) {\n params.user_story = userStoryId;\n }\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"tasks\", params);\n };\n service.bulkCreate = function(projectId, sprintId, usId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-create-tasks\");\n params = {\n project_id: projectId,\n sprint_id: sprintId,\n us_id: usId,\n bulk_tasks: data\n };\n return $http.post(url, params).then(function(result) {\n return result.data;\n });\n };\n service.upvote = function(taskId) {\n var url;\n url = $urls.resolve(\"task-upvote\", taskId);\n return $http.post(url);\n };\n service.downvote = function(taskId) {\n var url;\n url = $urls.resolve(\"task-downvote\", taskId);\n return $http.post(url);\n };\n service.watch = function(taskId) {\n var url;\n url = $urls.resolve(\"task-watch\", taskId);\n return $http.post(url);\n };\n service.unwatch = function(taskId) {\n var url;\n url = $urls.resolve(\"task-unwatch\", taskId);\n return $http.post(url);\n };\n service.bulkUpdateTaskTaskboardOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-task-taskboard-order\");\n params = {\n project_id: projectId,\n bulk_tasks: data\n };\n return $http.post(url, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeStatusColumnModes = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getStatusColumnModes = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixStatusColumnModes;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeUsRowModes = function(projectId, sprintId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixUsRowModes;\n hash = generateHash([projectId, sprintId, ns]);\n return $storage.set(hash, params);\n };\n service.getUsRowModes = function(projectId, sprintId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffixUsRowModes;\n hash = generateHash([projectId, sprintId, ns]);\n return $storage.get(hash) || {};\n };\n return function(instance) {\n return instance.tasks = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgTasksResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/memberships.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($config, $repo, $http, $urls, $q) {\n var service;\n service = {};\n service.changeAvatar = function(file) {\n var data, defered, maxFileSize, options, response, url;\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered = $q.defer();\n defered.reject(response);\n return defered.promise;\n }\n data = new FormData();\n data.append('avatar', file);\n options = {\n transformRequest: angular.identity,\n headers: {\n 'Content-Type': void 0\n }\n };\n url = ($urls.resolve(\"users\")) + \"/change_avatar\";\n return $http.post(url, data, {}, options);\n };\n service.removeAvatar = function() {\n var url;\n url = ($urls.resolve(\"users\")) + \"/remove_avatar\";\n return $http.post(url);\n };\n service.changePassword = function(currentPassword, newPassword) {\n var data, url;\n url = ($urls.resolve(\"users\")) + \"/change_password\";\n data = {\n current_password: currentPassword,\n password: newPassword\n };\n return $http.post(url, data);\n };\n return function(instance) {\n return instance.userSettings = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUserSettingsResourcesProvider\", [\"$tgConfig\", \"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/user.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($http, $urls) {\n var service;\n service = {};\n service.contacts = function(userId, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = $urls.resolve(\"user-contacts\", userId);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return $http.get(url, {}, httpOptions).then(function(result) {\n return result.data;\n });\n };\n return function(instance) {\n return instance.users = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUsersResourcesProvider\", [\"$tgHttp\", \"$tgUrls\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/userstories.coffee\n */\n\n(function() {\n var generateHash, module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n generateHash = taiga.generateHash;\n\n resourceProvider = function($repo, $http, $urls, $storage) {\n var hashSuffix, service;\n service = {};\n hashSuffix = \"userstories-queryparams\";\n service.get = function(projectId, usId) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n return $repo.queryOne(\"userstories\", usId, params);\n };\n service.getByRef = function(projectId, ref) {\n var params;\n params = service.getQueryParams(projectId);\n params.project = projectId;\n params.ref = ref;\n return $repo.queryOne(\"userstories\", \"by_ref\", params);\n };\n service.listInAllProjects = function(filters) {\n return $repo.queryMany(\"userstories\", filters);\n };\n service.filtersData = function(params) {\n return $repo.queryOneRaw(\"userstories-filters\", null, params);\n };\n service.listUnassigned = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId,\n \"milestone\": \"null\"\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"userstories\", params);\n };\n service.listAll = function(projectId, filters) {\n var params;\n params = {\n \"project\": projectId\n };\n params = _.extend({}, params, filters || {});\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(\"userstories\", params);\n };\n service.bulkCreate = function(projectId, status, bulk) {\n var data, url;\n data = {\n project_id: projectId,\n status_id: status,\n bulk_stories: bulk\n };\n url = $urls.resolve(\"bulk-create-us\");\n return $http.post(url, data);\n };\n service.upvote = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-upvote\", userStoryId);\n return $http.post(url);\n };\n service.downvote = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-downvote\", userStoryId);\n return $http.post(url);\n };\n service.watch = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-watch\", userStoryId);\n return $http.post(url);\n };\n service.unwatch = function(userStoryId) {\n var url;\n url = $urls.resolve(\"userstory-unwatch\", userStoryId);\n return $http.post(url);\n };\n service.bulkUpdateBacklogOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-backlog-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.bulkUpdateSprintOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-sprint-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.bulkUpdateKanbanOrder = function(projectId, data) {\n var params, url;\n url = $urls.resolve(\"bulk-update-us-kanban-order\");\n params = {\n project_id: projectId,\n bulk_stories: data\n };\n return $http.post(url, params);\n };\n service.listValues = function(projectId, type) {\n var params;\n params = {\n \"project\": projectId\n };\n service.storeQueryParams(projectId, params);\n return $repo.queryMany(type, params);\n };\n service.storeQueryParams = function(projectId, params) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.set(hash, params);\n };\n service.getQueryParams = function(projectId) {\n var hash, ns;\n ns = projectId + \":\" + hashSuffix;\n hash = generateHash([projectId, ns]);\n return $storage.get(hash) || {};\n };\n service.storeShowTags = function(projectId, showTags) {\n var hash;\n hash = generateHash([projectId, 'showTags']);\n return $storage.set(hash, showTags);\n };\n service.getShowTags = function(projectId) {\n var hash;\n hash = generateHash([projectId, 'showTags']);\n return $storage.get(hash) || null;\n };\n return function(instance) {\n return instance.userstories = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgUserstoriesResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", \"$tgStorage\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: webhooklogs.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.list = function(webhookId) {\n var params;\n params = {\n webhook: webhookId\n };\n return $repo.queryMany(\"webhooklogs\", params);\n };\n service.resend = function(webhooklogId) {\n var url;\n url = $urls.resolve(\"webhooklogs-resend\", webhooklogId);\n return $http.post(url);\n };\n return function(instance) {\n return instance.webhooklogs = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWebhookLogsResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: webhooks.coffee\n */\n\n(function() {\n var module, resourceProvider;\n\n resourceProvider = function($repo, $urls, $http) {\n var service;\n service = {};\n service.list = function(projectId) {\n var params;\n params = {\n project: projectId\n };\n return $repo.queryMany(\"webhooks\", params);\n };\n service.test = function(webhookId) {\n var url;\n url = $urls.resolve(\"webhooks-test\", webhookId);\n return $http.post(url);\n };\n return function(instance) {\n return instance.webhooks = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWebhooksResourcesProvider\", [\"$tgRepo\", \"$tgUrls\", \"$tgHttp\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/wikis.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(wikiId) {\n return $repo.queryOne(\"wiki\", wikiId);\n };\n service.getBySlug = function(projectId, slug) {\n return $repo.queryOne(\"wiki\", \"by_slug?project=\" + projectId + \"&slug=\" + slug);\n };\n service.listLinks = function(projectId) {\n return $repo.queryMany(\"wiki-links\", {\n project: projectId\n });\n };\n return function(instance) {\n return instance.wiki = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgWikiResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/main.coffee\n */\n\n(function() {\n var UserChangePasswordController, UserChangePasswordDirective, debounce, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaUserSettings\");\n\n UserChangePasswordController = (function(superClass) {\n extend(UserChangePasswordController, superClass);\n\n UserChangePasswordController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\", \"$translate\"];\n\n function UserChangePasswordController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, auth, translate) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.translate = translate;\n this.scope.sectionName = this.translate.instant(\"CHANGE_PASSWORD.SECTION_NAME\");\n this.scope.user = this.auth.getUser();\n }\n\n return UserChangePasswordController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserChangePasswordController\", UserChangePasswordController);\n\n UserChangePasswordDirective = function($rs, $confirm, $loading, $translate) {\n var link;\n link = function($scope, $el, $attrs, ctrl) {\n var submit, submitButton;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var currentLoading, promise;\n event.preventDefault();\n if ($scope.newPassword1 !== $scope.newPassword2) {\n $confirm.notify('error', $translate.instant(\"CHANGE_PASSWORD.ERROR_PASSWORD_MATCH\"));\n return;\n }\n currentLoading = $loading().target(submitButton).start();\n promise = $rs.userSettings.changePassword($scope.currentPassword, $scope.newPassword1);\n promise.then(function() {\n currentLoading.finish();\n return $confirm.notify('success');\n });\n return promise.then(null, function(response) {\n currentLoading.finish();\n return $confirm.notify('error', response.data._error_message);\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserChangePassword\", [\"$tgResources\", \"$tgConfirm\", \"$tgLoading\", \"$translate\", UserChangePasswordDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues/lightboxes.coffee\n */\n\n(function() {\n var DeleteUserDirective, bindOnce, debounce, module, taiga;\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaUserSettings\");\n\n DeleteUserDirective = function($repo, $rootscope, $auth, $location, $navUrls, lightboxService) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n $scope.$on(\"deletelightbox:new\", function(ctx, user) {\n return lightboxService.open($el);\n });\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n submit = function() {\n var promise;\n promise = $repo.remove($scope.user);\n promise.then(function(data) {\n lightboxService.close($el);\n $auth.logout();\n return $location.path($navUrls.resolve(\"login\"));\n });\n return promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n };\n $el.on(\"click\", \".button-red\", function(event) {\n event.preventDefault();\n return lightboxService.close($el);\n });\n return $el.on(\"click\", \".button-green\", debounce(2000, function(event) {\n event.preventDefault();\n return submit();\n }));\n };\n return {\n link: link,\n templateUrl: \"user/lightbox/lightbox-delete-account.html\"\n };\n };\n\n module.directive(\"tgLbDeleteUser\", [\"$tgRepo\", \"$rootScope\", \"$tgAuth\", \"$tgLocation\", \"$tgNavUrls\", \"lightboxService\", DeleteUserDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/main.coffee\n */\n\n(function() {\n var TaigaAvatarModelDirective, UserAvatarDirective, UserProfileDirective, UserSettingsController, debounce, mixOf, module, sizeFormat, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n sizeFormat = this.taiga.sizeFormat;\n\n module = angular.module(\"taigaUserSettings\");\n\n debounce = this.taiga.debounce;\n\n UserSettingsController = (function(superClass) {\n extend(UserSettingsController, superClass);\n\n UserSettingsController.$inject = [\"$scope\", \"$rootScope\", \"$tgConfig\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\", \"$translate\"];\n\n function UserSettingsController(scope, rootscope, config, repo, confirm, rs, params, q, location, navUrls, auth, translate) {\n var maxFileSize, promise, text;\n this.scope = scope;\n this.rootscope = rootscope;\n this.config = config;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.translate = translate;\n this.scope.sectionName = \"USER_SETTINGS.MENU.SECTION_TITLE\";\n this.scope.project = {};\n this.scope.user = this.auth.getUser();\n if (!this.scope.user) {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n this.location.replace();\n }\n this.scope.lang = this.getLan();\n this.scope.theme = this.getTheme();\n maxFileSize = this.config.get(\"maxUploadFileSize\", null);\n if (maxFileSize) {\n text = this.translate.instant(\"USER_SETTINGS.AVATAR_MAX_SIZE\", {\n \"maxFileSize\": sizeFormat(maxFileSize)\n });\n this.scope.maxFileSizeMsg = text;\n }\n promise = this.loadInitialData();\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserSettingsController.prototype.loadInitialData = function() {\n this.scope.availableThemes = this.config.get(\"themes\", []);\n return this.rs.locales.list().then((function(_this) {\n return function(locales) {\n _this.scope.locales = locales;\n return locales;\n };\n })(this));\n };\n\n UserSettingsController.prototype.openDeleteLightbox = function() {\n return this.rootscope.$broadcast(\"deletelightbox:new\", this.scope.user);\n };\n\n UserSettingsController.prototype.getLan = function() {\n return this.scope.user.lang || this.translate.preferredLanguage();\n };\n\n UserSettingsController.prototype.getTheme = function() {\n return this.scope.user.theme || this.config.get(\"defaultTheme\") || \"taiga\";\n };\n\n return UserSettingsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserSettingsController\", UserSettingsController);\n\n UserProfileDirective = function($confirm, $auth, $repo, $translate) {\n var link;\n link = function($scope, $el, $attrs) {\n var submit;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var changeEmail, form, onError, onSuccess;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n changeEmail = $scope.user.isAttributeModified(\"email\");\n $scope.user.lang = $scope.lang;\n $scope.user.theme = $scope.theme;\n onSuccess = function(data) {\n var text;\n $auth.setUser(data);\n if (changeEmail) {\n text = $translate.instant(\"USER_PROFILE.CHANGE_EMAIL_SUCCESS\");\n return $confirm.success(text);\n } else {\n return $confirm.notify('success');\n }\n };\n onError = function(data) {\n form.setErrors(data);\n return $confirm.notify('error', data._error_message);\n };\n return $repo.save($scope.user).then(onSuccess, onError);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserProfile\", [\"$tgConfirm\", \"$tgAuth\", \"$tgRepo\", \"$translate\", UserProfileDirective]);\n\n UserAvatarDirective = function($auth, $model, $rs, $confirm) {\n var link;\n link = function($scope, $el, $attrs) {\n var onError, onSuccess, showSizeInfo;\n showSizeInfo = function() {\n return $el.find(\".size-info\").removeClass(\"hidden\");\n };\n onSuccess = function(response) {\n var user;\n user = $model.make_model(\"users\", response.data);\n $auth.setUser(user);\n $scope.user = user;\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('success');\n };\n onError = function(response) {\n if (response.status === 413) {\n showSizeInfo();\n }\n $el.find('.loading-overlay').removeClass('active');\n return $confirm.notify('error', response.data._error_message);\n };\n $el.on(\"click\", \".js-change-avatar\", function() {\n return $el.find(\"#avatar-field\").click();\n });\n $el.on(\"change\", \"#avatar-field\", function(event) {\n if ($scope.avatarAttachment) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.userSettings.changeAvatar($scope.avatarAttachment).then(onSuccess, onError);\n }\n });\n $el.on(\"click\", \"a.js-use-gravatar\", function(event) {\n $el.find('.loading-overlay').addClass(\"active\");\n return $rs.userSettings.removeAvatar().then(onSuccess, onError);\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserAvatar\", [\"$tgAuth\", \"$tgModel\", \"$tgResources\", \"$tgConfirm\", UserAvatarDirective]);\n\n TaigaAvatarModelDirective = function($parse) {\n var link;\n link = function($scope, $el, $attrs) {\n var model, modelSetter;\n model = $parse($attrs.tgAvatarModel);\n modelSetter = model.assign;\n return $el.bind('change', function() {\n return $scope.$apply(function() {\n return modelSetter($scope, $el[0].files[0]);\n });\n });\n };\n return {\n link: link\n };\n };\n\n module.directive('tgAvatarModel', ['$parse', TaigaAvatarModelDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/nav.coffee\n */\n\n(function() {\n var UserSettingsNavigationDirective, module;\n\n UserSettingsNavigationDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var section;\n section = $attrs.tgUserSettingsNavigation;\n $el.find(\".active\").removeClass(\"active\");\n $el.find(\"#usersettingsmenu-\" + section + \" a\").addClass(\"active\");\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaUserSettings\");\n\n module.directive(\"tgUserSettingsNavigation\", UserSettingsNavigationDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings/notifications.coffee\n */\n\n(function() {\n var UserNotificationsController, UserNotificationsDirective, UserNotificationsListDirective, bindOnce, mixOf, module, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaUserSettings\");\n\n UserNotificationsController = (function(superClass) {\n extend(UserNotificationsController, superClass);\n\n UserNotificationsController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgConfirm\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$tgNavUrls\", \"$tgAuth\"];\n\n function UserNotificationsController(scope, rootscope, repo, confirm, rs, params, q, location, navUrls, auth) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.confirm = confirm;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n this.auth = auth;\n this.scope.sectionName = \"USER_SETTINGS.NOTIFICATIONS.SECTION_NAME\";\n this.scope.user = this.auth.getUser();\n promise = this.loadInitialData();\n promise.then(null, this.onInitialDataError.bind(this));\n }\n\n UserNotificationsController.prototype.loadInitialData = function() {\n return this.rs.notifyPolicies.list().then((function(_this) {\n return function(notifyPolicies) {\n _this.scope.notifyPolicies = notifyPolicies;\n return notifyPolicies;\n };\n })(this));\n };\n\n return UserNotificationsController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"UserNotificationsController\", UserNotificationsController);\n\n UserNotificationsDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserNotifications\", UserNotificationsDirective);\n\n UserNotificationsListDirective = function($repo, $confirm, $compile) {\n var link, template;\n template = _.template(\"<% _.each(notifyPolicies, function (notifyPolicy, index) { %>\\n
\\\">\\n
<%- notifyPolicy.project_name %>
\\n
\\n
\\n \\\" id=\\\"policy-all-<%- notifyPolicy.id %>\\\"\\n value=\\\"2\\\" <% if (notifyPolicy.notify_level == 2) { %>checked=\\\"checked\\\"<% } %>/>\\n \\n
\\n
\\n
\\n
\\n \\\" id=\\\"policy-involved-<%- notifyPolicy.id %>\\\"\\n value=\\\"1\\\" <% if (notifyPolicy.notify_level == 1) { %>checked=\\\"checked\\\"<% } %> />\\n \\n
\\n
\\n
\\n
\\n \\\" id=\\\"policy-none-<%- notifyPolicy.id %>\\\"\\n value=\\\"3\\\" <% if (notifyPolicy.notify_level == 3) { %>checked=\\\"checked\\\"<% } %> />\\n \\n
\\n
\\n
\\n<% }) %>\");\n link = function($scope, $el, $attrs) {\n var render;\n render = function() {\n var ctx, html;\n $el.off();\n ctx = {\n notifyPolicies: $scope.notifyPolicies\n };\n html = template(ctx);\n $el.html($compile(html)($scope));\n return $el.on(\"change\", \"input[type=radio]\", function(event) {\n var onError, onSuccess, policy, policyIndex, prev_level, target;\n target = angular.element(event.currentTarget);\n policyIndex = target.parents(\".policy-table-row\").data('index');\n policy = $scope.notifyPolicies[policyIndex];\n prev_level = policy.notify_level;\n policy.notify_level = parseInt(target.val(), 10);\n onSuccess = function() {\n return $confirm.notify(\"success\");\n };\n onError = function() {\n $confirm.notify(\"error\");\n return target.parents(\".policy-table-row\").find(\"input[value=\" + prev_level + \"]\").prop(\"checked\", true);\n };\n return $repo.save(policy).then(onSuccess, onError);\n });\n };\n $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n return bindOnce($scope, $attrs.ngModel, render);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgUserNotificationsList\", [\"$tgRepo\", \"$tgConfirm\", \"$compile\", UserNotificationsListDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: components.module.coffee\n */\n\n(function() {\n angular.module(\"taigaComponents\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaDiscover\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-apps.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaExternalApps\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaHome\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.module.coffee\n */\n\n(function() {\n angular.module(\"taigaNavigationBar\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile.module.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaProfile\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects.module.coffee\n */\n\n(function() {\n angular.module(\"taigaProjects\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: resources.module.coffee\n */\n\n(function() {\n angular.module(\"taigaResources2\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.module.coffee\n */\n\n(function() {\n angular.module(\"taigaUserTimeline\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment-link.directive.coffee\n */\n\n(function() {\n var AttachmentLinkDirective;\n\n AttachmentLinkDirective = function($parse, lightboxFactory) {\n var link;\n link = function(scope, el, attrs) {\n var attachment;\n attachment = $parse(attrs.tgAttachmentLink)(scope);\n el.on(\"click\", function(event) {\n if (taiga.isImage(attachment.getIn(['file', 'name']))) {\n event.preventDefault();\n return scope.$apply(function() {\n return lightboxFactory.create('tg-lb-attachment-preview', {\n \"class\": 'lightbox lightbox-block'\n }, {\n file: attachment.get('file')\n });\n });\n }\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentLinkDirective.$inject = [\"$parse\", \"tgLightboxFactory\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentLink\", AttachmentLinkDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment-gallery.directive.coffee\n */\n\n(function() {\n var AttachmentGalleryDirective;\n\n AttachmentGalleryDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachment: \"=\",\n onDelete: \"&\",\n onUpdate: \"&\",\n type: \"=\"\n },\n controller: \"Attachment\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachment/attachment-gallery.html\",\n link: link\n };\n };\n\n AttachmentGalleryDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentGallery\", AttachmentGalleryDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchment.controller.coffee\n */\n\n(function() {\n var AttachmentController;\n\n AttachmentController = (function() {\n AttachmentController.$inject = ['tgAttachmentsService', '$translate'];\n\n function AttachmentController(attachmentsService, translate) {\n this.attachmentsService = attachmentsService;\n this.translate = translate;\n this.form = {};\n this.form.description = this.attachment.getIn(['file', 'description']);\n this.form.is_deprecated = this.attachment.get(['file', 'is_deprecated']);\n this.title = this.translate.instant(\"ATTACHMENT.TITLE\", {\n fileName: this.attachment.get('name'),\n date: moment(this.attachment.get('created_date')).format(this.translate.instant(\"ATTACHMENT.DATE\"))\n });\n }\n\n AttachmentController.prototype.editMode = function(mode) {\n var attachment;\n attachment = this.attachment.set('editable', mode);\n return this.onUpdate({\n attachment: attachment\n });\n };\n\n AttachmentController.prototype[\"delete\"] = function() {\n return this.onDelete({\n attachment: this.attachment\n });\n };\n\n AttachmentController.prototype.save = function() {\n var attachment;\n attachment = this.attachment.set('loading', true);\n this.onUpdate({\n attachment: attachment\n });\n attachment = this.attachment.merge({\n editable: false,\n loading: false\n });\n attachment = attachment.mergeIn(['file'], {\n description: this.form.description,\n is_deprecated: !!this.form.is_deprecated\n });\n return this.onUpdate({\n attachment: attachment\n });\n };\n\n return AttachmentController;\n\n })();\n\n angular.module('taigaComponents').controller('Attachment', AttachmentController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachment.directive.coffee\n */\n\n(function() {\n var AttachmentDirective;\n\n AttachmentDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachment: \"=\",\n onDelete: \"&\",\n onUpdate: \"&\",\n type: \"=\"\n },\n controller: \"Attachment\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachment/attachment.html\",\n link: link\n };\n };\n\n AttachmentDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachment\", AttachmentDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-drop.directive.coffee\n */\n\n(function() {\n var AttachmentsDropDirective;\n\n AttachmentsDropDirective = function($parse) {\n var link;\n link = function(scope, el, attrs) {\n var eventAttr;\n eventAttr = $parse(attrs.tgAttachmentsDrop);\n el.on('dragover', function(e) {\n e.preventDefault();\n return false;\n });\n el.on('drop', function(e) {\n var dataTransfer;\n e.stopPropagation();\n e.preventDefault();\n dataTransfer = e.dataTransfer || (e.originalEvent && e.originalEvent.dataTransfer);\n return scope.$apply(function() {\n return eventAttr(scope, {\n files: dataTransfer.files\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentsDropDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsDrop\", AttachmentsDropDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-full.controller.coffee\n */\n\n(function() {\n var AttachmentsFullController, sizeFormat;\n\n sizeFormat = this.taiga.sizeFormat;\n\n AttachmentsFullController = (function() {\n AttachmentsFullController.$inject = [\"$translate\", \"$tgConfirm\", \"$tgConfig\", \"$tgStorage\", \"tgAttachmentsFullService\"];\n\n function AttachmentsFullController(translate, confirm, config, storage, attachmentsFullService) {\n this.translate = translate;\n this.confirm = confirm;\n this.config = config;\n this.storage = storage;\n this.attachmentsFullService = attachmentsFullService;\n this.mode = this.storage.get('attachment-mode', 'list');\n this.maxFileSize = this.config.get(\"maxUploadFileSize\", null);\n if (this.maxFileSize) {\n this.maxFileSize = sizeFormat(this.maxFileSize);\n }\n this.maxFileSizeMsg = this.maxFileSize ? this.translate.instant(\"ATTACHMENT.MAX_UPLOAD_SIZE\", {\n maxFileSize: this.maxFileSize\n }) : \"\";\n taiga.defineImmutableProperty(this, 'attachments', (function(_this) {\n return function() {\n return _this.attachmentsFullService.attachments;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsCount', (function(_this) {\n return function() {\n return _this.attachmentsFullService.deprecatedsCount;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'attachmentsVisible', (function(_this) {\n return function() {\n return _this.attachmentsFullService.attachmentsVisible;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsVisible', (function(_this) {\n return function() {\n return _this.attachmentsFullService.deprecatedsVisible;\n };\n })(this));\n }\n\n AttachmentsFullController.prototype.uploadingAttachments = function() {\n return this.attachmentsFullService.uploadingAttachments;\n };\n\n AttachmentsFullController.prototype.addAttachment = function(file) {\n var editable;\n editable = this.mode === 'list';\n return this.attachmentsFullService.addAttachment(this.projectId, this.objId, this.type, file, editable);\n };\n\n AttachmentsFullController.prototype.setMode = function(mode) {\n this.mode = mode;\n return this.storage.set('attachment-mode', mode);\n };\n\n AttachmentsFullController.prototype.toggleDeprecatedsVisible = function() {\n return this.attachmentsFullService.toggleDeprecatedsVisible();\n };\n\n AttachmentsFullController.prototype.addAttachments = function(files) {\n return _.forEach(files, (function(_this) {\n return function(file) {\n return _this.addAttachment(file);\n };\n })(this));\n };\n\n AttachmentsFullController.prototype.loadAttachments = function() {\n return this.attachmentsFullService.loadAttachments(this.type, this.objId, this.projectId);\n };\n\n AttachmentsFullController.prototype.deleteAttachment = function(toDeleteAttachment) {\n var message, title;\n title = this.translate.instant(\"ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT\");\n message = this.translate.instant(\"ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT\", {\n fileName: toDeleteAttachment.getIn(['file', 'name'])\n });\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(askResponse) {\n var onError, onSuccess;\n onError = function() {\n message = _this.translate.instant(\"ATTACHMENT.ERROR_DELETE_ATTACHMENT\", {\n errorMessage: message\n });\n _this.confirm.notify(\"error\", null, message);\n return askResponse.finish(false);\n };\n onSuccess = function() {\n return askResponse.finish();\n };\n return _this.attachmentsFullService.deleteAttachment(toDeleteAttachment, _this.type).then(onSuccess, onError);\n };\n })(this));\n };\n\n AttachmentsFullController.prototype.reorderAttachment = function(attachment, newIndex) {\n return this.attachmentsFullService.reorderAttachment(this.type, attachment, newIndex);\n };\n\n AttachmentsFullController.prototype.updateAttachment = function(toUpdateAttachment) {\n return this.attachmentsFullService.updateAttachment(toUpdateAttachment, this.type);\n };\n\n return AttachmentsFullController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"AttachmentsFull\", AttachmentsFullController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-full.directive.coffee\n */\n\n(function() {\n var AttachmentsFullDirective, bindOnce;\n\n bindOnce = this.taiga.bindOnce;\n\n AttachmentsFullDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return bindOnce(scope, 'vm.objId', function(value) {\n return ctrl.loadAttachments();\n });\n };\n return {\n scope: {},\n bindToController: {\n type: \"@\",\n objId: \"=\",\n projectId: \"=\"\n },\n controller: \"AttachmentsFull\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachments-full/attachments-full.html\",\n link: link\n };\n };\n\n AttachmentsFullDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsFull\", AttachmentsFullDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-full.service.coffee\n */\n\n(function() {\n var AttachmentsFullService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n AttachmentsFullService = (function(superClass) {\n extend(AttachmentsFullService, superClass);\n\n AttachmentsFullService.$inject = [\"tgAttachmentsService\", \"$rootScope\"];\n\n function AttachmentsFullService(attachmentsService, rootScope) {\n this.attachmentsService = attachmentsService;\n this.rootScope = rootScope;\n this._attachments = Immutable.List();\n this._deprecatedsCount = 0;\n this._attachmentsVisible = Immutable.List();\n this._deprecatedsVisible = false;\n this.uploadingAttachments = [];\n taiga.defineImmutableProperty(this, 'attachments', (function(_this) {\n return function() {\n return _this._attachments;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsCount', (function(_this) {\n return function() {\n return _this._deprecatedsCount;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'attachmentsVisible', (function(_this) {\n return function() {\n return _this._attachmentsVisible;\n };\n })(this));\n taiga.defineImmutableProperty(this, 'deprecatedsVisible', (function(_this) {\n return function() {\n return _this._deprecatedsVisible;\n };\n })(this));\n }\n\n AttachmentsFullService.prototype.toggleDeprecatedsVisible = function() {\n this._deprecatedsVisible = !this._deprecatedsVisible;\n return this.regenerate();\n };\n\n AttachmentsFullService.prototype.regenerate = function() {\n this._deprecatedsCount = this._attachments.count(function(it) {\n return it.getIn(['file', 'is_deprecated']);\n });\n if (this._deprecatedsVisible) {\n return this._attachmentsVisible = this._attachments;\n } else {\n return this._attachmentsVisible = this._attachments.filter(function(it) {\n return !it.getIn(['file', 'is_deprecated']);\n });\n }\n };\n\n AttachmentsFullService.prototype.addAttachment = function(projectId, objId, type, file, editable) {\n if (editable == null) {\n editable = true;\n }\n return new Promise((function(_this) {\n return function(resolve, reject) {\n var promise;\n if (_this.attachmentsService.validate(file)) {\n _this.uploadingAttachments.push(file);\n promise = _this.attachmentsService.upload(file, objId, projectId, type);\n return promise.then(function(file) {\n var attachment;\n _this.uploadingAttachments = _this.uploadingAttachments.filter(function(uploading) {\n return uploading.name !== file.get('name');\n });\n attachment = Immutable.Map();\n attachment = attachment.merge({\n file: file,\n editable: editable,\n loading: false\n });\n _this._attachments = _this._attachments.push(attachment);\n _this.regenerate();\n _this.rootScope.$broadcast(\"attachment:create\");\n return resolve(attachment);\n });\n } else {\n return reject(file);\n }\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.loadAttachments = function(type, objId, projectId) {\n return this.attachmentsService.list(type, objId, projectId).then((function(_this) {\n return function(files) {\n _this._attachments = files.map(function(file) {\n var attachment;\n attachment = Immutable.Map();\n return attachment.merge({\n loading: false,\n editable: false,\n file: file\n });\n });\n return _this.regenerate();\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.deleteAttachment = function(toDeleteAttachment, type) {\n var onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this._attachments = _this._attachments.filter(function(attachment) {\n return attachment !== toDeleteAttachment;\n });\n return _this.regenerate();\n };\n })(this);\n return this.attachmentsService[\"delete\"](type, toDeleteAttachment.getIn(['file', 'id'])).then(onSuccess);\n };\n\n AttachmentsFullService.prototype.reorderAttachment = function(type, attachment, newIndex) {\n var attachments, oldIndex, promises;\n oldIndex = this.attachments.findIndex(function(it) {\n return it === attachment;\n });\n if (oldIndex === newIndex) {\n return;\n }\n attachments = this.attachments.remove(oldIndex);\n attachments = attachments.splice(newIndex, 0, attachment);\n attachments = attachments.map(function(x, i) {\n return x.setIn(['file', 'order'], i + 1);\n });\n promises = [];\n attachments.forEach((function(_this) {\n return function(attachment) {\n var patch;\n patch = {\n order: attachment.getIn(['file', 'order'])\n };\n return promises.push(_this.attachmentsService.patch(attachment.getIn(['file', 'id']), type, patch));\n };\n })(this));\n return Promise.all(promises).then((function(_this) {\n return function() {\n _this._attachments = attachments;\n return _this.regenerate();\n };\n })(this));\n };\n\n AttachmentsFullService.prototype.updateAttachment = function(toUpdateAttachment, type) {\n var index, oldAttachment, patch;\n index = this._attachments.findIndex(function(attachment) {\n return attachment.getIn(['file', 'id']) === toUpdateAttachment.getIn(['file', 'id']);\n });\n oldAttachment = this._attachments.get(index);\n patch = taiga.patch(oldAttachment.get('file'), toUpdateAttachment.get('file'));\n if (toUpdateAttachment.get('loading')) {\n this._attachments = this._attachments.set(index, toUpdateAttachment);\n return this.regenerate();\n } else {\n return this.attachmentsService.patch(toUpdateAttachment.getIn(['file', 'id']), type, patch).then((function(_this) {\n return function() {\n _this._attachments = _this._attachments.set(index, toUpdateAttachment);\n return _this.regenerate();\n };\n })(this));\n }\n };\n\n return AttachmentsFullService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgAttachmentsFullService\", AttachmentsFullService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-simple.controller.coffee\n */\n\n(function() {\n var AttachmentsSimpleController;\n\n AttachmentsSimpleController = (function() {\n AttachmentsSimpleController.$inject = [\"tgAttachmentsService\"];\n\n function AttachmentsSimpleController(attachmentsService) {\n this.attachmentsService = attachmentsService;\n }\n\n AttachmentsSimpleController.prototype.addAttachment = function(file) {\n var attachment;\n attachment = Immutable.fromJS({\n file: file,\n name: file.name,\n size: file.size\n });\n if (this.attachmentsService.validate(file)) {\n this.attachments = this.attachments.push(attachment);\n if (this.onAdd) {\n return this.onAdd({\n attachment: attachment\n });\n }\n }\n };\n\n AttachmentsSimpleController.prototype.addAttachments = function(files) {\n return _.forEach(files, this.addAttachment.bind(this));\n };\n\n AttachmentsSimpleController.prototype.deleteAttachment = function(toDeleteAttachment) {\n this.attachments = this.attachments.filter(function(attachment) {\n return attachment !== toDeleteAttachment;\n });\n if (this.onDelete) {\n return this.onDelete({\n attachment: toDeleteAttachment\n });\n }\n };\n\n return AttachmentsSimpleController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"AttachmentsSimple\", AttachmentsSimpleController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attchments-simple.directive.coffee\n */\n\n(function() {\n var AttachmentsSimpleDirective;\n\n AttachmentsSimpleDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n scope: {},\n bindToController: {\n attachments: \"=\",\n onAdd: \"&\",\n onDelete: \"&\"\n },\n controller: \"AttachmentsSimple\",\n controllerAs: \"vm\",\n templateUrl: \"components/attachments-simple/attachments-simple.html\",\n link: link\n };\n };\n\n AttachmentsSimpleDirective.$inject = [];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsSimple\", AttachmentsSimpleDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-sortable.directive.coffee\n */\n\n(function() {\n var AttachmentSortableDirective;\n\n AttachmentSortableDirective = function($parse) {\n var link;\n link = function(scope, el, attrs) {\n var callback;\n callback = $parse(attrs.tgAttachmentsSortable);\n el.sortable({\n items: \"div[tg-bind-scope]\",\n handle: \"a.settings.icon.icon-drag-v\",\n containment: \".attachments\",\n dropOnEmpty: true,\n helper: 'clone',\n scroll: false,\n tolerance: \"pointer\",\n placeholder: \"sortable-placeholder single-attachment\"\n });\n el.on(\"sortstop\", function(event, ui) {\n var attachment, newIndex;\n attachment = ui.item.scope().attachment;\n newIndex = ui.item.index();\n return scope.$apply(function() {\n return callback(scope, {\n attachment: attachment,\n index: newIndex\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link\n };\n };\n\n AttachmentSortableDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgAttachmentsSortable\", AttachmentSortableDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: auto-select.directive.coffee\n */\n\n(function() {\n var AutoSelectDirective;\n\n AutoSelectDirective = function($timeout) {\n return {\n link: function(scope, elm) {\n return $timeout(function() {\n return elm[0].select();\n });\n }\n };\n };\n\n AutoSelectDirective.$inject = ['$timeout'];\n\n angular.module(\"taigaComponents\").directive(\"tgAutoSelect\", AutoSelectDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: file-change.directive.coffee\n */\n\n(function() {\n var FileChangeDirective;\n\n FileChangeDirective = function($parse) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var eventAttr;\n eventAttr = $parse(attrs.tgFileChange);\n el.on('change', function(event) {\n return scope.$apply(function() {\n return eventAttr(scope, {\n files: event.currentTarget.files\n });\n });\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n require: \"ngModel\",\n restrict: \"A\",\n link: link\n };\n };\n\n FileChangeDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgFileChange\", FileChangeDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: joy-ride.directive.coffee\n */\n\n(function() {\n var JoyRideDirective, taiga;\n\n taiga = this.taiga;\n\n JoyRideDirective = function($rootScope, currentUserService, joyRideService, $location, $translate) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var initJoyrRide, intro, unsuscribe;\n unsuscribe = null;\n intro = introJs();\n intro.oncomplete(function() {\n return $('html,body').scrollTop(0);\n });\n intro.onexit(function() {\n return currentUserService.disableJoyRide();\n });\n initJoyrRide = function(next, config) {\n if (!config[next.joyride]) {\n return;\n }\n intro.setOptions({\n exitOnEsc: false,\n exitOnOverlayClick: false,\n showStepNumbers: false,\n nextLabel: $translate.instant('JOYRIDE.NAV.NEXT') + ' →',\n prevLabel: '← ' + $translate.instant('JOYRIDE.NAV.BACK'),\n skipLabel: $translate.instant('JOYRIDE.NAV.SKIP'),\n doneLabel: $translate.instant('JOYRIDE.NAV.DONE'),\n disableInteraction: true\n });\n intro.setOption('steps', joyRideService.get(next.joyride));\n return intro.start();\n };\n return $rootScope.$on('$routeChangeSuccess', function(event, next) {\n if (!next.joyride || !currentUserService.isAuthenticated()) {\n intro.exit();\n if (unsuscribe) {\n unsuscribe();\n }\n return;\n }\n intro.oncomplete(function() {\n return currentUserService.disableJoyRide(next.joyride);\n });\n if (next.loader) {\n return unsuscribe = $rootScope.$on('loader:end', function() {\n currentUserService.loadJoyRideConfig().then(function(config) {\n return initJoyrRide(next, config);\n });\n return unsuscribe();\n });\n } else {\n return currentUserService.loadJoyRideConfig().then(function(config) {\n return initJoyrRide(next, config);\n });\n }\n });\n };\n return {\n scope: {},\n link: link\n };\n };\n\n JoyRideDirective.$inject = [\"$rootScope\", \"tgCurrentUserService\", \"tgJoyRideService\", \"$location\", \"$translate\"];\n\n angular.module(\"taigaComponents\").directive(\"tgJoyRide\", JoyRideDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: joy-ride.service.coffee\n */\n\n(function() {\n var JoyRideService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n JoyRideService = (function(superClass) {\n extend(JoyRideService, superClass);\n\n JoyRideService.$inject = ['$translate', 'tgCheckPermissionsService'];\n\n function JoyRideService(translate, checkPermissionsService) {\n this.translate = translate;\n this.checkPermissionsService = checkPermissionsService;\n }\n\n JoyRideService.prototype.getConfig = function() {\n return {\n dashboard: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.project-list > section:not(.ng-hide)',\n position: 'left',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP1.TITLE'),\n text: _this.translate.instant('JOYRIDE.DASHBOARD.STEP1.TEXT')\n }\n }, {\n element: '.working-on-container',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.DASHBOARD.STEP2.TEXT')\n }\n }, {\n element: '.watching-container',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TITLE'),\n text: [_this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TEXT1'), _this.translate.instant('JOYRIDE.DASHBOARD.STEP3.TEXT2')]\n }\n }\n ];\n if (!$('.project-list .create-project-button').is(':hidden')) {\n steps.push({\n element: '.project-list .create-project-button',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TITLE'),\n text: [_this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TEXT1'), _this.translate.instant('JOYRIDE.DASHBOARD.STEP4.TEXT2')]\n }\n });\n }\n return steps;\n };\n })(this),\n backlog: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.summary',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP1.TITLE'),\n text: [_this.translate.instant('JOYRIDE.BACKLOG.STEP1.TEXT1'), _this.translate.instant('JOYRIDE.BACKLOG.STEP1.TEXT2')]\n }\n }, {\n element: '.backlog-table-empty',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP2.TEXT')\n }\n }, {\n element: '.sprints',\n position: 'left',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP3.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP3.TEXT')\n }\n }\n ];\n if (_this.checkPermissionsService.check('add_us')) {\n steps.push({\n element: '.new-us',\n position: 'rigth',\n joyride: {\n title: _this.translate.instant('JOYRIDE.BACKLOG.STEP4.TITLE'),\n text: _this.translate.instant('JOYRIDE.BACKLOG.STEP4.TEXT')\n }\n });\n }\n return steps;\n };\n })(this),\n kanban: (function(_this) {\n return function() {\n var steps;\n steps = [\n {\n element: '.kanban-table-inner',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP1.TITLE'),\n text: _this.translate.instant('JOYRIDE.KANBAN.STEP1.TEXT')\n }\n }, {\n element: '.card-placeholder',\n position: 'right',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP2.TITLE'),\n text: _this.translate.instant('JOYRIDE.KANBAN.STEP2.TEXT')\n }\n }\n ];\n if (_this.checkPermissionsService.check('add_us')) {\n steps.push({\n element: '.icon-plus',\n position: 'bottom',\n joyride: {\n title: _this.translate.instant('JOYRIDE.KANBAN.STEP3.TITLE'),\n text: [_this.translate.instant('JOYRIDE.KANBAN.STEP3.TEXT1'), _this.translate.instant('JOYRIDE.KANBAN.STEP3.TEXT2')]\n }\n });\n }\n return steps;\n };\n })(this)\n };\n };\n\n JoyRideService.prototype.get = function(name) {\n var joyRide, joyRides;\n joyRides = this.getConfig();\n joyRide = joyRides[name].call(this);\n return _.map(joyRide, function(item) {\n var html;\n html = \"\";\n if (item.joyride.title) {\n html += \"

\" + item.joyride.title + \"

\";\n }\n if (_.isArray(item.joyride.text)) {\n _.forEach(item.joyride.text, function(text) {\n return html += \"

\" + text + \"

\";\n });\n } else {\n html += \"

\" + item.joyride.text + \"

\";\n }\n item.intro = html;\n return item;\n });\n };\n\n return JoyRideService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgJoyRideService\", JoyRideService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Andrey Antukh \n * Copyright (C) 2014-2015 Jesús Espino Garcia \n * Copyright (C) 2014-2015 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: live-announcement.directive.coffee\n */\n\n(function() {\n var LiveAnnouncementDirective;\n\n LiveAnnouncementDirective = function(liveAnnouncementService) {\n var link;\n link = function(scope, el, attrs) {};\n return {\n restrict: \"AE\",\n scope: {},\n controllerAs: 'vm',\n controller: function() {\n this.close = function() {\n return liveAnnouncementService.open = false;\n };\n return Object.defineProperties(this, {\n open: {\n get: function() {\n return liveAnnouncementService.open;\n }\n },\n title: {\n get: function() {\n return liveAnnouncementService.title;\n }\n },\n desc: {\n get: function() {\n return liveAnnouncementService.desc;\n }\n }\n });\n },\n link: link,\n templateUrl: \"components/live-announcement/live-announcement.html\"\n };\n };\n\n LiveAnnouncementDirective.$inject = [\"tgLiveAnnouncementService\"];\n\n angular.module(\"taigaComponents\").directive(\"tgLiveAnnouncement\", LiveAnnouncementDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: notification.service.coffee\n */\n\n(function() {\n var LiveAnnouncementService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n LiveAnnouncementService = (function(superClass) {\n extend(LiveAnnouncementService, superClass);\n\n function LiveAnnouncementService() {\n this.open = false;\n this.title = \"\";\n this.desc = \"\";\n }\n\n LiveAnnouncementService.prototype.show = function(title, desc) {\n this.open = true;\n this.title = title;\n return this.desc = desc;\n };\n\n return LiveAnnouncementService;\n\n })(taiga.Service);\n\n angular.module(\"taigaComponents\").service(\"tgLiveAnnouncementService\", LiveAnnouncementService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-logo.directive.coffee\n */\n\n(function() {\n var COLORS, IMAGES, LOGOS, ProjectLogoSrcDirective,\n modulo = function(a, b) { return (+a % (b = +b) + b) % b; };\n\n IMAGES = [\"/\" + window._version + \"/images/project-logos/project-logo-01.png\", \"/\" + window._version + \"/images/project-logos/project-logo-02.png\", \"/\" + window._version + \"/images/project-logos/project-logo-03.png\", \"/\" + window._version + \"/images/project-logos/project-logo-04.png\", \"/\" + window._version + \"/images/project-logos/project-logo-05.png\"];\n\n COLORS = [\"rgba( 153, 214, 220, 1 )\", \"rgba( 213, 156, 156, 1 )\", \"rgba( 214, 161, 212, 1 )\", \"rgba( 164, 162, 219, 1 )\", \"rgba( 152, 224, 168, 1 )\"];\n\n LOGOS = _.cartesianProduct(IMAGES, COLORS);\n\n ProjectLogoSrcDirective = function($parse) {\n var _getDefaultProjectLogo, link;\n _getDefaultProjectLogo = function(project) {\n var idx, key, logo;\n key = (project.get(\"slug\")) + \"-\" + (project.get(\"id\"));\n idx = modulo(murmurhash3_32_gc(key, 42), LOGOS.length);\n logo = LOGOS[idx];\n return {\n src: logo[0],\n color: logo[1]\n };\n };\n link = function(scope, el, attrs) {\n scope.$watch(\"project\", function(project) {\n var logo, projectLogo;\n project = Immutable.fromJS(project);\n if (!project) {\n return;\n }\n projectLogo = project.get('logo_small_url');\n if (projectLogo) {\n el.attr(\"src\", projectLogo);\n return el.css('background', \"\");\n } else {\n logo = _getDefaultProjectLogo(project);\n el.attr(\"src\", logo.src);\n return el.css('background', logo.color);\n }\n });\n return scope.$on(\"$destroy\", function() {\n return el.off();\n });\n };\n return {\n link: link,\n scope: {\n project: \"=tgProjectLogoSrc\"\n }\n };\n };\n\n ProjectLogoSrcDirective.$inject = [\"$parse\"];\n\n angular.module(\"taigaComponents\").directive(\"tgProjectLogoSrc\", ProjectLogoSrcDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-menu.controller.coffee\n */\n\n(function() {\n var ProjectMenuController;\n\n ProjectMenuController = (function() {\n ProjectMenuController.$inject = [\"tgProjectService\", \"tgLightboxFactory\"];\n\n function ProjectMenuController(projectService, lightboxFactory) {\n this.projectService = projectService;\n this.lightboxFactory = lightboxFactory;\n this.project = null;\n this.menu = Immutable.Map();\n }\n\n ProjectMenuController.prototype.show = function() {\n this.project = this.projectService.project;\n this.active = this._getActiveSection();\n this._setVideoConference();\n return this._setMenuPermissions();\n };\n\n ProjectMenuController.prototype.hide = function() {\n this.project = null;\n return this.menu = {};\n };\n\n ProjectMenuController.prototype.search = function() {\n return this.lightboxFactory.create(\"tg-search-box\", {\n \"class\": \"lightbox lightbox-search\"\n });\n };\n\n ProjectMenuController.prototype._setVideoConference = function() {\n var videoconferenceUrl;\n videoconferenceUrl = this._videoConferenceUrl();\n if (videoconferenceUrl) {\n return this.project = this.project.set(\"videoconferenceUrl\", videoconferenceUrl);\n }\n };\n\n ProjectMenuController.prototype._setMenuPermissions = function() {\n this.menu = Immutable.Map({\n backlog: false,\n kanban: false,\n issues: false,\n wiki: false\n });\n if (this.project.get(\"is_backlog_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_us\") !== -1) {\n this.menu = this.menu.set(\"backlog\", true);\n }\n if (this.project.get(\"is_kanban_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_us\") !== -1) {\n this.menu = this.menu.set(\"kanban\", true);\n }\n if (this.project.get(\"is_issues_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_issues\") !== -1) {\n this.menu = this.menu.set(\"issues\", true);\n }\n if (this.project.get(\"is_wiki_activated\") && this.project.get(\"my_permissions\").indexOf(\"view_wiki_pages\") !== -1) {\n return this.menu = this.menu.set(\"wiki\", true);\n }\n };\n\n ProjectMenuController.prototype._getActiveSection = function() {\n var indexBacklog, indexKanban, oldSectionName, sectionName, sectionsBreadcrumb;\n sectionName = this.projectService.section;\n sectionsBreadcrumb = this.projectService.sectionsBreadcrumb;\n indexBacklog = sectionsBreadcrumb.lastIndexOf(\"backlog\");\n indexKanban = sectionsBreadcrumb.lastIndexOf(\"kanban\");\n if (indexBacklog !== -1 || indexKanban !== -1) {\n if (indexKanban === -1 || indexBacklog > indexKanban) {\n oldSectionName = \"backlog\";\n } else {\n oldSectionName = \"kanban\";\n }\n }\n if (sectionName === \"backlog-kanban\") {\n if (oldSectionName === \"backlog\" || oldSectionName === \"kanban\") {\n sectionName = oldSectionName;\n } else if (this.project.get(\"is_backlog_activated\") && !this.project.get(\"is_kanban_activated\")) {\n sectionName = \"backlog\";\n } else if (!this.project.get(\"is_backlog_activated\") && this.project.get(\"is_kanban_activated\")) {\n sectionName = \"kanban\";\n }\n }\n return sectionName;\n };\n\n ProjectMenuController.prototype._videoConferenceUrl = function() {\n var baseUrl, url;\n if (this.project.get(\"videoconferences\") === \"appear-in\") {\n baseUrl = \"https://appear.in/\";\n } else if (this.project.get(\"videoconferences\") === \"talky\") {\n baseUrl = \"https://talky.io/\";\n } else if (this.project.get(\"videoconferences\") === \"jitsi\") {\n baseUrl = \"https://meet.jit.si/\";\n url = this.project.get(\"slug\") + \"-\" + taiga.slugify(this.project.get(\"videoconferences_extra_data\"));\n url = url.replace(/-/g, \"\");\n return baseUrl + url;\n } else if (this.project.get(\"videoconferences\") === \"custom\") {\n return this.project.get(\"videoconferences_extra_data\");\n } else {\n return \"\";\n }\n if (this.project.get(\"videoconferences_extra_data\")) {\n url = this.project.get(\"slug\") + \"-\" + this.project.get(\"videoconferences_extra_data\");\n } else {\n url = this.project.get(\"slug\");\n }\n return baseUrl + url;\n };\n\n return ProjectMenuController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"ProjectMenu\", ProjectMenuController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project-menu.directive.coffee\n */\n\n(function() {\n var ProjectMenuDirective, taiga;\n\n taiga = this.taiga;\n\n ProjectMenuDirective = function(projectService, lightboxFactory) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var projectChange;\n projectChange = function() {\n if (projectService.project) {\n return ctrl.show();\n } else {\n return ctrl.hide();\n }\n };\n scope.$watch((function() {\n return projectService.project;\n }), projectChange);\n scope.vm.fixed = false;\n return $(window).on(\"scroll\", function() {\n var position;\n position = $(window).scrollTop();\n if (position > 100 && scope.vm.fixed === false) {\n scope.vm.fixed = true;\n return scope.$digest();\n } else if (position < 100 && scope.vm.fixed === true) {\n scope.vm.fixed = false;\n return scope.$digest();\n }\n });\n };\n return {\n scope: {},\n controller: \"ProjectMenu\",\n controllerAs: \"vm\",\n templateUrl: \"components/project-menu/project-menu.html\",\n link: link\n };\n };\n\n ProjectMenuDirective.$inject = [\"tgProjectService\", \"tgLightboxFactory\"];\n\n angular.module(\"taigaComponents\").directive(\"tgProjectMenu\", ProjectMenuDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.directive.coffee\n */\n\n(function() {\n var TermsOfServiceAndPrivacyPolicyNoticeDirective;\n\n TermsOfServiceAndPrivacyPolicyNoticeDirective = function($config) {\n var link;\n link = function(scope, el, attrs) {\n scope.privacyPolicyUrl = $config.get(\"privacyPolicyUrl\");\n return scope.termsOfServiceUrl = $config.get(\"termsOfServiceUrl\");\n };\n return {\n restrict: \"AE\",\n scope: {},\n link: link,\n templateUrl: \"components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html\"\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgTermsOfServiceAndPrivacyPolicyNotice\", [\"$tgConfig\", TermsOfServiceAndPrivacyPolicyNoticeDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: vote-button.controller.coffee\n */\n\n(function() {\n var VoteButtonController;\n\n VoteButtonController = (function() {\n VoteButtonController.$inject = [\"tgCurrentUserService\"];\n\n function VoteButtonController(currentUserService) {\n this.currentUserService = currentUserService;\n this.user = this.currentUserService.getUser();\n this.isMouseOver = false;\n this.loading = false;\n }\n\n VoteButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n VoteButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n VoteButtonController.prototype.toggleVote = function() {\n var promise;\n this.loading = true;\n if (!this.item.is_voter) {\n promise = this._upvote();\n } else {\n promise = this._downvote();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n VoteButtonController.prototype._upvote = function() {\n return this.onUpvote().then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this));\n };\n\n VoteButtonController.prototype._downvote = function() {\n return this.onDownvote();\n };\n\n return VoteButtonController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"VoteButton\", VoteButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: vote-button.directive.coffee\n */\n\n(function() {\n var VoteButtonDirective;\n\n VoteButtonDirective = function() {\n return {\n scope: {},\n controller: \"VoteButton\",\n bindToController: {\n item: \"=\",\n onUpvote: \"=\",\n onDownvote: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: \"components/vote-button/vote-button.html\"\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgVoteButton\", VoteButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-button.controller.coffee\n */\n\n(function() {\n var WatchButtonController;\n\n WatchButtonController = (function() {\n WatchButtonController.$inject = [\"tgCurrentUserService\", \"$rootScope\"];\n\n function WatchButtonController(currentUserService, rootScope) {\n this.currentUserService = currentUserService;\n this.rootScope = rootScope;\n this.user = this.currentUserService.getUser();\n this.isMouseOver = false;\n this.loading = false;\n }\n\n WatchButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n WatchButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n WatchButtonController.prototype.openWatchers = function() {\n return this.rootScope.$broadcast(\"watcher:add\", this.item);\n };\n\n WatchButtonController.prototype.getPerms = function() {\n var name, perms;\n if (!this.item) {\n return \"\";\n }\n name = this.item._name;\n perms = {\n userstories: 'modify_us',\n issues: 'modify_issue',\n tasks: 'modify_task'\n };\n return perms[name];\n };\n\n WatchButtonController.prototype.toggleWatch = function() {\n var promise;\n this.loading = true;\n if (!this.item.is_watcher) {\n promise = this._watch();\n } else {\n promise = this._unwatch();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n WatchButtonController.prototype._watch = function() {\n return this.onWatch().then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this));\n };\n\n WatchButtonController.prototype._unwatch = function() {\n return this.onUnwatch();\n };\n\n return WatchButtonController;\n\n })();\n\n angular.module(\"taigaComponents\").controller(\"WatchButton\", WatchButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-button.directive.coffee\n */\n\n(function() {\n var WatchButtonDirective;\n\n WatchButtonDirective = function() {\n return {\n scope: {},\n controller: \"WatchButton\",\n bindToController: {\n item: \"=\",\n onWatch: \"=\",\n onUnwatch: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: function(item, attributes) {\n return \"components/watch-button/watch-button-\" + attributes.environment + \".html\";\n }\n };\n };\n\n angular.module(\"taigaComponents\").directive(\"tgWatchButton\", WatchButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home-order-by.controller.coffee\n */\n\n(function() {\n var DiscoverHomeOrderByController;\n\n DiscoverHomeOrderByController = (function() {\n DiscoverHomeOrderByController.$inject = ['$translate'];\n\n function DiscoverHomeOrderByController(translate) {\n this.translate = translate;\n this.is_open = false;\n this.texts = {\n week: this.translate.instant('DISCOVER.FILTERS.WEEK'),\n month: this.translate.instant('DISCOVER.FILTERS.MONTH'),\n year: this.translate.instant('DISCOVER.FILTERS.YEAR'),\n all: this.translate.instant('DISCOVER.FILTERS.ALL_TIME')\n };\n }\n\n DiscoverHomeOrderByController.prototype.currentText = function() {\n return this.texts[this.currentOrderBy];\n };\n\n DiscoverHomeOrderByController.prototype.open = function() {\n return this.is_open = true;\n };\n\n DiscoverHomeOrderByController.prototype.close = function() {\n return this.is_open = false;\n };\n\n DiscoverHomeOrderByController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n this.is_open = false;\n return this.onChange({\n orderBy: this.currentOrderBy\n });\n };\n\n return DiscoverHomeOrderByController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverHomeOrderBy\", DiscoverHomeOrderByController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home-order-by.directive.coffee\n */\n\n(function() {\n var DiscoverHomeOrderByDirective;\n\n DiscoverHomeOrderByDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"DiscoverHomeOrderBy\",\n controllerAs: \"vm\",\n bindToController: true,\n templateUrl: \"discover/components/discover-home-order-by/discover-home-order-by.html\",\n scope: {\n currentOrderBy: \"=orderBy\",\n onChange: \"&\"\n },\n link: link\n };\n };\n\n DiscoverHomeOrderByDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverHomeOrderBy\", DiscoverHomeOrderByDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-bar.controller.coffee\n */\n\n(function() {\n var DiscoverSearchBarController;\n\n DiscoverSearchBarController = (function() {\n DiscoverSearchBarController.$inject = ['tgDiscoverProjectsService'];\n\n function DiscoverSearchBarController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, 'projects', (function(_this) {\n return function() {\n return _this.discoverProjectsService.projectsCount;\n };\n })(this));\n this.discoverProjectsService.fetchStats();\n }\n\n DiscoverSearchBarController.prototype.selectFilter = function(filter) {\n return this.onChange({\n filter: filter,\n q: this.q\n });\n };\n\n DiscoverSearchBarController.prototype.submitFilter = function() {\n return this.onChange({\n filter: this.filter,\n q: this.q\n });\n };\n\n return DiscoverSearchBarController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearchBar\", DiscoverSearchBarController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.directive.coffee\n */\n\n(function() {\n var DiscoverSearchBarDirective;\n\n DiscoverSearchBarDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {};\n return {\n controller: \"DiscoverSearchBar\",\n controllerAs: \"vm\",\n templateUrl: 'discover/components/discover-search-bar/discover-search-bar.html',\n bindToController: true,\n scope: {\n q: \"=\",\n filter: \"=\",\n onChange: \"&\"\n },\n link: link\n };\n };\n\n DiscoverSearchBarDirective.$inject = [];\n\n angular.module('taigaDiscover').directive('tgDiscoverSearchBar', DiscoverSearchBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-list-header.controller.coffee\n */\n\n(function() {\n var DiscoverSearchListHeaderController;\n\n DiscoverSearchListHeaderController = (function() {\n DiscoverSearchListHeaderController.$inject = [];\n\n function DiscoverSearchListHeaderController() {\n this.like_is_open = this.orderBy.indexOf('-total_fans') === 0;\n this.activity_is_open = this.orderBy.indexOf('-total_activity') === 0;\n }\n\n DiscoverSearchListHeaderController.prototype.openLike = function() {\n this.like_is_open = true;\n this.activity_is_open = false;\n return this.setOrderBy('-total_fans_last_week');\n };\n\n DiscoverSearchListHeaderController.prototype.openActivity = function() {\n this.activity_is_open = true;\n this.like_is_open = false;\n return this.setOrderBy('-total_activity_last_week');\n };\n\n DiscoverSearchListHeaderController.prototype.setOrderBy = function(type) {\n if (type == null) {\n type = '';\n }\n if (!type) {\n this.like_is_open = false;\n this.activity_is_open = false;\n }\n return this.onChange({\n orderBy: type\n });\n };\n\n return DiscoverSearchListHeaderController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearchListHeader\", DiscoverSearchListHeaderController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search-list-header.directive.coffee\n */\n\n(function() {\n var DiscoverSearchListHeaderDirective;\n\n DiscoverSearchListHeaderDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"DiscoverSearchListHeader\",\n controllerAs: \"vm\",\n bindToController: true,\n templateUrl: \"discover/components/discover-search-list-header/discover-search-list-header.html\",\n scope: {\n onChange: \"&\",\n orderBy: \"=\"\n },\n link: link\n };\n };\n\n DiscoverSearchListHeaderDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverSearchListHeader\", DiscoverSearchListHeaderDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: featured-projects.controller.coffee\n */\n\n(function() {\n var FeaturedProjectsController;\n\n FeaturedProjectsController = (function() {\n FeaturedProjectsController.$inject = [\"tgDiscoverProjectsService\"];\n\n function FeaturedProjectsController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"featured\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.featured;\n };\n })(this));\n this.discoverProjectsService.fetchFeatured();\n }\n\n return FeaturedProjectsController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"FeaturedProjects\", FeaturedProjectsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: featured-projects.directive.coffee\n */\n\n(function() {\n var FeaturedProjectsDirective;\n\n FeaturedProjectsDirective = function() {\n var link;\n link = function(scope, el, attrs) {};\n return {\n controller: \"FeaturedProjects\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/featured-projects/featured-projects.html\",\n scope: {},\n link: link\n };\n };\n\n FeaturedProjectsDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgFeaturedProjects\", FeaturedProjectsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: highlighted.directive.coffee\n */\n\n(function() {\n var HighlightedDirective;\n\n HighlightedDirective = function() {\n return {\n templateUrl: \"discover/components/highlighted/highlighted.html\",\n scope: {\n loading: \"=\",\n highlighted: \"=\",\n orderBy: \"=\"\n }\n };\n };\n\n HighlightedDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgHighlighted\", HighlightedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-active.controller.coffee\n */\n\n(function() {\n var MostActiveController;\n\n MostActiveController = (function() {\n MostActiveController.$inject = [\"tgDiscoverProjectsService\"];\n\n function MostActiveController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"highlighted\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.mostActive;\n };\n })(this));\n this.currentOrderBy = 'week';\n this.order_by = this.getOrderBy();\n }\n\n MostActiveController.prototype.fetch = function() {\n this.loading = true;\n this.order_by = this.getOrderBy();\n return this.discoverProjectsService.fetchMostActive({\n order_by: this.order_by\n }).then((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n MostActiveController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n return this.fetch();\n };\n\n MostActiveController.prototype.getOrderBy = function(type) {\n if (this.currentOrderBy === 'all') {\n return '-total_activity';\n } else {\n return '-total_activity_last_' + this.currentOrderBy;\n }\n };\n\n return MostActiveController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"MostActive\", MostActiveController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-active.directive.coffee\n */\n\n(function() {\n var MostActiveDirective;\n\n MostActiveDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"MostActive\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/most-active/most-active.html\",\n scope: {},\n link: link\n };\n };\n\n MostActiveDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgMostActive\", MostActiveDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: msot-liked.controller.coffee\n */\n\n(function() {\n var MostLikedController;\n\n MostLikedController = (function() {\n MostLikedController.$inject = [\"tgDiscoverProjectsService\"];\n\n function MostLikedController(discoverProjectsService) {\n this.discoverProjectsService = discoverProjectsService;\n taiga.defineImmutableProperty(this, \"highlighted\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.mostLiked;\n };\n })(this));\n this.currentOrderBy = 'week';\n this.order_by = this.getOrderBy();\n }\n\n MostLikedController.prototype.fetch = function() {\n this.loading = true;\n this.order_by = this.getOrderBy();\n return this.discoverProjectsService.fetchMostLiked({\n order_by: this.order_by\n }).then((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n MostLikedController.prototype.orderBy = function(type) {\n this.currentOrderBy = type;\n return this.fetch();\n };\n\n MostLikedController.prototype.getOrderBy = function() {\n if (this.currentOrderBy === 'all') {\n return '-total_fans';\n } else {\n return '-total_fans_last_' + this.currentOrderBy;\n }\n };\n\n return MostLikedController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"MostLiked\", MostLikedController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: most-liked.directive.coffee\n */\n\n(function() {\n var MostLikedDirective;\n\n MostLikedDirective = function() {\n var link;\n link = function(scope, el, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"MostLiked\",\n controllerAs: \"vm\",\n templateUrl: \"discover/components/most-liked/most-liked.html\",\n scope: {},\n link: link\n };\n };\n\n MostLikedDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgMostLiked\", MostLikedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-home.controller.coffee\n */\n\n(function() {\n var DiscoverHomeController;\n\n DiscoverHomeController = (function() {\n DiscoverHomeController.$inject = ['$tgLocation', '$tgNavUrls'];\n\n function DiscoverHomeController(location, navUrls) {\n this.location = location;\n this.navUrls = navUrls;\n }\n\n DiscoverHomeController.prototype.onSubmit = function(q) {\n var url;\n url = this.navUrls.resolve('discover-search');\n return this.location.search('text', q).path(url);\n };\n\n return DiscoverHomeController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverHome\", DiscoverHomeController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.controller.coffee\n */\n\n(function() {\n var DiscoverSearchController;\n\n DiscoverSearchController = (function() {\n DiscoverSearchController.$inject = ['$routeParams', 'tgDiscoverProjectsService', '$route'];\n\n function DiscoverSearchController(routeParams, discoverProjectsService, route) {\n this.routeParams = routeParams;\n this.discoverProjectsService = discoverProjectsService;\n this.route = route;\n this.page = 1;\n taiga.defineImmutableProperty(this, \"searchResult\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.searchResult;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"nextSearchPage\", (function(_this) {\n return function() {\n return _this.discoverProjectsService.nextSearchPage;\n };\n })(this));\n this.q = this.routeParams.text;\n this.filter = this.routeParams.filter || 'all';\n this.orderBy = this.routeParams['order_by'] || '';\n this.loadingGlobal = false;\n this.loadingList = false;\n this.loadingPagination = false;\n }\n\n DiscoverSearchController.prototype.fetch = function() {\n this.page = 1;\n this.discoverProjectsService.resetSearchList();\n return this.search();\n };\n\n DiscoverSearchController.prototype.fetchByGlobalSearch = function() {\n if (this.loadingGlobal) {\n return;\n }\n this.loadingGlobal = true;\n return this.fetch().then((function(_this) {\n return function() {\n return _this.loadingGlobal = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.fetchByOrderBy = function() {\n if (this.loadingList) {\n return;\n }\n this.loadingList = true;\n return this.fetch().then((function(_this) {\n return function() {\n return _this.loadingList = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.showMore = function() {\n if (this.loadingPagination) {\n return;\n }\n this.loadingPagination = true;\n this.page++;\n return this.search().then((function(_this) {\n return function() {\n return _this.loadingPagination = false;\n };\n })(this));\n };\n\n DiscoverSearchController.prototype.search = function() {\n var filter, params;\n filter = this.getFilter();\n params = {\n page: this.page,\n q: this.q,\n order_by: this.orderBy\n };\n _.assign(params, filter);\n return this.discoverProjectsService.fetchSearch(params);\n };\n\n DiscoverSearchController.prototype.getFilter = function() {\n if (this.filter === 'people') {\n return {\n is_looking_for_people: true\n };\n } else if (this.filter === 'scrum') {\n return {\n is_backlog_activated: true\n };\n } else if (this.filter === 'kanban') {\n return {\n is_kanban_activated: true\n };\n }\n return {};\n };\n\n DiscoverSearchController.prototype.onChangeFilter = function(filter, q) {\n this.filter = filter;\n this.q = q;\n this.route.updateParams({\n filter: this.filter,\n text: this.q\n });\n return this.fetchByGlobalSearch();\n };\n\n DiscoverSearchController.prototype.onChangeOrder = function(orderBy) {\n this.orderBy = orderBy;\n this.route.updateParams({\n order_by: orderBy\n });\n return this.fetchByOrderBy();\n };\n\n return DiscoverSearchController;\n\n })();\n\n angular.module(\"taigaDiscover\").controller(\"DiscoverSearch\", DiscoverSearchController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-search.directive.coffee\n */\n\n(function() {\n var DiscoverSearchDirective;\n\n DiscoverSearchDirective = function() {\n var link;\n link = function(scope, element, attrs, ctrl) {\n return ctrl.fetch();\n };\n return {\n controller: \"DiscoverSearch\",\n controllerAs: \"vm\",\n link: link\n };\n };\n\n DiscoverSearchDirective.$inject = [];\n\n angular.module(\"taigaDiscover\").directive(\"tgDiscoverSearch\", DiscoverSearchDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: discover-projects.service.coffee\n */\n\n(function() {\n var DiscoverProjectsService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n DiscoverProjectsService = (function(superClass) {\n extend(DiscoverProjectsService, superClass);\n\n DiscoverProjectsService.$inject = [\"tgResources\", \"tgProjectsService\"];\n\n function DiscoverProjectsService(rs, projectsService) {\n this.rs = rs;\n this.projectsService = projectsService;\n this._mostLiked = Immutable.List();\n this._mostActive = Immutable.List();\n this._featured = Immutable.List();\n this._searchResult = Immutable.List();\n this._projectsCount = 0;\n this.decorate = this.projectsService._decorate.bind(this.projectsService);\n taiga.defineImmutableProperty(this, \"mostLiked\", (function(_this) {\n return function() {\n return _this._mostLiked;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"mostActive\", (function(_this) {\n return function() {\n return _this._mostActive;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"featured\", (function(_this) {\n return function() {\n return _this._featured;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"searchResult\", (function(_this) {\n return function() {\n return _this._searchResult;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"nextSearchPage\", (function(_this) {\n return function() {\n return _this._nextSearchPage;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"projectsCount\", (function(_this) {\n return function() {\n return _this._projectsCount;\n };\n })(this));\n }\n\n DiscoverProjectsService.prototype.fetchMostLiked = function(params) {\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 5);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._mostLiked = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchMostActive = function(params) {\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 5);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._mostActive = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchFeatured = function() {\n var params;\n params = {\n is_featured: true\n };\n return this.rs.projects.getProjects(params, false).then((function(_this) {\n return function(result) {\n var data, projects;\n data = result.data.slice(0, 4);\n projects = Immutable.fromJS(data);\n projects = projects.map(_this.decorate);\n return _this._featured = projects;\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.resetSearchList = function() {\n return this._searchResult = Immutable.List();\n };\n\n DiscoverProjectsService.prototype.fetchStats = function() {\n return this.rs.stats.discover().then((function(_this) {\n return function(discover) {\n return _this._projectsCount = discover.getIn(['projects', 'total']);\n };\n })(this));\n };\n\n DiscoverProjectsService.prototype.fetchSearch = function(params) {\n return this.rs.projects.getProjects(params).then((function(_this) {\n return function(result) {\n var projects;\n _this._nextSearchPage = !!result.headers('X-Pagination-Next');\n projects = Immutable.fromJS(result.data);\n projects = projects.map(_this.decorate);\n return _this._searchResult = _this._searchResult.concat(projects);\n };\n })(this));\n };\n\n return DiscoverProjectsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaDiscover\").service(\"tgDiscoverProjectsService\", DiscoverProjectsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-app.controller.coffee\n */\n\n(function() {\n var ExternalAppController, taiga,\n bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ExternalAppController = (function(superClass) {\n extend(ExternalAppController, superClass);\n\n ExternalAppController.$inject = [\"$routeParams\", \"tgExternalAppsService\", \"$window\", \"tgCurrentUserService\", \"$location\", \"$tgNavUrls\", \"tgXhrErrorService\", \"tgLoader\"];\n\n function ExternalAppController(routeParams, externalAppsService, window, currentUserService, location, navUrls, xhrError, loader) {\n var loginUrl, nextUrl;\n this.routeParams = routeParams;\n this.externalAppsService = externalAppsService;\n this.window = window;\n this.currentUserService = currentUserService;\n this.location = location;\n this.navUrls = navUrls;\n this.xhrError = xhrError;\n this.loader = loader;\n this.createApplicationToken = bind(this.createApplicationToken, this);\n this._getApplicationToken = bind(this._getApplicationToken, this);\n this._redirect = bind(this._redirect, this);\n this.loader.start(false);\n this._applicationId = this.routeParams.application;\n this._state = this.routeParams.state;\n this._getApplicationToken();\n this._user = this.currentUserService.getUser();\n this._application = null;\n nextUrl = encodeURIComponent(this.location.url());\n loginUrl = this.navUrls.resolve(\"login\");\n this.loginWithAnotherUserUrl = loginUrl + \"?next=\" + nextUrl;\n taiga.defineImmutableProperty(this, \"user\", (function(_this) {\n return function() {\n return _this._user;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"application\", (function(_this) {\n return function() {\n return _this._application;\n };\n })(this));\n }\n\n ExternalAppController.prototype._redirect = function(applicationToken) {\n var nextUrl;\n nextUrl = applicationToken.get(\"next_url\");\n return this.window.open(nextUrl, \"_self\");\n };\n\n ExternalAppController.prototype._getApplicationToken = function() {\n return this.externalAppsService.getApplicationToken(this._applicationId, this._state).then((function(_this) {\n return function(data) {\n _this._application = data.get(\"application\");\n if (data.get(\"auth_code\")) {\n return _this._redirect(data);\n } else {\n return _this.loader.pageLoaded();\n }\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n _this.loader.pageLoaded();\n return _this.xhrError.response(xhr);\n };\n })(this));\n };\n\n ExternalAppController.prototype.cancel = function() {\n return this.window.history.back();\n };\n\n ExternalAppController.prototype.createApplicationToken = function() {\n return this.externalAppsService.authorizeApplicationToken(this._applicationId, this._state).then((function(_this) {\n return function(data) {\n return _this._redirect(data);\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n return _this.xhrError.response(xhr);\n };\n })(this));\n };\n\n return ExternalAppController;\n\n })(taiga.Controller);\n\n angular.module(\"taigaExternalApps\").controller(\"ExternalApp\", ExternalAppController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-app.service.coffee\n */\n\n(function() {\n var ExternalAppsService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n ExternalAppsService = (function(superClass) {\n extend(ExternalAppsService, superClass);\n\n ExternalAppsService.$inject = [\"tgResources\"];\n\n function ExternalAppsService(rs) {\n this.rs = rs;\n }\n\n ExternalAppsService.prototype.getApplicationToken = function(applicationId, state) {\n return this.rs.externalapps.getApplicationToken(applicationId, state);\n };\n\n ExternalAppsService.prototype.authorizeApplicationToken = function(applicationId, state) {\n return this.rs.externalapps.authorizeApplicationToken(applicationId, state);\n };\n\n return ExternalAppsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaExternalApps\").service(\"tgExternalAppsService\", ExternalAppsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: feedback.service.coffee\n */\n\n(function() {\n var FeedbackService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n FeedbackService = (function(superClass) {\n extend(FeedbackService, superClass);\n\n FeedbackService.$inject = [\"tgLightboxFactory\"];\n\n function FeedbackService(lightboxFactory) {\n this.lightboxFactory = lightboxFactory;\n }\n\n FeedbackService.prototype.sendFeedback = function() {\n return this.lightboxFactory.create(\"tg-lb-feedback\", {\n \"class\": \"lightbox lightbox-feedback lightbox-generic-form\"\n });\n };\n\n return FeedbackService;\n\n })(taiga.Service);\n\n angular.module(\"taigaFeedback\").service(\"tgFeedbackService\", FeedbackService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: duty.directive.coffee\n */\n\n(function() {\n var DutyDirective;\n\n DutyDirective = function(navurls, $translate) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.vm.duty = scope.duty;\n return scope.vm.getDutyType = function() {\n if (scope.vm.duty) {\n if (scope.vm.duty.get('_name') === \"userstories\") {\n return $translate.instant(\"COMMON.USER_STORY\");\n }\n if (scope.vm.duty.get('_name') === \"tasks\") {\n return $translate.instant(\"COMMON.TASK\");\n }\n if (scope.vm.duty.get('_name') === \"issues\") {\n return $translate.instant(\"COMMON.ISSUE\");\n }\n }\n };\n };\n return {\n templateUrl: \"home/duties/duty.html\",\n scope: {\n \"duty\": \"=tgDuty\"\n },\n link: link\n };\n };\n\n DutyDirective.$inject = [\"$tgNavUrls\", \"$translate\"];\n\n angular.module(\"taigaHome\").directive(\"tgDuty\", DutyDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.controller.coffee\n */\n\n(function() {\n var HomeController;\n\n HomeController = (function() {\n HomeController.$inject = [\"tgCurrentUserService\", \"$location\", \"$tgNavUrls\"];\n\n function HomeController(currentUserService, location, navUrls) {\n this.currentUserService = currentUserService;\n this.location = location;\n this.navUrls = navUrls;\n if (!this.currentUserService.getUser()) {\n this.location.path(this.navUrls.resolve(\"discover\"));\n }\n }\n\n return HomeController;\n\n })();\n\n angular.module(\"taigaHome\").controller(\"Home\", HomeController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home.service.coffee\n */\n\n(function() {\n var HomeService, groupBy,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n groupBy = this.taiga.groupBy;\n\n HomeService = (function(superClass) {\n extend(HomeService, superClass);\n\n HomeService.$inject = [\"$tgNavUrls\", \"tgResources\", \"tgProjectsService\"];\n\n function HomeService(navurls, rs, projectsService) {\n this.navurls = navurls;\n this.rs = rs;\n this.projectsService = projectsService;\n }\n\n HomeService.prototype._attachProjectInfoToWorkInProgress = function(workInProgress, projectsById) {\n var _attachProjectInfoToDuty, _duties, assignedTo, watching;\n _attachProjectInfoToDuty = (function(_this) {\n return function(duty, objType) {\n var ctx, project, url;\n project = projectsById.get(String(duty.get('project')));\n ctx = {\n project: project.get('slug'),\n ref: duty.get('ref')\n };\n url = _this.navurls.resolve(\"project-\" + objType + \"-detail\", ctx);\n duty = duty.set('url', url);\n duty = duty.set('projectName', project.get('name'));\n duty = duty.set(\"_name\", objType);\n return duty;\n };\n })(this);\n assignedTo = workInProgress.get(\"assignedTo\");\n if (assignedTo.get(\"userStories\")) {\n _duties = assignedTo.get(\"userStories\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"userstories\");\n });\n assignedTo = assignedTo.set(\"userStories\", _duties);\n }\n if (assignedTo.get(\"tasks\")) {\n _duties = assignedTo.get(\"tasks\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"tasks\");\n });\n assignedTo = assignedTo.set(\"tasks\", _duties);\n }\n if (assignedTo.get(\"issues\")) {\n _duties = assignedTo.get(\"issues\").map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"issues\");\n });\n assignedTo = assignedTo.set(\"issues\", _duties);\n }\n watching = workInProgress.get(\"watching\");\n if (watching.get(\"userStories\")) {\n _duties = watching.get(\"userStories\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"userstories\");\n });\n watching = watching.set(\"userStories\", _duties);\n }\n if (watching.get(\"tasks\")) {\n _duties = watching.get(\"tasks\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"tasks\");\n });\n watching = watching.set(\"tasks\", _duties);\n }\n if (watching.get(\"issues\")) {\n _duties = watching.get(\"issues\").filter(function(duty) {\n return !!projectsById.get(String(duty.get('project')));\n });\n _duties = _duties.map(function(duty) {\n return _attachProjectInfoToDuty(duty, \"issues\");\n });\n watching = watching.set(\"issues\", _duties);\n }\n workInProgress = workInProgress.set(\"assignedTo\", assignedTo);\n return workInProgress = workInProgress.set(\"watching\", watching);\n };\n\n HomeService.prototype.getWorkInProgress = function(userId) {\n var assignedIssuesPromise, assignedTasksPromise, assignedTo, assignedUserStoriesPromise, params, params_us, projectsById, projectsPromise, watching, watchingIssuesPromise, watchingTasksPromise, watchingUserStoriesPromise, workInProgress;\n projectsById = Immutable.Map();\n projectsPromise = this.projectsService.getProjectsByUserId(userId).then(function(projects) {\n return projectsById = Immutable.fromJS(groupBy(projects.toJS(), function(p) {\n return p.id;\n }));\n });\n assignedTo = Immutable.Map();\n params = {\n status__is_closed: false,\n assigned_to: userId\n };\n params_us = {\n is_closed: false,\n assigned_to: userId\n };\n assignedUserStoriesPromise = this.rs.userstories.listInAllProjects(params_us).then(function(userstories) {\n return assignedTo = assignedTo.set(\"userStories\", userstories);\n });\n assignedTasksPromise = this.rs.tasks.listInAllProjects(params).then(function(tasks) {\n return assignedTo = assignedTo.set(\"tasks\", tasks);\n });\n assignedIssuesPromise = this.rs.issues.listInAllProjects(params).then(function(issues) {\n return assignedTo = assignedTo.set(\"issues\", issues);\n });\n params = {\n status__is_closed: false,\n watchers: userId\n };\n params_us = {\n is_closed: false,\n watchers: userId\n };\n watching = Immutable.Map();\n watchingUserStoriesPromise = this.rs.userstories.listInAllProjects(params_us).then(function(userstories) {\n return watching = watching.set(\"userStories\", userstories);\n });\n watchingTasksPromise = this.rs.tasks.listInAllProjects(params).then(function(tasks) {\n return watching = watching.set(\"tasks\", tasks);\n });\n watchingIssuesPromise = this.rs.issues.listInAllProjects(params).then(function(issues) {\n return watching = watching.set(\"issues\", issues);\n });\n workInProgress = Immutable.Map();\n return Promise.all([projectsPromise, assignedUserStoriesPromise, assignedTasksPromise, assignedIssuesPromise, watchingUserStoriesPromise, watchingTasksPromise, watchingIssuesPromise]).then((function(_this) {\n return function() {\n workInProgress = workInProgress.set(\"assignedTo\", assignedTo);\n workInProgress = workInProgress.set(\"watching\", watching);\n workInProgress = _this._attachProjectInfoToWorkInProgress(workInProgress, projectsById);\n return workInProgress;\n };\n })(this));\n };\n\n return HomeService;\n\n })(taiga.Service);\n\n angular.module(\"taigaHome\").service(\"tgHomeService\", HomeService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: home-project-list.directive.coffee\n */\n\n(function() {\n var HomeProjectListDirective;\n\n HomeProjectListDirective = function(currentUserService, projectsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n return scope.vm.newProject = function() {\n return projectsService.newProject();\n };\n };\n directive = {\n templateUrl: \"home/projects/home-project-list.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n HomeProjectListDirective.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n angular.module(\"taigaHome\").directive(\"tgHomeProjectList\", HomeProjectListDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: working-on.controller.coffee\n */\n\n(function() {\n var WorkingOnController;\n\n WorkingOnController = (function() {\n WorkingOnController.$inject = [\"tgHomeService\"];\n\n function WorkingOnController(homeService) {\n this.homeService = homeService;\n this.assignedTo = Immutable.Map();\n this.watching = Immutable.Map();\n }\n\n WorkingOnController.prototype._setAssignedTo = function(workInProgress) {\n var issues, tasks, userStories;\n userStories = workInProgress.get(\"assignedTo\").get(\"userStories\");\n tasks = workInProgress.get(\"assignedTo\").get(\"tasks\");\n issues = workInProgress.get(\"assignedTo\").get(\"issues\");\n this.assignedTo = userStories.concat(tasks).concat(issues);\n if (this.assignedTo.size > 0) {\n return this.assignedTo = this.assignedTo.sortBy(function(elem) {\n return elem.get(\"modified_date\");\n }).reverse();\n }\n };\n\n WorkingOnController.prototype._setWatching = function(workInProgress) {\n var issues, tasks, userStories;\n userStories = workInProgress.get(\"watching\").get(\"userStories\");\n tasks = workInProgress.get(\"watching\").get(\"tasks\");\n issues = workInProgress.get(\"watching\").get(\"issues\");\n this.watching = userStories.concat(tasks).concat(issues);\n if (this.watching.size > 0) {\n return this.watching = this.watching.sortBy(function(elem) {\n return elem.get(\"modified_date\");\n }).reverse();\n }\n };\n\n WorkingOnController.prototype.getWorkInProgress = function(userId) {\n return this.homeService.getWorkInProgress(userId).then((function(_this) {\n return function(workInProgress) {\n _this._setAssignedTo(workInProgress);\n return _this._setWatching(workInProgress);\n };\n })(this));\n };\n\n return WorkingOnController;\n\n })();\n\n angular.module(\"taigaHome\").controller(\"WorkingOn\", WorkingOnController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: working-on.directive.coffee\n */\n\n(function() {\n var WorkingOnDirective;\n\n WorkingOnDirective = function(homeService, currentUserService) {\n var link;\n link = function(scope, el, attrs, ctrl) {\n var user, userId;\n user = currentUserService.getUser();\n if (user) {\n userId = user.get(\"id\");\n return ctrl.getWorkInProgress(userId);\n }\n };\n return {\n controller: \"WorkingOn\",\n controllerAs: \"vm\",\n templateUrl: \"home/working-on/working-on.html\",\n scope: {},\n link: link\n };\n };\n\n WorkingOnDirective.$inject = [\"tgHomeService\", \"tgCurrentUserService\"];\n\n angular.module(\"taigaHome\").directive(\"tgWorkingOn\", WorkingOnDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: dropdown-project-list.directive.coffee\n */\n\n(function() {\n var DropdownProjectListDirective;\n\n DropdownProjectListDirective = function(currentUserService, projectsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n return scope.vm.newProject = function() {\n return projectsService.newProject();\n };\n };\n directive = {\n templateUrl: \"navigation-bar/dropdown-project-list/dropdown-project-list.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n DropdownProjectListDirective.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgDropdownProjectList\", DropdownProjectListDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: dropdown-user.directive.coffee\n */\n\n(function() {\n var DropdownUserDirective;\n\n DropdownUserDirective = function(authService, configService, locationService, navUrlsService, feedbackService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.vm.isFeedbackEnabled = configService.get(\"feedbackEnabled\");\n taiga.defineImmutableProperty(scope.vm, \"user\", function() {\n return authService.userData;\n });\n scope.vm.logout = function() {\n authService.logout();\n locationService.url(navUrlsService.resolve(\"discover\"));\n return locationService.search({});\n };\n return scope.vm.sendFeedback = function() {\n return feedbackService.sendFeedback();\n };\n };\n directive = {\n templateUrl: \"navigation-bar/dropdown-user/dropdown-user.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n DropdownUserDirective.$inject = [\"$tgAuth\", \"$tgConfig\", \"$tgLocation\", \"$tgNavUrls\", \"tgFeedbackService\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgDropdownUser\", DropdownUserDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.directive.coffee\n */\n\n(function() {\n var NavigationBarDirective;\n\n NavigationBarDirective = function(currentUserService, navigationBarService, locationService, navUrlsService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n scope.vm = {};\n scope.$on(\"$routeChangeSuccess\", function() {\n if (locationService.path() === \"/\") {\n return scope.vm.active = true;\n } else {\n return scope.vm.active = false;\n }\n });\n taiga.defineImmutableProperty(scope.vm, \"projects\", function() {\n return currentUserService.projects.get(\"recents\");\n });\n taiga.defineImmutableProperty(scope.vm, \"isAuthenticated\", function() {\n return currentUserService.isAuthenticated();\n });\n taiga.defineImmutableProperty(scope.vm, \"isEnabledHeader\", function() {\n return navigationBarService.isEnabledHeader();\n });\n scope.vm.login = function() {\n var nextUrl;\n nextUrl = encodeURIComponent(locationService.url());\n locationService.url(navUrlsService.resolve(\"login\"));\n return locationService.search({\n next: nextUrl\n });\n };\n return scope.vm.register = function() {\n var nextUrl;\n nextUrl = encodeURIComponent(locationService.url());\n locationService.url(navUrlsService.resolve(\"register\"));\n return locationService.search({\n next: nextUrl\n });\n };\n };\n directive = {\n templateUrl: \"navigation-bar/navigation-bar.html\",\n scope: {},\n link: link\n };\n return directive;\n };\n\n NavigationBarDirective.$inject = [\"tgCurrentUserService\", \"tgNavigationBarService\", \"$tgLocation\", \"$tgNavUrls\"];\n\n angular.module(\"taigaNavigationBar\").directive(\"tgNavigationBar\", NavigationBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: navigation-bar.service.coffee\n */\n\n(function() {\n var NavigationBarService,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n NavigationBarService = (function(superClass) {\n extend(NavigationBarService, superClass);\n\n function NavigationBarService() {\n this.disableHeader();\n }\n\n NavigationBarService.prototype.enableHeader = function() {\n return this.enabledHeader = true;\n };\n\n NavigationBarService.prototype.disableHeader = function() {\n return this.enabledHeader = false;\n };\n\n NavigationBarService.prototype.isEnabledHeader = function() {\n return this.enabledHeader;\n };\n\n return NavigationBarService;\n\n })(taiga.Service);\n\n angular.module(\"taigaNavigationBar\").service(\"tgNavigationBarService\", NavigationBarService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-bar.controller.coffee\n */\n\n(function() {\n var ProfileBarController;\n\n ProfileBarController = (function() {\n ProfileBarController.$inject = [\"tgUserService\"];\n\n function ProfileBarController(userService) {\n this.userService = userService;\n this.loadStats();\n }\n\n ProfileBarController.prototype.loadStats = function() {\n return this.userService.getStats(this.user.get(\"id\")).then((function(_this) {\n return function(stats) {\n return _this.stats = stats;\n };\n })(this));\n };\n\n return ProfileBarController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileBar\", ProfileBarController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-bar.directive.coffee\n */\n\n(function() {\n var ProfileBarDirective;\n\n ProfileBarDirective = function() {\n return {\n templateUrl: \"profile/profile-bar/profile-bar.html\",\n controller: \"ProfileBar\",\n controllerAs: \"vm\",\n scope: {\n user: \"=user\",\n isCurrentUser: \"=iscurrentuser\"\n },\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileBar\", ProfileBarDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-contacts.controller.coffee\n */\n\n(function() {\n var ProfileContactsController;\n\n ProfileContactsController = (function() {\n ProfileContactsController.$inject = [\"tgUserService\", \"tgCurrentUserService\"];\n\n function ProfileContactsController(userService, currentUserService) {\n this.userService = userService;\n this.currentUserService = currentUserService;\n this.currentUser = this.currentUserService.getUser();\n this.isCurrentUser = false;\n if (this.currentUser && this.currentUser.get(\"id\") === this.user.get(\"id\")) {\n this.isCurrentUser = true;\n }\n }\n\n ProfileContactsController.prototype.loadContacts = function() {\n return this.userService.getContacts(this.user.get(\"id\")).then((function(_this) {\n return function(contacts) {\n return _this.contacts = contacts;\n };\n })(this));\n };\n\n return ProfileContactsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileContacts\", ProfileContactsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-contacts.directive.coffee\n */\n\n(function() {\n var ProfileContactsDirective;\n\n ProfileContactsDirective = function() {\n var link;\n link = function(scope, elm, attrs, ctrl) {\n return ctrl.loadContacts();\n };\n return {\n templateUrl: \"profile/profile-contacts/profile-contacts.html\",\n scope: {\n user: \"=\"\n },\n controllerAs: \"vm\",\n controller: \"ProfileContacts\",\n link: link,\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileContacts\", ProfileContactsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: items.directive.coffee\n */\n\n(function() {\n var FavItemDirective;\n\n FavItemDirective = function() {\n var link, templateUrl;\n link = function(scope, el, attrs, ctrl) {\n return scope.vm = {\n item: scope.item\n };\n };\n templateUrl = function(el, attrs) {\n if (attrs.itemType === \"project\") {\n return \"profile/profile-favs/items/project.html\";\n } else {\n return \"profile/profile-favs/items/ticket.html\";\n }\n };\n return {\n scope: {\n \"item\": \"=tgFavItem\"\n },\n link: link,\n templateUrl: templateUrl\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgFavItem\", FavItemDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-favs.controller.coffee\n */\n\n(function() {\n var FavsBaseController, ProfileLikedController, ProfileVotedController, ProfileWatchedController, debounceLeading,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n debounceLeading = this.taiga.debounceLeading;\n\n FavsBaseController = (function() {\n function FavsBaseController() {\n this._init();\n }\n\n FavsBaseController.prototype._init = function() {\n this.enableFilterByAll = true;\n this.enableFilterByProjects = true;\n this.enableFilterByUserStories = true;\n this.enableFilterByTasks = true;\n this.enableFilterByIssues = true;\n this.enableFilterByTextQuery = true;\n this._resetList();\n this.q = null;\n return this.type = null;\n };\n\n FavsBaseController.prototype._resetList = function() {\n this.items = Immutable.List();\n this.scrollDisabled = false;\n return this._page = 1;\n };\n\n FavsBaseController.prototype._enableLoadingSpinner = function() {\n return this.isLoading = true;\n };\n\n FavsBaseController.prototype._disableLoadingSpinner = function() {\n return this.isLoading = false;\n };\n\n FavsBaseController.prototype._enableScroll = function() {\n return this.scrollDisabled = false;\n };\n\n FavsBaseController.prototype._disableScroll = function() {\n return this.scrollDisabled = true;\n };\n\n FavsBaseController.prototype._checkIfHasMorePages = function(hasNext) {\n if (hasNext) {\n this._page += 1;\n return this._enableScroll();\n } else {\n return this._disableScroll();\n }\n };\n\n FavsBaseController.prototype._checkIfHasNoResults = function() {\n return this.hasNoResults = this.items.size === 0;\n };\n\n FavsBaseController.prototype.loadItems = function() {\n this._enableLoadingSpinner();\n this._disableScroll();\n return this._getItems(this.user.get(\"id\"), this._page, this.type, this.q).then((function(_this) {\n return function(response) {\n _this.items = _this.items.concat(response.get(\"data\"));\n _this._checkIfHasMorePages(response.get(\"next\"));\n _this._checkIfHasNoResults();\n _this._disableLoadingSpinner();\n return _this.items;\n };\n })(this))[\"catch\"]((function(_this) {\n return function() {\n _this._disableLoadingSpinner();\n return _this.items;\n };\n })(this));\n };\n\n FavsBaseController.prototype.filterByTextQuery = debounceLeading(500, function() {\n this._resetList();\n return this.loadItems();\n });\n\n FavsBaseController.prototype.showAll = function() {\n if (this.type !== null) {\n this.type = null;\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showProjectsOnly = function() {\n if (this.type !== \"project\") {\n this.type = \"project\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showUserStoriesOnly = function() {\n if (this.type !== \"userstory\") {\n this.type = \"userstory\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showTasksOnly = function() {\n if (this.type !== \"task\") {\n this.type = \"task\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n FavsBaseController.prototype.showIssuesOnly = function() {\n if (this.type !== \"issue\") {\n this.type = \"issue\";\n this._resetList();\n return this.loadItems();\n }\n };\n\n return FavsBaseController;\n\n })();\n\n ProfileLikedController = (function(superClass) {\n extend(ProfileLikedController, superClass);\n\n ProfileLikedController.$inject = [\"tgUserService\"];\n\n function ProfileLikedController(userService) {\n this.userService = userService;\n ProfileLikedController.__super__.constructor.call(this);\n this.enableFilterByAll = false;\n this.enableFilterByProjects = false;\n this.enableFilterByUserStories = false;\n this.enableFilterByTasks = false;\n this.enableFilterByIssues = false;\n this.enableFilterByTextQuery = true;\n this._getItems = this.userService.getLiked;\n }\n\n return ProfileLikedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileLiked\", ProfileLikedController);\n\n ProfileVotedController = (function(superClass) {\n extend(ProfileVotedController, superClass);\n\n ProfileVotedController.$inject = [\"tgUserService\"];\n\n function ProfileVotedController(userService) {\n this.userService = userService;\n ProfileVotedController.__super__.constructor.call(this);\n this.enableFilterByAll = true;\n this.enableFilterByProjects = false;\n this.enableFilterByUserStories = true;\n this.enableFilterByTasks = true;\n this.enableFilterByIssues = true;\n this.enableFilterByTextQuery = true;\n this._getItems = this.userService.getVoted;\n }\n\n return ProfileVotedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileVoted\", ProfileVotedController);\n\n ProfileWatchedController = (function(superClass) {\n extend(ProfileWatchedController, superClass);\n\n ProfileWatchedController.$inject = [\"tgUserService\"];\n\n function ProfileWatchedController(userService) {\n this.userService = userService;\n ProfileWatchedController.__super__.constructor.call(this);\n this._getItems = this.userService.getWatched;\n }\n\n return ProfileWatchedController;\n\n })(FavsBaseController);\n\n angular.module(\"taigaProfile\").controller(\"ProfileWatched\", ProfileWatchedController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-favs.directive.coffee\n */\n\n(function() {\n var ProfileLikedDirective, ProfileVotedDirective, ProfileWatchedDirective, base;\n\n base = {\n scope: {},\n bindToController: {\n user: \"=\",\n type: \"@\",\n q: \"@\",\n scrollDisabled: \"@\",\n isLoading: \"@\",\n hasNoResults: \"@\"\n },\n controller: null,\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-favs/profile-favs.html\"\n };\n\n ProfileLikedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileLiked\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileLiked\", ProfileLikedDirective);\n\n ProfileVotedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileVoted\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileVoted\", ProfileVotedDirective);\n\n ProfileWatchedDirective = function() {\n return _.extend({}, base, {\n controller: \"ProfileWatched\"\n });\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileWatched\", ProfileWatchedDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-hints.controller.coffee\n */\n\n(function() {\n var ProfileHints;\n\n ProfileHints = (function() {\n ProfileHints.prototype.HINTS = [\n {\n url: \"https://taiga.io/support/import-export-projects/\"\n }, {\n url: \"https://taiga.io/support/custom-fields/\"\n }, {}, {}\n ];\n\n function ProfileHints(translate) {\n var hintKey;\n this.translate = translate;\n hintKey = Math.floor(Math.random() * this.HINTS.length) + 1;\n this.hint = this.HINTS[hintKey - 1];\n this.hint.linkText = this.hint.linkText || 'HINTS.LINK';\n this.hint.title = this.translate.instant(\"HINTS.HINT\" + hintKey + \"_TITLE\");\n this.hint.text = this.translate.instant(\"HINTS.HINT\" + hintKey + \"_TEXT\");\n }\n\n return ProfileHints;\n\n })();\n\n ProfileHints.$inject = [\"$translate\"];\n\n angular.module(\"taigaProfile\").controller(\"ProfileHints\", ProfileHints);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-hints.directive.coffee\n */\n\n(function() {\n var ProfileHints;\n\n ProfileHints = function($translate) {\n return {\n scope: {},\n controller: \"ProfileHints\",\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-hints/profile-hints.html\"\n };\n };\n\n ProfileHints.$inject = [\"$translate\"];\n\n angular.module(\"taigaProfile\").directive(\"tgProfileHints\", ProfileHints);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-projects.controller.coffee\n */\n\n(function() {\n var ProfileProjectsController;\n\n ProfileProjectsController = (function() {\n ProfileProjectsController.$inject = [\"tgProjectsService\", \"tgUserService\"];\n\n function ProfileProjectsController(projectsService, userService) {\n this.projectsService = projectsService;\n this.userService = userService;\n }\n\n ProfileProjectsController.prototype.loadProjects = function() {\n return this.projectsService.getProjectsByUserId(this.user.get(\"id\")).then((function(_this) {\n return function(projects) {\n return _this.userService.attachUserContactsToProjects(_this.user.get(\"id\"), projects);\n };\n })(this)).then((function(_this) {\n return function(projects) {\n return _this.projects = projects;\n };\n })(this));\n };\n\n return ProfileProjectsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileProjects\", ProfileProjectsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-projects.directive.coffee\n */\n\n(function() {\n var ProfileProjectsDirective;\n\n ProfileProjectsDirective = function() {\n var link;\n link = function(scope, elm, attr, ctrl) {\n return ctrl.loadProjects();\n };\n return {\n templateUrl: \"profile/profile-projects/profile-projects.html\",\n scope: {\n user: \"=\"\n },\n link: link,\n bindToController: true,\n controllerAs: \"vm\",\n controller: \"ProfileProjects\"\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileProjects\", ProfileProjectsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tab.directive.coffee\n */\n\n(function() {\n var ProfileTabDirective;\n\n ProfileTabDirective = function() {\n var link;\n link = function(scope, element, attrs, ctrl, transclude) {\n scope.tab = {};\n attrs.$observe(\"tgProfileTab\", function(name) {\n return scope.tab.name = name;\n });\n attrs.$observe(\"tabTitle\", function(title) {\n return scope.tab.title = title;\n });\n scope.tab.icon = attrs.tabIcon;\n scope.tab.active = !!attrs.tabActive;\n if (scope.$eval(attrs.tabDisabled) !== true) {\n return ctrl.addTab(scope.tab);\n }\n };\n return {\n templateUrl: \"profile/profile-tab/profile-tab.html\",\n scope: {},\n require: \"^tgProfileTabs\",\n link: link,\n transclude: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileTab\", ProfileTabDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tabs.controller.coffee\n */\n\n(function() {\n var ProfileTabsController;\n\n ProfileTabsController = (function() {\n function ProfileTabsController() {\n this.tabs = [];\n }\n\n ProfileTabsController.prototype.addTab = function(tab) {\n return this.tabs.push(tab);\n };\n\n ProfileTabsController.prototype.toggleTab = function(tab) {\n _.map(this.tabs, function(tab) {\n return tab.active = false;\n });\n return tab.active = true;\n };\n\n return ProfileTabsController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"ProfileTabs\", ProfileTabsController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile-tabs.directive.coffee\n */\n\n(function() {\n var ProfileTabsDirective;\n\n ProfileTabsDirective = function() {\n return {\n scope: {},\n controller: \"ProfileTabs\",\n controllerAs: \"vm\",\n templateUrl: \"profile/profile-tabs/profile-tabs.html\",\n transclude: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgProfileTabs\", ProfileTabsDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: profile.controller.coffee\n */\n\n(function() {\n var ProfileController;\n\n ProfileController = (function() {\n ProfileController.$inject = [\"tgAppMetaService\", \"tgCurrentUserService\", \"$routeParams\", \"tgUserService\", \"tgXhrErrorService\", \"$translate\"];\n\n function ProfileController(appMetaService, currentUserService, routeParams, userService, xhrError, translate) {\n this.appMetaService = appMetaService;\n this.currentUserService = currentUserService;\n this.routeParams = routeParams;\n this.userService = userService;\n this.xhrError = xhrError;\n this.translate = translate;\n this.isCurrentUser = false;\n if (this.routeParams.slug) {\n this.userService.getUserByUserName(this.routeParams.slug).then((function(_this) {\n return function(user) {\n if (!user.get('is_active')) {\n return _this.xhrError.notFound();\n } else {\n _this.user = user;\n _this.isCurrentUser = false;\n _this._setMeta(_this.user);\n return user;\n }\n };\n })(this))[\"catch\"]((function(_this) {\n return function(xhr) {\n return _this.xhrError.response(xhr);\n };\n })(this));\n } else {\n this.user = this.currentUserService.getUser();\n this.isCurrentUser = true;\n this._setMeta(this.user);\n }\n }\n\n ProfileController.prototype._setMeta = function(user) {\n var ctx, description, title;\n ctx = {\n userFullName: user.get(\"full_name_display\"),\n userUsername: user.get(\"username\")\n };\n title = this.translate.instant(\"USER.PROFILE.PAGE_TITLE\", ctx);\n description = user.get(\"bio\");\n return this.appMetaService.setAll(title, description);\n };\n\n return ProfileController;\n\n })();\n\n angular.module(\"taigaProfile\").controller(\"Profile\", ProfileController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.controller.coffee\n */\n\n(function() {\n var LikeProjectButtonController;\n\n LikeProjectButtonController = (function() {\n LikeProjectButtonController.$inject = [\"$tgConfirm\", \"tgLikeProjectButtonService\"];\n\n function LikeProjectButtonController(confirm, likeButtonService) {\n this.confirm = confirm;\n this.likeButtonService = likeButtonService;\n this.isMouseOver = false;\n this.loading = false;\n }\n\n LikeProjectButtonController.prototype.showTextWhenMouseIsOver = function() {\n return this.isMouseOver = true;\n };\n\n LikeProjectButtonController.prototype.showTextWhenMouseIsLeave = function() {\n return this.isMouseOver = false;\n };\n\n LikeProjectButtonController.prototype.toggleLike = function() {\n var promise;\n this.loading = true;\n if (!this.project.get(\"is_fan\")) {\n promise = this._like();\n } else {\n promise = this._unlike();\n }\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n return promise;\n };\n\n LikeProjectButtonController.prototype._like = function() {\n return this.likeButtonService.like(this.project.get('id')).then((function(_this) {\n return function() {\n return _this.showTextWhenMouseIsLeave();\n };\n })(this))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n };\n\n LikeProjectButtonController.prototype._unlike = function() {\n return this.likeButtonService.unlike(this.project.get('id'))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this));\n };\n\n return LikeProjectButtonController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"LikeProjectButton\", LikeProjectButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.directive.coffee\n */\n\n(function() {\n var LikeProjectButtonDirective;\n\n LikeProjectButtonDirective = function() {\n return {\n scope: {},\n controller: \"LikeProjectButton\",\n bindToController: {\n project: '='\n },\n controllerAs: \"vm\",\n templateUrl: \"projects/components/like-project-button/like-project-button.html\"\n };\n };\n\n angular.module(\"taigaProjects\").directive(\"tgLikeProjectButton\", LikeProjectButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: like-project-button.service.coffee\n */\n\n(function() {\n var LikeProjectButtonService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n LikeProjectButtonService = (function(superClass) {\n extend(LikeProjectButtonService, superClass);\n\n LikeProjectButtonService.$inject = [\"tgResources\", \"tgCurrentUserService\", \"tgProjectService\"];\n\n function LikeProjectButtonService(rs, currentUserService, projectService) {\n this.rs = rs;\n this.currentUserService = currentUserService;\n this.projectService = projectService;\n }\n\n LikeProjectButtonService.prototype._getProjectIndex = function(projectId) {\n return this.currentUserService.projects.get('all').findIndex(function(project) {\n return project.get('id') === projectId;\n });\n };\n\n LikeProjectButtonService.prototype._updateProjects = function(projectId, isFan) {\n var projectIndex, projects;\n projectIndex = this._getProjectIndex(projectId);\n if (projectIndex === -1) {\n return;\n }\n projects = this.currentUserService.projects.get('all').update(projectIndex, function(project) {\n var totalFans;\n totalFans = project.get(\"total_fans\");\n if (isFan) {\n totalFans++;\n } else {\n totalFans--;\n }\n return project.merge({\n is_fan: isFan,\n total_fans: totalFans\n });\n });\n return this.currentUserService.setProjects(projects);\n };\n\n LikeProjectButtonService.prototype._updateCurrentProject = function(isFan) {\n var project, totalFans;\n totalFans = this.projectService.project.get(\"total_fans\");\n if (isFan) {\n totalFans++;\n } else {\n totalFans--;\n }\n project = this.projectService.project.merge({\n is_fan: isFan,\n total_fans: totalFans\n });\n return this.projectService.setProject(project);\n };\n\n LikeProjectButtonService.prototype.like = function(projectId) {\n return this.rs.projects.likeProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, true);\n return _this._updateCurrentProject(true);\n };\n })(this));\n };\n\n LikeProjectButtonService.prototype.unlike = function(projectId) {\n return this.rs.projects.unlikeProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, false);\n return _this._updateCurrentProject(false);\n };\n })(this));\n };\n\n return LikeProjectButtonService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgLikeProjectButtonService\", LikeProjectButtonService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: sort-projects.directive.coffee\n */\n\n(function() {\n var SortProjectsDirective;\n\n SortProjectsDirective = function(currentUserService) {\n var directive, link;\n link = function(scope, el, attrs, ctrl) {\n var itemEl;\n itemEl = null;\n el.sortable({\n dropOnEmpty: true,\n revert: 200,\n axis: \"y\",\n opacity: .95,\n placeholder: 'placeholder',\n cancel: '.project-name'\n });\n return el.on(\"sortstop\", function(event, ui) {\n var i, index, len, project, sortData, sorted_project_ids, value;\n itemEl = ui.item;\n project = itemEl.scope().project;\n index = itemEl.index();\n sorted_project_ids = _.map(scope.projects.toJS(), function(p) {\n return p.id;\n });\n sorted_project_ids = _.without(sorted_project_ids, project.get(\"id\"));\n sorted_project_ids.splice(index, 0, project.get('id'));\n sortData = [];\n for (index = i = 0, len = sorted_project_ids.length; i < len; index = ++i) {\n value = sorted_project_ids[index];\n sortData.push({\n \"project_id\": value,\n \"order\": index\n });\n }\n return currentUserService.bulkUpdateProjectsOrder(sortData);\n });\n };\n directive = {\n scope: {\n projects: \"=tgSortProjects\"\n },\n link: link\n };\n return directive;\n };\n\n angular.module(\"taigaProjects\").directive(\"tgSortProjects\", [\"tgCurrentUserService\", SortProjectsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.controller.coffee\n */\n\n(function() {\n var WatchProjectButtonController;\n\n WatchProjectButtonController = (function() {\n WatchProjectButtonController.$inject = [\"$tgConfirm\", \"tgWatchProjectButtonService\"];\n\n function WatchProjectButtonController(confirm, watchButtonService) {\n this.confirm = confirm;\n this.watchButtonService = watchButtonService;\n this.showWatchOptions = false;\n this.loading = false;\n }\n\n WatchProjectButtonController.prototype.toggleWatcherOptions = function() {\n return this.showWatchOptions = !this.showWatchOptions;\n };\n\n WatchProjectButtonController.prototype.closeWatcherOptions = function() {\n return this.showWatchOptions = false;\n };\n\n WatchProjectButtonController.prototype.watch = function(notifyLevel) {\n if (notifyLevel === this.project.get('notify_level')) {\n return;\n }\n this.loading = true;\n this.closeWatcherOptions();\n return this.watchButtonService.watch(this.project.get('id'), notifyLevel)[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this))[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n WatchProjectButtonController.prototype.unwatch = function() {\n this.loading = true;\n this.closeWatcherOptions();\n return this.watchButtonService.unwatch(this.project.get('id'))[\"catch\"]((function(_this) {\n return function() {\n return _this.confirm.notify(\"error\");\n };\n })(this))[\"finally\"]((function(_this) {\n return function() {\n return _this.loading = false;\n };\n })(this));\n };\n\n return WatchProjectButtonController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"WatchProjectButton\", WatchProjectButtonController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.directive.coffee\n */\n\n(function() {\n var WatchProjectButtonDirective;\n\n WatchProjectButtonDirective = function() {\n return {\n scope: {},\n controller: \"WatchProjectButton\",\n bindToController: {\n project: \"=\"\n },\n controllerAs: \"vm\",\n templateUrl: \"projects/components/watch-project-button/watch-project-button.html\"\n };\n };\n\n angular.module(\"taigaProjects\").directive(\"tgWatchProjectButton\", WatchProjectButtonDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: watch-project-button.service.coffee\n */\n\n(function() {\n var WatchProjectButtonService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n WatchProjectButtonService = (function(superClass) {\n extend(WatchProjectButtonService, superClass);\n\n WatchProjectButtonService.$inject = [\"tgResources\", \"tgCurrentUserService\", \"tgProjectService\"];\n\n function WatchProjectButtonService(rs, currentUserService, projectService) {\n this.rs = rs;\n this.currentUserService = currentUserService;\n this.projectService = projectService;\n }\n\n WatchProjectButtonService.prototype._getProjectIndex = function(projectId) {\n return this.currentUserService.projects.get('all').findIndex(function(project) {\n return project.get('id') === projectId;\n });\n };\n\n WatchProjectButtonService.prototype._updateProjects = function(projectId, notifyLevel, isWatcher) {\n var projectIndex, projects;\n projectIndex = this._getProjectIndex(projectId);\n if (projectIndex === -1) {\n return;\n }\n projects = this.currentUserService.projects.get('all').update(projectIndex, (function(_this) {\n return function(project) {\n var totalWatchers;\n totalWatchers = project.get('total_watchers');\n if (!_this.projectService.project.get('is_watcher') && isWatcher) {\n totalWatchers++;\n } else if (_this.projectService.project.get('is_watcher') && !isWatcher) {\n totalWatchers--;\n }\n return project.merge({\n is_watcher: isWatcher,\n total_watchers: totalWatchers,\n notify_level: notifyLevel\n });\n };\n })(this));\n return this.currentUserService.setProjects(projects);\n };\n\n WatchProjectButtonService.prototype._updateCurrentProject = function(notifyLevel, isWatcher) {\n var project, totalWatchers;\n totalWatchers = this.projectService.project.get(\"total_watchers\");\n if (!this.projectService.project.get('is_watcher') && isWatcher) {\n totalWatchers++;\n } else if (this.projectService.project.get('is_watcher') && !isWatcher) {\n totalWatchers--;\n }\n project = this.projectService.project.merge({\n is_watcher: isWatcher,\n notify_level: notifyLevel,\n total_watchers: totalWatchers\n });\n return this.projectService.setProject(project);\n };\n\n WatchProjectButtonService.prototype.watch = function(projectId, notifyLevel) {\n return this.rs.projects.watchProject(projectId, notifyLevel).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, notifyLevel, true);\n return _this._updateCurrentProject(notifyLevel, true);\n };\n })(this));\n };\n\n WatchProjectButtonService.prototype.unwatch = function(projectId) {\n return this.rs.projects.unwatchProject(projectId).then((function(_this) {\n return function() {\n _this._updateProjects(projectId, null, false);\n return _this._updateCurrentProject(null, false);\n };\n })(this));\n };\n\n return WatchProjectButtonService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgWatchProjectButtonService\", WatchProjectButtonService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects-listing.controller.coffee\n */\n\n(function() {\n var ProjectsListingController;\n\n ProjectsListingController = (function() {\n ProjectsListingController.$inject = [\"tgCurrentUserService\", \"tgProjectsService\"];\n\n function ProjectsListingController(currentUserService, projectsService) {\n this.currentUserService = currentUserService;\n this.projectsService = projectsService;\n taiga.defineImmutableProperty(this, \"projects\", (function(_this) {\n return function() {\n return _this.currentUserService.projects.get(\"all\");\n };\n })(this));\n }\n\n ProjectsListingController.prototype.newProject = function() {\n return this.projectsService.newProject();\n };\n\n return ProjectsListingController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"ProjectsListing\", ProjectsListingController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project.controller.coffee\n */\n\n(function() {\n var ProjectController;\n\n ProjectController = (function() {\n ProjectController.$inject = [\"$routeParams\", \"tgAppMetaService\", \"$tgAuth\", \"$translate\", \"tgProjectService\"];\n\n function ProjectController(routeParams, appMetaService, auth, translate, projectService) {\n var projectSlug;\n this.routeParams = routeParams;\n this.appMetaService = appMetaService;\n this.auth = auth;\n this.translate = translate;\n this.projectService = projectService;\n projectSlug = this.routeParams.pslug;\n this.user = this.auth.userData;\n taiga.defineImmutableProperty(this, \"project\", (function(_this) {\n return function() {\n return _this.projectService.project;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"members\", (function(_this) {\n return function() {\n return _this.projectService.activeMembers;\n };\n })(this));\n this.appMetaService.setfn(this._setMeta.bind(this));\n }\n\n ProjectController.prototype._setMeta = function(project) {\n var ctx, metas;\n if (!this.project) {\n return null;\n }\n metas = {};\n ctx = {\n projectName: this.project.get(\"name\")\n };\n metas.title = this.translate.instant(\"PROJECT.PAGE_TITLE\", ctx);\n metas.description = this.project.get(\"description\");\n return metas;\n };\n\n return ProjectController;\n\n })();\n\n angular.module(\"taigaProjects\").controller(\"Project\", ProjectController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects.service.coffee\n */\n\n(function() {\n var ProjectsService, groupBy, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n ProjectsService = (function(superClass) {\n extend(ProjectsService, superClass);\n\n ProjectsService.$inject = [\"tgResources\", \"$projectUrl\", \"tgLightboxFactory\"];\n\n function ProjectsService(rs, projectUrl, lightboxFactory) {\n this.rs = rs;\n this.projectUrl = projectUrl;\n this.lightboxFactory = lightboxFactory;\n }\n\n ProjectsService.prototype.getProjectBySlug = function(projectSlug) {\n return this.rs.projects.getProjectBySlug(projectSlug).then((function(_this) {\n return function(project) {\n return _this._decorate(project);\n };\n })(this));\n };\n\n ProjectsService.prototype.getProjectStats = function(projectId) {\n return this.rs.projects.getProjectStats(projectId);\n };\n\n ProjectsService.prototype.getProjectsByUserId = function(userId, paginate) {\n return this.rs.projects.getProjectsByUserId(userId, paginate).then((function(_this) {\n return function(projects) {\n return projects.map(_this._decorate.bind(_this));\n };\n })(this));\n };\n\n ProjectsService.prototype._decorate = function(project) {\n var colorized_tags, tags, url;\n url = this.projectUrl.get(project.toJS());\n project = project.set(\"url\", url);\n colorized_tags = [];\n if (project.get(\"tags\")) {\n tags = project.get(\"tags\").sort();\n colorized_tags = tags.map(function(tag) {\n var color;\n color = project.get(\"tags_colors\").get(tag);\n return Immutable.fromJS({\n name: tag,\n color: color\n });\n });\n project = project.set(\"colorized_tags\", colorized_tags);\n }\n return project;\n };\n\n ProjectsService.prototype.newProject = function() {\n return this.lightboxFactory.create(\"tg-lb-create-project\", {\n \"class\": \"wizard-create-project\"\n });\n };\n\n ProjectsService.prototype.bulkUpdateProjectsOrder = function(sortData) {\n return this.rs.projects.bulkUpdateOrder(sortData);\n };\n\n return ProjectsService;\n\n })(taiga.Service);\n\n angular.module(\"taigaProjects\").service(\"tgProjectsService\", ProjectsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments-resource.service.coffee\n */\n\n(function() {\n var Resource, module, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n Resource = function(urlsService, http, config, $rootScope, $q, storage) {\n var service;\n service = {};\n service.list = function(type, objectId, projectId) {\n var httpOptions, params, url, urlname;\n urlname = \"attachments/\" + type;\n params = {\n object_id: objectId,\n project: projectId\n };\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n url = urlsService.resolve(urlname);\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service[\"delete\"] = function(type, id) {\n var url, urlname;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname) + (\"/\" + id);\n return http[\"delete\"](url);\n };\n service.patch = function(type, id, patch) {\n var url, urlname;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname) + (\"/\" + id);\n return http.patch(url, patch);\n };\n service.create = function(type, projectId, objectId, file) {\n var data, defered, maxFileSize, response, token, uploadComplete, uploadFailed, uploadProgress, url, urlname, xhr;\n urlname = \"attachments/\" + type;\n url = urlsService.resolve(urlname);\n defered = $q.defer();\n if (file === void 0) {\n defered.reject(null);\n return defered.promise;\n }\n maxFileSize = config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered.reject(response);\n return defered.promise;\n }\n uploadProgress = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"in-progress\";\n file.size = sizeFormat(evt.total);\n file.progressMessage = \"upload \" + (sizeFormat(evt.loaded)) + \" of \" + (sizeFormat(evt.total));\n return file.progressPercent = (Math.round((evt.loaded / evt.total) * 100)) + \"%\";\n });\n };\n })(this);\n uploadComplete = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n var attachment, error, ref, status;\n file.status = \"done\";\n status = evt.target.status;\n try {\n attachment = JSON.parse(evt.target.responseText);\n } catch (error) {\n attachment = {};\n }\n if (status >= 200 && status < 400) {\n attachment = Immutable.fromJS(attachment);\n return defered.resolve(attachment);\n } else {\n response = {\n status: status,\n data: {\n _error_message: (ref = data['attached_file']) != null ? ref[0] : void 0\n }\n };\n return defered.reject(response);\n }\n });\n };\n })(this);\n uploadFailed = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"error\";\n return defered.reject(\"fail\");\n });\n };\n })(this);\n data = new FormData();\n data.append(\"project\", projectId);\n data.append(\"object_id\", objectId);\n data.append(\"attached_file\", file);\n xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.addEventListener(\"load\", uploadComplete, false);\n xhr.addEventListener(\"error\", uploadFailed, false);\n token = storage.get('token');\n xhr.open(\"POST\", url);\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send(data);\n return defered.promise;\n };\n return function() {\n return {\n \"attachments\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"$tgConfig\", \"$rootScope\", \"$q\", \"$tgStorage\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgAttachmentsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: external-apps-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.getApplicationToken = function(applicationId, state) {\n var url;\n url = urlsService.resolve(\"applications\");\n url = url + \"/\" + applicationId + \"/token?state=\" + state;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.authorizeApplicationToken = function(applicationId, state) {\n var data, url;\n url = urlsService.resolve(\"application-tokens\");\n url = url + \"/authorize\";\n data = {\n \"state\": state,\n \"application\": applicationId\n };\n return http.post(url, data).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"externalapps\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgExternalAppsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: issues-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"issues\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"issues\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgIssuesResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: projects-resource.service.coffee\n */\n\n(function() {\n var Resource, module, pagination;\n\n pagination = function() {};\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getProjects = function(params, pagination) {\n var httpOptions, url;\n if (params == null) {\n params = {};\n }\n if (pagination == null) {\n pagination = true;\n }\n url = urlsService.resolve(\"projects\");\n httpOptions = {};\n if (!pagination) {\n httpOptions = {\n headers: {\n \"x-lazy-pagination\": true\n }\n };\n }\n return http.get(url, params, httpOptions);\n };\n service.getProjectBySlug = function(projectSlug) {\n var url;\n url = urlsService.resolve(\"projects\");\n url = url + \"/by_slug?slug=\" + projectSlug;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getProjectsByUserId = function(userId, paginate) {\n var httpOptions, params, url;\n if (paginate == null) {\n paginate = false;\n }\n url = urlsService.resolve(\"projects\");\n httpOptions = {};\n if (!paginate) {\n httpOptions.headers = {\n \"x-disable-pagination\": \"1\"\n };\n }\n params = {\n \"member\": userId,\n \"order_by\": \"memberships__user_order\"\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getProjectStats = function(projectId) {\n var url;\n url = urlsService.resolve(\"projects\");\n url = url + \"/\" + projectId;\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.bulkUpdateOrder = function(bulkData) {\n var url;\n url = urlsService.resolve(\"bulk-update-projects-order\");\n return http.post(url, bulkData);\n };\n service.getTimeline = function(projectId, page) {\n var params, url;\n params = {\n page: page,\n only_relevant: true\n };\n url = urlsService.resolve(\"timeline-project\");\n url = url + \"/\" + projectId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.likeProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-like\", projectId);\n return http.post(url);\n };\n service.unlikeProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-unlike\", projectId);\n return http.post(url);\n };\n service.watchProject = function(projectId, notifyLevel) {\n var data, url;\n data = {\n notify_level: notifyLevel\n };\n url = urlsService.resolve(\"project-watch\", projectId);\n return http.post(url, data);\n };\n service.unwatchProject = function(projectId) {\n var url;\n url = urlsService.resolve(\"project-unwatch\", projectId);\n return http.post(url);\n };\n return function() {\n return {\n \"projects\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"tgPaginateResponseService\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgProjectsResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: resources.coffee\n */\n\n(function() {\n var Resources, services;\n\n services = [\"tgProjectsResources\", \"tgUserResources\", \"tgUsersResources\", \"tgUserstoriesResource\", \"tgTasksResource\", \"tgIssuesResource\", \"tgExternalAppsResource\", \"tgAttachmentsResource\", \"tgStatsResource\"];\n\n Resources = function($injector) {\n var i, j, len, len1, ref, service, serviceFn, serviceName, serviceProperty;\n for (i = 0, len = services.length; i < len; i++) {\n serviceName = services[i];\n serviceFn = $injector.get(serviceName);\n service = $injector.invoke(serviceFn);\n ref = Object.keys(service);\n for (j = 0, len1 = ref.length; j < len1; j++) {\n serviceProperty = ref[j];\n if (this[serviceProperty]) {\n console.warm(\"repeated resource \" + serviceProperty);\n }\n this[serviceProperty] = service[serviceProperty];\n }\n }\n return this;\n };\n\n Resources.$inject = [\"$injector\"];\n\n angular.module(\"taigaResources2\").service(\"tgResources\", Resources);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: stats-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.discover = function(applicationId, state) {\n var url;\n url = urlsService.resolve(\"stats-discover\");\n return http.get(url).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"stats\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgStatsResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: tasks-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"tasks\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"tasks\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgTasksResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getUserStorage = function(key) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-storage\");\n if (key) {\n url += '/' + key;\n }\n httpOptions = {};\n return http.get(url, {}).then(function(response) {\n return response.data.value;\n });\n };\n service.setUserStorage = function(key, value) {\n var params, url;\n url = urlsService.resolve(\"user-storage\") + '/' + key;\n params = {\n key: key,\n value: value\n };\n return http.put(url, params);\n };\n service.createUserStorage = function(key, value) {\n var params, url;\n url = urlsService.resolve(\"user-storage\");\n params = {\n key: key,\n value: value\n };\n return http.post(url, params);\n };\n return function() {\n return {\n \"user\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUserResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: users-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http, paginateResponseService) {\n var service;\n service = {};\n service.getUserByUsername = function(username) {\n var httpOptions, params, url;\n url = urlsService.resolve(\"by_username\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n params = {\n username: username\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getStats = function(userId) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-stats\", userId);\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, {}, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getContacts = function(userId) {\n var httpOptions, url;\n url = urlsService.resolve(\"user-contacts\", userId);\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, {}, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n service.getLiked = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-liked\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n params.only_relevant = true;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getVoted = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-voted\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getWatched = function(userId, page, type, q) {\n var params, url;\n url = urlsService.resolve(\"user-watched\", userId);\n params = {};\n if (page != null) {\n params.page = page;\n }\n if (type != null) {\n params.type = type;\n }\n if (q != null) {\n params.q = q;\n }\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getProfileTimeline = function(userId, page) {\n var params, url;\n params = {\n page: page\n };\n url = urlsService.resolve(\"timeline-profile\");\n url = url + \"/\" + userId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n service.getUserTimeline = function(userId, page) {\n var params, url;\n params = {\n page: page,\n only_relevant: true\n };\n url = urlsService.resolve(\"timeline-user\");\n url = url + \"/\" + userId;\n return http.get(url, params, {\n headers: {\n 'x-lazy-pagination': true\n }\n }).then(function(result) {\n result = Immutable.fromJS(result);\n return paginateResponseService(result);\n });\n };\n return function() {\n return {\n \"users\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\", \"tgPaginateResponseService\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUsersResources\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: userstories-resource.service.coffee\n */\n\n(function() {\n var Resource, module;\n\n Resource = function(urlsService, http) {\n var service;\n service = {};\n service.listInAllProjects = function(params) {\n var httpOptions, url;\n url = urlsService.resolve(\"userstories\");\n httpOptions = {\n headers: {\n \"x-disable-pagination\": \"1\"\n }\n };\n return http.get(url, params, httpOptions).then(function(result) {\n return Immutable.fromJS(result.data);\n });\n };\n return function() {\n return {\n \"userstories\": service\n };\n };\n };\n\n Resource.$inject = [\"$tgUrls\", \"$tgHttp\"];\n\n module = angular.module(\"taigaResources2\");\n\n module.factory(\"tgUserstoriesResource\", Resource);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: app-meta.service.coffee\n */\n\n(function() {\n var AppMetaService, taiga, truncate;\n\n taiga = this.taiga;\n\n truncate = taiga.truncate;\n\n AppMetaService = (function() {\n AppMetaService.$inject = [\"$rootScope\"];\n\n function AppMetaService(rootScope) {\n this.rootScope = rootScope;\n }\n\n AppMetaService.prototype._set = function(key, value) {\n var meta;\n if (!key) {\n return;\n }\n if (key === \"title\") {\n meta = $(\"title\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.text(value || \"\");\n } else if (key.indexOf(\"og:\") === 0) {\n meta = $(\"meta[property='\" + key + \"']\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.attr(\"content\", value || \"\");\n } else {\n meta = $(\"meta[name='\" + key + \"']\");\n if (meta.length === 0) {\n meta = $(\"\");\n $(\"head\").append(meta);\n }\n return meta.attr(\"content\", value || \"\");\n }\n };\n\n AppMetaService.prototype.setTitle = function(title) {\n return this._set('title', title);\n };\n\n AppMetaService.prototype.setDescription = function(description) {\n return this._set(\"description\", truncate(description, 250));\n };\n\n AppMetaService.prototype.setTwitterMetas = function(title, description) {\n this._set(\"twitter:card\", \"summary\");\n this._set(\"twitter:site\", \"@taigaio\");\n this._set(\"twitter:title\", title);\n this._set(\"twitter:description\", truncate(description, 300));\n return this._set(\"twitter:image\", window.location.origin + \"/\" + window._version + \"/images/logo-color.png\");\n };\n\n AppMetaService.prototype.setOpenGraphMetas = function(title, description) {\n this._set(\"og:type\", \"object\");\n this._set(\"og:site_name\", \"Taiga - Love your projects\");\n this._set(\"og:title\", title);\n this._set(\"og:description\", truncate(description, 300));\n this._set(\"og:image\", window.location.origin + \"/\" + window._version + \"/images/logo-color.png\");\n return this._set(\"og:url\", window.location.href);\n };\n\n AppMetaService.prototype.setAll = function(title, description) {\n this.setTitle(title);\n this.setDescription(description);\n this.setTwitterMetas(title, description);\n return this.setOpenGraphMetas(title, description);\n };\n\n AppMetaService.prototype.addMobileViewport = function() {\n return $(\"head\").append(\"\");\n };\n\n AppMetaService.prototype.removeMobileViewport = function() {\n return $(\"meta[name=\\\"viewport\\\"]\").remove();\n };\n\n AppMetaService.prototype.setfn = function(fn) {\n if (this.listener) {\n this._listener();\n }\n return this._listener = this.rootScope.$watchCollection(fn, (function(_this) {\n return function(metas) {\n if (metas) {\n _this.setAll(metas.title, metas.description);\n return _this._listener();\n }\n };\n })(this));\n };\n\n return AppMetaService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgAppMetaService\", AppMetaService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2015 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: attachments.service.coffee\n */\n\n(function() {\n var AttachmentsService, sizeFormat;\n\n sizeFormat = this.taiga.sizeFormat;\n\n AttachmentsService = (function() {\n AttachmentsService.$inject = [\"$tgConfirm\", \"$tgConfig\", \"$translate\", \"tgResources\"];\n\n function AttachmentsService(confirm, config, translate, rs) {\n this.confirm = confirm;\n this.config = config;\n this.translate = translate;\n this.rs = rs;\n this.maxFileSize = this.getMaxFileSize();\n if (this.maxFileSize) {\n this.maxFileSizeFormated = sizeFormat(this.maxFileSize);\n }\n }\n\n AttachmentsService.prototype.sizeError = function(file) {\n var message;\n message = this.translate.instant(\"ATTACHMENT.ERROR_MAX_SIZE_EXCEEDED\", {\n fileName: file.name,\n fileSize: sizeFormat(file.size),\n maxFileSize: this.maxFileSizeFormated\n });\n return this.confirm.notify(\"error\", message);\n };\n\n AttachmentsService.prototype.validate = function(file) {\n if (this.maxFileSize && file.size > this.maxFileSize) {\n this.sizeError(file);\n return false;\n }\n return true;\n };\n\n AttachmentsService.prototype.getMaxFileSize = function() {\n return this.config.get(\"maxUploadFileSize\", null);\n };\n\n AttachmentsService.prototype.list = function(type, objId, projectId) {\n return this.rs.attachments.list(type, objId, projectId).then((function(_this) {\n return function(attachments) {\n return attachments.sortBy(function(attachment) {\n return attachment.get('order');\n });\n };\n })(this));\n };\n\n AttachmentsService.prototype[\"delete\"] = function(type, id) {\n return this.rs.attachments[\"delete\"](type, id);\n };\n\n AttachmentsService.prototype.saveError = function(file, data) {\n var message;\n message = \"\";\n if (file) {\n message = this.translate.instant(\"ATTACHMENT.ERROR_UPLOAD_ATTACHMENT\", {\n fileName: file.name,\n errorMessage: data.data._error_message\n });\n }\n return this.confirm.notify(\"error\", message);\n };\n\n AttachmentsService.prototype.upload = function(file, objId, projectId, type) {\n var promise;\n promise = this.rs.attachments.create(type, projectId, objId, file);\n promise.then(null, this.saveError.bind(this, file));\n return promise;\n };\n\n AttachmentsService.prototype.patch = function(id, type, patch) {\n var promise;\n promise = this.rs.attachments.patch(type, id, patch);\n promise.then(null, this.saveError.bind(this, null));\n return promise;\n };\n\n return AttachmentsService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgAttachmentsService\", AttachmentsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: check-permissions.service.coffee\n */\n\n(function() {\n var ChekcPermissionsService, taiga;\n\n taiga = this.taiga;\n\n ChekcPermissionsService = (function() {\n ChekcPermissionsService.$inject = [\"tgProjectService\"];\n\n function ChekcPermissionsService(projectService) {\n this.projectService = projectService;\n }\n\n ChekcPermissionsService.prototype.check = function(permission) {\n return this.projectService.project.get('my_permissions').indexOf(permission) !== -1;\n };\n\n return ChekcPermissionsService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgCheckPermissionsService\", ChekcPermissionsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: current-user.service.coffee\n */\n\n(function() {\n var CurrentUserService, groupBy, taiga;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n CurrentUserService = (function() {\n CurrentUserService.$inject = [\"tgProjectsService\", \"$tgStorage\", \"tgResources\"];\n\n function CurrentUserService(projectsService, storageService, rs) {\n this.projectsService = projectsService;\n this.storageService = storageService;\n this.rs = rs;\n this._user = null;\n this._projects = Immutable.Map();\n this._projectsById = Immutable.Map();\n this._joyride = null;\n taiga.defineImmutableProperty(this, \"projects\", (function(_this) {\n return function() {\n return _this._projects;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"projectsById\", (function(_this) {\n return function() {\n return _this._projectsById;\n };\n })(this));\n }\n\n CurrentUserService.prototype.isAuthenticated = function() {\n if (this.getUser() !== null) {\n return true;\n }\n return false;\n };\n\n CurrentUserService.prototype.getUser = function() {\n var userData;\n if (!this._user) {\n userData = this.storageService.get(\"userInfo\");\n if (userData) {\n userData = Immutable.fromJS(userData);\n this.setUser(userData);\n }\n }\n return this._user;\n };\n\n CurrentUserService.prototype.removeUser = function() {\n this._user = null;\n this._projects = Immutable.Map();\n this._projectsById = Immutable.Map();\n return this._joyride = null;\n };\n\n CurrentUserService.prototype.setUser = function(user) {\n this._user = user;\n return this._loadUserInfo();\n };\n\n CurrentUserService.prototype.bulkUpdateProjectsOrder = function(sortData) {\n return this.projectsService.bulkUpdateProjectsOrder(sortData).then((function(_this) {\n return function() {\n return _this.loadProjects();\n };\n })(this));\n };\n\n CurrentUserService.prototype.loadProjects = function() {\n return this.projectsService.getProjectsByUserId(this._user.get(\"id\")).then((function(_this) {\n return function(projects) {\n return _this.setProjects(projects);\n };\n })(this));\n };\n\n CurrentUserService.prototype.disableJoyRide = function(section) {\n if (section) {\n this._joyride[section] = false;\n } else {\n this._joyride = {\n backlog: false,\n kanban: false,\n dashboard: false\n };\n }\n return this.rs.user.setUserStorage('joyride', this._joyride);\n };\n\n CurrentUserService.prototype.loadJoyRideConfig = function() {\n return new Promise((function(_this) {\n return function(resolve) {\n if (_this._joyride !== null) {\n resolve(_this._joyride);\n return;\n }\n return _this.rs.user.getUserStorage('joyride').then(function(config) {\n _this._joyride = config;\n return resolve(_this._joyride);\n })[\"catch\"](function() {\n _this._joyride = {\n backlog: true,\n kanban: true,\n dashboard: true\n };\n _this.rs.user.createUserStorage('joyride', _this._joyride);\n return resolve(_this._joyride);\n });\n };\n })(this));\n };\n\n CurrentUserService.prototype._loadUserInfo = function() {\n return Promise.all([this.loadProjects()]);\n };\n\n CurrentUserService.prototype.setProjects = function(projects) {\n this._projects = this._projects.set(\"all\", projects);\n this._projects = this._projects.set(\"recents\", projects.slice(0, 10));\n this._projectsById = Immutable.fromJS(groupBy(projects.toJS(), function(p) {\n return p.id;\n }));\n return this.projects;\n };\n\n return CurrentUserService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgCurrentUserService\", CurrentUserService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: lightbox-factory.service.coffee\n */\n\n(function() {\n var LightboxFactory;\n\n LightboxFactory = (function() {\n LightboxFactory.$inject = [\"$rootScope\", \"$compile\"];\n\n function LightboxFactory(rootScope, compile) {\n this.rootScope = rootScope;\n this.compile = compile;\n }\n\n LightboxFactory.prototype.create = function(name, attrs, scopeAttrs) {\n var elm, html, scope;\n scope = this.rootScope.$new();\n scope = _.merge(scope, scopeAttrs);\n elm = $(\"
\").attr(name, true).attr(\"tg-bind-scope\", true);\n if (attrs) {\n elm.attr(attrs);\n }\n elm.addClass(\"remove-on-close\");\n html = this.compile(elm)(scope);\n $(document.body).append(html);\n };\n\n return LightboxFactory;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgLightboxFactory\", LightboxFactory);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: paginate-response.service.coffee\n */\n\n(function() {\n var PaginateResponse;\n\n PaginateResponse = function() {\n return function(result) {\n var paginateResponse;\n paginateResponse = Immutable.Map({\n \"data\": result.get(\"data\"),\n \"next\": !!result.get(\"headers\")(\"x-pagination-next\"),\n \"prev\": !!result.get(\"headers\")(\"x-pagination-prev\"),\n \"current\": result.get(\"headers\")(\"x-pagination-current\"),\n \"count\": result.get(\"headers\")(\"x-pagination-count\")\n });\n return paginateResponse;\n };\n };\n\n angular.module(\"taigaCommon\").factory(\"tgPaginateResponseService\", PaginateResponse);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: project.service.coffee\n */\n\n(function() {\n var ProjectService, taiga;\n\n taiga = this.taiga;\n\n ProjectService = (function() {\n ProjectService.$inject = [\"tgProjectsService\", \"tgXhrErrorService\"];\n\n function ProjectService(projectsService, xhrError) {\n this.projectsService = projectsService;\n this.xhrError = xhrError;\n this._project = null;\n this._section = null;\n this._sectionsBreadcrumb = Immutable.List();\n this._activeMembers = Immutable.List();\n taiga.defineImmutableProperty(this, \"project\", (function(_this) {\n return function() {\n return _this._project;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"section\", (function(_this) {\n return function() {\n return _this._section;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"sectionsBreadcrumb\", (function(_this) {\n return function() {\n return _this._sectionsBreadcrumb;\n };\n })(this));\n taiga.defineImmutableProperty(this, \"activeMembers\", (function(_this) {\n return function() {\n return _this._activeMembers;\n };\n })(this));\n }\n\n ProjectService.prototype.setSection = function(section) {\n this._section = section;\n if (section) {\n return this._sectionsBreadcrumb = this._sectionsBreadcrumb.push(this._section);\n } else {\n return this._sectionsBreadcrumb = Immutable.List();\n }\n };\n\n ProjectService.prototype.setProjectBySlug = function(pslug) {\n return new Promise((function(_this) {\n return function(resolve, reject) {\n if (!_this.project || _this.project.get('slug') !== pslug) {\n return _this.projectsService.getProjectBySlug(pslug).then(function(project) {\n _this.setProject(project);\n return resolve();\n })[\"catch\"](function(xhr) {\n return _this.xhrError.response(xhr);\n });\n } else {\n return resolve();\n }\n };\n })(this));\n };\n\n ProjectService.prototype.setProject = function(project) {\n this._project = project;\n return this._activeMembers = this._project.get('members').filter(function(member) {\n return member.get('is_active');\n });\n };\n\n ProjectService.prototype.cleanProject = function() {\n this._project = null;\n this._activeMembers = Immutable.List();\n this._section = null;\n return this._sectionsBreadcrumb = Immutable.List();\n };\n\n ProjectService.prototype.hasPermission = function(permission) {\n return this._project.get('my_permissions').indexOf(permission) !== -1;\n };\n\n ProjectService.prototype.fetchProject = function() {\n var pslug;\n pslug = this.project.get('slug');\n return this.projectsService.getProjectBySlug(pslug).then((function(_this) {\n return function(project) {\n return _this.setProject(project);\n };\n })(this));\n };\n\n return ProjectService;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgProjectService\", ProjectService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: scope-event.service.coffee\n */\n\n(function() {\n var ScopeEvent;\n\n ScopeEvent = (function() {\n function ScopeEvent() {}\n\n ScopeEvent.prototype.scopes = {};\n\n ScopeEvent.prototype._searchDuplicatedScopes = function(id) {\n return _.find(Object.keys(this.scopes), (function(_this) {\n return function(key) {\n return _this.scopes[key].$id === id;\n };\n })(this));\n };\n\n ScopeEvent.prototype._create = function(name, scope) {\n var duplicatedScopeName;\n duplicatedScopeName = this._searchDuplicatedScopes(scope.$id);\n if (duplicatedScopeName) {\n throw new Error(\"scopeEvent: this scope is already register with the name \\\"\" + duplicatedScopeName + \"\\\"\");\n }\n if (this.scopes[name]) {\n throw new Error(\"scopeEvent: \\\"\" + name + \"\\\" already in use\");\n } else {\n scope._tgEmitter = new EventEmitter2();\n scope.$on(\"$destroy\", (function(_this) {\n return function() {\n scope._tgEmitter.removeAllListeners();\n return delete _this.scopes[name];\n };\n })(this));\n return this.scopes[name] = scope;\n }\n };\n\n ScopeEvent.prototype.emitter = function(name, scope) {\n if (scope) {\n scope = this._create(name, scope);\n } else if (this.scopes[name]) {\n scope = this.scopes[name];\n } else {\n throw new Error(\"scopeEvent: \\\"\" + name + \"\\\" scope doesn't exist'\");\n }\n return scope._tgEmitter;\n };\n\n return ScopeEvent;\n\n })();\n\n angular.module(\"taigaCommon\").service(\"tgScopeEvent\", ScopeEvent);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: theme.service.coffee\n */\n\n(function() {\n var ThemeService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n ThemeService = (function(superClass) {\n extend(ThemeService, superClass);\n\n function ThemeService() {\n return ThemeService.__super__.constructor.apply(this, arguments);\n }\n\n return ThemeService;\n\n })(taiga.Service = function() {\n return {\n use: function(themeName) {\n var stylesheetEl;\n stylesheetEl = $(\"link[rel='stylesheet']:first\");\n if (stylesheetEl.length === 0) {\n stylesheetEl = $(\"\");\n $(\"head\").append(stylesheetEl);\n }\n return stylesheetEl.attr(\"href\", \"/\" + window._version + \"/styles/theme-\" + themeName + \".css\");\n }\n };\n });\n\n angular.module(\"taigaCommon\").service(\"tgThemeService\", ThemeService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user.service.coffee\n */\n\n(function() {\n var UserService, bindMethods, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n bindMethods = taiga.bindMethods;\n\n UserService = (function(superClass) {\n extend(UserService, superClass);\n\n UserService.$inject = [\"tgResources\"];\n\n function UserService(rs) {\n this.rs = rs;\n bindMethods(this);\n }\n\n UserService.prototype.getUserByUserName = function(username) {\n return this.rs.users.getUserByUsername(username);\n };\n\n UserService.prototype.getContacts = function(userId) {\n return this.rs.users.getContacts(userId);\n };\n\n UserService.prototype.getLiked = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getLiked(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getVoted = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getVoted(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getWatched = function(userId, pageNumber, objectType, textQuery) {\n return this.rs.users.getWatched(userId, pageNumber, objectType, textQuery);\n };\n\n UserService.prototype.getStats = function(userId) {\n return this.rs.users.getStats(userId);\n };\n\n UserService.prototype.attachUserContactsToProjects = function(userId, projects) {\n return this.getContacts(userId).then(function(contacts) {\n projects = projects.map(function(project) {\n var contactsFiltered;\n contactsFiltered = contacts.filter(function(contact) {\n var contactId;\n contactId = contact.get(\"id\");\n return project.get('members').indexOf(contactId) !== -1;\n });\n project = project.set(\"contacts\", contactsFiltered);\n return project;\n });\n return projects;\n });\n };\n\n return UserService;\n\n })(taiga.Service);\n\n angular.module(\"taigaCommon\").service(\"tgUserService\", UserService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: xhrError.service.coffee\n */\n\n(function() {\n var xhrError,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n xhrError = (function(superClass) {\n extend(xhrError, superClass);\n\n xhrError.$inject = [\"$q\", \"$location\", \"$tgNavUrls\"];\n\n function xhrError(q, location, navUrls) {\n this.q = q;\n this.location = location;\n this.navUrls = navUrls;\n }\n\n xhrError.prototype.notFound = function() {\n this.location.path(this.navUrls.resolve(\"not-found\"));\n return this.location.replace();\n };\n\n xhrError.prototype.permissionDenied = function() {\n this.location.path(this.navUrls.resolve(\"permission-denied\"));\n return this.location.replace();\n };\n\n xhrError.prototype.response = function(xhr) {\n if (xhr) {\n if (xhr.status === 404) {\n this.notFound();\n } else if (xhr.status === 403) {\n this.permissionDenied();\n }\n }\n return this.q.reject(xhr);\n };\n\n return xhrError;\n\n })(taiga.Service);\n\n angular.module(\"taigaCommon\").service(\"tgXhrErrorService\", xhrError);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-attachment.directive.coffee\n */\n\n(function() {\n var UserTimelineAttachmentDirective;\n\n UserTimelineAttachmentDirective = function(template, $compile) {\n var isImage, link, validFileExtensions;\n validFileExtensions = [\".jpg\", \".jpeg\", \".bmp\", \".gif\", \".png\"];\n isImage = function(url) {\n url = url.toLowerCase();\n return _.some(validFileExtensions, function(extension) {\n return url.indexOf(extension, url - extension.length) !== -1;\n });\n };\n link = function(scope, el) {\n var is_image, templateHtml;\n is_image = isImage(scope.attachment.get('url'));\n if (is_image) {\n templateHtml = template.get(\"user-timeline/user-timeline-attachment/user-timeline-attachment-image.html\");\n } else {\n templateHtml = template.get(\"user-timeline/user-timeline-attachment/user-timeline-attachment.html\");\n }\n el.html(templateHtml);\n $compile(el.contents())(scope);\n return el.find(\"img\").error(function() {\n return this.remove();\n });\n };\n return {\n link: link,\n scope: {\n attachment: \"=tgUserTimelineAttachment\"\n }\n };\n };\n\n UserTimelineAttachmentDirective.$inject = [\"$tgTemplate\", \"$compile\"];\n\n angular.module(\"taigaUserTimeline\").directive(\"tgUserTimelineAttachment\", UserTimelineAttachmentDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item-title.service.coffee\n */\n\n(function() {\n var UserTimelineItemTitle, unslugify;\n\n unslugify = this.taiga.unslugify;\n\n UserTimelineItemTitle = (function() {\n UserTimelineItemTitle.$inject = [\"$translate\", \"$sce\"];\n\n UserTimelineItemTitle.prototype._fieldTranslationKey = {\n 'status': 'COMMON.FIELDS.STATUS',\n 'subject': 'COMMON.FIELDS.SUBJECT',\n 'description_diff': 'COMMON.FIELDS.DESCRIPTION',\n 'points': 'COMMON.FIELDS.POINTS',\n 'assigned_to': 'COMMON.FIELDS.ASSIGNED_TO',\n 'severity': 'ISSUES.FIELDS.SEVERITY',\n 'priority': 'ISSUES.FIELDS.PRIORITY',\n 'type': 'ISSUES.FIELDS.TYPE',\n 'is_iocaine': 'TASK.FIELDS.IS_IOCAINE',\n 'is_blocked': 'COMMON.FIELDS.IS_BLOCKED'\n };\n\n UserTimelineItemTitle.prototype._params = {\n username: function(timeline, event) {\n var title_attr, url, user;\n user = timeline.getIn(['data', 'user']);\n if (user.get('is_profile_visible')) {\n title_attr = this.translate.instant('COMMON.SEE_USER_PROFILE', {\n username: user.get('username')\n });\n url = \"user-profile:username=timeline.getIn(['data', 'user', 'username'])\";\n return this._getLink(url, user.get('name'), title_attr);\n } else {\n return this._getUsernameSpan(user.get('name'));\n }\n },\n field_name: function(timeline, event) {\n var field_name;\n field_name = timeline.getIn(['data', 'value_diff', 'key']);\n return this.translate.instant(this._fieldTranslationKey[field_name]);\n },\n project_name: function(timeline, event) {\n var url;\n url = \"project:project=timeline.getIn(['data', 'project', 'slug'])\";\n return this._getLink(url, timeline.getIn([\"data\", \"project\", \"name\"]));\n },\n new_value: function(timeline, event) {\n var new_value, value;\n if (_.isArray(timeline.getIn([\"data\", \"value_diff\", \"value\"]).toJS())) {\n value = timeline.getIn([\"data\", \"value_diff\", \"value\"]).get(1);\n if (value === null && timeline.getIn([\"data\", \"value_diff\", \"key\"]) === 'assigned_to') {\n value = this.translate.instant('ACTIVITY.VALUES.UNASSIGNED');\n }\n new_value = value;\n } else {\n new_value = timeline.getIn([\"data\", \"value_diff\", \"value\"]).first().get(1);\n }\n return _.escape(new_value);\n },\n sprint_name: function(timeline, event) {\n var url;\n url = \"project-taskboard:project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['data', 'milestone', 'slug'])\";\n return this._getLink(url, timeline.getIn(['data', 'milestone', 'name']));\n },\n us_name: function(timeline, event) {\n var event_us, obj, text, url;\n obj = this._getTimelineObj(timeline, event).get('userstory');\n event_us = {\n obj: 'parent_userstory'\n };\n url = this._getDetailObjUrl(event_us);\n text = '#' + obj.get('ref') + ' ' + obj.get('subject');\n return this._getLink(url, text);\n },\n obj_name: function(timeline, event) {\n var obj, text, url;\n obj = this._getTimelineObj(timeline, event);\n url = this._getDetailObjUrl(event);\n if (event.obj === 'wikipage') {\n text = unslugify(obj.get('slug'));\n } else if (event.obj === 'milestone') {\n text = obj.get('name');\n } else {\n text = '#' + obj.get('ref') + ' ' + obj.get('subject');\n }\n return this._getLink(url, text);\n },\n role_name: function(timeline, event) {\n return _.escape(timeline.getIn(['data', 'value_diff', 'value']).keySeq().first());\n }\n };\n\n function UserTimelineItemTitle(translate, sce) {\n this.translate = translate;\n this.sce = sce;\n }\n\n UserTimelineItemTitle.prototype._translateTitleParams = function(param, timeline, event) {\n return this._params[param].call(this, timeline, event);\n };\n\n UserTimelineItemTitle.prototype._getTimelineObj = function(timeline, event) {\n return timeline.getIn(['data', event.obj]);\n };\n\n UserTimelineItemTitle.prototype._getDetailObjUrl = function(event) {\n var url;\n url = {\n \"issue\": [\"project-issues-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"wikipage\": [\"project-wiki-page\", \":project=timeline.getIn(['data', 'project', 'slug']),slug=timeline.getIn(['obj', 'slug'])\"],\n \"task\": [\"project-tasks-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"userstory\": [\"project-userstories-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'ref'])\"],\n \"parent_userstory\": [\"project-userstories-detail\", \":project=timeline.getIn(['data', 'project', 'slug']),ref=timeline.getIn(['obj', 'userstory', 'ref'])\"],\n \"milestone\": [\"project-taskboard\", \":project=timeline.getIn(['data', 'project', 'slug']),sprint=timeline.getIn(['obj', 'slug'])\"]\n };\n return url[event.obj][0] + url[event.obj][1];\n };\n\n UserTimelineItemTitle.prototype._getLink = function(url, text, title) {\n title = title || text;\n return $('').attr('tg-nav', url).text(text).attr('title', title).prop('outerHTML');\n };\n\n UserTimelineItemTitle.prototype._getUsernameSpan = function(text) {\n var title;\n title = title || text;\n return $('').addClass('username').text(text).prop('outerHTML');\n };\n\n UserTimelineItemTitle.prototype._getParams = function(timeline, event, timeline_type) {\n var params;\n params = {};\n timeline_type.translate_params.forEach((function(_this) {\n return function(param) {\n return params[param] = _this._translateTitleParams(param, timeline, event);\n };\n })(this));\n return params;\n };\n\n UserTimelineItemTitle.prototype.getTitle = function(timeline, event, type) {\n var params, paramsKeys, translation;\n params = this._getParams(timeline, event, type);\n paramsKeys = {};\n Object.keys(params).forEach(function(key) {\n return paramsKeys[key] = '{{' + key + '}}';\n });\n translation = this.translate.instant(type.key, paramsKeys);\n Object.keys(params).forEach(function(key) {\n var find;\n find = '{{' + key + '}}';\n return translation = translation.replace(new RegExp(find, 'g'), params[key]);\n });\n return translation;\n };\n\n return UserTimelineItemTitle;\n\n })();\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineItemTitle\", UserTimelineItemTitle);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item-type.service.coffee\n */\n\n(function() {\n var UserTimelineType, timelineType;\n\n timelineType = function(timeline, event) {\n var types;\n types = [\n {\n check: function(timeline, event) {\n return event.obj === 'membership';\n },\n key: 'TIMELINE.NEW_MEMBER',\n translate_params: ['project_name'],\n member: function(timeline) {\n return Immutable.Map({\n user: timeline.getIn(['data', 'user']),\n role: timeline.getIn(['data', 'role'])\n });\n }\n }, {\n check: function(timeline, event) {\n return event.obj === 'project' && event.type === 'create';\n },\n key: 'TIMELINE.NEW_PROJECT',\n translate_params: ['username', 'project_name'],\n description: function(timeline) {\n return timeline.getIn(['data', 'project', 'description']);\n }\n }, {\n check: function(timeline, event) {\n return event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'attachments';\n },\n key: 'TIMELINE.UPLOAD_ATTACHMENT',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'create';\n },\n key: 'TIMELINE.US_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'create';\n },\n key: 'TIMELINE.ISSUE_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'wikipage' && event.type === 'create';\n },\n key: 'TIMELINE.WIKI_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'create' && !timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'create' && timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_CREATED_WITH_US',\n translate_params: ['username', 'project_name', 'obj_name', 'us_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'milestone' && event.type === 'create';\n },\n key: 'TIMELINE.MILESTONE_CREATED',\n translate_params: ['username', 'project_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'userstory';\n },\n key: 'TIMELINE.NEW_COMMENT_US',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'issue';\n },\n key: 'TIMELINE.NEW_COMMENT_ISSUE',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.getIn(['data', 'comment']) && event.obj === 'task';\n },\n key: 'TIMELINE.NEW_COMMENT_TASK',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n text = timeline.getIn(['data', 'comment_html']);\n return $($.parseHTML(text)).text();\n }\n }, {\n check: function(timeline, event) {\n return timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && timeline.hasIn(['data', 'value_diff', 'value', 'backlog_order']) && event.type === 'change';\n },\n key: 'TIMELINE.US_MOVED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && event.type === 'change' && event.obj === 'userstory') {\n return timeline.getIn(['data', 'value_diff', 'value', 'milestone']).get(1) === null;\n }\n return false;\n },\n key: 'TIMELINE.US_REMOVED_FROM_MILESTONE',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'moveInBacklog' && event.type === 'change' && event.obj === 'userstory';\n },\n key: 'TIMELINE.US_ADDED_MILESTONE',\n translate_params: ['username', 'obj_name', 'sprint_name']\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'blocked' && event.type === 'change') {\n return timeline.getIn(['data', 'value_diff', 'value', 'is_blocked']).get(1) === true;\n }\n return false;\n },\n key: 'TIMELINE.BLOCKED',\n translate_params: ['username', 'obj_name'],\n description: function(timeline) {\n var text;\n if (timeline.hasIn(['data', 'value_diff', 'value', 'blocked_note_html'])) {\n text = timeline.getIn(['data', 'value_diff', 'value', 'blocked_note_html']).get(1);\n return $($.parseHTML(text)).text();\n } else {\n return false;\n }\n }\n }, {\n check: function(timeline, event) {\n if (timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'blocked' && event.type === 'change') {\n return timeline.getIn(['data', 'value_diff', 'value', 'is_blocked']).get(1) === false;\n }\n return false;\n },\n key: 'TIMELINE.UNBLOCKED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'milestone' && event.type === 'change';\n },\n key: 'TIMELINE.MILESTONE_UPDATED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'wikipage' && event.type === 'change';\n },\n key: 'TIMELINE.WIKI_UPDATED',\n translate_params: ['username', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'points';\n },\n key: 'TIMELINE.US_UPDATED_POINTS',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value', 'role_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.US_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'userstory' && event.type === 'change';\n },\n key: 'TIMELINE.US_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'change' && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.ISSUE_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'issue' && event.type === 'change';\n },\n key: 'TIMELINE.ISSUE_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && !timeline.getIn(['data', 'task', 'userstory']) && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.TASK_UPDATED',\n translate_params: ['username', 'field_name', 'obj_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && timeline.getIn(['data', 'task', 'userstory']) && timeline.hasIn(['data', 'value_diff']) && timeline.getIn(['data', 'value_diff', 'key']) === 'description_diff';\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_US',\n translate_params: ['username', 'field_name', 'obj_name', 'us_name']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && !timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'task' && event.type === 'change' && timeline.getIn(['data', 'task', 'userstory']);\n },\n key: 'TIMELINE.TASK_UPDATED_WITH_US_NEW_VALUE',\n translate_params: ['username', 'field_name', 'obj_name', 'us_name', 'new_value']\n }, {\n check: function(timeline, event) {\n return event.obj === 'user' && event.type === 'create';\n },\n key: 'TIMELINE.NEW_USER',\n translate_params: ['username']\n }\n ];\n return _.find(types, function(obj) {\n return obj.check(timeline, event);\n });\n };\n\n UserTimelineType = (function() {\n function UserTimelineType() {}\n\n UserTimelineType.prototype.getType = function(timeline, event) {\n return timelineType(timeline, event);\n };\n\n return UserTimelineType;\n\n })();\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineItemType\", UserTimelineType);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-item.directive.coffee\n */\n\n(function() {\n var UserTimelineItemDirective;\n\n UserTimelineItemDirective = function() {\n return {\n templateUrl: \"user-timeline/user-timeline-item/user-timeline-item.html\",\n scope: {\n timeline: \"=tgUserTimelineItem\"\n }\n };\n };\n\n angular.module(\"taigaUserTimeline\").directive(\"tgUserTimelineItem\", UserTimelineItemDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline-pagination-sequence.service.coffee\n */\n\n(function() {\n var UserTimelinePaginationSequence;\n\n UserTimelinePaginationSequence = function() {\n var obj;\n obj = {};\n obj.generate = function(config) {\n var getContent, items, next, page;\n page = 1;\n items = Immutable.List();\n config.minItems = config.minItems || 20;\n next = function() {\n items = Immutable.List();\n return getContent();\n };\n getContent = function() {\n return config.fetch(page).then(function(response) {\n var data;\n page++;\n data = response.get(\"data\");\n if (config.filter) {\n data = config.filter(data);\n }\n if (config.map) {\n data = data.map(config.map);\n }\n items = items.concat(data);\n if (items.size < config.minItems && response.get(\"next\")) {\n return getContent();\n }\n return Immutable.Map({\n items: items,\n next: response.get(\"next\")\n });\n });\n };\n return {\n next: function() {\n return next();\n }\n };\n };\n return obj;\n };\n\n angular.module(\"taigaUserTimeline\").factory(\"tgUserTimelinePaginationSequenceService\", UserTimelinePaginationSequence);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Andrey Antukh \n * Copyright (C) 2014-2016 Jesús Espino Garcia \n * Copyright (C) 2014-2016 David Barragán Merino \n * Copyright (C) 2014-2016 Alejandro Alonso \n * Copyright (C) 2014-2016 Juan Francisco Alcántara \n * Copyright (C) 2014-2016 Xavi Julian \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/profile/profile-timeline/profile-timeline.controller.coffee\n */\n\n(function() {\n var UserTimelineController, mixOf, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n mixOf = this.taiga.mixOf;\n\n UserTimelineController = (function(superClass) {\n extend(UserTimelineController, superClass);\n\n UserTimelineController.$inject = [\"tgUserTimelineService\"];\n\n function UserTimelineController(userTimelineService) {\n this.userTimelineService = userTimelineService;\n this.timelineList = Immutable.List();\n this.scrollDisabled = false;\n this.timeline = null;\n if (this.projectId) {\n this.timeline = this.userTimelineService.getProjectTimeline(this.projectId);\n } else if (this.currentUser) {\n this.timeline = this.userTimelineService.getProfileTimeline(this.user.get(\"id\"));\n } else {\n this.timeline = this.userTimelineService.getUserTimeline(this.user.get(\"id\"));\n }\n }\n\n UserTimelineController.prototype.loadTimeline = function() {\n this.scrollDisabled = true;\n return this.timeline.next().then((function(_this) {\n return function(response) {\n _this.timelineList = _this.timelineList.concat(response.get(\"items\"));\n if (response.get(\"next\")) {\n _this.scrollDisabled = false;\n }\n return _this.timelineList;\n };\n })(this));\n };\n\n return UserTimelineController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin));\n\n angular.module(\"taigaUserTimeline\").controller(\"UserTimeline\", UserTimelineController);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.directive.coffee\n */\n\n(function() {\n var UserTimelineDirective;\n\n UserTimelineDirective = function() {\n return {\n templateUrl: \"user-timeline/user-timeline/user-timeline.html\",\n controller: \"UserTimeline\",\n controllerAs: \"vm\",\n scope: {\n projectId: \"=projectid\",\n user: \"=\",\n currentUser: \"=\"\n },\n bindToController: true\n };\n };\n\n angular.module(\"taigaProfile\").directive(\"tgUserTimeline\", UserTimelineDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014-2016 Taiga Agile LLC \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: user-timeline.service.coffee\n */\n\n(function() {\n var UserTimelineService, taiga,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\n taiga = this.taiga;\n\n UserTimelineService = (function(superClass) {\n extend(UserTimelineService, superClass);\n\n UserTimelineService.$inject = [\"tgResources\", \"tgUserTimelinePaginationSequenceService\", \"tgUserTimelineItemType\", \"tgUserTimelineItemTitle\"];\n\n function UserTimelineService(rs, userTimelinePaginationSequenceService, userTimelineItemType, userTimelineItemTitle) {\n this.rs = rs;\n this.userTimelinePaginationSequenceService = userTimelinePaginationSequenceService;\n this.userTimelineItemType = userTimelineItemType;\n this.userTimelineItemTitle = userTimelineItemTitle;\n }\n\n UserTimelineService.prototype._valid_fields = ['status', 'subject', 'description_diff', 'assigned_to', 'points', 'severity', 'priority', 'type', 'attachments', 'is_iocaine', 'content_diff', 'name', 'estimated_finish', 'estimated_start', 'blocked', 'moveInBacklog', 'milestone'];\n\n UserTimelineService.prototype._invalid = [\n {\n check: function(timeline) {\n var fieldKey, value_diff;\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n if (value_diff) {\n fieldKey = value_diff.get('key');\n if (this._valid_fields.indexOf(fieldKey) === -1) {\n return true;\n } else if (fieldKey === 'attachments' && value_diff.get('value').get('new').size === 0) {\n return true;\n }\n }\n return false;\n }\n }, {\n check: function(timeline) {\n var event, value_diff;\n event = timeline.get('event_type').split(\".\");\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n return event[2] === 'change' && value_diff === void 0;\n }\n }, {\n check: function(timeline) {\n var event;\n event = timeline.get('event_type').split(\".\");\n return event[2] === 'delete';\n }\n }, {\n check: function(timeline) {\n var event;\n event = timeline.get('event_type').split(\".\");\n return event[1] === 'project' && event[2] === 'change';\n }\n }, {\n check: function(timeline) {\n return !!timeline.get(\"data\").get(\"comment_deleted\");\n }\n }, {\n check: function(timeline) {\n var event, value_diff;\n event = timeline.get('event_type').split(\".\");\n value_diff = timeline.get(\"data\").get(\"value_diff\");\n if (value_diff && event[1] === \"task\" && event[2] === \"change\" && value_diff.get(\"key\") === \"milestone\") {\n return timeline.get(\"data\").get(\"value_diff\").get(\"value\");\n }\n return false;\n }\n }\n ];\n\n UserTimelineService.prototype._isInValidTimeline = function(timeline) {\n return _.some(this._invalid, (function(_this) {\n return function(invalid) {\n return invalid.check.call(_this, timeline);\n };\n })(this));\n };\n\n UserTimelineService.prototype._parseEventType = function(event_type) {\n event_type = event_type.split(\".\");\n return {\n section: event_type[0],\n obj: event_type[1],\n type: event_type[2]\n };\n };\n\n UserTimelineService.prototype._getTimelineObject = function(timeline, event) {\n if (timeline.get('data').get(event.obj)) {\n return timeline.get('data').get(event.obj);\n }\n };\n\n UserTimelineService.prototype._attachExtraInfoToTimelineEntry = function(timeline, event, type) {\n var title;\n title = this.userTimelineItemTitle.getTitle(timeline, event, type);\n timeline = timeline.set('title_html', title);\n timeline = timeline.set('obj', this._getTimelineObject(timeline, event));\n if (type.description) {\n timeline = timeline.set('description', type.description(timeline));\n }\n if (type.member) {\n timeline = timeline.set('member', type.member(timeline));\n }\n if (timeline.getIn(['data', 'value_diff', 'key']) === 'attachments' && timeline.hasIn(['data', 'value_diff', 'value', 'new'])) {\n timeline = timeline.set('attachments', timeline.getIn(['data', 'value_diff', 'value', 'new']));\n }\n return timeline;\n };\n\n UserTimelineService.prototype._parseTimeline = function(response) {\n var newdata;\n newdata = Immutable.List();\n response.get('data').forEach((function(_this) {\n return function(item) {\n var data, event, newItem, values_diff;\n event = _this._parseEventType(item.get('event_type'));\n data = item.get('data');\n values_diff = data.get('values_diff');\n if (values_diff && values_diff.count()) {\n if (values_diff.has('is_blocked')) {\n values_diff = Immutable.Map({\n 'blocked': values_diff\n });\n }\n if (values_diff.has('milestone')) {\n if (event.obj === 'userstory') {\n values_diff = Immutable.Map({\n 'moveInBacklog': values_diff\n });\n } else {\n values_diff = values_diff.deleteIn(['values_diff', 'milestone']);\n }\n } else if (event.obj === 'milestone') {\n values_diff = Immutable.Map({\n 'milestone': values_diff\n });\n }\n return values_diff.forEach(function(value, key) {\n var newItem, obj;\n obj = Immutable.Map({\n key: key,\n value: value\n });\n newItem = item.setIn(['data', 'value_diff'], obj);\n newItem = newItem.deleteIn(['data', 'values_diff']);\n return newdata = newdata.push(newItem);\n });\n } else {\n newItem = item.deleteIn(['data', 'values_diff']);\n return newdata = newdata.push(newItem);\n }\n };\n })(this));\n return response.set('data', newdata);\n };\n\n UserTimelineService.prototype._addEntyAttributes = function(item) {\n var event, type;\n event = this._parseEventType(item.get('event_type'));\n type = this.userTimelineItemType.getType(item, event);\n return this._attachExtraInfoToTimelineEntry(item, event, type);\n };\n\n UserTimelineService.prototype.getProfileTimeline = function(userId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.users.getProfileTimeline(userId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n UserTimelineService.prototype.getUserTimeline = function(userId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.users.getUserTimeline(userId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n UserTimelineService.prototype.getProjectTimeline = function(projectId) {\n var config;\n config = {};\n config.fetch = (function(_this) {\n return function(page) {\n return _this.rs.projects.getTimeline(projectId, page).then(function(response) {\n return _this._parseTimeline(response);\n });\n };\n })(this);\n config.map = (function(_this) {\n return function(obj) {\n return _this._addEntyAttributes(obj);\n };\n })(this);\n config.filter = (function(_this) {\n return function(items) {\n return items.filterNot(function(item) {\n return _this._isInValidTimeline(item);\n });\n };\n })(this);\n return this.userTimelinePaginationSequenceService.generate(config);\n };\n\n return UserTimelineService;\n\n })(taiga.Service);\n\n angular.module(\"taigaUserTimeline\").service(\"tgUserTimelineService\", UserTimelineService);\n\n}).call(this);\n\n//# sourceMappingURL=maps/app.js.map\n"]} \ No newline at end of file diff --git a/dist/v-1454069705160/js/maps/libs.js.map b/dist/v-1454071457968/js/maps/libs.js.map similarity index 100% rename from dist/v-1454069705160/js/maps/libs.js.map rename to dist/v-1454071457968/js/maps/libs.js.map diff --git a/dist/v-1454069705160/js/templates.js b/dist/v-1454071457968/js/templates.js similarity index 99% rename from dist/v-1454069705160/js/templates.js rename to dist/v-1454071457968/js/templates.js index b75eeb9..d652a6e 100644 --- a/dist/v-1454069705160/js/templates.js +++ b/dist/v-1454071457968/js/templates.js @@ -2,9 +2,9 @@ angular.module("templates", []).run(["$templateCache", function($templateCache) $templateCache.put("admin/admin-memberships-row-checkbox.html","\n
\n \"/>\n
\n
"); $templateCache.put("admin/admin-memberships.html","\n
\n \n \n
\n \n
\n \n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n \n

\n
\n
\n
"); $templateCache.put("admin/admin-project-default-values.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n

\n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
\n
"); -$templateCache.put("admin/admin-project-export.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n

\n
\n
\n
\n
\"{{
\n

\n

\n
\n
\n
"); +$templateCache.put("admin/admin-project-export.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n

\n
\n
\n
\n
\"{{
\n

\n

\n
\n
\n
"); $templateCache.put("admin/admin-project-modules.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n
\n
\n
\n

\n
\n \n \n
\n
\n \n \n \n
\n
\n
\n \n
\n
\n
"); -$templateCache.put("admin/admin-project-profile.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
{{ \'ADMIN.PROJECT_PROFILE.RECRUITING\' | translate }}\n \n\n\n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n{{\'ADMIN.PROJECT_PROFILE.PRIVATE_OR_PUBLIC\' | translate }}\n
\n {{ \'ADMIN.PROJECT_PROFILE.DELETE\' | translate }}\n
\n
\n
\n
\n
\n
\n

\n

\n
\n
\n
"); +$templateCache.put("admin/admin-project-profile.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
{{ \'ADMIN.PROJECT_PROFILE.RECRUITING\' | translate }}\n \n\n\n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n{{\'ADMIN.PROJECT_PROFILE.PRIVATE_OR_PUBLIC\' | translate }}\n
\n {{ \'ADMIN.PROJECT_PROFILE.DELETE\' | translate }}\n
\n
\n
\n
\n
\n
\n

\n

\n
\n
\n
"); $templateCache.put("admin/admin-project-reports.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n

\n
\n

\n
\n
\n
\n
\n
\n
"); $templateCache.put("admin/admin-project-values-custom-fields.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n

\n
\n

\n
\n
\n
\n

{{ customFieldSectionTitle | translate }}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ attr.name }}
\n
{{ attr.description }}
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

{{ customFieldSectionTitle | translate }}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ attr.name }}
\n
{{ attr.description }}
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

{{ customFieldSectionTitle | translate }}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ attr.name }}
\n
{{ attr.description }}
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"); $templateCache.put("admin/admin-project-values-points.html","\n
\n \n \n
\n \n
\n
\n \n
\n \n
\n
\n
\n
\n

\n
\n

\n
\n
\n
\n

{{sectionName | translate}}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ value.name }}
\n
{{ value.value }}
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
"); @@ -20,12 +20,12 @@ $templateCache.put("admin/admin-third-parties-webhooks.html","\n< $templateCache.put("admin/memberships-row-avatar.html","\n
\" alt=\"<%- full_name %>\"/>\n
<%- full_name %>\n
<%- pending %><%- email %>
\n
\n
"); $templateCache.put("admin/project-csv.html","\n
\n
\n

\n
\n
\n
\n \n
\n
\n
\n
\n
\n
"); $templateCache.put("auth/change-password-from-recovery.html","\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n
\n


\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
"); -$templateCache.put("auth/forgot-password.html","\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n
\n


\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
"); +$templateCache.put("auth/forgot-password.html","\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n
\n


\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
"); $templateCache.put("auth/invitation.html","\n
\n
\n
\n

\n

\n
\n
\n

\n
\n \n
\n
\n \n \n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
"); $templateCache.put("auth/login-text.html","\n

 \" title=\"{{"AUTH.REGISTER" | translate}}\" translate=\"AUTH.CREATE_ACCOUNT\">

"); -$templateCache.put("auth/login.html","\n
\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n \n
\n
\n
\n
"); +$templateCache.put("auth/login.html","\n
\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n \n
\n
\n
\n
"); $templateCache.put("auth/register.html","\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
"); -$templateCache.put("backlog/backlog.html","\n
\n \n \n
\n
\n

\n
\n
\n \n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
--
\n
--
\n
--
\n
--
\n
\n\n \n \n \n\n\n
\n
\n
\n
\n\n \n \n \n\n\n
\n
\n

\n

{{\'BACKLOG.CUSTOMIZE_GRAPH_TEXT\' | translate}} {{\'BACKLOG.CUSTOMIZE_GRAPH_ADMIN\' | translate}}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
{{ ::us.total_voters }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{\'BACKLOG.EMPTY\'\n

\n
\n
\n \n
\n
\n

\n \n\n\n
\n
\"{{\'BACKLOG.SPRINTS.EMPTY\'\n

\n
\n
\n
\n
\n
\n
{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT_ANONYMOUS\' | translate }}{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT\' | translate }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT_ANONYMOUS\' | translate }}{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT\' | translate }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
\n
\n

\n
\n \n
\n \n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
"); +$templateCache.put("backlog/backlog.html","\n
\n \n \n
\n
\n

\n
\n
\n \n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
--
\n
--
\n
--
\n
--
\n
\n\n \n \n \n\n\n
\n
\n
\n
\n\n \n \n \n\n\n
\n
\n

\n

{{\'BACKLOG.CUSTOMIZE_GRAPH_TEXT\' | translate}} {{\'BACKLOG.CUSTOMIZE_GRAPH_ADMIN\' | translate}}

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
{{ ::us.total_voters }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{\'BACKLOG.EMPTY\'\n

\n
\n
\n \n
\n
\n

\n \n\n\n
\n
\"{{\'BACKLOG.SPRINTS.EMPTY\'\n

\n
\n
\n
\n
\n
\n
{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT_ANONYMOUS\' | translate }}{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT\' | translate }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT_ANONYMOUS\' | translate }}{{ \'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT\' | translate }}
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
\n
\n

\n
\n \n
\n \n
\n
\n
\n
\n

\n
\n \n \n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
"); $templateCache.put("backlog/filter-selected.html","<% _.each(filters, function(f) { %>\" data-id=\"<%- f.id %>\" class=\"single-filter selected\">\" class=\"name\"><%- f.name %><% }) %>"); $templateCache.put("backlog/filters.html","\n<% _.each(filters, function(f) { %>\n<% if (f.selected) { %>\" data-id=\"<%- f.id %>\" class=\"single-filter active\">\" class=\"name\"><%- f.name %><% if (f.count){ %><%- f.count %><% } %><% } else { %>\" data-id=\"<%- f.id %>\" class=\"single-filter\">\" class=\"name\"><%- f.name %><% if (f.count){ %><%- f.count %><% } %><% } %>\n<% }) %>"); $templateCache.put("backlog/progress-bar.html","\n
\n
%\" class=\"project-points-progress\">
\n
%\" class=\"closed-points-progress\">
"); @@ -36,9 +36,9 @@ $templateCache.put("contrib/main.html","\n
\n
\n <% if (description){ %><%- description %><% } %>\n
\n
<% if (type==\"text\") { %>\n \"/><% } else if (type==\"multiline\") { %>\n <% } else if (type==\"date\") { %>\n \"/><% } else { %>\n \"/><% } %>\n
\n
\n"); $templateCache.put("custom-attributes/custom-attribute-value.html","\n
\n
<%- name %><% if (description){ %><%- description %><% } %>
\n
<%- value %>
<% if (isEditable) { %>\n
<% } %>\n
"); $templateCache.put("custom-attributes/custom-attributes-values.html","\n
\n \n
open<% } %>\">\n
\">
\n
\n
"); -$templateCache.put("error/error.html","\n
\n
\n \"TAIGA\"\n

Taiga

\n

\n
\n
"); -$templateCache.put("error/not-found.html","\n
\n
\n \"TAIGA\"\n

\n

\n
\n
"); -$templateCache.put("error/permission-denied.html","\n
\n
\n \"TAIGA\"\n

\n

\n
\n
"); +$templateCache.put("error/error.html","\n
\n
\n \"TAIGA\"\n

Taiga

\n

\n
\n
"); +$templateCache.put("error/not-found.html","\n
\n
\n \"TAIGA\"\n

\n

\n
\n
"); +$templateCache.put("error/permission-denied.html","\n
\n
\n \"TAIGA\"\n

\n

\n
\n
"); $templateCache.put("issue/iocaine-button.html","\n
\n \n \n
"); $templateCache.put("issue/issue-paginator.html","\n
    <% if (showPrevious) { %>\n
  • <% } %>\n <% _.each(pages, function(item) { %>\n
  • \"><% if (item.type === \"page\") { %>\"><%- item.num %><% } else if (item.type === \"page-active\") { %><%- item.num %><% } else { %>...<% } %>
  • <% }); %>\n <% if (showNext) { %>\n
  • <% } %>\n
"); $templateCache.put("issue/issue-priority-button.html","\n
clickable<% }%>\">\" class=\"level\"><%- priority.name %><% if(editable){ %><% }%>\n \n
"); @@ -49,13 +49,13 @@ $templateCache.put("issue/issues-detail.html","\n
\" data-id=\"<%- f.id %>\" class=\"single-filter selected\">\" class=\"name\"><%- f.name %><% }) %>"); $templateCache.put("issue/issues-filters.html","\n<% _.each(filters, function(f) { %>\n<% if (!f.selected) { %>\" data-id=\"<%- f.id %>\" class=\"single-filter\">\" class=\"name\"><%- f.name %><% if (f.count){ %><%- f.count %><% } %>\n <% if (f.type == \"myFilters\"){ %><% } %><% } %>\n<% }) %>\n"); $templateCache.put("issue/issues-status-button.html","\" ng-click=\"editStatus()\" class=\"detail-status-inner js-edit-status <% if(editable){ %>clickable<% }%>\"><%- status.name %><% if(editable){ %><% }%>\n "); -$templateCache.put("issue/issues.html","\n
\n \n \n
\n
\n

\n
\n
\n \n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ ::issue.total_voters }}
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{ISSUES.TABLE.EMPTY.TITLE\n

\n
\n \n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n \n \n
\n
\n
\n
\n

\n
\n \n
\n \n
\n
\n
"); +$templateCache.put("issue/issues.html","\n
\n \n \n
\n
\n

\n
\n
\n \n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
{{ ::issue.total_voters }}
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{ISSUES.TABLE.EMPTY.TITLE\n

\n
\n \n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n \n \n
\n
\n
\n
\n

\n
\n \n
\n \n
\n
\n
"); $templateCache.put("issue/promote-issue-to-us-button.html","\n \n\n"); $templateCache.put("kanban/kanban-task.html","\n
\n
\n
\n
\n

\n
\n
\n

\n

\n

\n
\n
"); $templateCache.put("kanban/kanban.html","\n
\n \n
\n
\n

\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
\n
\n

\n
\n \n
\n \n
\n
\n
\n
"); $templateCache.put("project/wizard-create-project.html","\n
\n
\n
\n

\n

\n
\n
\n
\n
\n \n \n

{{ template.description }}

\n
\n
\n
\n
\n
\n
\n
\n

\n

\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
"); $templateCache.put("search/lightbox-search.html","\n
\n

\n
\n \n
\n
\n \n
\n
"); -$templateCache.put("search/search.html","\n
\n \n \n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
  • \n
  • \n
\n
\n \n \n \n \n
\n
"); +$templateCache.put("search/search.html","\n
\n \n \n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n

\n
\n
    \n
  • \n
  • \n
  • \n
  • \n
\n
\n \n \n \n \n
\n
"); $templateCache.put("task/related-task-create-form.html","\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
"); $templateCache.put("task/related-task-row-edit.html","\n
\n
\n \" placeholder=\"{{\'TASK.PLACEHOLDER_SUBJECT\' | translate}}\"/>\n
\n
\n
\n
\n
\n
\n
\n
\n
"); $templateCache.put("task/related-task-row.html","\n
\n
\n
<%- task.subject %>\" class=\"clickable\">#<%- task.ref %><%- task.subject %>\n
<% if(perms.modify_task) { %><% } %>\n <% if(perms.delete_task) { %><% } %>\n
\n
\n
\n\n
\n
\n
<% if(perms.modify_task) { %><% } %>\n
\n
"); @@ -76,26 +76,13 @@ $templateCache.put("user/cancel-account.html","\n
\n
\n
\n
\n
\n\n \n \n \n \n \n \n \n \n \n\n\n
\n

Taiga

\n
\n

\n

\n
\n
\n \n \n
\n
\n
\n
\n
\n
"); $templateCache.put("user/mail-notifications.html","\n
\n \n
\n \n
\n
\n
\n
\n

{{sectionName | translate}}

\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"); $templateCache.put("user/user-change-password.html","\n
\n \n
\n \n
\n
\n
\n
\n

{{sectionName | translate}}

\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
"); -$templateCache.put("user/user-profile.html","\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
\n
\n
"); +$templateCache.put("user/user-profile.html","\n
\n \n
\n \n
\n
\n
\n
\n
\n

\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n
\n
\n
"); $templateCache.put("wiki/editable-wiki-content.html","\n
\n
\n
\n
\n \n
Attach files by dragging & dropping on the textarea above.
\n
"); $templateCache.put("wiki/wiki-nav.html","\n
\n

\n
\n<% if (addWikiLinkPermission) { %><% } %>"); $templateCache.put("wiki/wiki-summary.html","\n
<%- totalEditions %>
\n
<%- lastModifiedDate %>
\n
\n
\" alt=\"<%- user.name %>\"/>
\n
<%- user.name %>
\n
"); $templateCache.put("wiki/wiki.html","\n
\n \n \n
\n
\n
\n
\n

\n
\n
\n

\n
\n \n
\n
"); -$templateCache.put("common/estimation/us-estimation-points-per-role.html","\n
    <% _.each(roles, function(role) { %>\n
  • \" title=\"<%- role.name %>\" class=\"ticket-role-points total <% if(editable){ %>clickable<% } %>\">\n \n <%- role.points %>\n \n <%- role.name %>
  • <% }); %>\n
  • <%- totalPoints %>
  • \n
"); -$templateCache.put("common/estimation/us-estimation-points.html","\n"); -$templateCache.put("common/estimation/us-estimation-total.html","\" class=\"us-points <% if (!editable) { %>not-clickable<% } %>\"><%= text %><% if (editable) { %><% } %>"); -$templateCache.put("common/estimation/us-points-roles-popover.html","\n"); -$templateCache.put("common/history/history-activity.html","\n
\">\n \n
\n <% if (comment.length > 0) { %>\n <% if ((deleteCommentDate || deleteCommentUser)) { %>\n
\', date: \'<%- deleteCommentDate %>\'}\">
<% } %>\n
\n <%= comment %>\n <% if (!deleteCommentDate && mode !== \"activity\" && canDeleteComment) { %>\" title=\"<%- deleteCommentActionTitle %>\" class=\"icon icon-delete comment-delete\"><% } %>\n
<% } %>\n <% if(changes.length > 0) { %>\n
<% if (mode != \"activity\") { %><%- changesText %><% } %>\n <% _.each(changes, function(change) { %>\n <%= change %>\n <% }) %>\n
<% } %>\n
\n
"); -$templateCache.put("common/history/history-base-entries.html","<% if (showMore > 0) { %>\'}\" class=\"show-more show-more-comments\"><% } %>\n<% _.each(entries, function(entry) { %>\n<%= entry %>\n<% }) %>"); -$templateCache.put("common/history/history-base.html","\n
\n
    \n
  • \n
  • \n
\n
\n
\n
\">\n
\" tg-toggle-comment=\"tg-toggle-comment\" class=\"add-comment\">\n <% if (mode !== \"edit\") { %>\n
Attach files by dragging & dropping on the textarea above.
\n <% } %>\n
\n
\n
\n
\n
\n
\n
"); -$templateCache.put("common/history/history-change-attachment.html","\n
\n
<%- name %>
\n
<% _.each(diff, function(change) { %>\n

<%- change.name %> 
<%- change.from %>\n

<%- change.name %> 
<%- change.to %>

\n

<% }) %>\n
\n
"); -$templateCache.put("common/history/history-change-diff.html","\n
\n
<%- name %>
\n
\n

<%= diff %>

\n
\n
"); -$templateCache.put("common/history/history-change-generic.html","\n
\n
<%- name %>
\n
\n


<%- from %>

\n


<%- to %>

\n
\n
"); -$templateCache.put("common/history/history-change-list.html","\n
\n
<%- name %>
\n
<% if (removed.length > 0) { %>\n


<%- removed %>

<% } %>\n <% if (added.length > 0) { %>\n


<%- added %>

<% } %>\n
\n
"); -$templateCache.put("common/history/history-change-points.html","<% _.each(points, function(point, name) { %>\n
\n
\'}\">
\n
\n


<%- point[0] %>

\n


<%- point[1] %>

\n
\n
<% }); %>"); -$templateCache.put("common/history/history-deleted-comment.html","\n
\n
\', date: \'<%- deleteCommentDate %>\'}\">\n
<%= deleteComment %>
\n
<% if (canRestoreComment) { %>\" title=\"{{ \'COMMENTS.RESTORE\' | translate }}\" class=\"comment-restore\"><% } %>\n
"); $templateCache.put("common/components/add-button.html","\n \n\n"); -$templateCache.put("common/components/assigned-to.html","\n
is-iocaine <% }; %>\">\" alt=\"<%- fullName %>\"/><% if (isIocaine) { %>\n
\n \n\n\n
<% }; %>\n
\n
<% if (isUnassigned) { %>\n
{{ \"COMMON.ASSIGNED_TO.NOT_ASSIGNED\" | translate }}
<% } else { %>\n
{{ \"COMMON.FIELDS.ASSIGNED_TO\" | translate }}
<% }; %>\n <% if (isEditable && !isUnassigned) { %><% } %>\n
"); +$templateCache.put("common/components/assigned-to.html","\n
is-iocaine <% }; %>\">\" alt=\"<%- fullName %>\"/><% if (isIocaine) { %>\n
\n \n\n\n
<% }; %>\n
\n
<% if (isUnassigned) { %>\n
{{ \"COMMON.ASSIGNED_TO.NOT_ASSIGNED\" | translate }}
<% } else { %>\n
{{ \"COMMON.FIELDS.ASSIGNED_TO\" | translate }}
<% }; %>\n <% if (isEditable && !isUnassigned) { %><% } %>\n
"); $templateCache.put("common/components/block-button.html","\n \n\n\n \n\n"); $templateCache.put("common/components/created-by.html","\n
\n
{{date}}
\n
\n
\"{{owner.full_name_display}}\"/
"); $templateCache.put("common/components/delete-button.html","\n \n\n"); @@ -112,6 +99,19 @@ $templateCache.put("common/components/status-display.html","<% if (is_closed) { $templateCache.put("common/components/taskboard-placeholder.html","\n
\n
\n
\n
\n
\n
\n
\n

{{\'TASKBOARD.PLACEHOLDER_CARD_TITLE\' | translate}}

\n

{{\'TASKBOARD.PLACEHOLDER_CARD_TEXT\' | translate}}

"); $templateCache.put("common/components/watchers.html","\n<% _.each(watchers, function(watcher) { %>\n<% if(watcher) { %>\n
\n
\" alt=\"<%- watcher.full_name_display %>\"/>
\n \n
<% } %>\n<% }); %>"); $templateCache.put("common/components/wysiwyg.html",""); +$templateCache.put("common/estimation/us-estimation-points-per-role.html","\n
    <% _.each(roles, function(role) { %>\n
  • \" title=\"<%- role.name %>\" class=\"ticket-role-points total <% if(editable){ %>clickable<% } %>\">\n \n <%- role.points %>\n \n <%- role.name %>
  • <% }); %>\n
  • <%- totalPoints %>
  • \n
"); +$templateCache.put("common/estimation/us-estimation-points.html","\n"); +$templateCache.put("common/estimation/us-estimation-total.html","\" class=\"us-points <% if (!editable) { %>not-clickable<% } %>\"><%= text %><% if (editable) { %><% } %>"); +$templateCache.put("common/estimation/us-points-roles-popover.html","\n"); +$templateCache.put("common/history/history-activity.html","\n
\">\n \n
\n <% if (comment.length > 0) { %>\n <% if ((deleteCommentDate || deleteCommentUser)) { %>\n
\', date: \'<%- deleteCommentDate %>\'}\">
<% } %>\n
\n <%= comment %>\n <% if (!deleteCommentDate && mode !== \"activity\" && canDeleteComment) { %>\" title=\"<%- deleteCommentActionTitle %>\" class=\"icon icon-delete comment-delete\"><% } %>\n
<% } %>\n <% if(changes.length > 0) { %>\n
<% if (mode != \"activity\") { %><%- changesText %><% } %>\n <% _.each(changes, function(change) { %>\n <%= change %>\n <% }) %>\n
<% } %>\n
\n
"); +$templateCache.put("common/history/history-base-entries.html","<% if (showMore > 0) { %>\'}\" class=\"show-more show-more-comments\"><% } %>\n<% _.each(entries, function(entry) { %>\n<%= entry %>\n<% }) %>"); +$templateCache.put("common/history/history-base.html","\n
\n
    \n
  • \n
  • \n
\n
\n
\n
\">\n
\" tg-toggle-comment=\"tg-toggle-comment\" class=\"add-comment\">\n <% if (mode !== \"edit\") { %>\n
Attach files by dragging & dropping on the textarea above.
\n <% } %>\n
\n
\n
\n
\n
\n
\n
"); +$templateCache.put("common/history/history-change-attachment.html","\n
\n
<%- name %>
\n
<% _.each(diff, function(change) { %>\n

<%- change.name %> 
<%- change.from %>\n

<%- change.name %> 
<%- change.to %>

\n

<% }) %>\n
\n
"); +$templateCache.put("common/history/history-change-diff.html","\n
\n
<%- name %>
\n
\n

<%= diff %>

\n
\n
"); +$templateCache.put("common/history/history-change-generic.html","\n
\n
<%- name %>
\n
\n


<%- from %>

\n


<%- to %>

\n
\n
"); +$templateCache.put("common/history/history-change-list.html","\n
\n
<%- name %>
\n
<% if (removed.length > 0) { %>\n


<%- removed %>

<% } %>\n <% if (added.length > 0) { %>\n


<%- added %>

<% } %>\n
\n
"); +$templateCache.put("common/history/history-change-points.html","<% _.each(points, function(point, name) { %>\n
\n
\'}\">
\n
\n


<%- point[0] %>

\n


<%- point[1] %>

\n
\n
<% }); %>"); +$templateCache.put("common/history/history-deleted-comment.html","\n
\n
\', date: \'<%- deleteCommentDate %>\'}\">\n
<%= deleteComment %>
\n
<% if (canRestoreComment) { %>\" title=\"{{ \'COMMENTS.RESTORE\' | translate }}\" class=\"comment-restore\"><% } %>\n
"); $templateCache.put("common/lightbox/lightbox-assigned-to-users.html","<% if (selected) { %>\n<% } %>\n<% _.each(users, function(user) { %>\n<% }) %>\n<% if (showMore) { %>\n
<% } %>"); $templateCache.put("common/lightbox/lightbox-assigned-to.html","\n
\n

\n
\n \n
\n
\n
"); $templateCache.put("common/lightbox/lightbox-attachment-preview.html","\n
"); @@ -130,19 +130,19 @@ $templateCache.put("external-apps/external-app.html","\n
\n
\n
\n
\n
\n \n
"); $templateCache.put("navigation-bar/navigation-bar.html","\n"); $templateCache.put("profile/profile.html","\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
"); -$templateCache.put("components/attachment/attachment-gallery.html","\n"); +$templateCache.put("components/attachment/attachment-gallery.html","\n"); $templateCache.put("components/attachment/attachment.html","\n
\n \n
{{\'ATTACHMENT.DEPRECATED\' | translate}}{{vm.attachment.getIn([\'file\', \'description\'])}}
\n
{{::vm.attachment.getIn([\'file\', \'size\']) | sizeFormat}}
\n
\n \n
\n
\n \n \n
\n
\n
\n
\n
\n
\n
"); -$templateCache.put("components/attachments-full/attachments-full.html","\n
\n
\n

{{vm.attachments.size}}

\n
\n \n \n
\n \n \n
\n
\n
\n
\n
{{\'ATTACHMENT.DROP\' | translate}}
\n
\n
\n
\n
\n \n
\n
\n
\n \n\n{{file.name}}
\n
{{file.size | sizeFormat}}
\n
{{file.progressMessage}}\n
\n
\n
\n
\n
\n
\n \n
\n
\"{{\'COMMON.LOADING\'
\n
{{file.progressMessage}}
\n
\n
\n
"); +$templateCache.put("components/attachments-full/attachments-full.html","\n
\n
\n

{{vm.attachments.size}}

\n
\n \n \n
\n \n \n
\n
\n
\n
\n
{{\'ATTACHMENT.DROP\' | translate}}
\n
\n
\n
\n
\n \n
\n
\n
\n \n\n{{file.name}}
\n
{{file.size | sizeFormat}}
\n
{{file.progressMessage}}\n
\n
\n
\n
\n
\n
\n \n
\n
\"{{\'COMMON.LOADING\'
\n
{{file.progressMessage}}
\n
\n
\n
"); $templateCache.put("components/attachments-simple/attachments-simple.html","\n
\n
\n

{{vm.attachments.size}}

\n
\n \n \n
\n
\n
\n
{{\'ATTACHMENT.DROP\' | translate}}
\n
\n
\n
\n
\n \n\n{{attachment.get(\'name\')}}
\n
{{attachment.get(\'size\') | sizeFormat}}
\n \n
\n
\n
"); -$templateCache.put("components/live-announcement/live-announcement.html","\n
\n
\"Loading...\"\n
\n

{{vm.title}}

\n

\n \n\n\n
\n
\n
"); +$templateCache.put("components/live-announcement/live-announcement.html","\n
\n
\"Loading...\"\n
\n

{{vm.title}}

\n

\n \n\n\n
\n
\n
"); $templateCache.put("components/project-menu/project-menu.html","\n"); $templateCache.put("components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html","\n

"); $templateCache.put("components/vote-button/vote-button.html","\n\n \n\n{{ vm.item.total_voters }}\n\n \n\n{{ ::vm.item.total_voters }}"); $templateCache.put("components/watch-button/watch-button-ticket.html","\n
{{ vm.item.watchers.length }} {{\'COMMON.WATCHERS.WATCHERS\' | translate}}
\n"); $templateCache.put("components/watch-button/watch-button.html","\n\n \n\n{{ vm.item.watchers.length }}\n\n \n\n{{ vm.item.watchers.length }}"); $templateCache.put("discover/discover-home/discover-home.html","\n
\n
\n \n
\n
\n \n \n
\n
\n \n
\n
"); -$templateCache.put("discover/discover-search/discover-search.html","\n
\n
\n \n
\n
\"{{\n

\n
\n
\n
\n
\n \n
\n
    \n
  • \n
    \"{{::project.get(\'name\')}}\"/\n
    \n

    {{project.get(\'name\')}}\n \n\n

    \n

    {{ ::project.get(\'description\') | limitTo:300 }}...

    \n
    \n
    \n
    \n\n \n \n \n\n{{::project.get(\'total_fans\')}}\n \n \n \n \n \n\n{{::project.get(\'total_watchers\')}}\n \n\n{{ ::project.get(\'members\').size }}
    \n
  • \n
{{ \'DISCOVER.VIEW_MORE\' | translate }}\n
\n
\n
"); -$templateCache.put("home/duties/duty.html","\n
\n
\n
\n

{{ ::vm.duty.get(\'projectName\')}}{{ ::vm.getDutyType() }}{{ ::vm.duty.get(\'status_extra_info\').get(\'name\') }}

\n

{{ \'COMMON.BLOCKED\' | translate }} {{ ::duty.get(\'subject\') }}

\n
"); +$templateCache.put("discover/discover-search/discover-search.html","\n
\n
\n \n
\n
\"{{\n

\n
\n
\n
\n
\n \n
\n
    \n
  • \n
    \"{{::project.get(\'name\')}}\"/\n
    \n

    {{project.get(\'name\')}}\n \n\n

    \n

    {{ ::project.get(\'description\') | limitTo:300 }}...

    \n
    \n
    \n
    \n\n \n \n \n\n{{::project.get(\'total_fans\')}}\n \n \n \n \n \n\n{{::project.get(\'total_watchers\')}}\n \n\n{{ ::project.get(\'members\').size }}
    \n
  • \n
{{ \'DISCOVER.VIEW_MORE\' | translate }}\n
\n
\n
"); +$templateCache.put("home/duties/duty.html","\n
\n
\n
\n

{{ ::vm.duty.get(\'projectName\')}}{{ ::vm.getDutyType() }}{{ ::vm.duty.get(\'status_extra_info\').get(\'name\') }}

\n

{{ \'COMMON.BLOCKED\' | translate }} {{ ::duty.get(\'subject\') }}

\n
"); $templateCache.put("home/projects/home-project-list.html","\n
\n
\n
\n
\n
\n
\n \n

{{::project.get(\'description\')| limitTo:100 }}...

\n
\n\n \n \n \n\n{{::project.get(\'total_fans\')}}\n \n \n \n \n \n\n{{::project.get(\'total_watchers\')}}\n \n\n{{ ::project.get(\'members\').size }}\n \n\n
\n
\n
\n
\n
\n\n\n \n \n \n\n\n

\n \n
"); $templateCache.put("home/working-on/empty.html","\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"); $templateCache.put("home/working-on/working-on.html","\n
\n
\n

{{\"HOME.DASHBOARD\" | translate}}

\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"); @@ -150,18 +150,18 @@ $templateCache.put("navigation-bar/dropdown-organization-list/dropdown-organizat $templateCache.put("navigation-bar/dropdown-project-list/dropdown-project-list.html","\n \n \n \n \n \n\n\n"); $templateCache.put("navigation-bar/dropdown-user/dropdown-user.html","{{ vm.user.get(\'full_name_display\') }}\"{{\n
\n
    \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
\n
"); $templateCache.put("profile/profile-bar/profile-bar.html","\n
\n
\"{{::vm.user.get(\'full_name\')}}\"
\n \n \n
\n

{{::vm.user.get(\"full_name_display\")}}

\n
@{{::vm.user.get(\"username\")}}
\n

{{::vm.stats.get(\'roles\').join(\", \")}}

\n \n \n \n \n \n \n
\n \n
\n
{{::vm.stats.get(\'total_num_projects\')}}
\n
{{::vm.stats.get(\'total_num_closed_userstories\')}}
\n
{{::vm.stats.get(\'total_num_contacts\')}}
\n
\n \n
{{::vm.user.get(\"bio\") | limitTo:210 }}{{vm.user.get(\"bio\").length < 210 ? \'\' : \'...\'}}
\n
"); -$templateCache.put("profile/profile-contacts/profile-contacts.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n\n \n \n \n\n\n
\n

\n
\n
\n

\n

\n
\n
\n
\"{{::contact.get(\'full_name\')}}\"/\n
\n

{{::contact.get(\'full_name_display\')}}

\n

{{::contact.get(\'roles\').join(\", \")}}

\n

{{::contact.get(\'bio\')}}

\n
\n
\n
"); -$templateCache.put("profile/profile-favs/profile-favs.html","\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{
\n
\n
\"{{\n

{{ \'USER.PROFILE_FAVS.EMPTY_TITLE\' | translate }}

\n
\n
"); +$templateCache.put("profile/profile-contacts/profile-contacts.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n\n \n \n \n\n\n
\n

\n
\n
\n

\n

\n
\n
\n
\"{{::contact.get(\'full_name\')}}\"/\n
\n

{{::contact.get(\'full_name_display\')}}

\n

{{::contact.get(\'roles\').join(\", \")}}

\n

{{::contact.get(\'bio\')}}

\n
\n
\n
"); +$templateCache.put("profile/profile-favs/profile-favs.html","\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\"{{
\n
\n
\"{{\n

{{ \'USER.PROFILE_FAVS.EMPTY_TITLE\' | translate }}

\n
\n
"); $templateCache.put("profile/profile-hints/profile-hints.html","\n

\n

{{::vm.hint.title}}

\n

\n {{::vm.hint.text}}\n  \n

"); -$templateCache.put("profile/profile-projects/profile-projects.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n\n \n \n \n\n\n

\n
\n
\n
\n
\"{{::project.get(\'name\')}}\"/\n
\n

{{::project.get(\'name\')}}

\n

{{ ::project.get(\'description\') | limitTo:300 }}

\n
\n
\n
{{::tag.get(\'name\')}}
\n
\n
\n
\n\n \n \n \n\n{{ ::project.get(\'total_fans\') }}\n\n \n\n{{ ::project.get(\'total_watchers\') }}
\n
\n
\n
\n
"); +$templateCache.put("profile/profile-projects/profile-projects.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n\n \n \n \n\n\n

\n
\n
\n
\n
\"{{::project.get(\'name\')}}\"/\n
\n

{{::project.get(\'name\')}}

\n

{{ ::project.get(\'description\') | limitTo:300 }}

\n
\n
\n
{{::tag.get(\'name\')}}
\n
\n
\n
\n\n \n \n \n\n{{ ::project.get(\'total_fans\') }}\n\n \n\n{{ ::project.get(\'total_watchers\') }}
\n
\n
\n
\n
"); $templateCache.put("profile/profile-tab/profile-tab.html","\n
\n \n
"); $templateCache.put("profile/profile-tabs/profile-tabs.html","\n"); $templateCache.put("projects/listing/projects-listing.html","\n
\n
\n

\n
\n
\n
\n
\n
\n
    \n
  • \n
    \n
    \"{{::project.get(\'name\')}}\"/\n
    \n

    {{project.get(\'name\')}}\n \n\n

    \n

    {{ ::project.get(\'description\') | limitTo:300 }}...

    \n
    \n
    \n
    {{::tag.get(\'name\')}}
    \n
    \n
  • \n
\n
\n \n
\n
"); -$templateCache.put("projects/project/project.html","\n
\n \n
\n
\n
\"{{::vm.project.get(\'name\')}}\"/
\n
\n
\n
\n

{{::vm.project.get(\"name\")}}

\n \n\n\n
\n
\n \n \n
\n
\n
\n\n \n \n \n\n{{ ::vm.project.get(\'total_fans\') }}\n\n \n\n{{ ::vm.project.get(\'total_watchers\') }}
\n
\n
\n

{{vm.project.get(\'description\')}}

\n
\n
\n
{{::tag.get(\'name\')}}
\n
\n
\n
\n
\n
\n
\n

{{\'PROJECT.LOOKING_FOR_PEOPLE\' | translate}}

\n

{{::vm.project.get(\'looking_for_people_note\')}}\"

\n
\n

{{\"PROJECT.SECTION.TEAM\" | translate}}

\n
    \n
  • \"{{::member.get(\'full_name\')}}\"/
  • \n
\n
\n
\n
\n
"); -$templateCache.put("user-timeline/user-timeline/user-timeline.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n
\n
\n
"); +$templateCache.put("projects/project/project.html","\n
\n \n
\n
\n
\"{{::vm.project.get(\'name\')}}\"/
\n
\n
\n
\n

{{::vm.project.get(\"name\")}}

\n \n\n\n
\n
\n \n \n
\n
\n
\n\n \n \n \n\n{{ ::vm.project.get(\'total_fans\') }}\n\n \n\n{{ ::vm.project.get(\'total_watchers\') }}
\n
\n
\n

{{vm.project.get(\'description\')}}

\n
\n
\n
{{::tag.get(\'name\')}}
\n
\n
\n
\n
\n
\n
\n

{{\'PROJECT.LOOKING_FOR_PEOPLE\' | translate}}

\n

{{::vm.project.get(\'looking_for_people_note\')}}\"

\n
\n

{{\"PROJECT.SECTION.TEAM\" | translate}}

\n
    \n
  • \"{{::member.get(\'full_name\')}}\"/
  • \n
\n
\n
\n
\n
"); +$templateCache.put("user-timeline/user-timeline/user-timeline.html","\n
\n
\n
\"Loading...\"/
\n
\n
\n
\n
\n
"); $templateCache.put("user-timeline/user-timeline-attachment/user-timeline-attachment-image.html","\n\n
\n
\"{{::attachment.get(\'filename\')}}\"/
\n
"); $templateCache.put("user-timeline/user-timeline-attachment/user-timeline-attachment.html","\n"); -$templateCache.put("user-timeline/user-timeline-item/user-timeline-item.html","\n
{{::timeline.get(\'created\') | momentFromNow}}\n
\n
\n \n
\"{{::timeline.getIn([\'data\',
\n \n
\"{{::timeline.getIn([\'data\',
\n

\n
\n
{{::timeline.get(\'description\') | limitTo:300}}
\n
\"{{::timeline.getIn([\'member\',\'user\',\n
{{::timeline.getIn([\'member\',\'user\', \'name\'])}}\n

{{::timeline.getIn([\'member\',\'role\', \'name\'])}}

\n
\n
\n
\n
\n
\n
"); +$templateCache.put("user-timeline/user-timeline-item/user-timeline-item.html","\n
{{::timeline.get(\'created\') | momentFromNow}}\n
\n
\n \n
\"{{::timeline.getIn([\'data\',
\n \n
\"{{::timeline.getIn([\'data\',
\n

\n
\n
{{::timeline.get(\'description\') | limitTo:300}}
\n
\"{{::timeline.getIn([\'member\',\'user\',\n
{{::timeline.getIn([\'member\',\'user\', \'name\'])}}\n

{{::timeline.getIn([\'member\',\'role\', \'name\'])}}

\n
\n
\n
\n
\n
\n
"); $templateCache.put("discover/components/discover-home-order-by/discover-home-order-by.html","\n
{{vm.currentText()}}\n
    \n
  • {{ \'DISCOVER.FILTERS.WEEK\' | translate }}
  • \n
  • {{ \'DISCOVER.FILTERS.MONTH\' | translate }}
  • \n
  • {{ \'DISCOVER.FILTERS.YEAR\' | translate }}
  • \n
  • {{ \'DISCOVER.FILTERS.ALL_TIME\' | translate }}
  • \n
\n
"); $templateCache.put("discover/components/discover-search-bar/discover-search-bar.html","\n
\n
\n

{{ \'DISCOVER.DISCOVER_TITLE\' | translate }}

\n

\n
\n \n
\n \n \n \n \n \n \n \n \n
\n
\n
\n
"); $templateCache.put("discover/components/discover-search-list-header/discover-search-list-header.html","\n"); @@ -170,6 +170,6 @@ $templateCache.put("discover/components/highlighted/highlighted.html","\n
\n
\n
\n \n \n \n\n\n

{{ \'DISCOVER.MOST_ACTIVE\' | translate }}

\n
\n \n
\n \n
\n
\n \n \n \n\n{{ \'DISCOVER.MOST_ACTIVE_EMPTY\' | translate }}\n
"); $templateCache.put("discover/components/most-liked/most-liked.html","\n
\n
\n
\n\n \n \n \n\n\n

{{ \'DISCOVER.MOST_LIKED\' | translate }}

\n
\n \n
\n \n
\n
\n\n \n \n \n\n{{ \'DISCOVER.MOST_LIKED_EMPTY\' | translate }}\n
"); $templateCache.put("profile/profile-favs/items/project.html","\n
\n
\n
\n
\n

{{ ::vm.item.get(\'name\') }}

\n

{{ ::vm.item.get(\'description\') }}

\n
\n
\n
{{ ::tag.get(\'name\') }}
\n
\n
\n\n \n \n \n\n{{ ::vm.item.get(\'total_fans\') }}\n\n \n\n{{ ::vm.item.get(\'total_watchers\') }}
\n
"); -$templateCache.put("profile/profile-favs/items/ticket.html","\n
\"{{\"{{\n
\n

{{:: vm.item.get(\'project_name\') }}{{:: vm.item.get(\'status\') }}

\n

{{ ::vm.item.get(\'subject\') }}{{ ::vm.item.get(\'subject\') }}{{ ::vm.item.get(\'subject\') }}

\n
\n
\n\n \n\n{{ ::vm.item.get(\'total_voters\') }}\n\n \n\n{{ ::vm.item.get(\'total_watchers\') }}
\n
"); +$templateCache.put("profile/profile-favs/items/ticket.html","\n
\"{{\"{{\n
\n

{{:: vm.item.get(\'project_name\') }}{{:: vm.item.get(\'status\') }}

\n

{{ ::vm.item.get(\'subject\') }}{{ ::vm.item.get(\'subject\') }}{{ ::vm.item.get(\'subject\') }}

\n
\n
\n\n \n\n{{ ::vm.item.get(\'total_voters\') }}\n\n \n\n{{ ::vm.item.get(\'total_watchers\') }}
\n
"); $templateCache.put("projects/components/like-project-button/like-project-button.html","\n\n \n \n \n\n{{ vm.project.get(\'total_fans\') }}"); $templateCache.put("projects/components/watch-project-button/watch-project-button.html","\n\n \n\n{{ vm.project.get(\'total_watchers\') }}\n");}]); \ No newline at end of file diff --git a/dist/v-1454069705160/locales/taiga/locale-ca.json b/dist/v-1454071457968/locales/taiga/locale-ca.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-ca.json rename to dist/v-1454071457968/locales/taiga/locale-ca.json diff --git a/dist/v-1454069705160/locales/taiga/locale-de.json b/dist/v-1454071457968/locales/taiga/locale-de.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-de.json rename to dist/v-1454071457968/locales/taiga/locale-de.json diff --git a/dist/v-1454069705160/locales/taiga/locale-en.json b/dist/v-1454071457968/locales/taiga/locale-en.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-en.json rename to dist/v-1454071457968/locales/taiga/locale-en.json diff --git a/dist/v-1454069705160/locales/taiga/locale-es.json b/dist/v-1454071457968/locales/taiga/locale-es.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-es.json rename to dist/v-1454071457968/locales/taiga/locale-es.json diff --git a/dist/v-1454069705160/locales/taiga/locale-fi.json b/dist/v-1454071457968/locales/taiga/locale-fi.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-fi.json rename to dist/v-1454071457968/locales/taiga/locale-fi.json diff --git a/dist/v-1454069705160/locales/taiga/locale-fr.json b/dist/v-1454071457968/locales/taiga/locale-fr.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-fr.json rename to dist/v-1454071457968/locales/taiga/locale-fr.json diff --git a/dist/v-1454069705160/locales/taiga/locale-it.json b/dist/v-1454071457968/locales/taiga/locale-it.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-it.json rename to dist/v-1454071457968/locales/taiga/locale-it.json diff --git a/dist/v-1454069705160/locales/taiga/locale-nl.json b/dist/v-1454071457968/locales/taiga/locale-nl.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-nl.json rename to dist/v-1454071457968/locales/taiga/locale-nl.json diff --git a/dist/v-1454069705160/locales/taiga/locale-pl.json b/dist/v-1454071457968/locales/taiga/locale-pl.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-pl.json rename to dist/v-1454071457968/locales/taiga/locale-pl.json diff --git a/dist/v-1454069705160/locales/taiga/locale-pt-br.json b/dist/v-1454071457968/locales/taiga/locale-pt-br.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-pt-br.json rename to dist/v-1454071457968/locales/taiga/locale-pt-br.json diff --git a/dist/v-1454069705160/locales/taiga/locale-ru.json b/dist/v-1454071457968/locales/taiga/locale-ru.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-ru.json rename to dist/v-1454071457968/locales/taiga/locale-ru.json diff --git a/dist/v-1454069705160/locales/taiga/locale-sv.json b/dist/v-1454071457968/locales/taiga/locale-sv.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-sv.json rename to dist/v-1454071457968/locales/taiga/locale-sv.json diff --git a/dist/v-1454069705160/locales/taiga/locale-tr.json b/dist/v-1454071457968/locales/taiga/locale-tr.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-tr.json rename to dist/v-1454071457968/locales/taiga/locale-tr.json diff --git a/dist/v-1454069705160/locales/taiga/locale-zh-hant.json b/dist/v-1454071457968/locales/taiga/locale-zh-hant.json similarity index 100% rename from dist/v-1454069705160/locales/taiga/locale-zh-hant.json rename to dist/v-1454071457968/locales/taiga/locale-zh-hant.json diff --git a/dist/v-1454069705160/styles/theme-high-contrast.css b/dist/v-1454071457968/styles/theme-high-contrast.css similarity index 100% rename from dist/v-1454069705160/styles/theme-high-contrast.css rename to dist/v-1454071457968/styles/theme-high-contrast.css diff --git a/dist/v-1454069705160/styles/theme-material-design.css b/dist/v-1454071457968/styles/theme-material-design.css similarity index 100% rename from dist/v-1454069705160/styles/theme-material-design.css rename to dist/v-1454071457968/styles/theme-material-design.css diff --git a/dist/v-1454069705160/styles/theme-taiga.css b/dist/v-1454071457968/styles/theme-taiga.css similarity index 100% rename from dist/v-1454069705160/styles/theme-taiga.css rename to dist/v-1454071457968/styles/theme-taiga.css diff --git a/dist/v-1454069705160/svg/activity.svg b/dist/v-1454071457968/svg/activity.svg similarity index 100% rename from dist/v-1454069705160/svg/activity.svg rename to dist/v-1454071457968/svg/activity.svg diff --git a/dist/v-1454069705160/svg/add.svg b/dist/v-1454071457968/svg/add.svg similarity index 100% rename from dist/v-1454069705160/svg/add.svg rename to dist/v-1454071457968/svg/add.svg diff --git a/dist/v-1454069705160/svg/attachment.svg b/dist/v-1454071457968/svg/attachment.svg similarity index 100% rename from dist/v-1454069705160/svg/attachment.svg rename to dist/v-1454071457968/svg/attachment.svg diff --git a/dist/v-1454069705160/svg/check.svg b/dist/v-1454071457968/svg/check.svg similarity index 100% rename from dist/v-1454069705160/svg/check.svg rename to dist/v-1454071457968/svg/check.svg diff --git a/dist/v-1454069705160/svg/client-requirement.svg b/dist/v-1454071457968/svg/client-requirement.svg similarity index 100% rename from dist/v-1454069705160/svg/client-requirement.svg rename to dist/v-1454071457968/svg/client-requirement.svg diff --git a/dist/v-1454069705160/svg/dashboard.svg b/dist/v-1454071457968/svg/dashboard.svg similarity index 100% rename from dist/v-1454069705160/svg/dashboard.svg rename to dist/v-1454071457968/svg/dashboard.svg diff --git a/dist/v-1454069705160/svg/discover.svg b/dist/v-1454071457968/svg/discover.svg similarity index 100% rename from dist/v-1454069705160/svg/discover.svg rename to dist/v-1454071457968/svg/discover.svg diff --git a/dist/v-1454069705160/svg/empty-project.svg b/dist/v-1454071457968/svg/empty-project.svg similarity index 100% rename from dist/v-1454069705160/svg/empty-project.svg rename to dist/v-1454071457968/svg/empty-project.svg diff --git a/dist/v-1454069705160/svg/eye.svg b/dist/v-1454071457968/svg/eye.svg similarity index 100% rename from dist/v-1454069705160/svg/eye.svg rename to dist/v-1454071457968/svg/eye.svg diff --git a/dist/v-1454069705160/svg/flag.svg b/dist/v-1454071457968/svg/flag.svg similarity index 100% rename from dist/v-1454069705160/svg/flag.svg rename to dist/v-1454071457968/svg/flag.svg diff --git a/dist/v-1454069705160/svg/gallery.svg b/dist/v-1454071457968/svg/gallery.svg similarity index 100% rename from dist/v-1454069705160/svg/gallery.svg rename to dist/v-1454071457968/svg/gallery.svg diff --git a/dist/v-1454069705160/svg/graph.svg b/dist/v-1454071457968/svg/graph.svg similarity index 100% rename from dist/v-1454069705160/svg/graph.svg rename to dist/v-1454071457968/svg/graph.svg diff --git a/dist/v-1454069705160/svg/help.svg b/dist/v-1454071457968/svg/help.svg similarity index 100% rename from dist/v-1454069705160/svg/help.svg rename to dist/v-1454071457968/svg/help.svg diff --git a/dist/v-1454069705160/svg/hide.svg b/dist/v-1454071457968/svg/hide.svg similarity index 100% rename from dist/v-1454069705160/svg/hide.svg rename to dist/v-1454071457968/svg/hide.svg diff --git a/dist/v-1454069705160/svg/iocaine.svg b/dist/v-1454071457968/svg/iocaine.svg similarity index 100% rename from dist/v-1454069705160/svg/iocaine.svg rename to dist/v-1454071457968/svg/iocaine.svg diff --git a/dist/v-1454069705160/svg/like.svg b/dist/v-1454071457968/svg/like.svg similarity index 100% rename from dist/v-1454069705160/svg/like.svg rename to dist/v-1454071457968/svg/like.svg diff --git a/dist/v-1454069705160/svg/list.svg b/dist/v-1454071457968/svg/list.svg similarity index 100% rename from dist/v-1454069705160/svg/list.svg rename to dist/v-1454071457968/svg/list.svg diff --git a/dist/v-1454069705160/svg/location.svg b/dist/v-1454071457968/svg/location.svg similarity index 100% rename from dist/v-1454069705160/svg/location.svg rename to dist/v-1454071457968/svg/location.svg diff --git a/dist/v-1454069705160/svg/lock.svg b/dist/v-1454071457968/svg/lock.svg similarity index 100% rename from dist/v-1454069705160/svg/lock.svg rename to dist/v-1454071457968/svg/lock.svg diff --git a/dist/v-1454069705160/svg/logo-color.svg b/dist/v-1454071457968/svg/logo-color.svg similarity index 100% rename from dist/v-1454069705160/svg/logo-color.svg rename to dist/v-1454071457968/svg/logo-color.svg diff --git a/dist/v-1454069705160/svg/logo-moustache.svg b/dist/v-1454071457968/svg/logo-moustache.svg similarity index 100% rename from dist/v-1454069705160/svg/logo-moustache.svg rename to dist/v-1454071457968/svg/logo-moustache.svg diff --git a/dist/v-1454069705160/svg/logo-nav.svg b/dist/v-1454071457968/svg/logo-nav.svg similarity index 100% rename from dist/v-1454069705160/svg/logo-nav.svg rename to dist/v-1454071457968/svg/logo-nav.svg diff --git a/dist/v-1454069705160/svg/logo.svg b/dist/v-1454071457968/svg/logo.svg similarity index 100% rename from dist/v-1454069705160/svg/logo.svg rename to dist/v-1454071457968/svg/logo.svg diff --git a/dist/v-1454069705160/svg/organizations.svg b/dist/v-1454071457968/svg/organizations.svg similarity index 100% rename from dist/v-1454069705160/svg/organizations.svg rename to dist/v-1454071457968/svg/organizations.svg diff --git a/dist/v-1454069705160/svg/pattern.svg b/dist/v-1454071457968/svg/pattern.svg similarity index 100% rename from dist/v-1454069705160/svg/pattern.svg rename to dist/v-1454071457968/svg/pattern.svg diff --git a/dist/v-1454069705160/svg/project.svg b/dist/v-1454071457968/svg/project.svg similarity index 100% rename from dist/v-1454069705160/svg/project.svg rename to dist/v-1454071457968/svg/project.svg diff --git a/dist/v-1454069705160/svg/projects.svg b/dist/v-1454071457968/svg/projects.svg similarity index 100% rename from dist/v-1454069705160/svg/projects.svg rename to dist/v-1454071457968/svg/projects.svg diff --git a/dist/v-1454069705160/svg/promote.svg b/dist/v-1454071457968/svg/promote.svg similarity index 100% rename from dist/v-1454069705160/svg/promote.svg rename to dist/v-1454071457968/svg/promote.svg diff --git a/dist/v-1454069705160/svg/recruit.svg b/dist/v-1454071457968/svg/recruit.svg similarity index 100% rename from dist/v-1454069705160/svg/recruit.svg rename to dist/v-1454071457968/svg/recruit.svg diff --git a/dist/v-1454069705160/svg/remove.svg b/dist/v-1454071457968/svg/remove.svg similarity index 100% rename from dist/v-1454069705160/svg/remove.svg rename to dist/v-1454071457968/svg/remove.svg diff --git a/dist/v-1454069705160/svg/search.svg b/dist/v-1454071457968/svg/search.svg similarity index 100% rename from dist/v-1454069705160/svg/search.svg rename to dist/v-1454071457968/svg/search.svg diff --git a/dist/v-1454069705160/svg/spinner-circle.svg b/dist/v-1454071457968/svg/spinner-circle.svg similarity index 100% rename from dist/v-1454069705160/svg/spinner-circle.svg rename to dist/v-1454071457968/svg/spinner-circle.svg diff --git a/dist/v-1454069705160/svg/spinner.svg b/dist/v-1454071457968/svg/spinner.svg similarity index 100% rename from dist/v-1454069705160/svg/spinner.svg rename to dist/v-1454071457968/svg/spinner.svg diff --git a/dist/v-1454069705160/svg/team-requirement.svg b/dist/v-1454071457968/svg/team-requirement.svg similarity index 100% rename from dist/v-1454069705160/svg/team-requirement.svg rename to dist/v-1454071457968/svg/team-requirement.svg diff --git a/dist/v-1454069705160/svg/team.svg b/dist/v-1454071457968/svg/team.svg similarity index 100% rename from dist/v-1454069705160/svg/team.svg rename to dist/v-1454071457968/svg/team.svg diff --git a/dist/v-1454069705160/svg/timeline.svg b/dist/v-1454071457968/svg/timeline.svg similarity index 100% rename from dist/v-1454069705160/svg/timeline.svg rename to dist/v-1454071457968/svg/timeline.svg diff --git a/dist/v-1454069705160/svg/trash.svg b/dist/v-1454071457968/svg/trash.svg similarity index 100% rename from dist/v-1454069705160/svg/trash.svg rename to dist/v-1454071457968/svg/trash.svg diff --git a/dist/v-1454069705160/svg/unlock.svg b/dist/v-1454071457968/svg/unlock.svg similarity index 100% rename from dist/v-1454069705160/svg/unlock.svg rename to dist/v-1454071457968/svg/unlock.svg diff --git a/dist/v-1454069705160/svg/unwatch.svg b/dist/v-1454071457968/svg/unwatch.svg similarity index 100% rename from dist/v-1454069705160/svg/unwatch.svg rename to dist/v-1454071457968/svg/unwatch.svg diff --git a/dist/v-1454069705160/svg/upvote.svg b/dist/v-1454071457968/svg/upvote.svg similarity index 100% rename from dist/v-1454069705160/svg/upvote.svg rename to dist/v-1454071457968/svg/upvote.svg diff --git a/dist/v-1454069705160/svg/watch.svg b/dist/v-1454071457968/svg/watch.svg similarity index 100% rename from dist/v-1454069705160/svg/watch.svg rename to dist/v-1454071457968/svg/watch.svg