mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 18:58:11 +02:00
Added more to admin overview, fixed some styling.
This commit is contained in:
1 parent
24842c65fb
commit
8ec07731a7
5 files changed
+402
-30
No files matched your search
@@ -95,6 +95,8 @@ $PageSection = "Admin";
|
|||||||
<section>
|
<section>
|
||||||
<h2>Plants</h2>
|
<h2>Plants</h2>
|
||||||
<div id="AdminOverviewMissingSprites"></div>
|
<div id="AdminOverviewMissingSprites"></div>
|
||||||
|
<div id="AdminOverviewPlantNoDescription"></div>
|
||||||
|
<div id="AdminOverviewPlantNoTags"></div>
|
||||||
<div id="AdminOverviewNoObtain"></div>
|
<div id="AdminOverviewNoObtain"></div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -102,6 +104,10 @@ $PageSection = "Admin";
|
|||||||
<h2>Mutations</h2>
|
<h2>Mutations</h2>
|
||||||
<div id="AdminOverviewNoDescription"></div>
|
<div id="AdminOverviewNoDescription"></div>
|
||||||
<div id="AdminOverviewNoHint"></div>
|
<div id="AdminOverviewNoHint"></div>
|
||||||
|
<div id="AdminOverviewMissingParents"></div>
|
||||||
|
<div id="AdminOverviewMissingChildren"></div>
|
||||||
|
<div id="AdminOverviewNoChance"></div>
|
||||||
|
<div id="AdminOverviewNoSuccessChange"></div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ $PageSection = "Admin";
|
|||||||
<textarea
|
<textarea
|
||||||
id="AdminMutationDescription"
|
id="AdminMutationDescription"
|
||||||
rows="4"
|
rows="4"
|
||||||
required
|
|
||||||
></textarea>
|
></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ $PageSection = "Admin";
|
|||||||
id="AdminPlantDescription"
|
id="AdminPlantDescription"
|
||||||
name="Description"
|
name="Description"
|
||||||
rows="4"
|
rows="4"
|
||||||
required
|
|
||||||
></textarea>
|
></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|||||||
+384
-28
@@ -1,5 +1,6 @@
|
|||||||
let AdminOverviewPlants = {};
|
let AdminOverviewPlants = {};
|
||||||
let AdminOverviewMutations = {};
|
let AdminOverviewMutations = {};
|
||||||
|
let AdminOverviewToggleNumber = 0;
|
||||||
|
|
||||||
|
|
||||||
async function AdminOverviewRequest(
|
async function AdminOverviewRequest(
|
||||||
@@ -206,9 +207,231 @@ function CollectAdminOverviewCreatedPlants() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function GetAdminOverviewPatternPlantKeys(
|
||||||
|
Mutation
|
||||||
|
) {
|
||||||
|
const PlantKeys = new Set();
|
||||||
|
|
||||||
|
for (const Row of Mutation.Pattern ?? []) {
|
||||||
|
if (!Array.isArray(Row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Cell of Row) {
|
||||||
|
if (
|
||||||
|
typeof Cell === "string" &&
|
||||||
|
AdminOverviewPlants[
|
||||||
|
Cell
|
||||||
|
] !== undefined
|
||||||
|
) {
|
||||||
|
PlantKeys.add(Cell);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Cell !== null &&
|
||||||
|
typeof Cell === "object" &&
|
||||||
|
!Array.isArray(Cell) &&
|
||||||
|
typeof Cell.Plant === "string" &&
|
||||||
|
AdminOverviewPlants[
|
||||||
|
Cell.Plant
|
||||||
|
] !== undefined
|
||||||
|
) {
|
||||||
|
PlantKeys.add(
|
||||||
|
Cell.Plant
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlantKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function GetAdminOverviewResultPlantKeys(
|
||||||
|
Mutation
|
||||||
|
) {
|
||||||
|
const PlantKeys = new Set();
|
||||||
|
|
||||||
|
for (const Row of Mutation.Success ?? []) {
|
||||||
|
if (!Array.isArray(Row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Cell of Row) {
|
||||||
|
let PlantKey = null;
|
||||||
|
|
||||||
|
if (typeof Cell === "string") {
|
||||||
|
PlantKey = Cell;
|
||||||
|
} else if (
|
||||||
|
Cell !== null &&
|
||||||
|
typeof Cell === "object" &&
|
||||||
|
!Array.isArray(Cell) &&
|
||||||
|
typeof Cell.Plant === "string"
|
||||||
|
) {
|
||||||
|
PlantKey = Cell.Plant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
PlantKey !== null &&
|
||||||
|
!PlantKey.startsWith("$") &&
|
||||||
|
AdminOverviewPlants[
|
||||||
|
PlantKey
|
||||||
|
] !== undefined
|
||||||
|
) {
|
||||||
|
PlantKeys.add(PlantKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlantKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function HasAdminOverviewMissingRelations(
|
||||||
|
Mutation,
|
||||||
|
RelationName,
|
||||||
|
ExpectedPlantKeys
|
||||||
|
) {
|
||||||
|
const RelationValues =
|
||||||
|
Mutation.Relations?.[
|
||||||
|
RelationName
|
||||||
|
];
|
||||||
|
|
||||||
|
if (
|
||||||
|
!Array.isArray(RelationValues) ||
|
||||||
|
RelationValues.length === 0
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RelationIds =
|
||||||
|
new Set(
|
||||||
|
RelationValues.map(
|
||||||
|
Value => Number(Value)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const PlantKey of ExpectedPlantKeys) {
|
||||||
|
const PlantId = Number(
|
||||||
|
AdminOverviewPlants[
|
||||||
|
PlantKey
|
||||||
|
]?.Id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
Number.isInteger(PlantId) &&
|
||||||
|
!RelationIds.has(PlantId)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function HasAdminOverviewSuccessChange(
|
||||||
|
Mutation
|
||||||
|
) {
|
||||||
|
if (!Array.isArray(Mutation.Success)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Row of Mutation.Success) {
|
||||||
|
if (!Array.isArray(Row)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Cell of Row) {
|
||||||
|
if (
|
||||||
|
Cell !== null &&
|
||||||
|
Cell !== "Keep"
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function CreateAdminOverviewNestedToggle(
|
||||||
|
Label,
|
||||||
|
NestedList
|
||||||
|
) {
|
||||||
|
AdminOverviewToggleNumber++;
|
||||||
|
|
||||||
|
const ContentId =
|
||||||
|
"AdminOverviewNested" +
|
||||||
|
AdminOverviewToggleNumber;
|
||||||
|
|
||||||
|
NestedList.id = ContentId;
|
||||||
|
NestedList.hidden = true;
|
||||||
|
|
||||||
|
const Toggle =
|
||||||
|
document.createElement("button");
|
||||||
|
|
||||||
|
Toggle.className =
|
||||||
|
"ShopSectionToggle";
|
||||||
|
Toggle.type = "button";
|
||||||
|
Toggle.setAttribute(
|
||||||
|
"aria-expanded",
|
||||||
|
"false"
|
||||||
|
);
|
||||||
|
Toggle.setAttribute(
|
||||||
|
"aria-controls",
|
||||||
|
ContentId
|
||||||
|
);
|
||||||
|
|
||||||
|
const Arrow =
|
||||||
|
document.createElement("span");
|
||||||
|
|
||||||
|
Arrow.className =
|
||||||
|
"ShopSectionArrow";
|
||||||
|
Arrow.setAttribute(
|
||||||
|
"aria-hidden",
|
||||||
|
"true"
|
||||||
|
);
|
||||||
|
Arrow.textContent = ">";
|
||||||
|
|
||||||
|
const Text =
|
||||||
|
document.createElement("span");
|
||||||
|
|
||||||
|
Text.textContent = Label;
|
||||||
|
|
||||||
|
Toggle.append(
|
||||||
|
Arrow,
|
||||||
|
Text
|
||||||
|
);
|
||||||
|
|
||||||
|
Toggle.addEventListener(
|
||||||
|
"click",
|
||||||
|
() => {
|
||||||
|
const IsExpanded =
|
||||||
|
Toggle.getAttribute(
|
||||||
|
"aria-expanded"
|
||||||
|
) === "true";
|
||||||
|
|
||||||
|
Toggle.setAttribute(
|
||||||
|
"aria-expanded",
|
||||||
|
String(!IsExpanded)
|
||||||
|
);
|
||||||
|
|
||||||
|
NestedList.hidden =
|
||||||
|
IsExpanded;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return Toggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function CreateAdminOverviewIssueList(
|
function CreateAdminOverviewIssueList(
|
||||||
Items,
|
Items,
|
||||||
NestedValues = null
|
NestedValues = null,
|
||||||
|
CollapseNested = false
|
||||||
) {
|
) {
|
||||||
const List =
|
const List =
|
||||||
document.createElement("ul");
|
document.createElement("ul");
|
||||||
@@ -220,31 +443,52 @@ function CreateAdminOverviewIssueList(
|
|||||||
const ListItem =
|
const ListItem =
|
||||||
document.createElement("li");
|
document.createElement("li");
|
||||||
|
|
||||||
const Label =
|
|
||||||
document.createElement("span");
|
|
||||||
|
|
||||||
Label.textContent = Item.Label;
|
|
||||||
ListItem.appendChild(Label);
|
|
||||||
|
|
||||||
const Nested =
|
const Nested =
|
||||||
NestedValues?.(Item) ?? [];
|
NestedValues?.(Item) ?? [];
|
||||||
|
|
||||||
if (Nested.length > 0) {
|
if (Nested.length === 0) {
|
||||||
const NestedList =
|
const Label =
|
||||||
document.createElement("ul");
|
document.createElement(
|
||||||
|
"span"
|
||||||
for (const Value of Nested) {
|
|
||||||
const NestedItem =
|
|
||||||
document.createElement("li");
|
|
||||||
|
|
||||||
NestedItem.textContent =
|
|
||||||
Value;
|
|
||||||
NestedList.appendChild(
|
|
||||||
NestedItem
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
ListItem.appendChild(
|
Label.textContent = Item.Label;
|
||||||
|
ListItem.appendChild(Label);
|
||||||
|
List.appendChild(ListItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NestedList =
|
||||||
|
document.createElement("ul");
|
||||||
|
|
||||||
|
for (const Value of Nested) {
|
||||||
|
const NestedItem =
|
||||||
|
document.createElement("li");
|
||||||
|
|
||||||
|
NestedItem.textContent =
|
||||||
|
Value;
|
||||||
|
NestedList.appendChild(
|
||||||
|
NestedItem
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollapseNested) {
|
||||||
|
ListItem.append(
|
||||||
|
CreateAdminOverviewNestedToggle(
|
||||||
|
Item.Label,
|
||||||
|
NestedList
|
||||||
|
),
|
||||||
|
NestedList
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const Label =
|
||||||
|
document.createElement(
|
||||||
|
"span"
|
||||||
|
);
|
||||||
|
|
||||||
|
Label.textContent = Item.Label;
|
||||||
|
ListItem.append(
|
||||||
|
Label,
|
||||||
NestedList
|
NestedList
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -260,7 +504,8 @@ function RenderAdminOverviewSection(
|
|||||||
ContainerId,
|
ContainerId,
|
||||||
Title,
|
Title,
|
||||||
Items,
|
Items,
|
||||||
NestedValues = null
|
NestedValues = null,
|
||||||
|
CollapseNested = false
|
||||||
) {
|
) {
|
||||||
const Container =
|
const Container =
|
||||||
document.getElementById(
|
document.getElementById(
|
||||||
@@ -289,13 +534,16 @@ function RenderAdminOverviewSection(
|
|||||||
Container.appendChild(
|
Container.appendChild(
|
||||||
CreateAdminOverviewIssueList(
|
CreateAdminOverviewIssueList(
|
||||||
Items,
|
Items,
|
||||||
NestedValues
|
NestedValues,
|
||||||
|
CollapseNested
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function RenderAdminOverview() {
|
function RenderAdminOverview() {
|
||||||
|
AdminOverviewToggleNumber = 0;
|
||||||
|
|
||||||
const CreatedPlants =
|
const CreatedPlants =
|
||||||
CollectAdminOverviewCreatedPlants();
|
CollectAdminOverviewCreatedPlants();
|
||||||
|
|
||||||
@@ -315,12 +563,18 @@ function RenderAdminOverview() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const MissingSprites = [];
|
const MissingSprites = [];
|
||||||
|
const PlantNoDescription = [];
|
||||||
|
const PlantNoTags = [];
|
||||||
const NoWaysToObtain = [];
|
const NoWaysToObtain = [];
|
||||||
|
|
||||||
for (
|
for (
|
||||||
const [PlantKey, Plant]
|
const [PlantKey, Plant]
|
||||||
of PlantEntries
|
of PlantEntries
|
||||||
) {
|
) {
|
||||||
|
const Label =
|
||||||
|
Plant.Name?.trim() ||
|
||||||
|
PlantKey;
|
||||||
|
|
||||||
const Missing =
|
const Missing =
|
||||||
GetAdminOverviewMissingSprites(
|
GetAdminOverviewMissingSprites(
|
||||||
PlantKey,
|
PlantKey,
|
||||||
@@ -329,19 +583,36 @@ function RenderAdminOverview() {
|
|||||||
|
|
||||||
if (Missing.length > 0) {
|
if (Missing.length > 0) {
|
||||||
MissingSprites.push({
|
MissingSprites.push({
|
||||||
Label:
|
Label: Label,
|
||||||
Plant.Name ?? PlantKey,
|
|
||||||
Missing: Missing
|
Missing: Missing
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof Plant.Description !==
|
||||||
|
"string" ||
|
||||||
|
Plant.Description.trim() === ""
|
||||||
|
) {
|
||||||
|
PlantNoDescription.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!Array.isArray(Plant.Tags) ||
|
||||||
|
Plant.Tags.length === 0
|
||||||
|
) {
|
||||||
|
PlantNoTags.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Plant.Shop?.ShopPlant !== true &&
|
Plant.Shop?.ShopPlant !== true &&
|
||||||
!CreatedPlants.has(PlantKey)
|
!CreatedPlants.has(PlantKey)
|
||||||
) {
|
) {
|
||||||
NoWaysToObtain.push({
|
NoWaysToObtain.push({
|
||||||
Label:
|
Label: Label
|
||||||
Plant.Name ?? PlantKey
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,6 +634,10 @@ function RenderAdminOverview() {
|
|||||||
|
|
||||||
const NoDescription = [];
|
const NoDescription = [];
|
||||||
const NoHint = [];
|
const NoHint = [];
|
||||||
|
const MissingParents = [];
|
||||||
|
const MissingChildren = [];
|
||||||
|
const NoChance = [];
|
||||||
|
const NoSuccessChange = [];
|
||||||
|
|
||||||
for (
|
for (
|
||||||
const [MutationKey, Mutation]
|
const [MutationKey, Mutation]
|
||||||
@@ -391,13 +666,70 @@ function RenderAdminOverview() {
|
|||||||
Label: Label
|
Label: Label
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
HasAdminOverviewMissingRelations(
|
||||||
|
Mutation,
|
||||||
|
"PlantsUsed",
|
||||||
|
GetAdminOverviewPatternPlantKeys(
|
||||||
|
Mutation
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
MissingParents.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
HasAdminOverviewMissingRelations(
|
||||||
|
Mutation,
|
||||||
|
"PlantsCreated",
|
||||||
|
GetAdminOverviewResultPlantKeys(
|
||||||
|
Mutation
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
MissingChildren.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number(Mutation.Chance) === 0) {
|
||||||
|
NoChance.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!HasAdminOverviewSuccessChange(
|
||||||
|
Mutation
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
NoSuccessChange.push({
|
||||||
|
Label: Label
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderAdminOverviewSection(
|
RenderAdminOverviewSection(
|
||||||
"AdminOverviewMissingSprites",
|
"AdminOverviewMissingSprites",
|
||||||
"Missing sprites",
|
"Missing sprites",
|
||||||
MissingSprites,
|
MissingSprites,
|
||||||
Item => Item.Missing
|
Item => Item.Missing,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewPlantNoDescription",
|
||||||
|
"No description",
|
||||||
|
PlantNoDescription
|
||||||
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewPlantNoTags",
|
||||||
|
"No tags",
|
||||||
|
PlantNoTags
|
||||||
);
|
);
|
||||||
|
|
||||||
RenderAdminOverviewSection(
|
RenderAdminOverviewSection(
|
||||||
@@ -417,6 +749,30 @@ function RenderAdminOverview() {
|
|||||||
"No hint",
|
"No hint",
|
||||||
NoHint
|
NoHint
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewMissingParents",
|
||||||
|
"Missing parents",
|
||||||
|
MissingParents
|
||||||
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewMissingChildren",
|
||||||
|
"Missing children",
|
||||||
|
MissingChildren
|
||||||
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewNoChance",
|
||||||
|
"No chance",
|
||||||
|
NoChance
|
||||||
|
);
|
||||||
|
|
||||||
|
RenderAdminOverviewSection(
|
||||||
|
"AdminOverviewNoSuccessChange",
|
||||||
|
"No success change",
|
||||||
|
NoSuccessChange
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,14 @@ ul, ol {
|
|||||||
color: var(--Text);
|
color: var(--Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul > li::marker {
|
||||||
|
content: "▪ ";
|
||||||
|
}
|
||||||
|
|
||||||
|
ul ul > li::marker {
|
||||||
|
content: "▫ ";
|
||||||
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
@@ -1716,6 +1724,10 @@ input, button, textarea, select {
|
|||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MutationHintList > li::marker {
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
|
||||||
.MutationHintList li + li {
|
.MutationHintList li + li {
|
||||||
margin-top: 0.35rem;
|
margin-top: 0.35rem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user