mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Bug fixes and buttons for previous and next page
* Use buttons for next and previous page in search results * Add custom routine for stringifying and parsing the selector to JSON so RegExp objects are preserved
This commit is contained in:
parent
4e8fc46475
commit
78a1d08a17
6 changed files with 74 additions and 15 deletions
|
|
@ -37,12 +37,16 @@ template(name="globalSearch")
|
||||||
a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}")
|
a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}")
|
||||||
each card in results.get
|
each card in results.get
|
||||||
+resultCard(card)
|
+resultCard(card)
|
||||||
if hasPreviousPage.get
|
table.global-search-footer
|
||||||
button.js-previous-page
|
tr
|
||||||
| {{_ 'previous-page' }}
|
td.global-search-previous-page
|
||||||
if hasNextPage.get
|
if hasPreviousPage.get
|
||||||
button.js-next-page
|
button.js-previous-page
|
||||||
| {{_ 'next-page' }}
|
| {{_ 'previous-page' }}
|
||||||
|
td.global-search-next-page(align="right")
|
||||||
|
if hasNextPage.get
|
||||||
|
button.js-next-page
|
||||||
|
| {{_ 'next-page' }}
|
||||||
else
|
else
|
||||||
.global-search-instructions
|
.global-search-instructions
|
||||||
h2 {{_ 'boards' }}
|
h2 {{_ 'boards' }}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ BlazeComponent.extendComponent({
|
||||||
if (this.queryParams) {
|
if (this.queryParams) {
|
||||||
const sessionData = this.getSessionData();
|
const sessionData = this.getSessionData();
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('selector:', JSON.parse(sessionData.selector));
|
console.log('selector:', sessionData.getSelector());
|
||||||
// console.log('session data:', sessionData);
|
// console.log('session data:', sessionData);
|
||||||
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
||||||
this.queryErrors = sessionData.errors;
|
this.queryErrors = sessionData.errors;
|
||||||
|
|
@ -414,7 +414,7 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: this.resultsPerPage,
|
limit: this.resultsPerPage,
|
||||||
selector: JSON.parse(sessionData.selector),
|
selector: sessionData.getSelector(),
|
||||||
skip: sessionData.lastHit,
|
skip: sessionData.lastHit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -441,7 +441,7 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: this.resultsPerPage,
|
limit: this.resultsPerPage,
|
||||||
selector: JSON.parse(sessionData.selector),
|
selector: sessionData.getSelector(),
|
||||||
skip:
|
skip:
|
||||||
sessionData.lastHit - sessionData.resultsCount - this.resultsPerPage,
|
sessionData.lastHit - sessionData.resultsCount - this.resultsPerPage,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -104,3 +104,15 @@ code
|
||||||
|
|
||||||
.list-title
|
.list-title
|
||||||
background-color: darkgray
|
background-color: darkgray
|
||||||
|
|
||||||
|
.global-search-footer
|
||||||
|
border: none
|
||||||
|
width: 100%
|
||||||
|
|
||||||
|
.global-search-next-page
|
||||||
|
border: none
|
||||||
|
text-align: right;
|
||||||
|
|
||||||
|
.global-search-previous-page
|
||||||
|
border: none
|
||||||
|
text-align: left;
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ CardComments.textSearch = (userId, textArray) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('cardComments selector:', selector);
|
// console.log('cardComments selector:', selector);
|
||||||
|
|
||||||
const comments = CardComments.find(selector);
|
const comments = CardComments.find(selector);
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,40 @@ SessionData.attachSchema(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SessionData.helpers({
|
||||||
|
getSelector() {
|
||||||
|
return SessionData.unpickle(this.selector);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
SessionData.unpickle = pickle => {
|
||||||
|
return JSON.parse(pickle, (key, value) => {
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
if (value.hasOwnProperty('$$class')) {
|
||||||
|
if (value.$$class === 'RegExp') {
|
||||||
|
return new RegExp(value.source, value.flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SessionData.pickle = value => {
|
||||||
|
return JSON.stringify(value, (key, value) => {
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
if (value.constructor.name === 'RegExp') {
|
||||||
|
return {
|
||||||
|
$$class: 'RegExp',
|
||||||
|
source: value.source,
|
||||||
|
flags: value.flags,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (!Meteor.isServer) {
|
if (!Meteor.isServer) {
|
||||||
SessionData.getSessionId = () => {
|
SessionData.getSessionId = () => {
|
||||||
let sessionId = Session.get('sessionId');
|
let sessionId = Session.get('sessionId');
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,9 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
check(sessionId, String);
|
check(sessionId, String);
|
||||||
check(queryParams, Object);
|
check(queryParams, Object);
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log('queryParams:', queryParams);
|
||||||
|
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('userId:', userId);
|
// console.log('userId:', userId);
|
||||||
|
|
@ -338,6 +341,9 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!selector.swimlaneId.hasOwnProperty('swimlaneId')) {
|
||||||
|
selector.swimlaneId = { $in: [] };
|
||||||
|
}
|
||||||
selector.swimlaneId.$in = querySwimlanes;
|
selector.swimlaneId.$in = querySwimlanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,6 +362,9 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!selector.hasOwnProperty('listId')) {
|
||||||
|
selector.listId = { $in: [] };
|
||||||
|
}
|
||||||
selector.listId.$in = queryLists;
|
selector.listId.$in = queryLists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,9 +530,9 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('selector:', selector);
|
// console.log('selector:', selector);
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('selector.$and:', selector.$and);
|
// console.log('selector.$and:', selector.$and);
|
||||||
|
|
||||||
let cards = null;
|
let cards = null;
|
||||||
|
|
||||||
|
|
@ -585,11 +594,11 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('projection:', projection);
|
// console.log('projection:', projection);
|
||||||
cards = Cards.find(selector, projection);
|
cards = Cards.find(selector, projection);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('count:', cards.count());
|
// console.log('count:', cards.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
const update = {
|
const update = {
|
||||||
|
|
@ -599,7 +608,7 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
resultsCount: 0,
|
resultsCount: 0,
|
||||||
cards: [],
|
cards: [],
|
||||||
errors: errors.errorMessages(),
|
errors: errors.errorMessages(),
|
||||||
selector: JSON.stringify(selector),
|
selector: SessionData.pickle(selector),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue