app/static/scripts/globalScripts.js
// callable to populate/refresh options for relationships when creating a new person
callable to populate/refresh options for relationships when creating a new person
callable to populate / refresh options for relationships when creating a new person
function update_new_person_relation_options(build_bool) {
    var relation_div = document.getElementById('new_person_relationship_options');
    if(!build_bool) { removeAllChildNodes(relation_div); }
    if( PERSON_ARRAY.length > 0) {
        let relation_type_label = document.createElement('label');
        relation_type_label.className = 'input_label';
        relation_type_label.innerText = 'This is a ';
        let relation_type_select = document.createElement('select');
        relation_type_select.className = 'select_input';
        relation_type_select.id = 'relation_type_select';
        let parent_option = document.createElement('option');
        parent_option.innerText = 'Parent';
        parent_option.className = 'option_input';
        parent_option.value = 'a';
        let sibling_option = document.createElement('option');
        sibling_option.innerText = 'Sibling';
        sibling_option.className = 'option_input';
        sibling_option.value = 'c';
        let child_option = document.createElement('option');
        child_option.innerText = 'Child';
        child_option.className = 'option_input';
        child_option.value = 'b';
        relation_type_select.append(parent_option, sibling_option, child_option);
        let of_label = document.createElement('label');
        of_label.className = 'input_label';
        of_label.innerText = ' of ';
        let person_select = document.createElement('select');
        person_select.className = 'select_input';
        person_select.id = 'person_select';
        for(let i = 0; i < PERSON_ARRAY.length; i++ ) {
            let person = PERSON_ARRAY[i];
            if(person.cardHolder) {
                if( person.cardHolder.className.includes('sibling_icon')) {
                    continue
                }
            }
            let new_option = document.createElement('option');
            new_option.value = person.id;
            new_option.innerText = person.givenName;
            new_option.className = 'option_input';
            person_select.appendChild(new_option);
        }
        relation_div.append(relation_type_label, relation_type_select, of_label, person_select);
    } else { 
        let relation_type_label = document.createElement('label');
        relation_type_label.className = 'input_label';
        relation_type_label.innerText = 'This person will be automatically assigned as the ROOT of the tree';
        relation_div.append(relation_type_label);
    }
}
function update_new_person_relation_options ( build_bool ) { var relation_div = document . getElementById ( 'new_person_relationship_options' ) ; if ( ! build_bool ) { removeAllChildNodes ( relation_div ) ; } if ( PERSON_ARRAY . length > 0 ) { let relation_type_label = document . createElement ( 'label' ) ; relation_type_label . className = 'input_label' ; relation_type_label . innerText = 'This is a ' ; let relation_type_select = document . createElement ( 'select' ) ; relation_type_select . className = 'select_input' ; relation_type_select . id = 'relation_type_select' ; let parent_option = document . createElement ( 'option' ) ; parent_option . innerText = 'Parent' ; parent_option . className = 'option_input' ; parent_option . value = 'a' ; let sibling_option = document . createElement ( 'option' ) ; sibling_option . innerText = 'Sibling' ; sibling_option . className = 'option_input' ; sibling_option . value = 'c' ; let child_option = document . createElement ( 'option' ) ; child_option . innerText = 'Child' ; child_option . className = 'option_input' ; child_option . value = 'b' ; relation_type_select . append ( parent_option , sibling_option , child_option ) ; let of_label = document . createElement ( 'label' ) ; of_label . className = 'input_label' ; of_label . innerText = ' of ' ; let person_select = document . createElement ( 'select' ) ; person_select . className = 'select_input' ; person_select . id = 'person_select' ; for ( let i = 0 ; i < PERSON_ARRAY . length ; i ++ ) { let person = PERSON_ARRAY [ i ] ; if ( person . cardHolder ) { if ( person . cardHolder . className . includes ( 'sibling_icon' ) ) { continue } } let new_option = document . createElement ( 'option' ) ; new_option . value = person . id ; new_option . innerText = person . givenName ; new_option . className = 'option_input' ; person_select . appendChild ( new_option ) ; } relation_div . append ( relation_type_label , relation_type_select , of_label , person_select ) ; } else { let relation_type_label = document . createElement ( 'label' ) ; relation_type_label . className = 'input_label' ; relation_type_label . innerText = 'This person will be automatically assigned as the ROOT of the tree' ; relation_div . append ( relation_type_label ) ; } }
callable to populate/refresh options for relationships when creating a new person
callable to populate / refresh options for relationships when creating a new person
// clear it for repopulation.. //build options in a loop based on the people availables // filters out siblings. so you can't add blind relationships // this is the first created person