disa_app/static/js/entry_form_data_in.js
// Convert an array into a form that Tagify understands
Convert an array into a form that Tagify understands
Convert an array into a form that Tagify understands
function prepareForTagify(data) {
  let tagifiedData;
  if (Array.isArray(data) && data.length > 0) {
    if (data[0].id && data[0].label) {
      tagifiedData = JSON.stringify(data.map(dataItem => {
        return { value: dataItem.label, dbID: dataItem.id }
      }));
    }
  } else if (data.id !== undefined && data.label !== undefined) {
    tagifiedData = JSON.stringify({ 
      value: dataItem.label, 
      dbID: dataItem.id
    });
  } else {
    tagifiedData = '[]';
  }
  console.log('TAGIFYING FROM ', data, ' TO ', tagifiedData);
  return tagifiedData;
}
function prepareForTagify ( data ) { let tagifiedData ; if ( Array . isArray ( data ) && data . length > 0 ) { if ( data [ 0 ] . id && data [ 0 ] . label ) { tagifiedData = JSON . stringify ( data . map ( dataItem => { return { value : dataItem . label , dbID : dataItem . id } } ) ) ; } } else if ( data . id !== undefined && data . label !== undefined ) { tagifiedData = JSON . stringify ( { value : dataItem . label , dbID : dataItem . id } ) ; } else { tagifiedData = '[]' ; } console . log ( 'TAGIFYING FROM ' , data , ' TO ' , tagifiedData ) ; return tagifiedData ; }
Convert an array into a form that Tagify understands
Convert an array into a form that Tagify understands