Skip to content

Commit

Permalink
Merge pull request #173 from portabilis/portabilis-patch-2024-12-03
Browse files Browse the repository at this point in the history
Portabilis patch 03/12/2024
  • Loading branch information
edersoares authored Dec 3, 2024
2 parents 4242feb + 03de291 commit 50cf1df
Show file tree
Hide file tree
Showing 112 changed files with 2,597 additions and 1,078 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
if: "! github.event.pull_request.draft"

runs-on: ubuntu-latest
timeout-minutes: 10

env:
RAILS_ENV: test
Expand All @@ -27,7 +28,8 @@ jobs:
POSTGRES_DB: idiario_test
ports:
- 5432:5432
options: --health-cmd pg_isready
options:
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3
Expand All @@ -40,16 +42,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6.6"
bundler: "2.4.22"
bundler-cache: true
env:
ImageOS: ubuntu20

- name: Configure database
run: cp config/database.sample.yml config/database.yml
Expand All @@ -67,7 +67,9 @@ jobs:
" > config/secrets.yml
- name: Migrate
run: RAILS_ENV=test bundle exec rake db:migrate
run: |
RAILS_ENV=test bundle exec rake db:migrate
- name: Tests
run: bundle exec rspec --exclude-pattern 'spec/acceptance/*.feature'
run: |
RAILS_ENV=test bundle exec rspec --exclude-pattern 'spec/acceptance/*.feature'
3 changes: 3 additions & 0 deletions app/assets/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ $(function(){

$('.remote .pagination a').on('click',
function() {
var onPageChange = new CustomEvent('onPageChange');
document.dispatchEvent(onPageChange);

$.getScript(this.href);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ $(function () {

var $unity = $('#discipline_teaching_plan_teaching_plan_attributes_unity_id');
var $grade = $('#discipline_teaching_plan_teaching_plan_attributes_grade_id');
var $year =$('#discipline_teaching_plan_teaching_plan_attributes_year');
var $discipline = $('#discipline_teaching_plan_discipline_id');
var $schoolTermType = $('#discipline_teaching_plan_teaching_plan_attributes_school_term_type_id');
var $schoolTermContainer = $('#school-term-container');
Expand All @@ -16,6 +17,7 @@ $(function () {
function fetchDisciplines() {
var unity_id = $unity.select2('val');
var grade_id = $grade.select2('val');
var year = $year.val();

$discipline.select2('val', '');
$discipline.select2({ data: [] });
Expand All @@ -25,6 +27,7 @@ $(function () {
url: Routes.search_by_grade_and_unity_disciplines_pt_br_path({
by_unity_id: unity_id,
by_grade: grade_id,
year: year,
format: 'json'
}),
success: handleFetchDisciplinesSuccess,
Expand Down
157 changes: 98 additions & 59 deletions app/assets/javascripts/views/knowledge_area_content_records/form.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
$(function () {
'use strict';
$(function() {
"use strict";

// Regular expression for dd/mm/yyyy date including validation for leap year and more
var dateRegex = '^(?:(?:31(\\/)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$';
var dateRegex =
"^(?:(?:31(\\/)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$";
var flashMessages = new FlashMessages();
var $classroom = $('#knowledge_area_content_record_content_record_attributes_classroom_id');
var $knowledgeArea = $('#knowledge_area_content_record_knowledge_area_ids');
var $recordDate = $('#knowledge_area_content_record_content_record_attributes_record_date');
var $contents = $('#knowledge_area_content_record_content_record_attributes_contents_tags');
var $classroom = $(
"#knowledge_area_content_record_content_record_attributes_classroom_id"
);
var $knowledgeArea = $("#knowledge_area_content_record_knowledge_area_ids");
var $recordDate = $(
"#knowledge_area_content_record_content_record_attributes_record_date"
);
var $contents = $(
"#knowledge_area_content_record_content_record_attributes_contents_tags"
);
var idContentsCounter = 1;

$classroom.on('change', function(){
var classroom_id = $classroom.select2('val');
$classroom.on("change", function() {
var classroom_id = $classroom.select2("val");

$knowledgeArea.select2('val', '');
$knowledgeArea.select2("val", "");
$knowledgeArea.select2({ data: [] });

if (!_.isEmpty(classroom_id)) {
Expand All @@ -22,104 +29,136 @@ $(function () {
loadContents();
});


var handleFetchContentsSuccess = function(data){
var handleFetchContentsSuccess = function(data) {
if (!_.isEmpty(data.contents)) {
_.each(data.contents, function(content) {
if(!$('input[type=checkbox][data-content_description="'+content.description+'"]').length){
var html = JST['templates/knowledge_area_content_records/contents_list_item'](content);
$('#contents-list').append(html);
if (
!$(
'input[type=checkbox][data-content_description="' +
content.description +
'"]'
).length
) {
var html = JST[
"templates/knowledge_area_content_records/contents_list_item"
](content);
$("#contents-list").append(html);
}
});
$('.list-group.checked-list-box .list-group-item:not(.initialized)').each(initializeListEvents);
$(".list-group.checked-list-box .list-group-item:not(.initialized)").each(
initializeListEvents
);
}
}
};

var handleFetchContentsError = function(){
flashMessages.error('Ocorreu um erro ao buscar os conteúdos de acordo com filtros informados.');
}
var handleFetchContentsError = function() {
flashMessages.error(
"Ocorreu um erro ao buscar os conteúdos de acordo com filtros informados."
);
};

var fetchContents = function(classroom_id, knowledge_area_ids, date){
var fetchContents = function(classroom_id, knowledge_area_ids, date) {
var params = {
classroom_id: classroom_id,
knowledge_area_ids: knowledge_area_ids,
date: date,
fetch_for_knowledge_area_records: true,
format: "json"
}
};
$.ajax({
url: Routes.contents_pt_br_path(params),
success: handleFetchContentsSuccess,
error: handleFetchContentsError
});
};

}

var loadContents = function(){
var classroom_id = $classroom.select2('val');
var knowledge_area_ids = $knowledgeArea.select2('val');
var loadContents = function() {
var classroom_id = $classroom.select2("val");
var knowledge_area_ids = $knowledgeArea.select2("val");
var date = $recordDate.val();
$('#contents-list .list-group-item:not(.manual)').remove();
$("#contents-list .list-group-item:not(.manual)").remove();

if (!_.isEmpty(classroom_id) &&
!_.isEmpty(knowledge_area_ids) &&
!_.isEmpty(date.match(dateRegex))) {
if (
!_.isEmpty(classroom_id) &&
!_.isEmpty(knowledge_area_ids) &&
!_.isEmpty(date.match(dateRegex))
) {
fetchContents(classroom_id, knowledge_area_ids, date);
}
}
};

$knowledgeArea.on('change', function(){
$knowledgeArea.on("change", function() {
loadContents();
});

$recordDate.on('change', function(){
$recordDate.on("change", function() {
loadContents();
});

function fetchKnowledgeAreas(classroom_id) {
$.ajax({
url: Routes.knowledge_areas_pt_br_path({ classroom_id: classroom_id, format: 'json' }),
url: Routes.knowledge_areas_pt_br_path({
classroom_id: classroom_id,
format: "json"
}),
success: handlefetchKnowledgeAreasSuccess,
error: handlefetchKnowledgeAreasError
});
};
}

function handlefetchKnowledgeAreasSuccess(knowledge_areas) {
var selectedKnowledgeAreas = _.map(knowledge_areas, function(knowledge_area) {
return { id: knowledge_area['id'], text: knowledge_area['description'] };
var selectedKnowledgeAreas = _.map(knowledge_areas, function(
knowledge_area
) {
return { id: knowledge_area["id"], text: knowledge_area["description"] };
});

$knowledgeArea.select2({ data: selectedKnowledgeAreas });
};
$knowledgeArea.select2({ data: selectedKnowledgeAreas, multiple: true });
}

function handlefetchKnowledgeAreasError() {
flashMessages.error('Ocorreu um erro ao buscar as áreas de conhecimento da turma selecionada.');
};
flashMessages.error(
"Ocorreu um erro ao buscar as áreas de conhecimento da turma selecionada."
);
}

$contents.on('change', function(e){
if(e.val.length){
var uniqueId = 'customId_' + idContentsCounter++;
$contents.on("change", function(e) {
if (e.val.length) {
var uniqueId = "customId_" + idContentsCounter++;
var content_description = e.val.join(", ");
if(content_description.trim().length &&
!$('input[type=checkbox][data-content_description="'+content_description+'"]').length){

var html = JST['templates/layouts/contents_list_manual_item']({
if (
content_description.trim().length &&
!$(
'input[type=checkbox][data-content_description="' +
content_description +
'"]'
).length
) {
var html = JST["templates/layouts/contents_list_manual_item"]({
id: uniqueId,
description: content_description,
model_name: 'knowledge_area_content_record',
submodel_name: 'content_record'
model_name: "knowledge_area_content_record",
submodel_name: "content_record"
});

$('#contents-list').append(html);
$('.list-group.checked-list-box .list-group-item:not(.initialized)').each(initializeListEvents);
}else{
var content_input = $('input[type=checkbox][data-content_description="'+content_description+'"]');
content_input.closest('li').show();
content_input.prop('checked', true).trigger('change');
$("#contents-list").append(html);
$(
".list-group.checked-list-box .list-group-item:not(.initialized)"
).each(initializeListEvents);
} else {
var content_input = $(
'input[type=checkbox][data-content_description="' +
content_description +
'"]'
);
content_input.closest("li").show();
content_input.prop("checked", true).trigger("change");
}

$('.knowledge_area_content_record_content_record_contents_tags .select2-input').val("");
$(
".knowledge_area_content_record_content_record_contents_tags .select2-input"
).val("");
}
$(this).select2('val', '');
$(this).select2("val", "");
});
});
13 changes: 12 additions & 1 deletion app/assets/javascripts/views/observation_record_report/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ $(function () {
return { id: discipline.table.id, name: discipline.table.name, text: discipline.table.text };
});

selectedDisciplines.unshift({ id: 'all', name: '<option>Todas</option>', text: 'Todas' });
if (selectedDisciplines.length > 1) {
selectedDisciplines.unshift({ id: 'all', name: '<option>Todas</option>', text: 'Todas' });
}

$discipline.select2({ data: selectedDisciplines });
}
Expand All @@ -95,4 +97,13 @@ $(function () {
$classroom.val('').select2({ data: [] });
$discipline.val('').select2({ data: [] });
}

$('form').submit(function () {
var tempoEspera = 2000;

// Define um timeout para habilitar o botão após o tempo de espera
setTimeout(function () {
$('#btn-submit').prop('disabled', false);
}, tempoEspera);
});
});
28 changes: 21 additions & 7 deletions app/assets/javascripts/views/users/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
$(function() {
var selected = [];

$(document).on('click', 'ul.pagination > li > a', function(e) {
var onPageChange = new CustomEvent('onPageChange');
document.dispatchEvent(onPageChange);
});

document.addEventListener("onPageChange", function (e) {
$("#select-all").prop("checked", false)
})

$('body').on('change', '.selected_users', function(event) {
selected = [];
$('.selected_users:checked').each(function() {
selected.push($(this).attr('value'));
});
selected = $('#export_selected_selected_users').val().split(",");

if ($(this).prop('checked')) {
selected.push($(this).attr('value'))
} else {
selected.pop($(this).attr('value'))
}

$('#export_selected_selected_users').val(selected);
});

$('body').on('change', '#select-all', function(e) {
selected = [];
selected = $('#export_selected_selected_users').val().split(",");

$('.selected_users:checked').each(function() {
if (!_.contains(selected, $(this).attr('value'))) {
if (!_.includes(selected, $(this).attr('value'))) {
selected.push($(this).attr('value'));
}
$('#export_selected_selected_users').val(selected);
});

$('.selected_users').each(function() {
if (!_.contains(selected, $(this).attr('value'))) {
if (!_.includes(selected, $(this).attr('value'))) {
selected.pop($(this).attr('value'));
}
$('#export_selected_selected_users').val(selected);
Expand Down
Loading

0 comments on commit 50cf1df

Please sign in to comment.