@dhyasama/totem-models 6.11.4 → 6.11.6
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/Deal.js +8 -8
- package/lib/Organization.js +8 -208
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -21,15 +21,15 @@ module.exports = function(mongoose, config) {
|
|
|
21
21
|
|
|
22
22
|
reminder: { type: Date },
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
person: { type: Schema.ObjectId, ref: 'Person'
|
|
26
|
-
type: { type: String, trim: true
|
|
27
|
-
}
|
|
24
|
+
source: {
|
|
25
|
+
person: { type: Schema.ObjectId, ref: 'Person' },
|
|
26
|
+
type: { type: String, trim: true }
|
|
27
|
+
},
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
person: { type: Schema.ObjectId, ref: 'Person'
|
|
31
|
-
type: { type: String,
|
|
32
|
-
}
|
|
29
|
+
referrer: {
|
|
30
|
+
person: { type: Schema.ObjectId, ref: 'Person' },
|
|
31
|
+
type: { type: String, trim: true }
|
|
32
|
+
},
|
|
33
33
|
|
|
34
34
|
documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
|
|
35
35
|
|
package/lib/Organization.js
CHANGED
|
@@ -206,77 +206,14 @@ module.exports = function(mongoose, config) {
|
|
|
206
206
|
|
|
207
207
|
active: { type: Boolean, default: false },
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
stages: [{
|
|
210
210
|
name: { type: String, trim: true },
|
|
211
211
|
order: { type: Number },
|
|
212
212
|
active: { type: Boolean, default: true },
|
|
213
213
|
color: { type: String, trim: true }
|
|
214
214
|
}],
|
|
215
215
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
standardFields: {
|
|
219
|
-
|
|
220
|
-
// Standard fields are always "on" in the system
|
|
221
|
-
// They can be configured in how they work on the deal list page
|
|
222
|
-
// order for standard fields only sets the order on the list page. their position is fixed on the org page deal section and edit form.
|
|
223
|
-
// order is co-mingled with order for custom fields
|
|
224
|
-
// colspan is for the number of columns the field should take up on the list page
|
|
225
|
-
// showOnFilter controls whether values are extracted and used in filtering options on list page
|
|
226
|
-
// showOnList controls if the field will be on deal list page
|
|
227
|
-
|
|
228
|
-
action: {
|
|
229
|
-
order: { type: Number, default: 99 },
|
|
230
|
-
colspan: { type: Number, default: 1 },
|
|
231
|
-
showOnFilter: { type: Boolean, default: true },
|
|
232
|
-
showOnList: { type: Boolean, default: true }
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
raise: {
|
|
236
|
-
order: { type: Number, default: 99 },
|
|
237
|
-
colspan: { type: Number, default: 1 },
|
|
238
|
-
showOnFilter: { type: Boolean, default: true },
|
|
239
|
-
showOnList: { type: Boolean, default: true }
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
valuation: {
|
|
243
|
-
order: { type: Number, default: 99 },
|
|
244
|
-
colspan: { type: Number, default: 1 },
|
|
245
|
-
showOnFilter: { type: Boolean, default: true },
|
|
246
|
-
showOnList: { type: Boolean, default: true }
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
sources: {
|
|
250
|
-
order: { type: Number, default: 99 },
|
|
251
|
-
colspan: { type: Number, default: 1 },
|
|
252
|
-
showOnFilter: { type: Boolean, default: true },
|
|
253
|
-
showOnList: { type: Boolean, default: true }
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
sourceTypes: {
|
|
257
|
-
order: { type: Number, default: 99 },
|
|
258
|
-
colspan: { type: Number, default: 1 },
|
|
259
|
-
showOnFilter: { type: Boolean, default: true },
|
|
260
|
-
showOnList: { type: Boolean, default: true }
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
referrers: {
|
|
264
|
-
order: { type: Number, default: 99 },
|
|
265
|
-
colspan: { type: Number, default: 1 },
|
|
266
|
-
showOnFilter: { type: Boolean, default: true },
|
|
267
|
-
showOnList: { type: Boolean, default: true }
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
chairs: {
|
|
271
|
-
order: { type: Number, default: 99 },
|
|
272
|
-
colspan: { type: Number, default: 1 },
|
|
273
|
-
showOnFilter: { type: Boolean, default: true },
|
|
274
|
-
showOnList: { type: Boolean, default: true }
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
customFields: [{
|
|
216
|
+
fields: [{
|
|
280
217
|
|
|
281
218
|
// Data stored on deals will be accessed with this key
|
|
282
219
|
// It must follow standard js variable naming rules
|
|
@@ -285,6 +222,9 @@ module.exports = function(mongoose, config) {
|
|
|
285
222
|
// Changing it after data is in the system will make data on deal inaccessible
|
|
286
223
|
key: { type: String, trim: true },
|
|
287
224
|
|
|
225
|
+
// this sets whether the field is a custom field
|
|
226
|
+
isStandard: false,
|
|
227
|
+
|
|
288
228
|
// User friendly text, will be displayed
|
|
289
229
|
label: { type: String, trim: true },
|
|
290
230
|
|
|
@@ -316,13 +256,12 @@ module.exports = function(mongoose, config) {
|
|
|
316
256
|
// colspan is for the number of columns the field should take up on the list page
|
|
317
257
|
colspan: { type: Number, default: 1 },
|
|
318
258
|
|
|
259
|
+
// showOnList controls if the field will be on deal list page
|
|
260
|
+
showOnList: { type: Boolean, default: true },
|
|
261
|
+
|
|
319
262
|
// showOnFilter controls whether values are extracted and used in filtering options on list page
|
|
320
263
|
showOnFilter: { type: Boolean, default: true },
|
|
321
264
|
|
|
322
|
-
// showOnList controls if the field will be on deal list page
|
|
323
|
-
// fields are always shown on org pages and in edit forms
|
|
324
|
-
showOnList: { type: Boolean, default: true }
|
|
325
|
-
|
|
326
265
|
}
|
|
327
266
|
|
|
328
267
|
}]
|
|
@@ -520,145 +459,6 @@ module.exports = function(mongoose, config) {
|
|
|
520
459
|
|
|
521
460
|
});
|
|
522
461
|
|
|
523
|
-
Organization.virtual('customer.deals.fields').get(function () {
|
|
524
|
-
|
|
525
|
-
// Combine standard fields and custom fields into a single list and sort by column order
|
|
526
|
-
// Fundraise is actually two fields, so multiply the order by ten to make room for the extra field
|
|
527
|
-
|
|
528
|
-
var self = this;
|
|
529
|
-
|
|
530
|
-
var standardFields = self.customer.deals.standardFields;
|
|
531
|
-
|
|
532
|
-
// Defaulting to off so it will be immediately apparent the customer hasn't been properly configured
|
|
533
|
-
standardFields = standardFields || {
|
|
534
|
-
fundraise: {
|
|
535
|
-
showOnList: false
|
|
536
|
-
},
|
|
537
|
-
sources: {
|
|
538
|
-
showOnList: false
|
|
539
|
-
},
|
|
540
|
-
referrers: {
|
|
541
|
-
showOnList: false
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
var customFields = self.customer.deals.customFields;
|
|
546
|
-
var result = [];
|
|
547
|
-
|
|
548
|
-
// Add standard fields
|
|
549
|
-
if (standardFields.action.showOnList) {
|
|
550
|
-
result.push({
|
|
551
|
-
name: 'Next Steps',
|
|
552
|
-
type: 'Text',
|
|
553
|
-
key: 'action',
|
|
554
|
-
isStandard: true,
|
|
555
|
-
order: standardFields.action.order * 10,
|
|
556
|
-
colspan: standardFields.action.colspan || 1,
|
|
557
|
-
showOnFilter: standardFields.action.showOnFilter === true ? true : false
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if (standardFields.raise.showOnList) {
|
|
562
|
-
result.push({
|
|
563
|
-
name: 'Raise',
|
|
564
|
-
type: 'Money',
|
|
565
|
-
key: 'fundraise.amount',
|
|
566
|
-
isStandard: true,
|
|
567
|
-
order: standardFields.raise.order * 10,
|
|
568
|
-
colspan: standardFields.raise.colspan || 1,
|
|
569
|
-
showOnFilter: standardFields.raise.showOnFilter === true ? true : false
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if(standardFields.valuation.showOnList) {
|
|
574
|
-
result.push({
|
|
575
|
-
name: 'Valuation',
|
|
576
|
-
type: 'Money',
|
|
577
|
-
key: 'fundraise.valuation',
|
|
578
|
-
isStandard: true,
|
|
579
|
-
order: standardFields.valuation.order * 10 + 1,
|
|
580
|
-
colspan: standardFields.valuation.colspan || 1,
|
|
581
|
-
showOnFilter: standardFields.valuation.showOnFilter === true ? true : false
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
if (standardFields.sources.showOnList) {
|
|
586
|
-
result.push({
|
|
587
|
-
name: 'Sources',
|
|
588
|
-
type: 'Reference',
|
|
589
|
-
key: 'sources',
|
|
590
|
-
isStandard: true,
|
|
591
|
-
order: standardFields.sources.order * 10,
|
|
592
|
-
colspan: standardFields.sources.colspan || 1,
|
|
593
|
-
showOnFilter: standardFields.sources.showOnFilter === true ? true : false
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (standardFields.sourceTypes.showOnList) {
|
|
598
|
-
result.push({
|
|
599
|
-
name: 'Source Type',
|
|
600
|
-
type: 'Single Select',
|
|
601
|
-
key: 'sourceTypes',
|
|
602
|
-
isStandard: true,
|
|
603
|
-
order: standardFields.sourceTypes.order * 10,
|
|
604
|
-
colspan: standardFields.sourceTypes.colspan || 1,
|
|
605
|
-
showOnFilter: standardFields.sourceTypes.showOnFilter === true ? true : false
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
if (standardFields.referrers.showOnList) {
|
|
610
|
-
result.push({
|
|
611
|
-
name: 'Referrers',
|
|
612
|
-
type: 'Reference',
|
|
613
|
-
key: 'referrers',
|
|
614
|
-
isStandard: true,
|
|
615
|
-
order: standardFields.referrers.order * 10,
|
|
616
|
-
colspan: standardFields.referrers.colspan || 1,
|
|
617
|
-
showOnFilter: standardFields.referrers.showOnFilter === true ? true : false
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
if (standardFields.chairs.showOnList) {
|
|
622
|
-
result.push({
|
|
623
|
-
name: 'Leads',
|
|
624
|
-
type: 'Reference',
|
|
625
|
-
key: 'organization.chairs',
|
|
626
|
-
isStandard: true,
|
|
627
|
-
order: standardFields.chairs.order * 10,
|
|
628
|
-
colspan: standardFields.chairs.colspan || 1,
|
|
629
|
-
showOnFilter: standardFields.chairs.showOnFilter === true ? true : false
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// Add custom fields
|
|
634
|
-
_.each(customFields, function(field) {
|
|
635
|
-
if (field.display.showOnList) {
|
|
636
|
-
result.push({
|
|
637
|
-
name: field.label,
|
|
638
|
-
type: field.type,
|
|
639
|
-
isStandard: false,
|
|
640
|
-
key: field.key,
|
|
641
|
-
options: field.options,
|
|
642
|
-
order: field.display.order * 10,
|
|
643
|
-
colspan: field.display.colspan || 1,
|
|
644
|
-
showOnFilter: field.display.showOnFilter === true ? true : false
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
// Sort the combined standard and custom fields
|
|
650
|
-
result = _.sortBy(result, function(item) { return item.order; });
|
|
651
|
-
|
|
652
|
-
// Now that we have all fields combined and ordered, make column order zero-indexed and gap-free
|
|
653
|
-
result = _.map(result, function(item, index) {
|
|
654
|
-
item.order = index;
|
|
655
|
-
return item;
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
return result;
|
|
659
|
-
|
|
660
|
-
});
|
|
661
|
-
|
|
662
462
|
Organization.virtual('employees.all').get(function () {
|
|
663
463
|
|
|
664
464
|
var self = this;
|