@dhyasama/totem-models 6.3.6 → 6.3.8

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.
@@ -215,8 +215,8 @@ module.exports = function(mongoose, config) {
215
215
 
216
216
  standardFields: {
217
217
 
218
- // active set to false will keep the field out of system for customer, i.e., off list page, org page deal section and deal edit form
219
- // if a field is active, it will show up on the org page deal section and deal edit form. there is no way to hide it in those places.
218
+ // Standard fields are always "on" in the system
219
+ // They can be configured in how they work on the deal list page
220
220
  // 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.
221
221
  // order is co-mingled with order for custom fields
222
222
  // colspan is for the number of columns the field should take up on the list page
@@ -224,7 +224,6 @@ module.exports = function(mongoose, config) {
224
224
  // showOnList controls if the field will be on deal list page
225
225
 
226
226
  fundraise: {
227
- active: { type: Boolean, default: true },
228
227
  order: { type: Number, default: 99 },
229
228
  colspan: { type: Number, default: 1 },
230
229
  showOnFilter: { type: Boolean, default: true },
@@ -232,7 +231,6 @@ module.exports = function(mongoose, config) {
232
231
  },
233
232
 
234
233
  sources: {
235
- active: { type: Boolean, default: true },
236
234
  order: { type: Number, default: 99 },
237
235
  colspan: { type: Number, default: 1 },
238
236
  showOnFilter: { type: Boolean, default: true },
@@ -240,7 +238,6 @@ module.exports = function(mongoose, config) {
240
238
  },
241
239
 
242
240
  referrers: {
243
- active: { type: Boolean, default: true },
244
241
  order: { type: Number, default: 99 },
245
242
  colspan: { type: Number, default: 1 },
246
243
  showOnFilter: { type: Boolean, default: true },
@@ -248,7 +245,6 @@ module.exports = function(mongoose, config) {
248
245
  },
249
246
 
250
247
  resources: {
251
- active: { type: Boolean, default: true },
252
248
  order: { type: Number, default: 99 },
253
249
  colspan: { type: Number, default: 1 },
254
250
  showOnFilter: { type: Boolean, default: true },
@@ -282,7 +278,7 @@ module.exports = function(mongoose, config) {
282
278
  // This is the value that gets stored
283
279
  value: { type: String, trim: true, required: true },
284
280
 
285
- // This is used to validate and aggregate answers for polls
281
+ // This is used to aggregate answers for polls
286
282
  type: { type: String, enum: ['String', 'Number', 'Boolean'], required: true }
287
283
 
288
284
  }],
@@ -501,11 +497,10 @@ module.exports = function(mongoose, config) {
501
497
 
502
498
  });
503
499
 
504
- Organization.virtual('customer.deals.columns').get(function () {
500
+ Organization.virtual('customer.deals.fields').get(function () {
505
501
 
506
502
  // Combine ever-present fields, standard fields and custom fields into a single list and sort by column order
507
503
  // Fundraise is actually two fields, so multiply the order by ten to make room for the extra field
508
- // Returns tuples of name/order
509
504
 
510
505
  var self = this;
511
506
 
@@ -514,15 +509,12 @@ module.exports = function(mongoose, config) {
514
509
  // Defaulting to off so it will be immediately apparent the customer hasn't been properly configured
515
510
  standardFields = standardFields || {
516
511
  fundraise: {
517
- active: false,
518
512
  showOnList: false
519
513
  },
520
514
  sources: {
521
- active: false,
522
515
  showOnList: false
523
516
  },
524
517
  referrers: {
525
- active: false,
526
518
  showOnList: false
527
519
  }
528
520
  };
@@ -531,28 +523,33 @@ module.exports = function(mongoose, config) {
531
523
  var result = [];
532
524
 
533
525
  // Add the standard fields that are active
534
- if (standardFields.fundraise.active && standardFields.fundraise.showOnList) {
526
+ if (standardFields.fundraise.showOnList) {
535
527
  result.push({
536
528
  name: 'Fundraise Amount',
529
+ type: 'Standard',
537
530
  order: standardFields.fundraise.order * 10,
538
- colspan: standardFields.fundraise.colspan
531
+ colspan: standardFields.fundraise.colspan,
539
532
  }, {
540
533
  name: 'Fundraise Valuation',
541
- order: standardFields.fundraise.order * 10 + 1
534
+ type: 'Standard',
535
+ order: standardFields.fundraise.order * 10 + 1,
536
+ colspan: standardFields.fundraise.colspan
542
537
  });
543
538
  }
544
539
 
545
- if (standardFields.sources.active && standardFields.sources.showOnList) {
540
+ if (standardFields.sources.showOnList) {
546
541
  result.push({
547
542
  name: 'Source',
543
+ type: 'Standard',
548
544
  order: standardFields.sources.order * 10,
549
545
  colspan: standardFields.fundraise.colspan
550
546
  });
551
547
  }
552
548
 
553
- if (standardFields.referrers.active && standardFields.referrers.showOnList) {
549
+ if (standardFields.referrers.showOnList) {
554
550
  result.push({
555
551
  name: 'Referrers',
552
+ type: 'Standard',
556
553
  order: standardFields.referrers.order * 10,
557
554
  colspan: standardFields.fundraise.colspan
558
555
  });
@@ -563,6 +560,8 @@ module.exports = function(mongoose, config) {
563
560
  if (field.display.showOnList) {
564
561
  result.push({
565
562
  name: field.label,
563
+ type: field.type,
564
+ key: field.key,
566
565
  order: field.display.order * 10,
567
566
  colspan: field.display.colspan
568
567
  });
@@ -572,15 +571,6 @@ module.exports = function(mongoose, config) {
572
571
  // Sort the combined standard and custom fields
573
572
  result = _.sortBy(result, function(item) { return item.order; });
574
573
 
575
- // Put the ever-present fields at the beginning
576
- result.unshift({
577
- name: 'Company',
578
- order: 0
579
- }, {
580
- name: 'Stage',
581
- order: 1
582
- });
583
-
584
574
  // Now that we have all fields combined and ordered, make column order zero-indexed and gap-free
585
575
  result = _.map(result, function(item, index) {
586
576
  item.order = index;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "6.3.6",
3
+ "version": "6.3.8",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -1188,20 +1188,16 @@ describe('Organization', function() {
1188
1188
 
1189
1189
  it('gets deal columns for a customer', function(done) {
1190
1190
 
1191
- var columns = customer1.customer.deals.columns;
1192
- columns.length.should.equal(6);
1193
- columns[0].name.should.equal('Company');
1194
- columns[0].order.should.equal(0);
1195
- columns[1].name.should.equal('Stage');
1196
- columns[1].order.should.equal(1);
1197
- columns[2].name.should.equal('Test Field 2');
1198
- columns[2].order.should.equal(2);
1199
- columns[3].name.should.equal('Fundraise Amount');
1200
- columns[3].order.should.equal(3);
1201
- columns[4].name.should.equal('Fundraise Valuation');
1202
- columns[4].order.should.equal(4);
1203
- columns[5].name.should.equal('Test Field Last');
1204
- columns[5].order.should.equal(5);
1191
+ var fields = customer1.customer.deals.fields;
1192
+ fields.length.should.equal(4);
1193
+ fields[0].name.should.equal('Test Field 2');
1194
+ fields[0].order.should.equal(0);
1195
+ fields[1].name.should.equal('Fundraise Amount');
1196
+ fields[1].order.should.equal(1);
1197
+ fields[2].name.should.equal('Fundraise Valuation');
1198
+ fields[2].order.should.equal(2);
1199
+ fields[3].name.should.equal('Test Field Last');
1200
+ fields[3].order.should.equal(3);
1205
1201
 
1206
1202
  return done();
1207
1203