Show the creator as the owner if no owner present

This commit is contained in:
James Allen 2018-01-23 13:47:48 +00:00
parent 08593f1f4b
commit d7706f642b
2 changed files with 17 additions and 9 deletions

View file

@ -395,19 +395,27 @@ module.exports = ProjectController =
return model return model
_buildV1ProjectViewModel: (project) -> _buildV1ProjectViewModel: (project) ->
{ projectViewModel = {
id: project.id id: project.id
name: project.title name: project.title
lastUpdated: new Date(project.updated_at * 1000) # Convert from epoch lastUpdated: new Date(project.updated_at * 1000) # Convert from epoch
accessLevel: if project.owner?.user_is_owner then "owner" else "readOnly"
archived: project.removed || project.archived archived: project.removed || project.archived
owner: {
# Unlisted V1 projects don't have an owner, so just show N/A
first_name: if project.owner then project.owner.name else 'N/A'
last_name: ''
}
isV1Project: true isV1Project: true
} }
if (project.owner? and project.owner.user_is_owner) or (project.creator? and project.creator.user_is_creator)
projectViewModel.accessLevel = "owner"
else
projectViewModel.accessLevel = "readOnly"
if project.owner?
projectViewModel.owner = {
first_name: project.owner.name
}
else if project.creator?
projectViewModel.owner = {
first_name: project.creator.name
}
return projectViewModel
_injectProjectOwners: (projects, callback = (error, projects) ->) -> _injectProjectOwners: (projects, callback = (error, projects) ->) ->
users = {} users = {}

View file

@ -480,9 +480,9 @@ define [
if $scope.project.accessLevel == "owner" if $scope.project.accessLevel == "owner"
return "You" return "You"
else if $scope.project.owner? else if $scope.project.owner?
return "#{$scope.project.owner.first_name} #{$scope.project.owner.last_name}" return [$scope.project.owner.first_name, $scope.project.owner.last_name].filter((n) -> n?).join(" ")
else else
return "?" return "None"
$scope.$watch "project.selected", (value) -> $scope.$watch "project.selected", (value) ->
if value? if value?