@memberjunction/ng-timeline 2.122.0 → 2.122.2
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/README.md +385 -245
- package/dist/lib/component/timeline.component.d.ts +377 -60
- package/dist/lib/component/timeline.component.d.ts.map +1 -1
- package/dist/lib/component/timeline.component.js +1904 -132
- package/dist/lib/component/timeline.component.js.map +1 -1
- package/dist/lib/events.d.ts +440 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +11 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/module.d.ts +14 -6
- package/dist/lib/module.d.ts.map +1 -1
- package/dist/lib/module.js +24 -26
- package/dist/lib/module.js.map +1 -1
- package/dist/lib/timeline-group.d.ts +387 -0
- package/dist/lib/timeline-group.d.ts.map +1 -0
- package/dist/lib/timeline-group.js +523 -0
- package/dist/lib/timeline-group.js.map +1 -0
- package/dist/lib/types.d.ts +491 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +49 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/public-api.d.ts +12 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +15 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +19 -17
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TimelineGroup class for configuring timeline data sources.
|
|
3
|
+
*
|
|
4
|
+
* The TimelineGroup class defines how data is loaded and displayed in the timeline.
|
|
5
|
+
* It supports both MemberJunction BaseEntity objects and plain JavaScript objects,
|
|
6
|
+
* making it usable in any Angular application.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/ng-timeline/timeline-group
|
|
9
|
+
*/
|
|
10
|
+
import { DEFAULT_CARD_CONFIG } from './types';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// HELPER FUNCTION - FIELD VALUE ACCESS
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Extracts a field value from a record, supporting both BaseEntity and plain objects.
|
|
16
|
+
*
|
|
17
|
+
* For BaseEntity objects (detected by presence of `.Get()` method), uses the `.Get()` method.
|
|
18
|
+
* For plain JavaScript objects, uses standard bracket notation.
|
|
19
|
+
*
|
|
20
|
+
* @param record - The source record (BaseEntity or plain object)
|
|
21
|
+
* @param fieldName - The name of the field to extract
|
|
22
|
+
* @returns The field value, or undefined if not found
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Works with BaseEntity
|
|
27
|
+
* const entity = await md.GetEntityObject<TaskEntity>('Tasks');
|
|
28
|
+
* const name = getFieldValue(entity, 'Name'); // Uses entity.Get('Name')
|
|
29
|
+
*
|
|
30
|
+
* // Works with plain objects
|
|
31
|
+
* const obj = { name: 'My Task', status: 'Open' };
|
|
32
|
+
* const name = getFieldValue(obj, 'name'); // Uses obj['name']
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function getFieldValue(record, fieldName) {
|
|
36
|
+
if (record == null) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
// Check if this is a BaseEntity (has .Get() method)
|
|
40
|
+
if (typeof record.Get === 'function') {
|
|
41
|
+
return record.Get(fieldName);
|
|
42
|
+
}
|
|
43
|
+
// Plain object - use bracket notation
|
|
44
|
+
return record[fieldName];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extracts an ID from a record, trying common ID field names.
|
|
48
|
+
*
|
|
49
|
+
* @param record - The source record
|
|
50
|
+
* @param idFieldName - Optional explicit ID field name
|
|
51
|
+
* @returns The record ID as a string, or a generated fallback ID
|
|
52
|
+
*/
|
|
53
|
+
export function getRecordId(record, idFieldName) {
|
|
54
|
+
if (record == null) {
|
|
55
|
+
return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
56
|
+
}
|
|
57
|
+
// Try explicit field name first
|
|
58
|
+
if (idFieldName) {
|
|
59
|
+
const id = getFieldValue(record, idFieldName);
|
|
60
|
+
if (id != null) {
|
|
61
|
+
return String(id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Try common ID field names
|
|
65
|
+
const commonIdFields = ['ID', 'id', 'Id', '_id', 'uuid', 'UUID'];
|
|
66
|
+
for (const field of commonIdFields) {
|
|
67
|
+
const id = getFieldValue(record, field);
|
|
68
|
+
if (id != null) {
|
|
69
|
+
return String(id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Fallback: generate a unique ID
|
|
73
|
+
return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
74
|
+
}
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// TIMELINE GROUP CLASS
|
|
77
|
+
// ============================================================================
|
|
78
|
+
/**
|
|
79
|
+
* Configures a data source for the timeline component.
|
|
80
|
+
*
|
|
81
|
+
* TimelineGroup defines how records are loaded, which fields to display,
|
|
82
|
+
* and how they should be styled. Multiple groups can be used to display
|
|
83
|
+
* different types of events on the same timeline.
|
|
84
|
+
*
|
|
85
|
+
* @typeParam T - The type of the source records. Defaults to `any` for maximum
|
|
86
|
+
* flexibility. MemberJunction users can specify BaseEntity subclasses
|
|
87
|
+
* for full type safety.
|
|
88
|
+
*
|
|
89
|
+
* @example Basic usage with plain objects
|
|
90
|
+
* ```typescript
|
|
91
|
+
* interface MyEvent {
|
|
92
|
+
* id: string;
|
|
93
|
+
* title: string;
|
|
94
|
+
* eventDate: Date;
|
|
95
|
+
* description: string;
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* const group = new TimelineGroup<MyEvent>();
|
|
99
|
+
* group.DataSourceType = 'array';
|
|
100
|
+
* group.EntityObjects = myEventsArray;
|
|
101
|
+
* group.TitleFieldName = 'title';
|
|
102
|
+
* group.DateFieldName = 'eventDate';
|
|
103
|
+
* group.DescriptionFieldName = 'description';
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example MemberJunction usage with BaseEntity
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { TaskEntity } from '@memberjunction/core-entities';
|
|
109
|
+
*
|
|
110
|
+
* const group = new TimelineGroup<TaskEntity>();
|
|
111
|
+
* group.EntityName = 'Tasks';
|
|
112
|
+
* group.DataSourceType = 'entity';
|
|
113
|
+
* group.Filter = "Status = 'Open'";
|
|
114
|
+
* group.TitleFieldName = 'Name';
|
|
115
|
+
* group.DateFieldName = 'DueDate';
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example With full configuration
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const group = new TimelineGroup<TaskEntity>();
|
|
121
|
+
* group.EntityName = 'Tasks';
|
|
122
|
+
* group.TitleFieldName = 'Name';
|
|
123
|
+
* group.DateFieldName = 'CompletedAt';
|
|
124
|
+
* group.SubtitleFieldName = 'Category';
|
|
125
|
+
* group.DescriptionFieldName = 'Description';
|
|
126
|
+
* group.DisplayIcon = 'fa-solid fa-check-circle';
|
|
127
|
+
* group.DisplayColor = '#4caf50';
|
|
128
|
+
* group.GroupLabel = 'Completed Tasks';
|
|
129
|
+
*
|
|
130
|
+
* group.CardConfig = {
|
|
131
|
+
* collapsible: true,
|
|
132
|
+
* defaultExpanded: false,
|
|
133
|
+
* summaryFields: [
|
|
134
|
+
* { fieldName: 'AssignedTo', label: 'Assignee', icon: 'fa-solid fa-user' },
|
|
135
|
+
* { fieldName: 'Priority', icon: 'fa-solid fa-flag' }
|
|
136
|
+
* ],
|
|
137
|
+
* actions: [
|
|
138
|
+
* { id: 'view', label: 'View', variant: 'primary' },
|
|
139
|
+
* { id: 'edit', label: 'Edit', variant: 'secondary' }
|
|
140
|
+
* ]
|
|
141
|
+
* };
|
|
142
|
+
*
|
|
143
|
+
* group.EventConfigFunction = (task) => ({
|
|
144
|
+
* icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,
|
|
145
|
+
* color: task.Status === 'Overdue' ? '#f44336' : undefined
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export class TimelineGroup {
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// DATA SOURCE CONFIGURATION
|
|
152
|
+
// ============================================================================
|
|
153
|
+
/**
|
|
154
|
+
* The MemberJunction entity name for this group.
|
|
155
|
+
* Required when `DataSourceType` is `'entity'`.
|
|
156
|
+
*
|
|
157
|
+
* @example 'Tasks', 'AI Agents', 'Users'
|
|
158
|
+
*/
|
|
159
|
+
EntityName;
|
|
160
|
+
/**
|
|
161
|
+
* How data is provided to the timeline.
|
|
162
|
+
* - `'array'`: Data is provided via the `EntityObjects` array (works with any object type)
|
|
163
|
+
* - `'entity'`: Data is loaded using MemberJunction's RunView (requires MJ core)
|
|
164
|
+
*
|
|
165
|
+
* @default 'entity'
|
|
166
|
+
*/
|
|
167
|
+
DataSourceType = 'entity';
|
|
168
|
+
/**
|
|
169
|
+
* SQL WHERE clause filter for entity queries.
|
|
170
|
+
* Only used when `DataSourceType` is `'entity'`.
|
|
171
|
+
*
|
|
172
|
+
* @example "Status = 'Open' AND Priority = 'High'"
|
|
173
|
+
*/
|
|
174
|
+
Filter;
|
|
175
|
+
/**
|
|
176
|
+
* Pre-loaded data array.
|
|
177
|
+
* Used when `DataSourceType` is `'array'`, or populated after loading when using `'entity'`.
|
|
178
|
+
*/
|
|
179
|
+
EntityObjects = [];
|
|
180
|
+
/**
|
|
181
|
+
* SQL ORDER BY clause for entity queries.
|
|
182
|
+
* Only used when `DataSourceType` is `'entity'`.
|
|
183
|
+
*
|
|
184
|
+
* @example 'CreatedAt DESC', 'Priority ASC, DueDate DESC'
|
|
185
|
+
*/
|
|
186
|
+
OrderBy;
|
|
187
|
+
/**
|
|
188
|
+
* Maximum number of records to load per batch.
|
|
189
|
+
* Used for virtual scrolling.
|
|
190
|
+
*
|
|
191
|
+
* @default undefined (uses component's virtualScroll.batchSize)
|
|
192
|
+
*/
|
|
193
|
+
MaxRecords;
|
|
194
|
+
// ============================================================================
|
|
195
|
+
// FIELD MAPPINGS
|
|
196
|
+
// ============================================================================
|
|
197
|
+
/**
|
|
198
|
+
* Field name for the event title.
|
|
199
|
+
* This is the primary text displayed on each timeline card.
|
|
200
|
+
*
|
|
201
|
+
* @required
|
|
202
|
+
*/
|
|
203
|
+
TitleFieldName;
|
|
204
|
+
/**
|
|
205
|
+
* Field name for the event date.
|
|
206
|
+
* Used for chronological ordering and date display.
|
|
207
|
+
*
|
|
208
|
+
* @required
|
|
209
|
+
*/
|
|
210
|
+
DateFieldName;
|
|
211
|
+
/**
|
|
212
|
+
* Field name for the subtitle.
|
|
213
|
+
* Displayed below the title in smaller text.
|
|
214
|
+
*/
|
|
215
|
+
SubtitleFieldName;
|
|
216
|
+
/**
|
|
217
|
+
* Field name for the description/body text.
|
|
218
|
+
* Displayed in the card body when expanded.
|
|
219
|
+
*/
|
|
220
|
+
DescriptionFieldName;
|
|
221
|
+
/**
|
|
222
|
+
* Field name containing an image URL.
|
|
223
|
+
* When set, displays an image in the card.
|
|
224
|
+
*/
|
|
225
|
+
ImageFieldName;
|
|
226
|
+
/**
|
|
227
|
+
* Field name for the unique record ID.
|
|
228
|
+
* Defaults to 'ID' or 'id' if not specified.
|
|
229
|
+
*/
|
|
230
|
+
IdFieldName;
|
|
231
|
+
// ============================================================================
|
|
232
|
+
// GROUP-LEVEL DISPLAY
|
|
233
|
+
// ============================================================================
|
|
234
|
+
/**
|
|
235
|
+
* Icon display mode.
|
|
236
|
+
* - `'standard'`: Uses a default icon based on the group index
|
|
237
|
+
* - `'custom'`: Uses the icon specified in `DisplayIcon`
|
|
238
|
+
*
|
|
239
|
+
* @default 'standard'
|
|
240
|
+
*/
|
|
241
|
+
DisplayIconMode = 'standard';
|
|
242
|
+
/**
|
|
243
|
+
* Custom icon class (Font Awesome).
|
|
244
|
+
* Only used when `DisplayIconMode` is `'custom'`.
|
|
245
|
+
*
|
|
246
|
+
* @example 'fa-solid fa-check', 'fa-regular fa-calendar'
|
|
247
|
+
*/
|
|
248
|
+
DisplayIcon;
|
|
249
|
+
/**
|
|
250
|
+
* Color assignment mode.
|
|
251
|
+
* - `'auto'`: System assigns colors based on group index
|
|
252
|
+
* - `'manual'`: Uses the color specified in `DisplayColor`
|
|
253
|
+
*
|
|
254
|
+
* @default 'auto'
|
|
255
|
+
*/
|
|
256
|
+
DisplayColorMode = 'auto';
|
|
257
|
+
/**
|
|
258
|
+
* Custom color for this group's markers and accents.
|
|
259
|
+
* Only used when `DisplayColorMode` is `'manual'`.
|
|
260
|
+
* Any valid CSS color value.
|
|
261
|
+
*
|
|
262
|
+
* @example '#4caf50', 'rgb(66, 135, 245)', 'var(--primary-color)'
|
|
263
|
+
*/
|
|
264
|
+
DisplayColor;
|
|
265
|
+
/**
|
|
266
|
+
* Human-readable label for this group.
|
|
267
|
+
* Used in legends, headers, or when distinguishing multiple groups.
|
|
268
|
+
*
|
|
269
|
+
* @example 'Completed Tasks', 'System Events', 'User Activities'
|
|
270
|
+
*/
|
|
271
|
+
GroupLabel;
|
|
272
|
+
// ============================================================================
|
|
273
|
+
// CARD CONFIGURATION
|
|
274
|
+
// ============================================================================
|
|
275
|
+
/**
|
|
276
|
+
* Card display configuration for this group.
|
|
277
|
+
* Defines how event cards are rendered.
|
|
278
|
+
* If not set, uses the component's `defaultCardConfig`.
|
|
279
|
+
*/
|
|
280
|
+
CardConfig;
|
|
281
|
+
// ============================================================================
|
|
282
|
+
// CUSTOM FUNCTIONS
|
|
283
|
+
// ============================================================================
|
|
284
|
+
/**
|
|
285
|
+
* Custom function to generate the event summary/description.
|
|
286
|
+
* Takes precedence over `DescriptionFieldName`.
|
|
287
|
+
*
|
|
288
|
+
* @param record - The source record
|
|
289
|
+
* @returns HTML string or plain text to display
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* group.SummaryFunction = (task) => {
|
|
294
|
+
* return `<strong>${task.Status}</strong>: ${task.Description}`;
|
|
295
|
+
* };
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
SummaryFunction;
|
|
299
|
+
/**
|
|
300
|
+
* Custom function to configure individual events.
|
|
301
|
+
* Allows per-event customization of icons, colors, and actions.
|
|
302
|
+
*
|
|
303
|
+
* @param record - The source record
|
|
304
|
+
* @returns Configuration overrides for this event
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* group.EventConfigFunction = (task) => ({
|
|
309
|
+
* icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,
|
|
310
|
+
* color: task.IsOverdue ? '#f44336' : undefined,
|
|
311
|
+
* actions: task.CanEdit ? [{ id: 'edit', label: 'Edit' }] : []
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
EventConfigFunction;
|
|
316
|
+
// ============================================================================
|
|
317
|
+
// METHODS
|
|
318
|
+
// ============================================================================
|
|
319
|
+
/**
|
|
320
|
+
* Gets the effective card configuration, merging with defaults.
|
|
321
|
+
*
|
|
322
|
+
* @returns The merged card configuration
|
|
323
|
+
*/
|
|
324
|
+
getEffectiveCardConfig() {
|
|
325
|
+
return {
|
|
326
|
+
...DEFAULT_CARD_CONFIG,
|
|
327
|
+
...this.CardConfig
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Extracts a field value from a record in this group.
|
|
332
|
+
*
|
|
333
|
+
* @param record - The source record
|
|
334
|
+
* @param fieldName - The field name to extract
|
|
335
|
+
* @returns The field value
|
|
336
|
+
*/
|
|
337
|
+
getValue(record, fieldName) {
|
|
338
|
+
return getFieldValue(record, fieldName);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Gets the ID of a record in this group.
|
|
342
|
+
*
|
|
343
|
+
* @param record - The source record
|
|
344
|
+
* @returns The record ID
|
|
345
|
+
*/
|
|
346
|
+
getId(record) {
|
|
347
|
+
return getRecordId(record, this.IdFieldName);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Gets the title from a record.
|
|
351
|
+
*
|
|
352
|
+
* @param record - The source record
|
|
353
|
+
* @returns The title string
|
|
354
|
+
*/
|
|
355
|
+
getTitle(record) {
|
|
356
|
+
const value = this.getValue(record, this.TitleFieldName);
|
|
357
|
+
return value != null ? String(value) : '';
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Gets the date from a record.
|
|
361
|
+
*
|
|
362
|
+
* @param record - The source record
|
|
363
|
+
* @returns The date object
|
|
364
|
+
*/
|
|
365
|
+
getDate(record) {
|
|
366
|
+
const value = this.getValue(record, this.DateFieldName);
|
|
367
|
+
if (value instanceof Date) {
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
371
|
+
return new Date(value);
|
|
372
|
+
}
|
|
373
|
+
return new Date();
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Gets the subtitle from a record.
|
|
377
|
+
*
|
|
378
|
+
* @param record - The source record
|
|
379
|
+
* @returns The subtitle string, or undefined
|
|
380
|
+
*/
|
|
381
|
+
getSubtitle(record) {
|
|
382
|
+
if (!this.SubtitleFieldName) {
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
const value = this.getValue(record, this.SubtitleFieldName);
|
|
386
|
+
return value != null ? String(value) : undefined;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Gets the description from a record.
|
|
390
|
+
*
|
|
391
|
+
* @param record - The source record
|
|
392
|
+
* @returns The description string, or undefined
|
|
393
|
+
*/
|
|
394
|
+
getDescription(record) {
|
|
395
|
+
// Use custom summary function if provided
|
|
396
|
+
if (this.SummaryFunction) {
|
|
397
|
+
return this.SummaryFunction(record);
|
|
398
|
+
}
|
|
399
|
+
// Use description field
|
|
400
|
+
if (this.DescriptionFieldName) {
|
|
401
|
+
const value = this.getValue(record, this.DescriptionFieldName);
|
|
402
|
+
return value != null ? String(value) : undefined;
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Gets the image URL from a record.
|
|
408
|
+
*
|
|
409
|
+
* @param record - The source record
|
|
410
|
+
* @returns The image URL, or undefined
|
|
411
|
+
*/
|
|
412
|
+
getImageUrl(record) {
|
|
413
|
+
const fieldName = this.CardConfig?.imageField || this.ImageFieldName;
|
|
414
|
+
if (!fieldName) {
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
const value = this.getValue(record, fieldName);
|
|
418
|
+
return value != null ? String(value) : undefined;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Gets the event configuration for a specific record.
|
|
422
|
+
*
|
|
423
|
+
* @param record - The source record
|
|
424
|
+
* @returns The event configuration (from EventConfigFunction or defaults)
|
|
425
|
+
*/
|
|
426
|
+
getEventConfig(record) {
|
|
427
|
+
if (this.EventConfigFunction) {
|
|
428
|
+
return this.EventConfigFunction(record);
|
|
429
|
+
}
|
|
430
|
+
return {};
|
|
431
|
+
}
|
|
432
|
+
// ============================================================================
|
|
433
|
+
// STATIC FACTORY METHODS
|
|
434
|
+
// ============================================================================
|
|
435
|
+
/**
|
|
436
|
+
* Creates a TimelineGroup from MemberJunction RunViewParams.
|
|
437
|
+
*
|
|
438
|
+
* This is a convenience method for MemberJunction applications.
|
|
439
|
+
* It loads data immediately and returns a configured group.
|
|
440
|
+
*
|
|
441
|
+
* **Note**: This method requires `@memberjunction/core` to be available.
|
|
442
|
+
* It will throw an error if used in non-MJ applications.
|
|
443
|
+
*
|
|
444
|
+
* @param params - RunView parameters for loading data
|
|
445
|
+
* @returns A configured TimelineGroup with loaded data
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const group = await TimelineGroup.FromView<TaskEntity>({
|
|
450
|
+
* EntityName: 'Tasks',
|
|
451
|
+
* ExtraFilter: "Status = 'Open'",
|
|
452
|
+
* OrderBy: 'DueDate DESC'
|
|
453
|
+
* });
|
|
454
|
+
* group.TitleFieldName = 'Name';
|
|
455
|
+
* group.DateFieldName = 'DueDate';
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
static async FromView(params) {
|
|
459
|
+
const group = new TimelineGroup();
|
|
460
|
+
try {
|
|
461
|
+
// Dynamically import MJ core to avoid hard dependency
|
|
462
|
+
const { RunView } = await import('@memberjunction/core');
|
|
463
|
+
const rv = new RunView();
|
|
464
|
+
const viewParams = {
|
|
465
|
+
...params,
|
|
466
|
+
ResultType: 'entity_object'
|
|
467
|
+
};
|
|
468
|
+
const result = await rv.RunView(viewParams);
|
|
469
|
+
if (result?.Success) {
|
|
470
|
+
group.EntityName = params.EntityName;
|
|
471
|
+
group.EntityObjects = result.Results;
|
|
472
|
+
group.DataSourceType = 'array'; // Already loaded
|
|
473
|
+
group.Filter = params.ExtraFilter;
|
|
474
|
+
group.OrderBy = params.OrderBy;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
console.warn('TimelineGroup.FromView requires @memberjunction/core. ' +
|
|
479
|
+
'Use DataSourceType="array" with EntityObjects for non-MJ applications.', error);
|
|
480
|
+
}
|
|
481
|
+
return group;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Creates a TimelineGroup from a plain array of objects.
|
|
485
|
+
*
|
|
486
|
+
* This is a convenience method that sets up the group for array-based data.
|
|
487
|
+
*
|
|
488
|
+
* @param data - Array of objects to display
|
|
489
|
+
* @param config - Configuration for field mappings
|
|
490
|
+
* @returns A configured TimelineGroup
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* const group = TimelineGroup.FromArray(myEvents, {
|
|
495
|
+
* titleField: 'name',
|
|
496
|
+
* dateField: 'eventDate',
|
|
497
|
+
* descriptionField: 'details'
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
static FromArray(data, config) {
|
|
502
|
+
const group = new TimelineGroup();
|
|
503
|
+
group.DataSourceType = 'array';
|
|
504
|
+
group.EntityObjects = data;
|
|
505
|
+
group.TitleFieldName = config.titleField;
|
|
506
|
+
group.DateFieldName = config.dateField;
|
|
507
|
+
group.SubtitleFieldName = config.subtitleField;
|
|
508
|
+
group.DescriptionFieldName = config.descriptionField;
|
|
509
|
+
group.ImageFieldName = config.imageField;
|
|
510
|
+
group.IdFieldName = config.idField;
|
|
511
|
+
group.GroupLabel = config.groupLabel;
|
|
512
|
+
if (config.icon) {
|
|
513
|
+
group.DisplayIconMode = 'custom';
|
|
514
|
+
group.DisplayIcon = config.icon;
|
|
515
|
+
}
|
|
516
|
+
if (config.color) {
|
|
517
|
+
group.DisplayColorMode = 'manual';
|
|
518
|
+
group.DisplayColor = config.color;
|
|
519
|
+
}
|
|
520
|
+
return group;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
//# sourceMappingURL=timeline-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-group.js","sourceRoot":"","sources":["../../src/lib/timeline-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,+EAA+E;AAC/E,uCAAuC;AACvC,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa,CAAC,MAAW,EAAE,SAAiB;IAC1D,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,oDAAoD;IACpD,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,sCAAsC;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAW,EAAE,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