mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
Merge pull request #918 from janLo/feature/caldav-category-filter
feat(issues): Add ability to filter caldav issues by category.
This commit is contained in:
commit
d6c937f51c
5 changed files with 18 additions and 5 deletions
|
|
@ -186,12 +186,12 @@ export class CaldavClientService {
|
|||
}
|
||||
|
||||
getOpenTasks$(cfg: CaldavCfg): Observable<CaldavIssue[]> {
|
||||
return from(this._getTasks(cfg, true)).pipe(
|
||||
return from(this._getTasks(cfg, true, true)).pipe(
|
||||
catchError((err) => throwError({[HANDLED_ERROR_PROP_STR]: 'Caldav: ' + err})));
|
||||
}
|
||||
|
||||
searchOpenTasks$(text: string, cfg: CaldavCfg): Observable<SearchResultItem[]> {
|
||||
return from(this._getTasks(cfg, true)
|
||||
return from(this._getTasks(cfg, true, true)
|
||||
.then(tasks =>
|
||||
tasks.filter(todo => todo.summary.includes(text))
|
||||
.map(todo => {
|
||||
|
|
@ -215,7 +215,7 @@ export class CaldavClientService {
|
|||
}
|
||||
|
||||
getByIds$(ids: string[], cfg: CaldavCfg): Observable<CaldavIssue[]> {
|
||||
return from(this._getTasks(cfg, false)
|
||||
return from(this._getTasks(cfg, false, false)
|
||||
.then(tasks => tasks
|
||||
.filter(task => task.id in ids))).pipe(
|
||||
catchError((err) => throwError({[HANDLED_ERROR_PROP_STR]: 'Caldav: ' + err})));
|
||||
|
|
@ -264,10 +264,11 @@ export class CaldavClientService {
|
|||
}
|
||||
}
|
||||
|
||||
private async _getTasks(cfg: CaldavCfg, filterOpen: boolean): Promise<CaldavIssue[]> {
|
||||
private async _getTasks(cfg: CaldavCfg, filterOpen: boolean, filterCategory: boolean): Promise<CaldavIssue[]> {
|
||||
const cal = await this._getCalendar(cfg);
|
||||
const tasks = await CaldavClientService._getAllTodos(cal, filterOpen).catch((err: any) => this._handleNetErr(err));
|
||||
return tasks.map((t: any) => CaldavClientService._mapTask(t));
|
||||
return tasks.map((t: any) => CaldavClientService._mapTask(t))
|
||||
.filter((t: CaldavIssue) => !filterCategory || !cfg.categoryFilter || (t.labels.includes(cfg.categoryFilter)));
|
||||
}
|
||||
|
||||
private async _getTask(cfg: CaldavCfg, uid: string): Promise<CaldavIssue> {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export const DEFAULT_CALDAV_CFG: CaldavCfg = {
|
|||
isAutoPoll: false,
|
||||
isSearchIssuesFromCaldav: true,
|
||||
isTransitionIssuesEnabled: false,
|
||||
categoryFilter: null,
|
||||
};
|
||||
|
||||
export const CALDAV_POLL_INTERVAL = 10 * 60 * 1000;
|
||||
|
|
@ -87,6 +88,14 @@ export const CALDAV_CONFIG_FORM: LimitedFormlyFieldConfig<CaldavCfg>[] = [
|
|||
label: T.F.CALDAV.FORM.IS_TRANSITION_ISSUES_ENABLED
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'categoryFilter',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: T.F.CALDAV.FORM.CALDAV_CATEGORY_FILTER,
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const CALDAV_CONFIG_FORM_SECTION: ConfigFormSection<CaldavCfg> = {
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ export interface CaldavCfg {
|
|||
isAutoPoll: boolean;
|
||||
isSearchIssuesFromCaldav: boolean;
|
||||
isTransitionIssuesEnabled: boolean;
|
||||
categoryFilter: string | null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ const T = {
|
|||
CALDAV_RESOURCE: 'F.CALDAV.FORM.CALDAV_RESOURCE',
|
||||
CALDAV_USER: 'F.CALDAV.FORM.CALDAV_USER',
|
||||
CALDAV_PASSWORD: 'F.CALDAV.FORM.CALDAV_PASSWORD',
|
||||
CALDAV_CATEGORY_FILTER: 'F.CALDAV.FORM.CALDAV_CATEGORY_FILTER',
|
||||
IS_AUTO_ADD_TO_BACKLOG: 'F.CALDAV.FORM.IS_AUTO_ADD_TO_BACKLOG',
|
||||
IS_AUTO_POLL: 'F.CALDAV.FORM.IS_AUTO_POLL',
|
||||
IS_SEARCH_ISSUES_FROM_CALDAV: 'F.CALDAV.FORM.IS_SEARCH_ISSUES_FROM_CALDAV',
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@
|
|||
"CALDAV_RESOURCE": "The name of the CalDav resource (the calendar)",
|
||||
"CALDAV_USER": "Your CalDav username",
|
||||
"CALDAV_PASSWORD": "Your CalDav password",
|
||||
"CALDAV_CATEGORY_FILTER": "Category to filter issues for (leave empty for none)",
|
||||
"IS_AUTO_ADD_TO_BACKLOG": "Automatically add uncompleted CalDav todos to your backlog",
|
||||
"IS_AUTO_POLL": "Automatically poll imported tasks for changes",
|
||||
"IS_SEARCH_ISSUES_FROM_CALDAV": "Show uncompleted CalDav todos as suggestion when adding new tasks",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue