@@ -22,9 +22,10 @@ export class DataExportModel extends Observable {
2222 /**
2323 * Constructor
2424 * @param {ObservableData<RemoteData<T[]>> } items$ observable data used as source for export
25- * @param {function } onDataNotAskedAction
25+ * @param {object<string, {exportFormat: function|null|undefined}> } fieldsFormatting defines selectable fields and their formatting
26+ * @param {function } onDataNotAskedAction function to be called in case of missing data
2627 */
27- constructor ( items$ , onDataNotAskedAction ) {
28+ constructor ( items$ , fieldsFormatting , onDataNotAskedAction ) {
2829 super ( ) ;
2930
3031 this . _items$ = items$ ;
@@ -38,14 +39,22 @@ export class DataExportModel extends Observable {
3839
3940 this . _exportName = 'data' ;
4041
41- this . columnFormats = null ;
42+ this . _fieldsFormatting = fieldsFormatting ;
4243 this . _onDataNotAskedAction = onDataNotAskedAction ;
4344
4445 this . _disabled = null ;
4546
4647 this . _totalExistingItemsCount = null ;
4748 }
4849
50+ /**
51+ * Get mapping of selecteble fields to their format functions
52+ * @return {object<string, {exportFormat: function|null|undefined}> } mapping
53+ */
54+ get fieldsFormatting ( ) {
55+ return this . _fieldsFormatting ;
56+ }
57+
4958 /**
5059 * Get total number of items that model knows they exist
5160 * @return {number } totalExistingItemsCount
@@ -104,7 +113,7 @@ export class DataExportModel extends Observable {
104113
105114 /**
106115 * Observable notified when the export configuration visually changes
107- * @return {Observable }
116+ * @return {Observable } the visual change observable
108117 */
109118 get visualChange$ ( ) {
110119 return this . _visualChange$ ;
@@ -161,7 +170,7 @@ export class DataExportModel extends Observable {
161170 const formatted = items . map ( ( item ) => {
162171 const selectedEntries = Object . entries ( pick ( item , selectedFields ) ) ;
163172 const mappedEntries = selectedEntries . map ( ( [ key , value ] ) => {
164- const formatter = this . columnFormats [ key ] ?. exportFormat || ( ( v ) => v ) ;
173+ const formatter = this . fieldsFormatting [ key ] ?. exportFormat || ( ( v ) => v ) ;
165174 return [ key , formatter ( value , item ) ] ;
166175 } ) ;
167176
0 commit comments