You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2015/03/26 11:49:52 UTC
[2/3] fauxton commit: updated refs/heads/master to 96d31bc
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/routes-index-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-index-editor.js b/app/addons/documents/routes-index-editor.js
index 4905f3a..38c9566 100644
--- a/app/addons/documents/routes-index-editor.js
+++ b/app/addons/documents/routes-index-editor.js
@@ -21,13 +21,13 @@ define([
'addons/documents/views-index',
'addons/databases/base',
'addons/fauxton/components',
- 'addons/documents/pagination/actions',
- 'addons/documents/pagination/stores'
+ 'addons/documents/pagination/stores',
+ 'addons/documents/index-results/actions'
],
function (app, FauxtonAPI, Helpers, BaseRoute, Documents, Index,
- Databases, Components, PaginationActions, PaginationStores) {
+ Databases, Components, PaginationStores, IndexResultsActions) {
var IndexEditorAndResults = BaseRoute.extend({
@@ -41,12 +41,6 @@ function (app, FauxtonAPI, Helpers, BaseRoute, Documents, Index,
}
},
- events: {
- 'route:updateAllDocs': 'updateAllDocsFromView',
- 'route:paginate': 'paginate',
- 'route:perPageChange': 'perPageChange',
- },
-
initialize: function (route, masterLayout, options) {
var databaseName = options[0];
@@ -96,7 +90,10 @@ function (app, FauxtonAPI, Helpers, BaseRoute, Documents, Index,
}
});
- PaginationActions.newPagination(this.indexedDocs);
+ IndexResultsActions.newResultsList({
+ collection: this.indexedDocs,
+ deleteable: false
+ });
this.viewEditor = this.setView('#left-content', new Index.ViewEditorReact({
viewName: viewName,
@@ -106,15 +103,7 @@ function (app, FauxtonAPI, Helpers, BaseRoute, Documents, Index,
designDocId: '_design/' + decodeDdoc
}));
- this.documentsView = this.createViewDocumentsView({
- designDoc: decodeDdoc,
- docParams: docParams,
- urlParams: urlParams,
- database: this.database,
- indexedDocs: this.indexedDocs,
- designDocs: this.designDocs,
- view: viewName
- });
+ this.resultList = this.setView('#dashboard-lower-content', new Index.ViewResultListReact({}));
this.apiUrl = function () {
return [this.indexedDocs.urlRef(urlParams), FauxtonAPI.constants.DOC_URLS.GENERAL];
@@ -150,9 +139,11 @@ function (app, FauxtonAPI, Helpers, BaseRoute, Documents, Index,
newDesignDoc: newDesignDoc
}));
- this.resultList = this.setView('#dashboard-lower-content', new Index.ViewResultListReact({
- documents: null
- }));
+ this.resultList = this.setView('#dashboard-lower-content', new Index.ViewResultListReact({}));
+ IndexResultsActions.newResultsList({
+ collection: [],
+ deleteable: false
+ });
}
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/shared-routes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/shared-routes.js b/app/addons/documents/shared-routes.js
index 497d059..4766203 100644
--- a/app/addons/documents/shared-routes.js
+++ b/app/addons/documents/shared-routes.js
@@ -97,20 +97,6 @@ define([
];
},
- createViewDocumentsView: function (options) {
- if (!options.docParams) {
- options.docParams = {};
- }
-
- return this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- database: options.database,
- collection: options.indexedDocs,
- viewList: true,
- ddocInfo: this.ddocInfo(options.designDoc, options.designDocs, options.view),
- docParams: options.docParams
- }));
- },
-
ddocInfo: function (designDoc, designDocs, view) {
return {
id: "_design/" + designDoc,
@@ -130,63 +116,6 @@ define([
urlParams: urlParams,
docParams: _.extend(params, {limit: limit})
};
- },
-
- updateAllDocsFromView: function (event) {
- var view = event.view,
- params = this.createParams(),
- urlParams = params.urlParams,
- docParams = params.docParams,
- ddoc = event.ddoc,
- pageSize = PaginationStores.indexPaginationStore.getPerPage(),
- collection;
-
- if (event.allDocs) {
- this.eventAllDocs = true; // this is horrible. But I cannot get the trigger not to fire the route!
- this.database.buildAllDocs(docParams);
- collection = this.database.allDocs;
- collection.paging.pageSize = pageSize;
- } else {
- collection = this.indexedDocs = new Documents.IndexCollection(null, {
- database: this.database,
- design: ddoc,
- view: view,
- params: docParams,
- paging: {
- pageSize: pageSize
- }
- });
-
- if (!this.documentsView) {
- this.documentsView = this.createViewDocumentsView({
- designDoc: ddoc,
- docParams: docParams,
- urlParams: urlParams,
- database: this.database,
- indexedDocs: this.indexedDocs,
- designDocs: this.designDocs,
- view: view
- });
- }
- }
-
- // this will lazily initialize all sub-views and render them
- this.documentsView.forceRender();
- },
-
- perPageChange: function (perPage) {
- this.documentsView.forceRender();
- this.documentsView.collection.pageSizeReset(perPage, {fetch: false});
- },
-
- paginate: function (options) {
- var collection = this.documentsView.collection;
- this.documentsView.collection.reset(collection);
-
- this.documentsView.forceRender();
-
- collection.paging.pageSize = options.perPage;
- var promise = collection[options.direction]({fetch: false});
}
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/actionsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/actionsSpec.js b/app/addons/documents/tests/actionsSpec.js
index b49124c..605298a 100644
--- a/app/addons/documents/tests/actionsSpec.js
+++ b/app/addons/documents/tests/actionsSpec.js
@@ -16,9 +16,11 @@ define([
'addons/documents/resources',
'addons/documents/index-editor/actiontypes',
'testUtils',
+ 'addons/documents/index-results/actions',
'addons/documents/base'
-], function (FauxtonAPI, Actions, Documents, ActionTypes, testUtils) {
+], function (FauxtonAPI, Actions, Documents, ActionTypes, testUtils, IndexResultsActions) {
var assert = testUtils.assert;
+ var restore = testUtils.restore;
FauxtonAPI.router = new FauxtonAPI.Router([]);
@@ -46,8 +48,9 @@ define([
});
afterEach(function () {
- FauxtonAPI.navigate.restore && FauxtonAPI.navigate.restore();
- FauxtonAPI.triggerRouteEvent.restore && FauxtonAPI.triggerRouteEvent.restore();
+ restore(FauxtonAPI.navigate);
+ restore(FauxtonAPI.triggerRouteEvent);
+ restore(IndexResultsActions.reloadResultsList);
});
it('shows a notification if no design doc id given', function () {
@@ -148,8 +151,8 @@ define([
assert.ok(spy.getCall(0).args[0].match(/_view\/test-view/));
});
- it('triggers update all docs', function () {
- var spy = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
+ it('triggers reload results list', function () {
+ var spy = sinon.spy(IndexResultsActions, 'reloadResultsList');
var viewInfo = {
viewName: 'test-view',
@@ -175,7 +178,6 @@ define([
Actions.saveView(viewInfo);
assert.ok(spy.calledOnce);
- assert.equal(spy.getCall(0).args[0], 'updateAllDocs');
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/headerSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/headerSpec.react.jsx b/app/addons/documents/tests/headerSpec.react.jsx
index ce914af..782a9d3 100644
--- a/app/addons/documents/tests/headerSpec.react.jsx
+++ b/app/addons/documents/tests/headerSpec.react.jsx
@@ -15,18 +15,18 @@ define([
'addons/documents/header/header.stores',
'addons/documents/header/header.actions',
- // importing the legacy
- 'addons/documents/views',
- 'addons/documents/resources',
'addons/databases/base',
- 'addons/fauxton/components',
- 'addons/documents/pagination/actions',
+ 'addons/documents/resources',
+ 'addons/documents/index-results/actions',
+ 'addons/documents/index-results/stores',
'testUtils',
'react'
-], function (FauxtonAPI, Views, Stores, Actions, Documents, Resources, Databases, Components, PaginationActions, utils, React) {
+], function (FauxtonAPI, Views, Stores, Actions, Databases, Resources,
+ IndexResultsActions, IndexResultsStore, utils, React) {
var assert = utils.assert;
+ var restore = utils.restore;
var TestUtils = React.addons.TestUtils;
describe('Header Controller', function () {
@@ -62,12 +62,9 @@ define([
});
describe('Bulkdocument Headerbar Controller', function () {
- var container, header, viewSandbox, bulkDeleteDocCollection;
+ var container, header;
beforeEach(function () {
- // needed for "pressing SelectAll should fill the delete-bulk-docs-collection"
- var ViewSandbox = utils.ViewSandbox;
var database = new Databases.Model({id: 'registry'});
- bulkDeleteDocCollection = new Resources.BulkDeleteDocCollection([], {databaseId: 'registry'});
database.allDocs = new Resources.AllDocs({_id: "ente"}, {
database: database,
@@ -75,40 +72,32 @@ define([
params: {}
});
- PaginationActions.newPagination(database.allDocs);
-
- var view = new Documents.Views.AllDocsList({
- viewList: false,
- bulkDeleteDocsCollection: bulkDeleteDocCollection,
+ IndexResultsActions.newResultsList({
collection: database.allDocs,
+ deleteable: false
});
- viewSandbox = new ViewSandbox();
- viewSandbox.renderView(view);
-
container = document.createElement('div');
});
afterEach(function () {
- bulkDeleteDocCollection.off();
- viewSandbox.remove();
-
React.unmountComponentAtNode(container);
+ restore(Actions.collapseDocuments);
});
- it('should trigger an event to communicate with the backbone elements', function () {
- var spy = sinon.spy(FauxtonAPI.Events, 'trigger');
+ it('should trigger action', function () {
+ var spy = sinon.spy(Actions, 'collapseDocuments');
header = TestUtils.renderIntoDocument(<Views.BulkDocumentHeaderController />, container);
TestUtils.Simulate.click($(header.getDOMNode()).find('.control-collapse')[0]);
assert.ok(spy.calledOnce);
});
- it('pressing SelectAll should fill the delete-bulk-docs-collection', function () {
+ it('pressing SelectAll should fill the selected items list', function () {
TestUtils.Simulate.click($(header.getDOMNode()).find('.control-select-all')[0]);
- assert.equal(bulkDeleteDocCollection.length, 1);
+ assert.equal(IndexResultsStore.indexResultsStore.getSelectedItemsLength(), 1);
});
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/nightwatch/deletesDocument.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/deletesDocument.js b/app/addons/documents/tests/nightwatch/deletesDocument.js
index 1f46bc1..4709f25 100644
--- a/app/addons/documents/tests/nightwatch/deletesDocument.js
+++ b/app/addons/documents/tests/nightwatch/deletesDocument.js
@@ -25,11 +25,10 @@ module.exports = {
.click('#dashboard-content a[href="#/database/' + newDatabaseName + '/_all_docs"]')
.waitForElementVisible('label[for="checkbox-' + newDocumentName + '"]', waitTime, false)
.click('label[for="checkbox-' + newDocumentName + '"]')
- .click('.control-toggle-alternative-header')
.waitForElementPresent('.control-select-all', waitTime, false)
.click('.control-delete')
.acceptAlert()
- .waitForElementVisible('#global-notifications .alert.alert-info', waitTime, false)
+ .waitForElementVisible('.alert.alert-info', waitTime, false)
.url(baseUrl + '/' + newDatabaseName + '/_all_docs')
.waitForElementPresent('pre', waitTime, false)
.getText('pre', function (result) {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/nightwatch/paginateView.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/paginateView.js b/app/addons/documents/tests/nightwatch/paginateView.js
index a711267..6353e13 100644
--- a/app/addons/documents/tests/nightwatch/paginateView.js
+++ b/app/addons/documents/tests/nightwatch/paginateView.js
@@ -12,7 +12,7 @@
module.exports = {
- 'change number of items per page': function (client) {
+ 'change number of items per page': function (client) {
/*jshint multistr: true */
var waitTime = 10000,
newDatabaseName = client.globals.testDatabaseName,
@@ -27,10 +27,11 @@ module.exports = {
// hack to get select working by clicking on it and using keyboard to select
// http://www.w3.org/TR/2012/WD-webdriver-20120710/
.keys(['\uE013', '\uE006'])
- .waitForElementNotPresent('.spinner', waitTime)
+ .waitForElementNotPresent('div[data-id="document_9"]', waitTime)
.execute(function () {
return $('.doc-row').length;
}, function (result) {
+ console.log(result.value);
client.assert.equal(result.value, 10);
})
.end();
@@ -50,12 +51,11 @@ module.exports = {
.click('#select-per-page')
// http://www.w3.org/TR/2012/WD-webdriver-20120710/
.keys(['\uE013', '\uE006'])
- .waitForElementNotPresent('.spinner', waitTime)
.click('#next')
- .waitForElementNotPresent('.spinner', waitTime)
+ .waitForElementNotPresent('div[data-id="document_1"]', waitTime)
.waitForElementPresent('div[data-id="document_19"]', waitTime)
.click('#previous')
- .waitForElementNotPresent('.spinner', waitTime)
+ .waitForElementNotPresent('div[data-id="document_19"]', waitTime)
.waitForElementPresent('div[data-id="document_1"]', waitTime)
.end();
},
@@ -74,13 +74,11 @@ module.exports = {
.click('#select-per-page')
// http://www.w3.org/TR/2012/WD-webdriver-20120710/
.keys(['\uE013', '\uE006'])
- .waitForElementNotPresent('.spinner', waitTime)
.click('#next')
- .waitForElementNotPresent('.spinner', waitTime)
+ .waitForElementNotPresent('div[data-id="document_1"]', waitTime)
.click('#select-per-page')
// http://www.w3.org/TR/2012/WD-webdriver-20120710/
.keys(['\uE013', '\uE006'])
- .waitForElementNotPresent('.spinner', waitTime)
.waitForElementPresent('div[data-id="document_1"]', waitTime)
.end();
}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/resourcesSpec.js b/app/addons/documents/tests/resourcesSpec.js
index ad480f2..11181ef 100644
--- a/app/addons/documents/tests/resourcesSpec.js
+++ b/app/addons/documents/tests/resourcesSpec.js
@@ -10,12 +10,13 @@
// License for the specific language governing permissions and limitations under
// the License.
define([
+ 'api',
'addons/documents/resources',
'testUtils',
'addons/documents/base'
-], function (Models, testUtils) {
+], function (FauxtonAPI, Models, testUtils) {
var assert = testUtils.assert;
describe('IndexCollection', function () {
@@ -49,9 +50,9 @@ define([
it('does not remove an id attribute', function () {
var res = doc.parse({
- _id: "be31e531fe131bdf416b479ac1000484",
- _rev: "4-3a1b9f4b988b413e9245cd250769da72",
- id: "foo"
+ _id: 'be31e531fe131bdf416b479ac1000484',
+ _rev: '4-3a1b9f4b988b413e9245cd250769da72',
+ id: 'foo'
});
assert.equal(res.id, 'foo');
});
@@ -62,8 +63,8 @@ define([
// {"ok":true,"id":"mycustomid","rev":"18-9cdeb1b121137233e3466b06a1780c29"}
// and our Model will think it has the id "mycustomid" instead of "foo"
var res = doc.parse({
- id: "be31e531fe131bdf416b479ac1000484",
- _rev: "4-3a1b9f4b988b413e9245cd250769da72",
+ id: 'be31e531fe131bdf416b479ac1000484',
+ _rev: '4-3a1b9f4b988b413e9245cd250769da72',
ok: true
});
assert.notOk(res.id);
@@ -91,7 +92,7 @@ define([
describe('QueryParams', function () {
describe('parse', function () {
it('should not parse arbitrary parameters', function () {
- var params = {"foo": "[1]]"};
+ var params = {'foo': '[1]]'};
var result = Models.QueryParams.parse(params);
assert.deepEqual(result, params);
@@ -99,29 +100,29 @@ define([
it('parses startkey, endkey', function () {
var params = {
- "startkey":"[\"a\",\"b\"]",
- "endkey":"[\"c\",\"d\"]"
+ 'startkey':'[\"a\",\"b\"]',
+ 'endkey':'[\"c\",\"d\"]'
};
var result = Models.QueryParams.parse(params);
assert.deepEqual(result, {
- "startkey": ["a", "b"],
- "endkey": ["c", "d"]
+ 'startkey': ['a', 'b'],
+ 'endkey': ['c', 'd']
});
});
it('parses key', function () {
var params = {
- "key":"[1,2]"
+ key:'[1,2]'
};
var result = Models.QueryParams.parse(params);
- assert.deepEqual(result, {"key": [1, 2]});
+ assert.deepEqual(result, {'key': [1, 2]});
});
it('does not modify input', function () {
var params = {
- "key":"[\"a\",\"b\"]"
+ key:'[\"a\",\"b\"]'
};
var clone = _.clone(params);
var result = Models.QueryParams.parse(params);
@@ -132,7 +133,7 @@ define([
describe('stringify', function () {
it('should not stringify arbitrary parameters', function () {
- var params = {"foo": [1, 2, 3]};
+ var params = {'foo': [1, 2, 3]};
var result = Models.QueryParams.stringify(params);
assert.deepEqual(result, params);
@@ -140,27 +141,27 @@ define([
it('stringifies startkey, endkey', function () {
var params = {
- "startkey": ["a", "b"],
- "endkey": ["c", "d"]
+ 'startkey': ['a', 'b'],
+ 'endkey': ['c', 'd']
};
var result = Models.QueryParams.stringify(params);
assert.deepEqual(result, {
- "startkey":"[\"a\",\"b\"]",
- "endkey":"[\"c\",\"d\"]"
+ 'startkey':'[\"a\",\"b\"]',
+ 'endkey':'[\"c\",\"d\"]'
});
});
it('stringifies key', function () {
- var params = {"key":[ "a", "b"]};
+ var params = {'key':[ 'a', 'b']};
var result = Models.QueryParams.stringify(params);
- assert.deepEqual(result, { "key": "[\"a\",\"b\"]" });
+ assert.deepEqual(result, { 'key': '[\"a\",\"b\"]' });
});
it('does not modify input', function () {
- var params = {"key": ["a", "b"]};
+ var params = {'key': ['a', 'b']};
var clone = _.clone(params);
var result = Models.QueryParams.stringify(params);
@@ -169,10 +170,10 @@ define([
it('is symmetrical with parse', function () {
var params = {
- "startkey": ["a", "b"],
- "endkey": ["c", "d"],
- "foo": "[1,2]",
- "bar": "abc"
+ 'startkey': ['a', 'b'],
+ 'endkey': ['c', 'd'],
+ 'foo': '[1,2]',
+ 'bar': 'abc'
};
var clone = _.clone(params);
@@ -187,6 +188,7 @@ define([
describe('Bulk Delete', function () {
var databaseId = 'ente',
collection,
+ promise,
values;
values = [{
@@ -209,9 +211,11 @@ define([
collection = new Models.BulkDeleteDocCollection(values, {
databaseId: databaseId
});
+
+ promise = FauxtonAPI.Deferred();
});
- it("contains the models", function () {
+ it('contains the models', function () {
collection = new Models.BulkDeleteDocCollection(values, {
databaseId: databaseId
});
@@ -219,45 +223,89 @@ define([
assert.equal(collection.length, 3);
});
- it("clears the memory if no errors happened", function () {
+ it('clears the memory if no errors happened', function () {
collection.handleResponse([
- {"ok": true, "id": "1", "rev": "10-72cd2edbcc0d197ce96188a229a7af01"},
- {"ok": true, "id": "2", "rev": "6-da537822b9672a4b2f42adb1be04a5b1"}
- ]);
+ {'ok': true, 'id': '1', 'rev': '10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok': true, 'id': '2', 'rev': '6-da537822b9672a4b2f42adb1be04a5b1'}
+ ], promise);
assert.equal(collection.length, 1);
});
- it("triggers a removed event with all ids", function () {
+ it('triggers a removed event with all ids', function () {
collection.listenToOnce(collection, 'removed', function (ids) {
assert.deepEqual(ids, ['Deferred', 'DeskSet']);
});
collection.handleResponse([
- {"ok": true, "id": "Deferred", "rev":"10-72cd2edbcc0d197ce96188a229a7af01"},
- {"ok": true, "id": "DeskSet", "rev":"6-da537822b9672a4b2f42adb1be04a5b1"}
- ]);
+ {'ok': true, 'id': 'Deferred', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok': true, 'id': 'DeskSet', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'}
+ ], promise);
});
- it("triggers a error event with all errored ids", function () {
+ it('triggers a error event with all errored ids', function () {
collection.listenToOnce(collection, 'error', function (ids) {
assert.deepEqual(ids, ['Deferred']);
});
collection.handleResponse([
- {"error": "confclict", "id": "Deferred", "rev":"10-72cd2edbcc0d197ce96188a229a7af01"},
- {"ok": true, "id": "DeskSet", "rev": "6-da537822b9672a4b2f42adb1be04a5b1"}
- ]);
+ {'error':'conflict', 'id':'Deferred', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok':true, 'id':'DeskSet', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'}
+ ], promise);
});
- it("removes successfull deleted from the collection but keeps one with errors", function () {
+ it('removes successfull deleted from the collection but keeps one with errors', function () {
collection.handleResponse([
- {"error": "confclict", "id": "1", "rev": "10-72cd2edbcc0d197ce96188a229a7af01"},
- {"ok": true, "id":"2", "rev": "6-da537822b9672a4b2f42adb1be04a5b1"},
- {"error": "conflict", "id":"3", "rev": "6-da537822b9672a4b2f42adb1be04a5b1"}
- ]);
+ {'error':'conflict', 'id':'1', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok':true, 'id':'2', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'},
+ {'error':'conflict', 'id':'3', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'}
+ ], promise);
assert.ok(collection.get('1'));
assert.ok(collection.get('3'));
assert.notOk(collection.get('2'));
});
+
+ it('triggers resolve for successful delete', function () {
+ var spy = sinon.spy();
+ promise.then(spy);
+
+ collection.handleResponse([
+ {'ok':true, 'id':'Deferred', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok':true, 'id':'DeskSet', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'}
+ ], promise);
+
+ assert.ok(spy.calledOnce);
+
+ });
+
+ it('triggers resolve for successful delete with errors as well', function () {
+ var spy = sinon.spy();
+ promise.then(spy);
+ var ids = {
+ errorIds: ['1'],
+ successIds: ['Deferred', 'DeskSet']
+ };
+
+ collection.handleResponse([
+ {'ok':true, 'id':'Deferred', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ {'ok':true, 'id':'DeskSet', 'rev':'6-da537822b9672a4b2f42adb1be04a5b1'},
+ {'error':'conflict', 'id':'1', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'},
+ ], promise);
+
+ assert.ok(spy.calledWith(ids));
+ });
+
+ it('triggers reject for failed delete', function () {
+ var spy = sinon.spy();
+ promise.fail(spy);
+
+ collection.handleResponse([
+ {'error':'conflict', 'id':'1', 'rev':'10-72cd2edbcc0d197ce96188a229a7af01'}
+ ], promise);
+
+ assert.ok(spy.calledWith(['1']));
+
+ });
+
+
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/routeSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/routeSpec.js b/app/addons/documents/tests/routeSpec.js
index 1e14302..966fbb7 100644
--- a/app/addons/documents/tests/routeSpec.js
+++ b/app/addons/documents/tests/routeSpec.js
@@ -26,16 +26,5 @@ define([
assert.equal(typeof routeObj.rightHeader, 'object');
});
- // after saving a new CouchDB-View we are calling the updateAllDocsFromView function.
- // The backbone-view AllDocsList is lazily initializing other views, in particular the
- // view AllDocsNumber and the pagination in the beforeRender method.
- // That means the we can not access .setCollection and .perPage from outside
- // before we render the view.
- it('does not fail because of lazy initializing race conditions', function () {
- var routeObj = new DocumentRoute(null, null, ['test']);
- routeObj.updateAllDocsFromView({ddoc: "_design/asdfsadf", view: "newView"});
-
- assert.equal(typeof routeObj.documentsView, 'object');
- });
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/viewsSpec.js b/app/addons/documents/tests/viewsSpec.js
deleted file mode 100644
index 0479762..0000000
--- a/app/addons/documents/tests/viewsSpec.js
+++ /dev/null
@@ -1,29 +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.
-define([
- 'addons/documents/views',
- 'addons/documents/resources',
- 'addons/databases/base',
- 'addons/fauxton/components',
- 'testUtils'
-], function (Documents, Resources, Databases, Components, testUtils) {
- var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox,
- viewSandbox;
-
- describe('AllDocsList', function () {
- it('should load', function () {
- assert.equal(typeof Documents.Views.AllDocsList, 'function');
- });
- });
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index dcb5988..dcd607d 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -25,7 +25,7 @@ define([
'addons/documents/header/header.react',
'addons/documents/header/header.actions',
'addons/documents/pagination/pagination.react',
- 'addons/documents/pagination/actions',
+ 'addons/documents/index-results/actions',
'addons/documents/pagination/stores',
//plugins
@@ -34,7 +34,7 @@ define([
function (app, FauxtonAPI, Components, Documents,
Databases, Views, QueryOptions, ReactHeader, ReactHeaderActions,
- ReactPagination, PaginationActions, PaginationStores) {
+ ReactPagination, IndexResultsActions, PaginationStores) {
function showError (msg) {
FauxtonAPI.addNotification({
@@ -269,262 +269,6 @@ function (app, FauxtonAPI, Components, Documents,
}
});
- Views.AllDocsList = FauxtonAPI.View.extend({
- template: "addons/documents/templates/all_docs_list",
-
- className: function () {
- if (this.viewList) {
- return '';
- }
- return 'show-select';
- },
-
- events: {
- 'change input': 'toggleDocument'
- },
-
- initialize: function (options) {
- this.rows = {};
-
- this.viewList = !!options.viewList;
-
- if (options.ddocInfo) {
- this.designDocs = options.ddocInfo.designDocs;
- this.ddocID = options.ddocInfo.id;
- }
- this.docParams = options.docParams || {};
- this.expandDocs = true;
-
- // some doclists don't have an option to delete
- if (!this.viewList) {
- this.bulkDeleteDocsCollection = options.bulkDeleteDocsCollection;
- }
- },
-
- removeDocuments: function (ids) {
- FauxtonAPI.when(ids.map(function (id) {
- return this.removeDocument(id);
- }.bind(this))).done(function () {
- FauxtonAPI.triggerRouteEvent('perPageChange', PaginationStores.indexPaginationStore.documentsLeftToFetch());
- FauxtonAPI.addNotification({
- msg: 'Successfully deleted your docs',
- clear: true
- });
-
- }.bind(this));
- },
-
- removeDocument: function (id) {
- var that = this,
- deferred = FauxtonAPI.Deferred();
-
- if (!this.rows[id]) {
- return;
- }
-
- this.rows[id].$el.fadeOut('slow', function () {
- that.rows[id].remove();
- deferred.resolve();
- });
-
- return deferred;
- },
-
- showError: function (ids) {
- if (ids) {
- showError('Failed to delete: ' + ids.join(', '));
- return;
- }
-
- showError('Failed to delete your document!');
- },
-
- toggleDocument: function (event) {
- var $row = this.$(event.target).closest('.doc-row'),
- docId = $row.attr('data-id'),
- rev = this.collection.get(docId).get('_rev'),
- data = {_id: docId, _rev: rev, _deleted: true};
-
- if (!$row.hasClass('js-to-delete')) {
- this.bulkDeleteDocsCollection.add(data);
- $row.find('.js-row-select').prop('checked', true);
- } else {
- this.bulkDeleteDocsCollection.remove(this.bulkDeleteDocsCollection.get(docId));
- $row.find('.js-row-select').prop('checked', false);
- }
-
- $row.toggleClass('js-to-delete');
-
- ReactHeaderActions.updateDocumentCount({
- selectedOnPage: this.$('.js-to-delete').length,
- documentsOnPageCount: this.$('.doc-row').length
- });
- },
-
- establish: function () {
- if (this.newView) { return null; }
-
- return this.collection.fetch({reset: true}).then(function () {
- PaginationActions.collectionReset();
- }, function (xhr, error, options) {
- // TODO: handle error requests that slip through
- // This should just throw a notification, not break the page
- var errorMsg = 'Bad Request';
-
- try {
- var responseText = JSON.parse(xhr.responseText);
- if (responseText.reason) {
- errorMsg = responseText.reason;
- }
- } catch (e) {
- console.log(e);
- }
-
- FauxtonAPI.addNotification({
- msg: errorMsg,
- type: "error",
- clear: true
- });
- });
- },
-
- toggleSelectAll: function (on) {
- this.selectAllBasedOnBoolean(on);
- },
-
- selectAllBasedOnBoolean: function (isActive) {
- var $allDocs = this.$('#doc-list'),
- $rows = $allDocs.find('.all-docs-item'),
- $checkboxes = $rows.find('input:checkbox'),
- modelsAffected,
- docs;
-
- $checkboxes.prop('checked', !isActive);
- $rows.toggleClass('js-to-delete', !isActive);
-
- if (isActive) {
- modelsAffected = _.reduce($rows, function (acc, el) {
- var docId = $(el).attr('data-id'),
- model = this.collection.get(docId);
-
- acc.push(model);
- return acc;
- }, [], this);
-
- this.bulkDeleteDocsCollection.remove(modelsAffected);
- } else {
- modelsAffected = _.reduce($rows, function (acc, el) {
- var docId = $(el).attr('data-id'),
- rev = this.collection.get(docId).get('_rev');
-
- acc.push({_id: docId, _rev: rev, _deleted: true});
- return acc;
- }, [], this);
- this.bulkDeleteDocsCollection.add(modelsAffected);
- }
-
- ReactHeaderActions.updateDocumentCount({
- selectedOnPage: this.$('.js-to-delete').length,
- documentsOnPageCount: this.$('.doc-row').length
- });
- },
-
- serialize: function () {
- return {
- endOfResults: !PaginationStores.indexPaginationStore.canShowNext()
- };
- },
-
- collapse: function () {
- if (this.expandDocs) {
- this.expandDocs = false;
- } else {
- this.expandDocs = true;
- }
-
- this.render();
- },
-
- bulkDelete: function () {
- var that = this,
- documentsLength = this.bulkDeleteDocsCollection.length,
- msg;
-
- msg = "Are you sure you want to delete these " + documentsLength + " docs?";
- if (documentsLength === 0 || !window.confirm(msg)) {
- return false;
- }
-
- this.bulkDeleteDocsCollection.bulkDelete();
- },
-
- cleanup: function () {
- this.allDocsNumber && this.allDocsNumber.remove();
- _.each(this.rows, function (row) {row.remove();});
-
- if (this.bulkDeleteDocsCollection) {
- this.bulkDeleteDocsCollection.reset();
- }
- },
-
- removeNestedViews: function () {
- _.each(this.rows, function (row) {
- row.remove();
- });
- this.rows = {};
- },
-
- beforeRender: function () {
- var docs;
-
- this.removeNestedViews();
-
- docs = this.expandDocs ? this.collection : this.collection.simple();
-
- docs.each(function (doc) {
- var isChecked;
- if (this.bulkDeleteDocsCollection) {
- isChecked = this.bulkDeleteDocsCollection.get(doc.id);
- }
-
- // the location of the ID attribute varies depending on the model. Also, for reduced view searches, the ID isn't
- // available so we use Backbone's own unique ID
- var id = _.has(doc, 'id') ? doc.id : doc.get('id');
- if (_.isUndefined(id)) {
- id = doc.cid;
- }
-
- this.rows[id] = this.insertView('#doc-list', new Views.Document({
- model: doc,
- checked: isChecked
- }));
- }, this);
- },
-
- afterRender: function () {
- $("#dashboard-content").scrollTop(0);
-
- prettyPrint();
-
- this.stopListening(FauxtonAPI.Events);
- this.listenTo(FauxtonAPI.Events, 'headerbar:collapse', this.collapse);
- this.listenTo(FauxtonAPI.Events, 'headerbar:selectall', this.toggleSelectAll);
- this.listenTo(FauxtonAPI.Events, 'headerbar:deleteselected', this.bulkDelete);
-
- if (this.bulkDeleteDocsCollection) {
- this.stopListening(this.bulkDeleteDocsCollection);
- this.listenTo(this.bulkDeleteDocsCollection, 'error', this.showError);
- this.listenTo(this.bulkDeleteDocsCollection, 'removed', this.removeDocuments);
- }
-
- ReactHeaderActions.updateDocumentCount({
- selectedOnPage: this.$('.js-to-delete').length,
- documentsOnPageCount: this.$('.doc-row').length
- });
- }
-
- });
-
Views.JumpToDoc = FauxtonAPI.View.extend({
template: "addons/documents/templates/jumpdoc",
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/assets/less/animations.less
----------------------------------------------------------------------
diff --git a/assets/less/animations.less b/assets/less/animations.less
index b7269d2..a0e4e28 100644
--- a/assets/less/animations.less
+++ b/assets/less/animations.less
@@ -29,7 +29,6 @@
-webkit-transition: opacity .25s ease-in-out;
}
-
.fadeIn {
opacity: 1;
}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/assets/less/react-animations.less
----------------------------------------------------------------------
diff --git a/assets/less/react-animations.less b/assets/less/react-animations.less
index a5a8a6b..80648a2 100644
--- a/assets/less/react-animations.less
+++ b/assets/less/react-animations.less
@@ -28,3 +28,21 @@
opacity: 0;
}
}
+
+.slow-fade-enter {
+ opacity: 0;
+ transition: opacity .75s;
+
+ &.slow-fade-enter-active {
+ opacity: 1;
+ }
+}
+
+.slow-fade-leave {
+ opacity: 1;
+ transition: opacity .75s;
+
+ &.slow-fade-leave-active {
+ opacity: 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/96d31bc7/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/test/mocha/testUtils.js b/test/mocha/testUtils.js
index 6313520..01cadfb 100644
--- a/test/mocha/testUtils.js
+++ b/test/mocha/testUtils.js
@@ -45,9 +45,16 @@ function(FauxtonAPI, chai, sinonChai) {
}
});
+ var restore = function (fn) {
+ if (fn.restore) {
+ fn.restore();
+ }
+ };
+
return {
chai: chai,
assert: chai.assert,
- ViewSandbox: ViewSandbox
+ ViewSandbox: ViewSandbox,
+ restore: restore
};
});