Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
735ce20
Replace CKEditor with Trumbowyg editor
Clem-Coding May 13, 2025
63ff723
add table plugin and default css for tables in editor
Clem-Coding May 13, 2025
e02a93f
Add translations in editor
Clem-Coding May 14, 2025
ddc6be8
add "table" class
Clem-Coding May 14, 2025
e15a475
integration of the elections page
Clem-Coding May 15, 2025
333f16a
election card partial and election index
Clem-Coding May 16, 2025
50a8107
adjust font sizes and add breadcrumb
Clem-Coding May 16, 2025
9bd1b22
add images for TypeElection
Clem-Coding May 19, 2025
cd55a65
Add latest election to election page integration
Clem-Coding May 19, 2025
aeec111
implement type election
Clem-Coding May 19, 2025
0ce6394
condition with image path for loading img in Election page by type
Clem-Coding May 20, 2025
45c3443
add traduction on election type page
Clem-Coding May 20, 2025
05f5efd
traductions
Clem-Coding May 21, 2025
3a6433c
election page by type and date
Clem-Coding May 21, 2025
521f4ea
conditions on bg img display and translations
Clem-Coding May 22, 2025
f9ee004
all_about for TypeElection and imgs
Clem-Coding May 22, 2025
34b02e7
Smooth display when opening the table
Clem-Coding May 23, 2025
f94cf05
start implementing search module with API integration and css
Clem-Coding May 23, 2025
f30e33e
search module for index election page
Clem-Coding May 26, 2025
297d1d0
implement search module for Election by type page
Clem-Coding May 26, 2025
f29a601
traductions done for Election by type page
Clem-Coding May 27, 2025
db0c7e0
traductions
Clem-Coding May 27, 2025
6b3f710
search module with date and name criteria
Clem-Coding May 27, 2025
7967183
translation for Select2 and possibility to search for multiple words
Clem-Coding May 28, 2025
afc6132
refactor: adapt code to new data source
Clem-Coding Jun 4, 2025
a8c57db
"Show more" button only if more than 5 elections
Clem-Coding Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ composer 2
PHP 8.1

## Assets
``npm run encore -- dev --watch``
``npx encore dev --watch``


## translate
Expand Down Expand Up @@ -58,8 +58,11 @@ Pour que les pages crudAction d'easyadmin ne plante pas, il faut exclure ainsi p
'required' => true,
],
'content' => [
'field_type' => CKEditorType::class,
'field_type' => TextareaType::class,
'required' => true,
'attr' => [
'class' => 'use-trumbowyg'
]
]
])
->hideOnIndex();
Expand Down
11 changes: 5 additions & 6 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
*/

// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';
import 'bootstrap';
import 'bootstrap-autocomplete';
import 'ckeditor4';
import 'select2';
import './main';
import "./styles/app.scss";
import "bootstrap";
import "bootstrap-autocomplete";
import "select2";
import "./main";
1 change: 1 addition & 0 deletions assets/election.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./search-election";
Binary file added assets/img/bg/election-results-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/bg/elections-infos-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/bg/federal-infos-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/bg/legislatives-infos-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/bg/non-federal-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/img/bg/non-federal-bg.png
Binary file not shown.
3 changes: 3 additions & 0 deletions assets/js/i18n/fr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/js/i18n/nl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 29 additions & 11 deletions assets/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
// PAGE
$('.page > p').wrap('<div class="paragraph"><div class="container"></div></div>');
$('.paragraph:odd').addClass('odd-paragraph');
$('.paragraph:even').addClass('even-paragraph');
$(".page > p").wrap('<div class="paragraph"><div class="container"></div></div>');
$(".paragraph:odd").addClass("odd-paragraph");
$(".paragraph:even").addClass("even-paragraph");

// PARTIS
$('#showNonFederal').on('click',() =>{
$('.federal-hidden').toggle(500);
$('#showNonFederal').fadeOut(500);
})
$('#showDisappeared').on('click',() =>{
$('.disappeared-hidden').toggle(500);
$('#showDisappeared').fadeOut(500);
})
$("#showNonFederal").on("click", () => {
$(".federal-hidden").toggle(500);
$("#showNonFederal").fadeOut(500);
});
$("#showDisappeared").on("click", () => {
$(".disappeared-hidden").toggle(500);
$("#showDisappeared").fadeOut(500);
});

// TYPE ELECTION

const $btn = $("#btn-show-more");
const showMoreText = $btn.data("show-more");
const showLessText = $btn.data("show-less");
const $collapseEl = $("#election-more");
const $firstTable = $(".history > table");

$collapseEl.on("show.bs.collapse", function () {
$firstTable.css("margin-bottom", 0);
$btn.text(showLessText);
});

$collapseEl.on("hide.bs.collapse", function () {
$firstTable.css("margin-bottom", "1rem");
$btn.text(showMoreText);
});
91 changes: 91 additions & 0 deletions assets/search-election.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//import des fichiers de traduction pour Select2
import "./js/i18n/fr.js";
import "./js/i18n/nl.js";

$("#selectElection").on("select2:select", function (e) {
const data = e.params.data;
const slug = data.slug;
window.location.href = `/election/${slug}`;
});

$(".filterSelect").select2({
theme: "bootstrap-5",
});

//data-attribut dans le select sur la page Election par type
const typeId = $("#selectElection").data("type-id");

//configuration de l'appel API pour la recherche des élections
const apiCall = {
ajax: {
delay: 200,
data: function (params) {
//les valeurs saisies par l'utilisateur, on les nettoie et on les transforme en un objet de requête
const term = params.term?.trim() || "";

// /\s+/ un ou plusieurs espaces blancs et virgule
const parts = term.split(/[\s,]+/);

let nameParts = [];
let datePart = [];

parts.forEach((part) => {
//vérifie que ça contient uniquement des chiffres
if (/^\d+$/.test(part)) {
datePart.push(part);
} else {
nameParts.push(part);
}
});

let query = {
itemsPerPage: 30,
page: params.page || 1,
};

if (typeId) {
query["idTypeElection.id"] = typeId;
}

if (nameParts) {
query.name = nameParts;
}

if (datePart) {
query.date = datePart;
}

return query;
},

//Réponse de l'API
processResults: function (data) {
const results = data["hydra:member"].map((item) => {
return {
id: item.id,
text: item.name + " (" + item.date + ")", // Concaténation nom + date (ce qui est affiché)

//valeurs à envoyer dans l'événement select2:select
date: item.date,
slug: item.slug,
};
});
return {
results,
pagination: {
more: data["hydra:view"]["hydra:last"] !== undefined,
},
};
},
},
};

//Langue de l'application, on la récupère depuis l'URL
const lang = window.location.pathname.split("/")[1] || "en";
const apiElection = apiCall;
apiElection.ajax.url = "/api/elections";
apiElection.placeholder = $("#placeholderSelectElection").html() ?? "Select an election";
apiElection.language = lang;

//Initialise Select2 avec l'Api call
$("#selectElection").select2(apiElection);
64 changes: 33 additions & 31 deletions assets/search-parti.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
$('.parti-search').on('change', function (e) {
window.location.href = 'parti/' + $(this).val();
$(".parti-search").on("change", function (e) {
window.location.href = "parti/" + $(this).val();
});

$(".filterSelect").select2({
theme: "bootstrap-5",
theme: "bootstrap-5",
});

let apiCall = {
ajax: {
delay: 1000,
data: function (params) {
var query = {
itemsPerPage: 30,
page: params.page || 1,
logo: params.term
}
return query;
ajax: {
delay: 1000,
data: function (params) {
var query = {
itemsPerPage: 30,
page: params.page || 1,
logo: params.term,
};
return query;
},
processResults: function (data) {
let results = data["hydra:member"].map((item) => {
return {
id: item.id,
text: item.acronym,
};
});
return {
results,
pagination: {
more: data["hydra:view"]["hydra:last"] !== undefined,
},
processResults: function (data) {
let results = data["hydra:member"].map((item) => {
return {
"id": item.id,
"text": item.acronym
}
})
return {
results,
pagination: {
more: data["hydra:view"]["hydra:last"] !== undefined
}
};
}
}
}
};
},
},
};

let apiParti = apiCall;
apiParti.ajax.url = '/api/partis';
apiParti.placeholder = $('#placeholderSelectParti').html() ?? "Select a parti";
$('#selectParti').select2(apiParti);
apiParti.ajax.url = "/api/partis";
apiParti.placeholder = $("#placeholderSelectParti").html() ?? "Select a parti";
$("#selectParti").select2(apiParti);

console.log("esai");
Loading