Add personal/team note visibility and edit history.
Notes can be marked personal or team, with revision snapshots and restore from the notes UI.
This commit is contained in:
@@ -61,18 +61,30 @@ export function assigneeWhere(
|
||||
return { assigneeId: { in: ids } };
|
||||
}
|
||||
|
||||
/** یادداشت: نویسنده یا پروندههای تحت مالکیت در محدوده دید */
|
||||
/** یادداشت: نویسنده یا پروندههای تحت مالکیت در محدوده دید + محرمانگی شخصی */
|
||||
export function noteAccessWhere(
|
||||
actor: Pick<Actor, 'userId' | 'role' | 'dataVisibility' | 'visibleUserIds'>,
|
||||
): Prisma.NoteWhereInput {
|
||||
const ids = scopedOwnerIds(actor);
|
||||
if (!ids) return {};
|
||||
return {
|
||||
const personalGate: Prisma.NoteWhereInput = {
|
||||
OR: [
|
||||
{ authorId: { in: ids } },
|
||||
{ deal: { ownerId: { in: ids } } },
|
||||
{ person: { ownerId: { in: ids } } },
|
||||
{ company: { ownerId: { in: ids } } },
|
||||
{ visibility: { not: 'personal' } },
|
||||
{ visibility: 'personal', authorId: actor.userId },
|
||||
// رکوردهای قدیمی بدون فیلد visibility در DB با default team میآیند
|
||||
],
|
||||
};
|
||||
if (!ids) return personalGate;
|
||||
return {
|
||||
AND: [
|
||||
personalGate,
|
||||
{
|
||||
OR: [
|
||||
{ authorId: { in: ids } },
|
||||
{ deal: { ownerId: { in: ids } } },
|
||||
{ person: { ownerId: { in: ids } } },
|
||||
{ company: { ownerId: { in: ids } } },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user