Skip to content

Commit d468202

Browse files
committed
fix user images with followers/stories
1 parent 5447f53 commit d468202

File tree

5 files changed

+51
-15
lines changed

5 files changed

+51
-15
lines changed

css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ img.profile-img-sm {
4949
max-height: 24px;
5050
}
5151

52+
img.profile-img-xs {
53+
max-height: 14px;
54+
max-width: 14px;
55+
}
56+
5257
/* fonts */
5358
.font-size-12{
5459
font-size: 12px;

js/AsanaService.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,7 @@ asanaModule.service("AsanaGateway", ["$http", "AsanaConstants", "$q", "$filter",
1717
options.query = {opt_fields: "name,email,photo"};
1818

1919
return AsanaGateway.api(options).then(function (response) {
20-
response.forEach(function (user) {
21-
if(user.photo == null){
22-
user.photo = {
23-
"image_21x21": "../img/nopicture.png",
24-
"image_27x27": "../img/nopicture.png",
25-
"image_36x36": "../img/nopicture.png",
26-
"image_60x60": "../img/nopicture.png",
27-
"image_128x128": "../img/nopicture.png",
28-
"image_1024x1024": "../img/nopicture.png"
29-
};
30-
}
31-
});
20+
AsanaConstants.setDefaultPicture(response);
3221
return response;
3322
});
3423
};
@@ -99,6 +88,9 @@ asanaModule.service("AsanaGateway", ["$http", "AsanaConstants", "$q", "$filter",
9988
var now = new Date().getTime(); // current time since epoch seconds
10089
return AsanaGateway.api(options).then(function (response) {
10190
response.forEach(function (element) {
91+
if(element.assignee != null){
92+
AsanaConstants.setDefaultPictureUser(element.assignee);
93+
}
10294
if(element.due_at !== null){
10395
element.due = Date.parse(element.due_at);
10496
element.schedule = $filter('date')(new Date(element.due), 'MMM d hh:mm a');
@@ -123,7 +115,11 @@ asanaModule.service("AsanaGateway", ["$http", "AsanaConstants", "$q", "$filter",
123115
options.query = {
124116
opt_fields: "assignee.name,assignee.photo,assignee_status,completed,completed_at,created_at,due_at,due_on,followers.name,hearted,hearts,memberships,modified_at,name,notes,num_hearts,projects.name,tags.name,workspace.name"
125117
};
126-
return AsanaGateway.api(options);
118+
return AsanaGateway.api(options).then(function (task) {
119+
AsanaConstants.setDefaultPictureUser(task.assignee);
120+
AsanaConstants.setDefaultPicture(task.followers);
121+
return task;
122+
});
127123
};
128124

129125
AsanaGateway.taskDone = function (options) {
@@ -142,7 +138,12 @@ asanaModule.service("AsanaGateway", ["$http", "AsanaConstants", "$q", "$filter",
142138
opt_fields: "type,text,created_at,created_by.name,created_by.email,created_by.photo.image_36x36"
143139
};
144140

145-
return AsanaGateway.api(options);
141+
return AsanaGateway.api(options).then(function (stories) {
142+
stories.forEach(function (story) {
143+
AsanaConstants.setDefaultPictureUser(story.created_by);
144+
});
145+
return stories;
146+
});
146147
};
147148

148149
AsanaGateway.addComment = function (options) {

js/constants.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ asanaModule.value("AsanaConstants", (function () {
5656
},
5757
setProjectOptional: function (value) {
5858
localStorage[this.PROJECT_OPTIONAL] = value;
59+
},
60+
61+
setDefaultPictureUser: function (user) {
62+
if(user.photo == null){
63+
user.photo = {
64+
"image_21x21": "../img/nopicture.png",
65+
"image_27x27": "../img/nopicture.png",
66+
"image_36x36": "../img/nopicture.png",
67+
"image_60x60": "../img/nopicture.png",
68+
"image_128x128": "../img/nopicture.png",
69+
"image_1024x1024": "../img/nopicture.png"
70+
};
71+
}
72+
},
73+
74+
setDefaultPicture: function (users) {
75+
users.forEach(function (user) {
76+
if(user.photo == null){
77+
user.photo = {
78+
"image_21x21": "../img/nopicture.png",
79+
"image_27x27": "../img/nopicture.png",
80+
"image_36x36": "../img/nopicture.png",
81+
"image_60x60": "../img/nopicture.png",
82+
"image_128x128": "../img/nopicture.png",
83+
"image_1024x1024": "../img/nopicture.png"
84+
};
85+
}
86+
});
5987
}
6088
};
6189
})());

pages/createTask.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<ui-select multiple data-ng-model="createTaskCtrl.selectedFollowers.list"
7171
data-ng-disabled="createTaskCtrl.workspaceNotSelected">
7272
<ui-select-match placeholder="Select Follower(s)" style="padding-left: 5px;">
73+
<img class="img-circle profile-img profile-img-xs" data-ng-src="{{$item.photo.image_36x36}}" data-ng-attr-title="{{$item.name}}">
7374
<span data-ng-bind="$item.name | nameInitials" data-ng-attr-title="{{$item.name}}"></span>
7475
</ui-select-match>
7576
<ui-select-choices repeat="follower in createTaskCtrl.users | orderBy:'name' | propertyFilter: {name: $select.search, email: $select.search}">

pages/tasks.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@
162162
data-ng-disabled="tasksCtrl.workspaceNotSelected" on-select="tasksCtrl.onFollowerAdd($item, $model)"
163163
on-remove="tasksCtrl.onFollowerRemove($item, $model)">
164164
<ui-select-match placeholder="Select Follower(s)" style="padding-left: 5px;">
165-
<span data-ng-bind="$item.name | nameInitials" title="{{$item.name}}"></span>
165+
<img class="img-circle profile-img profile-img-xs" data-ng-src="{{$item.photo.image_36x36}}" data-ng-attr-title="{{$item.name}}">
166+
<span data-ng-bind="$item.name | nameInitials" data-ng-attr-title="{{$item.name}}"></span>
166167
</ui-select-match>
167168
<ui-select-choices repeat="follower in tasksCtrl.users | orderBy:'name' | propertyFilter: {name: $select.search, email: $select.search}">
168169
<div class="overflow-ellipsis">

0 commit comments

Comments
 (0)