maj config : création view pages static, modale réactive contenu soit static soit etape

This commit is contained in:
Valentin
2024-07-31 00:33:21 +02:00
parent c9ff3e45d7
commit 35ec4a8388
55 changed files with 1179 additions and 221 deletions

View File

@@ -1,9 +1,9 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import '../scss/main.scss'
import Etape from './vuejs/Etape.vue'
import Modale from './vuejs/Modale.vue'
import { useEtapeStore } from './stores/etape';
import { useContentStore } from './stores/content';
// Working with the history API
// https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API
@@ -43,30 +43,45 @@ import { useEtapeStore } from './stores/etape';
}
function initVues(){
initVueEtapeModale();
initVueContentModale();
}
function initVueEtapeModale(){
const app = createApp(Etape).use(createPinia());
const store = useEtapeStore();
app.mount('#etape-modale');
function initVueContentModale(){
const app = createApp(Modale).use(createPinia());
const store = useContentStore();
app.mount('#content-modale');
processEtapeLinks(store);
processStaticLinks(store)
}
function onClickEtapeLink(e, store){
function onClickContentLink(e, store, category){
e.preventDefault();
let a = e.currentTarget;
let nid = a.dataset.nodeNid;
console.log(nid);
store.fetchEtapeData(nid);
if (category === 'etape') {
store.fetchEtapeData(nid);
} else if (category === 'static') {
store.fetchStaticData(nid);
}
return null;
}
function processStaticLinks(store){
let general_link_fields = document.querySelectorAll('#menu > ul > li > a');
for (let field of general_link_fields) {
let general_link_href = field.getAttribute('href');
const nid = general_link_href.charAt(general_link_href.length-1);
field.setAttribute('data-node-nid', nid);
field.addEventListener('click', (e) => onClickContentLink(e, store, 'static'));
}
}
function processEtapeLinks(store){
let etape_link_fields = document.querySelectorAll('#etapes-liste div.views-field-title');
@@ -85,7 +100,7 @@ import { useEtapeStore } from './stores/etape';
if (nid) {
let a = field.querySelector('a');
a.setAttribute('data-node-nid', nid);
a.addEventListener('click', (e) => onClickEtapeLink(e, store));
a.addEventListener('click', (e) => onClickContentLink(e, store, 'etape'));
}