chore: sync module from working instance and add install guide

This commit is contained in:
Kelin Rescue Hub
2026-04-09 14:11:34 -04:00
parent 20adb1bd1e
commit 039c12233e
23 changed files with 4577 additions and 394 deletions

View File

@@ -5,27 +5,205 @@ use humhub\modules\animal_management\models\forms\TransferRequestForm;
use humhub\modules\space\models\Space;
use humhub\widgets\Button;
use yii\bootstrap\ActiveForm;
use yii\helpers\Json;
/* @var Space $space */
/* @var Animal $animal */
/* @var TransferRequestForm $model */
/* @var bool $isInline */
/* @var string $returnTo */
$isInline = isset($isInline) ? (bool)$isInline : false;
$showTopCancel = (string)Yii::$app->request->get('showTopCancel', '0') === '1';
$returnTo = (string)($returnTo ?? 'view');
$transferFormId = 'animal-transfer-request-form';
$this->registerCss(<<<CSS
.animal-transfer-inline-shell.panel {
position: relative;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.22);
border-radius: 12px;
background: rgba(10, 18, 28, 0.36);
}
.animal-transfer-inline-shell > .panel-body {
position: relative;
z-index: 1;
background: rgba(10, 18, 28, 0.2);
}
.animal-transfer-inline-shell,
.animal-transfer-inline-shell .panel-body,
.animal-transfer-inline-shell .panel-heading,
.animal-transfer-inline-shell .control-label,
.animal-transfer-inline-shell .help-block {
color: #eef5fb;
}
.animal-transfer-inline-shell .panel-heading {
background: rgba(15, 23, 42, 0.4);
border-color: rgba(255, 255, 255, 0.22);
margin-left: 20px;
margin-bottom: 20px;
padding: 10px 20px;
max-width: fit-content;
border-radius: 10px;
}
.animal-transfer-inline-shell .panel-heading strong {
color: #f8fafc;
}
.animal-transfer-inline-shell .form-control {
background: rgba(10, 18, 28, 0.56);
border-color: rgba(255, 255, 255, 0.44);
color: #f3f8ff;
}
.animal-transfer-inline-shell .form-control::placeholder {
color: rgba(243, 248, 255, 0.72);
}
.animal-transfer-inline-shell select.form-control option {
color: #0f1b2a;
}
.animal-transfer-inline-shell .animal-inline-top-save-action {
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
padding: 0;
border-radius: 999px;
border: 1px solid rgba(255, 255, 255, 0.36);
background: rgba(15, 23, 42, 0.72);
color: #f8fafc;
cursor: pointer;
line-height: 1;
font-size: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.animal-transfer-inline-shell .animal-inline-top-save-action:hover,
.animal-transfer-inline-shell .animal-inline-top-save-action:focus {
background: rgba(30, 41, 59, 0.86);
border-color: rgba(255, 255, 255, 0.5);
color: #f8fafc;
outline: none;
}
CSS
);
if ($isInline) {
$this->registerCss(<<<CSS
html, body {
margin: 0 !important;
padding: 0 !important;
background: transparent !important;
scrollbar-width: none;
-ms-overflow-style: none;
}
html::-webkit-scrollbar, body::-webkit-scrollbar {
width: 0;
height: 0;
}
body > .panel:first-child {
margin-top: 0 !important;
}
CSS
);
}
?>
<div class="panel panel-default">
<div class="panel panel-default animal-transfer-inline-shell">
<?php if ($isInline): ?>
<div class="animal-inline-top-actions" style="display:flex;justify-content:flex-end;gap:8px;margin:8px 38px 6px 0;">
<?= \yii\helpers\Html::submitButton('<i class="fa fa-check"></i>', [
'class' => 'animal-inline-top-save-action',
'title' => Yii::t('AnimalManagementModule.base', 'Send Request'),
'form' => $transferFormId,
]) ?>
<?php if ($showTopCancel): ?>
<?= \yii\helpers\Html::button('<i class="fa fa-times"></i>', [
'id' => 'transfer-inline-add-cancel-icon',
'class' => 'animal-inline-top-save-action',
'title' => Yii::t('AnimalManagementModule.base', 'Cancel'),
'type' => 'button',
]) ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="panel-heading">
<?= Yii::t('AnimalManagementModule.base', '<strong>Transfer Request</strong> for {animal}', ['animal' => $animal->getDisplayName()]) ?>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?php
$formOptions = ['id' => $transferFormId];
if (!$isInline) {
$formOptions['target'] = '_top';
}
$form = ActiveForm::begin(['options' => $formOptions]);
?>
<?= \yii\helpers\Html::hiddenInput('returnTo', $returnTo) ?>
<?= $form->errorSummary($model, ['showAllErrors' => true]) ?>
<?= $form->field($model, 'to_space_id')->dropDownList($model->getTargetOptions(), ['prompt' => Yii::t('AnimalManagementModule.base', 'Select destination rescue')]) ?>
<?= $form->field($model, 'request_message')->textarea(['rows' => 4]) ?>
<?= $form->field($model, 'conditions_text')->textarea(['rows' => 3]) ?>
<?= Button::save(Yii::t('AnimalManagementModule.base', 'Send Request'))->submit() ?>
<?= Button::asLink(Yii::t('AnimalManagementModule.base', 'Cancel'))
->link($space->createUrl('/animal_management/animals/index')) ?>
<?php if (!$isInline): ?>
<?= Button::save(Yii::t('AnimalManagementModule.base', 'Send Request'))->submit() ?>
<?= Button::asLink(Yii::t('AnimalManagementModule.base', 'Cancel'))
->link($space->createUrl('/animal_management/animals/index')) ?>
<?php endif; ?>
<?php ActiveForm::end(); ?>
</div>
</div>
<?php
if ($isInline) {
$cancelPayload = Json::htmlEncode([
'source' => 'animal-inline-editor',
'type' => 'cancel',
'collapseId' => 'transfer-add-inline',
]);
$this->registerJs(<<<JS
(function() {
function postInlineCancel() {
if (window.parent && window.parent !== window) {
window.parent.postMessage($cancelPayload, '*');
}
}
if (window.jQuery) {
window.jQuery(document).on('click', '#transfer-inline-add-cancel, #transfer-inline-add-cancel-icon', function() {
postInlineCancel();
});
}
document.addEventListener('click', function(event) {
var target = event.target;
if (!target || !target.closest) {
return;
}
if (!target.closest('#transfer-inline-add-cancel, #transfer-inline-add-cancel-icon')) {
return;
}
postInlineCancel();
}, false);
})();
JS
, \yii\web\View::POS_END);
}
?>