From a8c4af2921433c9671e1e6044ccaa3262ba4c2e1 Mon Sep 17 00:00:00 2001 From: scottashton Date: Thu, 26 Jun 2014 09:07:12 +0200 Subject: [PATCH] graph creation works --- .../js/templates/edgeDefinitionTable.ejs | 10 ++-- .../frontend/js/views/graphManagementView.js | 59 ++++++++++++++----- .../aardvark/frontend/js/views/modalView.js | 11 ++-- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/templates/edgeDefinitionTable.ejs b/js/apps/system/aardvark/frontend/js/templates/edgeDefinitionTable.ejs index 6d1e874313..664720ad33 100644 --- a/js/apps/system/aardvark/frontend/js/templates/edgeDefinitionTable.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/edgeDefinitionTable.ejs @@ -2,7 +2,7 @@ Edge definitions*: -
+ @@ -10,20 +10,20 @@ - + fromCollections*: -
+ - + toCollections*: -
+ diff --git a/js/apps/system/aardvark/frontend/js/views/graphManagementView.js b/js/apps/system/aardvark/frontend/js/views/graphManagementView.js index c47043dd4e..fbefc9a625 100644 --- a/js/apps/system/aardvark/frontend/js/views/graphManagementView.js +++ b/js/apps/system/aardvark/frontend/js/views/graphManagementView.js @@ -165,12 +165,15 @@ collection, from, to; - - collection = $('#newEdgeDefinitions1').val(); - //collection = $("tr[id*='newEdgeDefinitions'").val(); - if (collection !== "") { - from = _.pluck($('#s2id_fromCollections1').select2("data"), "text"); - to = _.pluck($('#s2id_toCollections1').select2("data"), "text"); + for (var i = 0 ; i < $("tr[id*='newEdgeDefinitions']").length ; i++) { + if (!$('#s2id_fromCollections' + i) || !_.pluck($('#s2id_fromCollections' + i).select2("data"), "text") || + !$('#newEdgeDefinitions' + i) || !$('#newEdgeDefinitions' + i).val() || + !$('#s2id_toCollections' + i) || !_.pluck($('#s2id_toCollections' + i).select2("data"), "text") ) { + continue; + } + from = _.pluck($('#s2id_fromCollections' + i).select2("data"), "text"); + to = _.pluck($('#s2id_toCollections' + i).select2("data"), "text"); + collection = $('#newEdgeDefinitions' + i).val(); edgeDefinitions.push( { collection: collection, @@ -178,7 +181,7 @@ to: to } ); - } + }; if (!name) { arangoHelper.arangoNotification( @@ -243,9 +246,8 @@ ) ); buttons.push( - window.modalView.createSuccessButton("Create", this.createNewGraph.bind(this)) + window.modalView.createSuccessButton("Create", this.createNewGraph2.bind(this)) ); - window.modalView.show("modalTable.ejs", "Add new Graph", buttons, tableContent); }, @@ -339,6 +341,27 @@ number: this.counter }) ); + $('#newEdgeDefinitions'+this.counter).select2({ + tags: [], + showSearchBox: false, + minimumResultsForSearch: -1, + width: "336px", + maximumSelectionSize: 1 + }); + $('#newfromCollections'+this.counter).select2({ + tags: [], + showSearchBox: false, + minimumResultsForSearch: -1, + width: "336px", + maximumSelectionSize: 10 + }); + $('#newtoCollections'+this.counter).select2({ + tags: [], + showSearchBox: false, + minimumResultsForSearch: -1, + width: "336px", + maximumSelectionSize: 10 + }); window.modalView.undelegateEvents(); window.modalView.delegateEvents(this.events); return; @@ -377,18 +400,21 @@ "Edge definitions", true, false, - true + true, + 1 ) ); - tableContent.push( window.modalView.createSelect2Entry( "fromCollections0", "fromCollections", "", "The collection that contain the start vertices of the relation.", - "", - true + "fromCollections", + true, + false, + false, + 10 ) ); tableContent.push( @@ -397,8 +423,11 @@ "toCollections", "", "The collection that contain the end vertices of the relation.", - "", - true + "toCollections", + true, + false, + false, + 10 ) ); diff --git a/js/apps/system/aardvark/frontend/js/views/modalView.js b/js/apps/system/aardvark/frontend/js/views/modalView.js index 7e6319dd75..f993518f93 100644 --- a/js/apps/system/aardvark/frontend/js/views/modalView.js +++ b/js/apps/system/aardvark/frontend/js/views/modalView.js @@ -14,7 +14,7 @@ }; var createTextStub = function(type, label, value, info, placeholder, mandatory, regexp, - addDelete, addAdd) { + addDelete, addAdd, maxEntrySize) { var obj = { type: type, label: label @@ -37,6 +37,9 @@ if (addAdd !== undefined) { obj.addAdd = addAdd; } + if (maxEntrySize !== undefined) { + obj.maxEntrySize = maxEntrySize; + } if (regexp){ // returns true if the string contains the match obj.validateInput = function(el){ @@ -183,9 +186,9 @@ }, createSelect2Entry: function( - id, label, value, info, placeholder, mandatory, addDelete, addAdd) { + id, label, value, info, placeholder, mandatory, addDelete, addAdd, maxEntrySize) { var obj = createTextStub(this.tables.SELECT2, label, value, info, placeholder, - mandatory, undefined, addDelete, addAdd); + mandatory, undefined, addDelete, addAdd, maxEntrySize); obj.id = id; return obj; }, @@ -283,7 +286,7 @@ showSearchBox: false, minimumResultsForSearch: -1, width: "336px", - maximumSelectionSize: 8 + maximumSelectionSize: r.maxEntrySize ? r.maxEntrySize : 8 }); } });//handle select2