// this spreadsheet stores leave information of employee
ensure spreadsheet: LeaveSheet
withFields: [Employee, HalfDay, LeaveTime, FromDate, ToDate, NumberOfDays, NumberOfHolidays, TotalLeaveDays, TypeOfLeave, LeaveReason, MedicalProof, Divider, EmployeeRowId, Error, ApprovalStatus]
ofTypes: [pickUser, bool, pickText, date, date, decimal, number, number, pickText, paragraph, document, divider, rowId, error, pickText]
removeRoleSet: [Owner]
insertRoleSet: [Owner, Employee, Agent]
updateRoleSet: [Owner]
readRoleSet: [Owner]
readAfterDurationVar: VarDurationAttendance
ensure form EntityLeave
label: "Leave Application"
ensure section: Details
ensure field Employee
disabled: true
roleDataSource: [Owner, Employee, Agent]
defaultValue: $Self
ensure field HalfDay
showAsCheckbox: true
ensure field LeaveTime
showAs: radioButtonVertical
sourceVar: VarSetOfTextLeaveTime
ensure field FromDate
disabled: false
defaultValue: "now"
ensure field ToDate
disabled: false
defaultValue: "now"
ensure field NumberOfDays
disabled: true
numberOfDigitsAfterPeriod: 1
ensure field NumberOfHolidays
label: "Holidays Between Leave"
disabled: false
permissionMatrix: {
'defaultPermission': 'invisible'
}
ensure field TotalLeaveDays
disabled: true
permissionMatrix: {
'defaultPermission': 'invisible'
}
ensure field TypeOfLeave
label: "Type of Leave"
required: true
sourceVar: VarSetOfTextTypeOfLeave
ensure field LeaveReason kind: paragraph
ensure field MedicalProof kind: document
fileTypeSet: ["any"]
ensure field Divider
ensure field EmployeeRowId
permissionMatrix: {
'defaultPermission': 'invisible'
}
ensure field Error
showCloseButton: false
ensure field ApprovalStatus
label: "Approval Status"
permissionMatrix: {
'defaultPermission': 'read',
'Owner': 'write'
}
sourceVar: VarSetOfTextApprovalStatus
defaultOptionId: "keyPending"
ensure formula Error
assignToField: Details.Error
formula: "let NumberOfDays = ${f:NumberOfDays};
let TypeofLeave = ${f:TypeOfLeave.optionId};
let MedicalProof = ${f:MedicalProof.value.fileName}
if(TypeofLeave=='keySickLeave' && NumberOfDays>2){
'Please upload medical proof'
}
else if(TypeofLeave=='keyCasualLeave' && NumberOfDays>4){
'Cannot take more than 4 casual leave at a time'
}"
ensure formula NumberOfDays
assignToField: Details.NumberOfDays
formula: "const fromDate = ${f:FromDate};
const toDate = ${f:ToDate};
const halfDay = ${f:HalfDay};
if(fromDate && toDate){
const date1 = new Date(fromDate);
const date2 = new Date(toDate);
const diffInMs = date2 - date1;
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
(halfDay==true) ? 0.5 : diffInDays+1
}else{
0
}"
ensure formula TotalDays
assignToField: Details.TotalLeaveDays
formula: "const numberOfDays = ${f:NumberOfDays};
const numberOfHolidays = ${f:NumberOfHolidays};
if(numberOfDays>0){
numberOfDays - numberOfHolidays
}
"
ensure visibilityRule HalfDay
condition: "<root>
<stmt>Details.HalfDay == ${d:HalfDay.true}</stmt>
</root>"
ensure actionMapIfTrue Disable
comp: ToDate
visibilityAction: disable
visibilityActionOn: field
ensure actionMapIfTrue Show
comp: LeaveTime
visibilityAction: visible
visibilityActionOn: field
ensure actionMapIfFalse Enable
comp: ToDate
visibilityAction: enable
visibilityActionOn: field
ensure actionMapIfFalse Invisible
comp: LeaveTime
visibilityAction: invisible
visibilityActionOn: field
ensure visibilityRule DisableForm
condition: "<root>
<stmt>ApprovalStatus == ${d:ApprovalStatus.keyApproved}</stmt>
</root>"
ensure actionMapIfTrue Disable
comp: Details
visibilityAction: disable
visibilityActionOn: component
ensure actionMapIfFalse Enable
comp: Details
visibilityAction: enable
visibilityActionOn: component
ensure visibilityRule ShowMedicalProof
condition: "<root>
<and>
<stmt>Error has value</stmt>
<stmt>TypeOfLeave == ${d:TypeOfLeave.keySickLeave}</stmt>
</and>
</root>"
ensure actionMapIfTrue Show
comp: MedicalProof
visibilityAction: visible
visibilityActionOn: field
ensure actionMapIfFalse Hide
comp: MedicalProof
visibilityAction: invisible
visibilityActionOn: field