Changeset 427 for trunk/src/ajax
- Timestamp:
- 04/21/11 09:56:59 (14 years ago)
- Location:
- trunk/src/ajax/javascripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/ajax/javascripts/create.js ¶
r328 r427 131 131 return; 132 132 } 133 133 134 134 135 // --- if the validation succeeded the fragment will be sent to the server 135 136 var tPsis = topic.getContent().subjectIdentifiers; … … 151 152 } 152 153 154 153 155 function onSuccessHandler(topicStubs){ 154 156 var tsStr = "null"; … … 161 163 tsStr += "]"; 162 164 } 165 163 166 var jTopic = "\"topic\":" + topic.toJSON(); 164 167 var jTopicStubs = "\"topicStubs\":" + tsStr; … … 166 169 var jTmId = "\"tmIds\":" + tmId.toJSON(); 167 170 var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}"; 171 168 172 commitFragment(json, function(xhr){ alert("The fragment was committed succesfully!"); }, null); 169 173 } 170 174 171 175 function onErrorHandler(){ 172 176 // --- currently there is not needed a special handling for errors 173 // --- occurr edduring this operation177 // --- occurring during this operation 174 178 } 175 179 getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler); -
TabularUnified trunk/src/ajax/javascripts/datamodel.js ¶
r354 r427 550 550 "toJSON" : function(unique, removeNull){ 551 551 var content = this.getContent(unique, removeNull); 552 return content.length === 0 ? "null" : content.toJSON(); 552 if(!content || content.length === 0) return "null"; 553 return content.toJSON(); 553 554 }, 554 555 "isValid" : function(){ … … 2666 2667 } 2667 2668 catch(err){ 2668 2669 2669 alert("From RoleContainerC(): " + err); 2670 } 2670 2671 }, 2671 2672 "__orderContentsToRoles__" : function(contents, roleContainer, usedContents, alreadyUsedRoles){ … … 2921 2922 var usedContents = new Array(); 2922 2923 var alreadyUsedRoles = new Array(); 2923 2924 2924 2925 // --- searches for associaitonrole-constraints and roleplayer-constraints 2925 2926 var ret = this.__orderContentsToRoles__(cContents, this.__arContainer__.__frames__, usedContents, alreadyUsedRoles); … … 2927 2928 usedContents = ret.usedContents; 2928 2929 alreadyUsedRoles = ret.alreadyUsedRoles; 2929 2930 2930 2931 // --- searches for otherrole-constraints 2931 2932 ret = this.__orderContentsToRoles__(cContents, this.__orContainer__.__frames__, usedContents, alreadyUsedRoles); … … 2933 2934 usedContents = ret.usedContents; 2934 2935 alreadyUsedRoles = ret.alreadyUsedRoles; 2935 2936 2936 2937 // --- creates additional roles (associationrole-constraints) 2937 2938 ret = this.__createAdditionalRolesFromContents__(cContents, usedContents, alreadyUsedRoles, true); … … 2939 2940 usedContents = ret.usedContents; 2940 2941 alreadyUsedRoles = ret.alreadyUsedRoles; 2941 2942 2942 2943 // --- creates additional roles (associationrole-constraints) 2943 2944 ret = this.__createAdditionalRolesFromContents__(cContents, usedContents, alreadyUsedRoles, false); … … 2945 2946 usedContents = ret.usedContents; 2946 2947 alreadyUsedRoles = ret.alreadyUsedRoles; 2947 2948 2948 2949 this.__createNewRolesFromContents__(cContents); 2949 2950 }, … … 2995 2996 var roleMinOrg = parseInt(associationRoleConstraint.cardMin); 2996 2997 for(var i = 0; i !== rolePlayerConstraints.length; ++i){ 2998 // if no player is available for a rolePlayerConstraint the constraint is ignored and no warning is thrown 2999 if(!rolePlayerConstraints[i].players || rolePlayerConstraints[i].players.length < playerMin) continue; 3000 3001 2997 3002 var playerMin = rolePlayerConstraints[i].cardMin === 0 ? 1 : parseInt(rolePlayerConstraints[i].cardMin); 2998 if(rolePlayerConstraints[i].players.length < playerMin) throw "From __makeRolesFromARC__(): not enough players(=" + rolePlayerConstraints[i].players.length + ") to reach card-min(=" + playerMin + ") of roletype\"" + roleType.flatten()[0] + "\"!";2999 3003 for(var k = 0; k !== playerMin; ++k){ 3000 3004 // --- creates a new role … … 3023 3027 // existing roles --> all roles that owns a player which is selected of those listed in the roleplayer-constraint 3024 3028 var existingRoles = this.getExistingRoles(roleType, rolePlayerConstraints[i].players, this.__arContainer__.__frames__); 3025 var availablePlayers = rolePlayerConstraints[i].players;3029 var availablePlayers = (rolePlayerConstraints[i].players ? rolePlayerConstraints[i].players : new Array()); 3026 3030 if(existingRoles.length < rolePlayerConstraints[i].cardMax && availablePlayers.length > existingRoles.length){ 3027 3031 var currentAvailablePlayers = rolePlayerConstraints[i].players; … … 3048 3052 } 3049 3053 } 3050 if(currentlyCreated === 0) throw "Not enough players to create all needed roles of the type \"" + roleType.flatten()[0] + "\"!"; 3054 3055 // not enough roles created so an association with zero roles can be made 3056 if(currentlyCreated === 0) break; 3051 3057 }; 3052 3058 this.__checkARCButtons__(currentRoles, allAvailablePlayers, associationRoleConstraint); … … 3065 3071 var cMin = orpcs[i].cardMin === 0 ? 1 : parseInt(orpcs[i].cardMin); 3066 3072 var cMinOrg = parseInt(orpcs[i].cardMin); 3067 if(!cOtherPlayers || cOtherPlayers.length < cMin) throw "from __makeRolesFromORC__(): not enough players(=" + cOtherPlayers.length + ") for roletype + \"" + cOtherRoleType.flatten()[0] + "\"!"; 3073 3074 // if there are not enough other players the constraint is ignored and no error message is thrown 3075 if(!cOtherPlayers || cOtherPlayers.length < cMin) continue; 3076 3077 3068 3078 var existingRoles = this.getExistingRoles(cOtherRoleType, cOtherPlayers, this.__orContainer__.__frames__); 3069 3079 for(var j = 0; j < cMin - existingRoles.length; ++j){ … … 3472 3482 var rpcs = this.__rolePlayerConstraints__; 3473 3483 3474 // --- checks if there exist an y constraints3484 // --- checks if there exist aniy constraints 3475 3485 if(!arcs || arcs.length === 0){ 3476 3486 this.showError("No association-constraints found for this association!"); … … 3486 3496 var allAroles = new Array(); 3487 3497 var allAroles2 = new Array(); 3488 for(var i = 0; this.__arContainer__.__frames__ && i !== this.__arContainer__.__frames__.length; ++i){ 3489 this.__arContainer__.__frames__[i].hideError(); 3490 if(this.__arContainer__.__frames__[i].isUsed() === true){ 3491 allAroles.push(this.__arContainer__.__frames__[i]); 3492 allAroles2.push(this.__arContainer__.__frames__[i]); 3498 if(this.__arContainer__ && this.__arContainer__.__frames__){ 3499 for(var i = 0; this.__arContainer__.__frames__ && i !== this.__arContainer__.__frames__.length; ++i){ 3500 this.__arContainer__.__frames__[i].hideError(); 3501 if(this.__arContainer__.__frames__[i].isUsed() === true){ 3502 allAroles.push(this.__arContainer__.__frames__[i]); 3503 allAroles2.push(this.__arContainer__.__frames__[i]); 3504 } 3493 3505 } 3494 3506 } … … 3496 3508 // --- collects all used roles depending on otherrole-constraints 3497 3509 var allOroles = new Array(); 3498 for(var i = 0; i !== this.__orContainer__.__frames__.length; ++i){ 3499 this.__orContainer__.__frames__[i].hideError(); 3500 if(this.__orContainer__.__frames__[i].isUsed() === true) 3501 allOroles.push(this.__orContainer__.__frames__[i]); 3510 if(this.__orContainer__ && this.__orContainer__.__frames__){ 3511 for(var i = 0; i !== this.__orContainer__.__frames__.length; ++i){ 3512 this.__orContainer__.__frames__[i].hideError(); 3513 if(this.__orContainer__.__frames__[i].isUsed() === true) 3514 allOroles.push(this.__orContainer__.__frames__[i]); 3515 } 3502 3516 } 3503 3517 -
TabularUnified trunk/src/ajax/javascripts/requests.js ¶
r328 r427 10 10 //+ trunk/src/ajax/javascripts/external/MIT-LICENSE.txt. 11 11 //+----------------------------------------------------------------------------- 12 13 14 // --- replaces every / character that is not prefixed by a \ character 15 function escapeSlashInJSON(jsonString){ 16 return jsonString.replace(/([^\\])\//g, '$1\\/').replace(/([^\\])\//g, '$1\\/'); 17 } 18 12 19 13 20 // --- Sets a timeout function which alerts a message. … … 209 216 new Ajax.Request(COMMIT_URL, { 210 217 "method" : "post", 211 "postBody" : json,218 "postBody" : escapeSlashInJSON(json), 212 219 "onSuccess" : createXHRHandler(onSuccessHandler, timeFun), 213 220 "onFailure" : createXHRHandler(onFailure, timeFun)}); … … 229 236 new Ajax.Request(MARK_AS_DELETED_URL, { 230 237 "method" : "delete", 231 "postBody" : json,238 "postBody" : escapeSlashInJSON(json), 232 239 "onSuccess" : createXHRHandler(onSuccessHandler, timeFun), 233 240 "onFailure" : createXHRHandler(onFailure, timeFun)}); -
TabularUnified trunk/src/ajax/javascripts/tmcl_tools.js ¶
r328 r427 164 164 165 165 for(var i = 0; i !== anyConstraints.length; ++i){ 166 if(!anyConstraints[i].players) return players; 166 167 for(var j = 0; j !== anyConstraints[i].players.length; ++j){ 167 168 players.push(anyConstraints[i].players[j])
Note: See TracChangeset
for help on using the changeset viewer.