Add Office
Backend
1. Create a spreadsheet of offices
ensure spreadsheet: OfficeMaster;
withFields: ["Date*", "Name*", "OfficeNumber*", "MobileNumber*", "Active", "Address", "TeaPrice", "CoffeePrice"];
ofTypes: [date, text, text, mobileNumber, bool, paragraph, number, number];
defaultValueMap: {
"Date": "now",
"MobileNumber": "+919898989898",
"Address": "Some address";
}
minValues: {
"TeaPrice": 0,
"CoffeePrice": 0;
}
readRoleSet: [Owner];
insertRoleSet: [Owner];
updateRoleSet: [Owner];
searchables: [Name, OfficeNumber, MobileNumber, Address];
queryables: [Date, Name, Active, MobileNumber];
Frontend
1. Action to add office
// action to add the office to OfficeMaster spreadsheet
ensure action AddOffice kind: rowInsert
spreadsheet: OfficeMaster
icon: "PersonAddAlt1Rounded"
defaultValueMap: {
'Details.TeaPrice': 10,
'Details.Active': true,
'Details.CoffeePrice': 15
}
sendMessageToInbox: true
2. Action to open spreadsheet editor
// switch context to OfficeMaster where next commands would be directed
ctx spreadsheet OfficeMaster
// create two layouts for spreadsheet editor
// first: a list layout along with how each list item is laid out
ensure layoutSpreadsheet ListLayout kind: list
filter.showSearchBar: true
withEachItemAs:"
Name Date
MobileNumber OfficeNumber
TeaPrice, CoffeePrice"
// second: a table layout
ensure layoutSpreadsheet TableLayout kind: table
showComps: [Date, Name, OfficeNumber, MobileNumber, Active, Address, TeaPrice, CoffeePrice]
columnSizeSet: ["AutoSize"]
// action to create spreadsheet editor with default table layout
ensure action EditOfficeMaster kind: spreadsheetEditor
spreadsheet: OfficeMaster
icon: "EditNoteRounded"
defaultValueMap: {
'TeaPrice': 10,
'Active': true,
'CoffeePrice': 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
hideActionMenu: true
pinnedActions: [AddOffice, EditOfficeMaster]
actionPermission: {
'AddOffice': 'Owner',
'EditOfficeMaster': 'Owner'
}