Skip to content

Commit 84d87f1

Browse files
ronnyjohntialessandrofeitoza
authored andcommitted
Adds period filter to event page (#672)
1 parent bd84496 commit 84d87f1

24 files changed

Lines changed: 3532 additions & 3472 deletions

‎Makefile‎

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# Makefile para automatizar setup do projeto PHP com Docker
22

3-
include .env
4-
53
.PHONY: up install_dependencies generate_proxies migrate_database load_fixtures install_frontend compile_frontend generate_keys
64

7-
# Função para bloquear comandos em produção
8-
guard-not-prod:
9-
ifeq ($(APP_ENV),prod)
10-
$(error Este comando não pode ser executado em produção)
11-
endif
12-
135
# Inicia os serviços Docker em modo detached
146
up:
157
docker compose up -d
@@ -28,7 +20,7 @@ container_php:
2820

2921
# Instala dependências dentro do contêiner PHP
3022
install_dependencies:
31-
docker compose exec -T php bash -c "composer install --ignore-platform-req=ext-mongodb"
23+
docker compose exec -T php bash -c "COMPOSER_MEMORY_LIMIT=-1 composer install"
3224

3325
# Gera os arquivos de Proxies do MongoDB
3426
generate_proxies:
@@ -46,56 +38,45 @@ migrate_odm:
4638
docker compose exec -T php bash -c "php bin/console app:mongo:migrations:execute"
4739

4840
# Executa as fixtures de dados
49-
load_fixtures: guard-not-prod
41+
load_fixtures:
5042
docker compose exec -T php bash -c "php bin/console doctrine:fixtures:load -n --purge-exclusions=city --purge-exclusions=state"
5143

5244
# Instala dependências do frontend
5345
install_frontend:
5446
docker compose exec -T php bash -c "php bin/console importmap:install"
5547

5648
# Compila os arquivos do frontend
57-
compile_frontend: reset
49+
compile_frontend:
5850
docker compose exec -T php bash -c "php bin/console asset-map:compile"
5951

60-
# Abre uma instância gráfica do cypress
61-
open_cypress: load_fixtures
62-
xhost +local:
63-
CYPRESS_MODE=open docker compose --profile tests up
64-
6552
# Executa as fixtures de dados e os testes de front-end
66-
tests_front: guard-not-prod
67-
if [ "$(fixtures)" != "no" ]; then \
68-
make load_fixtures;\
69-
fi;
53+
tests_front: load_fixtures
7054
docker compose up cypress
7155

7256
# Executa as fixtures de dados e os testes de back-end
73-
tests_back: guard-not-prod
57+
tests_back:
7458
if [ "$(fixtures)" != "no" ]; then \
7559
make load_fixtures;\
7660
fi;
7761
docker compose exec -T php bash -c "php bin/paratest $(filename) --no-coverage"
7862

7963
# Executa as fixtures de dados e os testes de back-end
80-
tests_back_coverage: guard-not-prod
81-
if [ "$(fixtures)" != "no" ]; then \
82-
make load_fixtures;\
83-
fi;
64+
tests_back_coverage: load_fixtures
8465
docker compose exec -T php bash -c "php -d memory_limit=512M bin/paratest $(filename)"
8566

8667
# Limpa o cache do projeto
8768
reset:
8869
docker compose exec -T php bash -c "php bin/console cache:clear"
8970

9071
# Limpa a cache e o banco
91-
reset-deep: guard-not-prod
72+
reset-deep:
9273
rm -rf var/storage
93-
rm -rf assets/uploads
74+
docker compose exec -T php bash -c "rm -rf assets/uploads"
9475
rm -rf assets/vendor
9576
rm -rf public/assets
96-
rm -rf var/cache
97-
rm -rf var/log
98-
docker compose exec -T php bash -c "php bin/console cache:clear"
77+
docker compose exec -T php bash -c "rm -rf var/cache"
78+
docker compose exec -T php bash -c "rm -rf var/log"
79+
docker compose exec -T php bash -c "php -d memory_limit=-1 bin/console cache:clear"
9980
docker compose exec -T php bash -c "php bin/console doctrine:mongodb:schema:drop --search-index"
10081
docker compose exec -T php bash -c "php bin/console doctrine:mongodb:schema:drop --collection"
10182
docker compose exec -T php bash -c "php bin/console doctrine:mongodb:schema:drop --db"
@@ -112,9 +93,6 @@ style:
11293
docker compose exec -T php bash -c "php vendor/bin/phpcs --config-set installed_paths src/Standards"
11394
docker compose exec -T php bash -c "php vendor/bin/phpcs"
11495

115-
create-admin-user:
116-
docker compose exec -T php bash -c "php bin/console app:create-admin-user"
117-
11896
# Gera as chaves de autenticação JWT
11997
generate_keys:
12098
docker compose exec -T php bash -c "php bin/console lexik:jwt:generate-keypair --overwrite -n"
@@ -124,11 +102,5 @@ copy_dist:
124102
cp phpcs.xml.dist phpcs.xml
125103
cp phpunit.xml.dist phpunit.xml
126104

127-
permissions:
128-
mkdir -p var/
129-
mkdir -p vendor/
130-
mkdir -p config/jwt
131-
chmod -R 775 assets/ config/jwt var/ vendor/ public/
132-
133105
# Comando para rodar todos os passos juntos
134-
setup: guard-not-prod up install_dependencies copy_dist reset-deep generate_proxies migrate_database load_fixtures install_frontend compile_frontend generate_keys
106+
setup: up install_dependencies copy_dist reset-deep generate_proxies migrate_database load_fixtures install_frontend compile_frontend generate_keys

‎assets/app.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'air-datepicker/air-datepicker.css';
2+
import './styles/lib/air-datepicker-custom.css';
3+
14
import './styles/app.css';
25
import './styles/components/navbar.css';
36
import './styles/components/footer.css';

‎assets/js/event/period-filter.js‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {getLocale} from "@symfony/ux-translator";
2+
import AirDatepicker from 'air-datepicker';
3+
import '../../styles/lib/air-datepicker-custom.css';
4+
const datepickerLocale = await import('air-datepicker/locale/'+getLocale()+'.js');
5+
6+
const FORM_FILTER_SIDEBAR = document.getElementById('filter-sidebar');
7+
const PERIOD_SELECT = document.getElementById('period');
8+
const BTN_APPLY_PERIOD_FILTER = document.getElementById('apply-period-filter');
9+
const BTN_CLOSE_CALENDAR = document.getElementById('close-calendar');
10+
11+
const datepicker = new AirDatepicker(document.getElementById('datepicker'), {
12+
range: true,
13+
multipleDates: true,
14+
locale: await datepickerLocale.default.default,
15+
onSelect: function ({ date, formattedDate }) {
16+
const customPeriod = document.querySelector('#period option[data-name=custom]');
17+
customPeriod.classList.remove('d-none');
18+
customPeriod.innerText = formattedDate.join(' - ');
19+
20+
customPeriod.value = date.map(d => {
21+
return d.getFullYear() + '-'
22+
+ (d.getMonth()+1).toString().padStart(2, '0') + '-'
23+
+ d.getDate().toString().padStart(2, '0');
24+
}).join(',');
25+
customPeriod.selected = true;
26+
27+
if (date.length === 2) {
28+
customPeriod.selected = true;
29+
BTN_CLOSE_CALENDAR.click();
30+
}
31+
},
32+
});
33+
34+
PERIOD_SELECT.addEventListener('change', function () {
35+
datepicker.clear({silent: true});
36+
const customPeriod = document.querySelector('#period option[data-name=custom]');
37+
customPeriod.classList.add('d-none');
38+
customPeriod.innerText = '';
39+
});
40+
41+
BTN_APPLY_PERIOD_FILTER.addEventListener('click', function () {
42+
const period = PERIOD_SELECT.value;
43+
const url = new URL(window.location.href);
44+
45+
url.searchParams.set('period', period);
46+
47+
window.location.href = url.toString();
48+
});
49+
50+
(function () {
51+
const searchParams = new URLSearchParams(window.location.search);
52+
53+
new FormData(FORM_FILTER_SIDEBAR).forEach(function (value, key) {
54+
const element = FORM_FILTER_SIDEBAR.querySelector(`[name=${key}]`);
55+
if (element) {
56+
element.value = searchParams.get(key);
57+
}
58+
});
59+
60+
if ('' === PERIOD_SELECT.value) {
61+
const period = searchParams.get('period');
62+
if (period) {
63+
const customPeriod = document.querySelector('#period option[data-name=custom]');
64+
const periodInnerText = period.split(',').map(date => {
65+
const [year, month, day] = date.split('-');
66+
return `${day.padStart(2, '0')}/${month.padStart(2, '0')}/${year}`;
67+
});
68+
69+
customPeriod.value = period;
70+
customPeriod.selected = true;
71+
customPeriod.innerText = periodInnerText.join(' - ');
72+
}
73+
}
74+
})();

‎assets/js/navbar-dropdown.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
document.addEventListener('DOMContentLoaded', () => {
22
function toggleDropdown() {
33
const dropdownMenu = document.getElementById("customDropdown");
4-
dropdownMenu.classList.toggle("show");
4+
dropdownMenu?.classList.toggle("show");
55

66
setTimeout(() => {
7-
document.getElementById("dropdownMenuButton").blur();
7+
document.getElementById("dropdownMenuButton")?.blur();
88
}, 100);
99
}
1010

1111
const dropdownButton = document.getElementById("dropdownMenuButton");
12-
if (dropdownButton) {
13-
dropdownButton.addEventListener('click', (e) => {
14-
e.stopPropagation();
15-
toggleDropdown();
16-
});
17-
}
12+
dropdownButton?.addEventListener('click', (e) => {
13+
e.stopPropagation();
14+
toggleDropdown();
15+
});
1816

1917
document.addEventListener('click', (event) => {
2018
const dropdownMenu = document.getElementById("customDropdown");
2119

22-
if (dropdownMenu && dropdownMenu.classList.contains('show')) {
20+
if (dropdownMenu?.classList.contains('show')) {
2321
if (!dropdownButton.contains(event.target) && !dropdownMenu.contains(event.target)) {
2422
dropdownMenu.classList.remove('show');
2523
}

‎assets/js/side-filter.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function toggleSidebar() {
1616

1717
if (SIDEBAR.classList.contains('open')) {
1818
BTN_OPEN_FILTER.style.visibility = 'hidden';
19-
BTN_OPEN_FILTER.style.opacity = 0;
19+
BTN_OPEN_FILTER.style.opacity = '0';
2020
return;
2121
}
2222

2323
setTimeout(() => {
2424
BTN_OPEN_FILTER.style.visibility = 'visible';
25-
BTN_OPEN_FILTER.style.opacity = 1;
25+
BTN_OPEN_FILTER.style.opacity = '1';
2626
}, 300);
2727
}
2828

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.air-datepicker-cell {
2+
border: 2px solid var(--adp-border-color-inner);
3+
}
4+
5+
.air-datepicker-cell.-day- {
6+
aspect-ratio: 1;
7+
}
8+
9+
.air-datepicker-body--cells {
10+
gap: .3rem;
11+
}
12+
13+
.air-datepicker-body--cells.-days- {
14+
grid-auto-rows: initial;
15+
}
16+
17+
.air-datepicker-nav {
18+
border-bottom: initial;
19+
}
20+
21+
.air-datepicker-nav--title, .air-datepicker-nav--action {
22+
font-weight: bold;
23+
}
24+
25+
.air-datepicker-nav--action {
26+
border-radius: 50%;
27+
border: 1px solid var(--adp-accent-color);
28+
aspect-ratio: 1;
29+
display: block;
30+
padding: 0;
31+
}
32+
33+
.air-datepicker-nav--action path {
34+
stroke: var(--adp-accent-color);
35+
}
36+
37+
.air-datepicker-nav--title {
38+
background-color: var(--adp-accent-color);
39+
color: var(--adp-background-color);
40+
font-size: 14px;
41+
}
42+
43+
.air-datepicker-nav--title i {
44+
color: var(--adp-background-color);
45+
}
46+
47+
.air-datepicker-nav--title:hover, .air-datepicker-nav--title:hover i {
48+
color: var(--adp-accent-color);
49+
}
50+
51+
.air-datepicker {
52+
--adp-font-size: 10px;
53+
--adp-background-color: var(--bs-body-bg);
54+
--adp-background-color-hover: var(--bs-primary-bg-subtle);
55+
--adp-background-color-active: var(--bs-primary-bg-subtle);
56+
--adp-background-color-in-range: rgba(var(--bs-primary-rgb), .1);
57+
--adp-background-color-in-range-focused: rgba(var(--bs-primary-rgb), .2);
58+
--adp-background-color-selected-other-month-focused: var(--bs-primary-bg-subtle);
59+
--adp-background-color-selected-other-month: var(--bs-primary-bg-subtle);
60+
--adp-color: var(--bs-body-color);
61+
--adp-color-secondary: var(--bs-secondary-color);
62+
--adp-accent-color: var(--bs-primary);
63+
--adp-color-disabled: var(--bs-dropdown-link-disabled-color);
64+
--adp-color-disabled-in-range: var(--bs-nav-link-disabled-color);
65+
--adp-border-color: var(--bs-secondary-border-subtle);
66+
--adp-day-name-color: var(--adp-color);
67+
--adp-cell-border-radius: 7px;
68+
--adp-cell-background-color-selected: var(--bs-primary);
69+
--adp-cell-background-color-selected-hover: var(--bs-primary);
70+
--adp-cell-background-color-in-range: var(--bs-primary-bg-subtle);
71+
--adp-cell-background-color-in-range-hover: var(--bs-primary-border-subtle);
72+
}
73+
74+
.air-datepicker {
75+
border: initial;
76+
}

0 commit comments

Comments
 (0)