Contacts management with a collection

Prerequisites

git checkout origin/osp-communications-configuration.
git checkout origin/osp-collection-configuration.
git checkout origin/osp-web-configuration.
git checkout origin/osp-scripts-configuration.

Description

In this tutorial you will learn to :

  • Configure a basic contacts management

This will allow you to manage contacts dynamically to send notifications to multiple people or groups.

For a more advanced collection configuration, you can see collection. For example, the group can be managed dynamically.

Steps

1. Create the collection

The contacts collection will contain the information to send a notification to a group of person. Two static groups, DEV and TECH, are defined to separate contacts. Each contact has a name, enterprise, number and email.

For more detail about contacts, see contact management.

root/contacts/collection/schema.ospp

{
    "filters": [
        {
            "id": "all",
            "name": "All"
        },
        {
            "id": "group_dev",
            "name": "Dev"
        },
        {
            "id": "group_tech",
            "name": "Tech"
        }
    ],
    "schema": {
        "type": "object",
        "properties": {
            "type": {
                "type": "string",
                "enum": [
                    "ENTERPRISE",
                    "PERSONAL"
                ]
            },
            "firstname": {
                "type": "string"
            },
            "lastname": {
                "type": "string"
            },
            "enterprise": {
                "type": "string"
            },
            "number": {
                "type": "string"
            },
            "email": {
                "type": "string"
            },
            "groups": {
                "type": "array",
                "items": {
                    "type": "string",
                    "enum": [
                        "DEV",
                        "TECH"
                    ]
                }
            }
        },
        "required": [
            "groups"
        ]
    }
}

root/contacts/collection/schema.collections

{
    "moduleId": "modules.collections.collections-1",
    "collectionName": "contacts",
    "indexes": [
        {
            "name": "type",
            "index": {
                "type": 1
            }
        },
        {
            "name": "name",
            "index": {
                "name": 1
            }
        },
        {
            "name": "firstname",
            "index": {
                "firstname": 1
            }
        },
        {
            "name": "lastname",
            "index": {
                "lastname": 1
            }
        },
        {
            "name": "number",
            "index": {
                "number": 1
            }
        },
        {
            "name": "email",
            "index": {
                "email": 1
            }
        },
        {
            "name": "groups",
            "index": {
                "groups": 1
            }
        }
    ],
    "filters": [
        {
            "id": "all",
            "query": {}
        },
        {
            "id": "group_dev",
            "query": {
                "groups": "DEV"
            }
        },
        {
            "id": "group_tech",
            "query": {
                "groups": "TECH"
            }
        }
    ]
}

root/contacts/collection/schema.web

{
    "moduleId": "modules.web.web-1",
    "name": "Contacts",
    "displayedProperty": "lastname",
    "views": [
        {
            "id": "1",
            "name": "Contacts",
            "isDefault": true,
            "reorderable": true,
            "sort": [
                {
                    "field": "enterprise",
                    "direction": "desc"
                },
                {
                    "field": "lastname",
                    "direction": "desc"
                }
            ],
            "columns": [
                {
                    "name": "Type",
                    "field": "type",
                    "position": 0
                },
                {
                    "name": "Enterprise",
                    "field": "enterprise",
                    "position": 1
                },
                {
                    "name": "Lastname",
                    "field": "lastname",
                    "position": 2
                },
                {
                    "name": "Firstname",
                    "field": "firstname",
                    "position": 3
                },
                {
                    "name": "Number",
                    "field": "number",
                    "position": 4
                },
                {
                    "name": "Email",
                    "field": "email",
                    "position": 5
                },
                {
                    "name": "Groups",
                    "field": "groups",
                    "position": 6,
                    "render": "TAGS"
                }
            ]
        }
    ]
}

Note

Filters group_dev and group_tech can be used on request to send a notification only to a sub-set of the contacts.

1. Create the view to edit the collection

root/contacts/view/dashboard.view

{
    "configuration": [
      {
        "type": "CollectionTable",
        "id": "D2H2STZ3",
        "title": "",
        "collectionTableWidgetSettings": {
          "defaultSchema": "root.contacts.collection",
          "defaultFilter": "all",
          "pageSize": 50,
          "pageSizes": [
            50,
            100,
            200
          ],
          "resizeMode": "widget",
          "disableToolbarTableRefresh": false,
          "disableSchemaUpdate": false,
          "disableViewUpdate": false,
          "disableFilterUpdate": false,
          "disableToolbar": false,
          "disableToolbarMenu": false,
          "disableSidePanel": false,
          "disableToolbarExport": false,
          "disableToolbarColumnShowHide": false,
          "disableToolbarFilterShowHide": false,
          "disableToolbarSummaryShowHide": false,
          "disableToolbarSearch": false,
          "disableToolbarColumnChooser": false,
          "disableToolbarClearFilter": false
        }
      }
    ],
    "layout": {
      "lg": [
        {
          "w": 12,
          "h": 7,
          "x": 0,
          "y": 0,
          "i": "D2H2STZ3"
        }
      ]
    },
    "breakpoints": {
      "lg": 1200,
      "md": 996,
      "sm": 768,
      "xs": 480,
      "xxs": 0
    },
    "cols": {
      "lg": 12,
      "md": 10,
      "sm": 6,
      "xs": 4,
      "xxs": 2
    },
    "rowHeight": 150
  }

root/contacts/view/dashboard.web

{
    "moduleId": "modules.web.web-1",
    "title": "Contacts",
    "description": "",
    "tags": ["Contacts"]
}

root/contacts/view/form.web

{
    "moduleId": [
        "modules.web.web-1"
    ],
    "name": "Contacts",
    "description": "Add or edit contacts",
    "schema": "root.contacts.collection",
    "ui": {
        "type": "Group",
        "label": "Contact",
        "elements": [
            {
                "type": "Control",
                "scope": "#/properties/type",
                "label": "The type of the contact"
            },
            {
                "type": "Control",
                "scope": "#/properties/enterprise",
                "label": "The name of the enterprise"
            },
            {
                "type": "Control",
                "scope": "#/properties/firstname",
                "label": "The firstname of the person"
            },
            {
                "type": "Control",
                "scope": "#/properties/lastname",
                "label": "The lastname of the person"
            },
            {
                "type": "Control",
                "scope": "#/properties/number",
                "label": "The phone number of the contact"
            },
            {
                "type": "Control",
                "scope": "#/properties/email",
                "label": "The email of the contact"
            },
            {
                "type": "Control",
                "scope": "#/properties/groups",
                "label": "The group of the contact"
            }
        ]
    },
    "submit": {
        "destination": "Request",
        "type": "Deferred"
    }
}
../../_images/contact-editor.png ../../_images/contact-view.png