From 39d7ccb2d220a085de9fd7c56a6bfc469ab4927a Mon Sep 17 00:00:00 2001 From: Christine Yu Date: Tue, 15 Mar 2016 12:37:30 -0400 Subject: [PATCH] feat(bam): allow tab, add examples - copy tweaks - add cancel button - show invalid format error for all errors - update canBamSlice conditions for new ES index Closes #163 --- app/scripts/components/ui/search/styles.less | 5 +- app/scripts/files/files.controllers.ts | 46 +++++++++++++------ app/scripts/files/files.directives.ts | 4 +- .../files/templates/bam-slicing-failed.html | 3 +- app/scripts/files/templates/bam-slicing.html | 26 +++++++++-- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/app/scripts/components/ui/search/styles.less b/app/scripts/components/ui/search/styles.less index 728cd5d42..bb4b7efc8 100644 --- a/app/scripts/components/ui/search/styles.less +++ b/app/scripts/components/ui/search/styles.less @@ -35,5 +35,8 @@ textarea { resize: none; + -moz-tab-size : 4; + -o-tab-size : 4; + tab-size : 4; } -} \ No newline at end of file +} diff --git a/app/scripts/files/files.controllers.ts b/app/scripts/files/files.controllers.ts index 63e06e84d..5159d1a73 100755 --- a/app/scripts/files/files.controllers.ts +++ b/app/scripts/files/files.controllers.ts @@ -4,6 +4,7 @@ module ngApp.files.controllers { import ICoreService = ngApp.core.services.ICoreService; import ICartService = ngApp.cart.services.ICartService; import IFilesService = ngApp.files.services.IFilesService; + import IGqlService = ngApp.components.gql.IGqlService; export interface IFileController { file: IFile; @@ -68,46 +69,61 @@ module ngApp.files.controllers { } canBAMSlice(): boolean { - return (this.file.data_type || '').toLowerCase() === "raw sequencing data" && - (this.file.data_subtype || '').toLowerCase() === "aligned reads" && - _.indexOf(_.pluck(this.file.related_files, 'type'), "bai") !== -1; + return (this.file.data_type || '').toLowerCase() === 'aligned reads' && + (this.file.data_format || '').toLowerCase() === 'bam'; } } class BAMSlicingController { + exampleShowing: boolean = false; /* @ngInject */ constructor (private $uibModalInstance, private $scope: ng.IScope, private FilesService: IFilesService, - public fileID: string, - public completeCallback: any) {} + public file: any, + private GqlService: IGqlService, + public completeCallback: any) { + this.$scope.bedModel = ""; + } submit(): void { - this.FilesService.sliceBAM(this.fileID, this.$scope.bedModel, this.completeCallback); + this.FilesService.sliceBAM(this.file.file_id, this.$scope.bedModel, this.completeCallback); this.$uibModalInstance.dismiss('slicing'); } + allowTab($event: any): void { + if (event.keyCode === 9) { + event.preventDefault(); + + // current caret pos + var start = $event.target.selectionStart; + var end = $event.target.selectionEnd; + + var oldValue = this.$scope.bedModel; + this.$scope.bedModel = oldValue.substring(0, start) + '\t' + oldValue.substring(end); + // put caret in correct place + this.GqlService.setPos($event.target, start+1); + } + } + + toggleExample() { + this.exampleShowing = !this.exampleShowing; + } + closeModal(): void { this.$uibModalInstance.dismiss('cancelled'); } } class BAMFailedModalController { - public errorBlobString: string; + msg: string = "Invalid BED Format. Please refer to the examples described in the BAM Slicing pop-up."; /* @ngInject */ constructor(private $uibModalInstance, public errorStatus: string, public errorMsg: string, - private errorBlob: any) { - this.errorBlobString = ""; - var reader = new FileReader(); - reader.addEventListener("loadend", () => { - this.errorBlobString = _.get(JSON.parse(reader.result), "error", "Error slicing"); - }); - reader.readAsText(errorBlob); - } + private errorBlob: any) {} } diff --git a/app/scripts/files/files.directives.ts b/app/scripts/files/files.directives.ts index ee9baae65..385aa903b 100644 --- a/app/scripts/files/files.directives.ts +++ b/app/scripts/files/files.directives.ts @@ -95,8 +95,8 @@ module ngApp.files.directives { animation: false, size: "lg", resolve: { - fileID: function () { - return _.first(_.pluck(files, "file_id")); + file: function() { + return _.first(files); }, completeCallback: function() { return turnSpinnerOff; diff --git a/app/scripts/files/templates/bam-slicing-failed.html b/app/scripts/files/templates/bam-slicing-failed.html index 79def22f6..0d668014a 100644 --- a/app/scripts/files/templates/bam-slicing-failed.html +++ b/app/scripts/files/templates/bam-slicing-failed.html @@ -2,9 +2,8 @@

BAM Slicing Failed