Activated search subfolders as request by #154

This commit is contained in:
djmaze 2021-11-03 02:28:01 +01:00
parent b1038667ee
commit 6c797c34f8
51 changed files with 1024 additions and 874 deletions

View file

@ -6,6 +6,7 @@ import { MessageUserStore } from 'Stores/User/Message';
import { decorateKoCommands } from 'Knoin/Knoin';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
import { FolderUserStore } from 'Stores/User/Folder';
class AdvancedSearchPopupView extends AbstractViewPopup {
constructor() {
@ -17,12 +18,15 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
subject: '',
text: '',
selectedDateValue: -1,
selectedTreeValue: '',
hasAttachment: false,
starred: false,
unseen: false
});
this.showMultisearch = ko.computed(() => FolderUserStore.hasCapability('MULTISEARCH'));
let prefix = 'SEARCH/LABEL_ADV_DATE_';
this.selectedDates = ko.computed(() => {
translatorTrigger();
@ -37,6 +41,16 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
];
});
prefix = 'SEARCH/LABEL_ADV_SUBFOLDERS_';
this.selectedTree = ko.computed(() => {
translatorTrigger();
return [
{ id: '', name: i18n(prefix + 'NONE') },
{ id: 'subtree-one', name: i18n(prefix + 'SUBTREE_ONE') },
{ id: 'subtree', name: i18n(prefix + 'SUBTREE') }
];
});
decorateKoCommands(this, {
searchCommand: 1
});
@ -69,65 +83,54 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
});
}
buildSearchStringValue(value) {
if (value.includes(' ')) {
value = '"' + value + '"';
}
return value;
}
buildSearchString() {
const result = [],
from_ = this.from().trim(),
to = this.to().trim(),
subject = this.subject().trim(),
text = this.text().trim(),
isPart = [],
hasPart = [];
const
result = new FormData();
if (from_) {
result.push('from:' + this.buildSearchStringValue(from_));
let value = this.from().trim();
if (value) {
result.set('from', value);
}
if (to) {
result.push('to:' + this.buildSearchStringValue(to));
value = this.to().trim();
if (value) {
result.set('to', value);
}
if (subject) {
result.push('subject:' + this.buildSearchStringValue(subject));
value = this.subject().trim();
if (value) {
result.set('subject', value);
}
if (this.hasAttachment()) {
hasPart.push('attachment');
result.set('has', 'attachment');
}
if (this.unseen()) {
isPart.push('unseen');
result.set('is[]', 'unseen');
}
if (this.starred()) {
isPart.push('flagged');
}
if (hasPart.length) {
result.push('has:' + hasPart.join(','));
}
if (isPart.length) {
result.push('is:' + isPart.join(','));
result.set('is[]', 'flagged');
}
if (-1 < this.selectedDateValue()) {
let d = new Date();
d.setDate(d.getDate() - this.selectedDateValue());
result.push('date:' + d.format('Y.m.d') + '/');
result.set('date', d.format('Y.m.d') + '/');
}
if (text) {
result.push('text:' + this.buildSearchStringValue(text));
value = this.selectedTreeValue();
if (value) {
result.set('in', value);
}
return result.join(' ').trim();
value = this.text().trim();
if (value) {
result.set('text', value);
}
return new URLSearchParams(result).toString();
}
clearPopup() {

View file

@ -64,7 +64,9 @@ export class MailMessageList extends AbstractViewRight {
this.messageList = MessageUserStore.list;
this.sortSupported = FolderUserStore.sortSupported;
this.sortSupported = ko.computed(() =>
FolderUserStore.hasCapability('SORT') | FolderUserStore.hasCapability('ESORT')
);
this.composeInEdit = AppUserStore.composeInEdit;
this.leftPanelDisabled = leftPanelDisabled;