summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2013-12-12 11:11:28 +0200
committerGarren Smith <garren.smith@gmail.com>2013-12-12 11:11:28 +0200
commit936edf85f362715f4fda5a3706799686b38cda68 (patch)
tree20cd3400d1ebf249432bea340e4c55408bacf5bb
parent9c641f1677f9d9cf27f3c76af803636d980c0929 (diff)
downloadcouchdb-936edf85f362715f4fda5a3706799686b38cda68.tar.gz
Fauxton: View fixes
On saving new view contiue to show edit index Add new design doc to collection on save Reload view list when bulk or single deleting design doc
-rw-r--r--src/fauxton/app/modules/documents/views.js30
-rw-r--r--src/fauxton/app/templates/documents/view_editor.html6
2 files changed, 28 insertions, 8 deletions
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index de21010cd..49c443d34 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -371,6 +371,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
that.model.collection.remove(that.model.id);
+ if (!!that.model.id.match('_design')) {
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
+ }
}, function(resp) {
FauxtonAPI.addNotification({
msg: "Failed to destroy your doc!",
@@ -639,6 +642,10 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
model.collection.remove(model.id);
+ console.log(model.id.match('_design'), !!model.id.match('_design'));
+ if (!!model.id.match('_design')) {
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
+ }
that.$('.bulk-delete').addClass('disabled');
}, function(resp) {
FauxtonAPI.addNotification({
@@ -1159,7 +1166,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
views: {},
language: "javascript"
};
- return new this.DocModel(doc, {database: this.database});
+ var ddoc = new this.DocModel(doc, {database: this.database});
+ this.collection.add(ddoc);
+ return ddoc;
} else {
var ddocName = this.$('#ddoc').val();
return this.collection.find(function (ddoc) {
@@ -1201,8 +1210,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
this.ddocID = options.ddocInfo.id;
this.viewName = options.viewName;
this.ddocInfo = new Documents.DdocInfo({_id: this.ddocID},{database: this.database});
- }
+ }
+ this.showIndex = false;
_.bindAll(this);
},
@@ -1285,6 +1295,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
ddoc.setDdocView(viewName, mapVal, reduceVal);
ddoc.save().then(function () {
+ that.mapEditor.editSaved();
+ that.reduceEditor && that.reduceEditor.editSaved();
+
FauxtonAPI.addNotification({
msg: "View has been saved.",
type: "success",
@@ -1295,9 +1308,13 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
var fragment = '/database/' + that.database.id +'/' + ddocName + '/_view/' + viewName;
FauxtonAPI.navigate(fragment, {trigger: false});
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs',{selectedTab: ddocName.replace('_design/','') + '_' + viewName});
-
that.newView = false;
+ that.ddocID = ddoc.id;
+ that.viewName = viewName;
+ that.ddocInfo = ddoc;
+ that.showIndex = true;
+ that.render();
+ FauxtonAPI.triggerRouteEvent('reloadDesignDocs',{selectedTab: ddocName.replace('_design/','') + '_' + viewName});
}
if (that.reduceFunStr !== reduceVal) {
@@ -1538,8 +1555,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
}
this.designDocSelector.updateDesignDoc();
- if (this.newView) {
+ if (this.newView || this.showIndex) {
this.showEditors();
+ this.showIndex = false;
} else {
this.$('#index').hide();
this.$('#index-nav').parent().removeClass('active');
@@ -1566,6 +1584,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
//this.reduceEditor.setValue(this.langTemplates[this.defaultLang].reduce);
}
+ this.mapEditor.editSaved();
+ this.reduceEditor && this.reduceEditor.editSaved();
},
cleanup: function () {
diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html
index 886562545..cf6aa26ad 100644
--- a/src/fauxton/app/templates/documents/view_editor.html
+++ b/src/fauxton/app/templates/documents/view_editor.html
@@ -13,10 +13,10 @@ the License.
-->
<div class="row">
<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
- <li class="active"> <a id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
+ <li class="active"> <a data-bypass="true" id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
<% if (!newView) { %>
- <li><a id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
- <li><a id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
+ <li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+ <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
<% } %>
</ul>
<div class="all-docs-list errors-container"></div>