Changeset 23749

Show
Ignore:
Timestamp:
02.03.2011 15:40:09 (9 years ago)
Author:
davidb
Message:

Additinal logic (first cut) added to figure out if a document needs to be exploded to be able to correctly save the metadata in the 'import' folder

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/macros/seaweed.dm

    r23519 r23749  
    3030 
    3131<script type="text/javascript"> 
    32  
    33   function gsdefined(val)  
    34   \{ 
    35       return (typeof(val) != "undefined"); 
    36   \} 
    3732 
    3833  var tooltipParentElem = null; 
     
    121116 
    122117 
    123  
    124   var gsapi = new GSAjaxAPI("_gwcgi_","_cgiargc_"); 
    125  
    126118  window.onload=function()\{ 
    127119      try \{ 
     
    164156       // console.log("docoid = " + docoid + " metaname = " + metaname + " metapos = " + metapos + " metavalue = " + metavalue); 
    165157 
     158 
    166159           gsapi.setDocumentMetadata(docoid,metaname,metapos,metavalue); 
    167            gsapi.explodeDocument(docoid); 
    168          
     160 
     161       // figure out if needs to be exploded or if can be save with setImportMetadata 
     162       var needsExploding = 0; 
     163 
     164       var metanameParts = metaname.split(/\\./); 
     165       if (metanameParts.length==1) \{ 
     166             needsExploding = 1; 
     167       \} 
     168       else if (metanameParts[0] == "ex") \{ 
     169             needsExploding = 1; 
     170       \} 
     171 
     172       var docParts = docoid.split(/\\./); 
     173           if (docParts.length>=2) \{ 
     174             needsExploding = 1; 
     175       \} 
     176 
     177           if (needsExploding) \{ 
     178          if (confirm("Document needs to be exploded for this edit of " + metaname + " to be retained.\\nProceed?")) \{ 
     179             gsapi.explodeDocument(docoid); 
     180          \} 
     181       \} 
     182       else \{ 
     183            gsapi.setImportMetadata(docoid,metaname,metapos,metavalue); 
     184       \} 
     185 
    169186         \} 
    170187 
     
    198215  function seaweedReindexCollection() \{ 
    199216    var arc = document.getElementById("seaweedRC"); 
    200     arc.innerHTML = "reindexing ..."; 
     217    arc.innerHTML = "Reindexing ..."; 
    201218    gsapi.reindexCollection("incremental",seaweedReindexCallback); 
    202219  \} 
     
    204221  function seaweedReindexCallback(xmlHttp) \{ 
    205222    var arc = document.getElementById("seaweedRC"); 
    206     arc.innerHTML = "reindexing done."; 
     223    arc.innerHTML = "Reindexing done."; 
    207224  \}             
    208225