Compare commits
No commits in common. "558dbf64034b0fedec422f05c08fdb16fbae3fca" and "f3b93ca8c8049428b258669bf15626ebc52824fe" have entirely different histories.
558dbf6403
...
f3b93ca8c8
|
|
@ -2,5 +2,5 @@
|
|||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"printWidth": 220
|
||||
"printWidth": 60
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@
|
|||
"recherche"
|
||||
],
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"align": [
|
||||
"full"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -13,4 +13,3 @@ require_once(__DIR__ . '/includes/api.php');
|
|||
require_once(__DIR__ . '/includes/blocks.php');
|
||||
require_once(__DIR__ . '/includes/utilities.php');
|
||||
require_once(__DIR__ . '/includes/acf-fields.php');
|
||||
require_once(__DIR__ . '/includes/factories.php');
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ function build_search_artisan_posts_cards($request)
|
|||
|
||||
|
||||
if ($newsPostsDatas->found_posts === 0) {
|
||||
$html_template = "<div class='no-results'><img class='no-results__cover' src='" . get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg' alt=''/><h3>" . __("Aucun résultat trouvé", "metiers-patrimoine-theme") . "</h3><p>" . __("Essayez d'ajouter un <span class='highlighted-purple'>filtre supplémentaire</span> pour trouver plus de résultats", "metiers-patrimoine-theme") . "</p></div>";
|
||||
$html_template = "<div class='no-results'><img class='no-results__cover' src='" . get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg' alt=''/><h3>" . __("Aucun résultat trouvé", "metiers-patrimoine-theme") . "</h3><p>" . __("Essayez d'ajouter un filtre supplémentaire pour trouver plus de résultats", "metiers-patrimoine-theme") . "</p></div>";
|
||||
}
|
||||
$response_data = array(
|
||||
'html_template' => $html_template,
|
||||
|
|
@ -118,6 +118,20 @@ function build_search_artisan_posts_cards($request)
|
|||
|
||||
function debugQueryTest()
|
||||
{
|
||||
$taxQuery = array(
|
||||
'taxonomy' => 'metiers',
|
||||
'terms' => array(17, 18, 19, 20),
|
||||
'field' => 'term_id'
|
||||
);
|
||||
|
||||
$metaQuery = array(
|
||||
array(
|
||||
'key' => 'state',
|
||||
'value' => "brussels",
|
||||
'compare' => '='
|
||||
)
|
||||
);
|
||||
|
||||
$args = array(
|
||||
"status" => "publish",
|
||||
"post_type" => "artisans",
|
||||
|
|
@ -127,14 +141,6 @@ function debugQueryTest()
|
|||
's' => "Atelier Schrauwen",
|
||||
);
|
||||
$newsPostsDatas = new WP_Query($args);
|
||||
$filteredPosts = [];
|
||||
|
||||
foreach ($newsPostsDatas as $post => $value) {
|
||||
$persons = get_field('company_members', $value->ID);
|
||||
write_log($persons);
|
||||
}
|
||||
|
||||
|
||||
write_log($newsPostsDatas->posts);
|
||||
// write_log($newsPostsDatas->posts);
|
||||
}
|
||||
// debugQueryTest();
|
||||
|
|
|
|||
|
|
@ -1,179 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
function unique_migration_persons()
|
||||
{
|
||||
$transient = 'f71r4_my_onetime_check_metiers_45';
|
||||
if (!get_transient($transient)) {
|
||||
set_transient($transient, 'locked', 600);
|
||||
|
||||
write_log("Migration started");
|
||||
clean_persons();
|
||||
populate_personns();
|
||||
}
|
||||
}
|
||||
// add_action('init', 'unique_migration_persons');
|
||||
|
||||
function build_ids_from_csv($csv_file)
|
||||
{
|
||||
$postArray = [];
|
||||
if (($handle = fopen($csv_file, 'r')) !== false) {
|
||||
// Lire l'en-tête du CSV
|
||||
$headers = fgetcsv($handle, 0, ',');
|
||||
|
||||
// Parcourir chaque ligne du CSV
|
||||
while (($data = fgetcsv($handle, 0, ',')) !== false) {
|
||||
$row = array_combine($headers, $data);
|
||||
$post_fr_ID = $row['company_id (NEW)'];
|
||||
$post_nl_ID = apply_filters('wpml_object_id', $post_fr_ID, 'artisans', FALSE, 'nl') ?? null;
|
||||
|
||||
if (!in_array($post_fr_ID, $postArray)) {
|
||||
$postArray[] = $post_fr_ID;
|
||||
}
|
||||
if ($post_nl_ID && !in_array($post_nl_ID, $postArray)) {
|
||||
$postArray[] = $post_nl_ID;
|
||||
}
|
||||
}
|
||||
|
||||
// Fermer le fichier CSV
|
||||
fclose($handle);
|
||||
}
|
||||
return $postArray;
|
||||
}
|
||||
|
||||
function clean_persons()
|
||||
{
|
||||
$csv_file = '/Users/martoni_sato/Local Sites/homegrade-multi/app/public/wp-content/themes/Metiers_du_patrimoine/datas/20241114_Consolidations_cleaned_persons.csv';
|
||||
|
||||
$postsIdArray = [];
|
||||
$postsIdArray = build_ids_from_csv($csv_file);
|
||||
|
||||
foreach ($postsIdArray as $key => $postId) {
|
||||
$persons = get_field('company_members', $postId);
|
||||
if (!$persons) continue;
|
||||
|
||||
if ($postId === '119' || $postId === 8203) {
|
||||
$field_key = 'field_670d268f2b324';
|
||||
update_field($field_key, [], $postId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function build_personn_fr($row)
|
||||
{
|
||||
$personn_data_fr = array(
|
||||
'acf_fc_layout' => 'membre',
|
||||
'genre' => $row['Sexe'] ?? "",
|
||||
'first_name' => $row['first_name'] ?? "",
|
||||
'last_name' => $row['last_name'] ?? "",
|
||||
'description' => $row['formation_fr'] ?? "",
|
||||
'member_gsm_number' => $row['gsm'] ?? "",
|
||||
'old_website_person_id' => $row['person_id'] ?? "",
|
||||
);
|
||||
return $personn_data_fr;
|
||||
}
|
||||
function build_personn_nl($row)
|
||||
{
|
||||
$personn_data_nl = array(
|
||||
'acf_fc_layout' => 'membre',
|
||||
'genre' => $row['Sexe'] ?? "",
|
||||
'first_name' => $row['first_name'] ?? "",
|
||||
'last_name' => $row['last_name'] ?? "",
|
||||
'description' => $row['formation_nl'] ?? "",
|
||||
'member_gsm_number' => $row['gsm'] ?? "",
|
||||
'old_website_person_id' => $row['person_id'] ?? "",
|
||||
);
|
||||
return $personn_data_nl;
|
||||
}
|
||||
|
||||
function populate_personns()
|
||||
{
|
||||
// Chemin vers le fichier CSV
|
||||
$csv_file = '/Users/martoni_sato/Local Sites/homegrade-multi/app/public/wp-content/themes/Metiers_du_patrimoine/datas/20241114_Consolidations_cleaned_persons.csv';
|
||||
|
||||
if (($handle = fopen($csv_file, 'r')) !== false) {
|
||||
// Lire l'en-tête du CSV
|
||||
$headers = fgetcsv($handle, 0, ',');
|
||||
|
||||
// Parcourir chaque ligne du CSV
|
||||
while (($data = fgetcsv($handle, 0, ',')) !== false) {
|
||||
$row = array_combine($headers, $data);
|
||||
|
||||
|
||||
if ($row['company_id (NEW)'] === '119') {
|
||||
|
||||
$post_fr_ID = $row['company_id (NEW)'] ?? null;
|
||||
if (!$post_fr_ID) continue;
|
||||
$post_nl_ID = apply_filters('wpml_object_id', $post_fr_ID, 'artisans', FALSE, 'nl');
|
||||
|
||||
|
||||
write_log($post_fr_ID);
|
||||
write_log($post_nl_ID);
|
||||
// Récupérer les membres existants
|
||||
$existing_members_fr = is_array(get_field('company_members', $post_fr_ID)) ? get_field('company_members', $post_fr_ID) : [];
|
||||
$existing_members_nl = is_array(get_field('company_members', $post_nl_ID)) ? get_field('company_members', $post_nl_ID) : [];
|
||||
// write_log($existing_members_fr);
|
||||
// write_log($existing_members_nl);
|
||||
|
||||
// Build des données du contenu flexible
|
||||
$user_data_fr = build_personn_fr($row);
|
||||
$user_data_nl = build_personn_nl($row);
|
||||
|
||||
// write_log($user_data_fr);
|
||||
// write_log($user_data_nl);
|
||||
|
||||
$updatedMembersArrayFr = $existing_members_fr;
|
||||
$updatedMembersArrayNl = $existing_members_nl;
|
||||
|
||||
array_push($updatedMembersArrayFr, $user_data_fr);
|
||||
array_push($updatedMembersArrayNl, $user_data_nl);
|
||||
|
||||
|
||||
// write_log($updatedMembersArrayFr);
|
||||
// write_log($updatedMembersArrayNl);
|
||||
|
||||
$field_key = 'field_670d268f2b324';
|
||||
update_field($field_key, $updatedMembersArrayFr, $post_fr_ID);
|
||||
update_field($field_key, $updatedMembersArrayNl, $post_nl_ID);
|
||||
}
|
||||
}
|
||||
|
||||
// Fermer le fichier CSV
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_multiple_members_from_artisans()
|
||||
{
|
||||
$args = array(
|
||||
"status" => "publish",
|
||||
"post_type" => "artisans",
|
||||
"posts_per_page" => -1,
|
||||
// "tax_query" => $taxQuery,
|
||||
// "meta_query" => $metaQuery,
|
||||
);
|
||||
$newsPostsDatas = new WP_Query($args);
|
||||
$filteredPosts = [];
|
||||
|
||||
foreach ($newsPostsDatas->posts as $key => $post) {
|
||||
$persons = get_field('company_members', $post->ID);
|
||||
if (!$persons) continue;
|
||||
write_log(count($persons));
|
||||
if (count($persons) > 1) {
|
||||
write_log($post->ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $filteredPosts;
|
||||
|
||||
// write_log($newsPostsDatas->posts);
|
||||
|
||||
}
|
||||
|
||||
function show_acf_repeator()
|
||||
{
|
||||
$repeater = get_field('company_members', 123);
|
||||
write_log($repeater);
|
||||
}
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
.highlighted-purple {
|
||||
@apply font-bold underline underline-offset-4;
|
||||
}
|
||||
|
||||
.artisans-posts {
|
||||
@apply md:flex gap-4 pt-8;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="resultats-filtres-cactus" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 320.79 374.43">
|
||||
<svg id="Calque_19" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 334.65 374.43">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
|
|
@ -70,8 +70,9 @@
|
|||
<path id="Tracé_191" class="cls-2" d="M255.95,125.63l-4.29-2.48v-4.93l4.29,2.48v4.93Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<path id="Tracé_174-2" data-name="Tracé_174" class="cls-3" d="M287.68,207.86c-.23,2.56-1.68,19.56,1.92,23.89.23.28.83.98,1.87,1.28,2.78.81,6.89-1.71,8.55-4.79,1.82-3.39.26-6.74-.07-7.42.24.35,1,1.37,2.38,1.61,1.02.18,2.51.05,3.09-.79.95-1.38-1.05-3.89-3.54-8.51-1.69-3.13-2.85-5.83-3.59-7.69-3.53.81-7.06,1.61-10.59,2.42Z"/>
|
||||
<path class="cls-3" d="M272.74,162.28c1.96,3.46,7.77,14.01,11.32,25.93,2.22,7.48,3.37,14.87,3.48,15.62.28,1.85.47,3.4.6,4.51,4.42.5,8.84,1.01,13.25,1.51.42-5.29.39-11.8-.91-19.12-.68-3.86-1.62-7.35-2.64-10.46.52-6.69.31-17-4.22-28.52-2.13-5.43-4.77-9.95-7.27-13.57"/>
|
||||
<path id="Tracé_174-2" data-name="Tracé_174" class="cls-3" d="M308.44,203.24c1.75,1.99,12.12,13.57,21.1,11.18.77-.21,3.55-.94,4.03-2.78.63-2.38-2.81-5.85-8.86-8.96.85-.09,1.68-.29,2.47-.6.99-.38,3.44-1.48,3.46-2.26.03-.96-3.58-2.37-18.49-4.37l-3.73,7.79Z"/>
|
||||
<path class="cls-3" d="M284.29,133.91c.99,2.09,1.95,4.27,2.87,6.54,3.95,9.78,6.28,19.22,7.59,27.89.74,4.88,3.21,9.33,6.92,12.58,2.48,2.17,5.03,4.65,7.56,7.48,2.18,2.43,4.08,4.83,5.74,7.12-2.34,3.85-4.67,7.7-7.01,11.55-6.75-4.95-13.51-9.91-20.26-14.86-2.87-2.11-5.16-4.91-6.65-8.14-1.75-3.8-3.51-7.6-5.26-11.4"/>
|
||||
<path class="cls-3" d="M274.82,148.29c.16-1.42.81-5.67,4.34-9.21,2.19-2.2,4.57-3.2,5.95-3.66"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="cls-5" d="M154.46,202.01c-22.54-13.01-59.2-12.95-81.88.15-.89.51-1.73,1.04-2.55,1.58-18.49-2.21-38.53.84-52.94,9.16-22.68,13.1-22.8,34.26-.26,47.28,22.54,13.01,59.2,12.95,81.88-.15.89-.51,1.73-1.04,2.55-1.58,18.49,2.21,38.53-.84,52.94-9.16,22.68-13.1,22.8-34.26.26-47.28Z"/>
|
||||
|
|
@ -108,7 +109,7 @@
|
|||
<path class="cls-4" d="M84.15,165.36c-.1-1.79.59-3.62,1.85-4.9"/>
|
||||
<path class="cls-4" d="M87.85,173.3l1.84,1.22"/>
|
||||
<path class="cls-4" d="M57.9,151.97c1.41-1.45,2.82-2.9,4.23-4.35"/>
|
||||
<path class="cls-4" d="M41.89,146.37c-.82-.61-1.63-1.23-2.45-1.84"/>
|
||||
<path class="cls-4" d="M41.89,146.37l-2.45-1.84"/>
|
||||
<path class="cls-4" d="M16.89,157.56c-1.48,1.1-3.22,1.86-5.04,2.18"/>
|
||||
<path class="cls-4" d="M13.02,147.64l-3.04-4.92"/>
|
||||
<path class="cls-4" d="M21.12,140.29c1.13-1.45,1.95-3.16,2.37-4.95"/>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 252 KiB |
|
|
@ -10,7 +10,10 @@ function formatFormDataArray(formData) {
|
|||
if (Array.isArray(formObjectDatas[cleanName])) {
|
||||
formObjectDatas[cleanName].push(value);
|
||||
} else {
|
||||
formObjectDatas[cleanName] = [formObjectDatas[cleanName], value];
|
||||
formObjectDatas[cleanName] = [
|
||||
formObjectDatas[cleanName],
|
||||
value,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
formObjectDatas[cleanName] = value;
|
||||
|
|
@ -20,36 +23,37 @@ function formatFormDataArray(formData) {
|
|||
}
|
||||
|
||||
function observeSearchResetButton() {
|
||||
const currentSearchWordQueryButton = document.querySelector('.active-research-indicator');
|
||||
const currentSearchWordQueryButton =
|
||||
document.querySelector('.active-research-indicator');
|
||||
|
||||
const searchInput = document.querySelector('#search-input');
|
||||
const searchInput =
|
||||
document.querySelector('#search-input');
|
||||
|
||||
currentSearchWordQueryButton.addEventListener('click', () => {
|
||||
resetSearchfield();
|
||||
hydrateWithAllArtisans({});
|
||||
});
|
||||
currentSearchWordQueryButton.addEventListener(
|
||||
'click',
|
||||
resetTextualSearch
|
||||
);
|
||||
|
||||
searchInput.addEventListener('input', (event) => {
|
||||
console.log(event);
|
||||
if (event.target.value === '') {
|
||||
resetSearchfield();
|
||||
hydrateWithAllArtisans({});
|
||||
resetTextualSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
function clearAllCheckboxes() {
|
||||
const filtersCheckboxes = document.querySelectorAll('.taxonomy-checkbox');
|
||||
|
||||
filtersCheckboxes.forEach((checkbox) => {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
}
|
||||
|
||||
function resetSearchfield() {
|
||||
const searchInput = document.querySelector('#search-input');
|
||||
function resetTextualSearch() {
|
||||
const searchInput =
|
||||
document.querySelector('#search-input');
|
||||
searchInput.value = '';
|
||||
hydrateWithAllArtisans({});
|
||||
|
||||
const currentSearchWordQueryButton = document.querySelector('.active-research-indicator');
|
||||
currentSearchWordQueryButton.setAttribute('is-active', 'false');
|
||||
const currentSearchWordQueryButton =
|
||||
document.querySelector('.active-research-indicator');
|
||||
currentSearchWordQueryButton.setAttribute(
|
||||
'is-active',
|
||||
'false'
|
||||
);
|
||||
}
|
||||
|
||||
function formatSearchDataArray(formData) {
|
||||
|
|
@ -63,60 +67,95 @@ function formatSearchDataArray(formData) {
|
|||
|
||||
function handleRadioCardClick(card) {
|
||||
card.addEventListener('click', (e) => {
|
||||
const radioInput = card.querySelector('input[type="radio"]');
|
||||
const radioInput = card.querySelector(
|
||||
'input[type="radio"]'
|
||||
);
|
||||
radioInput.checked = true;
|
||||
const artisanPosts = document.querySelector('.artisans-posts');
|
||||
|
||||
clearAllCheckboxes();
|
||||
resetSearchfield();
|
||||
|
||||
const artisanPosts = document.querySelector(
|
||||
'.artisans-posts'
|
||||
);
|
||||
if (!artisanPosts) return;
|
||||
artisanPosts.scrollIntoView({ behavior: 'smooth' });
|
||||
});
|
||||
}
|
||||
async function hydrateFields(formObjectDatas) {
|
||||
const currentLanguage = document.querySelector('body').getAttribute('current-language');
|
||||
const currentLanguage = document
|
||||
.querySelector('body')
|
||||
.getAttribute('current-language');
|
||||
const taxonomy = formObjectDatas.search_by;
|
||||
const localisation = formObjectDatas.localisation ?? null;
|
||||
|
||||
const taxonomyIds = taxonomy === 'metiers' ? formObjectDatas.metiers : formObjectDatas.elementsbatiments;
|
||||
const taxonomyIds =
|
||||
taxonomy === 'metiers'
|
||||
? formObjectDatas.metiers
|
||||
: formObjectDatas.elementsbatiments;
|
||||
|
||||
const response = await fetch(`/wp-json/metiers-patrimoine-datas/v1/build/artisans?current-page-language=${currentLanguage}&taxonomy=${taxonomy}&taxonomy-ids=${taxonomyIds}&localisation=${localisation}`);
|
||||
const response = await fetch(
|
||||
`/wp-json/metiers-patrimoine-datas/v1/build/artisans?current-page-language=${currentLanguage}&taxonomy=${taxonomy}&taxonomy-ids=${taxonomyIds}&localisation=${localisation}`
|
||||
);
|
||||
const artisansDatas = await response.json();
|
||||
|
||||
const artisansGrid = document.querySelector('.artisans-posts__grid');
|
||||
const artisansGrid = document.querySelector(
|
||||
'.artisans-posts__grid'
|
||||
);
|
||||
artisansGrid.innerHTML = artisansDatas.html_template;
|
||||
const postResultsLiveDiv = document.querySelector('.posts-results-count .results-count');
|
||||
const postResultsLiveDiv = document.querySelector(
|
||||
'.posts-results-count .results-count'
|
||||
);
|
||||
|
||||
postResultsLiveDiv.innerHTML = artisansDatas.total_posts_found.toString();
|
||||
postResultsLiveDiv.innerHTML =
|
||||
artisansDatas.total_posts_found.toString();
|
||||
}
|
||||
async function hydrateWithAllArtisans() {
|
||||
const currentLanguage = document.querySelector('body').getAttribute('current-language');
|
||||
const response = await fetch(`/wp-json/metiers-patrimoine-datas/v1/build/artisans?current-page-language=${currentLanguage}`);
|
||||
const currentLanguage = document
|
||||
.querySelector('body')
|
||||
.getAttribute('current-language');
|
||||
|
||||
const response = await fetch(
|
||||
`/wp-json/metiers-patrimoine-datas/v1/build/artisans?current-page-language=${currentLanguage}`
|
||||
);
|
||||
const artisansDatas = await response.json();
|
||||
|
||||
const artisansGrid = document.querySelector('.artisans-posts__grid');
|
||||
const artisansGrid = document.querySelector(
|
||||
'.artisans-posts__grid'
|
||||
);
|
||||
artisansGrid.innerHTML = artisansDatas.html_template;
|
||||
const postResultsLiveDiv = document.querySelector('.posts-results-count .results-count');
|
||||
const postResultsLiveDiv = document.querySelector(
|
||||
'.posts-results-count .results-count'
|
||||
);
|
||||
|
||||
postResultsLiveDiv.innerHTML = artisansDatas.total_posts_found.toString();
|
||||
postResultsLiveDiv.innerHTML =
|
||||
artisansDatas.total_posts_found.toString();
|
||||
}
|
||||
|
||||
async function hydrateSearch(searchValue) {
|
||||
const currentLanguage = document.querySelector('body').getAttribute('current-language');
|
||||
const currentLanguage = document
|
||||
.querySelector('body')
|
||||
.getAttribute('current-language');
|
||||
|
||||
const response = await fetch(`/wp-json/metiers-patrimoine-datas/v1/build/artisans?search=${searchValue}¤t-page-language=${currentLanguage}`);
|
||||
const response = await fetch(
|
||||
`/wp-json/metiers-patrimoine-datas/v1/build/artisans?search=${searchValue}`
|
||||
);
|
||||
const searchArtisansDatas = await response.json();
|
||||
|
||||
const artisansGrid = document.querySelector('.artisans-posts__grid');
|
||||
artisansGrid.innerHTML = searchArtisansDatas.html_template;
|
||||
const artisansGrid = document.querySelector(
|
||||
'.artisans-posts__grid'
|
||||
);
|
||||
artisansGrid.innerHTML =
|
||||
searchArtisansDatas.html_template;
|
||||
|
||||
const postResultsAriaLiveDiv = document.querySelector('.posts-results-count .results-count');
|
||||
const postResultsAriaLiveDiv = document.querySelector(
|
||||
'.posts-results-count .results-count'
|
||||
);
|
||||
|
||||
postResultsAriaLiveDiv.innerHTML = searchArtisansDatas.total_posts_found.toString();
|
||||
postResultsAriaLiveDiv.innerHTML =
|
||||
searchArtisansDatas.total_posts_found.toString();
|
||||
|
||||
const currentQueriedWordAriaLiveDiv = document.querySelector('.current-queried-word');
|
||||
const activeSearchIndicator = document.querySelector('.active-research-indicator');
|
||||
const currentQueriedWordAriaLiveDiv =
|
||||
document.querySelector('.current-queried-word');
|
||||
const activeSearchIndicator = document.querySelector(
|
||||
'.active-research-indicator'
|
||||
);
|
||||
|
||||
currentQueriedWordAriaLiveDiv.innerHTML = searchValue;
|
||||
activeSearchIndicator.setAttribute('is-active', 'true');
|
||||
|
|
@ -124,43 +163,69 @@ async function hydrateSearch(searchValue) {
|
|||
|
||||
function handleHierarchicalTaxonomyCheckboxRelation(e) {
|
||||
// If parent is checked, check all children
|
||||
if (e.target.checked && e.target.classList.contains('parent-checkbox')) {
|
||||
const parentRootTag = e.target.closest('.checkbox-choice');
|
||||
const children = parentRootTag.querySelectorAll('.child-checkbox');
|
||||
if (
|
||||
e.target.checked &&
|
||||
e.target.classList.contains('parent-checkbox')
|
||||
) {
|
||||
const parentRootTag = e.target.closest(
|
||||
'.checkbox-choice'
|
||||
);
|
||||
const children = parentRootTag.querySelectorAll(
|
||||
'.child-checkbox'
|
||||
);
|
||||
|
||||
children.forEach((child) => {
|
||||
child.checked = true;
|
||||
});
|
||||
}
|
||||
if (!e.target.checked && e.target.classList.contains('parent-checkbox')) {
|
||||
if (
|
||||
!e.target.checked &&
|
||||
e.target.classList.contains('parent-checkbox')
|
||||
) {
|
||||
// alert('uncheck parent');
|
||||
const parent = e.target.closest('.checkbox-choice');
|
||||
const children = parent.querySelectorAll('.child-checkbox');
|
||||
const children = parent.querySelectorAll(
|
||||
'.child-checkbox'
|
||||
);
|
||||
|
||||
children.forEach((child) => {
|
||||
child.checked = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (!e.target.checked && e.target.classList.contains('child-checkbox')) {
|
||||
const checkboxRootTag = e.target.closest('.checkbox-choice');
|
||||
const parentCheckbox = checkboxRootTag.parentElement.parentElement.querySelector('.parent-checkbox');
|
||||
if (
|
||||
!e.target.checked &&
|
||||
e.target.classList.contains('child-checkbox')
|
||||
) {
|
||||
const checkboxRootTag = e.target.closest(
|
||||
'.checkbox-choice'
|
||||
);
|
||||
const parentCheckbox =
|
||||
checkboxRootTag.parentElement.parentElement.querySelector(
|
||||
'.parent-checkbox'
|
||||
);
|
||||
|
||||
parentCheckbox.checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleLocalisationCheckboxBehaviour(e) {
|
||||
const AlllocalisationsCheckboxes = document.querySelector('.localisation-checkbox[value="all"]');
|
||||
const AlllocalisationsCheckboxes = document.querySelector(
|
||||
'.localisation-checkbox[value="all"]'
|
||||
);
|
||||
// If parent is checked, check all children
|
||||
if (e.target.checked && e.target.value === 'all') {
|
||||
const localisationCheckboxes = document.querySelectorAll('.localisation-checkbox');
|
||||
const localisationCheckboxes =
|
||||
document.querySelectorAll('.localisation-checkbox');
|
||||
|
||||
localisationCheckboxes.forEach((checkbox) => {
|
||||
checkbox.checked = true;
|
||||
});
|
||||
}
|
||||
if (!e.target.checked && AlllocalisationsCheckboxes.checked === true) {
|
||||
if (
|
||||
!e.target.checked &&
|
||||
AlllocalisationsCheckboxes.checked === true
|
||||
) {
|
||||
AlllocalisationsCheckboxes.checked = false;
|
||||
}
|
||||
if (e.target.checked && e.target.value !== 'all') {
|
||||
|
|
@ -171,10 +236,16 @@ function handleLocalisationCheckboxBehaviour(e) {
|
|||
function handleFormChange(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (e.target.type === 'checkbox' && e.target.classList.contains('taxonomy-checkbox')) {
|
||||
if (
|
||||
e.target.type === 'checkbox' &&
|
||||
e.target.classList.contains('taxonomy-checkbox')
|
||||
) {
|
||||
handleHierarchicalTaxonomyCheckboxRelation(e);
|
||||
}
|
||||
if (e.target.type === 'checkbox' && e.target.classList.contains('localisation-checkbox')) {
|
||||
if (
|
||||
e.target.type === 'checkbox' &&
|
||||
e.target.classList.contains('localisation-checkbox')
|
||||
) {
|
||||
handleLocalisationCheckboxBehaviour(e);
|
||||
}
|
||||
const form = e.target.closest('form');
|
||||
|
|
@ -187,38 +258,53 @@ function handleFormChange(e) {
|
|||
function handleSearchSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const searchBy = document.querySelector('.metier-patrimoine-searchbar__search-by');
|
||||
const elementsBatimentsCheckbox = document.querySelector('#elements_batiments_checkbox');
|
||||
const metiersCheckbox = document.querySelector('#metiers_checkbox');
|
||||
const searchBy = document.querySelector(
|
||||
'.metier-patrimoine-searchbar__search-by'
|
||||
);
|
||||
const elementsBatimentsCheckbox = document.querySelector(
|
||||
'#elements_batiments_checkbox'
|
||||
);
|
||||
const metiersCheckbox = document.querySelector(
|
||||
'#metiers_checkbox'
|
||||
);
|
||||
|
||||
metiersCheckbox.checked = false;
|
||||
elementsBatimentsCheckbox.checked = false;
|
||||
|
||||
const form = e.target.closest('form');
|
||||
const searchValue = form.querySelector('#search-input').value;
|
||||
const searchValue =
|
||||
form.querySelector('#search-input').value;
|
||||
|
||||
hydrateSearch(searchValue);
|
||||
|
||||
const artisanPosts = document.querySelector('.artisans-posts');
|
||||
const artisanPosts = document.querySelector(
|
||||
'.artisans-posts'
|
||||
);
|
||||
if (!artisanPosts) return;
|
||||
artisanPosts.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
export default function dynamicSearch() {
|
||||
const form = document.querySelector('.metier-patrimoine-searchform');
|
||||
const form = document.querySelector(
|
||||
'.metier-patrimoine-searchform'
|
||||
);
|
||||
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
form.addEventListener('change', handleFormChange);
|
||||
|
||||
const searchRadioCards = document.querySelectorAll('.search-radio-card');
|
||||
const searchRadioCards = document.querySelectorAll(
|
||||
'.search-radio-card'
|
||||
);
|
||||
|
||||
searchRadioCards.forEach((card) => {
|
||||
handleRadioCardClick(card);
|
||||
});
|
||||
|
||||
const searchForm = document.querySelector('.artisan-search-bar');
|
||||
const searchForm = document.querySelector(
|
||||
'.artisan-search-bar'
|
||||
);
|
||||
|
||||
searchForm.addEventListener('submit', handleSearchSubmit);
|
||||
observeSearchResetButton();
|
||||
|
|
|
|||
|
|
@ -4,14 +4,6 @@
|
|||
<?php
|
||||
get_header();
|
||||
$pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
|
||||
|
||||
$initialPosts = new WP_Query([
|
||||
"status" => "publish",
|
||||
"post_type" => "artisans",
|
||||
"posts_per_page" => -1,
|
||||
"paged" => 1,
|
||||
]);
|
||||
|
||||
?>
|
||||
|
||||
<div class="homegrade-page-container metiers-patrimoine-page-container--repertoire-metiers">
|
||||
|
|
@ -32,6 +24,7 @@ $initialPosts = new WP_Query([
|
|||
|
||||
<li><a href="<?php echo $frontPageUrl ?>"><?php echo $frontPageTitle ?></a></li>
|
||||
|
||||
|
||||
<?php if ($currentPage) : ?>
|
||||
<li><a href="<?php echo get_post_permalink($currentPage->ID) ?>" aria-current="location" aria-disabled="true"><?php echo $currentPage->post_title ?></a></li>
|
||||
<?php endif; ?>
|
||||
|
|
@ -55,7 +48,8 @@ $initialPosts = new WP_Query([
|
|||
<aside class="metier-patrimoine-searchbar">
|
||||
<div class="metier-patrimoine-searchbar__results-indications">
|
||||
<p class="posts-results-count" role="status" aria-live="polite">
|
||||
<span class="results-count"><?php echo $initialPosts->found_posts; ?> </span>
|
||||
<span class="results-count">
|
||||
4 </span>
|
||||
<span class="results-text">résultat(s) </span>
|
||||
</p>
|
||||
<div class="active-research-indicator" is-active="false">
|
||||
|
|
@ -213,6 +207,12 @@ $initialPosts = new WP_Query([
|
|||
|
||||
<div class=" artisans-posts__grid">
|
||||
<?php
|
||||
$initialPosts = new WP_Query([
|
||||
"status" => "publish",
|
||||
"post_type" => "artisans",
|
||||
"posts_per_page" => -1,
|
||||
"paged" => 1,
|
||||
]);
|
||||
|
||||
|
||||
foreach ($initialPosts->posts as $key => $artisanPost) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user