Handle file delation + Handle file activation file + Activate last version on file activation

This commit is contained in:
brunosimon
2016-08-12 01:29:23 +02:00
parent a73a484d2a
commit 9ce3261a96
4 changed files with 65 additions and 42 deletions
@@ -25,14 +25,12 @@ application.controller(
$scope.file_click = function( file )
{
console.log('file click');
// project.each_file( function( file )
// {
// file.active = false;
// } );
file = file.data;
file.notif = 0;
// file.active = true;
// $scope.file = file;
$scope.file = file;
$scope.version = file.versions[ file.versions.length - 1 ];
};
$scope.version_click = function( version )
+31 -17
View File
@@ -33,22 +33,22 @@ application.factory(
socket.on( 'create_file', function( data )
{
console.log('create_file');
console.log(data);
// console.log('create_file');
// console.log(data);
var existing_file = result.files[ data.path.full ];
var file = result.files[ data.path.full ];
// Doesn't exist yet
if( typeof existing_file === 'undefined' )
if( typeof file === 'undefined' )
{
existing_file = Object.assign( {}, data );
existing_file.notif = 0;
result.files[ data.path.full ] = existing_file;
file = Object.assign( {}, data );
file.notif = 0;
result.files[ data.path.full ] = file;
result.tree.add_file( data.path.full, existing_file )
result.tree.add_file( data.path.full, file )
}
existing_file.notif++;
file.notif++;
// Apply callback
if( typeof update_callback === 'function' )
@@ -57,17 +57,17 @@ application.factory(
socket.on( 'create_version', function( data )
{
console.log('create_version');
console.log(data);
// console.log('create_version');
// console.log(data);
var existing_file = result.files[ data.file ];
var file = result.files[ data.file ];
// Doesn't exist yet
if( typeof existing_file !== 'undefined' )
if( typeof file !== 'undefined' )
{
existing_file.versions.push( data.version );
file.versions.push( data.version );
existing_file.notif++;
file.notif++;
// Apply callback
if( typeof update_callback === 'function' )
@@ -77,8 +77,22 @@ application.factory(
socket.on( 'delete_file', function( data )
{
console.log('delete_file');
console.log(data);
// console.log('delete_file');
// console.log(data);
var file = result.files[ data.path.full ];
// Doesn't exist yet
if( typeof file !== 'undefined' )
{
result.tree.remove_file( file.path.full )
delete result.files[ data.path.full ]
// Apply callback
if( typeof update_callback === 'function' )
update_callback.apply( this, [ data ] );
}
} );
// Update project event