more of new ascription/triad stuff.. getting there..

This commit is contained in:
Marcell Mars 2021-08-19 13:08:03 +02:00
parent 5c16681285
commit f5af0012f0

View file

@ -33,6 +33,14 @@
function newTier(fmKeyType, fmKey, fmValue = "") { function newTier(fmKeyType, fmKey, fmValue = "") {
console.log("newTier", fmKeyType, fmKey); console.log("newTier", fmKeyType, fmKey);
if (fmKeyType == "ascriptions" && fmKey == "_new") {
hasesCandidates = [... new Set(reckonHasesCandidates())]
if (hasesCandidates.length > 0) {
fmKey = hasesCandidates[0]
console.log(hasesCandidates, fmKey)
}
}
let tiers = []; let tiers = [];
let candidates = []; let candidates = [];
METASP[fmKey].tiers.forEach((t) => { METASP[fmKey].tiers.forEach((t) => {
@ -45,18 +53,32 @@
frontmatter[fmKeyType].push({ frontmatter[fmKeyType].push({
fmKey: fmKey, fmKey: fmKey,
tiers: tiers, tiers: tiers,
candidates: candidates, candidates: [...new Set(candidates)],
}); });
frontmatter = { ...frontmatter }; frontmatter = { ...frontmatter };
} }
function newHasTiers(arrgs) { function newHasTiers(arrgs) {
const [fmKeyType, index, oldFmKey, newFmKey] = arrgs.detail; let [fmKeyType, index, oldFmKey, newFmKey] = arrgs.detail;
hasesCandidates = [... new Set(reckonHasesCandidates())]
console.log(hasesCandidates)
if (fmKeyType=="triad" && oldFmKey == "_new") {
if (hasesCandidates.length > 0) {
newFmKey = hasesCandidates[0];
if (hasesCandidates.length > 1) {
oldFmKey = hasesCandidates[1]
}
} else {
return
}
}
frontmatter[fmKeyType][index] = { frontmatter[fmKeyType][index] = {
fmKey: newFmKey, fmKey: newFmKey,
tiers: [], tiers: [],
candidates: METASP[newFmKey].tiers, candidates: METASP[newFmKey].tiers,
}; };
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey); hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
hasesCandidates = [...hasesCandidates, oldFmKey]; hasesCandidates = [...hasesCandidates, oldFmKey];
toggleNewTriadButton(); toggleNewTriadButton();
@ -182,7 +204,7 @@
} }
function newTriad() { function newTriad() {
newHasTiers({ detail: ["triad", 0, "authors", "editors"] }); newHasTiers({ detail: ["triad", 0, "_new", ""] });
} }
function dispatchHash() { function dispatchHash() {
@ -223,6 +245,7 @@
{hases} {hases}
{hasesCandidates} {hasesCandidates}
on:hasTiersSelected={newHasTiers} on:hasTiersSelected={newHasTiers}
/> />
<SpTiers <SpTiers
on:addToCandidatesRemoveFromTiers={addToCandidatesRemoveFromTiers} on:addToCandidatesRemoveFromTiers={addToCandidatesRemoveFromTiers}
@ -243,7 +266,7 @@
{/each} {/each}
<div class="buttons news"> <div class="buttons news">
<div id="newtier" class="button" on:click={newTriad}>NEW TIER</div> <div id="newtier" class="button" on:click={newTriad}>NEW TIER</div>
<div id="newascription" class="button" on:click={() => newTier("ascriptions", "editors")}> <div id="newascription" class="button" on:click={() => newTier("ascriptions", "_new")}>
NEW ASCRIPTION NEW ASCRIPTION
</div> </div>
</div> </div>