Skip to content

Commit

Permalink
Fix/datepicker pt br (#693)
Browse files Browse the repository at this point in the history
* Feat: added class DatePickerWidget

* Fix: added new renderDatePicker

* Fix: added new renderDatePicker for school

* Fix: added new renderDatePicker for student

* Feat: added new version for changelog and config

---------

Co-authored-by: Igor Gonçalves <igor_goncalves@live.com>
  • Loading branch information
nathanipti and igorgoncalves committed Apr 26, 2024
1 parent 40e08ad commit 38b5ca7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 63 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## [Versão 3.78.136]
- Datepicker modificado para apresentar as informações em português

## [Versão 3.78.135]
- Adicionando funcionalidade de validação de planos de aula
- Criando novo tipo de usuário e visibilidade "Coordenador"
Expand Down
41 changes: 41 additions & 0 deletions app/components/DatePickerWidget.php
@@ -0,0 +1,41 @@
<?php

class DatePickerWidget
{
public static function renderDatePicker($model, $attribute)
{
return [
'model' => $model,
'attribute' => $attribute,
'options' => [
'dateFormat' => 'dd/mm/yy',
'changeYear' => true,
'changeMonth' => true,
'yearRange' => '1930:' . date('Y'),
'showOn' => 'focus',
'maxDate' => 0,
'monthNamesShort' => [
'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho',
'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'
],
'dayNames' => [
'Domingo',
'Segunda-feira',
'Terça-feira',
'Quarta-feira',
'Quinta-feira',
'Sexta-feira',
'Sábado'
],
'dayNamesShort' => ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
'dayNamesMin' => ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
],
'htmlOptions' => [
'id' => 'initial_date_picker',
'readonly' => 'readonly',
'style' => 'cursor: pointer;',
'placeholder' => 'Clique aqui para escolher a data'
],
];
}
}
2 changes: 1 addition & 1 deletion config.php
Expand Up @@ -4,7 +4,7 @@
$debug = getenv("YII_DEBUG");
defined('YII_DEBUG') or define('YII_DEBUG', $debug);

define("TAG_VERSION", '3.78.135');
define("TAG_VERSION", '3.78.136');

define("YII_VERSION", Yii::getVersion());
define("BOARD_MSG", '<div class="alert alert-success">Novas atualizações no TAG. Confira clicando <a class="changelog-link" href="?r=admin/changelog">aqui</a>.</div>');
Expand Down
23 changes: 3 additions & 20 deletions themes/default/views/instructor/_form.php
Expand Up @@ -250,26 +250,9 @@
</div>
<div style="margin-left: 23px">
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $modelInstructorIdentification,
'attribute' => 'birthday_date',
'options' => array(
'dateFormat' => 'dd/mm/yy',
'changeYear' => true,
'changeMonth' => true,
'yearRange' => '1930:' . date('Y'),
'showOn' => 'focus',
'maxDate' => 0
),
'htmlOptions' => array(
'readonly' => 'readonly',
'style' => 'cursor: pointer;',
'placeholder' => 'Clique aqui para escolher a data'
),
));

echo CHtml::link(' Limpar', '#', array(
'onclick' => '$("#' . CHtml::activeId($modelInstructorIdentification, 'birthday_date') . '").datepicker("setDate", null); return false;',
$this->widget('zii.widgets.jui.CJuiDatePicker', DatePickerWidget::renderDatePicker($modelInstructorIdentification, 'birthday_date'));
echo CHtml::link(' Limpar', '#', array(
'onclick' => '$("#' . CHtml::activeId($modelInstructorIdentification, 'birthday_date') . '").datepicker("setDate", null); return false;',
));
echo $form->error($modelInstructorIdentification, 'birthday_date');
?>
Expand Down
22 changes: 1 addition & 21 deletions themes/default/views/school/_form.php
Expand Up @@ -247,30 +247,10 @@
array('class' => 't-field-text__label')
); ?>
<?php
$yearRange = (date('Y')-1) . ":";
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $modelSchoolIdentification,
'attribute' => 'initial_date',
'options' => array(
'dateFormat' => 'dd/mm/yy',
'changeYear' => true,
'changeMonth' => true,
'yearRange' => $yearRange . date('Y'),
'showOn' => 'focus',
'maxDate' => 0
),
'htmlOptions' => array(
'id' => 'initial_date_picker',
'readonly' => 'readonly',
'style' => 'cursor: pointer;',
'placeholder' => 'Clique aqui para escolher a data'
),
));

$this->widget('zii.widgets.jui.CJuiDatePicker', DatePickerWidget::renderDatePicker($modelSchoolIdentification, 'initial_date'));
echo CHtml::link(' Limpar', '#', array(
'onclick' => '$("#' . CHtml::activeId($modelSchoolIdentification, 'initial_date') . '").datepicker("setDate", null); return false;',
));

echo $form->error($modelSchoolIdentification, 'initial_date');
?>
</div>
Expand Down
26 changes: 5 additions & 21 deletions themes/default/views/student/_form.php
Expand Up @@ -15,6 +15,8 @@
$cs->registerScriptFile($baseUrl . '/js/student/form/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END);
$cs->registerScriptFile($baseUrl . '/js/student/form/validations.js?v='.TAG_VERSION, CClientScript::POS_END);
$cs->registerScriptFile($baseUrl . '/js/student/form/pagination.js?v='.TAG_VERSION, CClientScript::POS_END);
$cs->registerScriptFile($baseUrl . '/js/student/form/datepicker-pt-BR.js?v='.TAG_VERSION, CClientScript::POS_END);


$cs->registerScriptFile($baseUrl . '/js/enrollment/form/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END);
$cs->registerScriptFile($baseUrl . '/js/enrollment/form/validations.js?v='.TAG_VERSION, CClientScript::POS_END);
Expand Down Expand Up @@ -192,27 +194,9 @@
<div class="t-field-text" id="dateOfBirth">
<?php echo $form->label($modelStudentIdentification, 'birthday', array('class' => 't-field-text__label--required')); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $modelStudentIdentification,
'attribute' => 'birthday',
'options' => array(
'dateFormat' => 'dd/mm/yy',
'changeYear' => true,
'changeMonth' => true,
'yearRange' => '1930:' . date('Y'),
'showOn' => 'focus',
'maxDate' => 0
),
'htmlOptions' => array(
'id' => 'initial_date_picker',
'readonly' => 'readonly',
'style' => 'cursor: pointer;',
'placeholder' => 'Clique aqui para escolher a data'
),
));

echo CHtml::link(' Limpar', '#', array(
'onclick' => '$("#' . CHtml::activeId($modelStudentIdentification, 'birthday') . '").datepicker("setDate", null); return false;',
$this->widget('zii.widgets.jui.CJuiDatePicker', DatePickerWidget::renderDatePicker($modelStudentIdentification, 'birthday'));
echo CHtml::link(' Limpar', '#', array(
'onclick' => '$("#' . CHtml::activeId($modelStudentIdentification, 'birthday') . '").datepicker("setDate", null); return false;',
));
echo $form->error($modelStudentIdentification, 'birthday');
?>
Expand Down

0 comments on commit 38b5ca7

Please sign in to comment.