Fix resource lookup premature collapse

This commit is contained in:
Jiang Yio 2022-09-26 18:30:10 -04:00
parent 976276e2e0
commit 030487d728

View File

@ -1,7 +1,8 @@
<template> <template>
<div>
<div class="input-group"> <div class="input-group">
<span class="input-group-text">🔎</span> <span class="input-group-text">🔎</span>
<input class="form-control" v-model="query_raw" @focus="collapsed = false" @blur="collapsed = true" /> <input class="form-control" v-model="query_raw" @focus="collapsed = false" />
</div> </div>
<div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;"> <div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;">
<table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0"> <table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0">
@ -25,6 +26,7 @@
<span class="badge bg-primary" style="cursor: default; margin-right: 0.35em;" v-on:click="reset">CLEAR {{resultset_selected.length}}</span> <span class="badge bg-primary" style="cursor: default; margin-right: 0.35em;" v-on:click="reset">CLEAR {{resultset_selected.length}}</span>
<span class="badge bg-secondary" style="cursor: default; margin-right: 0.35em;" v-for="row in resultset_selected" v-on:click="row.selected = false;"> {{row.RESOURCEID}} {{row.RESOURCE_NAME}}</span> <span class="badge bg-secondary" style="cursor: default; margin-right: 0.35em;" v-for="row in resultset_selected" v-on:click="row.selected = false;"> {{row.RESOURCEID}} {{row.RESOURCE_NAME}}</span>
</div> </div>
</div>
</template> </template>
<style scoped> <style scoped>
@ -91,6 +93,7 @@
} }
}, },
methods: { methods: {
collapse(evt) { if(!this.$el.contains(evt.target)) this.collapsed = true; },
reset(evt) { reset(evt) {
var selection = this.resultset_selected.slice(); var selection = this.resultset_selected.slice();
for(var i = selection.length - 1; i >= 0; --i) selection[i].selected = false; for(var i = selection.length - 1; i >= 0; --i) selection[i].selected = false;
@ -103,6 +106,10 @@
var rs = (await this.client.SDEC_RESOURCE()).slice(); var rs = (await this.client.SDEC_RESOURCE()).slice();
update_selection(rs, this.selection); update_selection(rs, this.selection);
this.resultset_raw = rs; this.resultset_raw = rs;
document.addEventListener('click', this.collapse);
},
destroyed() {
document.removeEventListener('click', this.collapse);
} }
}; };
</script> </script>