Created
July 10, 2019 15:31
-
-
Save Ayyagaries/918c86bccc37ecae324d8e44ed29528d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displayUI(_response) { | |
var buttonView; | |
var response_keys = _.keys(_response); | |
if (response_keys.length === 0) { | |
$.vw_row_fn.add(addText("Contact's first name", "txt_firstname")); | |
$.vw_row_ln.add(addText("Contact's last name", "txt_lastname")); | |
$.vw_row_dept.add(addText("Department", "txt_department")); | |
$.vw_row_purpose.add(addText("Purpose of visit", "txt_purpose")); | |
} else if (response_keys.length > 0) { | |
if (response_keys.includes("location")) { | |
if (_response.location.length > 0) { | |
buttonView = addButton("department", "-Location of Visit-", _response.location); | |
//buttonView.addEventListener('click', displayList); | |
$.vw_row_dept.add(buttonView); | |
} else { | |
$.vw_row_dept.add(addText("Department", "txt_department")); | |
} | |
} | |
if (response_keys.includes("purpose")) { | |
if (_response.purpose.length > 0) { | |
buttonView = addButton("purpose", "-Purpose of Visit-", _response.purpose); | |
//buttonView.addEventListener('click', displayList); | |
$.vw_row_purpose.add(buttonView); | |
} else { | |
$.vw_row_purpose.add(addText("Purpose of visit", "txt_purpose")); | |
} | |
} | |
// if there is person_visiting in the key and the length is greater than zero | |
if (response_keys.includes("person_visiting")) { | |
if (_response.person_visiting.length > 0) { | |
$.fn_ln_box.remove($.vw_row_fn); | |
buttonView = addButton("personvisting", "-Person Visiting-", _response.person_visiting); | |
//buttonView.addEventListener('click', displayList); | |
$.vw_row_ln.add(buttonView); | |
} | |
} else { | |
$.vw_row_fn.add(addText("Contact's first name", "txt_firstname")); | |
$.vw_row_ln.add(addText("Contact's last name", "txt_lastname")); | |
} | |
} | |
App.closeLoading(); | |
} | |
function addLabel(lblName) { | |
var alertlabel = Ti.UI.createLabel({ | |
id: "lbl_alert_" + lblName, | |
color: Alloy.Globals.colors.red, | |
font: { | |
fontFamily: 'FontAwesome', | |
fontSize: 20 | |
}, | |
height: Ti.UI.FILL, | |
right: 3, | |
text: Alloy.Globals.fa.exclamationTriangle, | |
textAlign: 'center', | |
visible: false, | |
width: 32 | |
}); | |
if (Alloy.isTablet) { | |
alertlabel.font = { | |
fontFamily: 'FontAwesome', | |
fontSize: 25 | |
}; | |
} | |
return alertlabel; | |
} | |
function addButton(btnName, btnTitle, dataDisplay) { | |
var buttonView = Ti.UI.createView({ | |
id: "btn_view_" + btnName, | |
width: Ti.UI.FILL, | |
height: Ti.UI.SIZE, | |
dataToDisplay: dataDisplay | |
}); | |
var chevronLabel = Ti.UI.createLabel({ | |
id: "chevron_lbl_" + btnName, | |
color: Alloy.Globals.colors.gray, | |
font: { | |
fontFamily: 'FontAwesome', | |
fontSize: 20 | |
}, | |
height: Ti.UI.FILL, | |
right: 5, | |
text: Alloy.Globals.fa.chevronRight, | |
textAlign: 'center', | |
width: 32, | |
dataToDisplay: dataDisplay, | |
}); | |
chevronLabel.addEventListener("click", displayList); | |
if (Alloy.isTablet) { | |
chevronLabel.font = { | |
fontFamily: 'FontAwesome', | |
fontSize: 25 | |
}; | |
} | |
var select_button = Ti.UI.createTextField({ | |
id: "btn_" + btnName, | |
hintText: btnTitle, | |
backgroundColor: 'transparent', | |
borderColor: '#fff', | |
borderRadius: 6, | |
borderWidth: 1, | |
width: '90%', | |
editable: false, | |
dataToDisplay: dataDisplay, | |
left: "2%", | |
}); | |
select_button.addEventListener("click", displayList); | |
//buttonView.addEventListener("click", displayList); | |
buttonView.add(select_button); | |
buttonView.add(chevronLabel); | |
return buttonView; | |
} | |
function displayList(e) { | |
App.openScreen('checkin/facilityDefaults', { | |
dataToDisplay: e.source.dataToDisplay | |
}).on('checkin.loadfacilityDefaults', function(data) { | |
e.source.value = data.companyName; | |
}); | |
} | |
function addText(hintText, textid) { | |
var textfield = Ti.UI.createTextField({ | |
hintText: hintText, | |
id: textid, | |
backgroundColor: 'transparent', | |
borderWidth: 0, | |
width: '98%', | |
}); | |
if (OS_IOS) { | |
textfield.width = "95%"; | |
} | |
if (Alloy.isTablet) { | |
textfield.font = { | |
fontSize: 20 | |
}; | |
} | |
textfield.addEventListener("change", textFieldChanged); | |
return textfield; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment