@dhyasama/totem-models 6.3.5 → 6.3.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/.npmignore +14 -0
- package/lib/Organization.js +18 -30
- package/package-lock.json +1829 -0
- package/package.json +1 -1
- package/test/Organization.js +10 -14
package/.npmignore
ADDED
package/lib/Organization.js
CHANGED
|
@@ -215,8 +215,8 @@ module.exports = function(mongoose, config) {
|
|
|
215
215
|
|
|
216
216
|
standardFields: {
|
|
217
217
|
|
|
218
|
-
//
|
|
219
|
-
//
|
|
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
|
|
281
|
+
// This is used to aggregate answers for polls
|
|
286
282
|
type: { type: String, enum: ['String', 'Number', 'Boolean'], required: true }
|
|
287
283
|
|
|
288
284
|
}],
|
|
@@ -297,7 +293,7 @@ module.exports = function(mongoose, config) {
|
|
|
297
293
|
// colspan is for the number of columns the field should take up on the list page
|
|
298
294
|
colspan: { type: Number, default: 1 },
|
|
299
295
|
|
|
300
|
-
//
|
|
296
|
+
// showOnFilter controls whether values are extracted and used in filtering options on list page
|
|
301
297
|
showOnFilter: { type: Boolean, default: true },
|
|
302
298
|
|
|
303
299
|
// showOnList controls if the field will be on deal list page
|
|
@@ -501,11 +497,10 @@ module.exports = function(mongoose, config) {
|
|
|
501
497
|
|
|
502
498
|
});
|
|
503
499
|
|
|
504
|
-
Organization.virtual('customer.deals.
|
|
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,27 +523,31 @@ module.exports = function(mongoose, config) {
|
|
|
531
523
|
var result = [];
|
|
532
524
|
|
|
533
525
|
// Add the standard fields that are active
|
|
534
|
-
if (standardFields.fundraise.
|
|
526
|
+
if (standardFields.fundraise.showOnList) {
|
|
535
527
|
result.push({
|
|
536
528
|
name: 'Fundraise Amount',
|
|
537
|
-
order: standardFields.fundraise.order * 10
|
|
529
|
+
order: standardFields.fundraise.order * 10,
|
|
530
|
+
colspan: standardFields.fundraise.colspan
|
|
538
531
|
}, {
|
|
539
532
|
name: 'Fundraise Valuation',
|
|
540
|
-
order: standardFields.fundraise.order * 10 + 1
|
|
533
|
+
order: standardFields.fundraise.order * 10 + 1,
|
|
534
|
+
colspan: standardFields.fundraise.colspan
|
|
541
535
|
});
|
|
542
536
|
}
|
|
543
537
|
|
|
544
|
-
if (standardFields.sources.
|
|
538
|
+
if (standardFields.sources.showOnList) {
|
|
545
539
|
result.push({
|
|
546
540
|
name: 'Source',
|
|
547
|
-
order: standardFields.sources.order * 10
|
|
541
|
+
order: standardFields.sources.order * 10,
|
|
542
|
+
colspan: standardFields.fundraise.colspan
|
|
548
543
|
});
|
|
549
544
|
}
|
|
550
545
|
|
|
551
|
-
if (standardFields.referrers.
|
|
546
|
+
if (standardFields.referrers.showOnList) {
|
|
552
547
|
result.push({
|
|
553
548
|
name: 'Referrers',
|
|
554
|
-
order: standardFields.referrers.order * 10
|
|
549
|
+
order: standardFields.referrers.order * 10,
|
|
550
|
+
colspan: standardFields.fundraise.colspan
|
|
555
551
|
});
|
|
556
552
|
}
|
|
557
553
|
|
|
@@ -560,7 +556,8 @@ module.exports = function(mongoose, config) {
|
|
|
560
556
|
if (field.display.showOnList) {
|
|
561
557
|
result.push({
|
|
562
558
|
name: field.label,
|
|
563
|
-
order: field.display.order * 10
|
|
559
|
+
order: field.display.order * 10,
|
|
560
|
+
colspan: field.display.colspan
|
|
564
561
|
});
|
|
565
562
|
}
|
|
566
563
|
});
|
|
@@ -568,15 +565,6 @@ module.exports = function(mongoose, config) {
|
|
|
568
565
|
// Sort the combined standard and custom fields
|
|
569
566
|
result = _.sortBy(result, function(item) { return item.order; });
|
|
570
567
|
|
|
571
|
-
// Put the ever-present fields at the beginning
|
|
572
|
-
result.unshift({
|
|
573
|
-
name: 'Company',
|
|
574
|
-
order: 0
|
|
575
|
-
}, {
|
|
576
|
-
name: 'Stage',
|
|
577
|
-
order: 1
|
|
578
|
-
});
|
|
579
|
-
|
|
580
568
|
// Now that we have all fields combined and ordered, make column order zero-indexed and gap-free
|
|
581
569
|
result = _.map(result, function(item, index) {
|
|
582
570
|
item.order = index;
|