mirror of
https://github.com/wekan/wekan.git
synced 2026-02-03 23:21:47 +01:00
Add new debug operator to search and fix some bugs
This commit is contained in:
parent
7f8f3f8f16
commit
94525a4d3d
7 changed files with 153 additions and 53 deletions
|
|
@ -42,6 +42,16 @@ template(name="globalSearch")
|
|||
autofocus dir="auto"
|
||||
)
|
||||
a.js-new-search.fa.fa-eraser
|
||||
if debug.get.show
|
||||
h1 Debug
|
||||
if debug.get.showSelector
|
||||
h2 Selector
|
||||
pre
|
||||
= sessionData.selector
|
||||
if debug.get.showProjection
|
||||
h2 Projection
|
||||
pre
|
||||
= sessionData.projection
|
||||
if searching.get
|
||||
+spinner
|
||||
else if hasResults.get
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import Cards from '../../models/cards';
|
||||
import SessionData from '../../models/usersessiondata';
|
||||
import {QueryDebug} from "../../config/query-classes";
|
||||
import {OPERATOR_DEBUG} from "../../config/search-const";
|
||||
|
||||
export class CardSearchPagedComponent extends BlazeComponent {
|
||||
onCreated() {
|
||||
|
|
@ -19,6 +21,8 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
this.sessionId = SessionData.getSessionId();
|
||||
this.subscriptionHandle = null;
|
||||
this.serverError = new ReactiveVar(false);
|
||||
this.sessionData = null;
|
||||
this.debug = new ReactiveVar(new QueryDebug());
|
||||
|
||||
const that = this;
|
||||
this.subscriptionCallbacks = {
|
||||
|
|
@ -52,6 +56,7 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
this.resultsCount = 0;
|
||||
this.totalHits = 0;
|
||||
this.queryErrors = null;
|
||||
this.debug.set(new QueryDebug());
|
||||
}
|
||||
|
||||
getSessionData(sessionId) {
|
||||
|
|
@ -63,30 +68,34 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
getResults() {
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('getting results');
|
||||
const sessionData = this.getSessionData();
|
||||
this.sessionData = this.getSessionData();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('session data:', sessionData);
|
||||
console.log('session data:', this.sessionData);
|
||||
const cards = [];
|
||||
sessionData.cards.forEach(cardId => {
|
||||
this.sessionData.cards.forEach(cardId => {
|
||||
cards.push(Cards.findOne({ _id: cardId }));
|
||||
});
|
||||
this.queryErrors = sessionData.errors;
|
||||
this.queryErrors = this.sessionData.errors;
|
||||
if (this.queryErrors.length) {
|
||||
// console.log('queryErrors:', this.queryErrorMessages());
|
||||
this.hasQueryErrors.set(true);
|
||||
// return null;
|
||||
}
|
||||
this.debug.set(new QueryDebug(this.sessionData.debug));
|
||||
console.log('debug:', this.debug.get().get());
|
||||
console.log('debug.show():', this.debug.get().show());
|
||||
console.log('debug.showSelector():', this.debug.get().showSelector());
|
||||
|
||||
if (cards) {
|
||||
this.totalHits = sessionData.totalHits;
|
||||
this.totalHits = this.sessionData.totalHits;
|
||||
this.resultsCount = cards.length;
|
||||
this.resultsStart = sessionData.lastHit - this.resultsCount + 1;
|
||||
this.resultsEnd = sessionData.lastHit;
|
||||
this.resultsStart = this.sessionData.lastHit - this.resultsCount + 1;
|
||||
this.resultsEnd = this.sessionData.lastHit;
|
||||
this.resultsHeading.set(this.getResultsHeading());
|
||||
this.results.set(cards);
|
||||
this.hasNextPage.set(sessionData.lastHit < sessionData.totalHits);
|
||||
this.hasNextPage.set(this.sessionData.lastHit < this.sessionData.totalHits);
|
||||
this.hasPreviousPage.set(
|
||||
sessionData.lastHit - sessionData.resultsCount > 0,
|
||||
this.sessionData.lastHit - this.sessionData.resultsCount > 0,
|
||||
);
|
||||
return cards;
|
||||
}
|
||||
|
|
@ -113,6 +122,7 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
|
||||
runGlobalSearch(queryParams) {
|
||||
this.searching.set(true);
|
||||
this.debug.set(new QueryDebug());
|
||||
this.stopSubscription();
|
||||
this.subscriptionHandle = this.getSubscription(queryParams);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue