A Layout is a top level component in the Glue layer that provides an entry point into a page. The layout is initialised on page load and it provides a number of context methods that child components can utilise.
Configuring the Layout
The UI platform namespace contains a "service-layout" element. To use this include the [ADD IN LINK TO UI NAMESPACE] namespace in your service configuration.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catcfg:Configuration xmlns="http://www.fostermoore.com/schema/cat-ng"
xmlns:catcfg="http://www.fostermoore.com/schema/catcfg-ng"
xmlns:ui="http://www.fostermoore.com/schema/catalyst-ui/v1">
<businessServices>
<businessService displayGroup="default" formItem="home" code="home">
<ui:service-layout namedLayout="home" />
</businessService>
</businessServices>
</catcfg:Configuration>
The service-layout tag has the following configurable attributes:
| Attribute | Default | Description |
|---|---|---|
| namedLayout | layout | The name of the layout component to the user for the service. |
| bodyClass | Adds the specified CSS class to the HTML body element for the service. | |
| display-title | true | Controls whether the title is displayed as part of the service. |
| display-menus | true | Controls whether the main menu should be shown. |
The Layout Template
The template for the Layout should be simple as all styling and structure should be coming from a component from the design system. The Layout template should wrap all content in a cat-app component and optionally provide slots for the layout_content and layout_mainmenu.
<cat-app>
<cat-service-layout :viewtree="viewtree" :changeOrgHandler="changeOrganisation">
<slot name="layout_content"></slot>
<slot name="layout_mainmenu" slot="mainmenu"></slot>
</cat-service-layout>
</cat-app>
The gluelayout Mixin
When creating a new Layout use the "gluelayout" mixin to provide common service methods to child components. This can either be done directly by adding the mixin to a custom .js file or by adding the layout ".vue" template into the "template/layout" directory.
Vue.component("${vueComponent}", {
mixins: [gluelayout],
template: "${vueTemplate}",
....
});
Any component using this mixin will provide a number of services required for child components to have access to the context.
Properties
The following properties are passed into the component:
| Name | Type | Description |
|---|---|---|
| viewtree | Map | The service render state. |
| user | Map | Some basic information about the currently logged-on user {"guest": false,"identifier": "ss8a2d9ca697f2cdbefddd7c5d9b8a4025525afaee66e127a545794c7670b5e0acfa51e8ce782b2b0bdc1c5e59925afca61a452b82c9c1143b213abbcf850a92cb1b6df38307060f5f139526e18ba8d2bdsx","userName": "registrar1@fostermoore.com","firstName": "User","lastName": "User","fullName": "Registrar1 User","email": "registrar1@fostermoore.com"} |
| menus | Array | Array of top level menu items. |
| service | Object | Some basic information about the service {"name": "Register a Professional","code": "professionalRegister","group": "create","displayTitle": true,"displayMenus": false,"mode": "Create","sessionTimeoutSeconds": 43200,"sessionTimeoutWarningSeconds": 120,"sessionTimeoutURL": "http://localhost:8080/security/ui/start/userLogoff"} |
| flash | Boolean or Object | False on initial page render and set to a Flash Message object if the server has responded with a flash message. |
| errors | Array | Empty on initial load and will be populated with any errors that happen on the server to be displayed. |
| licence | Object | Basic information about the user licence. |
Slots
The layout will be passed 2 child components into 2 named slots.
- layout_content: Will be passed a wrapped view tree component.
- layout_mainmenu: Will be passed a default menu implementation
<layout :viewtree="viewtree" :service="service" :menus="mainMenu" :user="user" :errors="errors" :flash="flash" :licence="licence">
<template slot="layout_mainmenu">
<mainmenu :menu="mainMenu"></mainmenu>
</template>
<content-wrapper slot="layout_content" :viewtree="viewtree">
<viewtree :viewtree="viewtree"></viewtree>
</content-wrapper>
</layout>
If a named layout is being used the layout tag will be replaced with the specific layout. If the layout being used does not have either of the named slots then they will be ignored.
Services
The layout is more than just an HTML wrapper for the form. It also exposes services that can be injected into child components.
| Name | Returns | Description |
|---|---|---|
| getMenus() | Array | Returns the main menu object. |
| getUserContext() | Object | Returns user information. (See user property) |
| getViewTree() | Map | Returns the view tree. Not that glue components don’t use this injection as the view tree is always passed into the glue component as a property. |
| resolveText(textKey, defaultText) | String | Allows simple text localisation to the front end. If the text key asked for is present in the view tree it will return the resolved text. If not present it will return the default text if provided. |
| displayParams() | Object | Returns an object containing rendering preferences which may be changed depending on context. e.g,{displayOptionals: true} THIS LOOKS LIKE ITS NOT CURRENTLY BEING USED CORRECTLY |

