finish front part of thanato and client , WIP save automatically the devis from db

This commit is contained in:
Tiavina 2024-12-20 13:11:19 +03:00
parent 72bb3360f9
commit 4ce4a2ab05
11 changed files with 115 additions and 33 deletions

View File

@ -95,8 +95,6 @@ export default {
values.push({ value: v, label: v })
} else if (result.description) {
let v = decode(result.description)
console.log('description orig', result.description)
console.log('description dest', v)
values.push({ value: v, label: v })
} else if (result.reference) {
let v = decode(result.reference)

View File

@ -109,6 +109,15 @@ export default {
return this.calendarObjectInstance?.client ?? null
},
/**
* Returns the embalmer(Thanato) or null if the event is still loading
*
* @return {string|null}
*/
embalmer() {
return this.calendarObjectInstance?.embalmer ?? null
},
/**
* Returns the description or null if the event is still loading
@ -333,7 +342,7 @@ export default {
* Returns an object with properties from RFCs including
* their displayName, a description, options, etc.
*
* @return {{geo, color, timeTransparency, description, resources, location, client, categories, accessClass, priority, status, locations, articles, clients}}
* @return {{geo, color, timeTransparency, description, resources, location, client, categories, accessClass, priority, status, locations, articles, clients,embalmer,embalmers}}
*/
rfcProps() {
return getRFCProperties()
@ -487,7 +496,6 @@ export default {
* @return {Promise<void>}
*/
async save(thisAndAllFuture = false) {
console.log("MIDITRA ATO NY SAVE",this.calendarObject);
if (!this.calendarObject) {
logger.error('Calendar-object not found')
return
@ -600,7 +608,6 @@ export default {
* @param {string} location New location
*/
updateLocation(location) {
console.log("updateLocation", location)
this.$store.commit('changeLocation', {
calendarObjectInstance: this.calendarObjectInstance,
location,
@ -619,6 +626,18 @@ export default {
})
},
/**
* Updates the embalmer(Thanatopracteur) of the event
*
* @param {string} embalmer New embalmer
*/
updateEmbalmer(embalmer) {
this.$store.commit('changeEmbalmer', {
calendarObjectInstance: this.calendarObjectInstance,
embalmer,
})
},
/**
* Updates the start date of this event
*

View File

@ -106,7 +106,6 @@ const mapCDavObjectToCalendarObject = (dav, calendarId) => {
* @return {object}
*/
const mapCalendarJsToCalendarObject = (calendarComponent, calendarId = null) => {
console.log("Ary ato mapCalendarJsToCalendarObject");
const vObjectIterator = calendarComponent.getVObjectIterator()
const firstVObject = vObjectIterator.next().value
if (!firstVObject) {
@ -124,8 +123,30 @@ const mapCalendarJsToCalendarObject = (calendarComponent, calendarId = null) =>
})
}
const getKeyValueIcsProperty = (key,value) => {
return `${key}:${value}\r\n`;
}
const setCustomKeyValueToIcsAndReturnIcs = (ics, key,value) => {
const property = getKeyValueIcsProperty(key,value);
ics = ics.replace('END:VEVENT', `${property}END:VEVENT`);
return ics;
}
const setCustomKeyValuesArrayToIcsAndReturnIcs = (ics, keyValueArray) => {
debugger
for (var key in keyValueArray) {
const value = keyValueArray[key] ? keyValueArray[key] : '';
ics = setCustomKeyValueToIcsAndReturnIcs(ics, key, value);
}
return ics;
}
export {
getDefaultCalendarObjectObject,
mapCDavObjectToCalendarObject,
mapCalendarJsToCalendarObject,
setCustomKeyValuesArrayToIcsAndReturnIcs,
getKeyValueIcsProperty,
setCustomKeyValueToIcsAndReturnIcs
}

View File

@ -58,6 +58,8 @@ const getDefaultEventObject = (props = {}) => Object.assign({}, {
location: null,
//client of the event
client : null,
//embalmer(Thanato) of the event
embalmer : null,
// description of the event
description: null,
// Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL)
@ -105,6 +107,7 @@ const mapEventComponentToEventObject = (eventComponent) => {
canModifyAllDay: eventComponent.canModifyAllDay(),
location: eventComponent.location,
client : eventComponent.client,
embalmer : eventComponent.embalmer,
description: eventComponent.description,
accessClass: eventComponent.accessClass,
status: eventComponent.status,
@ -203,6 +206,7 @@ const copyCalendarObjectInstanceIntoEventComponent = (eventObject, eventComponen
eventComponent.title = eventObject.title
eventComponent.location = eventObject.location
eventComponent.client = eventObject.client
eventComponent.embalmer = eventObject.embalmer
eventComponent.description = eventObject.description
eventComponent.accessClass = eventObject.accessClass
eventComponent.status = eventObject.status

View File

@ -139,6 +139,23 @@ const getRFCProperties = () => {
client: {
readableName: t('calendar', 'client'),
placeholder: t('calendar', 'Add a client'),
icon: 'User',
},
embalmers: {
readableName: t('calendar', 'Embalmers'),
icon: 'User',
searchable: true,
multiple: false,
info: t('calendar', 'Thanatopracteur from Gestion'),
placeholder: t('calendar', 'Choose thanatopracteur'),
tagPlaceholder: t('calendar', 'Choose thanatopracteur'),
options: [],
},
embalmer: {
readableName: t('calendar', 'Embalmer'),
placeholder: t('calendar', 'Add a thanatopracteur'),
icon: 'MapMarker',
},

View File

@ -321,12 +321,34 @@ const mutations = {
calendarObjectInstance.location = location
},
/**
* Change the client of an event
*
* @param {object} state The Vuex state
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.client New client to set
*/
changeClient(state, { calendarObjectInstance, client }) {
console.log("CHANGE CLIENT STORE", client);
calendarObjectInstance.eventComponent.client = client
calendarObjectInstance.client = client
},
/**
* Change the embalmer (Thanato) of an event
*
* @param {object} state The Vuex state
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.embalmer New embalmer to set
*/
changeEmbalmer(state, { calendarObjectInstance, embalmer }) {
calendarObjectInstance.eventComponent.embalmer = embalmer
calendarObjectInstance.embalmer = embalmer
},
/**
* Change the description of an event
*
@ -1663,9 +1685,6 @@ const actions = {
const eventComponent = state.calendarObjectInstance.eventComponent
const calendarObject = state.calendarObject
debugger
console.log("EVENNNNNNNTTT COMPONENTTTTT", eventComponent);
console.log("CALEEEEENNNDDDARRRR OBJEEEEEEEECCCCC TTTTTTT",calendarObject);
updateAlarms(eventComponent)
updateTalkParticipants(eventComponent)
@ -1693,7 +1712,6 @@ const actions = {
}
if (calendarId !== state.calendarObject.calendarId) {
console.log("MIDITRA ATO AMIN NY MOVE CALENDAR");
await dispatch('moveCalendarObject', {
calendarObject,
newCalendarId: calendarId,

View File

@ -24,7 +24,7 @@
*
*/
import Vue from 'vue'
import { mapCalendarJsToCalendarObject } from '../models/calendarObject.js'
import { mapCalendarJsToCalendarObject, setClientValueToIcsAndReturnIcs, setCustomKeyValuesArrayToIcsAndReturnIcs } from '../models/calendarObject.js'
import logger from '../utils/logger.js'
import {
createEvent,
@ -224,23 +224,26 @@ const actions = {
* @return {Promise<void>}
*/
async updateCalendarObject(context, { calendarObject }) {
debugger
let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT');
if (calendarObject.existsOnServer) {
calendarObject.dav.data = calendarObject.calendarComponent.toICS()
await calendarObject.dav.update()
context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', {
calendarId: calendarObject.calendarId,
calendarObjectId: calendarObject.id,
})
context.commit('incrementModificationCount')
return
// TODO - catch conflicts
}
const calendar = context.getters.getCalendarById(calendarObject.calendarId)
calendarObject.dav = await calendar.dav.createVObject(calendarObject.calendarComponent.toICS())
let icsValue = calendarObject.calendarComponent.toICS();
if(eventComponent != null){
const customKeyValue = {"CLIENT": eventComponent.client, "EMBALMER": eventComponent.embalmer};
icsValue = setCustomKeyValuesArrayToIcsAndReturnIcs(icsValue,customKeyValue);
}
calendarObject.dav = await calendar.dav.createVObject(icsValue);
calendarObject.existsOnServer = true
context.commit('updateCalendarObjectId', { calendarObject })

View File

@ -32,6 +32,7 @@
<EditSimple v-if="showWidgetEventDetails" :is-widget="true" :locations="locations" />
<EditSimple v-if="showWidgetEventDetails" :is-widget="true" :clients="clients" />
<EditSimple v-if="showWidgetEventDetails" :is-widget="true" :embalmers="embalmers" />
</div>
<NcContent v-else app-name="calendar calendar-custom" :class="classNames">

View File

@ -254,22 +254,13 @@
<template #icon>
<AccountMultiple :size="20" decorative />
</template>
<div class="app-sidebar-tab__content">
<InviteesList v-if="!isLoading"
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly"
:is-shared-with-me="isSharedWithMe"
:show-header="false"
@update-dates="updateDates" />
</div>
<SaveButtons v-if="showSaveButtons"
class="app-sidebar-tab__buttons"
:can-create-recurrence-exception="canCreateRecurrenceException"
:is-new="isNew"
:isReadOnly="false"
:force-this-and-all-future="forceThisAndAllFuture"
@save-this-only="prepareAccessForAttachments(false)"
@save-this-and-all-future="prepareAccessForAttachments(true)" />
<PropertySelectAjax class="property-embalmer"
url="/apps/gestion/ajaxGetThanatopracteurs"
:is-read-only="isReadOnly"
:prop-model="rfcProps.embalmers"
:value="embalmer"
:linkify-links="true"
@update:value="updateEmbalmer" />
</NcAppSidebarTab>
<NcAppSidebarTab v-if="!isLoading && !isError && showResources"
id="app-sidebar-tab-resources"

View File

@ -50,6 +50,8 @@ return [
['name' => 'page#ajaxGetArticles', 'url' => '/ajaxGetArticles', 'verb' => 'GET'],
['name' => 'page#ajaxGetProduits', 'url' => '/ajaxGetProduits', 'verb' => 'GET'],
['name' => 'page#ajaxGetClientsName', 'url' => '/ajaxGetClientsName', 'verb' => 'GET'],
['name' => 'page#ajaxGetThanatopracteurs', 'url' => '/ajaxGetThanatopracteurs', 'verb' => 'GET'],
['name' => 'page#getLieux', 'url' => '/getLieux', 'verb' => 'PROPFIND'],
['name' => 'page#insertLieu', 'url' => '/lieu/insert', 'verb' => 'POST'],

View File

@ -379,6 +379,14 @@ class PageController extends Controller {
return $this->myDb->getThanatopracteurs($this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function ajaxGetThanatopracteurs() {
return $this->myDb->getThanatopracteurs($this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired