Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/issuetemplate.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-02-08 19:58:48 +0300
committerJulius Härtl <jus@bitgrid.net>2018-08-15 18:39:15 +0300
commitc71357519020f49837047f575aa926b4c3e14aa8 (patch)
treee608acf6b50257b792e895a575a1fd032ed8d129 /lib
parented5f61d7149c9a0cbcdbbe3e6c37e4ceea4fb433 (diff)
Add section endpoint
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/APIController.php47
-rw-r--r--lib/DetailManager.php7
-rw-r--r--lib/Section.php8
3 files changed, 43 insertions, 19 deletions
diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php
index ec4a9ae..ad4537f 100644
--- a/lib/Controller/APIController.php
+++ b/lib/Controller/APIController.php
@@ -75,31 +75,42 @@ class APIController extends Controller {
$this->eventDispatcher->dispatch('\OCA\IssueTemplate::requestInformation', $event);
}
- public function details($app) {
+ public function sections($app) {
+ $this->queryAppDetails($app);
+
+ $sections = [];
+
+ /** @var ISection $section */
+ foreach ($this->detailManager->getSections() as $section) {
+ $sections[] = $section;
+ }
+ return $sections;
+ }
+
+ public function details($app, $sectionIdentifier) {
$this->queryAppDetails($app);
$model = [];
$schema = [];
- $sections = $this->detailManager->getSections();
- /** @var ISection $section */
- foreach ($sections as $section) {
- $model[$section->getIdentifier()] = [];
- $group = [
- 'legend' => $section->getTitle(),
- 'fields' => []
+ $section = $this->detailManager->getSection($sectionIdentifier);
+
+ $model[$section->getIdentifier()] = [];
+ $group = [
+ 'legend' => $section->getTitle(),
+ 'fields' => []
+ ];
+ /** @var IDetail $detail */
+ foreach ($section->getDetails() as $detail) {
+ $model[$section->getIdentifier()][$detail->getIdentifier()] = $detail->getInformation();
+ $group['fields'][] = [
+ 'type' => $this->getTypeFieldSchema($detail->getType()),
+ 'label' => $detail->getTitle(),
+ 'model' => $section->getIdentifier() . '.' . $detail->getIdentifier()
];
- /** @var IDetail $detail */
- foreach ($section->getDetails() as $detail) {
- $model[$section->getIdentifier()][$detail->getIdentifier()] = $detail->getInformation();
- $group['fields'][] = [
- 'type' => $this->getTypeFieldSchema($detail->getType()),
- 'label' => $detail->getTitle(),
- 'model' => $section->getIdentifier() . '.' . $detail->getIdentifier()
- ];
- }
- $schema['groups'][] = $group;
}
+ $schema['groups'][] = $group;
+
return [
'model' => $model,
'schema' => $schema
diff --git a/lib/DetailManager.php b/lib/DetailManager.php
index 8bba6c5..6baf90d 100644
--- a/lib/DetailManager.php
+++ b/lib/DetailManager.php
@@ -71,6 +71,13 @@ class DetailManager {
return $this->sections;
}
+ /**
+ * @return ISection
+ */
+ public function getSection($identifier) {
+ return $this->sections[$identifier];
+ }
+
public function getRenderedDetails() {
$result = '';
/** @var ISection $section */
diff --git a/lib/Section.php b/lib/Section.php
index 05ffeee..4590c99 100644
--- a/lib/Section.php
+++ b/lib/Section.php
@@ -23,7 +23,7 @@
namespace OCA\IssueTemplate;
-class Section implements ISection {
+class Section implements ISection, \JsonSerializable {
/** @var string */
private $identifier;
@@ -77,4 +77,10 @@ class Section implements ISection {
return $detail;
}
+ public function jsonSerialize() {
+ return [
+ 'identifier' => $this->getIdentifier(),
+ 'title' => $this->getTitle(),
+ ];
+ }
} \ No newline at end of file