Relaties
Bouw je 3 P’s op en geef iedere relatie de aandacht die hij verdient.
De basis van RAT
Wie zijn de mensen die je niet wilt vergeten?
Voeg People, Partners en Prospects toe. RAT onthoudt waarom iemand belangrijk is, wanneer er contact was en hoe vaak deze relatie aandacht verdient.
Totaal
0
People
0
Partners
0
Prospects
0
Nieuwe relatie
Geef RAT genoeg context om later echt slimme aandacht te kunnen geven.
Relatie opgeslagen
' +
'
';
});
grid.innerHTML =
html;
}
/* =====================================================
OPEN NIEUWE RELATIE
===================================================== */
window.RAT_openRelationModal =
function(){
const modal =
el("relationModal");
const form =
el("relationForm");
if(!modal || !form){
console.error(
"RAT: modal of formulier niet gevonden."
);
return;
}
form.reset();
el("relationId").value =
"";
el("modalTitle").textContent =
"Nieuwe relatie";
el("relationType").value =
"people";
el("relationImportance").value =
"Normaal";
el("relationFrequency").value =
"Maandelijks";
modal.classList.add(
"show"
);
document.body.style.overflow =
"hidden";
setTimeout(
function(){
const name =
el("relationName");
if(name){
name.focus();
}
},
100
);
};
/* =====================================================
CLOSE MODAL
===================================================== */
window.RAT_closeRelationModal =
function(){
const modal =
el("relationModal");
if(modal){
modal.classList.remove(
"show"
);
}
document.body.style.overflow =
"";
};
/* =====================================================
EDIT
===================================================== */
window.RAT_editRelation =
function(id){
const relation =
relations.find(function(item){
return item.id === id;
});
if(!relation){
return;
}
el("relationId").value =
relation.id;
el("modalTitle").textContent =
"Relatie aanpassen";
el("relationName").value =
relation.name || "";
el("relationCompany").value =
relation.company || "";
el("relationType").value =
relation.type || "people";
el("relationImportance").value =
relation.importance || "Normaal";
el("relationLastContact").value =
relation.lastContact || "";
el("relationFrequency").value =
relation.frequency || "Maandelijks";
el("relationWhyImportant").value =
relation.whyImportant || "";
el("relationOpenTopic").value =
relation.openTopic || "";
el("relationNotes").value =
relation.notes || "";
el("relationModal")
.classList.add(
"show"
);
document.body.style.overflow =
"hidden";
};
/* =====================================================
SAVE
===================================================== */
window.RAT_saveRelation =
function(event){
if(event){
event.preventDefault();
}
const name =
el("relationName").value.trim();
if(!name){
alert(
"Vul eerst een naam in."
);
return false;
}
const existingId =
el("relationId").value;
const record = {
id:
existingId ||
createId(),
name:
name,
company:
el("relationCompany").value.trim(),
type:
el("relationType").value,
importance:
el("relationImportance").value,
lastContact:
el("relationLastContact").value,
frequency:
el("relationFrequency").value,
whyImportant:
el("relationWhyImportant").value.trim(),
openTopic:
el("relationOpenTopic").value.trim(),
notes:
el("relationNotes").value.trim()
};
if(existingId){
const index =
relations.findIndex(function(item){
return item.id === existingId;
});
if(index !== -1){
relations[index] =
record;
}
}
else{
relations.unshift(
record
);
}
saveRelations();
renderRelations();
window.RAT_closeRelationModal();
showToast(
"Relatie opgeslagen ✓"
);
return false;
};
/* =====================================================
DELETE
===================================================== */
window.RAT_deleteRelation =
function(id){
const relation =
relations.find(function(item){
return item.id === id;
});
if(!relation){
return;
}
const confirmed =
window.confirm(
"Weet je zeker dat je " +
relation.name +
" wilt verwijderen?"
);
if(!confirmed){
return;
}
relations =
relations.filter(function(item){
return item.id !== id;
});
saveRelations();
renderRelations();
showToast(
"Relatie verwijderd"
);
};
/* =====================================================
INITIALIZE
===================================================== */
function initializeRAT(){
relations =
loadRelations();
/*
Alleen wanneer er helemaal nog geen data is,
zetten we drie voorbeelden neer.
*/
if(relations.length === 0){
relations = [
{
id:createId(),
name:"Dennis",
company:"VCN",
type:"partners",
importance:"Strategisch",
lastContact:"",
frequency:"Elke 2 weken",
whyImportant:"Belangrijke strategische samenwerkingspartner.",
openTopic:"Terugkoppeling over verdere samenwerking.",
notes:"Persoonlijk en informeel-zakelijk benaderen."
},
{
id:createId(),
name:"Antoine",
company:"Batterij Regeling",
type:"people",
importance:"Hoog",
lastContact:"",
frequency:"Wekelijks",
whyImportant:"Belangrijke collega en nauw betrokken bij de organisatie.",
openTopic:"",
notes:""
},
{
id:createId(),
name:"Jansen Bouwbedrijf",
company:"Jansen Bouwbedrijf",
type:"prospects",
importance:"Normaal",
lastContact:"",
frequency:"Maandelijks",
whyImportant:"Warme zakelijke prospect.",
openTopic:"Mogelijke samenwerking bespreken.",
notes:""
}
];
saveRelations();
}
/* SEARCH */
const search =
el("searchInput");
if(search){
search.addEventListener(
"input",
function(){
renderRelations();
}
);
}
/* FILTERS */
const filterButtons =
document.querySelectorAll(
"#rat-v2 .filter"
);
filterButtons.forEach(
function(button){
button.addEventListener(
"click",
function(){
filterButtons.forEach(
function(other){
other.classList.remove(
"active"
);
}
);
button.classList.add(
"active"
);
currentFilter =
button.getAttribute(
"data-filter"
);
renderRelations();
}
);
}
);
/* KLIK BUITEN MODAL */
const modal =
el("relationModal");
if(modal){
modal.addEventListener(
"click",
function(event){
if(
event.target === modal
){
window.RAT_closeRelationModal();
}
}
);
}
/* ESC SLUIT MODAL */
document.addEventListener(
"keydown",
function(event){
if(event.key === "Escape"){
window.RAT_closeRelationModal();
}
}
);
renderRelations();
}
/*
JouwWeb kan HTML op verschillende momenten
in de pagina plaatsen.
Daarom starten we zowel direct als na DOM-ready.
*/
if(
document.readyState === "loading"
){
document.addEventListener(
"DOMContentLoaded",
initializeRAT
);
}
else{
initializeRAT();
}
})();
' +
'
' +
'' +
escapeHtml(
typeLabel(relation.type)
) +
'' +
'' +
(
relation.whyImportant
?
'' +
escapeHtml(
initials(relation.name)
) +
'
' +
'' +
'
' +
'' + escapeHtml(relation.name) + '
' + '' +
escapeHtml(
relation.company ||
"Geen organisatie"
) +
'
' +
'' +
'Waarom belangrijk:
' + escapeHtml( relation.whyImportant ) + '
'
:
""
) +
'' + escapeHtml( relation.whyImportant ) + '
' +
'' +
'' +
'
' +
'