Changeset 327
- Timestamp:
- 10/14/10 16:07:24 (15 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/ajax/javascripts/datamodel.js ¶
r283 r327 4356 4356 && type !== "Topic" && type !== "Association"){ 4357 4357 throw "From makeRemoveObject(): type must be: \"Occurrence\" || \"Name\" " + 4358 "|| \" Variant\" || \"Topic\" || \"Association\" but is " + type;4358 "|| \"Topic\" but is " + type; 4359 4359 } 4360 4360 if (!objectToDelete){ … … 4362 4362 } 4363 4363 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]; 4367 4368 var psiFields = psiFrame.select("input"); 4368 for( i = 0; psiFields && i !== psiFields.length; ++i){4369 for(var i = 0; psiFields && i !== psiFields.length; ++i){ 4369 4370 var psiValue = psiFields[i].value; 4370 4371 if(psiValue.strip().length !== 0){ 4371 parentTopic = psiValue.strip().toJSON();4372 topPSIs = new Array(psiValue.strip()).toJSON(); 4372 4373 break; 4373 4374 } 4374 4375 } 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(); 4385 4383 break; 4386 4384 } 4387 4385 } 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\"}"; 4388 4399 } 4389 4400 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 } 4404 4414 4405 commitDeletedObject( jsonData, function(xhr){4415 commitDeletedObject(delMessage, function(xhr){ 4406 4416 alert("Objected deleted"); 4407 4417 if(type === "Topic"){ 4408 4418 $(CLASSES.subPage()).update(); 4409 makeHome(); 4419 setNaviClasses($(PAGES.home)); 4420 makePage(PAGES.home, ""); 4410 4421 } 4411 4422 else if (type === "Occurrence" || type === "Name"){ -
TabularUnified trunk/src/ajax/javascripts/requests.js ¶
r279 r327 220 220 221 221 222 // --- Sends a POST-Message to the server. The sent message enables the server222 // --- Sends a DELETE-Message to the server. The sent message enables the server 223 223 // --- to find the spcified object and mark it as deleted 224 224 function commitDeletedObject(json, onSuccessHandler, onFailureHandler) … … 228 228 var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler; 229 229 var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL); 230 231 230 new Ajax.Request(MARK_AS_DELETED_URL, { 232 "method" : " post",231 "method" : "delete", 233 232 "postBody" : json, 234 233 "onSuccess" : createXHRHandler(onSuccessHandler, timeFun), -
TabularUnified trunk/src/json/json_tmcl_validation.lisp ¶
r326 r327 203 203 (let ((topic-types 204 204 (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)) 206 207 collect (loop for other-role in 207 208 (roles (parent role :revision revision) :revision revision) … … 229 230 (let ((topic-instances 230 231 (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)) 232 234 collect (loop for other-role in (roles (parent role :revision revision) 233 235 :revision revision) … … 255 257 (let ((supertypes 256 258 (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)) 258 261 append (loop for other-role in (roles (parent role :revision revision) 259 262 :revision revision) … … 282 285 (let ((subtypes 283 286 (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)) 285 289 append (loop for other-role in (roles (parent role :revision revision) 286 290 :revision revision) … … 319 323 (current-valid-subtypes (append valid-subtypes (list topic-instance)))) 320 324 (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)) 322 327 (eq supertype-subtype 323 328 (instance-of (parent role :revision revision) … … 358 363 append (loop for role in (player-in-roles subtype-of-this 359 364 :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)) 361 367 (eq type-instance 362 368 (instance-of (parent role :revision revision) -
TabularUnified trunk/src/model/datamodel.lisp ¶
r325 r327 2771 2771 (let ((owner (parent construct :revision 0))) 2772 2772 (when owner 2773 ;(private-delete-player construct (player construct :revision revision) 2774 ;:revision revision) 2773 2775 (private-delete-role owner construct :revision revision)))) 2774 2776 -
TabularUnified trunk/src/rest_interface/set-up-json-interface.lisp ¶
r326 r327 388 388 (declare (ignorable param)) ;param is currently not used 389 389 (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 391 392 (let ((external-format (flexi-streams:make-external-format :UTF-8 :eol-style :LF))) 392 393 (let ((json-data (hunchentoot:raw-post-data :external-format external-format :force-text t)))
Note: See TracChangeset
for help on using the changeset viewer.