Skip to content

Commit 692a167

Browse files
fixing table views
1 parent 42e86d2 commit 692a167

File tree

4 files changed

+61
-10
lines changed

4 files changed

+61
-10
lines changed

lib/query/woqlLibrary.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,12 +781,12 @@ WOQLLibrary.prototype.active_commit_id = function(branch, ts, commit_var) {
781781

782782
//includes passed commit id in list
783783
WOQLLibrary.prototype.history_ids = function(commit_id, count, commit_var) {
784-
count = count || 10
785784
commit_var = commit_var || "Commit ID"
786785
let [commit_iri, cpath, tail_iri, cid] = this
787786
.vars("My Head IRI", "Commit Path", "My Tail IRI", commit_var)
788-
let q = new WOQLQuery().using("_commits").select(cid).limit(count)
789-
.triple(commit_iri, "ref:commit_id", commit_id)
787+
let q = new WOQLQuery().using("_commits").select(cid)
788+
if(count) q.limit(count)
789+
q.triple(commit_iri, "ref:commit_id", commit_id)
790790
.or(
791791
new WOQLQuery().eq(cid, commit_id),
792792
new WOQLQuery().path(commit_iri, "ref:commit_parent+", tail_iri, cpath)

lib/viewer/tableConfig.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,44 @@ WOQLTableRule.prototype.header = function(hdr){
185185
return this;
186186
}
187187

188+
WOQLTableRule.prototype.width = function(wid){
189+
if(typeof wid == "undefined"){
190+
return this.rule.width;
191+
}
192+
this.rule.width = wid;
193+
return this;
194+
}
195+
196+
WOQLTableRule.prototype.maxWidth = function(wid){
197+
if(typeof wid == "undefined"){
198+
return this.rule.maxWidth;
199+
}
200+
this.rule.maxWidth = wid;
201+
return this;
202+
}
203+
204+
WOQLTableRule.prototype.minWidth = function(wid){
205+
if(typeof wid == "undefined"){
206+
return this.rule.minWidth;
207+
}
208+
this.rule.minWidth = wid;
209+
return this;
210+
}
211+
188212
WOQLTableRule.prototype.prettyPrint = function(type){
189213
var str = Config.WOQLViewRule.prototype.prettyPrint.apply(this);
190214
if(typeof this.header() != "undefined"){
191215
str += ".header(" + this.header() + ")";
192216
}
217+
if(typeof this.width() != "undefined"){
218+
str += ".width(" + this.width() + ")";
219+
}
220+
if(typeof this.maxWidth() != "undefined"){
221+
str += ".maxWidth(" + this.maxWidth() + ")";
222+
}
223+
if(typeof this.minWidth() != "undefined"){
224+
str += ".minWidth(" + this.minWidth() + ")";
225+
}
193226
return str;
194227
}
195228

lib/viewer/woqlResult.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function WOQLResult(results, query, config) {
1616
this.insert_count = results ? results.inserts : 0
1717
this.delete_count = results ? results.deletes : 0
1818
this.transaction_retry_count = results ? results.transaction_retry_count : 0
19-
this.variable_names = results ? results['api:variables_names'] : false
19+
this.variable_names = results ? results['api:variable_names'] : false
20+
//console.log(results, this.variable_names)
2021
this.query = query ? query : WOQL.query()
2122
this.cursor = 0
2223
if (!(config && config.no_compress)) {
@@ -83,6 +84,10 @@ WOQLResult.prototype.getBindings = function() {
8384
return this.bindings
8485
}
8586

87+
WOQLResult.prototype.rows = function() {
88+
return this.bindings
89+
}
90+
8691
/**
8792
* Returns list of variables returned in bindings from API
8893
*/

lib/viewer/woqlTable.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ WOQLTable.prototype.getColumnsToRender = function(){
8585
var cols = this.getColumnOrder();
8686
}
8787
else {
88-
var cols = this.result.getVariableList();
88+
var cols = this.result.getVariableList();
8989
}
9090
var self = this;
9191
return (cols ? cols.filter(col => !self.hidden(col)) : []);
@@ -119,7 +119,7 @@ WOQLTable.prototype.getColumnHeaderContents = function(colid){
119119

120120

121121
WOQLTable.prototype.hidden = function(col){
122-
colid = UTILS.addNamespaceToVariable(col);
122+
colid = UTILS.removeNamespaceFromVariable(col);
123123
let matched_rules = new WOQLRule().matchColumn(this.config.rules, colid, "hidden");
124124
if(matched_rules.length){
125125
return matched_rules[matched_rules.length-1].rule.hidden;
@@ -141,21 +141,21 @@ WOQLTable.prototype.update = function(nquery){
141141

142142
WOQLTable.prototype.hasDefinedEvent = function(row, key, scope, action, rownum){
143143
if(scope == "row"){
144-
var matched_rules = new WOQLRule().matchRow(this.config.rules, row, this.result.cursor, action);
144+
var matched_rules = new WOQLRule().matchRow(this.config.rules, row, rownum, action);
145145
}
146146
else {
147-
var matched_rules = new WOQLRule().matchCell(this.config.rules, row, key, this.result.cursor, action);
147+
var matched_rules = new WOQLRule().matchCell(this.config.rules, row, key, rownum, action);
148148
}
149149
if(matched_rules && matched_rules.length) return true;
150150
return false;
151151
}
152152

153153
WOQLTable.prototype.getDefinedEvent = function(row, key, scope, action, rownum){
154154
if(scope == "row"){
155-
var matched_rules = new WOQLRule().matchRow(this.config.rules, row, this.result.cursor, action);
155+
var matched_rules = new WOQLRule().matchRow(this.config.rules, row, rownum, action);
156156
}
157157
else {
158-
var matched_rules = new WOQLRule().matchCell(this.config.rules, row, key, this.result.cursor, action);
158+
var matched_rules = new WOQLRule().matchCell(this.config.rules, row, key, rownum, action);
159159
}
160160
if(matched_rules && matched_rules.length) {
161161
var l = (matched_rules.length - 1);
@@ -185,6 +185,19 @@ WOQLTable.prototype.getColumnOrder = function(){
185185
return this.config.column_order();
186186
}
187187

188+
WOQLTable.prototype.getColumnDimensions = function(key){
189+
let cstyle = {}
190+
let w = new WOQLRule().matchColumn(this.config.rules, key, "width");
191+
if(w && w.length && w[w.length-1].rule.width) {
192+
cstyle.width = w[w.length-1].rule.width;
193+
}
194+
let max = new WOQLRule().matchColumn(this.config.rules, key, "maxWidth");
195+
if(max && max.length) cstyle.maxWidth = max[max.length-1].rule.maxWidth;
196+
let min = new WOQLRule().matchColumn(this.config.rules, key, "minWidth");
197+
if(min && min.length) cstyle.minWidth = min[min.length-1].rule.minWidth;
198+
return cstyle
199+
}
200+
188201
WOQLTable.prototype.hasColumnOrder = WOQLTable.prototype.getColumnOrder;
189202
WOQLTable.prototype.hasCellClick = WOQLTable.prototype.getCellClick;
190203
WOQLTable.prototype.hasRowClick = WOQLTable.prototype.getRowClick;

0 commit comments

Comments
 (0)