]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use boxes for system tags, shorten permission text
authorVincent Petry <pvince81@owncloud.com>
Wed, 27 Jan 2016 14:49:11 +0000 (15:49 +0100)
committerVincent Petry <pvince81@owncloud.com>
Thu, 28 Jan 2016 10:24:13 +0000 (11:24 +0100)
Permission text now doesn't appear when all permissions are there, or
shows as "invisible" or "not assignable", which should better cover all
use cases.

Changed select2 style to use boxes in the input field.

core/css/systemtags.css
core/js/systemtags/systemtags.js
core/js/systemtags/systemtagsinputfield.js
core/js/tests/specs/systemtags/systemtagsSpec.js
core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js

index d847baa680036c860b1aa2a0d4be0ec2e10e3e5c..2a02bc05ea72f4214ca5958f056e451543906738 100644 (file)
@@ -45,7 +45,7 @@
 }
 
 .systemtags-select2-container { 
-       width: 80%;
+       width: 100%;
 }
 
 .systemtags-select2-container .select2-choices {
 }
 
 .systemtags-select2-container .select2-choices .select2-search-choice {
-       border: 0;
-       box-shadow: none;
-       background: none;
-       padding: 0;
-       margin: 0;
        line-height: 20px;
+       padding-left: 5px;
 }
 
 .systemtags-select2-container .select2-choices .select2-search-choice.select2-locked .label {
-       font-style: italic;
+       opacity: 0.5;
 }
 
 .systemtags-select2-container .select2-choices .select2-search-choice-close {
        display: none;
 }
 .systemtags-select2-container .select2-choices .select2-search-field input {
-       margin: 0;
-       padding: 0;
        line-height: 20px;
 }
 
index 05d3ba2c7b8cd36edad432e98c3171591a9b3e05..042f49bb8ed02bc6e71323e82628d84ef6e324fd 100644 (file)
                                );
                        }
 
-                       var $span = $('<span>'),
-                               $tag = $('<em>').text(
-                                       t('core', '({uservisible}, {userassignable})', {
-                                               uservisible: tag.userVisible ? t('core', 'visible') : t('core', 'invisible'),
-                                               userassignable: tag.userAssignable ? t('core', 'assignable') : t('core', 'not assignable')
+                       var $span = $('<span>');
+                       $span.append(escapeHTML(tag.name));
+
+                       var scope;
+                       if (!tag.userAssignable) {
+                               scope = t('core', 'not assignable');
+                       }
+                       if (!tag.userVisible) {
+                               // invisible also implicitly means not assignable
+                               scope = t('core', 'invisible');
+                       }
+                       if (scope) {
+                               var $tag = $('<em>').text(' ' +
+                                       t('core', '({scope})', {
+                                               scope: scope
                                        })
                                );
-                       $span.append(escapeHTML(tag.name) + ' ');
-                       $span.append($tag);
+                               $span.append($tag);
+                       }
                        return $span;
                }
        };
index b90ecbe426564dd2f644eddee4a5a6937835d75a..3e0bfbbc55cd771faddc5e0b727d1a6de5699804 100644 (file)
@@ -34,8 +34,7 @@
                '    <span class="label">{{{tagMarkup}}}</span>' +
                '{{else}}' +
                '    <span class="label">{{name}}</span>' +
-               '{{/if}}' +
-               '<span class="comma">,&nbsp;</span>';
+               '{{/if}}';
 
        var RENAME_FORM_TEMPLATE =
                '<form class="systemtags-rename-form">' +
index 2e8390ad9f039d307949984cd7e41dd5ae725044..515b75258a068dd481d4ff02b616d3dce187ec3a 100644 (file)
@@ -34,7 +34,7 @@ describe('OC.SystemTags tests', function() {
                        userVisible: true
                });
                var $return = OC.SystemTags.getDescriptiveTag(tag);
-               expect($return.text()).toEqual('Twenty Three (visible, assignable)');
+               expect($return.text()).toEqual('Twenty Three');
                expect($return.hasClass('non-existing-tag')).toEqual(false);
        });
 
@@ -42,10 +42,28 @@ describe('OC.SystemTags tests', function() {
                var $return = OC.SystemTags.getDescriptiveTag({
                        id: 42,
                        name: 'Fourty Two',
-                       userAssignable: false,
-                       userVisible: false
+                       userAssignable: true,
+                       userVisible: true
                });
-               expect($return.text()).toEqual('Fourty Two (invisible, not assignable)');
+               expect($return.text()).toEqual('Fourty Two');
                expect($return.hasClass('non-existing-tag')).toEqual(false);
        });
+
+       it('scope', function() {
+               function testScope(userVisible, userAssignable, expectedText) {
+                       var $return = OC.SystemTags.getDescriptiveTag({
+                               id: 42,
+                               name: 'Fourty Two',
+                               userAssignable: userAssignable,
+                               userVisible: userVisible
+                       });
+                       expect($return.text()).toEqual(expectedText);
+                       expect($return.hasClass('non-existing-tag')).toEqual(false);
+               }
+
+               testScope(true, true, 'Fourty Two');
+               testScope(false, true, 'Fourty Two (invisible)');
+               testScope(false, false, 'Fourty Two (invisible)');
+               testScope(true, false, 'Fourty Two (not assignable)');
+       });
 });
index 07e926cd2a9ba34553a2c116573be6544b5df80d..a2347eb6893489a78f6c815e63d3d063ff2a9cb6 100644 (file)
@@ -234,12 +234,12 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() {
                it('formatResult renders tag name with visibility', function() {
                        var opts = select2Stub.getCall(0).args[0];
                        var $el = $(opts.formatResult({id: '1', name: 'test', userVisible: false, userAssignable: false}));
-                       expect($el.find('.label').text()).toEqual('test (invisible, not assignable)');
+                       expect($el.find('.label').text()).toEqual('test (invisible)');
                });
                it('formatSelection renders tag name with visibility', function() {
                        var opts = select2Stub.getCall(0).args[0];
                        var $el = $(opts.formatSelection({id: '1', name: 'test', userVisible: false, userAssignable: false}));
-                       expect($el.text().trim()).toEqual('test (invisible, not assignable),');
+                       expect($el.text().trim()).toEqual('test (invisible)');
                });
                describe('initSelection', function() {
                        var fetchStub;
@@ -337,7 +337,7 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() {
                it('formatSelection renders tag name only', function() {
                        var opts = select2Stub.getCall(0).args[0];
                        var $el = $(opts.formatSelection({id: '1', name: 'test'}));
-                       expect($el.text().trim()).toEqual('test,');
+                       expect($el.text().trim()).toEqual('test');
                });
                describe('initSelection', function() {
                        var fetchStub;