Skip to content

Commit 21c68fe

Browse files
committed
Connect frontend to the new record addition API (#141 #142)
1 parent e8666ab commit 21c68fe

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

frontend/vre/collection/collection.view.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import _ from 'lodash';
2+
13
import { View } from '../core/view.js';
24
import { AlertView } from '../alert/alert.view';
35
import { AdditionsToCollections } from '../additions/additions-to-collections';
@@ -52,7 +54,7 @@ export var VRECollectionView = View.extend({
5254
selected_records = selected_records || [];
5355
if (this.model) {
5456
// adding to array as the api expects an array.
55-
selected_records.push(this.model.toJSON());
57+
selected_records.push(this.model.id);
5658
}
5759
var selected_collections = this.$('select').val();
5860
var records_and_collections = new AdditionsToCollections({
@@ -64,11 +66,13 @@ export var VRECollectionView = View.extend({
6466
this.showError.bind(this),
6567
);
6668
},
69+
reportAddition: function(amount, uri) {
70+
var name = this.collection.get(uri).get('name');
71+
return 'Added ' + amount + ' record(s) to ' + name + '.';
72+
},
6773
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(' ');
7276
this.showAlert('success', feedbackString);
7377
},
7478
showError: function(response) {

0 commit comments

Comments
 (0)