Skip to content

Commit

Permalink
Merge pull request #154 from ConductionNL/development
Browse files Browse the repository at this point in the history
Fixes for related objects & Directory sync
  • Loading branch information
WilcoLouwerse authored Dec 9, 2024
2 parents 50fbbcf + 879a475 commit 3b280fc
Show file tree
Hide file tree
Showing 39 changed files with 998 additions and 131 deletions.
44 changes: 44 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,47 @@
margin-left: 16px;
color: inherit;
}

/* CodeMirror */
.codeMirrorContainer {
margin-block-start: 6px;
text-align: left;
}

.prettifyButton {
margin-block-start: 10px;
}

.codeMirrorContainer * .cm-content {
border-radius: 0 !important;
border: none !important;
}
.codeMirrorContainer * .cm-editor {
outline: none !important;
}
.codeMirrorContainer.light > .vue-codemirror {
border: 1px dotted silver;
}
.codeMirrorContainer.dark > .vue-codemirror {
border: 1px dotted grey;
}

/* value text color */
.codeMirrorContainer.light * .cm-content *::selection {
color: inherit !important;
background-color: #add6ff80 !important;
}
.codeMirrorContainer.dark * .cm-content *::selection {
color: inherit !important;
background-color: #add6ff26 !important;
}

/* value text color */
.codeMirrorContainer.dark :deep(.ͼ2 .cm-activeLine) {
background-color: #add6ff26;
}

/* text cursor */
.codeMirrorContainer :deep(.cm-content) * {
cursor: text !important;
}
19 changes: 18 additions & 1 deletion lib/Controller/AttachmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\IURLGenerator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Uid\Uuid;
Expand All @@ -37,6 +38,7 @@ class AttachmentsController extends Controller
* @param FileService $fileService The file service
* @param IUserSession $userSession The user session
* @param ObjectService $objectService The object service
* @param IURLGenerator $urlGenerator The URL generator
*/
public function __construct
(
Expand All @@ -46,7 +48,8 @@ public function __construct
private readonly AttachmentMapper $attachmentMapper,
private readonly FileService $fileService,
private readonly IUserSession $userSession,
private readonly ObjectService $objectService
private readonly ObjectService $objectService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -129,6 +132,17 @@ public function create(ObjectService $objectService): JSONResponse
// Save the new attachment object.
$object = $this->objectService->saveObject('attachment', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.attachments.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('attachment', $object);
}

// Return the created object as a JSON response.
return new JSONResponse($object);
}
Expand All @@ -153,6 +167,9 @@ public function update(string|int $id, ObjectService $objectService): JSONRespon
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.attachments.show', ['id' => $data['id']]));

// Save the updated attachment object
$object = $this->objectService->saveObject('attachment', $data);

Expand Down
19 changes: 18 additions & 1 deletion lib/Controller/CatalogiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

Expand All @@ -33,6 +34,7 @@ class CatalogiController extends Controller
* @param ObjectService $objectService The object service
* @param DirectoryService $directoryService The directory service
* @param BroadcastService $broadcastService The broadcast service
* @param IURLGenerator $urlGenerator The URL generator
*/
public function __construct(
$appName,
Expand All @@ -41,7 +43,8 @@ public function __construct(
private readonly CatalogMapper $catalogMapper,
private readonly ObjectService $objectService,
private readonly DirectoryService $directoryService,
private readonly BroadcastService $broadcastService
private readonly BroadcastService $broadcastService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -114,6 +117,17 @@ public function create(ObjectService $objectService): JSONResponse
// Save the new catalog object
$object = $this->objectService->saveObject('catalog', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.catalogs.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('catalog', $object);
}

// Update all external directories
$this->broadcastService->broadcast();

Expand Down Expand Up @@ -142,6 +156,9 @@ public function update(string|int $id, ObjectService $objectService): JSONRespon
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.catalogs.show', ['id' => $data['id']]));

// Save the updated catalog object
$object = $this->objectService->saveObject('catalog', $data);

Expand Down
20 changes: 18 additions & 2 deletions lib/Controller/OrganizationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
use OCP\IRequest;

use OCP\IURLGenerator;
/**
* Class OrganizationsController
*
Expand All @@ -26,13 +26,15 @@ class OrganizationsController extends Controller
* @param IAppConfig $config The app configuration
* @param OrganizationMapper $organizationMapper The organization mapper
* @param ObjectService $objectService The object service
* @param IURLGenerator $urlGenerator The URL generator
*/
public function __construct(
$appName,
IRequest $request,
private readonly IAppConfig $config,
private readonly OrganizationMapper $organizationMapper,
private readonly ObjectService $objectService
private readonly ObjectService $objectService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -109,6 +111,17 @@ public function create(): JSONResponse
// Save the new organization object
$object = $this->objectService->saveObject('organization', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.organizations.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('organization', $object);
}

// Return the created object as a JSON response
return new JSONResponse($object);
}
Expand All @@ -130,6 +143,9 @@ public function update(string|int $id): JSONResponse
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.organizations.show', ['id' => $data['id']]));

// Save the updated organization object
$object = $this->objectService->saveObject('organization', $data);

Expand Down
23 changes: 20 additions & 3 deletions lib/Controller/PublicationTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
use OCP\IRequest;

use OCP\IURLGenerator;
/**
* Class PublicationTypesController
*
Expand All @@ -29,6 +29,7 @@ class PublicationTypesController extends Controller
* @param ObjectService $objectService The object service
* @param DirectoryService $directoryService The directory service
* @param BroadcastService $broadcastService The broadcast service
* @param IURLGenerator $urlGenerator The URL generator
*/
public function __construct(
$appName,
Expand All @@ -37,7 +38,8 @@ public function __construct(
private readonly PublicationTypeMapper $publicationTypeMapper,
private readonly ObjectService $objectService,
private readonly DirectoryService $directoryService,
private readonly BroadcastService $broadcastService
private readonly BroadcastService $broadcastService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -118,6 +120,17 @@ public function create(): JSONResponse
// Save the new publication type object
$object = $this->objectService->saveObject('publicationType', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publicationTypes.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('publicationType', $object);
}

// Update all external directories
$this->broadcastService->broadcast();

Expand All @@ -142,6 +155,10 @@ public function update(string|int $id): JSONResponse
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publicationTypes.show', ['id' => $data['id']]));


// Save the updated publication type object
$object = $this->objectService->saveObject('publicationType', $data);

Expand Down Expand Up @@ -169,7 +186,7 @@ public function destroy(string|int $id): JSONResponse
// Return the result as a JSON response
return new JSONResponse(['success' => $result], $result === true ? '200' : '404');
}

/**
* Synchronize or delete a publication type based on listing status
*
Expand Down
20 changes: 19 additions & 1 deletion lib/Controller/PublicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Uid\Uuid;
Expand All @@ -49,6 +50,8 @@ class PublicationsController extends Controller
* @param FileService $fileService The file service
* @param DownloadService $downloadService The download service
* @param ObjectService $objectService The object service
* @param IURLGenerator $urlGenerator The URL generator
*
*/
public function __construct
(
Expand All @@ -59,7 +62,8 @@ public function __construct
private readonly IAppConfig $config,
private readonly FileService $fileService,
private readonly DownloadService $downloadService,
private ObjectService $objectService
private readonly ObjectService $objectService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -197,6 +201,17 @@ public function create(ObjectService $objectService): JSONResponse
// Save the new publication object
$object = $this->objectService->saveObject('publication', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publications.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('publication', $object);
}

// Return the created object as a JSON response
return new JSONResponse($object);
}
Expand All @@ -221,6 +236,9 @@ public function update(string|int $id, ObjectService $objectService): JSONRespon
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publications.show', ['id' => $data['id']]));

// Save the updated publication object
$object = $this->objectService->saveObject('publication', $data);

Expand Down
20 changes: 18 additions & 2 deletions lib/Controller/ThemesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
use OCP\IRequest;

use OCP\IURLGenerator;
/**
* Class ThemesController
*
Expand All @@ -27,14 +27,16 @@ class ThemesController extends Controller
* @param ThemeMapper $themeMapper The theme mapper for database operations
* @param IAppConfig $config The app configuration
* @param ObjectService $objectService The service for handling object operations
* @param IURLGenerator $urlGenerator The URL generator
*/
public function __construct
(
$appName,
IRequest $request,
private readonly ThemeMapper $themeMapper,
private readonly IAppConfig $config,
private readonly ObjectService $objectService
private readonly ObjectService $objectService,
private readonly IURLGenerator $urlGenerator
)
{
parent::__construct($appName, $request);
Expand Down Expand Up @@ -97,6 +99,17 @@ public function create(): JSONResponse
// Save the new theme object
$object = $this->objectService->saveObject('theme', $data);

// If object is a class change it to array
if (is_object($object) === true) {
$object = $object->jsonSerialize();
}

// If we do not have an uri, we need to generate one
if (isset($object['uri']) === false) {
$object['uri'] = $this->urlGenerator->getAbsoluteURL($$this->urlGenerator->linkToRoute('openCatalogi.themes.show', ['id' => $object['id']]));
$object = $this->objectService->saveObject('theme', $object);
}

// Return the created object as a JSON response
return new JSONResponse($object);
}
Expand All @@ -118,6 +131,9 @@ public function update(string|int $id): JSONResponse
// Ensure the ID in the data matches the ID in the URL
$data['id'] = $id;

// If we do not have an uri, we need to generate one
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.themes.show', ['id' => $data['id']]));

// Save the updated theme object
$object = $this->objectService->saveObject('theme', $data);

Expand Down
Loading

0 comments on commit 3b280fc

Please sign in to comment.