mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
017dae2e1b
|
@ -1,3 +1,12 @@
|
|||
#collectionPrev, #collectionNext{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disabledPag, .disabledPag a{
|
||||
opacity: 0.5 !important;
|
||||
cursor: default !important;
|
||||
}
|
||||
|
||||
#tableDiv {
|
||||
margin-top: -40px;
|
||||
padding: 20px 20px 20px 20px;
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
.arangoBtn {
|
||||
|
||||
}
|
||||
|
||||
.arangoBtnError {
|
||||
|
||||
}
|
||||
|
||||
.arangoBtnSuccess
|
||||
|
||||
}
|
||||
|
||||
/* Radius */
|
||||
.thumbnail, .navbar-inner, .btn, .btn-primary {
|
||||
border-radius:0;
|
||||
|
|
|
@ -2,7 +2,16 @@
|
|||
/*global require, exports */
|
||||
window.arangoCollections = Backbone.Collection.extend({
|
||||
url: '/_api/collection',
|
||||
|
||||
model: arangoCollection,
|
||||
|
||||
searchOptions : {
|
||||
searchPhrase: null,
|
||||
includeSystem: false,
|
||||
includeLoaded: true,
|
||||
includeUnloaded: true
|
||||
},
|
||||
|
||||
comparator : function(model) {
|
||||
return model.get('name').toLowerCase();
|
||||
},
|
||||
|
@ -50,6 +59,55 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
return response.collections;
|
||||
},
|
||||
|
||||
getPosition : function (name) {
|
||||
var list = this.getFiltered(this.searchOptions), i;
|
||||
var prev = null;
|
||||
var next = null;
|
||||
|
||||
for (i = 0; i < list.length; ++i) {
|
||||
if (list[i].get('name') === name) {
|
||||
if (i > 0) {
|
||||
prev = list[i - 1];
|
||||
}
|
||||
if (i < list.length - 1) {
|
||||
next = list[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { prev: prev, next: next };
|
||||
},
|
||||
|
||||
getFiltered : function (options) {
|
||||
var result = [ ];
|
||||
|
||||
var searchPhrase = '';
|
||||
if (options.searchPhrase !== null) {
|
||||
searchPhrase = options.searchPhrase.toLowerCase();
|
||||
}
|
||||
|
||||
this.models.forEach(function (model) {
|
||||
if (searchPhrase !== '' && model.get('name').toLowerCase().indexOf(searchPhrase) === -1) {
|
||||
// search phrase entered but current collection does not match?
|
||||
return;
|
||||
}
|
||||
if (options.includeSystem === false && model.get('isSystem')) {
|
||||
// system collection?
|
||||
return;
|
||||
}
|
||||
if (options.includeLoaded === false && model.get('status') === 'loaded') {
|
||||
return;
|
||||
}
|
||||
if (options.includeUnloaded === false && model.get('status') === 'unloaded') {
|
||||
return;
|
||||
}
|
||||
|
||||
result.push(model);
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
getProperties: function (id) {
|
||||
var data2;
|
||||
$.ajax({
|
||||
|
|
|
@ -84,6 +84,7 @@ $(document).ready(function() {
|
|||
this.newCollectionView.render();
|
||||
},
|
||||
documents: function(colid, pageid) {
|
||||
window.documentsView.colid = colid;
|
||||
window.documentsView.render();
|
||||
window.arangoDocumentsStore.getDocuments(colid, pageid);
|
||||
if (!window.documentsView) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</div>
|
||||
|
||||
<a href="#collection/<%= attributes.name %>/documents/1" class="plain">
|
||||
<img src="img/icon_arango.png" height="60" width="60" alt="" class="icon">
|
||||
<img src="<%= attributes.picture %>" height="60" width="60" alt="" class="icon">
|
||||
<span class="badge badge-success"><div class="cornered"><%= attributes.status %></div></span>
|
||||
|
||||
<h5 class="collectionName">
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<div id="transparentHeader">
|
||||
<div id="documentsToolbar" class="pagination pagination-small pagination-right">
|
||||
<ul>
|
||||
<li class="enabled"><a href="#">‹</a></li>
|
||||
<li class="enabled"><a href="#">›</a></li>
|
||||
<li class="enabled"><a id="collectionPrev">‹</a></li>
|
||||
<li class="enabled"><a id="collectionNext">›</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,13 +2,6 @@ var collectionsView = Backbone.View.extend({
|
|||
el: '#content',
|
||||
el2: '.thumbnails',
|
||||
|
||||
searchOptions: {
|
||||
searchPhrase: null,
|
||||
includeSystem: false,
|
||||
includeLoaded: true,
|
||||
includeUnloaded: true
|
||||
},
|
||||
|
||||
init: function () {
|
||||
},
|
||||
|
||||
|
@ -18,37 +11,14 @@ var collectionsView = Backbone.View.extend({
|
|||
$(this.el).html(this.template.text);
|
||||
this.setFilterValues();
|
||||
|
||||
var searchPhrase = '';
|
||||
if (this.searchOptions.searchPhrase !== null) {
|
||||
searchPhrase = this.searchOptions.searchPhrase.toLowerCase();
|
||||
}
|
||||
this.collection.each(function (arango_collection) {
|
||||
if (arango_collection.get('name').substr(0,1) === "_") {
|
||||
}
|
||||
if (searchPhrase !== '' && arango_collection.get('name').toLowerCase().indexOf(searchPhrase) === -1) {
|
||||
// search phrase entered but current collection does not match?
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.searchOptions.includeSystem === false && arango_collection.get('isSystem')) {
|
||||
// system collection?
|
||||
return;
|
||||
}
|
||||
if (this.searchOptions.includeLoaded === false && arango_collection.get('status') === 'loaded') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.searchOptions.includeUnloaded === false && arango_collection.get('status') === 'unloaded') {
|
||||
return;
|
||||
}
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
|
||||
this.collection.getFiltered(searchOptions).forEach(function (arango_collection) {
|
||||
$('.thumbnails', this.el).append(new window.CollectionListItemView({model: arango_collection}).render().el);
|
||||
|
||||
}, this);
|
||||
|
||||
$('.thumbnails', this.el).append('<li class="span3"><a href="#new" class="add"><img id="newCollection" src="/_admin/html/img/plus_icon.png" class="pull-left"></img>Add Collection</a></li>');
|
||||
|
||||
$('#searchInput').val(this.searchOptions.searchPhrase);
|
||||
$('#searchInput').val(searchOptions.searchPhrase);
|
||||
$('#searchInput').focus();
|
||||
var val = $('#searchInput').val();
|
||||
$('#searchInput').val('');
|
||||
|
@ -68,53 +38,50 @@ var collectionsView = Backbone.View.extend({
|
|||
"click #checkUnloaded" : "checkUnloaded"
|
||||
},
|
||||
checkSystem: function () {
|
||||
var oldValue = this.searchOptions.includeSystem;
|
||||
if ($('#checkSystem').is(":checked") === true) {
|
||||
this.searchOptions.includeSystem = true;
|
||||
}
|
||||
else {
|
||||
this.searchOptions.includeSystem = false;
|
||||
}
|
||||
if (oldValue != this.searchOptions.includeSystem) {
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
var oldValue = searchOptions.includeSystem;
|
||||
|
||||
searchOptions.includeSystem = ($('#checkSystem').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeSystem) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
checkLoaded: function () {
|
||||
var oldValue = this.searchOptions.includeLoaded;
|
||||
if ($('#checkLoaded').is(":checked") === true) {
|
||||
this.searchOptions.includeLoaded = true;
|
||||
}
|
||||
else {
|
||||
this.searchOptions.includeLoaded = false;
|
||||
}
|
||||
if (oldValue != this.searchOptions.includeLoaded) {
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
var oldValue = searchOptions.includeLoaded;
|
||||
|
||||
searchOptions.includeLoaded = ($('#checkLoaded').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeLoaded) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
checkUnloaded: function () {
|
||||
var oldValue = this.searchOptions.includeUnloaded;
|
||||
if ($('#checkUnloaded').is(":checked") === true) {
|
||||
this.searchOptions.includeUnloaded = true;
|
||||
}
|
||||
else {
|
||||
this.searchOptions.includeUnloaded = false;
|
||||
}
|
||||
if (oldValue != this.searchOptions.includeUnloaded) {
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
var oldValue = searchOptions.includeUnloaded;
|
||||
|
||||
searchOptions.includeUnloaded = ($('#checkUnloaded').is(":checked") === true);
|
||||
|
||||
if (oldValue != searchOptions.includeUnloaded) {
|
||||
this.render();
|
||||
}
|
||||
},
|
||||
|
||||
setFilterValues: function () {
|
||||
$('#checkLoaded').attr('checked', this.searchOptions.includeLoaded);
|
||||
$('#checkUnloaded').attr('checked', this.searchOptions.includeUnloaded);
|
||||
$('#checkSystem').attr('checked', this.searchOptions.includeSystem);
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
$('#checkLoaded').attr('checked', searchOptions.includeLoaded);
|
||||
$('#checkUnloaded').attr('checked', searchOptions.includeUnloaded);
|
||||
$('#checkSystem').attr('checked', searchOptions.includeSystem);
|
||||
},
|
||||
search: function () {
|
||||
var searchOptions = this.collection.searchOptions;
|
||||
var searchPhrase = $('#searchInput').val().replace(/(^\s+|\s+$)/g, '');
|
||||
|
||||
if (searchPhrase === this.searchOptions.searchPhrase) {
|
||||
if (searchPhrase === searchOptions.searchPhrase) {
|
||||
return;
|
||||
}
|
||||
this.searchOptions.searchPhrase = searchPhrase;
|
||||
searchOptions.searchPhrase = searchPhrase;
|
||||
|
||||
this.render();
|
||||
},
|
||||
|
|
|
@ -53,7 +53,7 @@ var documentView = Backbone.View.extend({
|
|||
key,
|
||||
self.value2html(value, true),
|
||||
JSON.stringify(value),
|
||||
'<i class="icon-edit"></i>',
|
||||
"",
|
||||
""
|
||||
]);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ var documentView = Backbone.View.extend({
|
|||
"key"+arangoHelper.getRandomToken(),
|
||||
this.value2html("editme"),
|
||||
JSON.stringify("editme"),
|
||||
'edit',
|
||||
'<i class="icon-edit"></i>',
|
||||
'<button class="enabled" id="deleteRow"><img src="/_admin/html/img/icon_delete.png" width="16" height="16"></button>'
|
||||
]);
|
||||
|
||||
|
|
|
@ -4,12 +4,20 @@ var documentsView = Backbone.View.extend({
|
|||
documentsPerPage: 10,
|
||||
totalPages: 1,
|
||||
|
||||
collectionContext : {
|
||||
prev: null,
|
||||
next: null
|
||||
},
|
||||
|
||||
alreadyClicked: false,
|
||||
|
||||
el: '#content',
|
||||
table: '#documentsTableID',
|
||||
|
||||
events: {
|
||||
"click #collectionPrev" : "prevCollection",
|
||||
"click #collectionNext" : "nextCollection",
|
||||
|
||||
"click #documentsTableID tr" : "clicked",
|
||||
"click #deleteDoc" : "remove",
|
||||
"click #plusIconDoc" : "addDocument",
|
||||
|
@ -20,6 +28,23 @@ var documentsView = Backbone.View.extend({
|
|||
"click #documents_next" : "nextDocuments",
|
||||
"click #confirmDeleteBtn" : "confirmDelete"
|
||||
},
|
||||
|
||||
buildCollectionLink : function (collection) {
|
||||
return "#collection/" + encodeURIComponent(collection.get('name')) + '/documents/1';
|
||||
},
|
||||
|
||||
prevCollection : function () {
|
||||
if (this.collectionContext.prev !== null) {
|
||||
window.location.hash = this.buildCollectionLink(this.collectionContext.prev);
|
||||
}
|
||||
},
|
||||
|
||||
nextCollection : function () {
|
||||
if (this.collectionContext.next !== null) {
|
||||
window.location.hash = this.buildCollectionLink(this.collectionContext.next);
|
||||
}
|
||||
},
|
||||
|
||||
addDocument: function () {
|
||||
var collid = window.location.hash.split("/")[1];
|
||||
window.arangoDocumentStore.addDocument(collid);
|
||||
|
@ -76,8 +101,8 @@ var documentsView = Backbone.View.extend({
|
|||
var self = a.currentTarget;
|
||||
var aPos = $(this.table).dataTable().fnGetPosition(self);
|
||||
|
||||
// if row is the addnewdoc row
|
||||
if (aPos === 10) {
|
||||
var checkData = $(this.table).dataTable().fnGetData(self);
|
||||
if (checkData[0] === '') {
|
||||
this.addDocument();
|
||||
return;
|
||||
}
|
||||
|
@ -123,7 +148,7 @@ var documentsView = Backbone.View.extend({
|
|||
});
|
||||
$(self.table).dataTable().fnAddData([
|
||||
'',
|
||||
'<a id="plusIconDoc" style="padding-left: 30px">Neu hinzufügen</a>',
|
||||
'<a id="plusIconDoc" style="padding-left: 30px">Add document</a>',
|
||||
'<img src="/_admin/html/img/plus_icon.png" id="documentAddBtn"></img>'
|
||||
]);
|
||||
$(".prettify").snippet("javascript", {style: "nedit", menu: false, startText: false, transparent: true, showNum: false});
|
||||
|
@ -148,16 +173,19 @@ var documentsView = Backbone.View.extend({
|
|||
template: new EJS({url: '/_admin/html/js/templates/documentsView.ejs'}),
|
||||
|
||||
render: function() {
|
||||
this.collectionContext = window.arangoCollectionsStore.getPosition(this.colid);
|
||||
|
||||
$(this.el).html(this.template.text);
|
||||
this.breadcrumb();
|
||||
return this;
|
||||
},
|
||||
|
||||
breadcrumb: function () {
|
||||
var name = window.location.hash.split("/")[1];
|
||||
$('#transparentHeader').append(
|
||||
'<div class="breadcrumb">'+
|
||||
'<a class="activeBread" href="#">Collections</a>'+
|
||||
' > '+
|
||||
' > '+
|
||||
'<a class="disabledBread">'+name+'</a>'+
|
||||
'</div>'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue