ics event changes

This commit is contained in:
Yuri Kuznetsov
2021-07-21 12:11:15 +03:00
parent ceef3e690d
commit 3e9556e1ef
8 changed files with 138 additions and 52 deletions
@@ -156,6 +156,8 @@ class IcsDataLoader implements Loader
$this->loadCreatedEvent($entity, $espoEvent, $eventData);
$entity->set('icsEventData', $eventData);
$entity->set('icsEventDateStart', $espoEvent->getDateStart());
}
private function loadCreatedEvent(Entity $entity, EspoEvent $espoEvent, object $eventData): void
@@ -55,7 +55,9 @@
"icsContents": "ICS Contents",
"icsEventData": "ICS Event Data",
"icsEventUid": "ICS Event UID",
"createdEvent": "Created Event"
"createdEvent": "Created Event",
"event": "Event",
"icsEventDateStart": "ICS Event Date Start"
},
"links": {
"replied": "Replied",
@@ -110,7 +112,8 @@
"Filters": "Filters",
"Folders": "Folders",
"No Subject": "No Subject",
"View Users": "View Users"
"View Users": "View Users",
"Event": "Event"
},
"strings": {
"sendingFailed": "Email sending failed"
@@ -27,6 +27,17 @@
"replied",
"replies"
],
"sidePanels": {
"detail": [
{
"name": "event",
"label": "Event",
"view": "views/email/record/panels/event",
"isForm": true,
"hidden": true
}
]
},
"menu":{
"list":{
"buttons":[
@@ -119,6 +130,18 @@
]
}
}
},
"panels": {
"event": {
"visible": {
"conditionGroup": [
{
"type": "isNotEmpty",
"attribute": "icsEventDateStart"
}
]
}
}
}
},
"filterList":[
@@ -347,10 +347,16 @@
"maxLength": 255,
"index": true
},
"createEventButton": {
"icsEventDateStart": {
"type": "datetime",
"readOnly": true,
"notStorable": true
},
"createEvent": {
"type": "base",
"disabled": true,
"notStorable": true
"notStorable": true,
"view": "views/email/fields/create-event"
},
"createdEvent": {
"type": "linkParent",
@@ -26,14 +26,21 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email/fields/create-event-button', ['views/fields/base', 'lib!espo'], function (Dep, Espo) {
define('views/email/fields/create-event', ['views/fields/base', 'lib!espo'], function (Dep, Espo) {
return Dep.extend({
detailTemplate: 'email/fields/create-event-button/detail',
detailTemplate: 'email/fields/create-event/detail',
eventEntityType: 'Meeting',
getAttributeList: function () {
return [
'icsEventData',
'createdEventId',
];
},
events: {
'click [data-action="createEvent"]': function () {
this.createEvent();
@@ -39,62 +39,20 @@ define('views/email/record/panels/default-side', 'views/record/panels/default-si
noLabel: true,
});
this.fieldList.push({
name: 'createEventButton',
view: 'views/email/fields/create-event-button',
noLabel: true,
readOnly: true,
});
this.fieldList.push({
name: 'createdEvent',
readOnly: true,
});
this.controlHasAttachmentField();
this.controlCreateEventButtonField();
this.listenTo(this.model, 'change:hasAttachment', this.controlHasAttachmentField, this);
this.listenTo(this.model, 'change:icsEventData', this.controlCreateEventButtonField, this);
this.listenTo(this.model, 'change:createdEventId', this.controlCreateEventButtonField, this);
},
controlHasAttachmentField: function () {
if (this.model.get('hasAttachment')) {
this.recordViewObject.showField('hasAttachment');
return;
}
else {
this.recordViewObject.hideField('hasAttachment');
}
this.recordViewObject.hideField('hasAttachment');
},
controlCreateEventButtonField: function () {
if (!this.model.get('icsEventData')) {
this.recordViewObject.hideField('createEventButton');
this.recordViewObject.showField('createdEvent');
return;
}
let eventData = this.model.get('icsEventData');
if (eventData.createdEvent) {
this.recordViewObject.hideField('createEventButton');
this.recordViewObject.showField('createdEvent');
return;
}
if (!this.model.get('createdEventId')) {
this.recordViewObject.hideField('createdEvent');
this.recordViewObject.showField('createEventButton');
return;
}
this.recordViewObject.hideField('createEventButton');
this.recordViewObject.showField('createdEvent');
},
});
});
@@ -0,0 +1,87 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2021 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email/record/panels/event', 'views/record/panels/side', function (Dep) {
return class extends Dep {
setupFields() {
super.setupFields();
this.fieldList.push({
name: 'icsEventDateStart',
readOnly: true,
labelText: this.translate('dateStart', 'fields', 'Meeting'),
});
this.fieldList.push({
name: 'createdEvent',
readOnly: true,
});
this.fieldList.push({
name: 'createEvent',
readOnly: true,
noLabel: true,
});
this.controlEventField();
this.listenTo(this.model, 'change:icsEventData', this.controlEventField, this);
this.listenTo(this.model, 'change:createdEventId', this.controlEventField, this);
}
controlEventField() {
if (!this.model.get('icsEventData')) {
this.recordViewObject.hideField('createEvent');
this.recordViewObject.showField('createdEvent');
return;
}
let eventData = this.model.get('icsEventData');
if (eventData.createdEvent) {
this.recordViewObject.hideField('createEvent');
this.recordViewObject.showField('createdEvent');
return;
}
if (!this.model.get('createdEventId')) {
this.recordViewObject.hideField('createdEvent');
this.recordViewObject.showField('createEvent');
return;
}
this.recordViewObject.hideField('createEvent');
this.recordViewObject.showField('createdEvent');
}
};
});