-
Notifications
You must be signed in to change notification settings - Fork 30
Configurable Importer #146
Description
Hi,
most of you probably know that I’m working on a new Importer with React.
We’re currently working on trying to make it easy configurable, and I came up with a few ideas how this could look like.
I would like your input on my current idea.
Thanks.
Idea
Have a config object, that is loaded at runtime and can be edited for each instance. There is a default which only handles name changes.
The default config would look like this:
config = {
steps: {
1: {
title: 'Layer Name'
fields: [
{ title: '', api_name: 'layer_name', type: 'text'}
]
}
}
};
The basic idea is that each step in the create layer window is represented by it’s position number.
Each Step has a title and fields. The Layername step only has one item. But for example the Configure time item would have multiple.
Here is a more detailed example
var config = {
steps: {
1: {
title: 'Layer Name',
fields: [
{ title: 'Layer', api_name: 'layer_name', type: 'text'}
]
},
2: {
title: 'Dates',
fields: [
{title: 'Start Date', api_name: 'start_date', type: 'fields'},
{title: 'End Date', api_name: 'end_date', type: 'fields'},
{title: '', api_name: 'configureTime', type: 'hidden', value: true, parent: 'start_date‘}
{title: '', api_name: 'convert_to_date', type: 'hidden', value: (d) => { return [d.start_date]}, parent: 'start_date'}
]},
3: {
title: 'Version Control',
fields: [
{title: '', api_name: 'editable', type: 'switch', values: [true, false]},
{title: '', api_name: 'geoserver_store', type: 'hidden', value: {'type': 'geogig'}, parent: 'editable'}
]}
}
}
As you can see there is even a idea about adding functions to it. They would be called with the results.
Hidden fields provide a way to add values to the configuration without displaying them.
The parent item ensures that this field only get’s added when the parent is filled.
What do you think? Feedback very much welcome and appreciated.