app/static/scripts/globalScripts.js
// to delete this person from all javascript and post AJAX to remove from db
to delete this person from all javascript and post AJAX to remove from db
to delete this person from all javascript and post AJAX to remove from db
function delete_person(id) {
        console.log('deleting id', id);
        let person_object = person_from_id(id);
        for( let entry of RELATION_ARRAY) {
            if( entry.person_a_id == id) {
                let relative = person_from_id(entry.person_b_id);
                relative.remove_relationship(person_object);
                let index = RELATION_ARRAY.indexOf(entry);
                RELATION_ARRAY.splice(index, 1);
            } else if ( entry.person_b_id == id ) {
                let relative = person_from_id(entry.person_a_id);
                relative.remove_relationship(person_object);
                let index = RELATION_ARRAY.indexOf(entry);
                RELATION_ARRAY.splice(index, 1);
            }
        }
        for( let person of PERSON_ARRAY) {
            if( person.id == id) {
                let index = PERSON_ARRAY.indexOf(person);
                PERSON_ARRAY.splice(index, 1);
            }
        }
        var person_id = {}
        person_id.id = id;
        var json_string = JSON.stringify(person_id);
        var ajax_request = new XMLHttpRequest();
        ajax_request.open("POST", "/delete_person");
        ajax_request.setRequestHeader("Content-Type", "application/json"); 
        ajax_request.send(json_string);
        ajax_request.onload = function() {
            update_tree();
        };
    }
function delete_person ( id ) { console . log ( 'deleting id' , id ) ; let person_object = person_from_id ( id ) ; for ( let entry of RELATION_ARRAY ) { if ( entry . person_a_id == id ) { let relative = person_from_id ( entry . person_b_id ) ; relative . remove_relationship ( person_object ) ; let index = RELATION_ARRAY . indexOf ( entry ) ; RELATION_ARRAY . splice ( index , 1 ) ; } else if ( entry . person_b_id == id ) { let relative = person_from_id ( entry . person_a_id ) ; relative . remove_relationship ( person_object ) ; let index = RELATION_ARRAY . indexOf ( entry ) ; RELATION_ARRAY . splice ( index , 1 ) ; } } for ( let person of PERSON_ARRAY ) { if ( person . id == id ) { let index = PERSON_ARRAY . indexOf ( person ) ; PERSON_ARRAY . splice ( index , 1 ) ; } } var person_id = { } person_id . id = id ; var json_string = JSON . stringify ( person_id ) ; var ajax_request = new XMLHttpRequest ( ) ; ajax_request . open ( "POST" , "/delete_person" ) ; ajax_request . setRequestHeader ( "Content-Type" , "application/json" ) ; ajax_request . send ( json_string ) ; ajax_request . onload = function ( ) { update_tree ( ) ; } ; }
to delete this person from all javascript and post AJAX to remove from db
to delete this person from all javascript and post AJAX to remove from db
// removal from relation array // person b must be sifted // removal from PERSON_ARRAY // remove html element -  // for cards this is different than siblings // do in click function // build json to send POST // important for flask interpretation // all javascript should be updated. // reload