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",
"PROJECTS_TAB": "Projects 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": {
"TITLE": "Your profile",

View File

@ -1,12 +1,20 @@
class ProfileContactsController
@.$inject = [
"tgUserService"
"tgUserService",
"tgCurrentUserService"
]
constructor: (@userService) ->
constructor: (@userService, @currentUserService) ->
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) =>
@.contacts = contacts

View File

@ -11,10 +11,18 @@ describe "ProfileContacts", ->
provide.value "tgUserService", mocks.userServices
_mockCurrentUserService = () ->
mocks.currentUserService = {
getUser: sinon.stub()
}
provide.value "tgCurrentUserService", mocks.currentUserService
_mocks = () ->
module ($provide) ->
provide = $provide
_mockUserService()
_mockCurrentUserService()
return null
@ -28,22 +36,51 @@ describe "ProfileContacts", ->
_mocks()
_inject()
it "load projects with contacts attached", (done) ->
userId = 2
it "load current user contacts", (done) ->
user = Immutable.fromJS({id: 2})
contacts = [
{id: 1},
{id: 2},
{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()
ctrl = $controller("ProfileContacts", $scope, {
userId: userId
user: user
})
ctrl.loadContacts().then () ->
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()

View File

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

View File

@ -1,7 +1,17 @@
section.profile-contacts
div(ng-if="!vm.contacts.size")
div(ng-if="vm.contacts === undefined")
div.spin
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
// a.active(href="", title="No Filter") all
// a(href="", title="Only show your team") team

View File

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

View File

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

View File

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

View File

@ -1,8 +1,13 @@
section.profile-projects
div(ng-if="!vm.projects.size")
div(ng-if="vm.projects === undefined")
div.spin
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-left

View File

@ -4,13 +4,13 @@ div.profile.centered(ng-if="vm.user")
div.main
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-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(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-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")
// include includes/profile-favorites

View File

@ -40,4 +40,16 @@
flex-shrink: 0;
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
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
h2.title {{"PROJECT.SECTION.TEAM" | translate}}
ul.involved-team

View File

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

View File

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

View File

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