More features and plants added
This commit is contained in:
+37
-13
@@ -127,9 +127,19 @@ export const featureTypes = {
|
||||
genus: "string",
|
||||
species: "string",
|
||||
cultivar: "string",
|
||||
gardenOrgId: "string",
|
||||
plantedDate: "date",
|
||||
note: "string",
|
||||
},
|
||||
externalLinks: [
|
||||
{
|
||||
label: "Garden.org",
|
||||
url: (details) =>
|
||||
details.gardenOrgId
|
||||
? `https://garden.org/plants/view/${encodeURIComponent(details.gardenOrgId)}/`
|
||||
: null,
|
||||
},
|
||||
],
|
||||
style: {
|
||||
color: "#3d7140",
|
||||
weight: 2,
|
||||
@@ -170,17 +180,9 @@ export const featureTypes = {
|
||||
cultivar: "string",
|
||||
bloomColor: "string",
|
||||
bloomSeason: "string",
|
||||
daylilyDatabaseId: "string",
|
||||
daylilyDatabaseUrl: "url",
|
||||
plantedDate: "date",
|
||||
note: "string",
|
||||
},
|
||||
externalLinks: [
|
||||
{
|
||||
label: "Daylily database",
|
||||
url: (details) => details.daylilyDatabaseUrl ?? null,
|
||||
},
|
||||
],
|
||||
style: {
|
||||
color: "#9f5e1d",
|
||||
weight: 2,
|
||||
@@ -267,8 +269,8 @@ export function listFeatureTypeSchemas() {
|
||||
label: definition.label,
|
||||
parentKind: definition.parentKind ?? null,
|
||||
geometryType: definition.geometryType,
|
||||
detailFields: { ...definition.detailFields },
|
||||
externalLinks: (definition.externalLinks ?? []).map((link) => ({
|
||||
detailFields: getInheritedDetailFields(kind),
|
||||
externalLinks: getInheritedExternalLinks(kind).map((link) => ({
|
||||
label: link.label,
|
||||
})),
|
||||
}));
|
||||
@@ -280,12 +282,34 @@ export function resolveFeatureStyle(kind, details = {}) {
|
||||
}
|
||||
|
||||
export function resolveFeatureLinks(kind, details = {}) {
|
||||
const { externalLinks = [] } = getFeatureType(kind);
|
||||
|
||||
return externalLinks
|
||||
return getInheritedExternalLinks(kind)
|
||||
.map((link) => ({
|
||||
label: link.label,
|
||||
url: link.url(details),
|
||||
}))
|
||||
.filter((link) => link.url);
|
||||
}
|
||||
|
||||
function getFeatureTypeLineage(kind) {
|
||||
const lineage = [];
|
||||
let currentKind = kind;
|
||||
|
||||
while (currentKind) {
|
||||
const definition = getFeatureType(currentKind);
|
||||
lineage.unshift(definition);
|
||||
currentKind = definition.parentKind;
|
||||
}
|
||||
|
||||
return lineage;
|
||||
}
|
||||
|
||||
function getInheritedDetailFields(kind) {
|
||||
return Object.assign(
|
||||
{},
|
||||
...getFeatureTypeLineage(kind).map((definition) => definition.detailFields ?? {}),
|
||||
);
|
||||
}
|
||||
|
||||
function getInheritedExternalLinks(kind) {
|
||||
return getFeatureTypeLineage(kind).flatMap((definition) => definition.externalLinks ?? []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user