From 09e4253f5fc091c2b24171640300f1ce4b485348 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 14 Apr 2015 03:06:18 -0400 Subject: [PATCH] VRFS-2699 select checkboxes for items already in list --- .../assets/javascripts/accounts_profile_samples.js | 7 +++++++ .../javascripts/dialog/recordingSelectorDialog.js | 12 +++++++++++- .../views/dialogs/_recordingSelectorDialog.html.haml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/web/app/assets/javascripts/accounts_profile_samples.js b/web/app/assets/javascripts/accounts_profile_samples.js index c91650205..51cb3e632 100644 --- a/web/app/assets/javascripts/accounts_profile_samples.js +++ b/web/app/assets/javascripts/accounts_profile_samples.js @@ -172,8 +172,15 @@ ui.launchRecordingSelectorDialog(response, window.jamkazamRecordingSources, function(selectedRecordings) { $jamkazamSampleList.empty(); + window.jamkazamRecordingSources = []; + // update the list with the selected recordings $.each(selectedRecordings, function(index, val) { + window.jamkazamRecordingSources.push({ + 'claimed_recording_id': val.id, + 'description': val.name + }); + buildJamkazamEntry(val.id, val.name); }); }); diff --git a/web/app/assets/javascripts/dialog/recordingSelectorDialog.js b/web/app/assets/javascripts/dialog/recordingSelectorDialog.js index 56474e7da..cc9e5dcf9 100644 --- a/web/app/assets/javascripts/dialog/recordingSelectorDialog.js +++ b/web/app/assets/javascripts/dialog/recordingSelectorDialog.js @@ -156,8 +156,18 @@ $('.details-arrow', $feedItem).click(toggleRecordingDetails); $('.play-button', $feedItem).click(toggleRecordingPlay); + var checked = ''; + + var match = $.grep(selectedRecordings, function(obj, index) { + return obj.claimed_recording_id === claimedRecording.id; + }); + + if (match && match.length > 0) { + checked = 'checked'; + } + // put the item on the page - $recordings.append("
"); + $recordings.append("
"); $recordings.append($feedItem); // these routines need the item to have height to work (must be after renderFeed) diff --git a/web/app/views/dialogs/_recordingSelectorDialog.html.haml b/web/app/views/dialogs/_recordingSelectorDialog.html.haml index 91539cf3d..3463baf73 100644 --- a/web/app/views/dialogs/_recordingSelectorDialog.html.haml +++ b/web/app/views/dialogs/_recordingSelectorDialog.html.haml @@ -11,4 +11,4 @@ .right.action-buttons %a.button-grey.btn-cancel-dialog{'layout-action' => 'cancel'} CANCEL - %a.button-orange.btn-select-recordings ADD \ No newline at end of file + %a.button-orange.btn-select-recordings SAVE \ No newline at end of file