Skip to content

Commit

Permalink
Merge pull request #382 from mikron-ia/issue-0253
Browse files Browse the repository at this point in the history
  • Loading branch information
mikron-ia authored Oct 7, 2023
2 parents 4ef2db8 + e9de95b commit bb1be71
Show file tree
Hide file tree
Showing 33 changed files with 959 additions and 156 deletions.
2 changes: 1 addition & 1 deletion backend/controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function actionIndex(): string
}

$searchModel = new GroupQuery(self::POSITIONS_PER_PAGE);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); // todo switch to searchForOperator() once Group has updated_at field; see issue #379
$dataProvider = $searchModel->searchForOperator(Yii::$app->request->queryParams);

return $this->render('index', [
'searchModel' => $searchModel,
Expand Down
29 changes: 19 additions & 10 deletions backend/views/game/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use backend\assets\GameAsset;
use common\models\EpicQuery;
use common\models\RecapQuery;
use common\models\Game;
use common\models\RecapQuery;
use kartik\date\DatePicker;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
Expand All @@ -19,17 +19,29 @@

<?php $form = ActiveForm::begin(); ?>

<div class="col-md-6 col-lg-3">
<div class="col-md-6 col-lg-4">
<?= $form->field($model, 'epic_id')->dropDownList(EpicQuery::getListOfEpicsForSelector()); ?>
</div>

<div class="col-md-6 col-lg-2">
<?= $form->field($model, 'status')
->dropDownList($model->isNewRecord ? Game::statusNames() : $model->getAllowedChangeNames())
<?= $form
->field($model, 'status')
->dropDownList(
$model->isNewRecord
? Game::statusNames()
: $model->getAllowedChangeNames()
)
?>
</div>

<div class="col-md-6 col-lg-2">
<div class="col-md-6 col-lg-6">
<?= $form->field($model, 'recap_id')->dropDownList(
RecapQuery::allFromCurrentEpicForSelector(),
['prompt' => ' --- ' . Yii::t('app', 'RECAP_PROMPT') . ' --- ']
) ?>
</div>

<div class="col-md-6 col-lg-6">
<?= $form->field($model, 'planned_date')->widget(
DatePicker::class,
[
Expand All @@ -43,11 +55,8 @@
) ?>
</div>

<div class="col-md-6 col-lg-5">
<?= $form->field($model, 'recap_id')->dropDownList(
RecapQuery::allFromCurrentEpicForSelector(),
['prompt' => ' --- ' . Yii::t('app', 'RECAP_PROMPT') . ' --- ']
) ?>
<div class="col-md-12 col-lg-6">
<?= $form->field($model, 'planned_location') ?>
</div>

<div class="col-md-5">
Expand Down
2 changes: 2 additions & 0 deletions backend/views/game/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
'format' => 'raw',
'value' => Html::a($model->epic->name, ['epic/view', 'key' => $model->epic->key], []),
],
'planned_date',
'planned_location',
[
'attribute' => 'recap_id',
'format' => 'raw',
Expand Down
8 changes: 8 additions & 0 deletions backend/views/group/_view_basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@
'label' => Yii::t('app', 'GROUP_IMPORTANCE'),
'value' => $model->getImportanceCategory(),
],
[
'label' => Yii::t('app', 'DESCRIPTION_COUNT_UNIQUE'),
'value' => $model->descriptionPack->getUniqueDescriptionTypesCount(),
],
[
'label' => Yii::t('app', 'DESCRIPTION_COUNT_EXPECTED'),
'format' => 'raw',
'value' => $model->getImportanceCategoryObject()->minimum() . ' &mdash; ' . $model->getImportanceCategoryObject()->maximum(),
],
[
'attribute' => 'updated_at',
'format' => 'datetime',
],
[
'attribute' => 'master_group_id',
'format' => 'raw',
Expand Down
19 changes: 16 additions & 3 deletions backend/web/js/game.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
$('#game-planned_date').on('change', function () {
$('#game-basics-constructed').val($(this).val());
});
$('#game-basics-constructed').val($('#game-basics').val());

function setBasicsConstructed() {
var datetime = $('#game-planned_date').val();
var location = $('#game-planned_location').val();
var separator = '';

if (datetime && location) {
separator = ', ';
}

$('#game-basics-constructed').val(location + separator + datetime);
}

$('#game-planned_date').on('change', setBasicsConstructed);
$('#game-planned_location').on('keyup', setBasicsConstructed);

$('#game-basics-transfer').on('click', function () {
$('#game-basics').val($('#game-basics-constructed').val());
Expand Down
15 changes: 15 additions & 0 deletions common/messages/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
'GAME_ID' => 'ID',
'GAME_NOTES' => 'Notes',
'GAME_PLANNED_DATE' => 'Planned date',
'GAME_PLANNED_LOCATION' => 'Planned location',
'GAME_POSITION' => 'Position',
'GAME_SESSION_NOT_AVAILABLE' => 'Session not available',
'GAME_STATUS' => 'Status',
Expand Down Expand Up @@ -359,6 +360,7 @@
'GROUP_NOT_AVAILABLE' => 'Group not available',
'GROUP_STATISTICS' => 'Technical data',
'GROUP_SUBGROUPS' => 'Subgroups',
'GROUP_UPDATED_AT' => 'Changed',
'GROUP_VISIBILITY' => 'Visibility',
'GROUP_WITHOUT_MASTER' => 'no master group',
'GROUP_WITHOUT_SUBGROUPS' => 'no subgroups',
Expand Down Expand Up @@ -600,6 +602,19 @@
'SCENARIO_TECHNICAL_DETAILS' => 'Technical details',
'SCENARIO_TITLE_CREATE' => 'Create scenario',
'SCENARIO_TITLE_UPDATE' => 'Modify scenario',
'SCRIBBLES_BUTTON_NO' => 'Click to mark as favorite',
'SCRIBBLES_BUTTON_WORKING' => 'Status change in progress...',
'SCRIBBLES_BUTTON_YES' => 'Marked as favorite; click to unmark',
'SCRIBBLES_FAVORITE_ERROR_GENERIC' => 'Status change error',
'SCRIBBLES_TITLE_NO' => 'Click for player\'s scribbles',
'SCRIBBLES_TITLE_YES' => 'Click for player\'s scribbles',
'SCRIBBLE_DENIED_ACCESS' => 'You have no rights to access this',
'SCRIBBLE_ID' => 'ID',
'SCRIBBLE_IS_FAVORITE' => 'Favorited?',
'SCRIBBLE_PACK' => 'Pack of scribbles',
'SCRIBBLE_PACK_CLASS' => 'Class',
'SCRIBBLE_PACK_ID' => 'ID',
'SCRIBBLE_TITLE' => 'Player\'s scribbles',
'SEEN_ALERT' => 'Alert threshold',
'SEEN_BEFORE_UPDATE' => 'Modified for:',
'SEEN_ID' => 'ID',
Expand Down
15 changes: 15 additions & 0 deletions common/messages/pl/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
'GAME_ID' => 'ID',
'GAME_NOTES' => 'Notatki',
'GAME_PLANNED_DATE' => 'Planowana data',
'GAME_PLANNED_LOCATION' => 'Planowane miejsce',
'GAME_POSITION' => 'Pozycja',
'GAME_SESSION_NOT_AVAILABLE' => 'Sesja niedostępna',
'GAME_STATUS' => 'Status',
Expand Down Expand Up @@ -359,6 +360,7 @@
'GROUP_NOT_AVAILABLE' => 'Grupa niedostępna',
'GROUP_STATISTICS' => 'Dane techniczne',
'GROUP_SUBGROUPS' => 'Grupy podrzędne',
'GROUP_UPDATED_AT' => 'Zmieniano',
'GROUP_VISIBILITY' => 'Widoczność',
'GROUP_WITHOUT_MASTER' => 'Brak grupy nadrzędnej',
'GROUP_WITHOUT_SUBGROUPS' => 'Brak grup podrzędnych',
Expand Down Expand Up @@ -600,6 +602,19 @@
'SCENARIO_TECHNICAL_DETAILS' => 'Szczegóły techniczne',
'SCENARIO_TITLE_CREATE' => 'Dodaj scenariusz',
'SCENARIO_TITLE_UPDATE' => 'Zmień scenariusz',
'SCRIBBLES_BUTTON_NO' => 'Klinij, by dodać do ulubionych',
'SCRIBBLES_BUTTON_WORKING' => 'Zmiana statusu w toku...',
'SCRIBBLES_BUTTON_YES' => 'W ulubionych; kliknij, by usunąć z ulubionych',
'SCRIBBLES_FAVORITE_ERROR_GENERIC' => 'Błąd zapisu statusu',
'SCRIBBLES_TITLE_NO' => 'Zapiski',
'SCRIBBLES_TITLE_YES' => 'Zapiski',
'SCRIBBLE_DENIED_ACCESS' => 'Brak dostępu',
'SCRIBBLE_ID' => 'ID',
'SCRIBBLE_IS_FAVORITE' => 'Ulubione?',
'SCRIBBLE_PACK' => 'Paczka zapisków',
'SCRIBBLE_PACK_CLASS' => 'Klasa',
'SCRIBBLE_PACK_ID' => 'ID',
'SCRIBBLE_TITLE' => 'Zapiski',
'SEEN_ALERT' => 'Próg sygnalizacji',
'SEEN_BEFORE_UPDATE' => 'Zmienione dla:',
'SEEN_ID' => 'ID',
Expand Down
32 changes: 29 additions & 3 deletions common/models/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use common\models\core\HasEpicControl;
use common\models\core\HasImportance;
use common\models\core\HasImportanceCategory;
use common\models\core\HasScribbles;
use common\models\core\HasSightings;
use common\models\core\HasVisibility;
use common\models\core\ImportanceCategory;
Expand Down Expand Up @@ -36,6 +37,7 @@
* @property string $external_data_pack_id
* @property string $seen_pack_id
* @property string $importance_pack_id
* @property int|null $scribble_pack_id
* @property string $utility_bag_id
*
* @property Epic $epic
Expand All @@ -44,12 +46,13 @@
* @property ExternalDataPack $externalDataPack
* @property ImportancePack $importancePack
* @property SeenPack $seenPack
* @property ScribblePack $scribblePack
* @property UtilityBag $utilityBag
* @property CharacterSheet[] $characterSheets
* @property GroupMembership[] $groupMemberships
* @property GroupMembership[] $groupMembershipsVisibleToUser
*/
class Character extends ActiveRecord implements Displayable, HasDescriptions, HasEpicControl, HasImportance, HasImportanceCategory, HasReputations, HasVisibility, HasSightings
class Character extends ActiveRecord implements Displayable, HasDescriptions, HasEpicControl, HasImportance, HasImportanceCategory, HasReputations, HasVisibility, HasScribbles, HasSightings
{
use ToolsForEntity;
use ToolsForHasDescriptions;
Expand All @@ -63,7 +66,7 @@ public function rules()
{
return [
[['epic_id', 'name', 'tagline', 'visibility', 'importance_category'], 'required'],
[['epic_id', 'character_sheet_id', 'description_pack_id'], 'integer'],
[['epic_id', 'character_sheet_id', 'description_pack_id', 'scribble_pack_id'], 'integer'],
[['data', 'visibility', 'importance_category'], 'string'],
[['key'], 'string', 'max' => 80],
[['name', 'tagline'], 'string', 'max' => 120],
Expand Down Expand Up @@ -95,6 +98,13 @@ public function rules()
'targetClass' => ExternalDataPack::class,
'targetAttribute' => ['external_data_pack_id' => 'external_data_pack_id']
],
[
['scribble_pack_id'],
'exist',
'skipOnError' => true,
'targetClass' => ScribblePack::class,
'targetAttribute' => ['scribble_pack_id' => 'scribble_pack_id']
],
[
['visibility'],
'in',
Expand Down Expand Up @@ -122,6 +132,7 @@ public function attributeLabels()
'external_data_pack_id' => Yii::t('app', 'EXTERNAL_DATA_PACK'),
'seen_pack_id' => Yii::t('app', 'SEEN_PACK_ID'),
'importance_pack_id' => Yii::t('app', 'IMPORTANCE_PACK'),
'scribble_pack_id' => Yii::t('app', 'SCRIBBLE_PACK'),
'utility_bag_id' => Yii::t('app', 'UTILITY_BAG'),
];
}
Expand Down Expand Up @@ -167,6 +178,11 @@ public function beforeSave($insert)
$this->importance_pack_id = $pack->importance_pack_id;
}

if (empty($this->scribble_pack_id)) {
$pack = ScribblePack::create('Character');
$this->scribble_pack_id = $pack->scribble_pack_id;
}

return parent::beforeSave($insert);
}

Expand Down Expand Up @@ -204,7 +220,7 @@ static public function allowedVisibilities(): array
/**
* @return ActiveQuery
*/
public function getEpic(): ActiveQuery
public function getEpic(): ActiveQuery
{
return $this->hasOne(Epic::class, ['epic_id' => 'epic_id']);
}
Expand Down Expand Up @@ -238,6 +254,16 @@ public function getImportancePack()
return $this->hasOne(ImportancePack::class, ['importance_pack_id' => 'importance_pack_id']);
}

/**
* Gets query for [[ScribblePack]].
*
* @return \yii\db\ActiveQuery|ScribblePackQuery
*/
public function getScribblePack(): ActiveQuery|ScribblePackQuery
{
return $this->hasOne(ScribblePack::class, ['scribble_pack_id' => 'scribble_pack_id']);
}

/**
* @return ActiveQuery
*/
Expand Down
4 changes: 2 additions & 2 deletions common/models/DescriptionPack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace common\models;

use common\models\core\HasEpicControl;
use common\models\core\IsPack;
use common\models\core\IsEditablePack;
use common\models\core\Language;
use Yii;
use yii\behaviors\TimestampBehavior;
Expand All @@ -21,7 +21,7 @@
* @property Character[] $people
* @property Epic $epic
*/
final class DescriptionPack extends ActiveRecord implements Displayable, IsPack
final class DescriptionPack extends ActiveRecord implements Displayable, IsEditablePack
{
public static function tableName()
{
Expand Down
4 changes: 2 additions & 2 deletions common/models/ExternalDataPack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace common\models;

use common\models\core\HasEpicControl;
use common\models\core\IsPack;
use common\models\core\IsEditablePack;
use common\models\core\Visibility;
use Yii;
use yii\behaviors\TimestampBehavior;
Expand All @@ -20,7 +20,7 @@
*
* @property Epic $epic
*/
class ExternalDataPack extends ActiveRecord implements IsPack
class ExternalDataPack extends ActiveRecord implements IsEditablePack
{
public static function tableName()
{
Expand Down
Loading

0 comments on commit bb1be71

Please sign in to comment.