app/static/scripts/globalScripts.js
// process click event for removal of relationship
process click event for removal of relationship
process click event for removal of relationship
function delete_relationship(event) {
            var id = event.target.getAttribute('var');
            var person_object = person_from_id(id);
            var owner_delete = document.getElementsByClassName('trash_can');
            var owner_id = owner_delete[0].getAttribute('var');
            var owner_object = person_from_id(owner_id);
            id = parseInt(id);
            owner_id = parseInt(owner_id);
            for( let entry of RELATION_ARRAY) {
                console.log('checking entry', entry);
                if( entry.person_a_id == id && entry.person_b_id == owner_id) {
                    console.log('removing relationships from arrays');
                    person_object.remove_relationship(owner_object);
                    owner_object.remove_relationship(person_object);
                    let index = RELATION_ARRAY.indexOf(entry);
                    RELATION_ARRAY.splice(index, 1);
                } else if ( entry.person_b_id == id && entry.person_a_id == owner_id ) {
                    console.log('removing relationships from arrays');
                    person_object.remove_relationship(owner_object);
                    owner_object.remove_relationship(person_object);
                    let index = RELATION_ARRAY.indexOf(entry);
                    RELATION_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", "/remove_relationship");
            ajax_request.setRequestHeader("Content-Type", "application/json"); 
            ajax_request.send(json_string);
            ajax_request.onload = function() {
                var profile_relation_div = event.target.parentElement;
                profile_relation_div.remove();
                console.log('after deletion of relatioship - ', RELATION_ARRAY);
                update_tree();
            };
        }
function delete_relationship ( event ) { var id = event . target . getAttribute ( 'var' ) ; var person_object = person_from_id ( id ) ; var owner_delete = document . getElementsByClassName ( 'trash_can' ) ; var owner_id = owner_delete [ 0 ] . getAttribute ( 'var' ) ; var owner_object = person_from_id ( owner_id ) ; id = parseInt ( id ) ; owner_id = parseInt ( owner_id ) ; for ( let entry of RELATION_ARRAY ) { console . log ( 'checking entry' , entry ) ; if ( entry . person_a_id == id && entry . person_b_id == owner_id ) { console . log ( 'removing relationships from arrays' ) ; person_object . remove_relationship ( owner_object ) ; owner_object . remove_relationship ( person_object ) ; let index = RELATION_ARRAY . indexOf ( entry ) ; RELATION_ARRAY . splice ( index , 1 ) ; } else if ( entry . person_b_id == id && entry . person_a_id == owner_id ) { console . log ( 'removing relationships from arrays' ) ; person_object . remove_relationship ( owner_object ) ; owner_object . remove_relationship ( person_object ) ; let index = RELATION_ARRAY . indexOf ( entry ) ; RELATION_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" , "/remove_relationship" ) ; ajax_request . setRequestHeader ( "Content-Type" , "application/json" ) ; ajax_request . send ( json_string ) ; ajax_request . onload = function ( ) { var profile_relation_div = event . target . parentElement ; profile_relation_div . remove ( ) ; console . log ( 'after deletion of relatioship - ' , RELATION_ARRAY ) ; update_tree ( ) ; } ; }
process click event for removal of relationship
process click event for removal of relationship
// removal from javascript side // person b must be sifted // ajax to remove server side // important for flask interpretation // all javascript should be updated. // remove name from current list on profile