You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2016/01/04 20:29:04 UTC
fauxton commit: updated refs/heads/master to 638ca17
Repository: couchdb-fauxton
Updated Branches:
refs/heads/master 92a0109d4 -> 638ca1744
Remove old unused Backbone code
Nothing here is used any more; there are React counterparts for
Pagination, ConfirmationModal.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/638ca174
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/638ca174
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/638ca174
Branch: refs/heads/master
Commit: 638ca17443a5faac6f74bf9ebdd30b55decb8c71
Parents: 92a0109
Author: Ben Keen <be...@gmail.com>
Authored: Fri Dec 18 10:05:50 2015 -0800
Committer: Ben Keen <be...@gmail.com>
Committed: Mon Jan 4 11:28:39 2016 -0800
----------------------------------------------------------------------
app/addons/fauxton/components.js | 117 ----------------------
app/addons/fauxton/tests/filteredViewSpec.js | 41 --------
app/addons/fauxton/tests/paginateSpec.js | 66 ------------
3 files changed, 224 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/638ca174/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js
index d78997d..40405c3 100644
--- a/app/addons/fauxton/components.js
+++ b/app/addons/fauxton/components.js
@@ -271,107 +271,6 @@ function (app, FauxtonAPI, ace, spin, ZeroClipboard) {
});
- Components.Pagination = FauxtonAPI.View.extend({
- tagName: "ul",
- className: 'pagination',
- template: "addons/fauxton/templates/pagination",
-
- initialize: function (options) {
- this.page = parseInt(options.page, 10);
- this.perPage = options.perPage;
- this.urlFun = options.urlFun;
- },
-
- serialize: function () {
- var total = this.collection.length;
- var totalPages = Math.ceil(total / this.perPage);
-
- var visiblePagesObject = this.getVisiblePages(this.page, totalPages);
-
- var from = visiblePagesObject.from,
- to = visiblePagesObject.to;
-
- return {
- page: this.page,
- perPage: this.perPage,
- total: total,
- totalPages: totalPages,
- urlFun: this.urlFun,
- from: from,
- to: to
- };
- },
-
- getVisiblePages: function (page, totalPages) {
- var from, to;
-
- if (totalPages < 10) {
- from = 1;
- to = totalPages + 1;
- } else { // if totalPages is more than 10
- from = page - 5;
- to = page + 5;
-
- if (from <= 1) {
- from = 1;
- to = 11;
- }
- if (to > totalPages + 1) {
- from = totalPages - 9;
- to = totalPages + 1;
- }
-
- }
-
- return {
- from: from,
- to: to
- };
-
- }
- });
-
-
- // A super-simple replacement for window.confirm()
- Components.ConfirmationModal = FauxtonAPI.View.extend({
- template: 'addons/fauxton/templates/confirmation_modal',
-
- events: {
- 'click .js-btn-success': 'onSelectOkay'
- },
-
- initialize: function (options) {
- this.options = _.extend({
- title: 'Please confirm',
- text: '',
- action: null
- }, options);
- },
-
- onSelectOkay: function () {
- this.hideModal();
- if (_.isFunction(this.options.action)) {
- this.options.action();
- }
- },
-
- showModal: function () {
- this.$('.modal').modal();
- $('.modal-backdrop').css('z-index', FauxtonAPI.constants.MISC.MODAL_BACKDROP_Z_INDEX);
- },
-
- hideModal: function () {
- this.$('.modal').modal('hide');
- },
-
- serialize: function () {
- return {
- title: this.options.title,
- text: this.options.text
- };
- }
- });
-
Components.ModalView = FauxtonAPI.View.extend({
disableLoader: true,
@@ -515,22 +414,6 @@ function (app, FauxtonAPI, ace, spin, ZeroClipboard) {
}
});
- Components.FilteredView = FauxtonAPI.View.extend({
- createFilteredData: function (json) {
- return _.reduce(this.filters, function (elements, filter) {
- return _.filter(elements, function (element) {
- var match = false;
- _.each(element, function (value) {
- if (new RegExp(filter, 'i').test(value.toString())) {
- match = true;
- }
- });
- return match;
- });
- }, json, this);
- }
- });
-
//Menu Drop down component. It takes links in this format and renders the Dropdown:
// [{
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/638ca174/app/addons/fauxton/tests/filteredViewSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/tests/filteredViewSpec.js b/app/addons/fauxton/tests/filteredViewSpec.js
deleted file mode 100644
index c24d439..0000000
--- a/app/addons/fauxton/tests/filteredViewSpec.js
+++ /dev/null
@@ -1,41 +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([
- 'app',
- 'addons/fauxton/components',
- 'testUtils'
-], function (app, Components, testUtils) {
- var assert = testUtils.assert;
-
- describe('FilteredView', function () {
- var filteredView;
-
-
- beforeEach(function () {
- filteredView = new Components.FilteredView();
- });
-
- afterEach(function () {
- });
-
- it('should be case insensitive', function () {
- filteredView.filters = ['ente'];
- var res = filteredView.createFilteredData([
- {id: 'LALA', bar: 'ENTE'},
- {id: '1', bar: '1', deleted: true},
- {id: '2', bar: '2'}
- ]);
- assert.equal(res.length, 1);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/638ca174/app/addons/fauxton/tests/paginateSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/tests/paginateSpec.js b/app/addons/fauxton/tests/paginateSpec.js
deleted file mode 100644
index dd110f8..0000000
--- a/app/addons/fauxton/tests/paginateSpec.js
+++ /dev/null
@@ -1,66 +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([
- 'app',
- 'addons/fauxton/components',
- 'addons/documents/resources',
- 'testUtils',
- 'api'
-], function (app, Views, Models, testUtils, FauxtonAPI) {
- var assert = testUtils.assert;
-
- describe('DatabasePaginate', function () {
- var totalPages, pageComponent, testObject, currentPage;
-
- beforeEach(function () {
- pageComponent = new Views.Pagination({page: 1});
- });
-
- it('Should return all the pages, if there are less than 10 total pages', function () {
- for (totalPages = 1; totalPages < 11; totalPages++) {
- for (currentPage = 1; currentPage < totalPages; currentPage++) {
- testObject = pageComponent.getVisiblePages(currentPage, totalPages);
- assert.deepEqual(testObject, {from: 1, to: totalPages + 1});
- }
- }
- });
-
- it('Should return only a ten page range, if more than 10 total pages', function () {
- var difference;
- for (totalPages = 10; totalPages < 50; totalPages++) {
- for (currentPage = totalPages; currentPage < totalPages; currentPage++) {
- testObject = pageComponent.getVisiblePages(currentPage, totalPages);
- difference = testObject.to - testObject.from;
- assert.equal(difference, 10);
- }
- }
- });
-
- it('Should return from 1 to 10, if accessing the first 6 pages', function () {
- totalPages = 50;
- for (currentPage = 1; currentPage <= 6; currentPage++) {
- testObject = pageComponent.getVisiblePages(currentPage, totalPages);
- assert.deepEqual(testObject, {from: 1, to: 11});
- }
-
- });
-
- it('Should return from totalpages-10 to totalPages, if accessing one of the last 4 pages', function () {
- totalPages = 50;
- for (currentPage = 46; currentPage <= totalPages; currentPage++) {
- testObject = pageComponent.getVisiblePages(currentPage, totalPages);
- assert.deepEqual(testObject, {from: 41, to: 51});
- }
- });
-
- });
-});