Skip to content

Commit

Permalink
Eoxia#325 [QuickEvent] add: close popup when quickenvent created
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-kilyan committed Nov 5, 2024
1 parent 6524613 commit 8021eb4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
13 changes: 12 additions & 1 deletion class/actions_easycrm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function printCommonFooter(array $parameters): int
$out .= ' - ' . '<span>' . $langs->trans('LastCommercialReminderDate') . ' : ' . dol_print_date($lastActionComm->datec, 'dayhourtext', 'tzuser') . '</span>';
}
if ($user->hasRight('agenda', 'myactions', 'create')) {
$out .= dolButtonToOpenUrlInDialogPopup('quickEventCreation' . $object->id, $langs->transnoentities('QuickEventCreation'), '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans('QuickEventCreation') . '"></span>', '/custom/easycrm/view/quickevent.php' . $url);
$out .= dolButtonToOpenUrlInDialogPopup('quickEventCreation' . $object->id, $langs->transnoentities('QuickEventCreation'), '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans('QuickEventCreation') . '"></span>', '/custom/easycrm/view/quickevent.php' . $url, '', 'classlink button bordertransp', "window.easycrm.quickevent.checkIframeCreation();");
}
if (!empty($lastActionComm)) {
$out .= '<br>' . dolButtonToOpenUrlInDialogPopup('lastActionComm' . $object->id, $langs->transnoentities('LastEvent') . ' : ' . $lastActionComm->label, img_picto('', $lastActionComm->picto) . ' ' . $lastActionComm->label, '/comm/action/card.php?id=' . $lastActionComm->id);
Expand Down Expand Up @@ -457,6 +457,17 @@ public function addHtmlHeader(array $parameters): int
$this->resprints = '<link rel="manifest" href="' . DOL_URL_ROOT . '/custom/easycrm/manifest.json.php' . '" />';
}

if (preg_match('/thirdpartycomm/', $parameters['context'])) {
$resourcesRequired = [
'js' => '/custom/easycrm/js/easycrm.min.js'
];

$out = '<!-- Includes JS added by module easycrm -->';
$out .= '<script src="' . dol_buildpath($resourcesRequired['js'], 1) . '"></script>';

$this->resprints = $out;
}

return 0; // or return 1 to replace standard code-->
}

Expand Down
2 changes: 1 addition & 1 deletion js/easycrm.min.js

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

53 changes: 52 additions & 1 deletion js/modules/quickevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Library javascript to enable Browser notifications
*/

"use strict";

/**
* \file js/quickevent.js
* \ingroup easycrm
Expand Down Expand Up @@ -78,4 +80,53 @@ window.easycrm.quickevent.labelKeyUp = function() {
} else {
$(".quickevent-label-warning-notice").addClass("hidden");
}
}
};

/**
* QuickEvent checkIframeCreation
* Check if the iframe is created
* If the iframe is created, check if the iframe change
*
* @memberof EasyCRM_QuickEvent
*
* @since 1.5.0
* @version 1.5.0
*
* @returns {void}
*/
window.easycrm.quickevent.checkIframeCreation = function() {
const interval = setInterval(function() {
if ($('.iframedialog').length) {
window.easycrm.quickevent.checkIframeChange();
clearInterval(interval);
}
}, 100);
};

/**
* QuickEvent checkIframeChange
* Check if the iframe change
* If the iframe change, reload the page
*
* @memberof EasyCRM_QuickEvent
*
* @since 1.5.0
* @version 1.5.0
*
* @returns {void}
*/
window.easycrm.quickevent.checkIframeChange = function() {
const iframe = $('.iframedialog')[0];
let url = iframe.contentWindow.location.href;

const interval = setInterval(function() {
if (url !== iframe.contentWindow.location.href) {
if (url === 'about:blank') {
url = iframe.contentWindow.location.href;
} else {
location.reload();
clearInterval(interval);
}
}
}, 100);
};

0 comments on commit 8021eb4

Please sign in to comment.