Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Commit

Permalink
feat(deal/ticket/task): Add watch option for deal, ticket, task and p…
Browse files Browse the repository at this point in the history
…ipeline

Closes erxes/erxes#1013
  • Loading branch information
munkhjin0223 committed Jul 8, 2019
1 parent 416fe74 commit 1956ec1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 121 deletions.
44 changes: 44 additions & 0 deletions boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ interface ICommonFields {
type: string;
}

export interface IItemCommonFields {
name?: string;
companyIds?: string[];
customerIds?: string[];
closeDate?: Date;
description?: string;
assignedUserIds?: string[];
watchedUserIds?: string[];
notifiedUserIds?: string[];
stageId?: string;
initialStageId?: string;
modifiedAt?: Date;
modifiedBy?: string;
userId?: string;
createdAt?: Date;
order?: number;
}

export interface IBoard extends ICommonFields {
name?: string;
isDefault?: boolean;
Expand All @@ -24,6 +42,7 @@ export interface IPipeline extends ICommonFields {
visibility?: string;
memberIds?: string[];
bgColor?: string;
watchedUserIds?: string[];
}

export interface IPipelineDocument extends IPipeline, Document {
Expand Down Expand Up @@ -60,6 +79,30 @@ const commonFieldsSchema = {
}),
};

export const commonItemFieldsSchema = {
_id: field({ pkey: true }),
userId: field({ type: String }),
createdAt: field({
type: Date,
default: new Date(),
}),
order: field({ type: Number }),
name: field({ type: String }),
companyIds: field({ type: [String] }),
customerIds: field({ type: [String] }),
closeDate: field({ type: Date }),
description: field({ type: String, optional: true }),
assignedUserIds: field({ type: [String] }),
watchedUserIds: field({ type: [String] }),
stageId: field({ type: String, optional: true }),
initialStageId: field({ type: String, optional: true }),
modifiedAt: field({
type: Date,
default: new Date(),
}),
modifiedBy: field({ type: String }),
};

export const boardSchema = new Schema({
_id: field({ pkey: true }),
name: field({ type: String }),
Expand All @@ -79,6 +122,7 @@ export const pipelineSchema = new Schema({
enum: PIPELINE_VISIBLITIES.ALL,
default: PIPELINE_VISIBLITIES.PUBLIC,
}),
watchedUserIds: field({ type: [String] }),
memberIds: field({ type: [String] }),
bgColor: field({ type: String }),
...commonFieldsSchema,
Expand Down
46 changes: 5 additions & 41 deletions deals.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Document, Schema } from 'mongoose';
import { field } from '../utils';
import { commonItemFieldsSchema, IItemCommonFields } from './boards';
import { PRODUCT_TYPES } from './constants';

interface ICommonFields {
userId?: string;
createdAt?: Date;
order?: number;
}

export interface IProduct {
name: string;
type?: string;
Expand All @@ -34,33 +29,15 @@ interface IProductData extends Document {
amount?: number;
}

export interface IDeal extends ICommonFields {
name?: string;
export interface IDeal extends IItemCommonFields {
productsData?: IProductData[];
companyIds?: string[];
customerIds?: string[];
closeDate?: Date;
description?: string;
assignedUserIds?: string[];
stageId?: string;
initialStageId?: string;
modifiedAt?: Date;
modifiedBy?: string;
}

export interface IDealDocument extends IDeal, ICommonFields, Document {
export interface IDealDocument extends IDeal, Document {
_id: string;
}

// Mongoose schemas =======================
const commonFieldsSchema = {
userId: field({ type: String }),
createdAt: field({
type: Date,
default: new Date(),
}),
order: field({ type: Number }),
};

export const productSchema = new Schema({
_id: field({ pkey: true }),
Expand Down Expand Up @@ -96,20 +73,7 @@ const productDataSchema = new Schema(
);

export const dealSchema = new Schema({
_id: field({ pkey: true }),
name: field({ type: String }),
...commonItemFieldsSchema,

productsData: field({ type: [productDataSchema] }),
companyIds: field({ type: [String] }),
customerIds: field({ type: [String] }),
closeDate: field({ type: Date }),
description: field({ type: String, optional: true }),
assignedUserIds: field({ type: [String] }),
stageId: field({ type: String, optional: true }),
initialStageId: field({ type: String, optional: true }),
modifiedAt: field({
type: Date,
default: new Date(),
}),
modifiedBy: field({ type: String }),
...commonFieldsSchema,
});
45 changes: 5 additions & 40 deletions tasks.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,18 @@
import { Document, Schema } from 'mongoose';
import { field } from '../utils';
import { commonItemFieldsSchema, IItemCommonFields } from './boards';

interface ICommonFields {
userId?: string;
createdAt?: Date;
order?: number;
}

export interface ITask extends ICommonFields {
name?: string;
companyIds?: string[];
customerIds?: string[];
closeDate?: Date;
description?: string;
assignedUserIds?: string[];
stageId?: string;
export interface ITask extends IItemCommonFields {
priority?: string;
modifiedAt?: Date;
modifiedBy?: string;
}

export interface ITaskDocument extends ITask, ICommonFields, Document {
export interface ITaskDocument extends ITask, Document {
_id: string;
}

// Mongoose schemas =======================
const commonFieldsSchema = {
userId: field({ type: String }),
createdAt: field({
type: Date,
default: new Date(),
}),
order: field({ type: Number }),
};

export const taskSchema = new Schema({
_id: field({ pkey: true }),
name: field({ type: String }),
companyIds: field({ type: [String] }),
customerIds: field({ type: [String] }),
closeDate: field({ type: Date }),
description: field({ type: String, optional: true }),
assignedUserIds: field({ type: [String] }),
stageId: field({ type: String, optional: true }),
...commonItemFieldsSchema,

priority: field({ type: String, optional: true }),
modifiedAt: field({
type: Date,
default: new Date(),
}),
modifiedBy: field({ type: String }),
...commonFieldsSchema,
});
45 changes: 5 additions & 40 deletions tickets.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
import { Document, Schema } from 'mongoose';
import { field } from '../utils';
import { commonItemFieldsSchema, IItemCommonFields } from './boards';

interface ICommonFields {
userId?: string;
createdAt?: Date;
order?: number;
}

export interface ITicket extends ICommonFields {
name?: string;
companyIds?: string[];
customerIds?: string[];
closeDate?: Date;
description?: string;
export interface ITicket extends IItemCommonFields {
priority?: string;
source?: string;
assignedUserIds?: string[];
stageId?: string;
modifiedAt?: Date;
modifiedBy?: string;
}

export interface ITicketDocument extends ITicket, ICommonFields, Document {
export interface ITicketDocument extends ITicket, Document {
_id: string;
}

// Mongoose schemas =======================
const commonFieldsSchema = {
userId: field({ type: String }),
createdAt: field({
type: Date,
default: new Date(),
}),
order: field({ type: Number }),
};

export const ticketSchema = new Schema({
_id: field({ pkey: true }),
name: field({ type: String }),
companyIds: field({ type: [String] }),
customerIds: field({ type: [String] }),
closeDate: field({ type: Date }),
description: field({ type: String, optional: true }),
assignedUserIds: field({ type: [String] }),
stageId: field({ type: String, optional: true }),
modifiedAt: field({
type: Date,
default: new Date(),
}),
modifiedBy: field({ type: String }),
...commonItemFieldsSchema,

priority: field({ type: String }),
source: field({ type: String }),
...commonFieldsSchema,
});

0 comments on commit 1956ec1

Please sign in to comment.