[update] Last version toggle

This commit is contained in:
brunosimon
2016-08-15 13:47:39 +02:00
parent bcabfd7e6d
commit 2a54fe708d
2 changed files with 29 additions and 5 deletions
@@ -76,6 +76,26 @@ application.controller(
} ); } );
}; };
project.on_new_version = function( data )
{
// Should open last version
if( $scope.always_last_version )
{
// Same file
if( $scope.file && $scope.file.path.full === data.file )
{
$scope.$apply( function()
{
if( $scope.version )
$scope.version.active = false;
$scope.version = data.version;
$scope.version.active = true;
} );
}
}
};
$scope.project = project; $scope.project = project;
$scope.file = null; $scope.file = null;
$scope.always_last_version = true; $scope.always_last_version = true;
@@ -106,6 +106,7 @@ application.factory(
result.files = {}; result.files = {};
result.tree = new Tree( { auto_wash: false } ); result.tree = new Tree( { auto_wash: false } );
result.on_update = null; result.on_update = null;
result.on_new_version = null;
// Connect // Connect
result.connect = function( project_name ) result.connect = function( project_name )
@@ -153,6 +154,9 @@ application.factory(
// Apply callback // Apply callback
if( typeof result.on_update === 'function' ) if( typeof result.on_update === 'function' )
result.on_update.apply( this, [ data ] ); result.on_update.apply( this, [ data ] );
if( typeof result.on_new_version === 'function' )
result.on_new_version.apply( this, [ data ] );
} }
} ); } );