maj config : création view pages static, modale réactive contenu soit static soit etape
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user