Skip to content

Commit

Permalink
preload featured article list by providing an extra parameter in url
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Sep 10, 2015
1 parent 0ed2d60 commit 0dac142
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class PlaylistsController extends Controller
{
/**
* @Route("/admin/playlists/")
* @Route("/admin/playlists/{articleNumber}/{language}/editor-view/",
* @Route("/admin/playlists/{articleNumber}/{language}/editor-view/{listId}",
* options={"expose"=true},
* name="newscoop_newscoop_playlists_editor"
* )
*/
public function indexAction(Request $request, $articleNumber = null, $language = null)
public function indexAction(Request $request, $articleNumber = null, $language = null, $listId = null)
{
$preferencesService = $this->get('preferences');
$em = $this->get('em');
Expand Down Expand Up @@ -55,6 +55,7 @@ public function indexAction(Request $request, $articleNumber = null, $language =
'editorView' => $editorView,
'articleNumber' => $articleNumber,
'language' => $languageCode,
'selectedListId' => $listId,
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ angular.module('playlistsApp').controller('PlaylistsController', [
}
});

// preload featured article list when selectedListId variable
// is given.
// selectedListId variable is set globally in twig template. Its value
// is filled with the data from the url parameter.
// Preloads all featured article lists when value of selectedListId is
// not found in existing lists, fetched from the server.
// When selectedListId is empty it will do nothing.
if (_.isEmpty($scope.playlists) && selectedListId) {
Playlist.getAll().$promise.then(function (data) {
$scope.playlists = data.items;
var selectedList = _.find(data.items, { 'id': parseInt(selectedListId) });
if (selectedList !== undefined) {
$scope.playlist.selected = selectedList;
$scope.setPlaylistInfoOnChange(selectedList);
}
});
}

// stops, starts counter
$scope.isCounting = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,10 @@
</div>

<script type="text/javascript">
var clientId = '{{ clientId }}';
var redirectUris = '{{ redirectUris }}';
var clientId = '{{ clientId }}',
redirectUris = '{{ redirectUris }}',
selectedListId = '{{ selectedListId }}';
$(document).ready(function() {
$('.input-filter').attr('placeholder', "{{'Search'|trans({}, 'messages') }}...");
});
Expand Down

0 comments on commit 0dac142

Please sign in to comment.