mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Implement date pattern negating on the UI: #660
This commit is contained in:
parent
891c155cce
commit
a14c2ff45d
@ -45,6 +45,7 @@ export class MetadataLoader {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (const stream of data.streams) {
|
for (const stream of data.streams) {
|
||||||
|
console.log(stream);
|
||||||
if (stream.width) {
|
if (stream.width) {
|
||||||
metadata.size.width = stream.width;
|
metadata.size.width = stream.width;
|
||||||
metadata.size.height = stream.height;
|
metadata.size.height = stream.height;
|
||||||
|
@ -357,7 +357,8 @@ export class SearchQueryParser {
|
|||||||
|
|
||||||
if (kwStartsWith(str, this.keywords.sameDay) ||
|
if (kwStartsWith(str, this.keywords.sameDay) ||
|
||||||
new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.lastNDays) + '!?:').test(str)) {
|
new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.lastNDays) + '!?:').test(str)) {
|
||||||
const freqStr = str.slice(str.indexOf(':') + 1);
|
|
||||||
|
const freqStr = str.indexOf('!:') === -1 ? str.slice(str.indexOf(':') + 1) : str.slice(str.indexOf('!:') + 2);
|
||||||
let freq: DatePatternFrequency = null;
|
let freq: DatePatternFrequency = null;
|
||||||
let ago;
|
let ago;
|
||||||
if (freqStr == this.keywords.every_week) {
|
if (freqStr == this.keywords.every_week) {
|
||||||
@ -381,15 +382,16 @@ export class SearchQueryParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (freq) {
|
if (freq) {
|
||||||
const ret = {
|
return {
|
||||||
type: SearchQueryTypes.date_pattern,
|
type: SearchQueryTypes.date_pattern,
|
||||||
daysLength: kwStartsWith(str, this.keywords.sameDay) ? 0 : intFromRegexp(str),
|
daysLength: kwStartsWith(str, this.keywords.sameDay) ? 0 : intFromRegexp(str),
|
||||||
frequency: freq
|
frequency: freq,
|
||||||
|
...((new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.lastNDays) + '!:').test(str) ||
|
||||||
|
str.startsWith(this.keywords.sameDay + '!:')) && {
|
||||||
|
negate: true
|
||||||
|
}),
|
||||||
|
...(ago && {agoNumber: ago})
|
||||||
} as DatePatternSearch;
|
} as DatePatternSearch;
|
||||||
if (ago) {
|
|
||||||
ret.agoNumber = ago;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,6 +588,9 @@ export class SearchQueryParser {
|
|||||||
} else {
|
} else {
|
||||||
strBuilder += this.keywords.lastNDays.replace(/%d/g, q.daysLength.toString());
|
strBuilder += this.keywords.lastNDays.replace(/%d/g, q.daysLength.toString());
|
||||||
}
|
}
|
||||||
|
if (q.negate === true) {
|
||||||
|
strBuilder += '!';
|
||||||
|
}
|
||||||
strBuilder += ':';
|
strBuilder += ':';
|
||||||
switch (q.frequency) {
|
switch (q.frequency) {
|
||||||
case DatePatternFrequency.every_week:
|
case DatePatternFrequency.every_week:
|
||||||
|
@ -153,6 +153,12 @@ describe('SearchQueryParser', () => {
|
|||||||
frequency: DatePatternFrequency.years_ago,
|
frequency: DatePatternFrequency.years_ago,
|
||||||
agoNumber: 1
|
agoNumber: 1
|
||||||
} as DatePatternSearch);
|
} as DatePatternSearch);
|
||||||
|
check({
|
||||||
|
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||||
|
frequency: DatePatternFrequency.years_ago,
|
||||||
|
agoNumber: 1,
|
||||||
|
negate: true
|
||||||
|
} as DatePatternSearch);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('Default logical operator should be AND', () => {
|
it('Default logical operator should be AND', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user