Changeset 327


Ignore:
Timestamp:
10/14/10 16:07:24 (15 years ago)
Author:
lgiessmann
Message:

adapted the "mark-as-deleted" functions of the UI to the latest update of the backend; fixed a bug in "json_tmcl_validation" when iterating marked-as-deleted assocations; fixed a bug in the UI that appeared after committing delete-messages to the backend --> ticket #74

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/ajax/javascripts/datamodel.js

    r283 r327  
    43564356       && type !== "Topic" && type !== "Association"){
    43574357        throw "From makeRemoveObject(): type must be: \"Occurrence\" || \"Name\" " +
    4358             "|| \"Variant\" || \"Topic\" || \"Association\" but is " + type;
     4358            "|| \"Topic\" but is " + type;
    43594359    }
    43604360    if (!objectToDelete){
     
    43624362    }
    43634363
    4364     var parentTopic = "null";
    4365     if(type === "Occurrence" || type === "Name"){
    4366         var psiFrame = objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode.select("tr." + CLASSES.subjectIdentifierFrame())[0];
     4364    // --- Returns a JSON-object that corresponds to a topicStub
     4365    function makeJsonTopicStub(topicFrame){
     4366        var topPSIs = "null";
     4367        var psiFrame = topicFrame.select("tr." + CLASSES.subjectIdentifierFrame())[0];
    43674368        var psiFields = psiFrame.select("input");
    4368         for(i = 0; psiFields && i !== psiFields.length; ++i){
     4369        for(var i = 0; psiFields && i !== psiFields.length; ++i){
    43694370            var psiValue = psiFields[i].value;
    43704371            if(psiValue.strip().length !== 0){
    4371                 parentTopic = psiValue.strip().toJSON();
     4372                topPSIs = new Array(psiValue.strip()).toJSON();
    43724373                break;
    43734374            }
    43744375        }
    4375     }
    4376 
    4377     var topics = "null";
    4378     if (type === "Topic"){
    4379         var psiFrame = objectToDelete.getFrame().select("tr." + CLASSES.subjectIdentifierFrame())[0];
    4380         var psiFields = psiFrame.select("input");
    4381         for(i = 0; psiFields && i !== psiFields.length; ++i){
    4382             var psiValue = psiFields[i].value;
    4383             if(psiValue.strip().length !== 0){
    4384                 topics = new Array(psiValue.strip()).toJSON();
     4376        var topIIs = "null";
     4377        var iiFrame = topicFrame.select("tr." + CLASSES.itemIdentityFrame())[0];
     4378        var iiFields = iiFrame.select("input");
     4379        for(var i = 0; iiFields && i !== iiFields.length; ++i){
     4380            var iiValue = iiFields[i].value;
     4381            if(iiValue.strip().length !== 0){
     4382                topIIs = new Array(iiValue.strip()).toJSON();
    43854383                break;
    43864384            }
    43874385        }
     4386        var topSLs = "null";
     4387        var slFrame = topicFrame.select("tr." + CLASSES.subjectLocatorFrame())[0];
     4388        var slFields = slFrame.select("input");
     4389        for(var i = 0; slFields && i !== slFields.length; ++i){
     4390            var slValue = slFields[i].value;
     4391            if(slValue.strip().length !== 0){
     4392                topSLs = new Array(slValue.strip()).toJSON();
     4393                break;
     4394            }
     4395        }
     4396        return "{\"id\":\"null\",\"itemIdentities\":" + topIIs +
     4397               ",\"subjectLocators\":" + topSLs + ",\"subjectIdentifiers\":" + topPSIs +
     4398               ",\"instanceOfs\":\"null\",\"names\":\"null\",\"occurrences\":\"null\"}";
    43884399    }
    43894400
    4390     var deletedObjects = null;
    4391     if(type === "Topic"){ deletedObjects = topics; }
    4392     else { deletedObjects = "[" + objectToDelete.toJSON() + "]"; }
    4393 
    4394     var jsonData = "{\"type\":\"" + type + "\"," +
    4395                     "\"topics\":" + topics + "," +
    4396                     "\"associations\":" + "null" + "," +
    4397                     "\"parentTopic\":" + parentTopic + "," +
    4398                     "\"parentName\":" + "null" + "," +
    4399                     "\"names\":" + (type === "Name" ? deletedObjects : "null") + "," +
    4400                     "\"variants\":" + "null" + "," +
    4401                     "\"occurrences\":" + (type === "Occurrence" ? deletedObjects : "null") + "," +
    4402                     "\"parentAssociation\":" + "null" + "," +
    4403                     "\"roles\":" + "null" + "}";
     4401    var delMessage = "null";
     4402
     4403    switch(type){
     4404    case "Topic":
     4405        delMessage = "{\"type\":\"Topic\",\"delete\":" + makeJsonTopicStub(objectToDelete.getFrame()) + "}";
     4406        break;
     4407    case "Name":
     4408    case "Occurrence":
     4409        delMessage = "{\"type\":\"" + type + "\",\"parent\":" +
     4410                     makeJsonTopicStub(objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode) +
     4411                     ",\"delete\":" + objectToDelete.toJSON() + "}";
     4412        break;
     4413    }
    44044414 
    4405     commitDeletedObject(jsonData, function(xhr){
     4415    commitDeletedObject(delMessage, function(xhr){
    44064416            alert("Objected deleted");
    44074417            if(type === "Topic"){
    44084418                $(CLASSES.subPage()).update();
    4409                 makeHome();
     4419                setNaviClasses($(PAGES.home));
     4420                makePage(PAGES.home, "");
    44104421            }
    44114422            else if (type === "Occurrence" || type === "Name"){
  • TabularUnified trunk/src/ajax/javascripts/requests.js

    r279 r327  
    220220
    221221
    222 // --- Sends a POST-Message to the server. The sent message enables the server
     222// --- Sends a DELETE-Message to the server. The sent message enables the server
    223223// --- to find the spcified object and mark it as deleted
    224224function commitDeletedObject(json, onSuccessHandler, onFailureHandler)
     
    228228        var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
    229229        var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
    230        
    231230        new Ajax.Request(MARK_AS_DELETED_URL, {
    232             "method" : "post",
     231            "method" : "delete",
    233232            "postBody" : json,
    234233            "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
  • TabularUnified trunk/src/json/json_tmcl_validation.lisp

    r326 r327  
    203203    (let ((topic-types
    204204           (loop for role in (player-in-roles topic-instance :revision revision)
    205               when (eq instance (instance-of role :revision revision))
     205              when (and (eq instance (instance-of role :revision revision))
     206                        (parent role :revision revision))
    206207              collect (loop for other-role in
    207208                           (roles (parent role :revision revision) :revision revision)
     
    229230    (let ((topic-instances
    230231           (loop for role in (player-in-roles topic-instance :revision revision)
    231               when (eq type (instance-of role :revision revision))
     232              when (and (eql type (instance-of role :revision revision))
     233                        (parent role :revision revision))
    232234              collect (loop for other-role in (roles (parent role :revision revision)
    233235                                                     :revision revision)
     
    255257    (let ((supertypes
    256258           (loop for role in (player-in-roles topic-instance :revision revision)
    257               when (eq subtype (instance-of role :revision revision))
     259              when (and (eq subtype (instance-of role :revision revision))
     260                        (parent role :revision revision))
    258261              append (loop for other-role in (roles (parent role :revision revision)
    259262                                                    :revision revision)
     
    282285    (let ((subtypes
    283286           (loop for role in (player-in-roles topic-instance :revision revision)
    284               when (eq supertype (instance-of role :revision revision))
     287              when (and (eq supertype (instance-of role :revision revision))
     288                        (parent role :revision revision))
    285289              append (loop for other-role in (roles (parent role :revision revision)
    286290                                                    :revision revision)
     
    319323          (current-valid-subtypes (append valid-subtypes (list topic-instance))))
    320324      (loop for role in (player-in-roles topic-instance :revision revision)
    321          when (and (eq supertype (instance-of role :revision revision))
     325         when (and (parent role :revision revision)
     326                   (eq supertype (instance-of role :revision revision))
    322327                   (eq supertype-subtype
    323328                       (instance-of (parent role :revision revision)
     
    358363               append (loop for role in (player-in-roles subtype-of-this
    359364                                                         :revision revision)
    360                          when (and (eq type (instance-of role :revision revision))
     365                         when (and (parent role :revision revision)
     366                                   (eq type (instance-of role :revision revision))
    361367                                   (eq type-instance
    362368                                       (instance-of (parent role :revision revision)
  • TabularUnified trunk/src/model/datamodel.lisp

    r325 r327  
    27712771  (let ((owner (parent construct :revision 0)))
    27722772    (when owner
     2773      ;(private-delete-player construct (player construct :revision revision)
     2774      ;:revision revision)
    27732775      (private-delete-role owner construct :revision revision))))
    27742776
  • TabularUnified trunk/src/rest_interface/set-up-json-interface.lisp

    r326 r327  
    388388  (declare (ignorable param)) ;param is currently not used
    389389  (let ((http-method (hunchentoot:request-method*)))
    390     (if (eq http-method :DELETE)
     390    (if (or (eq http-method :DELETE)
     391            (eq http-method :Post)) ;not nice - but the current ui-library can't send http-delete messages
    391392        (let ((external-format (flexi-streams:make-external-format :UTF-8 :eol-style :LF)))
    392393          (let ((json-data (hunchentoot:raw-post-data :external-format external-format :force-text t)))
Note: See TracChangeset for help on using the changeset viewer.