Skip to content
Extraits de code Groupes Projets
Valider 2d916da7 rédigé par Thomas Steur's avatar Thomas Steur Validation de Stefan Giehl
Parcourir les fichiers

refs #11721 if a page could not be found, fallback to a first entry in that category (#11727)

parent 668ff6fb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -16,18 +16,36 @@
var model = {
pages : [],
findPage: findPage,
findPageInCategory: findPageInCategory,
reloadAllPages : reloadAllPages,
getAllPages : getAllPages
};
return model;
function findPageInCategory(categoryId) {
var found = null;
angular.forEach(model.pages, function (page) {
// happens when user switches between sites, in this case check if the same category exists and if so,
// select first entry from that category
if (!found && page &&
page.category && page.subcategory &&
page.category.id === categoryId && page.subcategory.id) {
found = page;
}
});
return found;
}
function findPage(categoryId, subcategoryId)
{
var found = null;
angular.forEach(model.pages, function (page) {
if (page &&
if (!found &&
page &&
page.category && page.subcategory &&
page.category.id === categoryId && ('' + page.subcategory.id) === subcategoryId) {
found = page;
......
......@@ -7,9 +7,9 @@
(function () {
angular.module('piwikApp').controller('ReportingPageController', ReportingPageController);
ReportingPageController.$inject = ['$scope', 'piwik', '$rootScope', '$location', 'reportingPageModel'];
ReportingPageController.$inject = ['$scope', 'piwik', '$rootScope', '$location', 'reportingPageModel', 'reportingPagesModel'];
function ReportingPageController($scope, piwik, $rootScope, $location, pageModel) {
function ReportingPageController($scope, piwik, $rootScope, $location, pageModel, pagesModel) {
pageModel.resetPage();
$scope.pageModel = pageModel;
......@@ -53,6 +53,17 @@
}
pageModel.fetchPage(category, subcategory).then(function () {
if (!pageModel.page) {
var page = pagesModel.findPageInCategory(category);
if (page && page.subcategory) {
var $search = $location.search();
$search.subcategory = page.subcategory.id;
$location.search($search);
return;
}
}
$scope.hasNoPage = !pageModel.page;
$scope.loading = false;
});
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter