Moved all diagram creation and editing front end code to directive