@dhyasama/totem-models 6.11.5 → 6.11.7

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 CHANGED
@@ -21,15 +21,15 @@ module.exports = function(mongoose, config) {
21
21
 
22
22
  reminder: { type: Date },
23
23
 
24
- sources: [{
25
- person: { type: Schema.ObjectId, ref: 'Person', required: true },
26
- type: { type: String, trim: true, required: true }
27
- }],
24
+ source: {
25
+ person: { type: Schema.ObjectId, ref: 'Person' },
26
+ type: { type: String, trim: true }
27
+ },
28
28
 
29
- referrers: [{
30
- person: { type: Schema.ObjectId, ref: 'Person', required: true },
31
- type: { type: String, enum: ['Founder', 'Investor', 'Service Provider', 'Friends & Family', 'Limited Partner', 'Other'], required: true }
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
 
@@ -206,77 +206,14 @@ module.exports = function(mongoose, config) {
206
206
 
207
207
  active: { type: Boolean, default: false },
208
208
 
209
- statuses: [{
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
- sourceTypes: [ { type: String, trim: true } ],
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
  }]
@@ -511,151 +450,12 @@ module.exports = function(mongoose, config) {
511
450
  // Deals aren't on for customer
512
451
  else if (!self.customer.deals.active) return [];
513
452
 
514
- // Get active status names and sort them
515
- var statuses = _.filter(self.customer.deals.statuses, function(s) { return s.active; });
516
- statuses = _.sortBy(statuses, 'order');
517
- statuses = _.pluck(statuses, 'name');
518
-
519
- return statuses;
520
-
521
- });
522
-
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 Types',
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
- }
453
+ // Get active stage names and sort them
454
+ var stages = _.filter(self.customer.deals.stages, function(s) { return s.active; });
455
+ stages = _.sortBy(stages, 'order');
456
+ stages = _.pluck(stages, 'name');
608
457
 
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;
458
+ return stages;
659
459
 
660
460
  });
661
461
 
@@ -955,10 +755,10 @@ module.exports = function(mongoose, config) {
955
755
  if (err) return callback(err, null);
956
756
  else if (!org) return callback(new Error('Customer not found'), null);
957
757
 
958
- var statuses = org.customer.deals.activeStatuses;
758
+ var stages = org.customer.deals.activeStatuses;
959
759
 
960
- var match = _.find(statuses, function(status) {
961
- return status == previous.deal.stage;
760
+ var match = _.find(stages, function(stage) {
761
+ return stage == previous.deal.stage;
962
762
  });
963
763
 
964
764
  if (!match) return callback(new Error('This stage is not valid for this customer'), null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "6.11.5",
3
+ "version": "6.11.7",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",