[isidorus-cvs] r327 - in trunk/src: ajax/javascripts json model rest_interface
Lukas Giessmann
lgiessmann at common-lisp.net
Thu Oct 14 16:07:24 UTC 2010
Author: lgiessmann
Date: Thu Oct 14 12:07:24 2010
New Revision: 327
Log:
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
Modified:
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/requests.js
trunk/src/json/json_tmcl_validation.lisp
trunk/src/model/datamodel.lisp
trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Oct 14 12:07:24 2010
@@ -4355,58 +4355,69 @@
if(type !== "Occurrence" && type !== "Name" && type !== "Variant"
&& type !== "Topic" && type !== "Association"){
throw "From makeRemoveObject(): type must be: \"Occurrence\" || \"Name\" " +
- "|| \"Variant\" || \"Topic\" || \"Association\" but is " + type;
+ "|| \"Topic\" but is " + type;
}
if (!objectToDelete){
throw "From makeRemoveObject(): objectToDelete must be set";
}
- var parentTopic = "null";
- if(type === "Occurrence" || type === "Name"){
- var psiFrame = objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode.select("tr." + CLASSES.subjectIdentifierFrame())[0];
+ // --- Returns a JSON-object that corresponds to a topicStub
+ function makeJsonTopicStub(topicFrame){
+ var topPSIs = "null";
+ var psiFrame = topicFrame.select("tr." + CLASSES.subjectIdentifierFrame())[0];
var psiFields = psiFrame.select("input");
- for(i = 0; psiFields && i !== psiFields.length; ++i){
+ for(var i = 0; psiFields && i !== psiFields.length; ++i){
var psiValue = psiFields[i].value;
if(psiValue.strip().length !== 0){
- parentTopic = psiValue.strip().toJSON();
+ topPSIs = new Array(psiValue.strip()).toJSON();
break;
}
}
- }
-
- var topics = "null";
- if (type === "Topic"){
- var psiFrame = objectToDelete.getFrame().select("tr." + CLASSES.subjectIdentifierFrame())[0];
- var psiFields = psiFrame.select("input");
- for(i = 0; psiFields && i !== psiFields.length; ++i){
- var psiValue = psiFields[i].value;
- if(psiValue.strip().length !== 0){
- topics = new Array(psiValue.strip()).toJSON();
+ var topIIs = "null";
+ var iiFrame = topicFrame.select("tr." + CLASSES.itemIdentityFrame())[0];
+ var iiFields = iiFrame.select("input");
+ for(var i = 0; iiFields && i !== iiFields.length; ++i){
+ var iiValue = iiFields[i].value;
+ if(iiValue.strip().length !== 0){
+ topIIs = new Array(iiValue.strip()).toJSON();
break;
}
}
+ var topSLs = "null";
+ var slFrame = topicFrame.select("tr." + CLASSES.subjectLocatorFrame())[0];
+ var slFields = slFrame.select("input");
+ for(var i = 0; slFields && i !== slFields.length; ++i){
+ var slValue = slFields[i].value;
+ if(slValue.strip().length !== 0){
+ topSLs = new Array(slValue.strip()).toJSON();
+ break;
+ }
+ }
+ return "{\"id\":\"null\",\"itemIdentities\":" + topIIs +
+ ",\"subjectLocators\":" + topSLs + ",\"subjectIdentifiers\":" + topPSIs +
+ ",\"instanceOfs\":\"null\",\"names\":\"null\",\"occurrences\":\"null\"}";
}
- var deletedObjects = null;
- if(type === "Topic"){ deletedObjects = topics; }
- else { deletedObjects = "[" + objectToDelete.toJSON() + "]"; }
+ var delMessage = "null";
- var jsonData = "{\"type\":\"" + type + "\"," +
- "\"topics\":" + topics + "," +
- "\"associations\":" + "null" + "," +
- "\"parentTopic\":" + parentTopic + "," +
- "\"parentName\":" + "null" + "," +
- "\"names\":" + (type === "Name" ? deletedObjects : "null") + "," +
- "\"variants\":" + "null" + "," +
- "\"occurrences\":" + (type === "Occurrence" ? deletedObjects : "null") + "," +
- "\"parentAssociation\":" + "null" + "," +
- "\"roles\":" + "null" + "}";
+ switch(type){
+ case "Topic":
+ delMessage = "{\"type\":\"Topic\",\"delete\":" + makeJsonTopicStub(objectToDelete.getFrame()) + "}";
+ break;
+ case "Name":
+ case "Occurrence":
+ delMessage = "{\"type\":\"" + type + "\",\"parent\":" +
+ makeJsonTopicStub(objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode) +
+ ",\"delete\":" + objectToDelete.toJSON() + "}";
+ break;
+ }
- commitDeletedObject(jsonData, function(xhr){
+ commitDeletedObject(delMessage, function(xhr){
alert("Objected deleted");
if(type === "Topic"){
$(CLASSES.subPage()).update();
- makeHome();
+ setNaviClasses($(PAGES.home));
+ makePage(PAGES.home, "");
}
else if (type === "Occurrence" || type === "Name"){
if(objectToDelete.__owner__.__frames__.length > objectToDelete.__max__
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Thu Oct 14 12:07:24 2010
@@ -219,7 +219,7 @@
}
-// --- Sends a POST-Message to the server. The sent message enables the server
+// --- Sends a DELETE-Message to the server. The sent message enables the server
// --- to find the spcified object and mark it as deleted
function commitDeletedObject(json, onSuccessHandler, onFailureHandler)
{
@@ -227,9 +227,8 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
-
new Ajax.Request(MARK_AS_DELETED_URL, {
- "method" : "post",
+ "method" : "delete",
"postBody" : json,
"onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
"onFailure" : createXHRHandler(onFailure, timeFun)});
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Thu Oct 14 12:07:24 2010
@@ -202,7 +202,8 @@
(type (get-item-by-psi *type-psi* :revision revision)))
(let ((topic-types
(loop for role in (player-in-roles topic-instance :revision revision)
- when (eq instance (instance-of role :revision revision))
+ when (and (eq instance (instance-of role :revision revision))
+ (parent role :revision revision))
collect (loop for other-role in
(roles (parent role :revision revision) :revision revision)
when (and (not (eq role other-role))
@@ -228,7 +229,8 @@
(type (get-item-by-psi *type-psi* :revision revision)))
(let ((topic-instances
(loop for role in (player-in-roles topic-instance :revision revision)
- when (eq type (instance-of role :revision revision))
+ when (and (eql type (instance-of role :revision revision))
+ (parent role :revision revision))
collect (loop for other-role in (roles (parent role :revision revision)
:revision revision)
when (and (not (eq role other-role))
@@ -254,7 +256,8 @@
(subtype (get-item-by-psi *subtype-psi* :revision revision)))
(let ((supertypes
(loop for role in (player-in-roles topic-instance :revision revision)
- when (eq subtype (instance-of role :revision revision))
+ when (and (eq subtype (instance-of role :revision revision))
+ (parent role :revision revision))
append (loop for other-role in (roles (parent role :revision revision)
:revision revision)
when (and (not (eq role other-role))
@@ -281,7 +284,8 @@
(subtype (get-item-by-psi *subtype-psi* :revision revision)))
(let ((subtypes
(loop for role in (player-in-roles topic-instance :revision revision)
- when (eq supertype (instance-of role :revision revision))
+ when (and (eq supertype (instance-of role :revision revision))
+ (parent role :revision revision))
append (loop for other-role in (roles (parent role :revision revision)
:revision revision)
when (and (not (eq role other-role))
@@ -318,7 +322,8 @@
:revision revision))
(current-valid-subtypes (append valid-subtypes (list topic-instance))))
(loop for role in (player-in-roles topic-instance :revision revision)
- when (and (eq supertype (instance-of role :revision revision))
+ when (and (parent role :revision revision)
+ (eq supertype (instance-of role :revision revision))
(eq supertype-subtype
(instance-of (parent role :revision revision)
:revision revision)))
@@ -357,7 +362,8 @@
(loop for subtype-of-this in all-subtypes-of-this
append (loop for role in (player-in-roles subtype-of-this
:revision revision)
- when (and (eq type (instance-of role :revision revision))
+ when (and (parent role :revision revision)
+ (eq type (instance-of role :revision revision))
(eq type-instance
(instance-of (parent role :revision revision)
:revision revision)))
Modified: trunk/src/model/datamodel.lisp
==============================================================================
--- trunk/src/model/datamodel.lisp (original)
+++ trunk/src/model/datamodel.lisp Thu Oct 14 12:07:24 2010
@@ -2770,6 +2770,8 @@
(declare (ignorable source-locator))
(let ((owner (parent construct :revision 0)))
(when owner
+ ;(private-delete-player construct (player construct :revision revision)
+ ;:revision revision)
(private-delete-role owner construct :revision revision))))
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Thu Oct 14 12:07:24 2010
@@ -387,7 +387,8 @@
"Marks the corresponding elem as deleted."
(declare (ignorable param)) ;param is currently not used
(let ((http-method (hunchentoot:request-method*)))
- (if (eq http-method :DELETE)
+ (if (or (eq http-method :DELETE)
+ (eq http-method :Post)) ;not nice - but the current ui-library can't send http-delete messages
(let ((external-format (flexi-streams:make-external-format :UTF-8 :eol-style :LF)))
(let ((json-data (hunchentoot:raw-post-data :external-format external-format :force-text t)))
(handler-case
More information about the Isidorus-cvs
mailing list