#214: Fixed: Cannot read property from_ref of null
This commit is contained in:
parent
e3cd73ddaf
commit
aadb77cf56
|
@ -30,14 +30,18 @@ RosaABF.controller('PullRequestController',['$scope', '$http', 'ApiPullRequest',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.getBranch = function() {
|
// @param [from_ref] - sets only at first time
|
||||||
|
$scope.getBranch = function(from_ref) {
|
||||||
if (!$scope.project_resource) {
|
if (!$scope.project_resource) {
|
||||||
$scope.project_resource = ApiProject.resource.get({id: $scope.project_id});
|
$scope.project_resource = ApiProject.resource.get({id: $scope.project_id});
|
||||||
}
|
}
|
||||||
|
// Fix: at first load
|
||||||
|
// Cannot read property 'from_ref' of null
|
||||||
|
if (!from_ref) { from_ref = $scope.pull.from_ref.ref; }
|
||||||
$scope.project_resource.$refs({id: $scope.project_id}, function(results) {
|
$scope.project_resource.$refs({id: $scope.project_id}, function(results) {
|
||||||
_.each(results.refs_list, function(ref){
|
_.each(results.refs_list, function(ref){
|
||||||
var result = new ProjectRef(ref);
|
var result = new ProjectRef(ref);
|
||||||
if (!result.isTag && result.ref == $scope.pull.from_ref.ref) {
|
if (!result.isTag && result.ref == from_ref) {
|
||||||
$scope.branch = result;
|
$scope.branch = result;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
- if !@pull.cross_pull? && can?(:write, @project)
|
- if !@pull.cross_pull? && can?(:write, @project)
|
||||||
%div{'ng-init' => 'getBranch()', 'ng-show' => "pull.status == 'closed' || pull.status == 'merged'"}
|
%div{'ng-init' => "getBranch('#{@pull.from_ref}')", 'ng-show' => "pull.status == 'closed' || pull.status == 'merged'"}
|
||||||
%a.button{:href => '', 'ng-click' => 'deleteBranch()', 'ng-show' => "branch && branch.object.sha == pull.from_ref.sha"}
|
%a.button{:href => '', 'ng-click' => 'deleteBranch()', 'ng-show' => "branch && branch.object.sha == pull.from_ref.sha"}
|
||||||
= t('layout.projects.delete_branch')
|
= t('layout.projects.delete_branch')
|
||||||
%a.button{:href => '', 'ng-click' => 'restoreBranch()', 'ng-hide' => "branch"}
|
%a.button{:href => '', 'ng-click' => 'restoreBranch()', 'ng-hide' => "branch"}
|
||||||
|
|
Loading…
Reference in New Issue