Skip to content

Instantly share code, notes, and snippets.

@diogobaltazar
Created December 7, 2018 13:29
Show Gist options
  • Save diogobaltazar/cd3120f6f0abf1365d83b8cf0ac089bc to your computer and use it in GitHub Desktop.
Save diogobaltazar/cd3120f6f0abf1365d83b8cf0ac089bc to your computer and use it in GitHub Desktop.
form_data = {}
// evaluating the args out of the if-then clause enables them to be available
// inside the if-then body. They are intended to be evaluated on whether they're
// empty or not, but evaluating them on the if-then condition would not let all
// args be evaluated if at least one but the last was not empty.
lastEvolutionsEdit = {{admin_edit_evolution_txt.text}}
lastRoleEdit = {{admin_edit_role_txt.text}}
lastTrainEdit = {{admin_edit_training_txt.text}}
if (lastEvolutionsEdit || lastRoleEdit || lastTrainEdit ) {
lastID = {{COUNT__REP_DS_TRANSF__PHONO}}.result[0].totalHits
lastReport = {{getCurrentChosenProfessionReport}}[0]
form_data = { // exclude primary key
"PROFESSION": ""
, "ROLE": lastRoleEdit ? lastRoleEdit : lastReport.ROLE
, "ROLE_DATE": lastRoleEdit ? new Date(Date.now()) : lastReport.ROLE_DATE
, "EVOLUTIONS": lastEvolutionsEdit ? lastEvolutionsEdit : lastReport.EVOLUTIONS
, "EVOL_DATE": lastEvolutionsEdit ? new Date(Date.now()) : lastReport.EVOL_DATE
, "TRAIN_REC": lastTrainEdit ? lastTrainEdit : lastReport.TRAIN_REC
, "TRAIN_DATE": lastTrainEdit ? new Date(Date.now()) : lastReport.TRAIN_DATE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment