Skip to content

Commit

Permalink
Merge pull request #72 from ConductionNL/feature/PC108-82/Contactmome…
Browse files Browse the repository at this point in the history
…nt-detail-page

feature/PC108-82/Contactmoment-detail-page
  • Loading branch information
remko48 authored Dec 2, 2024
2 parents 805fe9f + e86d78b commit b6a716e
Show file tree
Hide file tree
Showing 30 changed files with 1,805 additions and 130 deletions.
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'klanten' => ['url' => 'api/klanten'],
'berichten' => ['url' => 'api/berichten'],
'contactmomenten' => ['url' => 'api/contactmomenten'],
'medewerkers' => ['url' => 'api/medewerkers'],

],
'routes' => [
Expand Down
134 changes: 134 additions & 0 deletions lib/Controller/MedewerkersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

namespace OCA\ZaakAfhandelApp\Controller;

use OCA\ZaakAfhandelApp\Service\ObjectService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;

/**
* Controller for handling employees (medewerkers) operations
*/
class MedewerkersController extends Controller
{
public function __construct(
$appName,
IRequest $request,
private readonly ObjectService $objectService,
)
{
parent::__construct($appName, $request);
}

/**
* Return (and search) all employees
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function index(): JSONResponse
{
// Retrieve all request parameters
$requestParams = $this->request->getParams();

// Fetch employees based on filters and order
$data = $this->objectService->getResultArrayForRequest('medewerkers', $requestParams);

// Return JSON response
return new JSONResponse($data);
}

/**
* Read a single employee
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function show(string $id): JSONResponse
{
// Fetch the employee by its ID
$object = $this->objectService->getObject('medewerkers', $id);

// Return the employee as a JSON response
return new JSONResponse($object);
}

/**
* Create an employee
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function create(): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

// Remove the 'id' field if it exists, as we're creating a new employee
unset($data['id']);

// Save the new employee
$object = $this->objectService->saveObject('medewerkers', $data);

// Return the created employee as a JSON response
return new JSONResponse($object);
}

/**
* Update an employee
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function update(string $id): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

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

// Return the updated employee as a JSON response
return new JSONResponse($object);
}

/**
* Delete an employee
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function destroy(string $id): JSONResponse
{
// Delete the employee
$result = $this->objectService->deleteObject('medewerkers', $id);

// Return the result as a JSON response
return new JSONResponse(['success' => $result], $result === true ? '200' : '404');
}

/**
* Get audit trail for a specific employee
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function getAuditTrail(string $id): JSONResponse
{
$auditTrail = $this->objectService->getAuditTrail('medewerkers', $id);
return new JSONResponse($auditTrail);
}
}
7 changes: 5 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function index(): JSONResponse
{
// Initialize the data array
$data = [];
$data['objectTypes'] = ['berichten', 'besluiten', 'documenten', 'klanten', 'resultaten', 'taken', 'informatieobjecten', 'organisaties', 'personen', 'zaken', 'rollen', 'statusen', 'zaakeigenschappen', 'zaaktypen','contactmomenten'];
$data['objectTypes'] = ['berichten', 'besluiten', 'documenten', 'klanten', 'resultaten', 'taken', 'informatieobjecten', 'organisaties', 'personen', 'zaken', 'rollen', 'statusen', 'zaakeigenschappen', 'zaaktypen','contactmomenten', 'medewerkers'];
$data['openRegisters'] = false;
$data['availableRegisters'] = [];

Expand Down Expand Up @@ -102,7 +102,10 @@ public function index(): JSONResponse
'zaaktypen_register' => '',
'contactmomenten_source' => 'internal',
'contactmomenten_schema' => '',
'contactmomenten_register' => ''
'contactmomenten_register' => '',
'medewerkers_source' => 'internal',
'medewerkers_schema' => '',
'medewerkers_register' => ''
];

// Get the current values for the object types from the configuration
Expand Down
1 change: 1 addition & 0 deletions src/entities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from './klanten/index.js'
export * from './taak/index.js'
export * from './bericht/index.js'
export * from './rol/index.js'
export * from './medewerkers/index.js'
export * from './contactmoment/index.js'
3 changes: 3 additions & 0 deletions src/entities/medewerkers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './medewerkers.ts'
export * from './medewerkers.types.ts'
export * from './medewerkers.mock.ts'
14 changes: 14 additions & 0 deletions src/entities/medewerkers/medewerkers.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Medewerker } from './medewerkers'
import { TMedewerker } from './medewerkers.types'

export const mockMedewerkerData = (): TMedewerker[] => [
{
id: '15551d6f-44e3-43f3-a9d2-59e583c91eb0',
voornaam: 'John',
tussenvoegsel: 'de',
achternaam: 'Doe',
email: '[email protected]',
},
]

export const mockMedewerker = (data: TMedewerker[] = mockMedewerkerData()): TMedewerker[] => data.map(item => new Medewerker(item))
12 changes: 12 additions & 0 deletions src/entities/medewerkers/medewerkers.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Medewerker } from './medewerkers'
import { mockMedewerkerData } from './medewerkers.mock'

describe('Medewerker Entity', () => {
it('should create a Medewerker entity with full data', () => {
const medewerker = new Medewerker(mockMedewerkerData()[0])

expect(medewerker).toBeInstanceOf(Medewerker)
expect(medewerker).toEqual(mockMedewerkerData()[0])
expect(medewerker.validate().success).toBe(true)
})
})
33 changes: 33 additions & 0 deletions src/entities/medewerkers/medewerkers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { SafeParseReturnType, z } from 'zod'
import { TMedewerker } from './medewerkers.types'

export class Medewerker implements TMedewerker {

public id: string
public voornaam: string
public tussenvoegsel: string
public achternaam: string
public email: string

constructor(source: TMedewerker) {
this.id = source.id || ''
this.voornaam = source.voornaam || ''
this.tussenvoegsel = source.tussenvoegsel || ''
this.achternaam = source.achternaam || ''
this.email = source.email || ''

}

public validate(): SafeParseReturnType<TMedewerker, unknown> {
const schema = z.object({
id: z.string().optional(),
voornaam: z.string().min(1),
tussenvoegsel: z.string(),
achternaam: z.string(),
email: z.string().email(),
})

return schema.safeParse(this)
}

}
7 changes: 7 additions & 0 deletions src/entities/medewerkers/medewerkers.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type TMedewerker = {
id: string;
voornaam: string;
tussenvoegsel: string;
achternaam: string;
email: string;
}
5 changes: 4 additions & 1 deletion src/modals/Modals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import { navigationStore } from '../store/store.js'
<ViewKlantAuditTrail v-if="navigationStore.modal === 'viewKlantAuditTrail'" />
<EditBericht />
<ViewBerichtAuditTrail v-if="navigationStore.modal === 'viewBerichtAuditTrail'" />
<EditTaak />
<EditTaak v-if="navigationStore.modal === 'editTaak'" />
<WidgetTaakForm v-if="navigationStore.modal === 'widgetTaakForm'" />
<ViewTaakAuditTrail v-if="navigationStore.modal === 'viewTaakAuditTrail'" />
<EditRol />
<ViewZaakAuditTrail v-if="navigationStore.modal === 'viewZaakAuditTrail'" />
<ViewKlantRegister v-if="navigationStore.modal === 'viewKlantRegister'" />
<DeleteContactMoment v-if="navigationStore.modal === 'deleteContactMoment'" />
<EditMedewerker v-if="navigationStore.modal === 'editMedewerker'" />
</div>
</template>

Expand All @@ -37,6 +38,7 @@ import EditRol from './rollen/EditRol.vue'
import ViewZaakAuditTrail from './zaken/ViewZaakAuditTrail.vue'
import ViewKlantRegister from './klantRegister/ViewKlantRegister.vue'
import DeleteContactMoment from './contactMomenten/DeleteContactMoment.vue'
import EditMedewerker from './medewerkers/EditMedewerker.vue'
export default {
name: 'Modals',
components: {
Expand All @@ -54,6 +56,7 @@ export default {
ViewZaakAuditTrail,
ViewKlantRegister,
DeleteContactMoment,
EditMedewerker,
},
}
</script>
Loading

0 comments on commit b6a716e

Please sign in to comment.