📁 Showcase
Add Order - English

Add Order

Set backend

1. DeliveryBoy role

// this role has an access to the ordering module.
 
ensure role DeliveryBoy
 

2. Time variable

// pickText variable to pick a time of the order
 
ensure var VarSetOfTextTime kind: setOfText
  deploy: fixedOnDeploy
  value: "<root>
      <node key='1'>Morning</node>
      <node key='2'>Afternoon</node>
    </root>"
 

3. OrderBook spreadsheet

// this spreadsheet stores the order information of customers.
 
ensure spreadsheet: OrderBook
  withFields: [Date, Time, TeaCount, CoffeeCount, Signature, Total]
  ofTypes: [date, pickText, number, number, signature, number]
  readRoleSet: [Owner, DeliveryBoy]
  insertRoleSet: [DeliveryBoy]
  updateRoleSet: [Owner]
  removeRoleSet: [Owner]
 

4. Decorate spreadsheet

// update the properties of the fields in OrderBook
 
ensure form FormOrderBook
ctx rename EntityOrder
 
ensure composite Details
ctx rename Order
ensure field Date defaultValue: "now"
ensure field TeaCount required: true
ensure field CoffeeCount required: true
ensure field Total disabled: true
ensure field Time
  sourceVar: VarSetOfTextTime
  defaultOptionId: "1"
 
ensure section: Office
ctx moveup
ensure field OfficeRef kind: ref
  spreadsheet: OfficeMaster
  layoutSpreadsheet: ListLayout
  copyFieldMap: {
    'OfficeMasterRowId': '$RowId',
    'Name': 'Name',
    'OfficeNumber': 'OfficeNumber',
    'MobileNumber': 'MobileNumber',
    'TeaPrice': 'TeaPrice',
    'CoffeePrice':  'CoffeePrice'
  }
 
ensure formula TotalFormula
  assignToField: Total
  formula: "(${f:TeaPrice} * ${f:TeaCount}) + (${f:CoffeePrice} * ${f:CoffeeCount})"
 
ensure spreadsheet OrderBook
  queryables: [Name, OfficeNumber, TeaPrice, CoffeePrice, Time, TeaCount, CoffeeCount, Total]
  searchables: [Name, OfficeNumber, TeaPrice, CoffeePrice, Time, MobileNumber, Total]
 

Set frontend

1. AddOrder action

// this action adds orders for customers
 
ensure action AddOrder kind: rowInsert
  icon: "AddShoppingCartRounded"
  spreadsheet: OrderBook
  sendMessageToInbox: true
 

2. OrderBook group

// this group has all the actions those can be performed on OrderBook spreadsheet
 
ensure group OrderBook allowPromptAssistant: false hideActionMenu: true
 

3. Decorate group

// adding action of OrderBook spreadsheet to group
 
ensure group OrderBook
  pinnedActions: [AddOrder]
  actionPermission: {
      'AddOrder': {
        'roles': [
          'DeliveryBoy'
        ]
      }
    }