couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject fauxton commit: updated refs/heads/master to e4f42a7
Date Wed, 10 Dec 2014 13:03:28 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 731717379 -> e4f42a7de


Revert "Allow editing documents from view"

This reverts commit 42cdf6886bb2062caa334485cc16b3fd5dcf5030.

This breaks the testsuite (bulkDelete.js)


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/e4f42a7d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/e4f42a7d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/e4f42a7d

Branch: refs/heads/master
Commit: e4f42a7de95be6f68895959da0d45d8a2937b270
Parents: 7317173
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Wed Dec 10 14:01:41 2014 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Wed Dec 10 14:02:41 2014 +0100

----------------------------------------------------------------------
 app/addons/documents/resources.js               | 17 ------
 app/addons/documents/routes-doc-editor.js       |  8 +--
 app/addons/documents/routes-documents.js        | 27 +++-------
 .../documents/templates/all_docs_item.html      | 13 ++---
 .../documents/templates/index_row_docular.html  | 29 +++++++++++
 .../tests/nightwatch/editDocumentsFromView.js   | 55 --------------------
 app/addons/documents/views-index.js             | 18 +++++--
 app/addons/documents/views.js                   |  6 +--
 .../custom-commands/clickWhenReady.js           | 12 -----
 .../custom-commands/createDocument.js           |  8 +--
 .../custom-commands/populateDatabase.js         |  2 +-
 test/nightwatch_tests/nightwatch_README.md      |  4 +-
 12 files changed, 61 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 58c17c6..1eaa6bb 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -89,14 +89,6 @@ function(app, FauxtonAPI, PagingCollection) {
       return this.docType() != "reduction";
     },
 
-    isFromView: function(){
-      return !this.id;
-    },
-
-    isReducedShown : function () {
-      return this.collection.params.reduce;
-    },
-
     isDdoc: function() {
       return this.docType() === "design doc";
     },
@@ -279,15 +271,6 @@ function(app, FauxtonAPI, PagingCollection) {
     isEditable: function() {
       return this.docType() != "reduction";
     },
-
-    isFromView: function(){
-      return !this.id;
-    },
-
-    isReducedShown : function () {
-      return this.collection.params.reduce;
-    },
-
     safeID: function() {
       var id = this.id || this.get("id");
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/routes-doc-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-doc-editor.js b/app/addons/documents/routes-doc-editor.js
index 4efed7c..83cca0b 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -39,8 +39,7 @@ function(app, FauxtonAPI, Documents, DocEditor, Databases) {
 
     routes: {
       "database/:database/:doc/code_editor": "code_editor",
-      "database/:database/:doc": "code_editor",
-      "database/:database/_design/:ddoc" :"showDesignDoc"
+      "database/:database/:doc": "code_editor"
     },
 
     events: {
@@ -71,11 +70,6 @@ function(app, FauxtonAPI, Documents, DocEditor, Databases) {
         model: this.doc,
         database: this.database
       }));
-
-    },
-
-    showDesignDoc: function (database, ddoc) {
-      this.code_editor(database, '_design/' + ddoc);
     },
 
     reRenderDoc: function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/routes-documents.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-documents.js b/app/addons/documents/routes-documents.js
index 0fd8d9e..3b49878 100644
--- a/app/addons/documents/routes-documents.js
+++ b/app/addons/documents/routes-documents.js
@@ -353,26 +353,13 @@ function(app, FauxtonAPI, Documents, Changes, Index, DocEditor, Databases,
Resou
         return [this.indexedDocs.urlRef("apiurl", urlParams), FauxtonAPI.constants.DOC_URLS.GENERAL];
       };
 
-      this.showQueryOptions(urlParams, ddoc, viewName);
-    },
-
-    showQueryOptions: function (urlParams, ddoc, viewName) {
-      var promise = this.designDocs.fetch({reset: true}),
-          that = this,
-          hasReduceFunction;
-
-      promise.then(function(resp) {
-        var design = _.findWhere(that.designDocs.models, {id: '_design/'+ddoc}); 
-        !_.isUndefined(hasReduceFunction = design.attributes.doc.views[viewName].reduce);
-
-        that.rightHeader.showQueryOptions();
-        that.rightHeader.resetQueryOptions({
-          queryParams: urlParams,
-          showStale: true,
-          hasReduce: hasReduceFunction,
-          viewName: viewName,
-          ddocName: ddoc
-        });
+      this.rightHeader.showQueryOptions();
+      this.rightHeader.resetQueryOptions({
+        queryParams: urlParams,
+        showStale: true,
+        hasReduce: true,
+        viewName: viewName,
+        ddocName: ddoc
       });
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/templates/all_docs_item.html
----------------------------------------------------------------------
diff --git a/app/addons/documents/templates/all_docs_item.html b/app/addons/documents/templates/all_docs_item.html
index 78a9b35..e0c62fc 100644
--- a/app/addons/documents/templates/all_docs_item.html
+++ b/app/addons/documents/templates/all_docs_item.html
@@ -20,18 +20,15 @@ the License.
 </div>
 <div class="doc-item">
   <header>
-    <span class="header-keylabel"><%- doc.isFromView() ? 'key' : 'id' %></span>
<span class="header-doc-id">"<%- docIdentifier %>"</span>
-    <% if (!doc.isReducedShown()) { %>
+    <span class="header-keylabel"><%- doc.isEditable() ? 'id' : 'key' %></span>
<span class="header-doc-id">"<%- docIdentifier %>"</span>
+
+  <% if (doc.isEditable()) { %>
     <div class="doc-edit-symbol pull-right">
-    <% if (doc.isFromView()) { %>
-      <a href="#<%- doc.url('app') %>">
-    <% } else {  %>
-      <a href="#<%- doc.url('web-index')%>">
-    <% } %>
+      <a href="#<%- doc.url('web-index') %>">
         <i class="fonticon-pencil"></i>
       </a>
     </div>
-    <% }; %>
+  <% } %>
   </header>
   <div class="doc-data">
     <pre class="prettyprint"><%- doc.prettyJSON() %></pre>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/app/addons/documents/templates/index_row_docular.html b/app/addons/documents/templates/index_row_docular.html
new file mode 100644
index 0000000..e8973ad
--- /dev/null
+++ b/app/addons/documents/templates/index_row_docular.html
@@ -0,0 +1,29 @@
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<% if (doc.isEditable()) { %>
+  <td class="select"><input type="checkbox"></td>
+<% } %>
+<td>
+  <div>
+    <pre class="prettyprint"><%- doc.prettyJSON() %></pre>
+
+      <div class="btn-group">
+        <a href="#<%= url %>" class="btn btn-small edits">Edit <%= doc.docType()
%></a>
+        <% if (doc.isEditable()) { %>
+          <button href="#" class="btn btn-small btn-danger delete" title="Delete this
document."><i class="icon icon-trash"></i></button>
+        <% } %>
+      </div>
+
+  </div>
+</td>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/tests/nightwatch/editDocumentsFromView.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/editDocumentsFromView.js b/app/addons/documents/tests/nightwatch/editDocumentsFromView.js
deleted file mode 100644
index 8ab9bcd..0000000
--- a/app/addons/documents/tests/nightwatch/editDocumentsFromView.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-module.exports = {
-  'Edit is allowed from default Map Views' : function (client) {
-    var newDatabaseName = client.globals.testDatabaseName,
-        newDocumentName = '_design/abc',
-        baseUrl = client.globals.test_settings.launch_url,
-        ddocContents = {
-          "views": {
-            "evens": {
-              "map": "function (doc) { if (doc.number%2 === 0){ emit(doc._id, doc.number);
} }",
-              "reduce" : "_count"
-            }
-          },
-          "language": "javascript"
-        };
-    
-    client
-      .loginToGUI()
-      .createDocument(newDocumentName, newDatabaseName, ddocContents )
-      .populateDatabase(newDatabaseName)
-
-      //navigate to 'evens' view (declared above), then click on first document's pencil
icon
-      .clickWhenReady('#dashboard-content a[href="#/database/' + newDatabaseName + '/_all_docs"]')
-      .clickWhenReady('#nav-header-abc')
-      .clickWhenReady('#nav-design-function-abcviews')
-      .clickWhenReady('#abc_evens')
-      .pause(1000) //why?
-      .clickWhenReady('a[href=\'#/database/fauxton-selenium-tests/document_10\']')
-
-      //navigated to editor
-      .waitForElementVisible('#editor-container', 10000, false)
-      .verify.urlContains('#/database/' + newDatabaseName +'/document_10');
-  },
-
-  'Edit is not allowed for Map Views where reduce is checked' : function (client) {
-    client
-      .clickWhenReady('#doc-actions .cancel-button')
-      .clickWhenReady('#toggle-query')
-      .clickWhenReady('#query-options-tray label[for="qoReduce"]')
-      .clickWhenReady('#button-options button[type="submit"]')
-      .waitForElementNotPresent('i.fonticon-pencil',10000)
-    .end();
-  }
-};

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/views-index.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-index.js b/app/addons/documents/views-index.js
index b726e0c..6fda62c 100644
--- a/app/addons/documents/views-index.js
+++ b/app/addons/documents/views-index.js
@@ -33,6 +33,16 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, QueryOption
 
   var Views = {};
 
+
+  // this is a temporary workaround until I hear of a better on. The problem is that on initial
page load (i.e. a refresh
+  // of the View page) the afterRender() functions calls a FauxtonAPI.triggerRouteEvent().
That causes this View to be
+  // rendered twice (at least, the afterRender() function then gets called twice) - and that
causes the header content to
+  // disappear. This var tracks whether the View has been rendered and if not, doesn't call
the triggerRouteEvent. btw,
+  // the reason the triggerRouteEvent('resetQueryOptions') code is there is that it ensures
the Query Options tray shows
+  // the appropriate content for the current View (i.e. hasReduce or not)
+  var hasRenderedOnce = false;
+
+
   Views.ViewEditor = FauxtonAPI.View.extend({
     template: "addons/documents/templates/view_editor",
     builtinReduces: ['_sum', '_count', '_stats'],
@@ -444,11 +454,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
QueryOption
     },
 
     afterRender: function() {
-
-      var queryOptionsMissing = $("#query-options").html() === "";
-      
-      if (this.params && !this.newView && queryOptionsMissing) {
-
+      if (this.params && !this.newView && hasRenderedOnce) {
         FauxtonAPI.triggerRouteEvent('resetQueryOptions', {
           queryParams: this.params,
           hasReduce: this.hasReduce(),
@@ -467,6 +473,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, QueryOption
         this.$('#index-nav').parent().removeClass('active');
       }
 
+      // note that this View has been rendered
+      hasRenderedOnce = true;
     },
 
     showEditors: function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index a4dd5a5..06d092c 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -196,7 +196,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
     },
 
     events: {
-      "dblclick .doc-item": "edit"
+      "dblclick pre.prettyprint": "edit"
     },
 
     attributes: function() {
@@ -219,9 +219,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, Views, QueryOptions)
 
     edit: function(event) {
       event.preventDefault();
-      if (!this.model.isReducedShown()) {
-        FauxtonAPI.navigate(this.model.url('app'));
-      }
+      FauxtonAPI.navigate("#" + this.model.url('web-index'));
     }
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/test/nightwatch_tests/custom-commands/clickWhenReady.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/clickWhenReady.js b/test/nightwatch_tests/custom-commands/clickWhenReady.js
deleted file mode 100644
index cae33e8..0000000
--- a/test/nightwatch_tests/custom-commands/clickWhenReady.js
+++ /dev/null
@@ -1,12 +0,0 @@
-exports.command = function (element, waitTime) {
-
-  if(waitTime === undefined){
-    waitTime = 10000;
-  }
-
-  this
-    .waitForElementVisible(element, waitTime, false)
-    .click(element)
-
-  return this;
-};

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/test/nightwatch_tests/custom-commands/createDocument.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/createDocument.js b/test/nightwatch_tests/custom-commands/createDocument.js
index 4d08505..388dc5a 100644
--- a/test/nightwatch_tests/custom-commands/createDocument.js
+++ b/test/nightwatch_tests/custom-commands/createDocument.js
@@ -9,16 +9,12 @@ function CreateDocument () {
 // inherit from node's event emitter
 util.inherits(CreateDocument, events.EventEmitter);
 
-CreateDocument.prototype.command = function (documentName, databaseName, docContents) {
+CreateDocument.prototype.command = function (documentName, databaseName) {
   var that = this,
       nano = helpers.getNanoInstance(),
       database = nano.use(databaseName);
 
-  if (docContents === undefined) {
-    docContents = { dummyKey: "testingValue" }; 
-  }
-
-  database.insert(docContents, documentName, function (err, body, header) {
+  database.insert({ dummyKey: "testingValue" }, documentName, function (err, body, header)
{
   
     if (err) {
       console.log('Error in nano CreateDocument Function: '+documentName+', in database:
'+databaseName, err.message);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/test/nightwatch_tests/custom-commands/populateDatabase.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/populateDatabase.js b/test/nightwatch_tests/custom-commands/populateDatabase.js
index bf01c97..ea1cbf8 100644
--- a/test/nightwatch_tests/custom-commands/populateDatabase.js
+++ b/test/nightwatch_tests/custom-commands/populateDatabase.js
@@ -19,7 +19,7 @@ PopulateDatabase.prototype.command = function (databaseName) {
     function () { return i < 20; },
     function (cb) {
         i++;
-        var document_id = 'document_'+ i;
+        var document_id = 'document_ '+ i;
         database.insert({ number: i }, document_id, cb);
     },
     function (err) {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e4f42a7d/test/nightwatch_tests/nightwatch_README.md
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/nightwatch_README.md b/test/nightwatch_tests/nightwatch_README.md
index 761d6f8..a18d6a7 100644
--- a/test/nightwatch_tests/nightwatch_README.md
+++ b/test/nightwatch_tests/nightwatch_README.md
@@ -51,10 +51,8 @@ has failed, and will not exit or skip subsequent tests.
 3. `.waitForElementNotPresent()`, `.waitForElementNotVisible()`, `.waitForElementPresent()`,
`.waitForElementVisible()`, 
 will exit testing by default if the Element is not found. There is a third argument, 'abortOnFailure',
if you set this 
 to 'false', the rest of the tests will continue even if this assertion fails.
-> there is a custom function called clickWhenReady which will wait for an element to visible,
then click on it
-
 4. Sometimes `.click()` doesn't work reliably (most likely if the element you are clicking
on doesn't have an 
-individual ID selector). You can use jquery to simulate a click by using `.execute('$("#CSS
Selector.HERE").click();')`.  
+individual ID selector). You can use jquery to simulate a click by using `.execute($("#CSS
Selector.HERE").click();)`
 5. The function `.pause(time)` is sometimes necessary, although we have tried to avoid excessive
use of a hard coded 
 pausing. Instead try and make use of the `.waitForElement` functions instead of `.pause(time)`.

 


Mime
View raw message