Skip to content

Commit

Permalink
Merge pull request biigle#846 from biigle/fix-file-filtering
Browse files Browse the repository at this point in the history
Add button to ensure filtering is finished
  • Loading branch information
mzur authored Jun 21, 2024
2 parents d43cae2 + 183fbd5 commit 98a64c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
35 changes: 33 additions & 2 deletions resources/assets/js/volumes/cloneForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default {
fileLabelIds: [],
annotationLabelIds: [],
cloneUrlTemplate: "",
noFilesFoundByPattern: false
noFilesFoundByPattern: false,
showTestQueryBtn: false,
cloneBtnTitle: "",
disableCloneBtn: false,
};
},
computed: {
Expand All @@ -65,7 +68,7 @@ export default {
return this.selectedAnnotationLabelIds.length;
},
cannotSubmit() {
return this.name === '' || this.selectedProjectId < 0 || this.loading;
return this.name === '' || this.selectedProjectId < 0 || this.loading || this.showTestQueryBtn || this.disableCloneBtn;
},
getCloneUrl() {
return this.cloneUrlTemplate.replace(':pid', this.selectedProjectId);
Expand Down Expand Up @@ -107,6 +110,8 @@ export default {
if (this.selectedFiles.length === 0) {
this.noFilesFoundByPattern = true;
}
this.showTestQueryBtn = false;
this.disableCloneBtn = this.noFilesFoundByPattern;
});
},
Expand Down Expand Up @@ -170,12 +175,38 @@ export default {
if (!newState) {
this.noFilesFoundByPattern = false;
}
if (!this.fileFiles) {
this.showTestQueryBtn = false;
this.filePattern = "";
this.selectedFiles = [];
}
this.disableCloneBtn = this.filterFiles;
},
cloneFileLabels(newState) {
if (!newState) {
this.filterFileLabels = false;
}
},
filePattern(newPattern, oldPattern) {
if (newPattern.length === 0) {
this.showTestQueryBtn = false;
return;
}
this.showTestQueryBtn = this.filterFiles && (oldPattern !== newPattern);
},
cannotSubmit() {
if (this.cannotSubmit) {
this.cloneBtnTitle = "The file filter query has to be tested first before the volume can be cloned.";
} else {
this.cloneBtnTitle = "";
}
},
noFilesFoundByPattern() {
if (this.cannotSubmit && this.noFilesFoundByPattern) {
this.cloneBtnTitle = "The cloned volume would be empty based on the current file filter query.";
}
}
},
created() {
this.volume = biigle.$require('volume');
Expand Down
3 changes: 2 additions & 1 deletion resources/views/volumes/clone.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
@endif
</div>
<div v-if="filterFiles" class="form-group" v-cloak>
<button :disabled="!showTestQueryBtn" type="button" v-on:click="loadFilesMatchingPattern" class="btn-xs btn btn-success pull-right">Test query</button>
@if ($volume->isImageVolume())
<label>Image(s):</label>
<input type="text" class="form-control" id="files"
Expand Down Expand Up @@ -150,7 +151,7 @@ class="request-labels-well well well-sm" v-cloak></label-trees>
<span class="pull-right">
<a class="btn btn-default" :disabled="loading" type="button"
href="{{URL::previous()}}">Cancel</a>
<input type="submit" class="btn btn-success" :disabled="cannotSubmit" value="Clone">
<input type="submit" class="btn btn-success" :disabled="cannotSubmit" value="Clone" :title="cloneBtnTitle">
</span>
<input v-if="filterAnnotations" v-for="id in selectedAnnotationLabelIds" type="hidden"
name="only_annotation_labels[]"
Expand Down

0 comments on commit 98a64c4

Please sign in to comment.