+
+ Resource Type
+ handleTypeChange(e.target.value)}
+ >
+ {types.map((t) => (
+
+ {t.label}
+
+ ))}
+
+
+ {fields.map((f) => renderField(f, valueObj))}
+
+ );
+};
+
+export default VariableTypeWidgetControl;
diff --git a/src/cms/widgets/VariableTypeWidget/types.ts b/src/cms/widgets/VariableTypeWidget/types.ts
new file mode 100644
index 0000000..29bcf5b
--- /dev/null
+++ b/src/cms/widgets/VariableTypeWidget/types.ts
@@ -0,0 +1,16 @@
+export interface FieldConfig {
+ name: string;
+ label: string;
+ type: "input" | "textarea" | "select" | "file";
+ options?: string[];
+ placeholder?: string;
+ hint?: string;
+ rows?: number;
+}
+
+export interface TypeConfig {
+ value: string;
+ label: string;
+ fields: FieldConfig[];
+ baseFields?: FieldConfig[];
+}
diff --git a/static/admin/config.yml b/static/admin/config.yml
index 7428e5c..7b64b34 100644
--- a/static/admin/config.yml
+++ b/static/admin/config.yml
@@ -103,6 +103,31 @@ collections:
},
],
}
+ - {
+ label: "Datasets",
+ name: "datasets",
+ widget: "relation",
+ collection: "resources",
+ search_fields: ["name"],
+ value_field: "{{slug}}",
+ display_fields: ["name"],
+ multiple: true,
+ required: false,
+ hint: "Select datasets from the Resources collection, if missing, please add to the Resources collection and then finish editing this entry.",
+ filters: [{ field: "resourceDetails.type", values: ["dataset"] }],
+ }
+ - {
+ label: "Resources",
+ name: "resources",
+ widget: "relation",
+ collection: "resources",
+ search_fields: ["resourceDetails.name", "resourceDetails.type"],
+ value_field: "{{slug}}",
+ display_fields: ["resourceDetails.type", "resourceDetails.name"],
+ multiple: true,
+ required: false,
+ hint: "Select other resources from the Resources collection, if missing, please add to the Resources collection and then finish editing this entry.",
+ }
- {
label: "Materials and Methods",
name: "materialsAndMethods",
@@ -331,7 +356,39 @@ collections:
required: false,
}
- { label: "Publish Date", name: "date", widget: "datetime", required: false }
-
+ - name: "resources"
+ label: "Resources"
+ label_singular: "Resource"
+ folder: "src/pages/resources"
+ create: true
+ slug: "{{name}}"
+ identifier_field: "name"
+ summary: "{{resourceDetails.type}}: {{name}}"
+ sortable_fields: ["name", "resourceDetails.type"]
+ view_groups: [
+ {
+ label: "Type",
+ field: "resourceDetails.type",
+ }
+ ]
+ fields:
+ - {
+ label: "Template Key",
+ name: "templateKey",
+ widget: "hidden",
+ default: "resource",
+ }
+ - {
+ label: "Name",
+ name: "name",
+ widget: "hidden",
+ default: "",
+ }
+ - {
+ label: "Resource Details",
+ name: "resourceDetails",
+ widget: "resource_union", # custom widget
+ }
- name: "pages"
label: "Pages"
files: