@dhyasama/totem-models 11.70.0 → 11.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Interaction.js +1 -76
- package/lib/LimitedPartner.js +1 -2
- package/lib/Message.js +0 -77
- package/lib/Note.js +0 -2
- package/lib/Organization.js +3 -3
- package/lib/Person.js +1 -2
- package/package.json +1 -1
package/lib/Interaction.js
CHANGED
|
@@ -5,7 +5,6 @@ module.exports = function(mongoose, config) {
|
|
|
5
5
|
let Schema = mongoose.Schema;
|
|
6
6
|
let async = require('async');
|
|
7
7
|
let _ = require('underscore');
|
|
8
|
-
let Note = mongoose.model('Note');
|
|
9
8
|
let utilities = require('@dhyasama/totem-utilities');
|
|
10
9
|
let moment = require('moment');
|
|
11
10
|
let helpers = require('../helpers');
|
|
@@ -22,8 +21,7 @@ module.exports = function(mongoose, config) {
|
|
|
22
21
|
internal: [{ type: Schema.ObjectId, ref: 'Person', index: true }], // people from customer
|
|
23
22
|
external: [{ type: Schema.ObjectId, ref: 'Person', index: true }] // everyone else
|
|
24
23
|
},
|
|
25
|
-
|
|
26
|
-
documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
|
|
24
|
+
comments: { type: String, trim: true },
|
|
27
25
|
analysis: {
|
|
28
26
|
overview: { type: String },
|
|
29
27
|
notes: [{
|
|
@@ -47,17 +45,6 @@ module.exports = function(mongoose, config) {
|
|
|
47
45
|
|
|
48
46
|
///////////////////////////////////////
|
|
49
47
|
|
|
50
|
-
Interaction.statics.addNote = function(interactionId, creatorPersonId, text, isPrivate, customerId, cb) {
|
|
51
|
-
|
|
52
|
-
Note.createForModel({
|
|
53
|
-
createdBy: creatorPersonId,
|
|
54
|
-
text: text,
|
|
55
|
-
isPrivate: isPrivate,
|
|
56
|
-
customer: customerId
|
|
57
|
-
}, this, interactionId, cb);
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
48
|
Interaction.statics.delete = function(providerEventId, totemCustomerId, cb) {
|
|
62
49
|
|
|
63
50
|
if (!cb) { throw new Error('cb is required'); }
|
|
@@ -75,31 +62,6 @@ module.exports = function(mongoose, config) {
|
|
|
75
62
|
|
|
76
63
|
};
|
|
77
64
|
|
|
78
|
-
Interaction.statics.deleteNote = function(noteId, customerId, cb) {
|
|
79
|
-
|
|
80
|
-
// Delete the note itself along with any references
|
|
81
|
-
|
|
82
|
-
if (!cb) { throw new Error('cb is required'); }
|
|
83
|
-
if (!noteId) { return cb(new Error('noteId is required'), null); }
|
|
84
|
-
if (!mongoose.Types.ObjectId.isValid(noteId)) { return cb(new Error('noteId is not a valid ObjectId'), null); }
|
|
85
|
-
|
|
86
|
-
var self = this;
|
|
87
|
-
|
|
88
|
-
var removeReferences = function removeReferences(callback) {
|
|
89
|
-
self.updateMany({}, {
|
|
90
|
-
$pull: { 'notes' : [noteId] }
|
|
91
|
-
}, callback);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
async.series([
|
|
95
|
-
Note.delete.bind(Note, noteId, customerId),
|
|
96
|
-
removeReferences
|
|
97
|
-
], function(err, results) {
|
|
98
|
-
return cb(err, null);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
|
|
103
65
|
Interaction.statics.getById = function getById(id, options, cb) {
|
|
104
66
|
|
|
105
67
|
const self = this;
|
|
@@ -257,15 +219,6 @@ module.exports = function(mongoose, config) {
|
|
|
257
219
|
|
|
258
220
|
query.populate('attendees.internal', 'name title avatarUrl doNotDisplay');
|
|
259
221
|
query.populate('attendees.external', 'name title avatarUrl doNotDisplay');
|
|
260
|
-
query.populate({ path: 'notes', match: { customer: options.CUSTOMER_ID } });
|
|
261
|
-
|
|
262
|
-
query.deepPopulate([
|
|
263
|
-
'notes.createdBy'
|
|
264
|
-
], {
|
|
265
|
-
populate: {
|
|
266
|
-
'notes.createdBy': { select: 'name avatarUrl title' }
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
222
|
|
|
270
223
|
query.sort(options.sort);
|
|
271
224
|
|
|
@@ -419,34 +372,6 @@ module.exports = function(mongoose, config) {
|
|
|
419
372
|
|
|
420
373
|
};
|
|
421
374
|
|
|
422
|
-
Interaction.statics.getNotes = function getNotes(personIds, options, cb) {
|
|
423
|
-
|
|
424
|
-
if (!cb) { throw new Error('cb is required'); }
|
|
425
|
-
if (!personIds) { return cb(new Error('personIds is required'), null); }
|
|
426
|
-
if (!options) { return cb(new Error('options is required'), null); }
|
|
427
|
-
if (!options.CUSTOMER_ID) { return cb(new Error('CUSTOMER_ID is required'), null); }
|
|
428
|
-
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
429
|
-
|
|
430
|
-
var self = this;
|
|
431
|
-
var query = self.find({ totemCustomerId: options.CUSTOMER_ID });
|
|
432
|
-
|
|
433
|
-
query.where({'attendees.external': { $in : personIds }});
|
|
434
|
-
query.populate({
|
|
435
|
-
path: 'notes',
|
|
436
|
-
match: { customer: options.CUSTOMER_ID }
|
|
437
|
-
});
|
|
438
|
-
query.deepPopulate([
|
|
439
|
-
'notes.createdBy'
|
|
440
|
-
], {
|
|
441
|
-
populate: {
|
|
442
|
-
'notes.createdBy': { select: 'name avatarUrl title' }
|
|
443
|
-
}
|
|
444
|
-
})
|
|
445
|
-
query.sort(options.sort);
|
|
446
|
-
query.exec(cb);
|
|
447
|
-
|
|
448
|
-
};
|
|
449
|
-
|
|
450
375
|
Interaction.statics.modifyById = function(id, update, cb) {
|
|
451
376
|
|
|
452
377
|
// VERY IMPORTANT NOTE
|
package/lib/LimitedPartner.js
CHANGED
|
@@ -338,12 +338,11 @@ module.exports = function(mongoose, config) {
|
|
|
338
338
|
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
-
LimitedPartner.statics.addNote = function(lpid, creatorPersonId, text,
|
|
341
|
+
LimitedPartner.statics.addNote = function(lpid, creatorPersonId, text, customerId, cb) {
|
|
342
342
|
|
|
343
343
|
Note.createForModel({
|
|
344
344
|
createdBy: creatorPersonId,
|
|
345
345
|
text: text,
|
|
346
|
-
isPrivate: isPrivate,
|
|
347
346
|
customer: customerId
|
|
348
347
|
}, this, lpid, cb);
|
|
349
348
|
|
package/lib/Message.js
CHANGED
|
@@ -11,7 +11,6 @@ module.exports = function(mongoose, config) {
|
|
|
11
11
|
moment = require('moment'),
|
|
12
12
|
helpers = require('../helpers'),
|
|
13
13
|
Document = mongoose.model('Document'),
|
|
14
|
-
Note = mongoose.model('Note');
|
|
15
14
|
|
|
16
15
|
let Message = new Schema({
|
|
17
16
|
|
|
@@ -30,7 +29,6 @@ module.exports = function(mongoose, config) {
|
|
|
30
29
|
internal: [{ type: Schema.ObjectId, ref: 'Person', index: true }], // people from customer
|
|
31
30
|
external: [{ type: Schema.ObjectId, ref: 'Person', index: true }] // everyone else
|
|
32
31
|
},
|
|
33
|
-
notes: [ { type: Schema.ObjectId, ref: 'Note' } ],
|
|
34
32
|
documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
|
|
35
33
|
raw: { type: Schema.Types.Mixed, required: true },
|
|
36
34
|
messageDate: { type: Date, required: true },
|
|
@@ -52,16 +50,6 @@ module.exports = function(mongoose, config) {
|
|
|
52
50
|
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
Message.statics.addNote = function(messageId, creatorPersonId, text, isPrivate, cb) {
|
|
56
|
-
|
|
57
|
-
Note.createForModel({
|
|
58
|
-
createdBy: creatorPersonId,
|
|
59
|
-
text: text,
|
|
60
|
-
isPrivate: isPrivate
|
|
61
|
-
}, this, messageId, cb);
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
|
|
65
53
|
Message.statics.delete = function(messageId, customerId, cb) {
|
|
66
54
|
|
|
67
55
|
const self = this;
|
|
@@ -94,27 +82,6 @@ module.exports = function(mongoose, config) {
|
|
|
94
82
|
|
|
95
83
|
};
|
|
96
84
|
|
|
97
|
-
Message.statics.deleteNote = function(noteId, customerId, cb) {
|
|
98
|
-
|
|
99
|
-
// Delete the note itself along with any references
|
|
100
|
-
|
|
101
|
-
const self = this;
|
|
102
|
-
|
|
103
|
-
let removeReferences = function removeReferences(callback) {
|
|
104
|
-
self.updateMany({}, {
|
|
105
|
-
$pull: { 'notes' : [noteId] }
|
|
106
|
-
}, callback);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
async.series([
|
|
110
|
-
Note.delete.bind(Note, noteId, customerId),
|
|
111
|
-
removeReferences
|
|
112
|
-
], function(err, results) {
|
|
113
|
-
return cb(err, null);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
};
|
|
117
|
-
|
|
118
85
|
Message.statics.getDocuments = function getDocuments(personIds, options, cb) {
|
|
119
86
|
|
|
120
87
|
if (!cb) { throw new Error('cb is required'); }
|
|
@@ -160,10 +127,6 @@ module.exports = function(mongoose, config) {
|
|
|
160
127
|
query.populate('organization', 'name logoUrl');
|
|
161
128
|
query.populate('recipients.internal', 'name avatarUrl title doNotDisplay');
|
|
162
129
|
query.populate('recipients.external', 'name avatarUrl title doNotDisplay');
|
|
163
|
-
query.populate({
|
|
164
|
-
path: 'notes',
|
|
165
|
-
match: { customer: options.CUSTOMER_ID }
|
|
166
|
-
});
|
|
167
130
|
query.populate({
|
|
168
131
|
path: 'documents',
|
|
169
132
|
match: { customer: options.CUSTOMER_ID }
|
|
@@ -216,20 +179,14 @@ module.exports = function(mongoose, config) {
|
|
|
216
179
|
|
|
217
180
|
query.populate('recipients.internal', 'name title avatarUrl doNotDisplay');
|
|
218
181
|
query.populate('recipients.external', 'name title avatarUrl doNotDisplay');
|
|
219
|
-
query.populate({
|
|
220
|
-
path: 'notes',
|
|
221
|
-
match: { customer: options.CUSTOMER_ID }
|
|
222
|
-
});
|
|
223
182
|
query.populate({
|
|
224
183
|
path: 'documents',
|
|
225
184
|
match: { customer: options.CUSTOMER_ID }
|
|
226
185
|
});
|
|
227
186
|
query.deepPopulate([
|
|
228
|
-
'notes.createdBy',
|
|
229
187
|
'documents.createdBy'
|
|
230
188
|
], {
|
|
231
189
|
populate: {
|
|
232
|
-
'notes.createdBy': { select: 'name avatarUrl title' },
|
|
233
190
|
'documents.createdBy': { select: 'name avatarUrl title' }
|
|
234
191
|
}
|
|
235
192
|
});
|
|
@@ -353,20 +310,14 @@ module.exports = function(mongoose, config) {
|
|
|
353
310
|
query.where({'recipients.external': { $in : personIds }});
|
|
354
311
|
query.populate('recipients.internal', 'name title avatarUrl doNotDisplay');
|
|
355
312
|
query.populate('recipients.external', 'name title avatarUrl doNotDisplay');
|
|
356
|
-
query.populate({
|
|
357
|
-
path: 'notes',
|
|
358
|
-
match: { customer: options.CUSTOMER_ID }
|
|
359
|
-
});
|
|
360
313
|
query.populate({
|
|
361
314
|
path: 'documents',
|
|
362
315
|
match: { customer: options.CUSTOMER_ID }
|
|
363
316
|
});
|
|
364
317
|
query.deepPopulate([
|
|
365
|
-
'notes.createdBy',
|
|
366
318
|
'documents.createdBy'
|
|
367
319
|
], {
|
|
368
320
|
populate: {
|
|
369
|
-
'notes.createdBy': { select: 'name avatarUrl title' },
|
|
370
321
|
'documents.createdBy': { select: 'name avatarUrl title' }
|
|
371
322
|
}
|
|
372
323
|
});
|
|
@@ -394,34 +345,6 @@ module.exports = function(mongoose, config) {
|
|
|
394
345
|
|
|
395
346
|
};
|
|
396
347
|
|
|
397
|
-
Message.statics.getNotes = function getNotes(personIds, options, cb) {
|
|
398
|
-
|
|
399
|
-
if (!cb) { throw new Error('cb is required'); }
|
|
400
|
-
if (!personIds) { return cb(new Error('fundId is required'), null); }
|
|
401
|
-
if (!options) { return cb(new Error('options is required'), null); }
|
|
402
|
-
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
403
|
-
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
404
|
-
|
|
405
|
-
const self = this;
|
|
406
|
-
let query = self.find({ customer: options.CUSTOMER_ID });
|
|
407
|
-
|
|
408
|
-
query.where({'attendees.external': { $in : personIds }});
|
|
409
|
-
query.populate({
|
|
410
|
-
path: 'notes',
|
|
411
|
-
match: { customer: options.CUSTOMER_ID }
|
|
412
|
-
});
|
|
413
|
-
query.deepPopulate([
|
|
414
|
-
'notes.createdBy'
|
|
415
|
-
], {
|
|
416
|
-
populate: {
|
|
417
|
-
'notes.createdBy': { select: 'name avatarUrl title' }
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
query.exec(cb);
|
|
422
|
-
|
|
423
|
-
};
|
|
424
|
-
|
|
425
348
|
Message.statics.getUnprocessedDeals = function getUnprocessedDeals(customerId, cb) {
|
|
426
349
|
|
|
427
350
|
const self = this;
|
package/lib/Note.js
CHANGED
|
@@ -15,8 +15,6 @@ module.exports = function(mongoose, config) {
|
|
|
15
15
|
|
|
16
16
|
createdBy: { type: Schema.ObjectId, ref: 'Person', index: false, required: true },
|
|
17
17
|
|
|
18
|
-
isPrivate: { type: Boolean, default: false },
|
|
19
|
-
|
|
20
18
|
text: { type: String, index: false, required: true, trim: true }
|
|
21
19
|
|
|
22
20
|
});
|
package/lib/Organization.js
CHANGED
|
@@ -305,7 +305,8 @@ module.exports = function(mongoose, config) {
|
|
|
305
305
|
shared: [{ type: Schema.ObjectId, ref: 'Financials' }],
|
|
306
306
|
|
|
307
307
|
display: {
|
|
308
|
-
|
|
308
|
+
currency: { type: String, enum: ['customer', 'company'] },
|
|
309
|
+
timeframe: { type: String, enum: ['All Years', 'Last 12 Months'], default: 'All Years' },
|
|
309
310
|
},
|
|
310
311
|
|
|
311
312
|
emails: [{
|
|
@@ -1048,12 +1049,11 @@ module.exports = function(mongoose, config) {
|
|
|
1048
1049
|
|
|
1049
1050
|
};
|
|
1050
1051
|
|
|
1051
|
-
Organization.statics.addNote = function(organizationId, creatorPersonId, text,
|
|
1052
|
+
Organization.statics.addNote = function(organizationId, creatorPersonId, text, customerId, cb) {
|
|
1052
1053
|
|
|
1053
1054
|
Note.createForModel({
|
|
1054
1055
|
createdBy: creatorPersonId,
|
|
1055
1056
|
text: text,
|
|
1056
|
-
isPrivate: isPrivate,
|
|
1057
1057
|
customer: customerId
|
|
1058
1058
|
}, this, organizationId, cb);
|
|
1059
1059
|
|
package/lib/Person.js
CHANGED
|
@@ -305,12 +305,11 @@ module.exports = function(mongoose, config) {
|
|
|
305
305
|
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
Person.statics.addNote = function(personId, creatorPersonId, text,
|
|
308
|
+
Person.statics.addNote = function(personId, creatorPersonId, text, customerId, cb) {
|
|
309
309
|
|
|
310
310
|
Note.createForModel({
|
|
311
311
|
createdBy: creatorPersonId,
|
|
312
312
|
text: text,
|
|
313
|
-
isPrivate: isPrivate,
|
|
314
313
|
customer: customerId
|
|
315
314
|
}, this, personId, cb);
|
|
316
315
|
|