diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-02-02 11:59:13 +0100 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-02-02 20:21:57 +0100 |
commit | 9ff6a2dab8e3f81efff2c7925ff2d77ceecd738f (patch) | |
tree | e0abb39c1c35a10af36385dcf53c46628334cf36 /settings | |
parent | 34e849d7024ed46568b7829782f602ae7d958abe (diff) | |
download | nextcloud-server-9ff6a2dab8e3f81efff2c7925ff2d77ceecd738f.tar.gz nextcloud-server-9ff6a2dab8e3f81efff2c7925ff2d77ceecd738f.zip |
Improve usability
- Trigger rename by doubleclick on token name
- Use action rename to open and close
- Line height stays the same
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/css/settings.scss | 12 | ||||
-rw-r--r-- | settings/js/authtoken_view.js | 37 | ||||
-rw-r--r-- | settings/js/templates.js | 2 | ||||
-rw-r--r-- | settings/js/templates/authtoken.handlebars | 2 |
4 files changed, 40 insertions, 13 deletions
diff --git a/settings/css/settings.scss b/settings/css/settings.scss index f833913b7d6..3316c475b66 100644 --- a/settings/css/settings.scss +++ b/settings/css/settings.scss @@ -440,7 +440,14 @@ table.nostyle { } &.token-name { - padding: 10px 0; + padding: 10px 6px; + &.token-rename { + padding: 0; + } + input { + width: 100%; + margin: 0; + } } &.more { @@ -456,6 +463,9 @@ table.nostyle { } } } + tr > *:nth-child(2) { + padding-left: 6px; + } tr > *:nth-child(3) { text-align: right; } diff --git a/settings/js/authtoken_view.js b/settings/js/authtoken_view.js index 6455a2d69f5..1484cffc337 100644 --- a/settings/js/authtoken_view.js +++ b/settings/js/authtoken_view.js @@ -220,7 +220,8 @@ $el.on('click', '.icon-more', _.bind(this._onConfigureToken, this)); $el.on('change', 'input.filesystem', _.bind(this._onSetTokenScope, this)); $el.on('click', '.icon-rename', _.bind(this._onRenameToken, this)); - $el.on('keyup', 'input.rename-token', _.bind(this._onEnterTokenName, this)); + $el.on('dblclick', '.token-name > span', _.bind(this._onRenameToken, this)); + $el.on('keyup', '.token-name > input', _.bind(this._onEnterTokenName, this)); this._form = $('#app-password-form'); this._tokenName = $('#app-password-name'); @@ -420,16 +421,25 @@ _onRenameToken: function (event) { var $target = $(event.target); var $row = $target.closest('tr'); - var id = $row.data('id'); - var token = this.collection.get(id); - if (_.isUndefined(token)) { + var tokenId = $row.data('id'); + var token = this.collection.get(tokenId); + + if (_.isUndefined(token) || token.get('current') === true) { // Ignore event return; } - $row.find('.token-name > span').addClass('hidden'); - $row.find('.token-name > input').removeClass('hidden').focus(); + var $tokenName = $row.find('.token-name'); + var showTokenNameInput = !$tokenName.hasClass('token-rename'); // if class token-rename present input is already visible. + + this._hideTokenNameInput(); + + if (showTokenNameInput) { + $tokenName.addClass('token-rename'); + $tokenName.find('span').addClass('hidden'); + $tokenName.find('input').removeClass('hidden').val(token.get('name')).focus(); + } this._hideConfigureToken(); }, @@ -437,9 +447,10 @@ _onEnterTokenName: function(event) { var $target = $(event.target); var $row = $target.closest('tr'); - var id = $row.data('id'); - var token = this.collection.get(id); + var tokenId = $row.data('id'); + var token = this.collection.get(tokenId); + if (_.isUndefined(token)) { // Ignore event return; @@ -455,11 +466,17 @@ } if (event.key === 'Escape') { - $row.find('.token-name > span').removeClass('hidden'); - $row.find('.token-name > input').addClass('hidden'); + this._hideTokenNameInput(); } }, + _hideTokenNameInput: function () { + var $tokenList = $('.token-list td.token-name'); + $tokenList.removeClass('token-rename'); + $tokenList.find('span').removeClass('hidden'); + $tokenList.find('input').addClass('hidden'); + }, + _toggleFormResult: function (showForm) { if (showForm) { this._result.slideUp(); diff --git a/settings/js/templates.js b/settings/js/templates.js index ac6ba948dd1..e35f93d3cb9 100644 --- a/settings/js/templates.js +++ b/settings/js/templates.js @@ -3,7 +3,7 @@ templates['authtoken'] = template({"1":function(container,depth0,helpers,partials,data) { var helper; - return " <input class=\"hidden rename-token\" type=\"text\" value=\"" + return " <input class=\"hidden\" type=\"text\" value=\"" + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper))) + "\" />\n"; },"3":function(container,depth0,helpers,partials,data) { diff --git a/settings/js/templates/authtoken.handlebars b/settings/js/templates/authtoken.handlebars index 5e9d4118640..37dc31f04c6 100644 --- a/settings/js/templates/authtoken.handlebars +++ b/settings/js/templates/authtoken.handlebars @@ -5,7 +5,7 @@ <td class="token-name"> <span>{{name}}</span> {{#if canRename}} - <input class="hidden rename-token" type="text" value="{{name}}" /> + <input class="hidden" type="text" value="{{name}}" /> {{/if}} </td> <td> |