verdere refactoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
import { escapeHtml } from "../../cmap/cmap-utils.js";
|
||||
import { splitPageReference } from "../reference.js";
|
||||
|
||||
/** Render wiki-specific HTML content for CMap editor items. */
|
||||
export class CmapEditorPresentation {
|
||||
@@ -37,7 +38,7 @@ export class CmapEditorPresentation {
|
||||
`<span class="cmap-card-usage" title="${escapeHtml(usageLabel)}">(${usageCount})</span>`;
|
||||
const descriptionReference = this.canonicalPageReference(record.descriptionPageSlug || "");
|
||||
const descriptionExists = Boolean(descriptionReference &&
|
||||
this.state.pages.some((page) => page.slug === descriptionReference));
|
||||
this.state.pages.some((page) => this.pageMatchesReference(page, descriptionReference)));
|
||||
const descriptionButton = record.descriptionPageSlug ?
|
||||
`<button type="button" class="rw-cmap-view-description ${descriptionExists ? "is-filled" : "is-empty"}" aria-label="${escapeHtml(this.translate("view-concept-description", "View concept description"))}">I</button>` : "";
|
||||
const linkedTarget = record.pageSlug || record.cmapSlug || record.parentCmapLink;
|
||||
@@ -63,4 +64,13 @@ export class CmapEditorPresentation {
|
||||
const current = typeof entry === "number" ? entry : Number(entry?.count) || 0;
|
||||
return Math.max(1, storedTotal - current + (Number(record.usageCount) || 1));
|
||||
}
|
||||
|
||||
pageMatchesReference(page, reference) {
|
||||
if (page.slug === reference) return true;
|
||||
const parts = splitPageReference(reference);
|
||||
return String(page.namespace || "").toLocaleLowerCase() ===
|
||||
parts.namespace.toLocaleLowerCase() &&
|
||||
String(page.pageSlug || page.slug || "").toLocaleLowerCase() ===
|
||||
parts.slug.toLocaleLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user