Changeset 25104


Ignore:
Timestamp:
02/20/12 16:42:15 (9 years ago)
Author:
sjm84
Message:

Added the ability to remove metadata

Location:
main/trunk/greenstone3/web/interfaces/oran/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/js/documentmaker_scripts.js

    r25096 r25104  
    55var _indexCounter = 0;
    66var _deletedSections = new Array();
     7var _deletedMetadata = new Array();
    78var _undoOperations = new Array();
    89var _baseURL;
  • main/trunk/greenstone3/web/interfaces/oran/js/documentmaker_scripts_util.js

    r25100 r25104  
    148148        updateFromTop();
    149149    }
     150    else if(undoOp.op == "display")
     151    {
     152        undoOp.srcElem.style.display = undoOp.subOp;
     153    }
     154   
     155    if(undoOp.removeDeletedMetadata)
     156    {
     157        _deletedMetadata.pop();
     158    }
    150159
    151160    if(undoOp.removeTransaction)
     
    169178function save()
    170179{
     180    for(var i = 0; i < _deletedMetadata.length; i++)
     181    {
     182        var currentRow = _deletedMetadata[i];
     183        console.log(currentRow.parentNode);
     184        //Get document ID
     185        var currentElem = currentRow;
     186        while((currentElem = currentElem.parentNode).tagName != "TABLE");
     187        var docID = currentElem.getAttribute("id").substring(4);
     188
     189        //Get metadata name
     190        var cells = currentRow.getElementsByTagName("TD");
     191        var nameCell = cells[0];
     192        var name = nameCell.innerHTML;
     193        var valueCell = cells[1];
     194        var value = valueCell.innerHTML;
     195       
     196        gs.functions.removeArchivesMetadata(gs.cgiParams.p_c /*bad*/, "localsite" /*bad*/, docID, name, null, value, function(){console.log("REMOVED ARCHIVES");});
     197        addCollectionToBuild(gs.cgiParams.p_c);
     198       
     199        removeFromParent(currentRow);
     200    }
     201
    171202    var changes = de.Changes.getChangedEditableSections();
    172     var metaBuild = false;
    173203   
    174204    for(var i = 0; i < changes.length; i++)
     
    193223            changedElem.originalValue = changedElem.innerHTML;
    194224            addCollectionToBuild(gs.cgiParams.p_c);
    195             metaBuild = true;
    196225        }
    197226        //Save content
     
    210239        if(i != _transactions.length - 1)
    211240        {
    212             request +=",";
     241            request += ",";
    213242        }
    214243    }
     
    243272        }
    244273    }
    245    
    246     if(metaBuild || request != "[]")
     274
     275    if(_collectionsToBuild.length > 0)
    247276    {
    248277        var saveButton = document.getElementById("saveButton");
     
    630659    {
    631660        var undo = new Array();
    632         var prev = getPrevSiblingOfType(row, "tr");
    633         var next = getNextSiblingOfType(row, "tr");
    634         var parent = row.parentNode;
    635         if(prev)
    636         {
    637             undo.op = "mva";
    638             undo.refElem = prev;
    639         }
    640         else if(next)
    641         {
    642             undo.op = "mvb";
    643             undo.refElem = next;
    644         }
    645         else
    646         {
    647             undo.op = "mvi";
    648             undo.refElem = parent;
    649         }
    650661        undo.srcElem = row;
    651         undo.removeTransaction = true;
     662        undo.op = "display";
     663        undo.subOp = "table-row";
     664        undo.removeDeletedMetadata = true;
    652665        _undoOperations.push(undo);
    653 
    654         /*
    655         saveTransaction('{"operation":"deleteMetadata", "collection":"' + section.collection + '", "oid":"' + section.nodeID + '"}');
    656         addCollectionToBuild(section.collection);
    657         */
    658 
    659         _deletedSections.push(row);
    660         removeFromParent(row);
     666        _deletedMetadata.push(row);
     667        row.style.display = "none";
    661668    }
    662669    newCell.appendChild(removeLink);
  • main/trunk/greenstone3/web/interfaces/oran/js/javascript-global-functions.js

    r25101 r25104  
    310310    if(metadataPosition != null)
    311311    {
    312         callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archive-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition, responseFunction);
     312        callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metapos=" + metadataPosition, responseFunction);
    313313    }
    314314    else if(metadataValue != null)
    315315    {
    316         callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archive-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
     316        callMetadataServer("removeArchiveMetadata", "cgi-bin/metadata-server.pl?a=remove-archives-metadata&c=" + collection + "&site=" + site + "&d=" + documentID + "&metaname=" + metadataName + "&metavalue=" + metadataValue, responseFunction);
    317317    }
    318318}
Note: See TracChangeset for help on using the changeset viewer.