Skip to content

Commit

Permalink
Add titles
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
  • Loading branch information
LukasReschke committed Apr 25, 2017
1 parent 48a4504 commit 35665da
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
57 changes: 39 additions & 18 deletions settings/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ public function viewApps($category = '') {
return $templateResponse;
}

/**
* Get all available categories
*
* @return JSONResponse
*/
public function listCategories() {
private function getAllCategories() {
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);

$formattedCategories = [
Expand All @@ -150,7 +145,16 @@ public function listCategories() {
];
}

return new JSONResponse($formattedCategories);
return $formattedCategories;
}

/**
* Get all available categories
*
* @return JSONResponse
*/
public function listCategories() {
return new JSONResponse($this->getAllCategories());
}

/**
Expand Down Expand Up @@ -346,17 +350,34 @@ public function listApps($category = '') {
$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:
Expand Down
2 changes: 1 addition & 1 deletion settings/js/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion settings/templates/apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<?php endif; ?>
</script>


<script id="app-template-installed" type="text/x-handlebars">
<div class="section" id="app-{{id}}">
<div class="app-image app-image-icon"></div>
Expand Down Expand Up @@ -74,6 +73,9 @@
</script>

<script id="app-template" type="text/x-handlebars">
{{#if newCategory}}
<br/><h2>{{categoryName}}</h2>
{{/if}}
<div class="section" id="app-{{id}}">
{{#if preview}}
<div class="app-image{{#if previewAsIcon}} app-image-icon{{/if}} icon-loading">
Expand Down

0 comments on commit 35665da

Please sign in to comment.