diff --git a/app/coffee/modules/team/main.coffee b/app/coffee/modules/team/main.coffee index 3f1819d8..b59db7ff 100644 --- a/app/coffee/modules/team/main.coffee +++ b/app/coffee/modules/team/main.coffee @@ -20,61 +20,174 @@ ### taiga = @.taiga + mixOf = @.taiga.mixOf -groupBy = @.taiga.groupBy module = angular.module("taigaTeam") ############################################################################# -## Task Detail Controller +## Team Controller ############################################################################# class TeamController extends mixOf(taiga.Controller, taiga.PageMixin) @.$inject = [ "$scope", - "$rootScope", "$tgRepo", - "$tgConfirm", "$tgResources", "$routeParams", "$q", - "$tgLocation", - "$log", "$appTitle", - "$tgNavUrls", - "$tgAnalytics", + "$tgAuth" "tgLoader" ] - constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, - @log, @appTitle, @navUrls, @analytics, tgLoader) -> - @scope.taskRef = @params.taskref + constructor: (@scope, @repo, @rs, @params, @q, @appTitle, @auth, tgLoader) -> @scope.sectionName = "Team" promise = @.loadInitialData() - promise.then () => - @appTitle.set(@scope.project.name + " - Team") + # On Success + promise.then => + @appTitle.set("Team - " + @scope.project.name) tgLoader.pageLoaded() + # On Error + promise.then null, @.onInitialDataError.bind(@) + + @scope.currentUser = @auth.getUser() + + setRole: (role) -> + if role + @scope.filtersRole = role + else + @scope.filtersRole = "" + + loadMembers: -> + return @rs.memberships.list(@scope.projectId).then (data) => + @scope.memberships = data.models + return data + loadProject: -> return @rs.projects.get(@scope.projectId).then (project) => @scope.project = project @scope.$emit('project:loaded', project) - @scope.statusList = project.task_statuses - @scope.statusById = groupBy(project.task_statuses, (x) -> x.id) - @scope.membersById = groupBy(project.memberships, (x) -> x.user) + return project loadInitialData: -> - params = { - pslug: @params.pslug - } - - promise = @repo.resolve(params).then (data) => + promise = @repo.resolve({pslug: @params.pslug}).then (data) => @scope.projectId = data.project return data return promise.then(=> @.loadProject()) + .then(=> @.loadUsersAndRoles()) + .then(=> @.loadMembers()) module.controller("TeamController", TeamController) + +############################################################################# +## Team Filters Directive +############################################################################# + +TeamFiltersDirective = () -> + template = """ + + """ + + return { + template: template + } + +module.directive("tgTeamFilters", [TeamFiltersDirective]) + +############################################################################# +## Team Members Directive +############################################################################# + +TeamMembersDirective = () -> + template = """ +
+
+
+ +
+ + + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ 666 +
+
+ """ + return { + link: (scope) -> + if !_.isArray(scope.memberships) + scope.memberships = [scope.memberships] + + template: template + scope: { + memberships: "=", + filtersQ: "=filtersq", + filtersRole: "=filtersrole", + currentUser: "@currentuser" + } + } + +module.directive("tgTeamMembers", TeamMembersDirective) + +############################################################################# +## Leave project Directive +############################################################################# + +LeaveProjectDirective = ($repo, $confirm, $location) -> + template= """ + + Leave this project + + """ #TODO: i18n + + link = ($scope) -> + $scope.leave = () -> + $confirm.ask("Leave this project", "Are you sure you want to leave the project?")#TODO: i18n + .then (finish) => + console.log "TODO" + return { + scope: {}, + restrict: "EA", + replace: true, + template: template, + link: link + } + +module.directive("tgLeaveProject", ["$tgRepo", "$tgConfirm", "$tgLocation", LeaveProjectDirective]) diff --git a/app/partials/views/modules/team/team-filters.jade b/app/partials/views/modules/team/team-filters.jade index 6f4a93d6..27e2942e 100644 --- a/app/partials/views/modules/team/team-filters.jade +++ b/app/partials/views/modules/team/team-filters.jade @@ -5,36 +5,7 @@ section.team-filters form.search-in fieldset - input(type="text", placeholder="Search by username or role...") + input(type="text", placeholder="Search by username or role...", ng-model="filtersQ") a.icon.icon-search(href="", title="search") - nav - ul - li - a(href="", title="") - span.title Team - span.icon.icon-arrow-right - li - a(href="", title="") - span.title UX - span.icon.icon-arrow-right - li - a(href="", title="") - span.title Design - span.icon.icon-arrow-right - li - a(href="", title="") - span.title Front - span.icon.icon-arrow-right - li - a(href="", title="") - span.title Back - span.icon.icon-arrow-right - li - a(href="", title="") - span.title Product Owner - span.icon.icon-arrow-right - li - a(href="", title="") - span.title StakeHolders - span.icon.icon-arrow-right + nav(tg-team-filters) \ No newline at end of file diff --git a/app/partials/views/modules/team/team-table.jade b/app/partials/views/modules/team/team-table.jade index 6d34a323..9566b943 100644 --- a/app/partials/views/modules/team/team-table.jade +++ b/app/partials/views/modules/team/team-table.jade @@ -25,48 +25,11 @@ section.table-team.basic-table Total Power div.popover.attribute-explanation span How far did you go into this Taiga? - div.row.hero - div.username - figure.avatar - img(src="https://s3.amazonaws.com/uifaces/faces/twitter/bermonpainter/128.jpg", alt="username") - figcaption - span.name Xavier Julián Olmos - span.position The Fucking Master - div.attribute - span.icon.icon-github(style="opacity: .3;") - div.attribute - span.icon.icon-github(style="opacity: .1;") - div.attribute - span.icon.icon-github(style="opacity: .3;") - div.attribute - span.icon.icon-github(style="opacity: .1;") - div.attribute - span.icon.icon-github.top - div.attribute - span.points 666 + + div.hero(tg-team-members, memberships="currentUser" currentuser=true) h2 span Team > - span All + span {{filtersRole.name || "All"}} -section.table-team.basic-table - - for (var x = 0; x < 10; x++) - div.row - div.username - figure.avatar - img(src="https://s3.amazonaws.com/uifaces/faces/twitter/jackiesaik/128.jpg", alt="username") - figcaption - span.name Oompa Loompa - span.position Role - div.attribute - span.icon.icon-github(style="opacity: .1;") - div.attribute - span.icon.icon-github(style="opacity: .2;") - div.attribute - span.icon.icon-github(style="opacity: .3;") - div.attribute - span.icon.icon-github(style="opacity: .3;") - div.attribute - span.icon.icon-github(style="opacity: .1;") - div.attribute - span.points 666 +section.table-team.basic-table(tg-team-members, memberships="memberships", filtersq="filtersQ", filtersrole="filtersRole") diff --git a/app/styles/modules/team/team-filters.scss b/app/styles/modules/team/team-filters.scss index e0adda09..3b09364a 100644 --- a/app/styles/modules/team/team-filters.scss +++ b/app/styles/modules/team/team-filters.scss @@ -16,7 +16,10 @@ a { display: block; padding: 1rem 0 1rem 1rem; - &:hover { + &:hover, + &.active { + @include transition (color .3s linear); + color: $green-taiga; .icon { @include transition (opacity .3s linear); opacity: 1; diff --git a/app/styles/modules/team/team-table.scss b/app/styles/modules/team/team-table.scss index 2ad52a81..98d46076 100644 --- a/app/styles/modules/team/team-table.scss +++ b/app/styles/modules/team/team-table.scss @@ -28,15 +28,31 @@ } } } + .leave-project { + display: block; + margin-top: .3rem; + .icon { + margin-right: .2rem; + } + &:hover { + .icon { + @include transition (color .3s linear); + color: $red; + } + } + } .team-header { @extend %title; @extend %bold; border-bottom: 0; } .hero { - background: $very-light-gray; - border-bottom: 0; - margin: 1rem 0; + width: 100%; + .row { + background: $very-light-gray; + border-bottom: 0; + margin: 1rem 0; + } } .avatar { @include table-flex(stretch, center, flex, row, wrap, flex-start);