|
|
|
@ -29,34 +29,35 @@ |
|
|
|
|
import {wpDirectivesModule} from '../../../angular-modules'; |
|
|
|
|
import {WpAttachmentsService} from './wp-attachments.service'; |
|
|
|
|
|
|
|
|
|
type FileListAsArray = FileList & typeFixes.ArrayFix; |
|
|
|
|
|
|
|
|
|
export class WorkPackageAttachmentsController { |
|
|
|
|
public workPackage:any; |
|
|
|
|
public workPackage: any; |
|
|
|
|
|
|
|
|
|
public attachments:any[] = []; |
|
|
|
|
public fetchingConfiguration:boolean = false; |
|
|
|
|
public files:File[] = []; |
|
|
|
|
public hasRightToUpload:boolean = false; |
|
|
|
|
public I18n:any; |
|
|
|
|
public loading:boolean = false; |
|
|
|
|
public rejectedFiles:any[] = []; |
|
|
|
|
public attachments: any[] = []; |
|
|
|
|
public fetchingConfiguration: boolean = false; |
|
|
|
|
public files: FileListAsArray = []; |
|
|
|
|
public hasRightToUpload: boolean = false; |
|
|
|
|
public loading: boolean = false; |
|
|
|
|
public rejectedFiles: any[] = []; |
|
|
|
|
|
|
|
|
|
public settings = { |
|
|
|
|
maximumFileSize: Number |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public size:any; |
|
|
|
|
public size: any; |
|
|
|
|
|
|
|
|
|
private currentlyFocussing; |
|
|
|
|
private editMode:boolean; |
|
|
|
|
private editMode: boolean; |
|
|
|
|
|
|
|
|
|
constructor(protected $scope:any, |
|
|
|
|
protected $element:ng.IAugmentedJQuery, |
|
|
|
|
protected $attrs:ng.IAttributes, |
|
|
|
|
protected wpAttachments:WpAttachmentsService, |
|
|
|
|
protected NotificationsService:any, |
|
|
|
|
protected I18n:any, |
|
|
|
|
protected ConfigurationService:any, |
|
|
|
|
protected ConversionService:any) { |
|
|
|
|
constructor(protected $scope: any, |
|
|
|
|
protected $element: ng.IAugmentedJQuery, |
|
|
|
|
protected $attrs: ng.IAttributes, |
|
|
|
|
protected wpAttachments: WpAttachmentsService, |
|
|
|
|
protected NotificationsService: any, |
|
|
|
|
protected I18n: any, |
|
|
|
|
protected ConfigurationService: any, |
|
|
|
|
protected ConversionService: any) { |
|
|
|
|
|
|
|
|
|
this.attachments = this.wpAttachments.getCurrentAttachments(); |
|
|
|
|
this.editMode = $attrs.hasOwnProperty('edit'); |
|
|
|
@ -76,7 +77,7 @@ export class WorkPackageAttachmentsController { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public upload():void { |
|
|
|
|
public upload(): void { |
|
|
|
|
if (this.workPackage.isNew) { |
|
|
|
|
this.files.forEach((file) => { |
|
|
|
|
this.attachments.push(file); |
|
|
|
@ -92,7 +93,7 @@ export class WorkPackageAttachmentsController { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public loadAttachments():void { |
|
|
|
|
public loadAttachments(): void { |
|
|
|
|
if (this.editMode) { |
|
|
|
|
this.loading = true; |
|
|
|
|
this.wpAttachments.load(this.workPackage, true).finally(() => { |
|
|
|
@ -101,7 +102,7 @@ export class WorkPackageAttachmentsController { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public remove(file):void { |
|
|
|
|
public remove(file): void { |
|
|
|
|
if (this.workPackage.isNew) { |
|
|
|
|
_.remove(this.wpAttachments.attachments, file); |
|
|
|
|
} else { |
|
|
|
@ -109,30 +110,30 @@ export class WorkPackageAttachmentsController { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public focus(attachment:any):void { |
|
|
|
|
public focus(attachment: any): void { |
|
|
|
|
this.currentlyFocussing = attachment; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public focussing(attachment:any):boolean { |
|
|
|
|
public focussing(attachment: any): boolean { |
|
|
|
|
return this.currentlyFocussing === attachment; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public filterFiles(files):void { |
|
|
|
|
public filterFiles(files): void { |
|
|
|
|
// Directories cannot be uploaded and as such, should not become files in
|
|
|
|
|
// the sense of this directive. The files within the directories will
|
|
|
|
|
// be taken though.
|
|
|
|
|
_.remove(files, (file:any) => { |
|
|
|
|
_.remove(files, (file: any) => { |
|
|
|
|
return file.type === 'directory'; |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public uploadFilteredFiles(files):void { |
|
|
|
|
public uploadFilteredFiles(files): void { |
|
|
|
|
this.filterFiles(files); |
|
|
|
|
this.upload(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function wpAttachmentsDirective():ng.IDirective { |
|
|
|
|
function wpAttachmentsDirective(): ng.IDirective { |
|
|
|
|
return { |
|
|
|
|
bindToController: true, |
|
|
|
|
controller: WorkPackageAttachmentsController, |
|
|
|
@ -142,7 +143,7 @@ function wpAttachmentsDirective():ng.IDirective { |
|
|
|
|
scope: { |
|
|
|
|
workPackage: '&', |
|
|
|
|
}, |
|
|
|
|
templateUrl: (element:ng.IAugmentedJQuery, attrs:ng.IAttributes):string => { |
|
|
|
|
templateUrl: (element: ng.IAugmentedJQuery, attrs: ng.IAttributes): string => { |
|
|
|
|
if (attrs.hasOwnProperty('edit')) { |
|
|
|
|
return '/components/work-packages/wp-attachments/wp-attachments-edit.directive.html'; |
|
|
|
|
} else { |
|
|
|
|