Skip to main content

Selection Rules

Related links:

Selection rules are very similar to selections. However, rather than modifying the structure of the deck during the creation or editing of an appointment, instead it is applied after modifying the deck in the slide sorter. The operations you will likely to do here will be turning on/off sections/slides and reordering sections/slides.

Installing

In your hooks folder, create the file selection-rules.js: (usually src/js/hooks/)

export default {
onChange({ sections }) {
return sections;
},
};

In your hooks file, add to your interface: (usually src/js/hooks.js)

import SelectionRules from "./hooks/selection-rules.js";

export default {
selectionRules: SelectionRules,
};

Events

EventDescription
onChange(sections[,options...])Called when a user makes a change using the slide sorter (eg. toggles or reorders a slide)

The return value should be the list of sections passed in, with whatever modifications you made. Optional messages can also be returned to notify the user of changes.

Options

Each event is passed an object of values that can be used to determine determine slide ordering and visibility.

export default {
onChange({ sections, data, context, feeds }) {
return sections;
},
};

Parameters:

sections

Contains the current state of sections, slides and subslides in the presentation.

context

Contains the context at the point of the event. This will by default only contain a fields key, containing values from fields.

feeds

Contains the feeds at the point of the event. Each feed is supplied as a separate entry within the feeds object. You can understand the outputs here by viewing the feeds tab when working on hooks.

fields

Shortcut access to the same values as context.fields, which is the values selected by fields.

data

Contains useful general data from preso creation/editing process that you may need for your selections logic: data from the server, user information, preso data, etc.

data.appointment

{
"adjunctSections": [],
"adjunctSlides": [],
"adjunctSubSlides": [],
"appointmentssection_set": [],
"appointmentsslide_set": [],
"attendees": "",
"begin": "2017-07-11T06:05:29.000000Z",
"bookmarks": [],
"contact_set": [
{
"customer": "https://demo-server.salespreso.com/api/customers/1/",
"email": "john.smith@testcustomer.com",
"fullName": "John Smith",
"id": 1,
"name_first": "John",
"name_last": "Smith",
"notes": "Skinny latte with one sugar",
"opportunity_set": [],
"phone": "0400 000 000",
"photo_128": null,
"photo_256": null,
"photo_512": null,
"position": "CEO",
"url": "https://demo-server.salespreso.com/api/contacts/1/",
"user": null
}
],
"created_by_support": false,
"created_date": "2017-07-11T06:06:40.000000Z",
"creation_status": "ready",
"deckversion_set": [],
"display_contacts": "John Smith",
"display_title": "Test customer",
"end": "2017-07-11T07:05:29.000000Z",
"id": 1,
"latest_snapshot": {
"id": 1,
"url": "https://demo-server.salespreso.com/api/snapshots/1/"
},
"latest_tele": {
"url": "https://demo-server.salespreso.com/api/hostedpresos/"
},
"modified_date": "2017-07-11T06:06:40.000000Z",
"opportunity_set": [
{
"appointment_set": [],
"contact_set": [],
"customer": "https://demo-server.salespreso.com/api/customers/1/",
"id": 1,
"is_default": false,
"name": "Happiness opportunity",
"profile": {
"cost": 1200,
"product": "premium"
},
"soft_deleted": false,
"stage_name": "Proposal accepted",
"url": "https://demo-server.salespreso.com/api/opportunities/1/"
}
],
"preset": null,
"sort_date": "2017-07-11T06:06:40.000000Z",
"support_mode": false,
"url": "https://demo-server.salespreso.com/api/appointments/1/",
"user": {
"actions": [],
"email": "jane.doe@example.com",
"first_name": "Jane",
"fullName": "Jane Doe",
"groups": [],
"id": 1,
"is_support": false,
"last_name": "Doe",
"permissions": {
"appointments": {
"canUploadCustomSlides": false,
"isContentAdmin": false,
"livePresenter": false,
"telePresenter": false
},
"presets": {
"canCreateCompanyPresets": false
},
"tempslides": {
"canModifyTemporarySlides": false
}
},
"preferences": {
"app_prefs": {},
"email_signature": "",
"notification_sender": "default",
"timezone": ""
},
"url": "https://demo-server.salespreso.com/api/users/1/",
"username": "jane.doe"
},
"viewtype": "live"
}

data.appointment.preset

If a preset is selected at preso creation, the relevant preset URL will be available - otherwise, data.appointment.preset will be null.

"https://server.livepreso.com/api/presets/2/"
note

Preset data is fetched in the fieldsets hook, giving you detailed information on the selected slides, if the preset is a company or personal preset etc. If you require this information for your selection rules logic, we recommend saving it to the context using fieldsets.

data.customers

A list of the customers associated with the preso.

[
{
"contact_set": [
"https://demo-server.salespreso.com/api/contacts/1/",
"https://demo-server.salespreso.com/api/contacts/2/"
],
"default_location": null,
"default_opportunity": "https://demo-server.salespreso.com/api/opportunities/0/",
"id": 1,
"logo": "file:///Users/user/Desktop/awesome_logo.jpg",
"logo_128": "file:///Users/user/Desktop/awesome_logo.jpg",
"logo_256": "file:///Users/user/Desktop/awesome_logo.jpg",
"logo_512": "file:///Users/user/Desktop/awesome_logo.jpg",
"logo_original": "file:///Users/user/Desktop/awesome_logo.jpg",
"notes": "Really awesome customer",
"opportunity_set": [
{
"appointment_set": [],
"contact_set": [],
"customer": null,
"id": 0,
"is_default": true,
"name": "__default__",
"profile": null,
"soft_deleted": false,
"stage_name": "",
"url": "https://demo-server.salespreso.com/api/opportunities/0/"
},
{
"appointment_set": [],
"contact_set": [],
"customer": null,
"id": 1,
"is_default": false,
"name": "Happiness opportunity",
"profile": {
"cost": 1200,
"product": "premium"
},
"soft_deleted": false,
"stage_name": "Proposal accepted",
"url": "https://demo-server.salespreso.com/api/opportunities/1/"
},
{
"appointment_set": [],
"contact_set": [],
"customer": null,
"id": 2,
"is_default": false,
"name": "Mediocre opportunity",
"profile": {
"cost": 800,
"product": "entry level"
},
"soft_deleted": false,
"stage_name": "Proposal pending",
"url": "https://demo-server.salespreso.com/api/opportunities/2/"
}
],
"primaryColour": "#0098ff",
"primary_colour": "#0098ff",
"profile": {
"awesomeness": 100,
"product_level": "premium"
},
"soft_deleted": false,
"title": "Test customer",
"url": "https://demo-server.salespreso.com/api/customers/1/"
}
]

data.contacts

[
{
"customer": "https://demo-server.salespreso.com/api/customers/1/",
"email": "john.smith@testcustomer.com",
"fullName": "John Smith",
"id": 1,
"name_first": "John",
"name_last": "Smith",
"notes": "Skinny latte with one sugar",
"opportunity_set": [],
"phone": "0400 000 000",
"photo_128": null,
"photo_256": null,
"photo_512": null,
"position": "CEO",
"url": "https://demo-server.salespreso.com/api/contacts/1/",
"user": null
}
]

data.headers

Contains headers (token and api version) required when interacting with LivePreso API.

data.initialContext

When editing an appointment, this will contain the context of the previous save.

Initial save:

"initialContext": {
"fields": {}
}

"context": {
"fields": {
"selected_country": "australia"
},
"selected_country": "australia"
}

After edit:

"initialContext": {
"fields": {
"selected_country": "australia"
},
"selected_country": "australia"
}

"context": {
"fields": {
"selected_country": "canada"
},
"selected_country": "canada"
}

After another edit:

"initialContext": {
"fields": {
"selected_country": "canada"
},
"selected_country": "canada"
}
>
"context": {
"fields": {
"selected_country": "new zealand"
},
"selected_country": "new zealand"
}

data.isNewAppointment

Boolean that is true if the appointment is new.

data.urls

Contains endpoints that may be necessary to interact with the LivePreso API.

data.user

Details about the owner of the preso.

{
"actions": [],
"email": "jane.doe@example.com",
"first_name": "Jane",
"fullName": "Jane Doe",
"groups": [],
"id": 1,
"is_support": false,
"last_name": "Doe",
"permissions": {
"appointments": {
"canUploadCustomSlides": false,
"isContentAdmin": false,
"livePresenter": false,
"telePresenter": false
},
"presets": {
"canCreateCompanyPresets": false
},
"tempslides": {
"canModifyTemporarySlides": false
}
},
"preferences": {
"app_prefs": {},
"email_signature": "",
"notification_sender": "default",
"timezone": ""
},
"url": "https://demo-server.salespreso.com/api/users/1/",
"username": "jane.doe"
}

Return values

Returned value can be the sections object on its own, or an object containing sections and an array of messages strings.

sections

Modified state of sections, slides and subslides to be applied to the presentation.

warning

While it is possible to alter other aspects of the sections object, we recommend sticking to the modification of sequencing and visibility at this stage. Anything beyond this and you will need to test it thoroughly in both the CDK and the App, as support has not been developed beyond sequencing and visibility.

messages

Array of messages for display to the user in the LivePreso app.

See the toggling and reordering slides guide for further information and examples.

export default {
onChange({ sections }) {
return {
sections,
messages: ["Changes have been made"],
};
},
};