Skip to content

Commit

Permalink
Off-the-record option is now available in Story, Group, and Article
Browse files Browse the repository at this point in the history
Closes #397
  • Loading branch information
mikron-ia committed May 30, 2024
1 parent 39c000d commit 61122c6
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 9 deletions.
6 changes: 6 additions & 0 deletions backend/views/article/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<?= $form->field($model, 'text_raw')->textarea(['rows' => 12]) ?>
</div>

<?php if (!$model->isNewRecord): ?>
<div class="col-md-12">
<?= $form->field($model, 'is_off_the_record_change')->checkbox() ?>
</div>
<?php endif; ?>

<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('app', 'BUTTON_CREATE') : Yii::t('app', 'BUTTON_UPDATE'),
Expand Down
2 changes: 1 addition & 1 deletion backend/views/character/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>

<div class="col-md-12">
<?= $form->field($model, 'is_soft_change')->checkbox() ?>
<?= $form->field($model, 'is_off_the_record_change')->checkbox() ?>
</div>
<?php endif; ?>

Expand Down
6 changes: 6 additions & 0 deletions backend/views/group/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
) ?>
</div>

<?php if (!$model->isNewRecord): ?>
<div class="col-md-12">
<?= $form->field($model, 'is_off_the_record_change')->checkbox() ?>
</div>
<?php endif; ?>

<div class="clearfix"></div>

<div class="form-group">
Expand Down
6 changes: 6 additions & 0 deletions backend/views/story/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<?= $form->field($model, 'long')->textarea(['rows' => 20]); ?>
</div>

<?php if (!$model->isNewRecord): ?>
<div class="col-md-12">
<?= $form->field($model, 'is_off_the_record_change')->checkbox() ?>
</div>
<?php endif; ?>

<div class="form-group col-md-2">
<?php
echo Html::submitButton(
Expand Down
10 changes: 8 additions & 2 deletions common/models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Article extends ActiveRecord implements HasEpicControl, HasVisibility, Has
use ToolsForEntity;
use ToolsForDescription;

public bool $is_off_the_record_change = false;

public static function tableName()
{
return 'article';
Expand All @@ -53,6 +55,7 @@ public function rules()
[['text_raw'], 'string'],
[['title', 'subtitle'], 'string', 'max' => 120],
[['visibility'], 'string', 'max' => 20],
[['is_off_the_record_change'], 'boolean'],
[
['description_pack_id'],
'exist',
Expand Down Expand Up @@ -90,6 +93,7 @@ public function attributeLabels()
'text_raw' => Yii::t('app', 'ARTICLE_TEXT'),
'text_ready' => Yii::t('app', 'ARTICLE_TEXT'),
'utility_bag_id' => Yii::t('app', 'UTILITY_BAG'),
'is_off_the_record_change' => Yii::t('app', 'CHECK_OFF_THE_RECORD_CHANGE'),
];
}

Expand Down Expand Up @@ -138,9 +142,11 @@ public function beforeSave($insert)
return parent::beforeSave($insert);
}

public function afterSave($insert, $changedAttributes)
public function afterSave($insert, $changedAttributes): void
{
$this->seenPack->updateRecord();
if (!$this->is_off_the_record_change) {
$this->seenPack->updateRecord();
}
parent::afterSave($insert, $changedAttributes);
}

Expand Down
12 changes: 9 additions & 3 deletions common/models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Group extends ActiveRecord implements Displayable, HasDescriptions, HasEpi
use ToolsForEntity;
use ToolsForHasDescriptions;

public bool $is_off_the_record_change = false;

public static function tableName(): string
{
return 'group';
Expand All @@ -87,6 +89,7 @@ public function rules(): array
],
[['name'], 'string', 'max' => 120],
[['visibility', 'importance_category'], 'string', 'max' => 20],
[['is_off_the_record_change'], 'boolean'],
[
['epic_id'],
'exist',
Expand Down Expand Up @@ -164,13 +167,16 @@ public function attributeLabels(): array
'master_group_id' => Yii::t('app', 'GROUP_MASTER_GROUP'),
'scribble_pack_id' => Yii::t('app', 'SCRIBBLE_PACK'),
'utility_bag_id' => Yii::t('app', 'UTILITY_BAG'),
'is_off_the_record_change' => Yii::t('app', 'CHECK_OFF_THE_RECORD_CHANGE'),
];
}

public function afterSave($insert, $changedAttributes)
public function afterSave($insert, $changedAttributes): void
{
$this->seenPack->updateRecord();
$this->utilityBag->flagAsChanged();
if (!$this->is_off_the_record_change) {
$this->seenPack->updateRecord();
$this->utilityBag->flagAsChanged();
}
$this->utilityBag->flagForImportanceRecalculation();
parent::afterSave($insert, $changedAttributes);
}
Expand Down
12 changes: 9 additions & 3 deletions common/models/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Story extends ActiveRecord implements Displayable, HasParameters, HasEpicC
*/
private $parametersFormatted;

public bool $is_off_the_record_change = false;

public static function tableName()
{
return 'story';
Expand All @@ -69,6 +71,7 @@ public function rules()
[['key'], 'string', 'max' => 80],
[['name'], 'string', 'max' => 120],
[['visibility'], 'string', 'max' => 20],
[['is_off_the_record_change'], 'boolean'],
[
['epic_id'],
'exist',
Expand Down Expand Up @@ -100,6 +103,7 @@ public function attributeLabels()
'data' => Yii::t('app', 'STORY_DATA'),
'parameter_pack_id' => Yii::t('app', 'PARAMETER_PACK'),
'utility_bag_id' => Yii::t('app', 'UTILITY_BAG'),
'is_off_the_record_change' => Yii::t('app', 'CHECK_OFF_THE_RECORD_CHANGE'),
];
}

Expand All @@ -111,10 +115,12 @@ public function afterFind()
parent::afterFind();
}

public function afterSave($insert, $changedAttributes)
public function afterSave($insert, $changedAttributes): void
{
$this->seenPack->updateRecord();
$this->utilityBag->flagAsChanged();
if (!$this->is_off_the_record_change) {
$this->seenPack->updateRecord();
$this->utilityBag->flagAsChanged();
}
parent::afterSave($insert, $changedAttributes);
}

Expand Down
10 changes: 10 additions & 0 deletions console/controllers/CrutchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function actionSaveCharacterSheets(): void
$objects = CharacterSheet::find()->all();

foreach ($objects as $object) {
/** @var CharacterSheet $object */
$object->save(false);
}
}
Expand All @@ -63,6 +64,8 @@ public function actionSaveGroups(): void
$objects = Group::find()->all();

foreach ($objects as $object) {
/** @var Group $object */
$object->is_off_the_record_change = true;
$object->save(false);
}
}
Expand All @@ -77,6 +80,7 @@ public function actionSaveEpics(): void
$objects = Epic::find()->all();

foreach ($objects as $object) {
/** @var Epic $object */
$object->save(false);
}
}
Expand All @@ -90,6 +94,7 @@ public function actionSaveRecaps(): void
$objects = Recap::find()->all();

foreach ($objects as $object) {
/** @var Recap $object */
$object->save(false);
}
}
Expand All @@ -104,6 +109,8 @@ public function actionSaveStories(): void
$objects = Story::find()->all();

foreach ($objects as $object) {
/** @var Story $object */
$object->is_off_the_record_change = true;
$object->save(false);
}
}
Expand All @@ -117,6 +124,8 @@ public function actionSaveArticles(): void
$objects = Article::find()->all();

foreach ($objects as $object) {
/** @var Article $object */
$object->is_off_the_record_change = true;
$object->save(false);
}
}
Expand All @@ -131,6 +140,7 @@ public function actionSaveGames(): void
$objects = Game::find()->all();

foreach ($objects as $object) {
/** @var Game $object */
$object->save(false);
}
}
Expand Down

0 comments on commit 61122c6

Please sign in to comment.