From 4b1ac3fef204b9ac252766fb7496b3ec5fbed731 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 25 Apr 2017 20:17:52 +0200 Subject: Add titles Signed-off-by: Lukas Reschke --- settings/Controller/AppSettingsController.php | 57 ++++++++++++++++++--------- settings/js/apps.js | 2 +- settings/templates/apps.php | 4 +- 3 files changed, 43 insertions(+), 20 deletions(-) (limited to 'settings') diff --git a/settings/Controller/AppSettingsController.php b/settings/Controller/AppSettingsController.php index 0d204bd47ab..a8b6d8b242d 100644 --- a/settings/Controller/AppSettingsController.php +++ b/settings/Controller/AppSettingsController.php @@ -127,12 +127,7 @@ class AppSettingsController extends Controller { return $templateResponse; } - /** - * Get all available categories - * - * @return JSONResponse - */ - public function listCategories() { + private function getAllCategories() { $currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2); $formattedCategories = [ @@ -150,7 +145,16 @@ class AppSettingsController extends Controller { ]; } - return new JSONResponse($formattedCategories); + return $formattedCategories; + } + + /** + * Get all available categories + * + * @return JSONResponse + */ + public function listCategories() { + return new JSONResponse($this->getAllCategories()); } /** @@ -346,17 +350,34 @@ class AppSettingsController extends Controller { $bundles = $this->bundleFetcher->getBundles(); $apps = []; foreach($bundles as $bundle) { - $apps[] = [ - 'id' => $bundle->getIdentifier(), - 'author' => 'Nextcloud', - 'name' => $bundle->getName() . ' (' . $bundle->getDescription() .')', - 'description' => '', - 'internal' => true, - 'active' => false, - 'removable' => false, - 'groups' => [], - 'apps' => $bundle->getAppIdentifiers(), - ]; + $newCategory = true; + $allApps = $appClass->listAllApps(); + $categories = $this->getAllCategories(); + foreach($categories as $singleCategory) { + $newApps = $this->getAppsForCategory($singleCategory['id']); + foreach($allApps as $app) { + foreach($newApps as $key => $newApp) { + if($app['id'] === $newApp['id']) { + unset($newApps[$key]); + } + } + } + $allApps = array_merge($allApps, $newApps); + } + + foreach($bundle->getAppIdentifiers() as $identifier) { + foreach($allApps as $app) { + if($app['id'] === $identifier) { + if($newCategory) { + $app['newCategory'] = true; + $app['categoryName'] = $bundle->getName(); + } + $newCategory = false; + $apps[] = $app; + continue; + } + } + } } break; default: diff --git a/settings/js/apps.js b/settings/js/apps.js index cda0b5112ea..bff28a60abb 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -99,7 +99,7 @@ OC.Settings.Apps = OC.Settings.Apps || { return _.extend({level: 0}, app); }); var source; - if (categoryId === 'enabled' || categoryId === 'disabled' || categoryId === 'installed' || categoryId === 'app-bundles') { + if (categoryId === 'enabled' || categoryId === 'disabled' || categoryId === 'installed') { source = $("#app-template-installed").html(); $('#apps-list').addClass('installed'); } else { diff --git a/settings/templates/apps.php b/settings/templates/apps.php index 310513722cf..b3dcbeba233 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -29,7 +29,6 @@ script( -