Proper rendering of bundles

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-05-29 18:23:42 +02:00
parent 334f0ad61b
commit 30cd8ed837
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF
2 changed files with 36 additions and 18 deletions

View file

@ -140,6 +140,7 @@ class AppSettingsController extends Controller {
$params['urlGenerator'] = $this->urlGenerator;
$params['updateCount'] = count($this->getAppsWithUpdates());
$params['developerDocumentation'] = $this->urlGenerator->linkToDocs('developer-manual');
$params['bundles'] = $this->getBundles();
$this->navigationManager->setActiveEntry('core_apps');
$templateResponse = new TemplateResponse('settings', 'settings', ['serverData' => $params]);
@ -150,6 +151,20 @@ class AppSettingsController extends Controller {
return $templateResponse;
}
private function getBundles() {
$result = [];
$bundles = $this->bundleFetcher->getBundles();
foreach ($bundles as $bundle) {
$result[] = [
'name' => $bundle->getName(),
'id' => $bundle->getIdentifier(),
'appIdentifiers' => $bundle->getAppIdentifiers()
];
}
return $result;
}
private function getAllCategories() {
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
@ -385,28 +400,22 @@ class AppSettingsController extends Controller {
foreach($bundles as $bundle) {
$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]);
}
$newApps = $this->getAppsForCategory();
foreach($allApps as $app) {
foreach($newApps as $key => $newApp) {
if($app['id'] === $newApp['id']) {
unset($newApps[$key]);
}
}
$allApps = array_merge($allApps, $newApps);
}
$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();
}
$app['bundleId'] = $bundle->getIdentifier();
$newCategory = false;
$apps[] = $app;
continue;
}

View file

@ -27,16 +27,16 @@
</div>
<div id="apps-list" class="installed" v-if="useBundleView">
<template v-for="app in apps">
<div class="apps-header" v-if="app.newCategory">
<template v-for="bundle in bundles">
<div class="apps-header">
<div class="app-image"></div>
<h2>{{ app.categoryName }} <input class="enable" type="button" value="Alle aktivieren"></h2>
<h2>{{ bundle.name }} <input class="enable" type="button" value="Alle aktivieren"></h2>
<div class="app-version"></div>
<div class="app-level"></div>
<div class="app-groups"></div>
<div class="actions">&nbsp;</div>
</div>
<app-item v-else :key="app.id" :app="app" :category="category"/>
<app-item v-for="app in bundleApps(bundle.id)" :key="app.id" :app="app" :category="category"/>
</template>
</div>
@ -82,6 +82,15 @@ export default {
return this.$store.getters.getApps
.filter(app => app.name.toLowerCase().search(this.search.toLowerCase()) !== -1)
},
bundles() {
return this.$store.getters.getServerData.bundles;
},
bundleApps() {
return function(bundle) {
return this.$store.getters.getApps
.filter(app => app.bundleId === bundle);
}
},
searchApps() {
if (this.search === '') {
return [];