chore: sync module from working instance and add install guide
This commit is contained in:
@@ -23,11 +23,14 @@ use yii\helpers\Html;
|
||||
/* @var array<int, AnimalMedicalVisit> $latestMedicalVisitByAnimal */
|
||||
/* @var array<int, string> $animalImageUrls */
|
||||
/* @var array<int, string> $transferAnimalImageUrls */
|
||||
/* @var array<int, mixed> $animalDonationGoalsByAnimal */
|
||||
/* @var array $tileFields */
|
||||
/* @var array<int, array> $tileFieldOverrides */
|
||||
/* @var Space $space */
|
||||
/* @var bool $canManage */
|
||||
|
||||
$isTabletFocusMode = ($viewMode === 'tablet') && ((string)Yii::$app->request->get('focus', '') === '1');
|
||||
|
||||
$currentParams = [
|
||||
'q' => $queryValue,
|
||||
'status' => $statusFilter,
|
||||
@@ -40,6 +43,13 @@ $currentParams = [
|
||||
|
||||
$buildUrl = static function (array $overrides) use ($space, $currentParams): string {
|
||||
$params = array_merge($currentParams, $overrides);
|
||||
|
||||
if (($params['view'] ?? '') !== 'tablet') {
|
||||
unset($params['focus']);
|
||||
} elseif (($params['focus'] ?? '') !== '1') {
|
||||
unset($params['focus']);
|
||||
}
|
||||
|
||||
return $space->createUrl('/animal_management/animals/index', $params);
|
||||
};
|
||||
|
||||
@@ -47,16 +57,70 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
$nextDirection = ($sortKey === $column && $sortDirection === 'asc') ? 'desc' : 'asc';
|
||||
return $buildUrl(['sort' => $column, 'direction' => $nextDirection, 'view' => 'table']);
|
||||
};
|
||||
|
||||
$showDonationSettingsLinks = $canManage && $space->moduleManager->isEnabled('donations');
|
||||
?>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<?php if ($isTabletFocusMode): ?>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
#animals-index-panel.animal-focus-overlay {
|
||||
position: fixed !important;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 9999;
|
||||
margin: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
border: 0 !important;
|
||||
width: 100vw !important;
|
||||
max-width: 100vw !important;
|
||||
height: 100vh !important;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#animals-index-panel.animal-focus-overlay .panel-heading {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
#animals-index-panel.animal-focus-overlay .panel-body {
|
||||
flex: 1 1 auto;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="animals-index-panel" class="panel panel-default<?= $isTabletFocusMode ? ' animal-focus-overlay' : '' ?>">
|
||||
<div class="panel-heading" style="display:flex;justify-content:space-between;align-items:center;">
|
||||
<span><?= Yii::t('AnimalManagementModule.base', '<strong>Animals</strong>') ?></span>
|
||||
<span style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;">
|
||||
<?= Html::a('<i class="fa fa-th-large"></i>', $buildUrl(['view' => 'tiles']), [
|
||||
<?= Html::a('<i class="fa fa-tablet"></i>', $buildUrl(['view' => 'tablet', 'focus' => '1']), [
|
||||
'class' => 'btn btn-default btn-sm' . ($viewMode === 'tablet' ? ' active' : ''),
|
||||
'title' => Yii::t('AnimalManagementModule.base', 'Tablet View'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', 'Tablet View'),
|
||||
]) ?>
|
||||
<?= Html::a('<i class="fa fa-bars"></i>', $buildUrl(['view' => 'rows']), [
|
||||
'class' => 'btn btn-default btn-sm' . ($viewMode === 'rows' ? ' active' : ''),
|
||||
'title' => Yii::t('AnimalManagementModule.base', 'Row View'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', 'Row View'),
|
||||
]) ?>
|
||||
<?= Html::a('<i class="fa fa-columns"></i>', $buildUrl(['view' => 'tiles2']), [
|
||||
'class' => 'btn btn-default btn-sm' . ($viewMode === 'tiles2' ? ' active' : ''),
|
||||
'title' => Yii::t('AnimalManagementModule.base', '2-Column View'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', '2-Column View'),
|
||||
]) ?>
|
||||
<?= Html::a('<i class="fa fa-th"></i>', $buildUrl(['view' => 'tiles']), [
|
||||
'class' => 'btn btn-default btn-sm' . ($viewMode === 'tiles' ? ' active' : ''),
|
||||
'title' => Yii::t('AnimalManagementModule.base', 'Tile View'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', 'Tile View'),
|
||||
'title' => Yii::t('AnimalManagementModule.base', '3-Column View'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', '3-Column View'),
|
||||
]) ?>
|
||||
<?= Html::a('<i class="fa fa-table"></i>', $buildUrl(['view' => 'table']), [
|
||||
'class' => 'btn btn-default btn-sm' . ($viewMode === 'table' ? ' active' : ''),
|
||||
@@ -76,6 +140,9 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
<div class="panel-body">
|
||||
<form method="get" action="<?= Html::encode($space->createUrl('/animal_management/animals/index')) ?>" class="form-inline" style="margin-bottom:12px;display:flex;gap:8px;flex-wrap:wrap;">
|
||||
<input type="hidden" name="view" value="<?= Html::encode($viewMode) ?>">
|
||||
<?php if ($isTabletFocusMode): ?>
|
||||
<input type="hidden" name="focus" value="1">
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="sort" value="<?= Html::encode($sortKey) ?>">
|
||||
<input type="hidden" name="direction" value="<?= Html::encode($sortDirection) ?>">
|
||||
<?php foreach ($selectedColumns as $col): ?>
|
||||
@@ -125,12 +192,22 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
<?= Yii::t('AnimalManagementModule.base', 'No animal profiles yet. Create the first intake record to begin tracking.') ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if ($viewMode === 'tiles'): ?>
|
||||
<?php if ($viewMode !== 'table'): ?>
|
||||
<?php
|
||||
$tileColumnClass = 'col-xs-12 col-sm-6 col-md-4';
|
||||
if ($viewMode === 'tiles2') {
|
||||
$tileColumnClass = 'col-xs-12 col-sm-6';
|
||||
} elseif ($viewMode === 'rows') {
|
||||
$tileColumnClass = 'col-xs-12';
|
||||
} elseif ($viewMode === 'tablet') {
|
||||
$tileColumnClass = 'col-xs-12';
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<?php foreach ($animals as $animal): ?>
|
||||
<?php $animalId = (int)$animal->id; ?>
|
||||
<?php $lastMedical = $latestMedicalVisitByAnimal[$animalId] ?? null; ?>
|
||||
<div class="col-sm-6 col-md-4" style="margin-bottom:16px;">
|
||||
<div class="<?= Html::encode($tileColumnClass) ?>" style="margin-bottom:16px;">
|
||||
<?= $this->render('_tile', [
|
||||
'animal' => $animal,
|
||||
'contentContainer' => $space,
|
||||
@@ -138,6 +215,9 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
'imageUrl' => $animalImageUrls[$animalId] ?? '',
|
||||
'tileFields' => $tileFieldOverrides[$animalId] ?? $tileFields,
|
||||
'showMedicalIcon' => true,
|
||||
'showDonationSettingsButton' => $showDonationSettingsLinks,
|
||||
'existingDonationGoal' => $animalDonationGoalsByAnimal[$animalId] ?? null,
|
||||
'tileLayoutMode' => $viewMode,
|
||||
]) ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@@ -205,6 +285,13 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
->link($space->createUrl('/animal_management/animals/medical-visits', ['id' => $animal->id])) ?>
|
||||
<?= Button::asLink(Yii::t('AnimalManagementModule.base', 'Progress'))
|
||||
->link($space->createUrl('/animal_management/animals/progress-updates', ['id' => $animal->id])) ?>
|
||||
<?php if ($showDonationSettingsLinks): ?>
|
||||
<?= Button::asLink(Yii::t('AnimalManagementModule.base', 'Donations'))
|
||||
->link($space->createUrl('/donations/settings', [
|
||||
'goalType' => 'animal',
|
||||
'targetAnimalId' => (int)$animal->id,
|
||||
])) ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManage): ?>
|
||||
<?= Button::asLink(Yii::t('AnimalManagementModule.base', 'Edit'))
|
||||
->link($space->createUrl('/animal_management/animals/edit', ['id' => $animal->id])) ?>
|
||||
@@ -223,10 +310,11 @@ $sortUrl = static function (string $column) use ($buildUrl, $sortKey, $sortDirec
|
||||
<?php if ($canManage): ?>
|
||||
<hr>
|
||||
|
||||
<h4 id="incoming-transfers" style="margin-top:0;"><?= Yii::t('AnimalManagementModule.base', 'Incoming Transfer Requests') ?></h4>
|
||||
<?php if (empty($incomingTransfers)): ?>
|
||||
<div class="text-muted" style="margin-bottom:12px;"><?= Yii::t('AnimalManagementModule.base', 'No incoming requests.') ?></div>
|
||||
<?php else: ?>
|
||||
<?php $incomingTransfersHeading = empty($incomingTransfers)
|
||||
? Yii::t('AnimalManagementModule.base', 'No Incoming Transfers')
|
||||
: Yii::t('AnimalManagementModule.base', 'Incoming Transfer Requests'); ?>
|
||||
<h4 id="incoming-transfers" style="margin-top:0;"><?= Html::encode($incomingTransfersHeading) ?></h4>
|
||||
<?php if (!empty($incomingTransfers)): ?>
|
||||
<div class="row" style="margin-bottom:4px;">
|
||||
<?php foreach ($incomingTransfers as $transfer): ?>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user