Skip to content

Commit 9495aa9

Browse files
authored
Merge pull request #21063 from guerler/remove_jquery.001
Remove jquery from legacy onload helpers and Rule Builder
2 parents 414cb32 + 0aa35a2 commit 9495aa9

File tree

16 files changed

+112
-590
lines changed

16 files changed

+112
-590
lines changed

client/src/components/RuleBuilder/ColumnSelector.vue

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<template>
22
<div v-if="!multiple || !ordered" class="rule-column-selector">
3-
<label class="d-flex justify-content-end align-items-center">
3+
<div class="d-flex justify-content-end align-items-center">
44
<span v-b-tooltip.hover class="mr-auto help-text" :title="help">{{ label }}</span>
55
<div v-b-tooltip.hover class="mr-1" :title="title">
6-
<Select2 :value="target" :multiple="multiple" @input="handleInput">
7-
<option v-for="(col, index) in colHeaders" :key="col" :value="index">{{ col }}</option>
8-
</Select2>
6+
<SelectBasic :value="target" :multiple="multiple" :options="columnOptions" @input="handleInput" />
97
</div>
108
<slot></slot>
11-
</label>
9+
</div>
1210
</div>
1311
<div v-else class="rule-column-selector">
1412
<span class="help-text" :title="help">{{ label }}</span>
@@ -28,25 +26,21 @@
2826
<i @click="$emit('update:orderedEdit', true)">... {{ l("Assign Another Column") }}</i>
2927
</span>
3028
<span v-else class="rule-column-selector-target-select">
31-
<Select2 placeholder="Select a column" @input="handleAdd">
32-
<option />
33-
<!-- empty option selection for placeholder -->
34-
<option v-for="(col, index) in remainingHeaders" :key="col" :value="index">{{ col }}</option>
35-
</Select2>
29+
<SelectBasic placeholder="Select a column" :options="remainingOptions" @input="handleAdd" />
3630
</span>
3731
</li>
3832
</ol>
3933
</div>
4034
</template>
4135

4236
<script>
43-
import Select2 from "components/Select2";
37+
import SelectBasic from "components/RuleBuilder/SelectBasic";
4438
import _l from "utils/localization";
4539
import Vue from "vue";
4640
4741
export default {
4842
components: {
49-
Select2,
43+
SelectBasic,
5044
},
5145
props: {
5246
target: {
@@ -86,18 +80,15 @@ export default {
8680
},
8781
},
8882
computed: {
89-
remainingHeaders() {
90-
const colHeaders = this.colHeaders;
83+
columnOptions() {
84+
return this.colHeaders.map((col, index) => ({ id: index, text: col }));
85+
},
86+
remainingOptions() {
9187
if (!this.multiple) {
92-
return colHeaders;
93-
}
94-
const remaining = {};
95-
for (const key in colHeaders) {
96-
if (this.target.indexOf(parseInt(key)) === -1) {
97-
remaining[key] = colHeaders[key];
98-
}
88+
return this.columnOptions;
9989
}
100-
return remaining;
90+
const exclude = new Set(this.target.map(Number));
91+
return this.columnOptions.filter((opt) => !exclude.has(opt.id));
10192
},
10293
title() {
10394
return _l("Select a column");
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<VueMultiselect
3+
class="select-basic"
4+
:allow-empty="multiple"
5+
:close-on-select="!multiple"
6+
:options="options"
7+
:multiple="multiple"
8+
:placeholder="placeholder || 'Select an option'"
9+
:value="selectedValue"
10+
deselect-label=""
11+
label="text"
12+
select-label=""
13+
track-by="id"
14+
@input="onInput" />
15+
</template>
16+
17+
<script setup>
18+
import { computed } from "vue";
19+
import VueMultiselect from "vue-multiselect";
20+
21+
const props = defineProps({
22+
value: { required: false },
23+
multiple: { type: Boolean, default: false },
24+
options: { type: Array, default: () => [] },
25+
placeholder: { type: String, default: null },
26+
});
27+
28+
const emit = defineEmits(["input"]);
29+
30+
const selectedValue = computed(() => {
31+
if (!props.value) {
32+
return props.multiple ? [] : null;
33+
}
34+
if (props.multiple) {
35+
return props.options.filter((opt) => props.value.includes(opt.id));
36+
}
37+
const singleValue = Array.isArray(props.value) ? props.value[0] : props.value;
38+
return props.options.find((opt) => opt.id === singleValue) || null;
39+
});
40+
41+
const onInput = (selected) => {
42+
const outputValue = props.multiple ? selected.map((opt) => opt.id) : selected ? selected.id : null;
43+
emit("input", outputValue);
44+
};
45+
</script>

client/src/components/RuleCollectionBuilder.vue

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
:display-rule-type.sync="displayRuleType"
5757
@saveRule="handleRuleSave">
5858
<ColumnSelector :target.sync="addSortingTarget" :col-headers="activeRuleColHeaders" />
59-
<label v-b-tooltip.hover :title="titleNumericSort">
59+
<label v-b-tooltip.hover.noninteractive :title="titleNumericSort">
6060
<input v-model="addSortingNumeric" type="checkbox" />
6161
{{ l("Numeric sorting.") }}
6262
</label>
@@ -141,7 +141,7 @@
141141
{{ l("Replacement Expression") }}
142142
<input v-model="addColumnRegexReplacement" type="text" class="rule-replacement" />
143143
</label>
144-
<label v-b-tooltip.hover>
144+
<label v-b-tooltip.hover.noninteractive>
145145
<input v-model="addColumnRegexAllowUnmatched" type="checkbox" />
146146
{{ l("Allow regular expression unmatched.") }}
147147
</label>
@@ -401,7 +401,7 @@
401401
<div class="rules-buttons btn-group">
402402
<div class="dropup">
403403
<button
404-
v-b-tooltip.hover.bottom
404+
v-b-tooltip.hover.bottom.noninteractive
405405
type="button"
406406
:title="titleRulesMenu"
407407
class="rule-menu-rules-button primary-button dropdown-toggle"
@@ -425,7 +425,7 @@
425425
</div>
426426
<div class="dropup">
427427
<button
428-
v-b-tooltip.hover.bottom
428+
v-b-tooltip.hover.bottom.noninteractive
429429
type="button"
430430
:title="titleFilterMenu"
431431
class="rule-menu-filter-button primary-button dropdown-toggle"
@@ -444,7 +444,7 @@
444444
</div>
445445
<div class="dropup">
446446
<button
447-
v-b-tooltip.hover.bottom
447+
v-b-tooltip.hover.bottom.noninteractive
448448
type="button"
449449
:title="titleColumMenu"
450450
class="rule-menu-column-button primary-button dropdown-toggle"
@@ -520,17 +520,15 @@
520520
<input v-if="elementsType == 'datasets'" v-model="hideSourceItems" type="checkbox" />
521521
<div v-if="extension && showFileTypeSelector" class="rule-footer-extension-group">
522522
<label>{{ l("Type") }}:</label>
523-
<Select2 v-model="extension" name="extension" class="extension-select">
524-
<option v-for="col in extensions" :key="col.id" :value="col['id']">
525-
{{ col["text"] }}
526-
</option>
527-
</Select2>
523+
<SelectBasic
524+
v-model="extension"
525+
name="extension"
526+
class="extension-select"
527+
:options="extensions" />
528528
</div>
529529
<div v-if="genome && showGenomeSelector" class="rule-footer-genome-group">
530530
<label>{{ l("Genome") }}:</label>
531-
<Select2 v-model="genome" class="genome-select">
532-
<option v-for="col in genomes" :key="col.id" :value="col['id']">{{ col["text"] }}</option>
533-
</Select2>
531+
<SelectBasic v-model="genome" class="genome-select" :options="genomes" />
534532
</div>
535533
<label v-if="showAddNameTag">{{ l("Add nametag for name") }}:</label>
536534
<input v-if="showAddNameTag" v-model="addNameTag" type="checkbox" />
@@ -625,10 +623,9 @@ import RuleModalMiddle from "components/RuleBuilder/RuleModalMiddle";
625623
import RuleTargetComponent from "components/RuleBuilder/RuleTargetComponent";
626624
import SavedRulesSelector from "components/RuleBuilder/SavedRulesSelector";
627625
import SaveRules from "components/RuleBuilder/SaveRules";
626+
import SelectBasic from "components/RuleBuilder/SelectBasic";
628627
import StateDiv from "components/RuleBuilder/StateDiv";
629-
import Select2 from "components/Select2";
630628
import UploadUtils from "components/Upload/utils";
631-
import $ from "jquery";
632629
import { getAppRoot } from "onload/loadConfig";
633630
import { useHistoryStore } from "stores/historyStore";
634631
import _ from "underscore";
@@ -662,7 +659,7 @@ export default {
662659
RuleModalHeader,
663660
RuleModalMiddle,
664661
RuleModalFooter,
665-
Select2,
662+
SelectBasic,
666663
GButton,
667664
},
668665
mixins: [SaveRules],
@@ -1496,25 +1493,6 @@ export default {
14961493
this.errorMessage = "Unknown error encountered: " + error;
14971494
}
14981495
},
1499-
swapOrientation() {
1500-
this.orientation = this.orientation == "horizontal" ? "vertical" : "horizontal";
1501-
const hotTable = this.$refs.hotTable.table;
1502-
if (this.orientation == "horizontal") {
1503-
this.$nextTick(function () {
1504-
const fullWidth = $(".rule-builder-body").width();
1505-
hotTable.updateSettings({
1506-
width: fullWidth,
1507-
});
1508-
});
1509-
} else {
1510-
this.$nextTick(function () {
1511-
const fullWidth = $(".rule-builder-body").width();
1512-
hotTable.updateSettings({
1513-
width: fullWidth - 270,
1514-
});
1515-
});
1516-
}
1517-
},
15181496
attemptCreate() {
15191497
this.createCollection();
15201498
},
@@ -1856,16 +1834,16 @@ export default {
18561834
return { data, sources };
18571835
},
18581836
highlightColumn(n) {
1859-
const headerSelection = $(`.htCore > thead > tr > th:nth-child(${n + 1})`);
1860-
headerSelection.addClass("ht__highlight");
1861-
const bodySelection = $(`.htCore > tbody > tr > td:nth-child(${n + 1})`);
1862-
bodySelection.addClass("rule-highlight");
1837+
const headerSelection = document.querySelectorAll(`.htCore > thead > tr > th:nth-child(${n + 1})`);
1838+
headerSelection.forEach((el) => el.classList.add("ht__highlight"));
1839+
const bodySelection = document.querySelectorAll(`.htCore > tbody > tr > td:nth-child(${n + 1})`);
1840+
bodySelection.forEach((el) => el.classList.add("rule-highlight"));
18631841
},
18641842
unhighlightColumn(n) {
1865-
const headerSelection = $(`.htCore > thead > tr > th:nth-child(${n + 1})`);
1866-
headerSelection.removeClass("ht__highlight");
1867-
const bodySelection = $(`.htCore > tbody > tr > td:nth-child(${n + 1})`);
1868-
bodySelection.removeClass("rule-highlight");
1843+
const headerSelection = document.querySelectorAll(`.htCore > thead > tr > th:nth-child(${n + 1})`);
1844+
headerSelection.forEach((el) => el.classList.remove("ht__highlight"));
1845+
const bodySelection = document.querySelectorAll(`.htCore > tbody > tr > td:nth-child(${n + 1})`);
1846+
bodySelection.forEach((el) => el.classList.remove("rule-highlight"));
18691847
},
18701848
_datasetFor(dataIndex, data, mappingAsDict) {
18711849
const res = {};
@@ -1976,7 +1954,7 @@ export default {
19761954
width: 100%;
19771955
overflow: hidden;
19781956
}
1979-
.select2-container {
1957+
.select-basic {
19801958
min-width: 60px;
19811959
}
19821960
.vertical #hot-table {
@@ -2066,33 +2044,33 @@ export default {
20662044
font-style: italic;
20672045
font-weight: bold;
20682046
}
2069-
.rules-buttons {
2070-
}
20712047
.rule-footer-inputs label {
2072-
padding-left: 20px;
2048+
margin-left: 1rem;
2049+
margin-right: 1rem;
20732050
align-self: baseline;
20742051
}
2075-
.rule-footer-inputs .select2-container {
2052+
.rule-footer-inputs .select-basic {
20762053
align-self: baseline;
20772054
}
20782055
.rule-footer-inputs {
20792056
display: flex;
20802057
justify-content: space-between;
20812058
flex-wrap: wrap;
20822059
align-items: baseline;
2060+
margin-top: 1rem;
20832061
}
20842062
.rule-footer-inputs input {
20852063
align-self: baseline;
20862064
}
20872065
.extension-select {
20882066
flex: 1;
2089-
max-width: 120px;
2090-
min-width: 60px;
2067+
max-width: 200px;
2068+
min-width: 200px;
20912069
}
20922070
.genome-select {
20932071
flex: 1;
20942072
max-width: 300px;
2095-
min-width: 120px;
2073+
min-width: 300px;
20962074
}
20972075
.collection-name {
20982076
flex: 1;

client/src/components/Select2.vue

Lines changed: 0 additions & 58 deletions
This file was deleted.

client/src/legacy/grid/grid-view.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import GridModel from "legacy/grid/grid-model";
1111
import Templates from "legacy/grid/grid-template";
1212
import PopupMenu from "./popup-menu";
1313
import { setWindowTitle } from "./utils";
14-
import { init_refresh_on_change } from "onload/globalInits/init_refresh_on_change";
1514

1615
var $ = jQuery;
1716

@@ -114,10 +113,6 @@ export default Backbone.View.extend({
114113
// configure elements
115114
this.init_grid_elements();
116115
this.init_grid_controls();
117-
118-
// attach global event handler
119-
// TODO: redundant (the onload/standard page handlers do this) - but needed because these are constructed after page ready
120-
init_refresh_on_change();
121116
},
122117

123118
// Initialize grid controls

0 commit comments

Comments
 (0)