| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage core |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2025 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
/** |
| 15 |
* Obtain vars from arguments received in the layout file. |
| 16 |
* |
| 17 |
* @var array $data The data for rendering the areas/projects for single selection. |
| 18 |
*/ |
| 19 |
extract($displayData); |
| 20 |
|
| 21 |
// determine the JS event to dispatch upon the selection of an area/project |
| 22 |
$select_event = $data['select_event'] ?? 'vbo-tm-area-id-selected'; |
| 23 |
|
| 24 |
?> |
| 25 |
<div class="vbo-tm-areapicker-list"> |
| 26 |
<?php |
| 27 |
// iterate over all the existing task areas |
| 28 |
foreach (VBOTaskModelArea::getInstance()->getItems() as $area): |
| 29 |
// wrap the area record into a registry |
| 30 |
$taskArea = VBOTaskArea::getInstance((array) $area); |
| 31 |
?> |
| 32 |
<div class="selectable-area-container"> |
| 33 |
<div class="area-info"> |
| 34 |
<div class="area-name"> |
| 35 |
<?php VikBookingIcons::e($taskArea->getIcon()); ?> <?php echo $taskArea->getName(); ?> |
| 36 |
</div> |
| 37 |
<?php if ($comments = $taskArea->get('comments')): ?> |
| 38 |
<div class="area-comments"> |
| 39 |
<?php echo $comments; ?> |
| 40 |
</div> |
| 41 |
<?php endif; ?> |
| 42 |
</div> |
| 43 |
<div class="area-actions"> |
| 44 |
<button type="button" class="btn btn-success" data-area-id="<?php echo $taskArea->getID(); ?>" data-area-name="<?php echo $this->escape($taskArea->getName()); ?>"><?php echo JText::translate('VBO_SELECT'); ?></button> |
| 45 |
</div> |
| 46 |
</div> |
| 47 |
<?php endforeach; ?> |
| 48 |
</div> |
| 49 |
|
| 50 |
<script> |
| 51 |
/** |
| 52 |
* Register the click events over the various areas/projects. |
| 53 |
*/ |
| 54 |
document.querySelectorAll('.vbo-tm-areapicker-list button[data-area-id]') |
| 55 |
.forEach((button) => { |
| 56 |
button.addEventListener('click', (e) => { |
| 57 |
VBOCore.emitEvent('<?php echo $select_event; ?>', { |
| 58 |
area: { |
| 59 |
id: button.getAttribute('data-area-id'), |
| 60 |
name: button.getAttribute('data-area-name'), |
| 61 |
}, |
| 62 |
}); |
| 63 |
}); |
| 64 |
}); |
| 65 |
</script> |