New SAMO Browse
Level: Intermediate
Keywords: SAMO Browse, application page, browse
The result: page SAMO Browse for working with feature data
Second type of application page are browse pages. Using samo-browse module, it is possible to show information about features (position, attributes, related features etc.). SAMO Browse offers wide functionality. It enables user to browse, filter, create, edit, delete the entity or run entity Intents.
The samo-browse web module is universal, it can display entities with different types of listings:
- Table or list for displaying and filtering defined features
- Map for presenting defined feature data in map view
- Detail for displaying detail view of selected feature (see New Detail)
It is very important to realize that the samo-browse web module is only capable of displaying entity detail, but its content is defined in configurations of entity metadata and their details, see New SAMO Entity and New Detail.
How to create new SAMO Browse?β
This chapter will describe how to implement SAMO Browse with most the common configuration options.
Include new page to folder structureβ
All pages are located under the pages folder of the corresponding application part. See following folder structure:
dynamic-app
β
ββββsamo-demo\configuration
β
ββββapplication\parts
β
ββββap_assets
β
ββββpages
β β pg_dashboard.json
β β pg_assets-browse.json
β ββββ...
ββββpart.json
More about folder structure of Gateway metadata and Dynamic-App metadata can be found in SAMO Lighthouse.
Define basic configurationβ
The list of features may be homogeneous or heterogeneous, depending on whether it displays a list of instances of the same entities or different ones. Browser therefore works with a group of entities, see Defining entity group. Parameter entitiesGroup defines which feature types we want to work with in the SAMO Browse.
The second mandatory parameter is defaultView, which enables to configure the default display mode of SAMO Browse. Parameter values could be set to table or map. Each value represents initial view of feature data, to see data in map or just in table.
The last mandatory parameter is map which extends the basic configuration of SAMO Map module used to show data on map. To see map configuration posibilities, please check Samo map page.
{
"module" : {
"type": "component:entity-modules/browse/samo-browse",
"entitiesGroup": "example-group",
"defaultView": "table",
"map": {
"extends" : "default",
"enabledLayers" : ["searchLayer", "baseOSM"]
}
}
}
Properties that are shown as columns in SAMO Browse in the table view are set using propertyGroupId parameter. Here it is possilbe to use the id of LIDS form, or propertyGroups defined in SAMO client metadata.
Customize SAMO Browseβ
In this chapter we will show some basic customization examples. All posibilities are documented in Dynamic-App Module Catalog
Table only viewβ
If we want to use only table view, it means we don't want to use map and hide possibility to switch between table and map view, we need do it in two steps.
- set default view to
table - disable changing view by setting property
canChangeViewtofalse
{
"type": "component:entity-modules/browse/samo-browse",
"entitiesGroup": "example-group",
"defaultView": "table",
"canChangeView" : false,
"map": {
"extends" : "default",
"enabledLayers" : ["searchLayer", "baseOSM"]
}
}
Browse with default filter conditionβ
If we want to configure SAMO Browse to show only entities based on some specific condition, entities in a particular state, or entities assigned to the logged in user, we need to define query parameter with condition for the Search Extension.
{
"type": "component:entity-modules/browse/samo-browse",
"entitiesGroup": "example-group",
"query":{
"must" : [{
"type": "terms",
"field" : "at_example_cl_stateExample.ca_stateExample_id",
"values": [1]
}]
}
"map": {
"extends" : "default",
"enabledLayers" : ["searchLayer", "baseOSM"]
}
}