Skip to content

Commit f2a5a9f

Browse files
authored
Merge pull request #6491 from Countly/validating-active-users
fix: Improve datatable local search
2 parents d95f275 + ab9d16a commit f2a5a9f

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

frontend/express/public/javascripts/countly/vue/components/datatable.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,33 @@
7272
var currentArray = this.rows.slice();
7373
if (this.displaySearch && this.controlParams.searchQuery) {
7474
var queryLc = (this.controlParams.searchQuery + "").toLowerCase();
75+
76+
var searchableFields = [];
77+
if (this.$refs.elTable && this.$refs.elTable.columns) {
78+
this.$refs.elTable.columns.forEach(function(col) {
79+
if (col.columnKey) {
80+
searchableFields.push(col.columnKey);
81+
}
82+
});
83+
}
84+
7585
currentArray = currentArray.filter(function(item) {
76-
return Object.keys(item).some(function(fieldKey) {
77-
if (item[fieldKey] === null || item[fieldKey] === undefined) {
86+
// If no searchable fields found from columns, use original search logic
87+
if (!searchableFields.length) {
88+
return Object.keys(item).some(function(fieldKey) {
89+
if (item[fieldKey] === null || item[fieldKey] === undefined) {
90+
return false;
91+
}
92+
return (item[fieldKey] + "").toLowerCase().indexOf(queryLc) > -1;
93+
});
94+
}
95+
96+
return searchableFields.some(function(fieldKey) {
97+
var value = item[fieldKey];
98+
if (value === null || value === undefined) {
7899
return false;
79100
}
80-
return (item[fieldKey] + "").toLowerCase().indexOf(queryLc) > -1;
101+
return (value + "").toLowerCase().indexOf(queryLc) > -1;
81102
});
82103
});
83104
}

frontend/express/public/javascripts/countly/vue/components/vis.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,8 @@
26162616
Vue.component("cly-chart-time", BaseLineChart.extend({
26172617
data: function() {
26182618
return {
2619-
forwardedSlots: ["chart-left", "chart-right"]
2619+
forwardedSlots: ["chart-left", "chart-right"],
2620+
chartType: 'line'
26202621
};
26212622
},
26222623
props: {
@@ -2733,6 +2734,7 @@
27332734
else if (!this.areNotesHidden) {
27342735
this.getGraphNotes();
27352736
}
2737+
this.chartType = this.seriesOptions?.type || 'line';
27362738
},
27372739
notesVisibility: function() {
27382740
if (!this.areNotesHidden) {
@@ -2745,7 +2747,7 @@
27452747
},
27462748
template: '<div class="cly-vue-chart" :class="chartClasses" :style="chartStyles">\
27472749
<div class="cly-vue-chart__echart bu-is-flex bu-is-flex-direction-column bu-is-flex-grow-1 bu-is-flex-shrink-1" style="min-height: 0">\
2748-
<chart-header :test-id="testId + \'-header\'" ref="header" :category="this.category" :hide-notation="this.hideNotation" v-if="!isChartEmpty" @series-toggle="onSeriesChange" :show-zoom="showZoom" :show-toggle="showToggle" :show-download="showDownload" @graph-notes-refresh="refresh" @notes-visibility="notesVisibility">\
2750+
<chart-header :test-id="testId + \'-header\'" ref="header" :chart-type="this.chartType" :category="this.category" :hide-notation="this.hideNotation" v-if="!isChartEmpty" @series-toggle="onSeriesChange" :show-zoom="showZoom" :show-toggle="showToggle" :show-download="showDownload" @graph-notes-refresh="refresh" @notes-visibility="notesVisibility">\
27492751
<template v-for="item in forwardedSlots" v-slot:[item]="slotScope">\
27502752
<slot :name="item" v-bind="slotScope"></slot>\
27512753
</template>\

0 commit comments

Comments
 (0)