feat(notes): let organizations define their own note fields
The note form was fixed. Owners can add fields and each note keeps those values. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,7 @@ export enum CustomFieldEntityDto {
|
||||
person = 'person',
|
||||
company = 'company',
|
||||
deal = 'deal',
|
||||
note = 'note',
|
||||
}
|
||||
|
||||
export enum CustomFieldTypeDto {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
IsDateString,
|
||||
IsIn,
|
||||
IsInt,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Max,
|
||||
@@ -171,6 +172,10 @@ export class CreateNoteDto {
|
||||
@ValidateIf((_, v) => v !== '' && v != null)
|
||||
@IsString()
|
||||
activityId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
customFields?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateNoteDto {
|
||||
@@ -248,6 +253,10 @@ export class UpdateNoteDto {
|
||||
@ValidateIf((_, v) => v !== '' && v != null)
|
||||
@IsString()
|
||||
activityId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
customFields?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
class NoteAiNextActionDtoClass {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { PrismaService } from '../prisma/prisma.service';
|
||||
import { buildSearchWhere, ci } from '../common/search';
|
||||
import { LocalFileStorage } from '../storage/local-file.storage';
|
||||
import { GamificationService } from '../gamification/gamification.service';
|
||||
import { asCustomFields, toJsonCustomFields } from '../common/custom-fields';
|
||||
import {
|
||||
type Actor,
|
||||
noteAccessWhere,
|
||||
@@ -45,6 +46,7 @@ type NoteRow = {
|
||||
checklist: Prisma.JsonValue | null;
|
||||
locationText: string | null;
|
||||
analyzeEnabled: boolean;
|
||||
customFields: Prisma.JsonValue;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
person: { id: string; firstName: string; lastName: string } | null;
|
||||
@@ -224,6 +226,7 @@ export class NotesService {
|
||||
: Prisma.JsonNull,
|
||||
locationText: emptyToNull(dto.locationText ?? null),
|
||||
analyzeEnabled,
|
||||
customFields: toJsonCustomFields(dto.customFields),
|
||||
personId: emptyToNull(dto.personId ?? null),
|
||||
companyId: emptyToNull(dto.companyId ?? null),
|
||||
dealId: emptyToNull(dto.dealId ?? null),
|
||||
@@ -280,6 +283,9 @@ export class NotesService {
|
||||
if (dto.analyzeEnabled !== undefined) {
|
||||
data.analyzeEnabled = dto.analyzeEnabled;
|
||||
}
|
||||
if ('customFields' in dto) {
|
||||
data.customFields = toJsonCustomFields(dto.customFields);
|
||||
}
|
||||
if ('personId' in dto) data.personId = emptyToNull(dto.personId ?? null);
|
||||
if ('companyId' in dto) data.companyId = emptyToNull(dto.companyId ?? null);
|
||||
if ('dealId' in dto) data.dealId = emptyToNull(dto.dealId ?? null);
|
||||
@@ -616,6 +622,7 @@ export class NotesService {
|
||||
checklist: parseChecklist(row.checklist),
|
||||
locationText: row.locationText ?? null,
|
||||
analyzeEnabled: row.analyzeEnabled ?? true,
|
||||
customFields: asCustomFields(row.customFields),
|
||||
person: row.person
|
||||
? {
|
||||
id: row.person.id,
|
||||
|
||||
Reference in New Issue
Block a user