Skip to content

Commit

Permalink
Merge pull request #717 from stopfstedt/work-in-progress-indicators
Browse files Browse the repository at this point in the history
Work in progress indicators
  • Loading branch information
stopfstedt authored Feb 20, 2021
2 parents f72b666 + 3c012d0 commit f77fdcf
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 27 deletions.
16 changes: 9 additions & 7 deletions assets/js/app.card_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@
{
var card = app.data.cards.findById(code),
modal = $('#cardModal');
var info = '<div class="card-faction">' + app.format.faction(card) + '</div>'
+ '<div class="card-info">' + app.format.info(card) + '</div>'
+ '<div class="card-traits">' + app.format.traits(card) + '</div>'
+ '<div class="card-text border-' + card.faction_code + '">' + app.format.text(card) + '</div>'
+ '<div class="card-pack">' + app.format.pack(card) + '</div>';

if (card.work_in_progress) {
info = '<div class="alert alert-danger">' + Translator.trans('card.info.workInProgress') + '</div>' + info;
}
if(!card)
return;

modal.data('code', code);
modal.find('.card-modal-link').attr('href', card.url);
modal.find('h3.modal-title').html(app.format.name(card));
modal.find('.modal-image').html('<img class="img-responsive" src="' + card.image_url + '">');
modal.find('.modal-info').html(
'<div class="card-faction">' + app.format.faction(card) + '</div>'
+ '<div class="card-info">' + app.format.info(card) + '</div>'
+ '<div class="card-traits">' + app.format.traits(card) + '</div>'
+ '<div class="card-text border-' + card.faction_code + '">' + app.format.text(card) + '</div>'
+ '<div class="card-pack">' + app.format.pack(card) + '</div>'
);
modal.find('.modal-info').html(info);

var qtyelt = modal.find('.modal-qty');
if(qtyelt) {
Expand Down
21 changes: 11 additions & 10 deletions assets/js/app.tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
var content;
if(mode === 'text') {
var image = card.image_url ? '<div class="card-thumbnail card-thumbnail-' + (card.type_code === 'plot' ? 4 : 3) + 'x card-thumbnail-' + card.type_code + '" style="background-image:url(' + card.image_url + ')"></div>' : "";

content = image
+ '<h4 class="card-name">' + app.format.name(card) + '</h4>'
+ '<div class="card-faction">' + app.format.faction(card) + '</div>'
+ '<div class="card-info">' + app.format.info(card) + '</div>'
+ '<div class="card-traits">' + app.format.traits(card) + '</div>'
+ '<div class="card-text border-' + card.faction_code + '">' + app.format.text(card) + '</div>'
+ '<div class="card-pack">' + app.format.pack(card) + '</div>'
;

var info = '<h4 class="card-name">' + app.format.name(card) + '</h4>';
if (card.work_in_progress) {
info = info + '<div class="alert alert-danger">' + Translator.trans('card.info.workInProgress') + '</div>';
}
info = info
+ '<div class="card-faction">' + app.format.faction(card) + '</div>'
+ '<div class="card-info">' + app.format.info(card) + '</div>'
+ '<div class="card-traits">' + app.format.traits(card) + '</div>'
+ '<div class="card-text border-' + card.faction_code + '">' + app.format.text(card) + '</div>'
+ '<div class="card-pack">' + app.format.pack(card) + '</div>';
content = image + info;
} else {
content = card.image_url ? '<img src="' + card.image_url + '">' : "";
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/ui.card.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
var button = $('<button class="btn btn-default" id="review-button"><span class="glyphicon glyphicon-pencil"></span> ' + Translator.trans('card.reviews.edit') + '</a>');
$('#review-' + review_id + ' .review-text').append(button);
$('input[name=review_id').val(review_id);
$('input[name=review_id]').val(review_id);
};

/**
Expand Down
33 changes: 33 additions & 0 deletions migrations/Version20210217015924.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Adds work-in-progress column to pack table.
*/
final class Version20210217015924 extends AbstractMigration
{
public function getDescription() : string
{
return 'Adds work-in-progress column to pack table.';
}

public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE pack ADD work_in_progress TINYINT(1) DEFAULT \'0\' NOT NULL');
}

public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE pack DROP work_in_progress');
}
}
4 changes: 3 additions & 1 deletion src/Command/ImportStdCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,16 @@ protected function importPacksJsonFile(array $pack, array $map, OutputInterface
$data['size'] = count($pack['cards']);
$data['position'] = $map[$pack['code']]['position'];
$data['cycle_code'] = $map[$pack['code']]['cycle'];
$data['work_in_progress'] = array_key_exists('workInProgress', $pack) ? $pack['workInProgress'] : false;

$entity = $this->getEntityFromData(Pack::class, $data, [
'name',
'code',
'position',
'size',
'date_release',
'cgdb_id'
'cgdb_id',
'work_in_progress',
], [
'cycle_code'
], [], $output);
Expand Down
6 changes: 6 additions & 0 deletions src/Controller/ReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function postAction(Request $request, Texts $texts)
if (!$card) {
throw new Exception("This card does not exist.");
}

if ($card->getPack()->getWorkInProgress()) {
throw $this->createAccessDeniedException(
"This card is considered work-in-progress and cannot be reviewed."
);
}
/*
if(!$card->getPack()->getDateRelease())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function displayAction(
// reconstruction de la bonne chaine de recherche pour affichage
$q = $cardsData->buildQueryFromConditions($conditions);
if ($q && $rows = $cardsData->getSearchRows($conditions, $sort)) {
if (count($rows) == 1) {
if (count($rows) === 1 && ! $rows[0]->getPack()->getWorkInProgress()) {
$includeReviews = true;
}

Expand Down
20 changes: 19 additions & 1 deletion src/Entity/Pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class Pack implements PackInterface
*/
protected $cgdbId;

/**
* @var int|null
*
* @ORM\Column(name="work_in_progress", type="boolean", nullable=false, options={"default"=false})
*/
protected bool $workInProgress = false;

/**
* @var Collection
*
Expand Down Expand Up @@ -295,6 +302,16 @@ public function getCycle()
return $this->cycle;
}

public function getWorkInProgress(): bool
{
return $this->workInProgress;
}

public function setWorkInProgress(bool $workInProgress): void
{
$this->workInProgress = $workInProgress;
}

/**
* @inheritdoc
*/
Expand All @@ -307,7 +324,8 @@ public function serialize()
'name' => $this->name,
'position' => $this->position,
'size' => $this->size,
'cgdb_id' => $this->cgdbId
'cgdb_id' => $this->cgdbId,
'work_in_progress' => $this->workInProgress
];
}

Expand Down
4 changes: 4 additions & 0 deletions src/Entity/PackInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ public function setCycle(CycleInterface $cycle = null);
* @return CycleInterface
*/
public function getCycle();

public function setWorkInProgress(bool $workInProgress): void;

public function getWorkInProgress(): bool;
}
2 changes: 2 additions & 0 deletions src/Services/CardsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ public function getCardInfo(CardInterface $card, bool $api, string $version = nu
$cardinfo['ci'] = is_numeric($cardinfo['ci']) ? intval($cardinfo['ci']) : null;
}

$cardinfo['work_in_progress'] = $card->getPack()->getWorkInProgress();

return $cardinfo;
}

Expand Down
5 changes: 5 additions & 0 deletions templates/Search/card-work-in-progress.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if card.work_in_progress %}
<div class="alert alert-danger" role="alert">
{{ "card.info.workInProgress" | trans }}
</div>
{% endif %}
8 changes: 2 additions & 6 deletions templates/Search/display-card.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/ui.card.js') }}"></script>
<script type="text/javascript">
{% if cards is not empty %}
app.user.params.card_id = {{ cards[0].id }};
{% endif %}
</script>
{% endblock %}

{% block main %}
<div class="row">
<div class="col-md-9">
<div class="col-md-12">
<div class="row">
{% for card in cards %}
<div class="col-sm-7" style="margin-bottom:2em">
Expand All @@ -25,6 +20,7 @@
</h3>
</div>
<div class="panel-body card-content">
{% include 'Search/card-work-in-progress.html.twig' %}
{% include 'Search/card-faction.html.twig' %}
{% include 'Search/card-info.html.twig' %}
{% include 'Search/card-text.html.twig' %}
Expand Down
1 change: 1 addition & 0 deletions templates/Search/display-scan.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{% if index in cards|keys %}
{% set card = cards[index] %}
<div class="col-sm-3" style="margin-bottom:30px">
{% include 'Search/card-work-in-progress.html.twig' %}
<a href="{{ card.url }}" class="no-popup"><img src="{{ card.image_url }}" alt="{{ card.name }}"
style="width:100%" class="img-responsive"></a>
</div>
Expand Down
1 change: 1 addition & 0 deletions templates/Search/display-spoiler.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<div class="faction-icon">
<span class="icon-{{ card.faction_code }} fg-{{ card.faction_code }}"></span>
</div>
{% include 'Search/card-work-in-progress.html.twig' %}
{% include 'Search/card-faction.html.twig' %}
{% include 'Search/card-info.html.twig' %}
{% include 'Search/card-text.html.twig' %}
Expand Down
1 change: 1 addition & 0 deletions translations/messages.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ card:
strini: S.
type: T.
faction: F.
workInProgress: Diese Karte gilt als "in Arbeit" und kann ohne weitere Ankündigung geändert oder entfernt werden.

challenges:
military: Militäreinsatz
Expand Down
1 change: 1 addition & 0 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ card:
strini: S.
type: T.
faction: F.
workInProgress: This card is considered "work in progress" and may be subject to modifications or removal without further notice.

challenges:
military: Military
Expand Down
1 change: 1 addition & 0 deletions translations/messages.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ card:
strini: Fu.
type: T.
faction: F.
workInProgress: Esta tarjeta se considera "trabajo en progreso" y puede estar sujeta a modificaciones o eliminación sin previo aviso.

challenges:
military: Militar
Expand Down

0 comments on commit f77fdcf

Please sign in to comment.