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
1 changed files with 27 additions and 4 deletions

View File

@ -33,6 +33,14 @@
function newTier(fmKeyType, fmKey, fmValue = "") {
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 candidates = [];
METASP[fmKey].tiers.forEach((t) => {
@ -45,18 +53,32 @@
frontmatter[fmKeyType].push({
fmKey: fmKey,
tiers: tiers,
candidates: candidates,
candidates: [...new Set(candidates)],
});
frontmatter = { ...frontmatter };
}
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] = {
fmKey: newFmKey,
tiers: [],
candidates: METASP[newFmKey].tiers,
};
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
hasesCandidates = [...hasesCandidates, oldFmKey];
toggleNewTriadButton();
@ -182,7 +204,7 @@
}
function newTriad() {
newHasTiers({ detail: ["triad", 0, "authors", "editors"] });
newHasTiers({ detail: ["triad", 0, "_new", ""] });
}
function dispatchHash() {
@ -223,6 +245,7 @@
{hases}
{hasesCandidates}
on:hasTiersSelected={newHasTiers}
/>
<SpTiers
on:addToCandidatesRemoveFromTiers={addToCandidatesRemoveFromTiers}
@ -243,7 +266,7 @@
{/each}
<div class="buttons news">
<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
</div>
</div>