annotate query_builder/querybuild.html @ 34:4bbb832c53ac

Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
author arussell
date Sat, 19 Dec 2015 23:25:23 -0500
parents acc60a20582c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
1 <!DOCTYPE html>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
2 <html>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
3 <head>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
4 <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
5 <title>Query Builder</title>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
6 <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
7 <link rel="stylesheet" href="select2-4.0.1/dist/css/select2.min.css">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
8
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
9 <script type="text/javascript" src="js/d3.min.js"></script>
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
10 <script type="text/javascript" src="js/underscore-min.js"></script>
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
11 <script type="text/javascript" src="select2-4.0.1/vendor/jquery-2.1.0.js"></script>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
12 <script type="text/javascript" src="select2-4.0.1/dist/js/select2.full.min.js"></script>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
13
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
14
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
15
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
16 </head>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
17 <body style="background:none;">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
18 <div role="navigation" class="navbar navbar-default navbar-static-top">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
19 <div class="container">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
20 <div class="row">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
21 <div class="col-sm-6 col-md-6">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
22 <ul class="nav navbar-nav">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
23 </ul>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
24 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
25 <div class="navbar-header col-sm-6 col-md-6" style="height: auto;">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
26 <div class="col-md-6">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
27 <div class="navbar-brand">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
28 <div class="brand">ISMI Query Builder</div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
29 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
30 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
31 <div class="col-md-offset-6">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
32 <div class="logo-well" style="height: 60%; width: 60%;">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
33 <a href="//neo4j.com/developer-resources">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
34 <img src="//neo4j-contrib.github.io/developer-resources/language-guides/assets/img/logo-white.svg" alt="Neo4j World's Leading Graph Database" id="logo" style="max-height: 50%; width: 50%">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
35 </a>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
36 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
37 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
38 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
39 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
40 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
41 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
42 <div class="container">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
43 <div class="row" style="width: 95%">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
44 <div class="col-lg">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
45 <div class="panel panel-default">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
46 <div class="panel-heading" id="title">Query Builder</div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
47
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
48 <section>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
49 <div class="s2-example">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
50 <div id="filters">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
51 <div class="row" id="startrow" style="margin-top: 15px">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
52 <div class="col-sm-4 col-md-4" id="select-col1">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
53 <select class="selected-object form-control">
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
54 <option selected>Object type : </option>
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
55 </select>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
56 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
57 <div class="col-sm-4 col-md-4" id="select-col2">
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
58 <select class="select-object1 form-control" id="startselect">
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
59 <option disable selected></option>
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
60 <option>TEXT</option>
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
61 <option>WITNESS</option>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
62 <option>PERSON</option>
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
63 <option>CODEX</option>
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
64 <option>PLACE</option>
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
65 <option>REPOSITORY</option>
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
66 <option>COLLECTION</option>
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
67 </select>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
68 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
69 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
70 <div class="row" id="row1" style="margin-top: 15px">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
71 <div class="col-sm-4 col-md-4" id="1filter-col1">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
72 <select class="filter-box1 form-control">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
73 <option value="" disabled selected>Choose filter...</option>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
74 </select>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
75 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
76 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
77 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
78 <div align="left" style="margin-top: 30px"><button id="minus_filter_button" class="btn btn-warning btn-md" type="button"> - </button>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
79 <button id="plus_filter_button" class="btn btn-warning btn-md" type="button"> + </button>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
80 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
81 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
82
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
83
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
84 <div class="container-fluid" style="margin-top: 15px">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
85 <form role="form">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
86 <div class="form-group">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
87 <label for="results-container">Results list</label>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
88 <select multiple class="form-control" id="results-container" style="min-height: 300px;">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
89 </select>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
90 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
91 </form>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
92
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
93 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
94
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
95 <!-- <pre data-fill-from=".js-code-data-array"></pre> -->
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
96 </section>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
97
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
98 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
99 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
100 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
101 </div>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
102
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
103
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
104
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
105
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
106
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
107
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
108 <script type="text/javascript" class="js-code-data-array">
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
109 //var queryData = [];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
110
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
111 // Defining initial variables and helper functions
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
112 var sourceType = "TEXT";
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
113 var currentQueryData;
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
114 var targets = [];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
115 var targetTypes = [];
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
116 var targetObj = [{}]; // The current objects on the display box
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
117 var numFilters = 1;
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
118 var filters = [
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
119 { id: 0, text: 'has relation' },
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
120 { id: 1, text: 'attribute' }
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
121 ];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
122 $(".filter-box"+numFilters).select2({
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
123 // Initialize first filter box
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
124 data: filters,
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
125 minimumResultsForSearch: Infinity
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
126 });
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
127 var listTolerance = 100;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
128 //$("")
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
129
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
130 function filter_html(n) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
131 return '<div class="row" id="row'+n+'" style="margin-top: 15px">' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
132 '<div class="col-sm-4 col-md-4" id="'+n+'filter-col1">' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
133 '<select class="filter-box'+n+' form-control">' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
134 '<option value="" disabled selected>Choose filter...</option>' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
135 '</select>' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
136 '</div>' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
137 '</div>';
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
138 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
139 function constraint_html(classn) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
140 return '<div class="col-sm-4 col-md-4" id="'+classn+'filter-col2">' +
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
141 '<select class="rel-constraint-box'+classn+' form-control" >' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
142 '</select>' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
143 '</div>';
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
144 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
145 function attr_constraint_html(classn) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
146 return '<div class="col-sm-4 col-md-4" id="'+classn+'filter-col2">' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
147 '<select class="attr-constraint-box'+classn+' form-control" >' +
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
148 '</select>' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
149 '</div>';
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
150 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
151 function submit_html(classn) {
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
152 return '<div class="col-sm-4 col-md-4" id="'+classn+'filter-col3">' +
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
153 '<div class="form-group'+classn+'">' +
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
154 '<form onsubmit="return false;"> ' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
155 '<input type="text" name="attr-field" class="form-control" id="attr-input'+classn+'">' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
156 '</input>' +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
157 '</form>' +
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
158 '</div>' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
159 '</div>';
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
160 }
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
161 function select_html(selection, n) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
162 return '<div class="row" id="row'+n+'" style="margin-top: 15px">' +
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
163 '<div class="col-sm-4 col-md-4" id="select-col1"> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
164 '<select class="selected-object form-control"> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
165 '<option selected>Selected object is: </option> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
166 '</select> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
167 '</div> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
168 '<div class="col-sm-4 col-md-4" id="select-col2"> ' +
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
169 '<h4>' + selection +
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
170 '</h4>' +
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
171 '</div> ' +
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
172 '</div>';
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
173 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
174
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
175
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
176
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
177
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
178 // Button filters
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
179 $("#plus_filter_button").click(function() {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
180 console.log("add filter");
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
181 numFilters++;
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
182 $("#filters").append(filter_html(numFilters));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
183 $(".filter-box"+numFilters).select2({
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
184 data: filters,
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
185 minimumResultsForSearch: Infinity
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
186 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
187 });
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
188 // TODO: update minus button to alter the currRel currAttr arrays
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
189 $("#minus_filter_button").click(function() {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
190 console.log("minus filter");
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
191 //$("#row"+numFilters).remove();
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
192 //numFilters--;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
193
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
194 // NOTE: Temporary solution for removing filters,
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
195 while (numFilters > 0) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
196 $("#row"+numFilters).remove();
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
197 numFilters--;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
198 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
199 numFilters++;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
200 $("#filters").append(filter_html(numFilters));
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
201 $(".filter-box"+numFilters).select2({
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
202 data: filters,
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
203 minimumResultsForSearch: Infinity
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
204 });
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
205 currAttrs = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
206 currRels = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
207 currSource = sourceType;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
208
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
209
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
210 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
211 $("#results-container").dblclick(function() {
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
212 var displayChoice = $("#results-container").find("option:selected").text();
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
213 console.log(targetObj);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
214 if (!targetObj[displayChoice]) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
215 // increase tolerance
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
216 console.log("increase listTolerance");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
217 listTolerance = 100000;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
218 process_display_results(currentQueryData);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
219 listTolerance = 100;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
220 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
221 else {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
222 console.log(displayChoice + ".........");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
223 var displayType = targetObj[displayChoice];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
224 /*
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
225 _.map(targetObj, function(obj){
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
226
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
227 if (_.values(_.values(targetObj))[1] === displayChoice) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
228 selection = (_.values(_.values(obj))[0])[1];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
229 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
230 else {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
231 selection = (_.values(_.values(obj))[0])[0];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
232 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
233 });
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
234 */
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
235 numFilters++;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
236 $("#filters").append(select_html(displayChoice, numFilters));
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
237 // Generate inner relation list
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
238 //genRelations(sourceType, ".constraint-box"+numFilters);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
239 sourceType = displayChoice;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
240 console.log("New Target");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
241 genResults("New Target", [displayType,displayChoice], "target")
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
242 }
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
243 });
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
244 $(function() {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
245 $("input").submit(function(event, data) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
246 console.log($('.form-control').find("option:selected").text());
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
247 console.log(event);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
248 console.log(data);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
249 event.preventDefault();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
250
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
251 });
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
252 });
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
253
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
254
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
255 // Change Events
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
256 $('body').on('change', function(event){
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
257 var classname = (event.target.className).substr(0, (event.target.className).indexOf(" "));
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
258 var classnum = (event.target.className.match(/\d+\.\d+|\d+\b|\d+(?=\w)/g) || [] ).map(function (v) {return +v;}).shift();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
259 var allclass = '.'+classname;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
260 var selectedOption = $(allclass).find('option:selected').text();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
261 console.log("SEL "+ selectedOption);
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
262
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
263 // Change is on the filter box
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
264 if (classname.indexOf("filter-box") > -1) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
265 if (selectedOption === "has relation") {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
266 // Remove any other boxes in the row
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
267 $("#"+classnum+"filter-col2").remove();
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
268 $("#row"+classnum).append(constraint_html(classnum));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
269 // Generate inner relation list
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
270 genRelations(sourceType, ".rel-constraint-box"+classnum);
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
271 }
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
272 if (selectedOption === "attribute") {
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
273 $("#"+classnum+"filter-col2").remove();
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
274 $("#row"+classnum).append(attr_constraint_html(classnum));
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
275 genAttributes(sourceType, ".attr-constraint-box"+classnum);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
276 //$("#row"+classnum).append(submit_html(classnum));
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
277 $("#row"+classnum).append(submit_html(classnum));
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
278
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
279 }
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
280
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
281 // NOT IMPLEMENTED
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
282 /*
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
283 if (selectedOption === "return") {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
284 $("#"+classnum+"filter-col2").remove();
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
285 $("#row"+classnum).append(constraint_html(classnum));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
286 genAttributes(targetTypes, ".constraint-box"+classnum);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
287 }
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
288 */
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
289 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
290
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
291 // Change is on the relationship constraint box
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
292 if (classname.indexOf("rel-constraint-box") > -1) {
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
293 //$().remove();
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
294 genResults(sourceType, selectedOption, "results-container");
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
295 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
296
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
297 // Change is on the attr constraint box
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
298 if (classname.indexOf("attr-constraint-box") > -1) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
299 //$().remove();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
300 console.log("CHANGE ON ATTR");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
301 console.log("changing currentqueryattr to" + selectedOption);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
302 currentQueryAttr = selectedOption;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
303 console.log("currentQueryAttr is" + currentQueryAttr);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
304 //genResults(sourceType, selectedOption, "results-container");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
305 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
306
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
307 // Change is on subject scope
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
308 if (classname.indexOf("select-object") > -1) {
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
309 sourceType = selectedOption;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
310 console.log("CHANGE ON SCOPE");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
311 genResults(sourceType, "New Source", "results-container");
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
312
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
313 //ajax1(query, "results-container")
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
314 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
315 });
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
316 $("#filters").submit(function (event) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
317 var inputId = $("input:text[name=attr-field]")[0].id;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
318 var inputValue = $("input:text[name=attr-field]").val();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
319 // Alter results list
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
320 console.log("QUERY TYPE IS ATTRIBUTE NOW");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
321 currentQueryType = "attribute";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
322 console.log("SUBMITTED");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
323 genResults(sourceType, inputValue, "results-container")
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
324
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
325
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
326 });
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
327 // For use in the onchange events above
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
328 function genRelations(sourceNodeType, constraintBox) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
329 console.log("GENERATE ALL RELATIONS");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
330 var query = "match (source:"+sourceNodeType+")-[rel]-target return distinct rel.type";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
331 console.log("QUERY TYPE IS RELATION NOW");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
332 currentQueryType = "relation";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
333 ajax1(query, constraintBox);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
334 }
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
335
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
336 function genAttributes(sourceNodeType, constraintBox) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
337 console.log("GENERATE ALL ATTRIBUTES");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
338 var query = "match (n:"+sourceNodeType+") with keys(n) as collection unwind collection as attributes return distinct attributes";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
339 ajax1(query, constraintBox);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
340 }
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
341
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
342 function genResults(sourceNodeType, selected, constraintBox) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
343 // TODO: Return first the list of current values of the display box
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
344
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
345 if (selected === "New Source") {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
346 console.log("NEW SOURCE - UPDATE RESULTS");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
347 var query = "match (source:"+sourceNodeType+") return source._n_label, source.type";
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
348 set_current_query('source', sourceNodeType+")");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
349 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
350 else if (sourceNodeType === "New Target") {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
351 newTarget = 1;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
352 set_current_query('target', selected);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
353 var query = get_current_query;
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
354 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
355 else if (currentQueryType === "attribute") {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
356 console.log("ATTR CHANGE - UPDATE RESULTS");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
357 console.log("before update currentQueryAttr is " + currentQueryAttr);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
358 var qAttr = currentQueryAttr;
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
359 set_current_query('attribute', "."+qAttr+"=~\"(?i).*"+selected+".*\"");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
360 // this might cause an issue
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
361 var query = get_current_query();
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
362 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
363 /*
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
364 var query = "match (source:"+sourceNodeType+") where ";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
365 if (get_result_labels()) query += get_result_labels() + " AND ";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
366 query += "source."+qAttr+"=~\"(?i).*"+selected+".*\" return distinct source._n_label, source.type limit 5";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
367 // TODO: case where all attributes are searched
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
368 // if (selected === "ALL") set_current_query('attribute', "."+qAttr+"=~\"(?i).*"+selected+".*\"");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
369
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
370 console.log(query);
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
371 */
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
372 else if (currentQueryType === "relation") {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
373 var query = "match (source:" + sourceNodeType + ")-[rel:" + selected + "]->(target) return distinct target._n_label, target.type";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
374 console.log("REL CHANGE - UPDATE RESULTS");
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
375 set_current_query('relation', selected+"]->(");
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
376 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
377 else {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
378 console.log("GENRESULTS IMPROPERLY CALLED");
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
379 return;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
380 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
381 ajax1(query, constraintBox);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
382 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
383 var currentQueryType;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
384 var currentQueryAttr;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
385 var resultLabelString = "";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
386 function get_result_labels() {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
387 return resultLabelString;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
388 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
389 function set_result_labels(currentResults) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
390 resultLabelString = "(";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
391 for (var i = 0; i < currentResults.length; i++) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
392 if (i > 0) resultLabelString += " OR ";
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
393 resultLabelString += 'source._n_label=\"'+currentResults[i].text.substr(1)+'\"';
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
394 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
395 resultLabelString += ")"
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
396 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
397 // to use contains
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
398 // TODO: start n = node(*) where n.Name =~ '.*SUBSTRING.*' return n.Name, n;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
399
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
400 var currSource = [sourceType];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
401 var currRels = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
402 var currAttrs = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
403 var currQ = '';
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
404
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
405 function set_current_query(type, q) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
406 if (type === 'source') {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
407 currSource[0] = ("match (source:"+q);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
408 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
409 else if (type === 'target') {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
410 currSource.push("match (target:"+q[0]+")");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
411 currRels = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
412 currAttrs = [];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
413 currAttrs.push("target._n_label=\""+q[1]+"\"");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
414 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
415 else if (type === 'relation') {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
416 currRels.push("-[rel"+currRels.length+":"+q+"target"+currRels.length+")");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
417 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
418 else if (type === 'attribute') {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
419 if (Boolean(currRels.length)) currAttrs.push("target"+(currRels.length-1)+q);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
420 else currAttrs.push("source"+q);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
421 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
422 else if (type === 'return') {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
423 return currQ
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
424 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
425 else {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
426 console.log("improper call to change current query");
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
427 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
428 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
429 var newTarget = -1;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
430 function get_current_query() {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
431 var currQ = currSource[currSource.length-1];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
432 var i;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
433 var n=currRels.length;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
434 var m=currAttrs.length;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
435 for (i=0; i<n; i++) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
436 currQ += currRels[i];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
437 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
438 currQ += " where ";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
439 for (i=0; i<m; i++) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
440 if (Boolean(i)) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
441 currQ += "AND ";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
442 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
443 currQ += currAttrs[i]+" ";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
444 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
445 if (Boolean(currRels.length)) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
446 currQ += "return distinct target"+(currRels.length-1)+"._n_label, target"+(currRels.length-1)+".type";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
447 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
448 else if (newTarget > 0) {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
449 currQ += "return distinct target._n_label, target.type";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
450 newTarget = -1;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
451 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
452 else currQ += "return distinct source._n_label, source.type";
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
453 console.log(currQ);
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
454 return currQ;
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
455 }
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
456
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
457
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
458
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
459
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
460
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
461 // Ajax request function
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
462 function ajax1(q, resBox) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
463 $.ajaxSetup({
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
464 headers: {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
465 "Authorization": 'Basic ' + window.btoa("neo4j"+":"+"neo5j")
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
466 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
467 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
468 return $.ajax({
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
469 type: "POST",
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
470 url: "https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data/cypher",
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
471 accepts: "application/json",
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
472 dataType: "json",
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
473 data: {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
474 "query": q,
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
475 "params": {}
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
476 },
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
477 beforeSend: function (xhr) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
478 xhr.setRequestHeader ("Authorization", "Basic " + btoa('neo4j'+":"+'neo5j'));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
479 },
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
480 processResults: function (data, params) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
481 // parse the results into the format expected by Select2
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
482 // since we are using custom formatting functions we do not need to
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
483 // alter the remote JSON data, except to indicate that infinite
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
484 // scrolling can be used
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
485 params.page = params.page || 1;
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
486 return {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
487 pagination: {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
488 more: (params.page * 30) < data.length
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
489 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
490 };
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
491 },
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
492 success: function (res, textStatus, jqXHR) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
493 ajaxCheck(res, resBox, textStatus);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
494 console.log(textStatus);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
495 },
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
496 error: function (jqXHR, textStatus, errorThrown) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
497 console.log(textStatus);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
498 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
499 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
500 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
501 // Check if request was successful
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
502 function ajaxCheck(a1, resBox, status){
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
503 if (status === 'error') console.log("error: bad ajax request");
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
504 //else dataGen(a1);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
505 dataGen(a1.data, resBox);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
506 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
507 // On success, generate new data
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
508 // TODO: might want to just always return nodes and then deal with the queryData different for each type of return
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
509 function dataGen(dataArr, resBox) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
510 var d = dataArr;
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
511 targets = [];
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
512 targetObj = [];
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
513
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
514 // Consider implementing localStorage to avoid reloading every time
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
515 var queryData = [];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
516 for (var i= 0; i<d.length; i++) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
517 var j = d[i];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
518 queryData.push({ id: j, text: j[0] });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
519 targets.push(j[1]);
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
520 targetObj[j[0]]=j[1];
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
521 }
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
522 console.log(queryData);
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
523 // Now that queryData array has been defined we will sort it by its label value and initialize the option.
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
524 queryData.sort(function(a,b){
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
525 var c = a.text.replace(/<|>/g, '');
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
526 var d = b.text.replace(/<|>/g, '');
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
527 return c.localeCompare(d);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
528 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
529
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
530 // Change the displayed results
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
531 if (resBox === "results-container") {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
532 process_display_results(queryData);
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
533 }
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
534 if (resBox === "target") {
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
535 sourceType = currSource[0];
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
536 }
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
537 // Or fill any select boxes
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
538 else {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
539 $(resBox).select2({
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
540 data: queryData
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
541 });
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
542 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
543 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
544 function process_display_results(queryData) {
34
4bbb832c53ac Completed: Base functionality for simple examples. Minus button now removes all filters for simplicity. Still need to adjust how to go about restarting the querying process once a result has been selected from the display list (eg. the 'selected object is:' case). Also need to strip out a bunch of unneeded code.
arussell
parents: 32
diff changeset
545 currentQueryData = queryData;
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
546 var weights = [];
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
547 var resultLength = queryData.length;
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
548 targetTypes = [];
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
549 set_result_labels(queryData);
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
550 $('#results-container')
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
551 .find('option')
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
552 .remove()
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
553 .end()
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
554 ;
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
555 for (var i = 0; i < targets.length; i++) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
556 if (targetTypes.indexOf(targets[i]) == -1) {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
557 targetTypes.push(targets[i]);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
558 weights.push(1);
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
559 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
560 else {
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
561 weights[targetTypes.indexOf(targets[i])] += 1;
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
562 }
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
563 }
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
564 if (resultLength < listTolerance) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
565 for (var i = 0; i < resultLength; i++) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
566 // TODO: put this jQuery call into its own function to be called if the else statement occurs
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
567 // TODO: but the user actually does want to see the entire huge list.
32
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
568 // This next bit removes duplicate labels if we want to use that for things like cities
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
569 // would this throw issues with other things??
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
570 //$('#results-container option:contains('+queryData[i].text+')').each(function(){
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
571 // $(this).remove();
acc60a20582c Temporary Changes for querybuilder. Selecting attribute and having results list filter not fully working yet. Need 'ALL' option in attributes.
arussell
parents: 28
diff changeset
572 //});
28
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
573 $('#results-container')
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
574 .append($("<option></option>")
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
575 .attr("value", i)
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
576 .text(queryData[i].text));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
577 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
578 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
579 else {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
580 for (var i = 0; i < targetTypes.length; i++) {
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
581 $('#results-container')
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
582 .append($("<option></option>")
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
583 .text(targetTypes[i] + " [ " + weights[i] + " ]"));
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
584 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
585 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
586 }
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
587
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
588 </script>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
589
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
590 </body>
5384b71df52a querybuild.html added, beginning prototype.
arussell
parents:
diff changeset
591 </html>