Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button to ensure filtering is finished #846

Merged
merged 8 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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