-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#454 Add ProgressField #483
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
abae57c
Add ProgressField
f99b5cf
#454 Fix code styling and deprecated dependencies
b2b4bf0
#454 Fix Review + Improve
31aecde
#454 Fix Code Styling
86ea3f0
#454 Correctif show ProgressValue percent
cfcee78
#454 fix Rework ProgressBarField
416c46e
#454 fix error bottomLabel
c4feda9
#454 fix style max exceeding
4747a1e
#454 fix style background
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Crudit ProgressBar Field | ||
|
||
### Usage | ||
|
||
To enable the progress bar for a field, you need to set the type: | ||
|
||
```php | ||
$value = Field::new("value", ProgressField::class); | ||
``` | ||
And it's done ! | ||
|
||
### Attributs | ||
|
||
You can customize your ProgressField with the following options: | ||
|
||
- 'barCssClass' => Defines the color of the progress bar with a Bootstrap class, | ||
- 'progressLabel' => Change the label displayed on the progress bar, | ||
- 'progressLabelCssClass' => Defines the Bootstrap class for the label to customize it, | ||
- 'min' => Integer who defines the minimum value, | ||
- 'max' => integer who defines the maximum value, | ||
- 'isBottomLabelActivate' => activates or deactivates the bottom label with true/false, | ||
- 'bottomLabel' => Change the label under the bar, | ||
|
||
### Example: | ||
|
||
```php | ||
$nbDeplacement = Field::new('nbDeplacement', ProgressBarField::class) | ||
->setOptions( | ||
[ | ||
"barCssClass" => "bg-info", | ||
"progressLabel" => "Example" | ||
"progressLabelCssClass" => "lh-sm fa-sm text-black" | ||
"isBottomLabelActivate" => true, | ||
] | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lle\CruditBundle\Field; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class ProgressBarField extends AbstractField | ||
{ | ||
public function support(string $type): bool | ||
{ | ||
return (in_array($type, ["progress", self::class])); | ||
} | ||
|
||
public function getDefaultTemplate(): ?string | ||
{ | ||
return "@LleCrudit/field/progressbar.html.twig"; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $optionsResolver): void | ||
{ | ||
parent::configureOptions($optionsResolver); | ||
$optionsResolver->setDefaults([ | ||
"barCssClass" => null, | ||
"progressLabel" => null, | ||
"progressLabelCssClass" => null, | ||
"min" => 0, | ||
"max" => 100, | ||
"isBottomLabelActivate" => false, | ||
"bottomLabel" => null, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="position-relative d-flex"> | ||
<div class="progress w-100" role="progressbar" aria-valuenow="{{ value }}" | ||
aria-valuemin="{{ options.min }}" aria-valuemax="{{ options.max }}"> | ||
<div class="progress-bar | ||
{% if value > options.max %} bg-danger | ||
{% else %} bg-primary {% endif %} | ||
{% if options.barCssClass %} {{ options.barCssClass }}{% endif %} | ||
progress-bar-animated" style="width: {{ value }}%;"> | ||
</div> | ||
</div> | ||
<div class="d-flex position-absolute justify-content-center align-items-center w-100"> | ||
<span class="{% if value > options.max %} text-white {% endif %} | ||
{% if options.progressLabelCssClass %} {{ options.progressLabelCssClass }} | ||
{% else %} lh-sm fa-sm {% endif %}"> | ||
{% if options.progressLabel %} | ||
{{ options.progressLabel }} | ||
{% else %} {{ value }} % {% endif %} | ||
</span> | ||
</div> | ||
</div> | ||
|
||
{% if options.isBottomLabelActivate %} | ||
<div> | ||
<span class="{% if options.progressLabelCssClass %} {{ options.progressLabelCssClass }} | ||
{% else %} lh-sm fa-sm {% endif %}"> | ||
{% if options.bottomLabel %} {{ options.bottomLabel }} | ||
{% else %} {{ value }} % {% endif %} | ||
</span> | ||
</div> | ||
{% endif %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j'aimerais bien qu'on puisse avoir ça à partir d'une propriété/méthode dans l'entité.
si l'entité définit son propre maximum, on peut pas avoir une valeur fixe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ce qui est prévu c'est que l'entité calcule le pourcentage, donc le dev peut le faire avec n'importe quelle valeur de maximum. Par défaut, c'est 100 et 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
si c'est un pourcentage le min max ce sera toujours 0 à 100 si jamais
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
donc pas très utile d'avoir ces 2 options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
effectivement ca n'a que peux d'interet.