mirror of
https://github.com/usememos/memos.git
synced 2025-02-21 21:57:47 +01:00
feat: add visibility filter (#461)
* feat: add visibility filter * update
This commit is contained in:
parent
cb50bbc3cb
commit
407d1cdcaa
@ -173,6 +173,8 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterIn
|
|||||||
const valueDataSource =
|
const valueDataSource =
|
||||||
type === "TYPE"
|
type === "TYPE"
|
||||||
? filterConsts["TYPE"].values.map(({ text, value }) => ({ text: t(text), value }))
|
? filterConsts["TYPE"].values.map(({ text, value }) => ({ text: t(text), value }))
|
||||||
|
: type === "VISIBILITY"
|
||||||
|
? filterConsts["VISIBILITY"].values.map(({ text, value }) => ({ text: t(text), value }))
|
||||||
: tags.sort().map((t) => {
|
: tags.sort().map((t) => {
|
||||||
return { text: t, value: t };
|
return { text: t, value: t };
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,34 @@ export const filterConsts = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
VISIBILITY: {
|
||||||
|
text: "Visibility",
|
||||||
|
value: "VISIBILITY",
|
||||||
|
operators: [
|
||||||
|
{
|
||||||
|
text: "filter.operator.is",
|
||||||
|
value: "IS",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "filter.operator.is-not",
|
||||||
|
value: "IS_NOT",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
text: "memo.visibility.public",
|
||||||
|
value: "PUBLIC",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "memo.visibility.protected",
|
||||||
|
value: "PROTECTED",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "memo.visibility.private",
|
||||||
|
value: "PRIVATE",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const memoSpecialTypes = filterConsts["TYPE"].values;
|
export const memoSpecialTypes = filterConsts["TYPE"].values;
|
||||||
@ -173,6 +201,12 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
|
|||||||
} else {
|
} else {
|
||||||
return memo.displayTs > dayjs(value).valueOf();
|
return memo.displayTs > dayjs(value).valueOf();
|
||||||
}
|
}
|
||||||
|
} else if (type === "VISIBILITY") {
|
||||||
|
let matched = memo.visibility === value;
|
||||||
|
if (operator === "IS_NOT") {
|
||||||
|
matched = !matched;
|
||||||
|
}
|
||||||
|
shouldShow = matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shouldShow;
|
return shouldShow;
|
||||||
|
12
web/src/types/filter.d.ts
vendored
12
web/src/types/filter.d.ts
vendored
@ -41,6 +41,14 @@ interface DisplayTimeFilter extends BaseFilter {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterType = "TEXT" | "TYPE" | "TAG" | "DISPLAY_TIME";
|
interface VisibilityFilter extends BaseFilter {
|
||||||
|
type: "VISIBILITY";
|
||||||
|
value: {
|
||||||
|
operator: "IS" | "IS_NOT";
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type Filter = BaseFilter | TagFilter | TypeFilter | TextFilter | DisplayTimeFilter;
|
type FilterType = "TEXT" | "TYPE" | "TAG" | "DISPLAY_TIME" | "VISIBILITY";
|
||||||
|
|
||||||
|
type Filter = BaseFilter | TagFilter | TypeFilter | TextFilter | DisplayTimeFilter | VisibilityFilter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user