Add Office
Backend
1. Create SS of offices
// create spreadsheet OfficeMaster to store the office data
ensure spreadsheet: OfficeMaster
withFields: [Date, Name, OfficeNumber, MobileNumber, Active, Address, TeaPrice, CoffeePrice]
ofTypes: [date, text, text, mobileNumber, bool, paragraph, number, number]
readRoleSet: [Owner]
insertRoleSet: [Owner]
updateRoleSet: [Owner]
ensure spreadsheet OfficeMaster
searchables: [Name, OfficeNumber, MobileNumber, Address]
queryables: [Date, Name, Active, MobileNumber]
// update the properties of the fields in OfficeMaster
ensure form FormOfficeMaster
ctx rename EntityOffice
ensure composite Details
ensure field Date required: true defaultValue: "now"
ensure field Name required: true
ensure field OfficeNumber required: true
ensure field MobileNumber required: true defaultValue: "+919898989898"
ensure field Address required: true defaultValue: "1 finite loop, Cupertino, California."
ensure field TeaPrice min: 0
ensure field CoffeePrice min: 0
Frontend
1. Action to add office
// this action adds the office to OfficeMaster spreadsheet
ensure action AddOffice kind: rowInsert
spreadsheet: OfficeMaster
icon: "PersonAddAlt1Rounded"
defaultValueMap: {
'TeaPrice': {
'value': 10
},
'Active': {
'value': true
},
'CoffeePrice': {
'value': 15
}
}
sendMessageToInbox: true
2. Action to configure SS editor
ensure spreadsheet OfficeMaster
// set a list layout with following layout for each list item
//
// FirstLine => Name Date
// SecondLine => MobileNumber OfficeNumber
// ThirdLine => TeaPrice, CoffeePrice
ensure layoutSpreadsheet ListLayout kind: list
filter.showSearchBar: true
firstLine.first.lineFields: [Name]
firstLine.caption.lineFields: [Date]
secondLine.first.lineFields: [MobileNumber]
secondLine.caption.lineFields: [OfficeNumber]
thirdLine.first.lineFields: [TeaPrice, CoffeePrice]
// set a table layout
ensure layoutSpreadsheet TableLayout kind: table
showComps: [Date, Name, OfficeNumber, MobileNumber, Active, Address, TeaPrice, CoffeePrice]
columnSizeSet: ["AutoSize"]
// this action update the existing office or add a new office
ensure action EditOfficeMaster kind: spreadsheetEditor
spreadsheet: OfficeMaster
icon: "EditNoteRounded"
defaultValueMap: {
'TeaPrice': {
'value': 10
},
'Active': {
'value': true
},
'CoffeePrice': {
'value': 15
}
}
layoutSpreadsheet: TableLayout
bulkInsertRoleSet: [Owner]
3. Expose Actions through a Group
// create a group with actions that can be performed on the OfficeMaster spreadsheet
ensure group OfficeMaster
allowPromptAssistant: false
hideActionMenu: true
// add actions to the group
ensure group OfficeMaster
pinnedActions: [AddOffice, EditOfficeMaster]
actionPermission: {
'AddOffice': {
'roles': [
'Owner'
]
},
'EditOfficeMaster': {
'roles': [
'Owner'
]
}
}