diff --git a/install/install_schema/data.sql b/install/install_schema/data.sql index d858741576fd..d85240cb5b2e 100644 --- a/install/install_schema/data.sql +++ b/install/install_schema/data.sql @@ -3574,6 +3574,9 @@ insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_clas insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (106,'EditViewPreSave','Reservations_DuplicateChecker_Handler',1,'Reservations','',5,84,1); insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (107,'EntityAfterLinkForSource','ModTracker_ModTrackerHandler_Handler',1,'','',8,32,0); insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (108,'EntityAfterUnLinkForSource','ModTracker_ModTrackerHandler_Handler',1,'','',8,32,0); +insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (109,'EditViewPreSave','Calendar_RepeatEvents_Handler',1,'Calendar','',5,9,1); +insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (110,'PreDelete','Calendar_RepeatEvents_Handler',1,'Calendar','',5,9,1); +insert into `vtiger_eventhandlers`(`eventhandler_id`,`event_name`,`handler_class`,`is_active`,`include_modules`,`exclude_modules`,`priority`,`owner_id`,`privileges`) values (111,'PreStateChange','Calendar_RepeatEvents_Handler',1,'Calendar','',5,9,1); /*Data for the table `vtiger_expectedresponse` */ diff --git a/install/install_schema/scheme.sql b/install/install_schema/scheme.sql index 232c9ab00eb7..33e809d7e333 100644 --- a/install/install_schema/scheme.sql +++ b/install/install_schema/scheme.sql @@ -6394,7 +6394,7 @@ CREATE TABLE `vtiger_eventhandlers` ( `privileges` tinyint(1) DEFAULT 1, PRIMARY KEY (`eventhandler_id`), KEY `event_name_class` (`event_name`,`handler_class`) -) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8; /*Table structure for table `vtiger_expectedresponse` */ diff --git a/layouts/basic/modules/Calendar/Modals/RepeatEvents.tpl b/layouts/basic/modules/Calendar/Modals/RepeatEvents.tpl new file mode 100644 index 000000000000..1ab7f13cca44 --- /dev/null +++ b/layouts/basic/modules/Calendar/Modals/RepeatEvents.tpl @@ -0,0 +1,37 @@ +{**} +{strip} + + + +{/strip} diff --git a/layouts/basic/modules/Calendar/Modals/RepeatEventsDelete.tpl b/layouts/basic/modules/Calendar/Modals/RepeatEventsDelete.tpl new file mode 100644 index 000000000000..16ef17a26fc4 --- /dev/null +++ b/layouts/basic/modules/Calendar/Modals/RepeatEventsDelete.tpl @@ -0,0 +1,38 @@ +{**} +{strip} + + + +{/strip} diff --git a/layouts/basic/modules/Vtiger/Detail/Field/Recurrence.tpl b/layouts/basic/modules/Vtiger/Detail/Field/Recurrence.tpl deleted file mode 100644 index 90f29e6dbe3e..000000000000 --- a/layouts/basic/modules/Vtiger/Detail/Field/Recurrence.tpl +++ /dev/null @@ -1,64 +0,0 @@ -{**} -{strip} -
- -
- {$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'))} -{/strip} diff --git a/layouts/basic/modules/Vtiger/Edit/Field/Recurrence.tpl b/layouts/basic/modules/Vtiger/Edit/Field/Recurrence.tpl index 769f5e65c6d9..a9c2b361a37f 100644 --- a/layouts/basic/modules/Vtiger/Edit/Field/Recurrence.tpl +++ b/layouts/basic/modules/Vtiger/Edit/Field/Recurrence.tpl @@ -11,58 +11,9 @@ -->*} {strip}
-
- -
- {assign var="RECURRING_INFORMATION" value=Vtiger_Recurrence_UIType::getRecurringInfo($FIELD_MODEL->get('fieldvalue'))} @@ -71,27 +22,27 @@ {/if}
- {\App\Language::translate('LBL_RECURRING_TYPE', $MODULE)} + {\App\Language::translate('LBL_RECURRING_TYPE', $MODULE_NAME)}
- {\App\Language::translate('LBL_REPEAT_INTERVAL', $MODULE)} + {\App\Language::translate('LBL_REPEAT_INTERVAL', $MODULE_NAME)}
- {\App\Language::translate('LBL_SM_SUN', $MODULE)} + {\App\Language::translate('LBL_SM_SUN', $MODULE_NAME)} - - - - - -
@@ -159,7 +110,7 @@
- {\App\Language::translate('LBL_REAPEAT_BY', $MODULE)} + {\App\Language::translate('LBL_REAPEAT_BY', $MODULE_NAME)}
@@ -170,8 +121,8 @@
+ aria-label="{\App\Language::translate('LBL_DAY_IN_MONTH', $MODULE_NAME)}" + value="{\App\Language::translate('LBL_DAY_IN_MONTH', $MODULE_NAME)}" readonly="readonly">
@@ -181,13 +132,13 @@
+ aria-label="{\App\Language::translate('LBL_DAY_IN_WEEK', $MODULE_NAME)}" + value="{\App\Language::translate('LBL_DAY_IN_WEEK', $MODULE_NAME)}" readonly="readonly">
- {\App\Language::translate('LBL_REPEAT_END', $MODULE)} + {\App\Language::translate('LBL_REPEAT_END', $MODULE_NAME)}
@@ -198,21 +149,21 @@
+ value="{\App\Language::translate('LBL_NEVER', $MODULE_NAME)}" readonly="readonly">
-  {\App\Language::translate('LBL_COUNT', $MODULE)} +  {\App\Language::translate('LBL_COUNT', $MODULE_NAME)}
@@ -220,14 +171,14 @@ -  {\App\Language::translate('LBL_UNTIL', $MODULE)} +  {\App\Language::translate('LBL_UNTIL', $MODULE_NAME)}
'greaterThanDependentField', 'params' => ['date_start']]]))}' />
diff --git a/modules/Calendar/actions/Delete.php b/modules/Calendar/actions/Delete.php index 0218da652af6..79e14ac62d64 100644 --- a/modules/Calendar/actions/Delete.php +++ b/modules/Calendar/actions/Delete.php @@ -14,22 +14,22 @@ class Calendar_Delete_Action extends Vtiger_Delete_Action /** {@inheritdoc} */ public function process(App\Request $request) { - $this->record->delete(); $typeRemove = Calendar_RecuringEvents_Model::UPDATE_THIS_EVENT; if (!$request->isEmpty('typeRemove')) { $typeRemove = $request->getInteger('typeRemove'); + $this->record->ext['repeatType'] = $typeRemove; } - $recurringEvents = Calendar_RecuringEvents_Model::getInstance(); - $recurringEvents->typeSaving = $typeRemove; - $recurringEvents->recordModel = $this->record; - $recurringEvents->templateRecordId = $request->getInteger('record'); - $recurringEvents->delete(); - $response = new Vtiger_Response(); - if ('List' === $request->getByType('sourceView')) { - $response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_RECORD_HAS_BEEN_DELETED')]]); - } else { - $response->setResult($this->record->getModule()->getListViewUrl()); + $result = $this->performDelete($request); + if (!$result) { + $recurringEvents = Calendar_RecuringEvents_Model::getInstance(); + $recurringEvents->typeSaving = $typeRemove; + $recurringEvents->recordModel = $this->record; + $recurringEvents->templateRecordId = $request->getInteger('record'); } + + $response = new Vtiger_Response(); + $response->setEmitType(Vtiger_Response::$EMIT_JSON); + $response->setResult($result); $response->emit(); } } diff --git a/modules/Calendar/actions/Save.php b/modules/Calendar/actions/Save.php index 215741f35c2d..01fcb7312c55 100644 --- a/modules/Calendar/actions/Save.php +++ b/modules/Calendar/actions/Save.php @@ -46,8 +46,11 @@ public function saveRecord(App\Request $request) protected function getRecordModelFromRequest(App\Request $request) { parent::getRecordModelFromRequest($request); - if (!$request->isEmpty('typeSaving') && Calendar_RecuringEvents_Model::UPDATE_THIS_EVENT === $request->getInteger('typeSaving')) { - $this->record->set('recurrence', $this->record->getPreviousValue('recurrence')); + if (!$request->isEmpty('typeSaving') && ($typeSaving = $request->getInteger('typeSaving'))) { + $this->record->ext['repeatType'] = $typeSaving; + if (Calendar_RecuringEvents_Model::UPDATE_THIS_EVENT === $typeSaving) { + $this->record->set('recurrence', $this->record->getPreviousValue('recurrence')); + } } return $this->record; } diff --git a/modules/Calendar/handlers/RepeatEvents.php b/modules/Calendar/handlers/RepeatEvents.php new file mode 100644 index 000000000000..fd8e8759b91e --- /dev/null +++ b/modules/Calendar/handlers/RepeatEvents.php @@ -0,0 +1,80 @@ + + */ +/** + * Calendar_RepeatEvents_Handler class. + */ +class Calendar_RepeatEvents_Handler +{ + /** + * EditViewPreSave handler function. + * + * @param App\EventHandler $eventHandler + */ + public function editViewPreSave(App\EventHandler $eventHandler) + { + $response = ['result' => true]; + $recordModel = $eventHandler->getRecordModel(); + if ($recordModel->get('reapeat') && !isset($recordModel->ext['repeatType'])) { + $response = [ + 'result' => false, + 'type' => 'modal', + 'url' => "index.php?module=Calendar&view=RepeatEvents&record={$recordModel->getId()}", + ]; + } + return $response; + } + + /** + * Pre delete handler function. + * + * @param App\EventHandler $eventHandler + * + * @return array + */ + public function preDelete(App\EventHandler $eventHandler) + { + $response = ['result' => true]; + $recordModel = $eventHandler->getRecordModel(); + if ($recordModel->get('reapeat') && !isset($recordModel->ext['repeatType'])) { + $response = [ + 'result' => false, + 'type' => 'modal', + 'url' => "index.php?module=Calendar&view=RepeatEventsDelete&record={$recordModel->getId()}", + ]; + } + return $response; + } + + /** + * Register pre state change. + * + * @param App\EventHandler $eventHandler + * + * @return array + */ + public function preStateChange(App\EventHandler $eventHandler) + { + $responseData = ['result' => true]; + $recordModel = $eventHandler->getRecordModel(); + $repeatCondition = $recordModel->get('reapeat'); + $noRepeatType = !isset($recordModel->ext['repeatType']); + $newStateExists = isset($recordModel->ext['newState']); + $isTrashState = \App\Record::STATE_TRASH === $recordModel->ext['newState']; + if ($repeatCondition && $noRepeatType && $newStateExists && $isTrashState) { + $responseData = [ + 'result' => false, + 'type' => 'modal', + 'url' => "index.php?module=Calendar&view=RepeatEventsDelete&record={$recordModel->getId()}", + ]; + } + return $responseData; + } +} diff --git a/modules/Calendar/models/DetailView.php b/modules/Calendar/models/DetailView.php index e62029ca1c8e..accd40358b47 100644 --- a/modules/Calendar/models/DetailView.php +++ b/modules/Calendar/models/DetailView.php @@ -57,11 +57,12 @@ public function getDetailViewLinks(array $linkParams): array $linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ 'linktype' => 'DETAIL_VIEW_EXTENDED', 'linklabel' => 'LBL_MOVE_TO_TRASH', - 'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId() . '")', + 'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'), + 'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId(), + 'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC')], 'linkicon' => 'fas fa-trash-alt', - 'linkclass' => 'btn-outline-dark btn-sm entityStateBtn', + 'linkclass' => 'entityStateBtn btn-outline-dark btn-sm js-record-action', 'style' => empty($stateColors['Trash']) ? '' : "background: {$stateColors['Trash']};", - 'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'), ]); } if (!$recordModel->isReadOnly() && $recordModel->privilegeToDelete() && 1 === $recordModel->get('reapeat')) { @@ -71,12 +72,13 @@ public function getDetailViewLinks(array $linkParams): array } } $linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ - 'linktype' => 'DETAIL_VIEW_EXTENDED', - 'linklabel' => 'LBL_DELETE_RECORD_COMPLETELY', - 'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId() . '")', - 'linkicon' => 'fas fa-eraser', - 'linkclass' => 'btn-outline-dark btn-sm', - 'title' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY'), + 'linktype' => 'DETAIL_VIEW_EXTENDED', + 'linklabel' => 'LBL_DELETE_RECORD_COMPLETELY', + 'title' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY'), + 'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId(), + 'linkdata' => ['confirm' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY_DESC')], + 'linkicon' => 'fas fa-eraser', + 'linkclass' => 'btn-dark btn-sm js-record-action', ]); } return $linkModelList; diff --git a/modules/Calendar/views/RepeatEvents.php b/modules/Calendar/views/RepeatEvents.php new file mode 100644 index 000000000000..2ab61ed51acc --- /dev/null +++ b/modules/Calendar/views/RepeatEvents.php @@ -0,0 +1,50 @@ + + */ + +/** + * Modal window for repeat events purpose class. + */ +class Calendar_RepeatEvents_View extends \App\Controller\Modal +{ + /** {@inheritdoc} */ + public $successBtnIcon = 'far fa-save'; + + /** {@inheritdoc} */ + public $modalIcon = 'fas fa-save mr-2'; + + /** {@inheritdoc} */ + protected $pageTitle = 'LBL_TITLE_TYPE_SAVING'; + + /** {@inheritdoc} */ + public $showFooter = false; + + /** {@inheritdoc} */ + public $autoRegisterEvents = false; + + /** {@inheritdoc} */ + public function checkPermission(App\Request $request) + { + if ($request->isEmpty('record', true)) { + throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406); + } + $recordModel = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), 'Calendar'); + if (!$recordModel->isEditable()) { + throw new \App\Exceptions\NoPermitted('ERR_PERMISSION_DENIED', 406); + } + } + + /** {@inheritdoc} */ + public function process(App\Request $request) + { + $viewer = $this->getViewer($request); + $viewer->view('Modals/RepeatEvents.tpl', $request->getModule()); + } +} diff --git a/modules/Calendar/views/RepeatEventsDelete.php b/modules/Calendar/views/RepeatEventsDelete.php new file mode 100644 index 000000000000..e6432952d6da --- /dev/null +++ b/modules/Calendar/views/RepeatEventsDelete.php @@ -0,0 +1,54 @@ + + */ + +/** + * Modal window for delete repeat events class. + */ +class Calendar_RepeatEventsDelete_View extends \App\Controller\Modal +{ + /** {@inheritdoc} */ + public $successBtnIcon = 'far fa-save'; + + /** {@inheritdoc} */ + public $modalIcon = 'fas fa-save mr-2'; + + /** {@inheritdoc} */ + protected $pageTitle = 'LBL_TITLE_TYPE_DELETE'; + + /** {@inheritdoc} */ + public $showFooter = false; + + /** @var Vtiger_Record_Model */ + private $recordModel; + + /** {@inheritdoc} */ + public $autoRegisterEvents = false; + + /** {@inheritdoc} */ + public function checkPermission(App\Request $request) + { + if ($request->isEmpty('record', true)) { + throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406); + } + $this->recordModel = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), 'Calendar'); + if (!$this->recordModel->privilegeToDelete() || !$this->recordModel->privilegeToMoveToTrash()) { + throw new \App\Exceptions\NoPermitted('ERR_PERMISSION_DENIED', 406); + } + } + + /** {@inheritdoc} */ + public function process(App\Request $request) + { + $viewer = $this->getViewer($request); + $viewer->assign('DELETE_URL', $this->recordModel->getDeleteUrl()); + $viewer->view('Modals/RepeatEventsDelete.tpl', $request->getModule()); + } +} diff --git a/modules/Vtiger/actions/Delete.php b/modules/Vtiger/actions/Delete.php index 218ebf3d2ebc..6b6c19f3805b 100644 --- a/modules/Vtiger/actions/Delete.php +++ b/modules/Vtiger/actions/Delete.php @@ -34,21 +34,37 @@ public function checkPermission(App\Request $request) /** {@inheritdoc} */ public function process(App\Request $request) + { + $result = $this->performDelete($request); + + $response = new Vtiger_Response(); + $response->setEmitType(Vtiger_Response::$EMIT_JSON); + $response->setResult($result); + $response->emit(); + } + + /** + * Perform delete action. + * + * @param App\Request $request + * + * @return array + */ + protected function performDelete(App\Request $request): array { $result = []; - $eventHandler = $this->record->getEventHandler(); $skipHandlers = $request->getArray('skipHandlers', \App\Purifier::ALNUM, [], \App\Purifier::INTEGER); + $eventHandler = $this->record->getEventHandler(); foreach ($eventHandler->getHandlers(\App\EventHandler::PRE_DELETE) as $handler) { $handlerId = $handler['eventhandler_id']; $response = $eventHandler->triggerHandler($handler); if (!($response['result'] ?? null) && (!isset($response['hash'], $skipHandlers[$handlerId]) || $skipHandlers[$handlerId] !== $response['hash'])) { + $result[$handlerId] = $response; if ($result && 'confirm' === ($response['type'] ?? '')) { break; } - $result[$handlerId] = $response; } } - if (!$result) { $this->record->delete(); if ('List' === $request->getByType('sourceView')) { @@ -57,10 +73,6 @@ public function process(App\Request $request) $result = ['url' => $this->record->getModule()->getListViewUrl()]; } } - - $response = new Vtiger_Response(); - $response->setEmitType(Vtiger_Response::$EMIT_JSON); - $response->setResult($result); - $response->emit(); + return $result; } } diff --git a/modules/Vtiger/actions/Save.php b/modules/Vtiger/actions/Save.php index f087bffda91e..98fa0920e265 100644 --- a/modules/Vtiger/actions/Save.php +++ b/modules/Vtiger/actions/Save.php @@ -99,8 +99,9 @@ public function saveRecord(App\Request $request) foreach ($eventHandler->getHandlers(\App\EventHandler::EDIT_VIEW_PRE_SAVE) as $handler) { $handlerId = $handler['eventhandler_id']; $response = $eventHandler->triggerHandler($handler); + if (!($response['result'] ?? null) && (!isset($response['hash'], $skipHandlers[$handlerId]) || $skipHandlers[$handlerId] !== $response['hash'])) { - throw new \App\Exceptions\NoPermittedToRecord($response['message'], 406); + throw new \App\Exceptions\NoPermittedToRecord($response['message'] ?? 'ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406); } } if (!$request->isEmpty('fromView') && 'MassQuickCreate' === $request->getByType('fromView')) { @@ -168,12 +169,12 @@ public function preSaveValidation(App\Request $request) $skipHandlers = $request->getArray('skipHandlers', \App\Purifier::ALNUM, [], \App\Purifier::INTEGER); foreach ($eventHandler->getHandlers(\App\EventHandler::EDIT_VIEW_PRE_SAVE) as $handler) { $handlerId = $handler['eventhandler_id']; - $response = $eventHandler->triggerHandler($handler); - if (!($response['result'] ?? null) && (!isset($response['hash'], $skipHandlers[$handlerId]) || $skipHandlers[$handlerId] !== $response['hash'])) { - if ($result && 'confirm' === ($response['type'] ?? '')) { + $handlerResponse = $eventHandler->triggerHandler($handler); + if (!($handlerResponse['result'] ?? null) && (!isset($handlerResponse['hash'], $skipHandlers[$handlerId]) || $skipHandlers[$handlerId] !== $handlerResponse['hash'])) { + $result[$handlerId] = $handlerResponse; + if ('confirm' === ($handlerResponse['type'] ?? '')) { break; } - $result[$handlerId] = $response; } } $response = new Vtiger_Response(); diff --git a/modules/Vtiger/actions/State.php b/modules/Vtiger/actions/State.php index 414ec0a8e3cf..4513171edb56 100644 --- a/modules/Vtiger/actions/State.php +++ b/modules/Vtiger/actions/State.php @@ -41,6 +41,8 @@ public function checkPermission(App\Request $request) /** {@inheritdoc} */ public function process(App\Request $request) { + $stateId = array_search($request->getByType('state'), \App\Record::STATES); + $this->record->ext['newState'] = $stateId; $result = []; $eventHandler = $this->record->getEventHandler(); $skipHandlers = $request->getArray('skipHandlers', \App\Purifier::ALNUM, [], \App\Purifier::INTEGER); @@ -56,7 +58,6 @@ public function process(App\Request $request) } if (!$result) { - $stateId = array_search($request->getByType('state'), \App\Record::STATES); $this->record->changeState($stateId); if ('List' === $request->getByType('sourceView')) { $result = ['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]; diff --git a/modules/Vtiger/uitypes/Recurrence.php b/modules/Vtiger/uitypes/Recurrence.php index d8398043501c..ecae8fe2c7d3 100644 --- a/modules/Vtiger/uitypes/Recurrence.php +++ b/modules/Vtiger/uitypes/Recurrence.php @@ -57,12 +57,6 @@ public function getTemplateName() return 'Edit/Field/Recurrence.tpl'; } - /** {@inheritdoc} */ - public function getDetailViewTemplateName() - { - return 'Detail/Field/Recurrence.tpl'; - } - /** * Function to get the edit value in display view. * diff --git a/public_html/layouts/basic/modules/Calendar/resources/Detail.js b/public_html/layouts/basic/modules/Calendar/resources/Detail.js deleted file mode 100644 index d14a0de7652d..000000000000 --- a/public_html/layouts/basic/modules/Calendar/resources/Detail.js +++ /dev/null @@ -1,34 +0,0 @@ -/* {[The file is published on the basis of YetiForce Public License 5.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */ -'use strict'; - -Vtiger_Detail_Js( - 'Calendar_Detail_Js', - { - deleteRecord: function (deleteRecordActionUrl) { - app.showConfirmModal({ - text: app.vtranslate('LBL_DELETE_CONFIRMATION'), - confirmedCallback: () => { - app.showModalWindow($('.typeRemoveModal').clone(), function (container) { - container.find('.typeSavingBtn').on('click', function (e) { - var currentTarget = $(e.currentTarget); - app.hideModalWindow(); - AppConnector.request(deleteRecordActionUrl + '&typeRemove=' + currentTarget.data('value')).done(function ( - data - ) { - if (data.success == true) { - window.location.href = data.result; - } else { - app.showNotify({ - text: data.error.message, - type: 'error' - }); - } - }); - }); - }); - } - }); - } - }, - {} -); diff --git a/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js b/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js deleted file mode 100644 index 1c4b3a37ed64..000000000000 --- a/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -/* {[The file is published on the basis of YetiForce Public License 5.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */"use strict";Vtiger_Detail_Js("Calendar_Detail_Js",{deleteRecord:function deleteRecord(deleteRecordActionUrl){app.showConfirmModal({text:app.vtranslate("LBL_DELETE_CONFIRMATION"),confirmedCallback:function confirmedCallback(){app.showModalWindow($(".typeRemoveModal").clone(),function(container){container.find(".typeSavingBtn").on("click",function(e){var currentTarget=$(e.currentTarget);app.hideModalWindow(),AppConnector.request(deleteRecordActionUrl+"&typeRemove="+currentTarget.data("value")).done(function(data){!0==data.success?window.location.href=data.result:app.showNotify({text:data.error.message,type:"error"});});});});}});}},{}); -//# sourceMappingURL=Detail.min.js.map diff --git a/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js.map b/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js.map deleted file mode 100644 index b7b20fa21c30..000000000000 --- a/public_html/layouts/basic/modules/Calendar/resources/Detail.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Detail.min.js","sources":["Detail.js"],"sourcesContent":["/* {[The file is published on the basis of YetiForce Public License 5.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */\n'use strict';\n\nVtiger_Detail_Js(\n\t'Calendar_Detail_Js',\n\t{\n\t\tdeleteRecord: function (deleteRecordActionUrl) {\n\t\t\tapp.showConfirmModal({\n\t\t\t\ttext: app.vtranslate('LBL_DELETE_CONFIRMATION'),\n\t\t\t\tconfirmedCallback: () => {\n\t\t\t\t\tapp.showModalWindow($('.typeRemoveModal').clone(), function (container) {\n\t\t\t\t\t\tcontainer.find('.typeSavingBtn').on('click', function (e) {\n\t\t\t\t\t\t\tvar currentTarget = $(e.currentTarget);\n\t\t\t\t\t\t\tapp.hideModalWindow();\n\t\t\t\t\t\t\tAppConnector.request(deleteRecordActionUrl + '&typeRemove=' + currentTarget.data('value')).done(function (\n\t\t\t\t\t\t\t\tdata\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (data.success == true) {\n\t\t\t\t\t\t\t\t\twindow.location.href = data.result;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tapp.showNotify({\n\t\t\t\t\t\t\t\t\t\ttext: data.error.message,\n\t\t\t\t\t\t\t\t\t\ttype: 'error'\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t},\n\t{}\n);\n"],"names":["Vtiger_Detail_Js","deleteRecord","deleteRecordActionUrl","app","showConfirmModal","text","vtranslate","confirmedCallback","showModalWindow","$","clone","container","find","on","e","currentTarget","hideModalWindow","AppConnector","request","data","done","success","window","location","href","result","showNotify","error","message","type"],"mappings":";;AAAA,kKACA,YAAY,CAEZA,gBAAgB,CACf,oBAAoB,CACpB,CACCC,YAAY,CAAE,SAAAA,YAAUC,CAAAA,qBAAqB,CAAE,CAC9CC,GAAG,CAACC,gBAAgB,CAAC,CACpBC,IAAI,CAAEF,GAAG,CAACG,UAAU,CAAC,yBAAyB,CAAC,CAC/CC,iBAAiB,CAAE,SAAAA,iBAAA,EAAM,CACxBJ,GAAG,CAACK,eAAe,CAACC,CAAC,CAAC,kBAAkB,CAAC,CAACC,KAAK,EAAE,CAAE,SAAUC,SAAS,CAAE,CACvEA,SAAS,CAACC,IAAI,CAAC,gBAAgB,CAAC,CAACC,EAAE,CAAC,OAAO,CAAE,SAAUC,CAAC,CAAE,CACzD,IAAIC,aAAa,CAAGN,CAAC,CAACK,CAAC,CAACC,aAAa,CAAC,CACtCZ,GAAG,CAACa,eAAe,EAAE,CACrBC,YAAY,CAACC,OAAO,CAAChB,qBAAqB,CAAG,cAAc,CAAGa,aAAa,CAACI,IAAI,CAAC,OAAO,CAAC,CAAC,CAACC,IAAI,CAAC,SAC/FD,IAAI,CACH,CACG,CAAAA,CAAAA,EAAAA,IAAI,CAACE,OAAe,CACvBC,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAGL,IAAI,CAACM,MAAM,CAElCtB,GAAG,CAACuB,UAAU,CAAC,CACdrB,IAAI,CAAEc,IAAI,CAACQ,KAAK,CAACC,OAAO,CACxBC,IAAI,CAAE,OACP,CAAC,EAEH,CAAC,EACF,CAAC,EACF,CAAC,EACF,CACD,CAAC,EACF,CACD,CAAC,CACD,EAAE,CACF;;"} \ No newline at end of file diff --git a/public_html/layouts/basic/modules/Calendar/resources/Edit.js b/public_html/layouts/basic/modules/Calendar/resources/Edit.js index 72a65ff5a32a..61ee0dd7f6a3 100644 --- a/public_html/layouts/basic/modules/Calendar/resources/Edit.js +++ b/public_html/layouts/basic/modules/Calendar/resources/Edit.js @@ -279,30 +279,10 @@ Vtiger_Edit_Js( * @param {jQuery} form */ registerFormSubmitEvent: function (form) { - var thisInstance = this; - var lockSave = true; - if (app.getRecordId()) { - form.on(Vtiger_Edit_Js.recordPreSave, function (e) { - if (lockSave && form.find('input[name="reapeat"]').is(':checked')) { - e.preventDefault(); - app.showModalWindow(form.find('.typeSavingModal').clone(), function (container) { - container.find('.typeSavingBtn').on('click', function (e) { - var currentTarget = $(e.currentTarget); - form.find('[name="typeSaving"]').val(currentTarget.data('value')); - app.hideModalWindow(); - lockSave = false; - form.submit(); - }); - }); - } - }); - } + let thisInstance = this; form.on('submit', function (e) { const recurringCheck = form.find('input[name="reapeat"]').is(':checked'); if (recurringCheck) { - if (app.getRecordId() && lockSave) { - e.preventDefault(); - } form.find('[name="recurrence"]').val(thisInstance.getRule()); } let rows = form.find('.js-participants-content .js-participant-row'); diff --git a/public_html/layouts/basic/modules/Calendar/resources/RepeatEvents.js b/public_html/layouts/basic/modules/Calendar/resources/RepeatEvents.js new file mode 100644 index 000000000000..2fe374ac5e65 --- /dev/null +++ b/public_html/layouts/basic/modules/Calendar/resources/RepeatEvents.js @@ -0,0 +1,32 @@ +/* {[The file is published on the basis of YetiForce Public License 5.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */ +'use strict'; +jQuery.Class( + 'Calendar_RepeatEvents_JS', + {}, + { + /** + * Modal container + */ + container: false, + /** + * Set saving mode for records + * @params : jQuery form element + */ + setSavingModeForRecords(form) { + this.container.find('.js-repeat-events-mode').on('click', function (e) { + $.progressIndicator({ position: 'html', blockInfo: { enabled: true } }); + form.find('[name="typeSaving"]').val($(e.currentTarget).data('value')); + form.submit(); + app.hideModalWindow(); + }); + }, + /** + * Register modal events + * @param {jQuery} modalContainer + */ + registerEvents: function (modalContainer) { + this.container = modalContainer; + this.setSavingModeForRecords(this.form); + } + } +); diff --git a/public_html/layouts/basic/modules/Calendar/resources/RepeatEventsDelete.js b/public_html/layouts/basic/modules/Calendar/resources/RepeatEventsDelete.js new file mode 100644 index 000000000000..354deead7edc --- /dev/null +++ b/public_html/layouts/basic/modules/Calendar/resources/RepeatEventsDelete.js @@ -0,0 +1,42 @@ +/* {[The file is published on the basis of YetiForce Public License 5.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */ +'use strict'; +jQuery.Class( + 'Calendar_RepeatEventsDelete_JS', + {}, + { + /** + * Modal container + */ + container: false, + /** + * Set saving mode for records + */ + setDeleteModeForRecords() { + const thisInstance = this; + this.container.find('.js-repeat-events-mode').on('click', function (e) { + app.hideModalWindow(); + $.progressIndicator({ position: 'html', blockInfo: { enabled: true } }); + let deleteRecordActionUrl = thisInstance.container.find('[name="delete-url"]').attr('data-url'); + let removeType = $(e.currentTarget).data('value'); + AppConnector.request(deleteRecordActionUrl + '&typeRemove=' + removeType).done(function (data) { + if (data.success == true) { + window.location.href = data.result.url; + } else { + app.showNotify({ + text: app.vtranslate('JS_ERROR'), + type: 'error' + }); + } + }); + }); + }, + /** + * Register modal events + * @param {jQuery} modalContainer + */ + registerEvents: function (modalContainer) { + this.container = modalContainer; + this.setDeleteModeForRecords(); + } + } +);