[isidorus-cvs] r639 - trunk/src/ajax/javascripts

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Jul 18 14:08:10 UTC 2011


Author: lgiessmann
Date: Mon Jul 18 07:08:08 2011
New Revision: 639

Log:
fixed ticket #114 => added a delete button and functionality for associations to the UI

Modified:
   trunk/src/ajax/javascripts/constants.js
   trunk/src/ajax/javascripts/datamodel.js

Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js	Mon Jul 18 05:08:51 2011	(r638)
+++ trunk/src/ajax/javascripts/constants.js	Mon Jul 18 07:08:08 2011	(r639)
@@ -24,7 +24,7 @@
 var SUMMARY_URL = HOST_PREF + "json/summary";
 var MARK_AS_DELETED_URL = HOST_PREF + "mark-as-deleted";
 var TM_OVERVIEW = HOST_PREF + "json/tmcl/overview/";
-var TIMEOUT = 30000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
+var TIMEOUT = 60000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
 
 
 
@@ -94,6 +94,7 @@
 	       "topicPsis" : function(){ return "topicPsis"; },
                "removeLink" : function(){ return "removeLink"; },
 	       "removeNameRow" : function(){ return "removeOccurrenceRow"; },
+	       "removeAssociationRow" : function(){ return "removeAssociationRow"; },
 	       "removeOccurrenceRow" : function(){ return "removeNameRow"; },
 	       "removeTopicRow" : function(){ return "removeTopicRow"; }
 	      };

Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js	Mon Jul 18 05:08:51 2011	(r638)
+++ trunk/src/ajax/javascripts/datamodel.js	Mon Jul 18 07:08:08 2011	(r639)
@@ -433,6 +433,18 @@
 						  for(var i = 0; i !== values.length; ++i)values[i] = encodeURI(values[i]);
 						  return values;
 					      },
+					      "reset" : function(){
+						 if(!this.__container__.__frames__) return;
+						 
+						 for(var i = 0; i != this.__container__.__frames__.length; ++i)
+						     this.__container__.__frames__[i].remove();
+
+						 while(this.__container__.__frames__.length != 0)this.__container__.__frames__.shift();
+
+						 new TextrowC("", ".*", this.__container__, 1, -1, null);
+						 this.__error__.insert({"before" : this.__container__.__frames__[0].getFrame()});
+						 
+					      },
 					      "toJSON" : function(unique, removeNull){
 						  var content = this.getContent(unique, removeNull);
 						  return content.length === 0 ? "null" : content.toJSON();
@@ -3678,6 +3690,13 @@
 							 });
 						     }
 						     setDblClickHandler(this);
+
+						     // --- mark-as-deleted
+						     if(contents){
+							 var myself = this;
+							 this.__table__.insert({"bottom" : makeRemoveLink(function(event){
+									 makeRemoveObject("Association", myself);
+								     }, "delete Association")});}
 						 }
 					         catch(err){
 						     alert("From AssociationC(): " + err);
@@ -4359,6 +4378,7 @@
       case "delete Occurrence" : trClass = CLASSES.removeOccurrenceRow(); break;
       case "delete Topic" : trClass = CLASSES.removeTopicRow(); break;
       case "delete Name" : trClass = CLASSES.removeNameRow(); break;
+      case "delete Association" : trClass = CLASSES.removeAssociationRow(); break;
     }
 
     var tr = new Element("tr", {"class" : trClass}).insert(new Element("td", {"colspan" : 3}).insert(link));
@@ -4372,7 +4392,7 @@
     if(type !== "Occurrence" && type !== "Name" && type !== "Variant"
        && type !== "Topic" && type !== "Association"){
 	throw "From makeRemoveObject(): type must be: \"Occurrence\" || \"Name\" " +
-	    "|| \"Topic\" but is " + type;
+	    "|| \"Topic\" || \"Association\" but is " + type;
     }
     if (!objectToDelete){
 	throw "From makeRemoveObject(): objectToDelete must be set";
@@ -4418,15 +4438,18 @@
     var delMessage = "null";
 
     switch(type){
-    case "Topic":
+      case "Topic":
 	delMessage = "{\"type\":\"Topic\",\"delete\":" + makeJsonTopicStub(objectToDelete.getFrame()) + "}";
 	break;
-    case "Name":
-    case "Occurrence":
+      case "Name":
+      case "Occurrence":
 	delMessage = "{\"type\":\"" + type + "\",\"parent\":" +
-                     makeJsonTopicStub(objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode) +
-                     ",\"delete\":" + objectToDelete.toJSON() + "}";
+	makeJsonTopicStub(objectToDelete.getFrame().parentNode.parentNode.parentNode.parentNode) +
+	",\"delete\":" + objectToDelete.toJSON() + "}";
         break;
+      case "Association":
+	  delMessage = "{\"type\":\"Association\",\"delete\":" + objectToDelete.toJSON() + "}";
+	break;
     }
  
     commitDeletedObject(delMessage, function(xhr){
@@ -4434,8 +4457,14 @@
 		$(CLASSES.subPage()).update();
 		setNaviClasses($(PAGES.home));
 		makePage(PAGES.home, "");
-	    }
-	    else if (type === "Occurrence" || type === "Name"){
+	    }else if(type === "Association"){
+		if(objectToDelete.__owner__.__frames__.length === 1){
+		    objectToDelete.__itemIdentity__.reset();
+		    objectToDelete.disable();
+		}else {
+		    objectToDelete.remove();
+		}
+	    }else if (type === "Occurrence" || type === "Name"){
 		if(objectToDelete.__owner__.__frames__.length >= 1 &&
 		   objectToDelete.__owner__.__frames__.length > objectToDelete.__min__){
 		    objectToDelete.remove();
@@ -4458,6 +4487,6 @@
 		    ii.remove();
 		}
 	    }
-	    alert("Objected deleted");
+	    alert("Object deleted");
 	});   
 }
\ No newline at end of file




More information about the Isidorus-cvs mailing list