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,29 +1,31 @@
<template> <template>
<div class="input-group"> <div>
<span class="input-group-text">🔎</span> <div class="input-group">
<input class="form-control" v-model="query_raw" @focus="collapsed = false" @blur="collapsed = true" /> <span class="input-group-text">🔎</span>
</div> <input class="form-control" v-model="query_raw" @focus="collapsed = false" />
<div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;"> </div>
<table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0"> <div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;">
<thead> <table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0">
<tr><th></th><th>ID</th><th>Name</th><th>Type</th><th>User</th></tr> <thead>
</thead> <tr><th></th><th>ID</th><th>Name</th><th>Type</th><th>User</th></tr>
<tbody> </thead>
<template v-for="row in resultset_filtered"> <tbody>
<tr :class="{ 'table-active': row.selected }" v-if="row.INACTIVE != 'YES'"> <template v-for="row in resultset_filtered">
<td><input type="checkbox" v-model="row.selected" /></td> <tr :class="{ 'table-active': row.selected }" v-if="row.INACTIVE != 'YES'">
<td>{{row.RESOURCEID}}</td> <td><input type="checkbox" v-model="row.selected" /></td>
<td>{{row.RESOURCE_NAME}}</td> <td>{{row.RESOURCEID}}</td>
<td>{{row.RESOURCETYPE}}</td> <td>{{row.RESOURCE_NAME}}</td>
<td>{{row.USERNAME}}</td> <td>{{row.RESOURCETYPE}}</td>
</tr> <td>{{row.USERNAME}}</td>
</template> </tr>
</tbody> </template>
</table> </tbody>
</div> </table>
<div style="font-family: monospace;" v-if="resultset_selected.length"> </div>
<span class="badge bg-primary" style="cursor: default; margin-right: 0.35em;" v-on:click="reset">CLEAR {{resultset_selected.length}}</span> <div style="font-family: monospace;" v-if="resultset_selected.length">
<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-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>
</div>
</div> </div>
</template> </template>
@ -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>