diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index 623326df..f5f6c32f 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -538,7 +538,11 @@ "PROJECTS": "Projects", "CLOSED_US": "Closed US", "CONTACTS": "Contacts", - "REPORT": "Report Abuse" + "REPORT": "Report Abuse", + "ACTIVITY_TAB": "Activity Tab", + "PROJECTS_TAB": "Projects Tab", + "CONTACTS_TAB": "Contacts Tab", + "FAVORITES_TAB": "Favorites Tab" } }, "PROJECT": { diff --git a/app/modules/profile/includes/profile-contacts.jade b/app/modules/profile/includes/profile-contacts.jade deleted file mode 100644 index e3ed4c1f..00000000 --- a/app/modules/profile/includes/profile-contacts.jade +++ /dev/null @@ -1,45 +0,0 @@ -section.profile-contacts - nav.profile-contact-filters - a.active(href="", title="No Filter") all - a(href="", title="Only show your team") team - a(href="", title="Only show people you follow") following - a(href="", title="Only show people follow you") followers - - for (var x = 0; x < 3; x++) - div.profile-contact-single - div.profile-contact-picture - a(href="", title="See {{ user.nickname }} profile") - img(src="https://s3.amazonaws.com/uifaces/faces/twitter/koridhandy/128.jpg", alt="{{ user.nickname }}") - div.profile-contact-data - h1 - a(href="", title="See {{ user.nickname}} profile") Sebastián Molina - span.your-contact Your contact - p Chief GIF Officer at myamazingpage.com. Tweet me at @sebas - div.extra-info - span.position Back-end developer & Stakeholder - span.location Madrid - div.profile-project-stats - div.stat-projects(title="2 projects") - span.icon.icon-project - span.stat-num 2 - div.stat-viewer(title="2 followers") - span.icon.icon-open-eye - span.stat-num 4 - - div.profile-contact-single - div.profile-contact-picture - a(href="", title="See {{ user.nickname }} profile") - img(src="https://s3.amazonaws.com/uifaces/faces/twitter/marktimemedia/128.jpg", alt="{{ user.nickname }}") - div.profile-contact-data - h1 - a(href="", title="See {{ user.nickname}} profile") Ane Moreno - p Have some experience working with sock monkeys in Orlando, FL. Crossed the country licensing bongos in Miami, FL. What gets me going now is deploying catfish in Bethesda, MD. Prior to my current job I was selling dandruff in Minneapolis, MN. In 2009 I was marketing Elvis Presley in Hanford, CA. - div.extra-info - span.position Monkey Socker & Deployer - span.location Miami - div.profile-project-stats - div.stat-comments(title="2 comments") - span.icon.icon-project - span.stat-num 2 - div.stat-viewer(title="2 followers") - span.icon.icon-open-eye - span.stat-num 4 diff --git a/app/modules/profile/profile-contacts/profile-contacts.controller.coffee b/app/modules/profile/profile-contacts/profile-contacts.controller.coffee new file mode 100644 index 00000000..e2d0e463 --- /dev/null +++ b/app/modules/profile/profile-contacts/profile-contacts.controller.coffee @@ -0,0 +1,17 @@ +class ProfileContactsController + @.$inject = [ + "tgUserService", + "$tgAuth" + ] + + constructor: (@userService, @auth) -> + + loadContacts: () -> + userId = @auth.getUser().id + + @userService.getUserContacts(userId) + .then (contacts) => + @.contacts = contacts + +angular.module("taigaProfile") + .controller("ProfileContacts", ProfileContactsController) diff --git a/app/modules/profile/profile-contacts/profile-contacts.controller.spec.coffee b/app/modules/profile/profile-contacts/profile-contacts.controller.spec.coffee new file mode 100644 index 00000000..4bfd467d --- /dev/null +++ b/app/modules/profile/profile-contacts/profile-contacts.controller.spec.coffee @@ -0,0 +1,63 @@ +describe "ProfileContacts", -> + $controller = null + $q = null + provide = null + $rootScope = null + mocks = {} + + _mockUserService = () -> + mocks.userService = { + getUserContacts: sinon.stub() + } + + provide.value "tgUserService", mocks.userService + + _mockAuthService = () -> + stub = sinon.stub() + + stub.returns({id: 2}) + + provide.value "$tgAuth", { + getUser: stub + } + + _mocks = () -> + module ($provide) -> + provide = $provide + _mockUserService() + _mockAuthService() + + return null + + _inject = (callback) -> + inject (_$controller_, _$q_, _$rootScope_) -> + $q = _$q_ + $rootScope = _$rootScope_ + $controller = _$controller_ + + beforeEach -> + module "taigaProfile" + _mocks() + _inject() + + it "load projects with contacts attached", (done) -> + userId = 2 + contacts = [ + {id: 1}, + {id: 2}, + {id: 3} + ] + + mocks.userService.getUserContacts = (userId) -> + expect(userId).to.be.equal(userId) + + return $q (resolve, reject) -> + resolve(contacts) + + ctrl = $controller("ProfileContacts") + + ctrl.loadContacts().then () -> + expect(ctrl.contacts).to.be.equal(contacts) + done() + + $rootScope.$apply() diff --git a/app/modules/profile/profile-contacts/profile-contacts.directive.coffee b/app/modules/profile/profile-contacts/profile-contacts.directive.coffee new file mode 100644 index 00000000..70e2dd4d --- /dev/null +++ b/app/modules/profile/profile-contacts/profile-contacts.directive.coffee @@ -0,0 +1,13 @@ +ProfileContactsDirective = () -> + link = (scope, elm, attrs, ctrl) -> + ctrl.loadContacts() + + return { + templateUrl: "profile/profile-contacts/profile-contacts.html", + scope: {}, + controllerAs: "vm", + controller: "ProfileContacts", + link: link + } + +angular.module("taigaProfile").directive("tgProfileContacts", ProfileContactsDirective) diff --git a/app/modules/profile/profile-contacts/profile-contacts.jade b/app/modules/profile/profile-contacts/profile-contacts.jade new file mode 100644 index 00000000..e81fef75 --- /dev/null +++ b/app/modules/profile/profile-contacts/profile-contacts.jade @@ -0,0 +1,30 @@ +section.profile-contacts + // nav.profile-contact-filters + // a.active(href="", title="No Filter") all + // a(href="", title="Only show your team") team + // a(href="", title="Only show people you follow") following + // a(href="", title="Only show people follow you") followers + + div.profile-contact-single(tg-repeat="contact in ::vm.contacts") + div.profile-contact-picture + a(tg-nav="user-profile:username=contact.username", title="{{::contact.name }}") + img(ng-src='{{::contact.photo}}', alt='{{::contact.full_name}}') + + div.profile-contact-data + h1 + a(tg-nav="user-profile:username=contact.username", title="{{::contact.name }}") + | {{::contact.full_name}} + // span.your-contact Your contact + + p(ng-if="contact.bio") {{::contact.bio}} + + div.extra-info + span.position {{::contact.roles.join(", ")}} + // span.location todo + // div.profile-project-stats + // div.stat-projects(title="2 projects") + // span.icon.icon-project + // span.stat-num 2 + // div.stat-viewer(title="2 followers") + // span.icon.icon-open-eye + // span.stat-num 4 diff --git a/app/modules/profile/profile-tab/profile-tab.directive.coffee b/app/modules/profile/profile-tab/profile-tab.directive.coffee index ca6f3e59..50625f32 100644 --- a/app/modules/profile/profile-tab/profile-tab.directive.coffee +++ b/app/modules/profile/profile-tab/profile-tab.directive.coffee @@ -2,8 +2,10 @@ ProfileTabDirective = () -> link = (scope, element, attrs, ctrl, transclude) -> scope.tab = {} + attrs.$observe "tabTitle", (title) -> + scope.tab.title = title + scope.tab.name = attrs.tgProfileTab - scope.tab.title = attrs.tabTitle scope.tab.icon = attrs.tabIcon scope.tab.active = !!attrs.tabActive diff --git a/app/modules/profile/profile-tabs/profile-tabs.jade b/app/modules/profile/profile-tabs/profile-tabs.jade index beb2d776..00390cd8 100644 --- a/app/modules/profile/profile-tabs/profile-tabs.jade +++ b/app/modules/profile/profile-tabs/profile-tabs.jade @@ -1,6 +1,6 @@ div nav.profile-content-tabs - a.tab(ng-repeat="tab in ::vm.tabs", href="", title="{{::tab.title}}", ng-class="{active: tab.active}" ng-click="vm.toggleTab(tab)") + a.tab(ng-repeat="tab in ::vm.tabs", href="", title="{{tab.title}}", ng-class="{active: tab.active}" ng-click="vm.toggleTab(tab)") span.icon(ng-class="::tab.icon") span {{::tab.name}} diff --git a/app/modules/profile/profile.jade b/app/modules/profile/profile.jade index 8ce0ba20..f7a6bd2e 100644 --- a/app/modules/profile/profile.jade +++ b/app/modules/profile/profile.jade @@ -3,16 +3,16 @@ div.profile.centered include includes/profile-bar div.main div.timeline-wrapper(tg-profile-tabs) - div(tg-profile-tab="activity", tab-title="Activity Tab", tab-icon="icon-timeline", tab-active) + div(tg-profile-tab="activity", tab-title="{{'USER.PROFILE.ACTIVITY_TAB' | translate}}", tab-icon="icon-timeline", tab-active) div(tg-profile-timeline) - div(tg-profile-tab="projects", tab-title="Projects Tab", tab-icon="icon-project") + div(tg-profile-tab="projects", tab-title="{{'USER.PROFILE.PROJECTS_TAB' | translate}}", tab-icon="icon-project") div(tg-profile-projects) - div(tg-profile-tab="contacts", tab-title="Contacts Tab", tab-icon="icon-team") - include includes/profile-contacts + div(tg-profile-tab="contacts", tab-title="{{'USER.PROFILE.CONTACTS_TAB' | translate}}", tab-icon="icon-team") + div(tg-profile-contacts) - div(tg-profile-tab="favorites", tab-title="Favorites Tab", tab-icon="icon-star-fill") - include includes/profile-favorites + // div(tg-profile-tab="favorites", tab-title="{{'USER.PROFILE.FAVORITES_TAB' | translate}}", tab-icon="icon-star-fill") + // include includes/profile-favorites include includes/profile-sidebar diff --git a/app/modules/services/user.service.coffee b/app/modules/services/user.service.coffee index ab1bc0f4..743649e2 100644 --- a/app/modules/services/user.service.coffee +++ b/app/modules/services/user.service.coffee @@ -10,8 +10,7 @@ class UserService extends taiga.Service .then (projects) -> return Immutable.fromJS(projects) attachUserContactsToProjects: (userId, projects) -> - return @rs.users.contacts(userId) - .then (contacts) -> return Immutable.fromJS(contacts) + return @.getUserContacts(userId) .then (contacts) -> projects = projects.map (project) -> project.contacts = contacts.filter (contact) -> @@ -22,4 +21,8 @@ class UserService extends taiga.Service return projects + getUserContacts: (userId) -> + return @rs.users.contacts(userId) + .then (contacts) -> return Immutable.fromJS(contacts) + angular.module("taigaCommon").service("tgUserService", UserService) diff --git a/app/modules/services/user.service.spec.coffee b/app/modules/services/user.service.spec.coffee index e7c671ae..ec16ce41 100644 --- a/app/modules/services/user.service.spec.coffee +++ b/app/modules/services/user.service.spec.coffee @@ -91,3 +91,24 @@ describe.skip "UserService", -> done() $rootScope.$apply() + + it "get user contacts", (done) -> + userId = 2 + + contacts = [ + {id: 1}, + {id: 2}, + {id: 3} + ] + + mocks.resources.user.contacts = (userId) -> + expect(userId).to.be.equal(userId) + + return $q (resolve, reject) -> + resolve(contacts) + + userService.getUserContacts(userId).then (_contacts_) -> + expect(_contacts_.toJS()).to.be.eql(contacts) + done() + + $rootScope.$apply()