You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2014/03/13 15:43:32 UTC
[1/3] couchdb commit: updated refs/heads/master to e671933
Repository: couchdb
Updated Branches:
refs/heads/master b4332e437 -> e671933c2
Fauxton: focus input on doubleclick
Fauxton: hide field if Esc if pressed
Fauxton: fix small typo
Fauxton: save value, when I press Enter
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e671933c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e671933c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e671933c
Branch: refs/heads/master
Commit: e671933c2f4d83735ce918d00d8dfe5c1130f727
Parents: f3ca960
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Wed Mar 12 22:49:35 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400
----------------------------------------------------------------------
src/fauxton/app/addons/config/resources.js | 31 ++++++++++++++++----
.../app/addons/config/tests/resourcesSpec.js | 29 +++++++++++++++++-
src/fauxton/app/core/tests/layoutSpec.js | 2 +-
3 files changed, 55 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index 8f9ab08..e5ebe65 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -22,7 +22,7 @@ function (app, FauxtonAPI) {
Config.Model = Backbone.Model.extend({});
Config.OptionModel = Backbone.Model.extend({
documentation: "config",
-
+
url: function () {
return app.host + '/_config/' + this.get("section") + '/' + this.get("name");
},
@@ -84,7 +84,8 @@ function (app, FauxtonAPI) {
"dblclick .js-edit-value": "editValue",
"click .js-delete-value": "deleteValue",
"click .js-cancel-value": "cancelEdit",
- "click .js-save-value": "saveValue"
+ "click .js-save-value": "saveValue",
+ "keyup .js-value-input": "processKeyEvents"
},
deleteValue: function (event) {
@@ -99,20 +100,40 @@ function (app, FauxtonAPI) {
editValue: function (event) {
this.$(".js-show-value").addClass("js-hidden");
this.$(".js-edit-value-form").removeClass("js-hidden");
+ this.$(".js-value-input").focus();
+ },
+
+ processKeyEvents: function (event) {
+ // Enter key
+ if (event.keyCode === 13) {
+ return this.saveAndRender();
+ }
+ // Esc key
+ if (event.keyCode === 27) {
+ return this.discardValue();
+ }
},
saveValue: function (event) {
- this.model.save({value: this.$(".js-value-input").val()});
- this.render();
+ this.saveAndRender();
},
- cancelEdit: function (event) {
+ discardValue: function (event) {
this.$(".js-edit-value-form").addClass("js-hidden");
this.$(".js-show-value").removeClass("js-hidden");
},
+ cancelEdit: function (event) {
+ this.discardValue();
+ },
+
serialize: function () {
return {option: this.model.toJSON()};
+ },
+
+ saveAndRender: function () {
+ this.model.save({value: this.$(".js-value-input").val()});
+ this.render();
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
index 98f6569..b9b8d09 100644
--- a/src/fauxton/app/addons/config/tests/resourcesSpec.js
+++ b/src/fauxton/app/addons/config/tests/resourcesSpec.js
@@ -17,7 +17,7 @@ define([
var assert = testUtils.assert,
ViewSandbox = testUtils.ViewSandbox;
- describe("ViewItem", function () {
+ describe("Config: ViewItem", function () {
var tabMenu, optionModel;
beforeEach(function () {
@@ -52,6 +52,33 @@ define([
assert.ok(renderSpy.calledOnce);
assert.ok(saveSpy.calledOnce);
});
+
+ it("pressing enter should save the model and render", function () {
+ var renderSpy = sinon.stub(tabMenu, 'render');
+ var saveSpy = sinon.stub(optionModel, 'save');
+
+ var e = $.Event("keyup");
+ e.keyCode = 13;
+ tabMenu.$('.js-value-input').trigger(e);
+
+ assert.ok(renderSpy.calledOnce);
+ assert.ok(saveSpy.calledOnce);
+ });
+
+ it("pressing Esc hides the field", function () {
+ var e = $.Event("keyup");
+ e.keyCode = 27;
+ tabMenu.$('.js-value-input').trigger(e);
+
+ assert.ok(tabMenu.$('.js-edit-value-form').hasClass('js-hidden'));
+ });
+
+ it("pressing Cancel hides the field", function () {
+ tabMenu.$('.js-edit-value').trigger('dblclick');
+ tabMenu.$('.js-cancel-value').trigger('click');
+
+ assert.ok(tabMenu.$('.js-edit-value-form').hasClass('js-hidden'));
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e671933c/src/fauxton/app/core/tests/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/tests/layoutSpec.js b/src/fauxton/app/core/tests/layoutSpec.js
index b58966b..40b1947 100644
--- a/src/fauxton/app/core/tests/layoutSpec.js
+++ b/src/fauxton/app/core/tests/layoutSpec.js
@@ -15,7 +15,7 @@ define([
], function (FauxtonAPI, testUtils) {
var assert = testUtils.assert;
- describe("Faxuton Layout", function () {
+ describe("Fauxton Layout", function () {
var layout;
beforeEach(function () {
[3/3] couchdb commit: updated refs/heads/master to e671933
Posted by de...@apache.org.
Fauxton: use class instead of inline-style
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a07924df
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a07924df
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a07924df
Branch: refs/heads/master
Commit: a07924df35f9bc9c555f2a49b1b84d174896e5b1
Parents: b4332e4
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Mar 11 19:24:10 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400
----------------------------------------------------------------------
src/fauxton/app/addons/config/assets/less/config.less | 3 +++
src/fauxton/app/addons/config/resources.js | 8 ++++----
src/fauxton/app/addons/config/templates/item.html | 4 ++--
3 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less
index 651cbe3..44311de 100644
--- a/src/fauxton/app/addons/config/assets/less/config.less
+++ b/src/fauxton/app/addons/config/assets/less/config.less
@@ -21,6 +21,9 @@
.js-delete-value {
cursor: pointer;
}
+ .js-hidden {
+ display: none;
+ }
button {width: 7%;}
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index b5c0b6c..8f9ab08 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -97,8 +97,8 @@ function (app, FauxtonAPI) {
},
editValue: function (event) {
- this.$(".js-show-value").hide();
- this.$(".js-edit-value-form").show();
+ this.$(".js-show-value").addClass("js-hidden");
+ this.$(".js-edit-value-form").removeClass("js-hidden");
},
saveValue: function (event) {
@@ -107,8 +107,8 @@ function (app, FauxtonAPI) {
},
cancelEdit: function (event) {
- this.$(".js-edit-value-form").hide();
- this.$(".js-show-value").show();
+ this.$(".js-edit-value-form").addClass("js-hidden");
+ this.$(".js-show-value").removeClass("js-hidden");
},
serialize: function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a07924df/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
index a628fe6..108fa58 100644
--- a/src/fauxton/app/addons/config/templates/item.html
+++ b/src/fauxton/app/addons/config/templates/item.html
@@ -20,9 +20,9 @@ the License.
<td > <%= option.name %> </td>
<td class="js-edit-value">
<div class="js-show-value">
- <%= option.value %>
+ <%= option.value %>
</div>
- <div class="js-edit-value-form" style="display:none">
+ <div class="js-edit-value-form js-hidden">
<input class="js-value-input" type="text" value="<%- option.value %>" />
<button class="js-save-value btn btn-success fonticon-circle-check btn-small"> </button>
<button class="js-cancel-value btn btn-small fonticon-circle-x"> </button>
[2/3] couchdb commit: updated refs/heads/master to e671933
Posted by de...@apache.org.
Fauxton: add tests for config
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f3ca9602
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f3ca9602
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f3ca9602
Branch: refs/heads/master
Commit: f3ca96026a8da409756e30c8cf8efd05968feeab
Parents: a07924d
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Mar 11 19:48:57 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Thu Mar 13 10:43:23 2014 -0400
----------------------------------------------------------------------
src/Makefile.am | 1 +
.../app/addons/config/tests/resourcesSpec.js | 57 ++++++++++++++++++++
2 files changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3ca9602/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 59aa6bf..a213baa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,7 @@ FAUXTON_FILES = \
fauxton/app/addons/config/routes.js \
fauxton/app/addons/config/templates/dashboard.html \
fauxton/app/addons/config/templates/item.html \
+ fauxton/app/addons/config/tests/resourcesSpec.js \
fauxton/app/addons/contribute/base.js \
fauxton/app/addons/exampleAuth/base.js \
fauxton/app/addons/exampleAuth/templates/noAccess.html \
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3ca9602/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
new file mode 100644
index 0000000..98f6569
--- /dev/null
+++ b/src/fauxton/app/addons/config/tests/resourcesSpec.js
@@ -0,0 +1,57 @@
+// 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([
+ 'api',
+ 'addons/config/resources',
+ 'testUtils'
+], function (FauxtonAPI, Resources, testUtils) {
+ var assert = testUtils.assert,
+ ViewSandbox = testUtils.ViewSandbox;
+
+ describe("ViewItem", function () {
+ var tabMenu, optionModel;
+
+ beforeEach(function () {
+ optionModel = new Resources.OptionModel({
+ section: "foo",
+ name: "bar"
+ });
+
+ tabMenu = new Resources.ViewItem({
+ model: optionModel
+ });
+ });
+
+ describe("editing Items", function () {
+ var viewSandbox;
+ beforeEach(function () {
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(tabMenu);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
+ });
+
+ it("click on save should save the model and render", function () {
+ var renderSpy = sinon.stub(tabMenu, 'render');
+ var saveSpy = sinon.stub(optionModel, 'save');
+
+ tabMenu.$('.js-edit-value').trigger('dblclick');
+ tabMenu.$('.js-save-value').trigger('click');
+
+ assert.ok(renderSpy.calledOnce);
+ assert.ok(saveSpy.calledOnce);
+ });
+ });
+ });
+});