Skip to content

Commit 75469ec

Browse files
Merge pull request #37 from developmentseed/fix/32-widget-error
Fix render extension schema
2 parents fd5ae65 + 67086c7 commit 75469ec

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: packages/data-plugins/lib/collections/ext-render.ts

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export class PluginRender extends Plugin {
7070
label: 'Colormap',
7171
type: 'string',
7272
'ui:widget': 'tagger',
73+
allowOther: {
74+
type: 'string'
75+
},
7376
enum: colorMaps
7477
},
7578
colormap: {
@@ -89,6 +92,9 @@ export class PluginRender extends Plugin {
8992
label: 'Resampling',
9093
type: 'string',
9194
'ui:widget': 'tagger',
95+
allowOther: {
96+
type: 'string'
97+
},
9298
enum: [
9399
['near', 'Nearest neighbour'],
94100
['bilinear', 'Bilinear'],

Diff for: packages/data-widgets/lib/widgets/tagger.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ export function WidgetTagger(props: WidgetProps) {
5353

5454
if (field.type === 'string') {
5555
if (!field.enum) {
56-
throw new Error("WidgetTagger: 'enum' is required for string fields");
56+
throw new Error("WidgetTagger: 'enum' is required when type is 'string'");
5757
}
5858

5959
if (field.allowOther?.type !== 'string') {
6060
throw new Error(
61-
"WidgetTagger: 'allowOther.type' is required for the 'tagger' widget. Use the 'select' widget instead."
61+
"WidgetTagger: 'allowOther.type' is required for the 'tagger' widget with 'enum' options. Use the 'select' widget instead."
6262
);
6363
}
6464

@@ -68,14 +68,14 @@ export function WidgetTagger(props: WidgetProps) {
6868
if (field.type === 'array') {
6969
if (field.items.type !== 'string') {
7070
throw new Error(
71-
"WidgetTagger: 'items.type' must be 'string' for array fields"
71+
"WidgetTagger: 'items.type' must be 'string' when type is 'array'"
7272
);
7373
}
7474

7575
if (field.items.enum) {
7676
if (field.items.allowOther?.type !== 'string') {
7777
throw new Error(
78-
"WidgetTagger: 'items.allowOther.type' is required for the 'tagger' widget with 'enum'. Use the 'select' widget instead."
78+
"WidgetTagger: 'items.allowOther.type' is required for the 'tagger' widget with 'enum' options. Use the 'select' widget instead."
7979
);
8080
}
8181

0 commit comments

Comments
 (0)