Skip to content

Commit

Permalink
Added Contactmoment widget and form
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Nov 12, 2024
1 parent b935939 commit 61b5bd8
Show file tree
Hide file tree
Showing 17 changed files with 244 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
nextcloud:
user: root
container_name: nextcloud
# entrypoint: occ app:enable openconnector
# entrypoint: occ app:enable zaakafhandelapp
image: nextcloud
restart: always
ports:
Expand Down
1 change: 1 addition & 0 deletions img/account-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/chat-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/office-building-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OCA\ZaakAfhandelApp\Dashboard\ZakenWidget;
use OCA\ZaakAfhandelApp\Dashboard\TakenWidget;
use OCA\ZaakAfhandelApp\Dashboard\OpenZakenWidget;
use OCA\ZaakAfhandelApp\Dashboard\ContactmomentenWidget;

/**
* Class Application
Expand All @@ -34,7 +35,7 @@ public function register(IRegistrationContext $context): void
$context->registerDashboardWidget(ZakenWidget::class);
$context->registerDashboardWidget(TakenWidget::class);
$context->registerDashboardWidget(OpenZakenWidget::class);

$context->registerDashboardWidget(ContactmomentenWidget::class);
}

public function boot(IBootContext $context): void
Expand Down
69 changes: 69 additions & 0 deletions lib/Dashboard/ContactmomentenWidget.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 ContactmomentenWidget implements IWidget
{

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

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

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

/**
* @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 . '-contactmomentenWidget');
Util::addStyle(Application::APP_ID, 'dashboardWidgets');
}
}
10 changes: 10 additions & 0 deletions src/contactmomentenWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import ContactMomentenWidget from './views/widgets/ContactMomentenWidget.vue'

OCA.Dashboard.register('zaakAfhandelApp_contactmomenten_widget', async (el, { widget }) => {
Vue.mixin({ methods: { t, n } })
const View = Vue.extend(ContactMomentenWidget)
new View({
propsData: { title: widget.title },
}).$mount(el)
})
1 change: 1 addition & 0 deletions src/entities/bericht/bericht.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TBericht } from './bericht.types'
export const mockBerichtData = (): TBericht[] => [
{
id: '15551d6f-44e3-43f3-a9d2-59e583c91eb0',
title: 'Bericht 1',
batchID: '15551d6f-44e3-43f3-a9d2-59e583c91eb0',
aanmaakDatum: '2024-01-01',
berichtLeverancierID: '15551d6f-44e3-43f3-a9d2-59e583c91eb0',
Expand Down
3 changes: 3 additions & 0 deletions src/entities/bericht/bericht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TBericht, BerichtID } from './bericht.types'
export class Bericht implements TBericht {

public id: string
public title: string
public batchID: string
public aanmaakDatum: string
public berichtLeverancierID: string
Expand All @@ -22,6 +23,7 @@ export class Bericht implements TBericht {

constructor(source: TBericht) {
this.id = source.id || ''
this.title = source.title || ''
this.batchID = source.batchID || ''
this.aanmaakDatum = source.aanmaakDatum || ''
this.berichtLeverancierID = source.berichtLeverancierID || ''
Expand All @@ -42,6 +44,7 @@ export class Bericht implements TBericht {
public validate(): SafeParseReturnType<TBericht, unknown> {
const schema = z.object({
id: z.string(),
title: z.string(),
batchID: z.string(),
aanmaakDatum: z.string(),
berichtLeverancierID: z.string(),
Expand Down
1 change: 1 addition & 0 deletions src/entities/bericht/bericht.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type BerichtID = string; // create an alias for string called BerichtID t

export type TBericht = {
id: string;
title: string;
batchID: string;
aanmaakDatum: string;
berichtLeverancierID: string;
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ new Vue(
pinia,
render: h => h(App),
},
).$mount('#content')
).$mount('#content')
18 changes: 17 additions & 1 deletion src/modals/berichten/EditBericht.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { berichtStore, navigationStore, klantStore } from '../../store/store.js'
<NcDialog v-if="navigationStore.modal === 'editBericht'"
name="Bericht"
size="normal"
:can-close="false">
@closing="response = $event, closeModalFromButton()">
<NcNoteCard v-if="success" type="success">
<p>Bericht succesvol aangepast</p>
</NcNoteCard>
Expand Down Expand Up @@ -136,6 +136,12 @@ export default {
Plus,
Help,
},
props: {
dashboardWidget: {
type: Boolean,
required: false,
},
},
data() {
return {
success: false,
Expand Down Expand Up @@ -187,6 +193,12 @@ export default {
}
},
methods: {
closeModalFromButton() {
setTimeout(() => {
this.closeModal()
}, 300)
},
closeModal() {
navigationStore.setModal(false)
this.success = false
Expand Down Expand Up @@ -220,6 +232,10 @@ export default {
this.success = true
this.loading = false
setTimeout(this.closeModal, 2000)
if (this.dashboardWidget === true) {
this.$emit('save-success')
}
} catch (error) {
this.loading = false
this.success = false
Expand Down
2 changes: 1 addition & 1 deletion src/views/berichten/BerichtenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { navigationStore, berichtStore } from '../../store/store.js'
</NcActionButton>
</NcActions>
</div>
<div v-if="berichtStore.berichtenList">
<div v-if="!!berichtStore.berichtenList?.length">
<NcListItem v-for="(bericht, i) in berichtStore.berichtenList"
:key="`${bericht}${i}`"
:name="bericht?.onderwerp"
Expand Down
20 changes: 19 additions & 1 deletion src/views/klanten/KlantenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { navigationStore, klantStore } from '../../store/store.js'
</template>
Bewerken
</NcActionButton>
<NcActionButton @click="klantStore.setKlantItem(klant); navigationStore.setDialog('deleteKlant')">
<NcActionButton @click="klantStore.setKlantItem(klant); deleteKlant()">
<template #icon>
<TrashCanOutline :size="20" />
</template>
Expand Down Expand Up @@ -126,6 +126,24 @@ export default {
}
return name
},
deleteKlant() {
fetch(
`/index.php/apps/zaakafhandelapp/api/klanten/${klantStore.klantItem.id}`,
{
method: 'DELETE',
},
)
.then((response) => {
response.json().then((data) => {
this.klantenList = data
})
this.loading = false
})
.catch((err) => {
console.error(err)
this.loading = false
})
},
fetchData(newPage) {
this.loading = true
fetch(
Expand Down
111 changes: 111 additions & 0 deletions src/views/widgets/ContactMomentenWidget.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<script setup>
import { berichtStore, navigationStore } from '../../store/store.js'
</script>

<template>
<div class="contactmomentenContainer">
<div class="itemContainer">
<NcDashboardWidget :items="items"
:loading="loading"
@show="onShow">
<template #empty-content>
<NcEmptyContent :title="t('Geen contact momenten')">
<template #icon>
<ChatOutline />
</template>
</NcEmptyContent>
</template>
</NcDashboardWidget>
</div>

<NcButton type="primary" @click="openModal">
<template #icon>
<Plus :size="20" />
</template>
Contact moment starten
</NcButton>

<BerichtForm v-if="isModalOpen"
:dashboard-widget="true"
@save-success="fetchBerichtItems"
@close="closeModal" />
</div>
</template>

<script>
// Components
import { NcDashboardWidget, NcEmptyContent, NcButton } from '@nextcloud/vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import ChatOutline from 'vue-material-design-icons/ChatOutline.vue'
import BerichtForm from '../../modals/berichten/EditBericht.vue'
export default {
name: 'ContactMomentenWidget',
components: {
NcDashboardWidget,
NcEmptyContent,
NcButton,
Plus,
},
data() {
return {
loading: false,
isModalOpen: false,
berichtItems: [],
}
},
computed: {
items() {
return this.berichtItems
},
},
mounted() {
this.fetchBerichtItems()
},
methods: {
fetchBerichtItems() {
this.loading = true
berichtStore.refreshBerichtenList()
.then(() => {
this.berichtItems = berichtStore.berichtenList.map(bericht => ({
id: bericht.id,
mainText: bericht.title,
subText: bericht.aanmaakDatum,
avatarUrl: '/apps-extra/zaakafhandelapp/img/chat-outline.svg',
}))
this.loading = false
})
},
openModal() {
this.isModalOpen = true
berichtStore.setBerichtItem(null)
navigationStore.setModal('editBericht')
},
closeModal() {
this.isModalOpen = false
navigationStore.setModal(null)
},
onShow() {
window.open('/apps/opencatalogi/catalogi', '_self')
},
},
}
</script>
<style>
.contactmomentenContainer{
display: flex;
justify-content: space-between;
flex-direction: column;
height: 100%;
}
.itemContainer{
overflow: auto;
}
</style>
2 changes: 1 addition & 1 deletion src/views/zaken/ZakenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { navigationStore, zaakStore } from '../../store/store.js'
</NcActions>
</div>

<div v-if="!!zaakStore.zakenList?.length">
<div v-if="!!zaakStore.zakenList?.length && !loading">
<NcListItem v-for="(zaak, i) in zaakStore.zakenList"
:key="`${zaak}${i}`"
:name="zaak?.identificatie"
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ webpackConfig.entry = {
import: path.join(__dirname, 'src', 'openZakenWidget.js'),
filename: appId + '-openZakenWidget.js',
},
contactmomentenWidget: {
import: path.join(__dirname, 'src', 'contactmomentenWidget.js'),
filename: appId + '-contactmomentenWidget.js',
},
}

module.exports = webpackConfig

0 comments on commit 61b5bd8

Please sign in to comment.