|
|
@ -27,36 +27,36 @@ |
|
|
|
//++
|
|
|
|
//++
|
|
|
|
|
|
|
|
|
|
|
|
import {wpDirectivesModule} from '../../../angular-modules'; |
|
|
|
import {wpDirectivesModule} from '../../../angular-modules'; |
|
|
|
import {WpAttachmentsService} from './wp-attachments.service' |
|
|
|
import {WpAttachmentsService} from './wp-attachments.service'; |
|
|
|
|
|
|
|
|
|
|
|
export class WorkPackageAttachmentsController{ |
|
|
|
export class WorkPackageAttachmentsController { |
|
|
|
public workPackage: any; |
|
|
|
public workPackage:any; |
|
|
|
|
|
|
|
|
|
|
|
public attachments: Array = []; |
|
|
|
public attachments:any[] = []; |
|
|
|
public fetchingConfiguration: boolean = false; |
|
|
|
public fetchingConfiguration:boolean = false; |
|
|
|
public files: Array<File> = []; |
|
|
|
public files:File[] = []; |
|
|
|
public hasRightToUpload: boolean = false; |
|
|
|
public hasRightToUpload:boolean = false; |
|
|
|
public I18n: any; |
|
|
|
public I18n:any; |
|
|
|
public loading: boolean = false; |
|
|
|
public loading:boolean = false; |
|
|
|
public rejectedFiles: Array = []; |
|
|
|
public rejectedFiles:any[] = []; |
|
|
|
|
|
|
|
|
|
|
|
public settings: Object = { |
|
|
|
public settings = { |
|
|
|
maximumFileSize: Number |
|
|
|
maximumFileSize: Number |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public size: any; |
|
|
|
public size:any; |
|
|
|
|
|
|
|
|
|
|
|
private currentlyFocussing; |
|
|
|
private currentlyFocussing; |
|
|
|
private editMode: boolean; |
|
|
|
private editMode:boolean; |
|
|
|
|
|
|
|
|
|
|
|
constructor(protected $scope: ng.IScope, |
|
|
|
constructor(protected $scope:any, |
|
|
|
protected $element: ng.IAugmentedJQuery, |
|
|
|
protected $element:ng.IAugmentedJQuery, |
|
|
|
protected $attrs: ng.IAttributes, |
|
|
|
protected $attrs:ng.IAttributes, |
|
|
|
protected wpAttachments: WpAttachmentsService, |
|
|
|
protected wpAttachments:WpAttachmentsService, |
|
|
|
protected NotificationsService: ng.IServiceProvider, |
|
|
|
protected NotificationsService:any, |
|
|
|
protected I18n: any, |
|
|
|
protected I18n:any, |
|
|
|
protected ConfigurationService: ng.IServiceProviderFactory, |
|
|
|
protected ConfigurationService:any, |
|
|
|
protected ConversionService: ng.IServiceProvider){ |
|
|
|
protected ConversionService:any) { |
|
|
|
|
|
|
|
|
|
|
|
this.attachments = this.wpAttachments.getCurrentAttachments(); |
|
|
|
this.attachments = this.wpAttachments.getCurrentAttachments(); |
|
|
|
this.editMode = $attrs.hasOwnProperty('edit'); |
|
|
|
this.editMode = $attrs.hasOwnProperty('edit'); |
|
|
@ -70,13 +70,13 @@ export class WorkPackageAttachmentsController{ |
|
|
|
this.fetchingConfiguration = false; |
|
|
|
this.fetchingConfiguration = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if(angular.isDefined(this.workPackage)) { |
|
|
|
if (this.workPackage && this.workPackage.attachments) { |
|
|
|
this.loadAttachments(); |
|
|
|
this.loadAttachments(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public upload(): void { |
|
|
|
public upload():void { |
|
|
|
if (this.workPackage.isNew) { |
|
|
|
if (this.workPackage.isNew) { |
|
|
|
this.files.forEach((file) => { |
|
|
|
this.files.forEach((file) => { |
|
|
|
this.attachments.push(file); |
|
|
|
this.attachments.push(file); |
|
|
@ -92,33 +92,32 @@ export class WorkPackageAttachmentsController{ |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public loadAttachments(): void { |
|
|
|
public loadAttachments():void { |
|
|
|
if (this.editMode) { |
|
|
|
if (this.editMode) { |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
this.wpAttachments.load(this.workPackage,true).finally(() => { |
|
|
|
this.wpAttachments.load(this.workPackage, true).finally(() => { |
|
|
|
this.loading = false; |
|
|
|
this.loading = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public remove(file): void { |
|
|
|
public remove(file):void { |
|
|
|
if(this.workPackage.isNew){ |
|
|
|
if (this.workPackage.isNew) { |
|
|
|
_.remove(this.wpAttachments.attachments, file); |
|
|
|
_.remove(this.wpAttachments.attachments, file); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
this.wpAttachments.remove(file); |
|
|
|
this.wpAttachments.remove(file); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public focus(attachment: any): void { |
|
|
|
public focus(attachment:any):void { |
|
|
|
this.currentlyFocussing = attachment; |
|
|
|
this.currentlyFocussing = attachment; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public focussing(attachment: any): boolean { |
|
|
|
public focussing(attachment:any):boolean { |
|
|
|
return this.currentlyFocussing === attachment; |
|
|
|
return this.currentlyFocussing === attachment; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public filterFiles(files): void { |
|
|
|
public filterFiles(files):void { |
|
|
|
// Directories cannot be uploaded and as such, should not become files in
|
|
|
|
// Directories cannot be uploaded and as such, should not become files in
|
|
|
|
// the sense of this directive. The files within the directories will
|
|
|
|
// the sense of this directive. The files within the directories will
|
|
|
|
// be taken though.
|
|
|
|
// be taken though.
|
|
|
@ -127,15 +126,13 @@ export class WorkPackageAttachmentsController{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public uploadFilteredFiles(files): void { |
|
|
|
public uploadFilteredFiles(files):void { |
|
|
|
this.filterFiles(files); |
|
|
|
this.filterFiles(files); |
|
|
|
this.upload() |
|
|
|
this.upload(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function wpAttachmentsDirective(): ng.IDirective { |
|
|
|
function wpAttachmentsDirective():ng.IDirective { |
|
|
|
return { |
|
|
|
return { |
|
|
|
bindToController: true, |
|
|
|
bindToController: true, |
|
|
|
controller: WorkPackageAttachmentsController, |
|
|
|
controller: WorkPackageAttachmentsController, |
|
|
@ -145,15 +142,14 @@ function wpAttachmentsDirective(): ng.IDirective { |
|
|
|
scope: { |
|
|
|
scope: { |
|
|
|
workPackage: '&', |
|
|
|
workPackage: '&', |
|
|
|
}, |
|
|
|
}, |
|
|
|
templateUrl: (element: ng.IAugmentedJQuery, attrs: ng.IAttributes): string => { |
|
|
|
templateUrl: (element:ng.IAugmentedJQuery, attrs:ng.IAttributes):string => { |
|
|
|
if(attrs.hasOwnProperty('edit')) { |
|
|
|
if (attrs.hasOwnProperty('edit')) { |
|
|
|
return '/components/work-packages/wp-attachments/wp-attachments-edit.directive.html'; |
|
|
|
return '/components/work-packages/wp-attachments/wp-attachments-edit.directive.html'; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return '/components/work-packages/wp-attachments/wp-attachments.directive.html'; |
|
|
|
return '/components/work-packages/wp-attachments/wp-attachments.directive.html'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wpDirectivesModule.directive('wpAttachments', wpAttachmentsDirective); |
|
|
|
wpDirectivesModule.directive('wpAttachments', wpAttachmentsDirective); |
|
|
|