Skip to content

Commit

Permalink
Merge pull request #46 from ConductionNL/feature/PC388-68-and-69/Dash…
Browse files Browse the repository at this point in the history
…board-widgets

feature/PC388-68-and-69/Dashboard-widgets
  • Loading branch information
remko48 authored Nov 13, 2024
2 parents a33ba01 + 96a1a28 commit 2993878
Show file tree
Hide file tree
Showing 22 changed files with 572 additions and 21 deletions.
4 changes: 4 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use OCA\ZaakAfhandelApp\Dashboard\TakenWidget;
use OCA\ZaakAfhandelApp\Dashboard\OpenZakenWidget;
use OCA\ZaakAfhandelApp\Dashboard\ContactmomentenWidget;
use OCA\ZaakAfhandelApp\Dashboard\PersonenWidget;
use OCA\ZaakAfhandelApp\Dashboard\OrganisatiesWidget;

/**
* Class Application
Expand All @@ -36,6 +38,8 @@ public function register(IRegistrationContext $context): void
$context->registerDashboardWidget(TakenWidget::class);
$context->registerDashboardWidget(OpenZakenWidget::class);
$context->registerDashboardWidget(ContactmomentenWidget::class);
$context->registerDashboardWidget(PersonenWidget::class);
$context->registerDashboardWidget(OrganisatiesWidget::class);
}

public function boot(IBootContext $context): void
Expand Down
69 changes: 69 additions & 0 deletions lib/Dashboard/OrganisatiesWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php


namespace OCA\ZaakAfhandelApp\Dashboard;

use OCP\Dashboard\IWidget;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Util;

use OCA\ZaakAfhandelApp\AppInfo\Application;

class OrganisatiesWidget implements IWidget
{

public function __construct(
private IL10N $l10n,
private IURLGenerator $url
) {}

/**
* @inheritDoc
*/
public function getId(): string
{
return 'zaakAfhandelApp_organisaties_widget';
}

/**
* @inheritDoc
*/
public function getTitle(): string
{
return $this->l10n->t('Organisaties zoeken');
}

/**
* @inheritDoc
*/
public function getOrder(): int
{
return 10;
}

/**
* @inheritDoc
*/
public function getIconClass(): string
{
return 'icon-zaken-widget';
}

/**
* @inheritDoc
*/
public function getUrl(): ?string
{
return null;
}

/**
* @inheritDoc
*/
public function load(): void
{
Util::addScript(Application::APP_ID, Application::APP_ID . '-organisatiesWidget');
Util::addStyle(Application::APP_ID, 'dashboardWidgets');
}
}
69 changes: 69 additions & 0 deletions lib/Dashboard/PersonenWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php


namespace OCA\ZaakAfhandelApp\Dashboard;

use OCP\Dashboard\IWidget;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Util;

use OCA\ZaakAfhandelApp\AppInfo\Application;

class PersonenWidget implements IWidget
{

public function __construct(
private IL10N $l10n,
private IURLGenerator $url
) {}

/**
* @inheritDoc
*/
public function getId(): string
{
return 'zaakAfhandelApp_personen_widget';
}

/**
* @inheritDoc
*/
public function getTitle(): string
{
return $this->l10n->t('Personen zoeken');
}

/**
* @inheritDoc
*/
public function getOrder(): int
{
return 10;
}

/**
* @inheritDoc
*/
public function getIconClass(): string
{
return 'icon-zaken-widget';
}

/**
* @inheritDoc
*/
public function getUrl(): ?string
{
return null;
}

/**
* @inheritDoc
*/
public function load(): void
{
Util::addScript(Application::APP_ID, Application::APP_ID . '-personenWidget');
Util::addStyle(Application::APP_ID, 'dashboardWidgets');
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@nextcloud/router": "^2.0.1",
"@nextcloud/vue": "^8.12.0",
"bootstrap-vue": "^2.23.1",
"lodash": "^4.17.21",
"pinia": "^2.2.4",
"vue": "^2.7.14",
"vue-loading-overlay": "^3.4.3",
Expand Down Expand Up @@ -53,4 +54,4 @@
"typescript": "^5.5.4",
"vue-jest": "^3.0.7"
}
}
}
4 changes: 1 addition & 3 deletions src/dialogs/Dialogs.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<!-- Placeholder div -->
<div>

</div>
<div />
</template>

<script>
Expand Down
1 change: 1 addition & 0 deletions src/entities/klanten/klanten.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TKlant } from './klanten.types'
export const mockKlantData = (): TKlant[] => [
{
id: '15551d6f-44e3-43f3-a9d2-59e583c91eb0',
type: 'persoon',
voornaam: 'John',
tussenvoegsel: 'de',
achternaam: 'Doe',
Expand Down
4 changes: 3 additions & 1 deletion src/entities/klanten/klanten.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SafeParseReturnType, z } from 'zod'
import { TKlant } from './klanten.types'
import { TKlant, TKlantType } from './klanten.types'

export class Klant implements TKlant {

public id: string
public type: TKlantType
public voornaam: string
public tussenvoegsel: string
public achternaam: string
Expand All @@ -22,6 +23,7 @@ export class Klant implements TKlant {

constructor(source: TKlant) {
this.id = source.id || ''
this.type = source.type || 'persoon'
this.voornaam = source.voornaam || ''
this.tussenvoegsel = source.tussenvoegsel || ''
this.achternaam = source.achternaam || ''
Expand Down
3 changes: 3 additions & 0 deletions src/entities/klanten/klanten.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export type TKlantType = 'persoon' | 'organisatie'

export type TKlant = {
id: string;
type: TKlantType;
voornaam: string;
tussenvoegsel: string;
achternaam: string;
Expand Down
24 changes: 23 additions & 1 deletion src/modals/klanten/EditKlant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import { klantStore, navigationStore } from '../../store/store.js'
</NcNoteCard>

<div v-if="!success" class="form-group">
<NcSelect
v-bind="typeOptions"
v-model="klantItem.type"
:disabled="loading"
input-label="Type klant"
required />

<NcTextField :disabled="loading"
label="Voornaam"
maxlength="255"
Expand Down Expand Up @@ -105,7 +112,7 @@ import { klantStore, navigationStore } from '../../store/store.js'
Help
</NcButton>
<NcButton v-if="!success"
:disabled="loading"
:disabled="loading || !klantItem.type"
type="primary"
@click="editKlant()">
<template #icon>
Expand All @@ -126,6 +133,7 @@ import {
NcTextField,
NcLoadingIcon,
NcNoteCard,
NcSelect,
} from '@nextcloud/vue'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
Expand All @@ -140,6 +148,7 @@ export default {
NcButton,
NcLoadingIcon,
NcNoteCard,
NcSelect,
// Icons
ContentSaveOutline,
Cancel,
Expand All @@ -154,6 +163,7 @@ export default {
hasUpdated: false,
klantItem: {
voornaam: '',
type: 'persoon',
tussenvoegsel: '',
achternaam: '',
telefoonnummer: '',
Expand All @@ -169,14 +179,24 @@ export default {
subjectIdentificatie: '',
subjectType: '',
},
typeOptions: {
options: [
{ value: 'persoon', label: 'Persoon' },
{ value: 'organisatie', label: 'Organisatie' },
],
},
}
},
updated() {
if (navigationStore.modal === 'editKlant' && !this.hasUpdated) {
const klantType = this.typeOptions.options.find((option) => option.value === klantStore.klantItem?.type)
if (klantStore.klantItem?.id) {
this.klantItem = {
...klantStore.klantItem,
voornaam: klantStore.klantItem.voornaam || '',
type: klantType || { value: 'persoon', label: 'Persoon' },
tussenvoegsel: klantStore.klantItem.tussenvoegsel || '',
achternaam: klantStore.klantItem.achternaam || '',
telefoonnummer: klantStore.klantItem.telefoonnummer || '',
Expand Down Expand Up @@ -205,6 +225,7 @@ export default {
this.hasUpdated = false
this.klantItem = {
voornaam: '',
type: { value: 'persoon', label: 'Persoon' },
tussenvoegsel: '',
achternaam: '',
telefoonnummer: '',
Expand All @@ -226,6 +247,7 @@ export default {
try {
await klantStore.saveKlant({
...this.klantItem,
type: this.klantItem.type.value,
})
this.success = true
this.loading = false
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<NcCheckboxRadioSwitch :checked.sync="configuration.external" type="switch">
{{ t('forms', 'Enable sharing') }}
</NcCheckboxRadioSwitch>

<b>Mongo DB</b>
<NcTextField :value.sync="configuration.mongodbLocation"
label="The location (url)"
Expand Down
10 changes: 10 additions & 0 deletions src/organisatiesWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import OrganisatiesWidget from './views/widgets/OrganisatiesWidget.vue'

OCA.Dashboard.register('zaakAfhandelApp_organisaties_widget', async (el, { widget }) => {
Vue.mixin({ methods: { t, n } })
const View = Vue.extend(OrganisatiesWidget)
new View({
propsData: { title: widget.title },
}).$mount(el)
})
10 changes: 10 additions & 0 deletions src/personenWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import PersonenWidget from './views/widgets/PersonenWidget.vue'

OCA.Dashboard.register('zaakAfhandelApp_personen_widget', async (el, { widget }) => {
Vue.mixin({ methods: { t, n } })
const View = Vue.extend(PersonenWidget)
new View({
propsData: { title: widget.title },
}).$mount(el)
})
Loading

0 comments on commit 2993878

Please sign in to comment.