11import { Plugin , SchemaFieldObject } from '@stac-manager/data-core' ;
2+ import { emptyString2Null , fieldIf , null2EmptyString } from '../utils' ;
23
34export class PluginCore extends Plugin {
45 name = 'CollectionsCore' ;
56
6- // async init(data) {
7- // await new Promise((resolve) => setTimeout(resolve, 100));
8- // }
7+ isNew : boolean = false ;
8+
9+ async init ( data : any ) {
10+ this . isNew = ! data ?. id ;
11+ }
912
1013 editSchema ( ) : SchemaFieldObject {
1114 return {
@@ -19,10 +22,10 @@ export class PluginCore extends Plugin {
1922 // 'links'
2023 // ],
2124 properties : {
22- id : {
25+ ... fieldIf ( this . isNew , 'id' , {
2326 label : 'Collection ID' ,
2427 type : 'string'
25- } ,
28+ } ) ,
2629 title : {
2730 label : 'Title' ,
2831 type : 'string'
@@ -136,7 +139,36 @@ export class PluginCore extends Plugin {
136139 } ,
137140 type : {
138141 label : 'Type' ,
139- type : 'string'
142+ type : 'string' ,
143+ 'ui:widget' : 'select' ,
144+ enum : [
145+ [ 'application/geo+json' , 'geo+json' ] ,
146+ [ 'application/geopackage+sqlite3' , 'geopackage+sqlite3' ] ,
147+ [ 'application/json' , 'json' ] ,
148+ [ 'application/schema+json' , 'schema+json' ] ,
149+ [
150+ 'application/vnd.google-earth.kml+xml' ,
151+ 'vnd.google-earth.kml+xml'
152+ ] ,
153+ [ 'application/vnd.google-earth.kmz' , 'vnd.google-earth.kmz' ] ,
154+ [
155+ 'application/vnd.oai.openapi+json;version=3.0' ,
156+ 'vnd.oai.openapi+json;version=3.0'
157+ ] ,
158+ [ 'application/x-hdf' , 'x-hdf' ] ,
159+ [ 'application/x-hdf5' , 'x-hdf5' ] ,
160+ [ 'application/xml' , 'xml' ] ,
161+ [ 'image/jp2' , 'jp2' ] ,
162+ [ 'image/jpeg' , 'jpeg' ] ,
163+ [ 'image/png' , 'png' ] ,
164+ [
165+ 'image/tiff; application=geotiff; profile=cloud-optimized' ,
166+ 'COG'
167+ ] ,
168+ [ 'image/tiff; application=geotiff' , 'Geotiff' ] ,
169+ [ 'text/html' , 'HTML' ] ,
170+ [ 'text/plain' , 'Text' ]
171+ ]
140172 } ,
141173 title : {
142174 label : 'Title' ,
@@ -201,7 +233,7 @@ export class PluginCore extends Plugin {
201233 providers : data ?. providers || [ ] ,
202234 stac_extensions : data ?. stac_extensions ,
203235 spatial : data ?. extent ?. spatial . bbox || [ ] ,
204- temporal : data ?. extent ?. temporal . bbox || [ ] ,
236+ temporal : data ?. extent ?. temporal . interval . map ( null2EmptyString ) || [ ] ,
205237 links : data ?. links || [ ] ,
206238 assets : Object . entries < Record < string , any > > ( data ?. assets || { } ) . map (
207239 ( [ key , value ] ) => ( {
@@ -227,10 +259,10 @@ export class PluginCore extends Plugin {
227259
228260 extent : {
229261 spatial : {
230- bbox : [ data . spatial ?. map ( ( { value } : any ) => Number ( value ) ) ]
262+ bbox : data . spatial
231263 } ,
232264 temporal : {
233- interval : [ data . temporal ? .map ( ( { value } : any ) => value ) ]
265+ interval : data . temporal . map ( emptyString2Null )
234266 }
235267 } ,
236268
0 commit comments