Commit 366db7ee1fa7c3f5dfd7e45cc604fb5e04f1b6ee

Authored by Everton Muniz
Committed by GitHub
2 parents 94f2648b 21d6cb58
Exists in 2.8 and in 6 other branches 2.2, 2.3, 2.4, 2.5, 2.6, 2.7

Merge pull request #6241 from portabilis/issue-6222

Altera exibição de mensagens no faltas e notas
ieducar/intranet/styles/custom.css
... ... @@ -32,6 +32,10 @@ input:read-only {
32 32 background-color: #e9f0f8 !important;
33 33 }
34 34  
  35 +.input-success {
  36 + background-color: #a7f9a8;
  37 +}
  38 +
35 39 .select2-container{
36 40 font-size: 14px;
37 41 line-height: 15px;
... ...
ieducar/intranet/styles/flash-messages.css
... ... @@ -4,7 +4,6 @@
4 4 margin: 0 auto;
5 5 max-height: 100vh;
6 6 overflow-y: auto;
7   - pointer-events: none;
8 7 position: fixed;
9 8 right: 0;
10 9 top: 0;
... ... @@ -95,3 +94,8 @@
95 94 font-weight: bold;
96 95 margin-bottom: 4px;
97 96 }
  97 +
  98 +.msg-diario.flashMessages {
  99 + width: 400px;
  100 + left: auto;
  101 +}
... ...
ieducar/modules/Avaliacao/Assets/Javascripts/Diario.js
... ... @@ -376,13 +376,15 @@ function postNota($notaFieldElement) {
376 376  
377 377 $notaFieldElement.data('old_value', $notaFieldElement.val());
378 378 postResource(options, handleErrorOnPostResource);
  379 + } else {
  380 + $j('#' + $notaFieldElement.attr('id')).addClass('error');
379 381 }
380 382 }
381 383  
382 384 function checkIfShowNotaRecuperacaoParalelaField(notaLancada, dataResponse){
383 385 componente_curricular_id = dataResponse.componente_curricular_id;
384 386 matricula_id = dataResponse.matricula_id;
385   - $jnotaRecuperacaoParalelaField = $j('#nota-recuperacao-paralela-' + matricula_id + '-cc-' + componente_curricular_id);
  387 + $jnotaRecuperacaoParalelaField = $j('#nota_recuperacao_paralela-matricula-' + matricula_id + '-cc-' + componente_curricular_id);
386 388  
387 389 if(!$jnotaRecuperacaoParalelaField.length){
388 390 return false;
... ... @@ -436,6 +438,8 @@ function postNotaExame($notaExameFieldElement) {
436 438  
437 439 $notaExameFieldElement.data('old_value', $notaExameFieldElement.val());
438 440 postResource(options, handleErrorOnPostResource);
  441 + } else {
  442 + $j('#' + $notaExameFieldElement.attr('id')).addClass('error');
439 443 }
440 444 }
441 445  
... ... @@ -469,6 +473,8 @@ function postNotaRecuperacaoParalela($notaRecuperacaoParalelaElement) {
469 473  
470 474 $notaRecuperacaoParalelaElement.data('old_value', $notaRecuperacaoParalelaElement.val());
471 475 postResource(options, handleErrorOnPostResource);
  476 + } else {
  477 + $j('#' + $notaRecuperacaoParalelaElement.attr('id')).addClass('error');
472 478 }
473 479 }
474 480  
... ... @@ -500,6 +506,8 @@ function postNotaRecuperacaoEspecifica($notaRecuperacaoEspecificaElement) {
500 506  
501 507 $notaRecuperacaoEspecificaElement.data('old_value', $notaRecuperacaoEspecificaElement.val());
502 508 postResource(options, handleErrorOnPostResource);
  509 + } else {
  510 + $j('#' + $notaRecuperacaoEspecificaElement.attr('id')).addClass('error');
503 511 }
504 512 }
505 513  
... ... @@ -532,6 +540,17 @@ function postFalta($faltaFieldElement) {
532 540  
533 541 $faltaFieldElement.data('old_value', $faltaFieldElement.val());
534 542 postResource(options, handleErrorOnPostResource);
  543 + } else {
  544 + $j('#' + $faltaFieldElement.attr('id')).addClass('error');
  545 +
  546 + var regra = $element.closest('tr').data('regra');
  547 +
  548 + // se presenca geral, muda o valor em todas faltas da mesma matricula
  549 + if (regra.tipo_presenca == 'geral') {
  550 + $j('#' + $faltaFieldElement.attr('id')).closest('table').find('.falta-matricula-' + $element
  551 + .data('matricula_id') + '-cc')
  552 + .not($element).addClass('error').removeClass('success');
  553 + }
535 554 }
536 555 }
537 556  
... ... @@ -594,18 +613,23 @@ function postMedia($mediaElementField) {
594 613 etapa : $j('#etapa').val()
595 614 };
596 615  
597   - var options = {
598   - url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'media', additionalVars),
599   - dataType : 'json',
600   - data : {att_value : $mediaElementField.val()},
601   - success : function(dataResponse) {
602   - afterChangeResource($mediaElementField);
603   - handleChange(dataResponse);
604   - }
605   - };
606 616  
607   - $mediaElementField.data('old_value', $mediaElementField.val());
608   - postResource(options, handleErrorOnPostResource);
  617 + if (validatesIfValueIsNumeric($mediaElementField.val(), $mediaElementField.attr('id'))) {
  618 + var options = {
  619 + url: postResourceUrlBuilder.buildUrl(API_URL_BASE, 'media', additionalVars),
  620 + dataType: 'json',
  621 + data: {att_value: $mediaElementField.val()},
  622 + success: function (dataResponse) {
  623 + afterChangeResource($mediaElementField);
  624 + handleChange(dataResponse);
  625 + }
  626 + };
  627 +
  628 + $mediaElementField.data('old_value', $mediaElementField.val());
  629 + postResource(options, handleErrorOnPostResource);
  630 + } else {
  631 + $j('#' + $mediaElementField.attr('id')).addClass('error');
  632 + }
609 633 }
610 634  
611 635 function deleteMedia($mediaFieldElement){
... ... @@ -775,7 +799,7 @@ function deleteFalta($faltaFieldElement) {
775 799 var ccId = $faltaFieldElement.data('componente_curricular_id');
776 800  
777 801 var $notaField = $j('#nota-matricula-'+ matriculaId + '-cc-' + ccId);
778   - var $notaExameField = $j('#nota-exame-matricula-'+ matriculaId + '-cc-' + ccId);
  802 + var $notaExameField = $j('#nota_exame-matricula-'+ matriculaId + '-cc-' + ccId);
779 803 var $parecerField = $j('#parecer-matricula-'+ matriculaId + '-cc-' + ccId);
780 804  
781 805 if(($notaField.length < 1 || $notaField.val() == '') &&
... ... @@ -804,7 +828,7 @@ function deleteFalta($faltaFieldElement) {
804 828  
805 829 $faltaFieldElement.val($faltaFieldElement.data('old_value'));
806 830  
807   - handleMessages([{type : 'error', msg : safeUtf8Decode('Falta não pode ser removida após ter lançado notas ou parecer descritivo, tente definir como 0 (zero).')}], $faltaFieldElement.attr('id'));
  831 + handleMessagesDiario([{type : 'error', msg : safeUtf8Decode('Falta não pode ser removida após ter lançado notas ou parecer descritivo, tente definir como 0 (zero).')}], $faltaFieldElement.attr('id'));
808 832 }
809 833 }
810 834  
... ... @@ -858,10 +882,53 @@ function handleChange(dataResponse) {
858 882  
859 883 var targetId = dataResponse.resource + '-matricula-' + dataResponse.matricula_id +
860 884 '-cc-' + componenteCurricularId;
861   - handleMessages(dataResponse.msgs, targetId);
  885 +
  886 + handleMessagesDiario(dataResponse.msgs, targetId);
862 887 updateResourceRow(dataResponse);
863 888 }
864 889  
  890 +var handleMessagesDiario = function(arrayMessage, targetId) {
  891 + var hasError = false;
  892 + var hasSuccess = false;
  893 +
  894 + arrayMessage = $j.map(arrayMessage, function (item, index) {
  895 + if (item.type == 'success') {
  896 + hasSuccess = true;
  897 + return null;
  898 + }
  899 +
  900 + if (item.type == 'error') {
  901 + hasError = true;
  902 + }
  903 +
  904 + return item;
  905 + });
  906 +
  907 + if (hasSuccess) {
  908 + $j('#' + targetId).addClass('success');
  909 + $j('#' + targetId).removeClass('error');
  910 +
  911 + if (targetId.includes('falta-matricula')) {
  912 + $j('#' + targetId).closest('table').find('.falta-matricula-' + $element
  913 + .data('matricula_id') + '-cc')
  914 + .not($element).addClass('success').removeClass('error');
  915 + }
  916 + }
  917 +
  918 + if (hasError) {
  919 + $j('#' + targetId).addClass('error');
  920 + $j('#' + targetId).removeClass('success');
  921 +
  922 + if (targetId.includes('falta-matricula')) {
  923 + $j('#' + targetId).closest('table').find('.falta-matricula-' + $element
  924 + .data('matricula_id') + '-cc')
  925 + .not($element).addClass('error').removeClass('success');
  926 + }
  927 + }
  928 +
  929 + messageUtils.handleMessages(arrayMessage, targetId);
  930 +};
  931 +
865 932 var regraDiferenciadaId = undefined;
866 933  
867 934 var setRegraDiferenciadaId = function(regras){
... ... @@ -1060,7 +1127,7 @@ function handleSearch($resultTable, dataResponse) {
1060 1127  
1061 1128 //set onchange events
1062 1129 var $notaFields = $resultTable.find('.nota-matricula-cc');
1063   - var $notaExameFields = $resultTable.find('.nota-exame-matricula-cc');
  1130 + var $notaExameFields = $resultTable.find('.nota_exame-matricula-cc');
1064 1131 var $faltaFields = $resultTable.find('.falta-matricula-cc');
1065 1132 var $parecerFields = $resultTable.find('.parecer-matricula-cc');
1066 1133 var $notaRecuperacaoParalelaFields = $resultTable.find('.nota-recuperacao-paralela-cc');
... ... @@ -1096,6 +1163,7 @@ function handleSearch($resultTable, dataResponse) {
1096 1163 if ((componenteCurricularSelected) && (showBotaoReplicarNotas))
1097 1164 criaBotaoReplicarNotas();
1098 1165  
  1166 + $j('.flashMessages').addClass('msg-diario');
1099 1167 }
1100 1168  
1101 1169 function _notaField(matriculaId, componenteCurricularId, klass, id, value, areaConhecimentoId, maxLength, tipoNota, regra) {
... ... @@ -1200,8 +1268,8 @@ function notaField(matriculaId, componenteCurricularId, value, areaConhecimentoI
1200 1268 function notaExameField(matriculaId, componenteCurricularId, value, maxLength, tipoNota, regra) {
1201 1269 return _notaField(matriculaId,
1202 1270 componenteCurricularId,
1203   - 'nota-exame-matricula-cc',
1204   - 'nota-exame-matricula-' + matriculaId + '-cc-' + componenteCurricularId,
  1271 + 'nota_exame-matricula-cc',
  1272 + 'nota_exame-matricula-' + matriculaId + '-cc-' + componenteCurricularId,
1205 1273 value,
1206 1274 null,
1207 1275 maxLength,
... ... @@ -1270,7 +1338,7 @@ function notaRecuperacaoParalelaField(matriculaId, componenteCurricularId, value
1270 1338 return _notaField(matriculaId,
1271 1339 componenteCurricularId,
1272 1340 'nota-recuperacao-paralela-cc',
1273   - 'nota-recuperacao-paralela-' + matriculaId + '-cc-' + componenteCurricularId,
  1341 + 'nota_recuperacao_paralela-matricula-' + matriculaId + '-cc-' + componenteCurricularId,
1274 1342 value,
1275 1343 'area-id-' + areaConhecimentoId,
1276 1344 maxLength,
... ... @@ -1282,7 +1350,7 @@ function notaRecuperacaoEspecificaField(matriculaId, componenteCurricularId, val
1282 1350 return _notaField(matriculaId,
1283 1351 componenteCurricularId,
1284 1352 'nota-recuperacao-especifica-matricula-cc',
1285   - 'nota-recuperacao-especifica-matricula-' + matriculaId + '-cc-' + componenteCurricularId,
  1353 + 'nota_recuperacao_especifica-matricula-' + matriculaId + '-cc-' + componenteCurricularId,
1286 1354 value,
1287 1355 'area-id-' + areaConhecimentoId,
1288 1356 maxLength,
... ... @@ -1572,8 +1640,8 @@ function updateResourceRow(dataResponse) {
1572 1640 var ccId = dataResponse.componente_curricular_id;
1573 1641  
1574 1642 var $situacaoField = $j('#situacao-matricula-' + matriculaId + '-cc-' + ccId);
1575   - var $fieldNotaExame = $j('#nota-exame-matricula-' + matriculaId + '-cc-' + ccId);
1576   - var $fieldNotaEspecifica = $j('#nota-recuperacao-especifica-matricula-' + matriculaId + '-cc-' + ccId);
  1643 + var $fieldNotaExame = $j('#nota_exame-matricula-' + matriculaId + '-cc-' + ccId);
  1644 + var $fieldNotaEspecifica = $j('#nota_recuperacao_especifica-matricula-' + matriculaId + '-cc-' + ccId);
1577 1645 var $fieldNN = $j('#nn-matricula-' + matriculaId + '-cc-' + ccId);
1578 1646 var $fieldMedia = $j('#media-matricula-' + matriculaId + '-cc-' + ccId);
1579 1647  
... ... @@ -1756,7 +1824,7 @@ function navegacaoTab(sentido){
1756 1824 $j(this).attr('tabindex', i);
1757 1825 i++;
1758 1826 });
1759   - $j(document).find('.nota-exame-matricula-cc').each(function(){
  1827 + $j(document).find('.nota_exame-matricula-cc').each(function(){
1760 1828 $j(this).attr('tabindex', i);
1761 1829 i++;
1762 1830 });
... ... @@ -1938,8 +2006,6 @@ function criaBotaoReplicarNotas(){
1938 2006 }
1939 2007 }
1940 2008 };
1941   -
1942   -
1943 2009 })(jQuery);
1944 2010  
1945 2011 function handleLockedMessage() {
... ...
ieducar/modules/Avaliacao/Views/DiarioApiController.php
... ... @@ -468,14 +468,15 @@ class DiarioApiController extends ApiCoreController
468 468  
469 469 $this->serviceBoletim()->updateMediaComponente($mediaLancada, $componenteCurricular, $etapa, true);
470 470 $this->messenger->append('Média da matrícula ' . $this->getRequest()->matricula_id . ' alterada com sucesso.', 'success');
471   - $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
472 471 $this->appendResponse('situacao', $this->getSituacaoComponente($this->getRequest()->componente_curricular_id));
473   - $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
474 472 $this->appendResponse('media', $this->getMediaAtual($this->getRequest()->componente_curricular_id));
475 473 $this->appendResponse('media_arredondada', $this->getMediaArredondadaAtual($this->getRequest()->componente_curricular_id));
476 474 } else {
477 475 $this->messenger->append('Usuário não possui permissão para alterar a média do aluno.', 'error');
478 476 }
  477 +
  478 + $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
  479 + $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
479 480 }
480 481  
481 482 protected function postMediaDesbloqueia() {
... ... @@ -686,13 +687,14 @@ class DiarioApiController extends ApiCoreController
686 687 $this->trySaveServiceBoletim();
687 688 $this->messenger->append('Nota de recuperação da matrícula ' . $this->getRequest()->matricula_id . ' excluída com sucesso.', 'success');
688 689  
689   - $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
690   - $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
691 690 $this->appendResponse('situacao', $this->getSituacaoComponente());
692 691 $this->appendResponse('nota_original', $notaOriginal);
693 692 $this->appendResponse('media', $this->getMediaAtual($this->getRequest()->componente_curricular_id));
694 693 $this->appendResponse('media_arredondada', $this->getMediaArredondadaAtual($this->getRequest()->componente_curricular_id));
695 694 }
  695 +
  696 + $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
  697 + $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
696 698 }
697 699  
698 700 protected function deleteNotaRecuperacaoEspecifica()
... ... @@ -711,13 +713,14 @@ class DiarioApiController extends ApiCoreController
711 713 $this->trySaveServiceBoletim();
712 714 $this->messenger->append('Nota de recuperação da matrícula ' . $this->getRequest()->matricula_id . ' excluída com sucesso.', 'success');
713 715  
714   - $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
715   - $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
716 716 $this->appendResponse('situacao', $this->getSituacaoComponente());
717 717 $this->appendResponse('nota_original', $notaOriginal);
718 718 $this->appendResponse('media', $this->getMediaAtual($this->getRequest()->componente_curricular_id));
719 719 $this->appendResponse('media_arredondada', $this->getMediaArredondadaAtual($this->getRequest()->componente_curricular_id));
720 720 }
  721 +
  722 + $this->appendResponse('matricula_id', $this->getRequest()->matricula_id);
  723 + $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id);
721 724 }
722 725  
723 726 protected function deleteFalta()
... ...