diff --git a/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js b/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js index 66cb75b0..33ff0942 100644 --- a/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js +++ b/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js @@ -15,7 +15,6 @@ export default class EntryFormatter { formatField(field) { var label = field.label() || field.name(); var type = field.type(); - switch (type) { case 'boolean': case 'choice': @@ -69,7 +68,13 @@ export default class EntryFormatter { value: entry.listValues[field.name()] }; }; - case 'referenced_many': + case 'reference_many': + return function (entry) { + return { + name: label, + value: entry.listValues[field.name()].join(', ') + }; + }; case 'referenced_list': return; //ignored } diff --git a/src/javascripts/test/unit/Crud/misc/EntryFormatterSpec.js b/src/javascripts/test/unit/Crud/misc/EntryFormatterSpec.js index c9867501..5f2a0928 100644 --- a/src/javascripts/test/unit/Crud/misc/EntryFormatterSpec.js +++ b/src/javascripts/test/unit/Crud/misc/EntryFormatterSpec.js @@ -70,6 +70,16 @@ describe("Service: EntryFormatter.getFormatter formatter", function () { expect(formatter({listValues: {reference: 'a reference'}})).toEqual({Reference: 'a reference'}); }); + it('formatter should format field of type reference_many', function () { + var formatter = entryFormatter.getFormatter([getField({ + type: 'reference_many', + name: 'references', + label: 'References' + })]); + + expect(formatter({listValues: {references: ['referenced_value1', 'referenced_value2']}})).toEqual({References: 'referenced_value1, referenced_value2'}); + }); + it('formatter should format field of type date', function () { var formatter = entryFormatter.getFormatter([getField({ type: 'date',