Author: lgiessmann Date: Thu Jun 25 14:16:30 2009 New Revision: 68
Log: ajax-client: fixed a general bug with optional occurrences, currently they are not disabled or minimized, when they own any content; fixed a bug with opera and textarea-values, currently there is used the method setValue instead of using update(<value>) - so in the browsers firefox, opera, safari there are no problems - therefore IE makes a lot of trouble!
Modified: trunk/src/ajax/javascripts/constants.js trunk/src/ajax/javascripts/datamodel.js trunk/src/json/json_tmcl_validation.lisp trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/ajax/javascripts/constants.js ============================================================================== --- trunk/src/ajax/javascripts/constants.js (original) +++ trunk/src/ajax/javascripts/constants.js Thu Jun 25 14:16:30 2009 @@ -12,7 +12,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE -var HOST_PREF = "http://localhost:8000/"; +var HOST_PREF = "192.168.178.21/"; //"http://localhost:8000/"; var GET_PREFIX = HOST_PREF + "json/get/"; var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/"; var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
Modified: trunk/src/ajax/javascripts/datamodel.js ============================================================================== --- trunk/src/ajax/javascripts/datamodel.js (original) +++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 14:16:30 2009 @@ -1913,9 +1913,11 @@ var _content = null; if(_contents && _contents.length > k) _content = _contents[k]; var occurrence = new OccurrenceC(_content, constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler); - if(min === 0) occurrence.disable(); + if(min === 0 && !_content){ + occurrence.disable(); + occurrence.minimize(); + } this.__error__.insert({"before" : occurrence.getFrame()}); - if(min === 0)occurrence.minimize(); } } } @@ -2199,11 +2201,19 @@ else { this.__topicid__.__frames__[0].hideError(); } + if(this.__subjectIdentifier__.getContent().length === 0){ + ret = false; + this.showError("The topic must contain at least one SubjectIdentifier!<br/>If it is not possible to insert one - please create a subjectidentifier-constraint for this topic (-type)!"); + } + else if(ret === true){ + this.hideError(); + }
if(this.__subjectLocator__.isValid() === false) ret = false; if(this.__subjectIdentifier__.isValid() === false) ret = false; if(this.__name__.isValid() === false) ret = false; if(this.__occurrence__.isValid() === false) ret = false; + return ret; }, "getReferencedTopics" : function(){ @@ -2488,8 +2498,8 @@ var RoleContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints, parent){ $super(); this.__frame__.writeAttribute({"class" : CLASSES.roleContainer()}); - this.__arContainer__ = new Object(); - this.__orContainer__ = new Object(); + this.__arContainer__ = new Object(); this.__arContainer__.__frames__ = new Array(); + this.__orContainer__ = new Object(); this.__orContainer__.__frames__ = new Array(); this.__associationRoleConstraints__ = associationRoleConstraints; this.__otherRoleConstraints__ = otherRoleConstraints; this.__rolePlayerConstraints__ = rolePlayerConstraints; @@ -2567,7 +2577,7 @@ return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles}; }, "__createAdditionalRolesFromContents__" : function(contents,usedContents, alreadyUsedRoles, isARC){ - var roleContainer = this.__orContainer__.__frames__; + var roleContainer = this.__orContainer__.__frames__; if(isARC === true) roleContainer = this.__arContainer__.__frames__; if(roleContainer && roleContainer.length !== 0){ @@ -3972,8 +3982,7 @@ this.__datatype__.__frames__[0].remove(); this.__datatype__ = new Object(); }catch(err){} - - myself.__value__ = new Element("textarea", {"rows" : 3}).update(value); + myself.__value__ = new Element("textarea", {"rows" : 3}).setValue(value); myself.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Resource Value", myself.__value__)}); if(cssTitle && cssTitle.length !== 0) myself.__value__.writeAttribute({"title" : cssTitle});
Modified: trunk/src/json/json_tmcl_validation.lisp ============================================================================== --- trunk/src/json/json_tmcl_validation.lisp (original) +++ trunk/src/json/json_tmcl_validation.lisp Thu Jun 25 14:16:30 2009 @@ -121,7 +121,7 @@ (not akos-are-topictype) topictype-constraint) ;(return-from topictype-p nil)) - (error "~a is not a valid -- type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype))))) + (error "~a is not a valid type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype))))) (loop for isa-of-this in isas-of-this when (and (not (find isa-of-this current-checked-topics :test #'eq)) @@ -269,4 +269,26 @@ (topictype-of-p x nil) x) (condition () nil))) - all-subtypes-of-all-instances))))))) \ No newline at end of file + all-subtypes-of-all-instances))))))) + + +(defun return-all-tmcl-types () + "Returns all topics that are valid tmcl-types" + (let ((all-topics + (elephant:get-instances-by-class 'd:TopicC)) + (topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*)) + (topictype-constraint (get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*))) + (let ((all-types + (remove-if #'null + (map 'list #'(lambda(x) + (handler-case (progn + (json-tmcl::topictype-p x topictype topictype-constraint) + x) + (condition () nil))) all-topics)))) + (let ((not-abstract-types + (remove-if #'null + (map 'list #'(lambda(x) + (unless (json-tmcl:abstract-p x) + x)) + all-types)))) + not-abstract-types)))) \ No newline at end of file
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 Jun 25 14:16:30 2009 @@ -107,28 +107,12 @@ "Returns all topics that are valid types -> so they have to be valid to the topictype-constraint (if it exists) and the can't be abstract." (declare (ignorable param)) - (handler-case (let ((all-topics - (elephant:get-instances-by-class 'd:TopicC)) - (topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*)) - (topictype-constraint (get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*))) - (let ((all-types - (remove-if #'null - (map 'list #'(lambda(x) - (handler-case (progn - (json-tmcl::topictype-p x topictype topictype-constraint) - x) - (condition () nil))) all-topics)))) - (let ((not-abstract-types - (remove-if #'null - (map 'list #'(lambda(x) - (unless (json-tmcl:abstract-p x) - x)) - all-types)))) - (setf (hunchentoot:content-type*) "application/json") ;RFC 4627 - (json:encode-json-to-string - (map 'list #'(lambda(y) - (map 'list #'uri y)) - (map 'list #'psis not-abstract-types)))))) + (handler-case (let ((topic-types (json-tmcl::return-all-tmcl-types))) + (setf (hunchentoot:content-type*) "application/json") ;RFC 4627 + (json:encode-json-to-string + (map 'list #'(lambda(y) + (map 'list #'uri y)) + (map 'list #'psis topic-types)))) (condition (err) (progn (setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+) (setf (hunchentoot:content-type*) "text")