Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1214992 - [Stingray][Home] Filter out cards inside folder. r=ylia…
Browse files Browse the repository at this point in the history
…o, a=mahe
  • Loading branch information
rexboy7 authored and BavarianTomcat committed Nov 16, 2015
1 parent a6245ba commit 760e531
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
13 changes: 13 additions & 0 deletions shared/js/smart-screen/cards/folder.js
Expand Up @@ -58,6 +58,19 @@
return this._cardsInFolder;
};

Folder.prototype.getFilteredCardList =
function folder_getFilteredCardList(filterName) {
if (typeof this._cardsInFolder !== 'object') {
return;
}
if (filterName === 'all') {
return this._cardsInFolder;
} else if (filterName) {
return this._cardsInFolder.filter(
elem => (elem.group === filterName));
}
};

Folder.prototype.isEmpty = function folder_isEmpty() {
return this._cardsInFolder.length === 0;
};
Expand Down
24 changes: 19 additions & 5 deletions tv_apps/smart-home/js/filter_manager.js
@@ -1,4 +1,4 @@
/* global CardFilter */
/* global CardFilter, Folder */

(function(exports) {
'use strict';
Expand Down Expand Up @@ -167,7 +167,7 @@
window.requestAnimationFrame(this._performBubbleUp.bind(this));
} else {
this._cardListElem.style.opacity = 1;
this._cardListElem.style.transition = undefined;
this._cardListElem.style.transition = '';
this._cardListElem.removeAttribute('smart-bubbles-direction');
this._smartBubblesElem.play(
document.querySelectorAll('#card-list > .card > .app-button'));
Expand Down Expand Up @@ -212,10 +212,22 @@

var that = this;
var filter = this.getFilterByIconName(this._cardFilter.filter);
var gotFilteredCardList = function(filteredList) {
var gotCardLists = function(results) {
// results[0] is the main card list which has been filtered.
// results[1] is the main card list.
var filteredList = results[0];
var cardList = results[1];

// Get filtered card list for each folder.
cardList.filter(elem => elem instanceof Folder).forEach(elem => {
filteredList = filteredList.concat(
elem.getFilteredCardList(filter.name));
});

filteredList.forEach(function(card) {
that._cardScrollable.addNode(that._home.createCardNode(card));
});

that._filteredCardList =
(filter.name !== 'all') ? filteredList : undefined;
that._cardListElem.style.opacity = 0;
Expand All @@ -224,8 +236,10 @@

if (this._isBubbleSinking()) {
this._cardScrollable.clean();
this._cardManager.getFilteredCardList(filter.name).then(
gotFilteredCardList);
Promise.all([
this._cardManager.getFilteredCardList(filter.name),
this._cardManager.getCardList()
]).then(gotCardLists);
} else {
this._isFilterChanging = false;
}
Expand Down

0 comments on commit 760e531

Please sign in to comment.