empty profile tabs

stable
Juanfran 2015-06-02 12:35:00 +02:00
parent 936979ba98
commit 97300c6ce9
15 changed files with 110 additions and 34 deletions

View File

@ -542,7 +542,11 @@
"ACTIVITY_TAB": "Activity Tab", "ACTIVITY_TAB": "Activity Tab",
"PROJECTS_TAB": "Projects Tab", "PROJECTS_TAB": "Projects Tab",
"CONTACTS_TAB": "Contacts Tab", "CONTACTS_TAB": "Contacts Tab",
"FAVORITES_TAB": "Favorites Tab" "FAVORITES_TAB": "Favorites Tab",
"CONTACTS_EMPTY": "{{username}} doesn't have contacts yet",
"CURRENT_USER_CONTACTS_EMPTY": "You don't have contacts yet",
"CURRENT_USER_CONTACTS_EMPTY_EXPLAIN": "The people with whom you work at Taiga will be your contacts automatically",
"PROJECTS_EMPTY": "{{username}} doesn't' have projects yet"
}, },
"PROFILE_SIDEBAR": { "PROFILE_SIDEBAR": {
"TITLE": "Your profile", "TITLE": "Your profile",

View File

@ -1,12 +1,20 @@
class ProfileContactsController class ProfileContactsController
@.$inject = [ @.$inject = [
"tgUserService" "tgUserService",
"tgCurrentUserService"
] ]
constructor: (@userService) -> constructor: (@userService, @currentUserService) ->
loadContacts: () -> loadContacts: () ->
@userService.getContacts(@.userId) @.currentUser = @currentUserService.getUser()
@.isCurrentUser = false
if @.currentUser.get("id") == @.user.get("id")
@.isCurrentUser = true
@userService.getContacts(@.user.get("id"))
.then (contacts) => .then (contacts) =>
@.contacts = contacts @.contacts = contacts

View File

@ -11,10 +11,18 @@ describe "ProfileContacts", ->
provide.value "tgUserService", mocks.userServices provide.value "tgUserService", mocks.userServices
_mockCurrentUserService = () ->
mocks.currentUserService = {
getUser: sinon.stub()
}
provide.value "tgCurrentUserService", mocks.currentUserService
_mocks = () -> _mocks = () ->
module ($provide) -> module ($provide) ->
provide = $provide provide = $provide
_mockUserService() _mockUserService()
_mockCurrentUserService()
return null return null
@ -28,22 +36,51 @@ describe "ProfileContacts", ->
_mocks() _mocks()
_inject() _inject()
it "load projects with contacts attached", (done) -> it "load current user contacts", (done) ->
userId = 2 user = Immutable.fromJS({id: 2})
contacts = [ contacts = [
{id: 1}, {id: 1},
{id: 2}, {id: 2},
{id: 3} {id: 3}
] ]
mocks.userServices.getContacts.withArgs(userId).promise().resolve(contacts) mocks.currentUserService.getUser.returns(user)
mocks.userServices.getContacts.withArgs(user.get("id")).promise().resolve(contacts)
$scope = $rootScope.$new() $scope = $rootScope.$new()
ctrl = $controller("ProfileContacts", $scope, { ctrl = $controller("ProfileContacts", $scope, {
userId: userId user: user
}) })
ctrl.loadContacts().then () -> ctrl.loadContacts().then () ->
expect(ctrl.contacts).to.be.equal(contacts) expect(ctrl.contacts).to.be.equal(contacts)
expect(ctrl.isCurrentUser).to.be.true
done()
it "load user contacts", (done) ->
user = Immutable.fromJS({id: 2})
user2 = Immutable.fromJS({id: 3})
contacts = [
{id: 1},
{id: 2},
{id: 3}
]
mocks.currentUserService.getUser.returns(user2)
mocks.userServices.getContacts.withArgs(user.get("id")).promise().resolve(contacts)
$scope = $rootScope.$new()
ctrl = $controller("ProfileContacts", $scope, {
user: user
})
ctrl.loadContacts().then () ->
expect(ctrl.contacts).to.be.equal(contacts)
expect(ctrl.isCurrentUser).to.be.false
done() done()

View File

@ -5,7 +5,7 @@ ProfileContactsDirective = () ->
return { return {
templateUrl: "profile/profile-contacts/profile-contacts.html", templateUrl: "profile/profile-contacts/profile-contacts.html",
scope: { scope: {
userId: "=userid" user: "="
}, },
controllerAs: "vm", controllerAs: "vm",
controller: "ProfileContacts", controller: "ProfileContacts",

View File

@ -1,7 +1,17 @@
section.profile-contacts section.profile-contacts
div(ng-if="!vm.contacts.size") div(ng-if="vm.contacts === undefined")
div.spin div.spin
img(src="/svg/spinner-circle.svg", alt="Loading...") img(src="/svg/spinner-circle.svg", alt="Loading...")
div.empty-tab(ng-if="vm.contacts && !vm.contacts.size")
include ../../../svg/hide.svg
div(ng-if="!vm.isCurrentUser")
p(translate="USER.PROFILE.CONTACTS_EMPTY", translate-values="{username: vm.user.get('full_name_display')}")
div(ng-if="vm.isCurrentUser")
p(translate="USER.PROFILE.CURRENT_USER_CONTACTS_EMPTY")
p(translate="USER.PROFILE.CURRENT_USER_CONTACTS_EMPTY_EXPLAIN")
// nav.profile-contact-filters // nav.profile-contact-filters
// a.active(href="", title="No Filter") all // a.active(href="", title="No Filter") all
// a(href="", title="Only show your team") team // a(href="", title="Only show your team") team

View File

@ -7,9 +7,9 @@ class ProfileProjectsController
constructor: (@projectsService, @userService) -> constructor: (@projectsService, @userService) ->
loadProjects: () -> loadProjects: () ->
@projectsService.getProjectsByUserId(@.userId) @projectsService.getProjectsByUserId(@.user.get("id"))
.then (projects) => .then (projects) =>
return @userService.attachUserContactsToProjects(@.userId, projects) return @userService.attachUserContactsToProjects(@.user.get("id"), projects)
.then (projects) => .then (projects) =>
@.projects = projects @.projects = projects

View File

@ -47,7 +47,7 @@ describe "ProfileProjects", ->
_inject() _inject()
it "load projects with contacts attached", (done) -> it "load projects with contacts attached", (done) ->
userId = 2 user = Immutable.fromJS({id: 2})
projects = [ projects = [
{id: 1}, {id: 1},
{id: 2}, {id: 2},
@ -60,13 +60,13 @@ describe "ProfileProjects", ->
{id: 3, contacts: "fake"} {id: 3, contacts: "fake"}
] ]
mocks.projectsService.getProjectsByUserId.withArgs(userId).promise().resolve(projects) mocks.projectsService.getProjectsByUserId.withArgs(user.get("id")).promise().resolve(projects)
mocks.userService.attachUserContactsToProjects.withArgs(userId, projects).returns(projectsWithContacts) mocks.userService.attachUserContactsToProjects.withArgs(user.get("id"), projects).returns(projectsWithContacts)
$scope = $rootScope.$new() $scope = $rootScope.$new()
ctrl = $controller("ProfileProjects", $scope, { ctrl = $controller("ProfileProjects", $scope, {
userId: userId user: user
}) })
ctrl.loadProjects().then () -> ctrl.loadProjects().then () ->

View File

@ -5,7 +5,7 @@ ProfileProjectsDirective = () ->
return { return {
templateUrl: "profile/profile-projects/profile-projects.html", templateUrl: "profile/profile-projects/profile-projects.html",
scope: { scope: {
userId: "=userid" user: "="
}, },
link: link link: link
bindToController: true, bindToController: true,

View File

@ -1,8 +1,13 @@
section.profile-projects section.profile-projects
div(ng-if="!vm.projects.size") div(ng-if="vm.projects === undefined")
div.spin div.spin
img(src="/svg/spinner-circle.svg", alt="Loading...") img(src="/svg/spinner-circle.svg", alt="Loading...")
div.empty-tab(ng-if="vm.projects && !vm.projects.size")
include ../../../svg/hide.svg
p(translate="USER.PROFILE.PROJECTS_EMPTY", translate-values="{username: vm.user.get('full_name_display')}")
div.project-list-single(tg-repeat="project in vm.projects") div.project-list-single(tg-repeat="project in vm.projects")
div.project-list-single-left div.project-list-single-left

View File

@ -4,13 +4,13 @@ div.profile.centered(ng-if="vm.user")
div.main div.main
div.timeline-wrapper(tg-profile-tabs) div.timeline-wrapper(tg-profile-tabs)
div(tg-profile-tab="activity", tab-title="{{'USER.PROFILE.ACTIVITY_TAB' | translate}}", 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-user-timeline, userId="vm.user.get('id')") div(tg-user-timeline, user="vm.user")
div(tab-disabled="{{vm.isCurrentUser}}", tg-profile-tab="projects", tab-title="{{'USER.PROFILE.PROJECTS_TAB' | translate}}", tab-icon="icon-project") div(tab-disabled="{{vm.isCurrentUser}}", tg-profile-tab="projects", tab-title="{{'USER.PROFILE.PROJECTS_TAB' | translate}}", tab-icon="icon-project")
div(tg-profile-projects, userId="vm.user.get('id')") div(tg-profile-projects, user="vm.user")
div(tg-profile-tab="contacts", tab-title="{{'USER.PROFILE.CONTACTS_TAB' | translate}}", tab-icon="icon-team") div(tg-profile-tab="contacts", tab-title="{{'USER.PROFILE.CONTACTS_TAB' | translate}}", tab-icon="icon-team")
div(tg-profile-contacts, userId="vm.user.get('id')") div(tg-profile-contacts, user="vm.user")
// div(tg-profile-tab="favorites", tab-title="{{'USER.PROFILE.FAVORITES_TAB' | translate}}", tab-icon="icon-star-fill") // div(tg-profile-tab="favorites", tab-title="{{'USER.PROFILE.FAVORITES_TAB' | translate}}", tab-icon="icon-star-fill")
// include includes/profile-favorites // include includes/profile-favorites

View File

@ -40,4 +40,16 @@
flex-shrink: 0; flex-shrink: 0;
width: 150px; width: 150px;
} }
.empty-tab {
padding: 5vh;
text-align: center;
svg {
margin: 2rem auto;
max-width: 160px;
text-align: center;
}
p {
font-size: .9rem;
}
}
} }

View File

@ -14,7 +14,7 @@ div.wrapper
div.project-data div.project-data
section.timeline(ng-if="vm.project") section.timeline(ng-if="vm.project")
div(tg-user-timeline, projectId="vm.project.get('id')", userId="vm.user.get('id')") div(tg-user-timeline, projectId="vm.project.get('id')")
section.involved-data section.involved-data
h2.title {{"PROJECT.SECTION.TEAM" | translate}} h2.title {{"PROJECT.SECTION.TEAM" | translate}}
ul.involved-team ul.involved-team

View File

@ -43,7 +43,7 @@ class UserTimelineController extends mixOf(taiga.Controller, taiga.PageMixin, ta
@._timelineLoaded(newTimelineList) @._timelineLoaded(newTimelineList)
else else
@userTimelineService @userTimelineService
.getTimeline(@.userId, @.page) .getTimeline(@.user.get("id"), @.page)
.then (newTimelineList) => .then (newTimelineList) =>
@._timelineLoaded(newTimelineList) @._timelineLoaded(newTimelineList)

View File

@ -3,7 +3,7 @@ describe "UserTimelineController", ->
mocks = {} mocks = {}
mockUser = {id: 3} mockUser = Immutable.fromJS({id: 3})
_mockUserTimeline = () -> _mockUserTimeline = () ->
mocks.userTimelineService = { mocks.userTimelineService = {
@ -49,12 +49,12 @@ describe "UserTimelineController", ->
it "the scrollDisabled variable must be true during the timeline load", () -> it "the scrollDisabled variable must be true during the timeline load", () ->
myCtrl = controller "UserTimeline" myCtrl = controller "UserTimeline"
myCtrl.userId = mockUser.id myCtrl.user = mockUser
thenStub = sinon.stub() thenStub = sinon.stub()
mocks.userTimelineService.getTimeline = sinon.stub() mocks.userTimelineService.getTimeline = sinon.stub()
.withArgs(mockUser.id, myCtrl.page) .withArgs(mockUser.get("id"), myCtrl.page)
.returns({ .returns({
then: thenStub then: thenStub
}) })
@ -73,12 +73,12 @@ describe "UserTimelineController", ->
emptyTimelineList = Immutable.fromJS([]) emptyTimelineList = Immutable.fromJS([])
myCtrl = controller "UserTimeline" myCtrl = controller "UserTimeline"
myCtrl.userId = mockUser.id myCtrl.user = mockUser
thenStub = sinon.stub() thenStub = sinon.stub()
mocks.userTimelineService.getTimeline = sinon.stub() mocks.userTimelineService.getTimeline = sinon.stub()
.withArgs(mockUser.id, myCtrl.page) .withArgs(mockUser.get("id"), myCtrl.page)
.returns({ .returns({
then: thenStub then: thenStub
}) })
@ -95,12 +95,12 @@ describe "UserTimelineController", ->
it "pagiantion increase one every call to loadTimeline", () -> it "pagiantion increase one every call to loadTimeline", () ->
myCtrl = controller "UserTimeline" myCtrl = controller "UserTimeline"
myCtrl.userId = mockUser.id myCtrl.user = mockUser
thenStub = sinon.stub() thenStub = sinon.stub()
mocks.userTimelineService.getTimeline = sinon.stub() mocks.userTimelineService.getTimeline = sinon.stub()
.withArgs(mockUser.id, myCtrl.page) .withArgs(mockUser.get("id"), myCtrl.page)
.returns({ .returns({
then: thenStub then: thenStub
}) })
@ -115,12 +115,12 @@ describe "UserTimelineController", ->
it "timeline items", () -> it "timeline items", () ->
myCtrl = controller "UserTimeline" myCtrl = controller "UserTimeline"
myCtrl.userId = mockUser.id myCtrl.user = mockUser
thenStub = sinon.stub() thenStub = sinon.stub()
mocks.userTimelineService.getTimeline = sinon.stub() mocks.userTimelineService.getTimeline = sinon.stub()
.withArgs(mockUser.id, myCtrl.page) .withArgs(mockUser.get("id"), myCtrl.page)
.returns({ .returns({
then: thenStub then: thenStub
}) })
@ -133,7 +133,7 @@ describe "UserTimelineController", ->
it "project timeline items", () -> it "project timeline items", () ->
myCtrl = controller "UserTimeline" myCtrl = controller "UserTimeline"
myCtrl.userId = mockUser.id myCtrl.user = mockUser
myCtrl.projectId = 4 myCtrl.projectId = 4
thenStub = sinon.stub() thenStub = sinon.stub()

View File

@ -5,7 +5,7 @@ UserTimelineDirective = ->
controllerAs: "vm", controllerAs: "vm",
scope: { scope: {
projectId: "=projectid", projectId: "=projectid",
userId: "=userid" user: "="
}, },
bindToController: true bindToController: true
} }