Make stemma data return consistent; refrain from assuming digraph in edit box. Fixes #28
[scpubgit/stemmaweb.git] / root / js / componentload.js
index 4c17616..3bb43a9 100644 (file)
@@ -47,10 +47,12 @@ function loadTradition( textid, textname, editable ) {
        $('#open_stemma_add').show();
        $('#open_stemma_edit').show();
        $('#open_textinfo_edit').show();
+       $('#relatebutton_label').text('View collation and edit relationships');
     } else {
        $('#open_stemma_add').hide();
        $('#open_stemma_edit').hide();
        $('#open_textinfo_edit').hide();
+       $('#relatebutton_label').text('View collation and relationships');
     }
 
     // Then get and load the actual content.
@@ -73,6 +75,9 @@ function loadTradition( textid, textname, editable ) {
                load_stemma( selectedStemmaID );
        // Set up the relationship mapper button
                $('#run_relater').attr( 'action', _get_url([ "relation", textid ]) );
+               // Set up the download button
+               $('#dl_tradition').attr( 'href', _get_url([ "download", textid ]) );
+               $('#dl_tradition').attr( 'download', selectedTextInfo.name + '.xml' );
        });
 }
 
@@ -88,7 +93,12 @@ function load_textinfo() {
        // Who the owner is
        $('#owner_id').empty().append('no one');
        if( selectedTextInfo.owner ) {
-               $('#owner_id').empty().append( selectedTextInfo.owner );
+               var owneremail = selectedTextInfo.owner;
+               var chop = owneremail.indexOf( '@' );
+               if( chop > -1 ) {
+                       owneremail = owneremail.substr( 0, chop + 1 ) + '...';
+               }
+               $('#owner_id').empty().append( owneremail );
        }
        // Whether or not it is public
        $('#not_public').empty();
@@ -124,7 +134,10 @@ function load_stemma( idx ) {
        selectedStemmaID = idx;
        show_stemmapager();
        if( idx > -1 ) {
-               loadSVG( stemmata[idx] );
+               // Load the SVG and identifier of the stemma
+               var stemmadata = stemmata[idx];
+               loadSVG( stemmadata['svg'] );
+               $('#stemma_identifier').empty().text( stemmadata['name'] );
                // Stexaminer submit action
                var stexpath = _get_url([ "stexaminer", selectedTextID, idx ]);
                $('#run_stexaminer').attr( 'action', stexpath );
@@ -383,10 +396,13 @@ $(document).ready( function() {
                                        // We received a stemma SVG string in return. 
                                        // Update the current stemma sequence number
                                        selectedStemmaID = data.stemmaid;
-                                       // Stash the answer in our SVG array
-                                       stemmata[selectedStemmaID] = data.stemmasvg;
+                                       delete data.stemmaid;
+                                       // Stash the answer in the appropriate spot in our stemma array
+                                       stemmata[selectedStemmaID] = data;
                                        // Display the new stemma
                                        load_stemma( selectedStemmaID );
+                                       // Show the edit button, in case this was the first new stemma
+                                       $('#open_stemma_edit').show();
                                        // Reenable the button and close the form
                                        $(evt.target).button("enable");
                                        $('#stemma-edit-dialog').dialog('close');