mirror of https://gitee.com/bigwinds/arangodb
addad desc sorting for graphs view
This commit is contained in:
parent
091d4cdf02
commit
8bd979e3e5
|
@ -6,9 +6,29 @@
|
||||||
window.GraphCollection = Backbone.Collection.extend({
|
window.GraphCollection = Backbone.Collection.extend({
|
||||||
model: window.Graph,
|
model: window.Graph,
|
||||||
|
|
||||||
|
sortOptions: {
|
||||||
|
desc: false
|
||||||
|
},
|
||||||
|
|
||||||
url: "/_api/gharial",
|
url: "/_api/gharial",
|
||||||
|
|
||||||
comparator: "_key",
|
//comparator: "_key",
|
||||||
|
|
||||||
|
comparator: function(item, item2) {
|
||||||
|
var a, b;
|
||||||
|
if (this.sortOptions.desc === true) {
|
||||||
|
a = item.get('_key');
|
||||||
|
b = item2.get('_key');
|
||||||
|
return a < b ? 1 : a > b ? -1 : 0;
|
||||||
|
}
|
||||||
|
a = item.get('_key');
|
||||||
|
b = item2.get('_key');
|
||||||
|
return a > b ? 1 : a < b ? -1 : 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
setSortingDesc: function(val) {
|
||||||
|
this.sortOptions.desc = val;
|
||||||
|
},
|
||||||
|
|
||||||
parse: function(res) {
|
parse: function(res) {
|
||||||
if (!res.error) {
|
if (!res.error) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script id="graphManagementView.ejs" type="text/template">
|
<script id="graphManagementView.ejs" type="text/template">
|
||||||
<div class="headerBar">
|
<div class="headerBar">
|
||||||
<!-- <div class="headerButtonBar">
|
<div class="headerButtonBar">
|
||||||
<ul class="headerButtonList">
|
<ul class="headerButtonList">
|
||||||
<li class="enabled">
|
<li class="enabled">
|
||||||
<a id="graphManagementToggle" class="headerButton">
|
<a id="graphManagementToggle" class="headerButton">
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>-->
|
</div>
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<a class="arangoHeader">Graphs</a>
|
<a class="arangoHeader">Graphs</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,25 +23,10 @@
|
||||||
<div id="graphManagementDropdown" class="dropdownInner">
|
<div id="graphManagementDropdown" class="dropdownInner">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="nav-header">Sorting</li>
|
<li class="nav-header">Sorting</li>
|
||||||
|
<li><a>
|
||||||
<li><a href="#">
|
|
||||||
<label class="checkbox checkboxLabel">
|
<label class="checkbox checkboxLabel">
|
||||||
<input class="css-checkbox" type="checkbox" id="sortName">
|
<input class="css-checkbox" type="checkbox" id="graphSortDesc">
|
||||||
<label class="css-label css-label-round"></label>Sort by ?
|
<label class="css-label" id="graphSortDesc"></label>Sort descending
|
||||||
</label>
|
|
||||||
</a></li>
|
|
||||||
|
|
||||||
<li><a href="#">
|
|
||||||
<label class="checkbox checkboxLabel">
|
|
||||||
<input class="css-checkbox" type="checkbox" id="sortType">
|
|
||||||
<label class="css-label css-label-round"></label>Sort by ?
|
|
||||||
</label>
|
|
||||||
</a></li>
|
|
||||||
|
|
||||||
<li><a href="#">
|
|
||||||
<label class="checkbox checkboxLabel">
|
|
||||||
<input class="css-checkbox" type="checkbox" id="sortOrder">
|
|
||||||
<label class="css-label"></label>Sort descending
|
|
||||||
</label>
|
</label>
|
||||||
</a></li>
|
</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
render: function(){
|
render: function(){
|
||||||
this.currentDatabase();
|
this.currentDatabase();
|
||||||
|
|
||||||
|
|
||||||
//sorting
|
//sorting
|
||||||
this.collection.sort();
|
this.collection.sort();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
"click #createGraph" : "addNewGraph",
|
"click #createGraph" : "addNewGraph",
|
||||||
"keyup #graphManagementSearchInput" : "search",
|
"keyup #graphManagementSearchInput" : "search",
|
||||||
"click #graphManagementSearchSubmit" : "search",
|
"click #graphManagementSearchSubmit" : "search",
|
||||||
"click .tile-graph" : "loadGraphViewer"
|
"click .tile-graph" : "loadGraphViewer",
|
||||||
|
"click #graphManagementToggle" : "toggleGraphDropdown",
|
||||||
|
"click .css-label" : "checkBoxes",
|
||||||
|
"change #graphSortDesc" : "sorting"
|
||||||
},
|
},
|
||||||
|
|
||||||
loadGraphViewer: function(e) {
|
loadGraphViewer: function(e) {
|
||||||
|
@ -81,15 +84,43 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkBoxes: function (e) {
|
||||||
|
//chrome bugfix
|
||||||
|
var clicked = e.currentTarget.id;
|
||||||
|
$('#'+clicked).click();
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleGraphDropdown: function() {
|
||||||
|
//apply sorting to checkboxes
|
||||||
|
$('#graphSortDesc').attr('checked', this.collection.sortOptions.desc);
|
||||||
|
|
||||||
|
$('#graphManagementToggle').toggleClass('activated');
|
||||||
|
$('#graphManagementDropdown2').slideToggle(200);
|
||||||
|
},
|
||||||
|
|
||||||
|
sorting: function() {
|
||||||
|
if ($('#graphSortDesc').is(":checked")) {
|
||||||
|
this.collection.setSortingDesc(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.collection.setSortingDesc(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.collection.fetch({
|
this.collection.fetch({
|
||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.collection.sort();
|
||||||
|
|
||||||
$(this.el).html(this.template.render({
|
$(this.el).html(this.template.render({
|
||||||
graphs: this.collection,
|
graphs: this.collection,
|
||||||
searchString : ''
|
searchString : ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.events["click .tableRow"] = this.showHideDefinition.bind(this);
|
this.events["click .tableRow"] = this.showHideDefinition.bind(this);
|
||||||
this.events['change tr[id*="newEdgeDefinitions"]'] = this.setFromAndTo.bind(this);
|
this.events['change tr[id*="newEdgeDefinitions"]'] = this.setFromAndTo.bind(this);
|
||||||
this.events["click .graphViewer-icon-button"] = this.addRemoveDefinition.bind(this);
|
this.events["click .graphViewer-icon-button"] = this.addRemoveDefinition.bind(this);
|
||||||
|
|
Loading…
Reference in New Issue