1
+ import _ from 'lodash' ;
2
+
1
3
import { View } from '../core/view.js' ;
2
4
import { AlertView } from '../alert/alert.view' ;
3
5
import { AdditionsToCollections } from '../additions/additions-to-collections' ;
@@ -52,7 +54,7 @@ export var VRECollectionView = View.extend({
52
54
selected_records = selected_records || [ ] ;
53
55
if ( this . model ) {
54
56
// adding to array as the api expects an array.
55
- selected_records . push ( this . model . toJSON ( ) ) ;
57
+ selected_records . push ( this . model . id ) ;
56
58
}
57
59
var selected_collections = this . $ ( 'select' ) . val ( ) ;
58
60
var records_and_collections = new AdditionsToCollections ( {
@@ -64,11 +66,13 @@ export var VRECollectionView = View.extend({
64
66
this . showError . bind ( this ) ,
65
67
) ;
66
68
} ,
69
+ reportAddition : function ( amount , uri ) {
70
+ var name = this . collection . get ( uri ) . get ( 'name' ) ;
71
+ return 'Added ' + amount + ' record(s) to ' + name + '.' ;
72
+ } ,
67
73
showSuccess : function ( response ) {
68
- var feedbackString = '' ;
69
- $ . each ( response , function ( key , value ) {
70
- feedbackString = feedbackString . concat ( 'Added ' , value , ' record(s) to ' , key , ". " ) ;
71
- } ) ;
74
+ var feedback = _ . map ( response , this . reportAddition . bind ( this ) ) ;
75
+ var feedbackString = feedback . join ( ' ' ) ;
72
76
this . showAlert ( 'success' , feedbackString ) ;
73
77
} ,
74
78
showError : function ( response ) {
0 commit comments