Skip to content

Commit 43a9879

Browse files
committed
Fix active scope not visible in the menu if excluded
Depending on some settings (for example, if lookup server upload is disabled) some items can be hidden in the scope menu. However, if the user selected an scope in the past once the settings were changed the scope was no longer visible in the menu. Now the active scope will be always visible in the menu, although if it is an excluded scope it will be disabled. Selecting any other scope will then hide the excluded and no longer active one. When upload to the lookup server is disabled the scope menu was hidden for display name and email in the personal information settings; now the menu will be always shown to enable the above described behaviour. Note that the menu will be shown even if there is a single available scope so the user can read its description. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
1 parent 3ae1ec4 commit 43a9879

File tree

5 files changed

+90
-24
lines changed

5 files changed

+90
-24
lines changed

apps/settings/css/settings.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,16 @@ select {
425425
font-weight: bold;
426426
}
427427
}
428+
429+
&.disabled {
430+
opacity: .5;
431+
432+
cursor: default;
433+
434+
* {
435+
cursor: default;
436+
}
437+
}
428438
}
429439
}
430440
}

apps/settings/js/federationscopemenu.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
className: 'federationScopeMenu popovermenu bubble menu menu-center',
2424
field: undefined,
2525
_scopes: undefined,
26+
_excludedScopes: [],
2627

2728
initialize: function(options) {
2829
this.field = options.field;
@@ -58,9 +59,7 @@
5859
];
5960

6061
if (options.excludedScopes && options.excludedScopes.length) {
61-
this._scopes = this._scopes.filter(function(scopeEntry) {
62-
return options.excludedScopes.indexOf(scopeEntry.name) === -1;
63-
})
62+
this._excludedScopes = options.excludedScopes
6463
}
6564
},
6665

@@ -122,6 +121,17 @@
122121
} else {
123122
this._scopes[i].active = false;
124123
}
124+
125+
var isExcludedScope = this._excludedScopes.includes(this._scopes[i].name)
126+
if (isExcludedScope && !this._scopes[i].active) {
127+
this._scopes[i].hidden = true
128+
} else if (isExcludedScope && this._scopes[i].active) {
129+
this._scopes[i].hidden = false
130+
this._scopes[i].disabled = true
131+
} else {
132+
this._scopes[i].hidden = false
133+
this._scopes[i].disabled = false
134+
}
125135
}
126136

127137
this.render();

apps/settings/js/templates.js

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,65 @@
11
(function() {
22
var template = Handlebars.template, templates = OC.Settings.Templates = OC.Settings.Templates || {};
33
templates['federationscopemenu'] = template({"1":function(container,depth0,helpers,partials,data) {
4+
var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
5+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
6+
return parent[propertyName];
7+
}
8+
return undefined
9+
};
10+
11+
return ((stack1 = lookupProperty(helpers,"unless").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"hidden") : depth0),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":2},"end":{"line":25,"column":13}}})) != null ? stack1 : "");
12+
},"2":function(container,depth0,helpers,partials,data) {
413
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
514
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
615
return parent[propertyName];
716
}
817
return undefined
918
};
1019

11-
return " <li>\n <a href=\"#\" class=\"menuitem action action-"
12-
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":4,"column":45},"end":{"line":4,"column":53}}}) : helper)))
13-
+ " permanent "
14-
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"active") : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":64},"end":{"line":4,"column":91}}})) != null ? stack1 : "")
15-
+ "\" data-action=\""
16-
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":4,"column":106},"end":{"line":4,"column":114}}}) : helper)))
17-
+ "\">\n"
18-
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"iconClass") : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data,"loc":{"start":{"line":5,"column":4},"end":{"line":9,"column":11}}})) != null ? stack1 : "")
20+
return " <li>\n"
21+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"disabled") : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(6, data, 0),"data":data,"loc":{"start":{"line":5,"column":3},"end":{"line":9,"column":10}}})) != null ? stack1 : "")
22+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"iconClass") : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.program(10, data, 0),"data":data,"loc":{"start":{"line":10,"column":4},"end":{"line":14,"column":11}}})) != null ? stack1 : "")
1923
+ " <p>\n <strong class=\"menuitem-text\">"
20-
+ alias4(((helper = (helper = lookupProperty(helpers,"displayName") || (depth0 != null ? lookupProperty(depth0,"displayName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data,"loc":{"start":{"line":11,"column":35},"end":{"line":11,"column":50}}}) : helper)))
24+
+ alias4(((helper = (helper = lookupProperty(helpers,"displayName") || (depth0 != null ? lookupProperty(depth0,"displayName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data,"loc":{"start":{"line":16,"column":35},"end":{"line":16,"column":50}}}) : helper)))
2125
+ "</strong><br>\n <span class=\"menuitem-text-detail\">"
22-
+ alias4(((helper = (helper = lookupProperty(helpers,"tooltip") || (depth0 != null ? lookupProperty(depth0,"tooltip") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tooltip","hash":{},"data":data,"loc":{"start":{"line":12,"column":40},"end":{"line":12,"column":51}}}) : helper)))
23-
+ "</span>\n </p>\n </a>\n </li>\n";
24-
},"2":function(container,depth0,helpers,partials,data) {
25-
return "active";
26+
+ alias4(((helper = (helper = lookupProperty(helpers,"tooltip") || (depth0 != null ? lookupProperty(depth0,"tooltip") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tooltip","hash":{},"data":data,"loc":{"start":{"line":17,"column":40},"end":{"line":17,"column":51}}}) : helper)))
27+
+ "</span>\n </p>\n"
28+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"disabled") : depth0),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.program(14, data, 0),"data":data,"loc":{"start":{"line":19,"column":3},"end":{"line":23,"column":10}}})) != null ? stack1 : "")
29+
+ " </li>\n";
30+
},"3":function(container,depth0,helpers,partials,data) {
31+
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
32+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
33+
return parent[propertyName];
34+
}
35+
return undefined
36+
};
37+
38+
return " <div class=\"menuitem action action-"
39+
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":6,"column":38},"end":{"line":6,"column":46}}}) : helper)))
40+
+ " permanent "
41+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"active") : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":6,"column":57},"end":{"line":6,"column":84}}})) != null ? stack1 : "")
42+
+ " disabled\" data-action=\""
43+
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":6,"column":108},"end":{"line":6,"column":116}}}) : helper)))
44+
+ "\">\n";
2645
},"4":function(container,depth0,helpers,partials,data) {
46+
return "active";
47+
},"6":function(container,depth0,helpers,partials,data) {
48+
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
49+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
50+
return parent[propertyName];
51+
}
52+
return undefined
53+
};
54+
55+
return " <a href=\"#\" class=\"menuitem action action-"
56+
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":8,"column":45},"end":{"line":8,"column":53}}}) : helper)))
57+
+ " permanent "
58+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"active") : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":8,"column":64},"end":{"line":8,"column":91}}})) != null ? stack1 : "")
59+
+ "\" data-action=\""
60+
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":8,"column":106},"end":{"line":8,"column":114}}}) : helper)))
61+
+ "\">\n";
62+
},"8":function(container,depth0,helpers,partials,data) {
2763
var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {
2864
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
2965
return parent[propertyName];
@@ -32,10 +68,14 @@ templates['federationscopemenu'] = template({"1":function(container,depth0,helpe
3268
};
3369

3470
return " <span class=\"icon "
35-
+ container.escapeExpression(((helper = (helper = lookupProperty(helpers,"iconClass") || (depth0 != null ? lookupProperty(depth0,"iconClass") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"iconClass","hash":{},"data":data,"loc":{"start":{"line":6,"column":23},"end":{"line":6,"column":36}}}) : helper)))
71+
+ container.escapeExpression(((helper = (helper = lookupProperty(helpers,"iconClass") || (depth0 != null ? lookupProperty(depth0,"iconClass") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"iconClass","hash":{},"data":data,"loc":{"start":{"line":11,"column":23},"end":{"line":11,"column":36}}}) : helper)))
3672
+ "\"></span>\n";
37-
},"6":function(container,depth0,helpers,partials,data) {
73+
},"10":function(container,depth0,helpers,partials,data) {
3874
return " <span class=\"no-icon\"></span>\n";
75+
},"12":function(container,depth0,helpers,partials,data) {
76+
return " </div>\n";
77+
},"14":function(container,depth0,helpers,partials,data) {
78+
return " </a>\n";
3979
},"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
4080
var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
4181
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
@@ -45,7 +85,7 @@ templates['federationscopemenu'] = template({"1":function(container,depth0,helpe
4585
};
4686

4787
return "<ul>\n"
48-
+ ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"items") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":2,"column":1},"end":{"line":16,"column":10}}})) != null ? stack1 : "")
88+
+ ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"items") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":2,"column":1},"end":{"line":26,"column":10}}})) != null ? stack1 : "")
4989
+ "</ul>\n";
5090
},"useData":true});
5191
})();

apps/settings/js/templates/federationscopemenu.handlebars

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<ul>
22
{{#each items}}
3+
{{#unless hidden}}
34
<li>
5+
{{#if disabled}}
6+
<div class="menuitem action action-{{name}} permanent {{#if active}}active{{/if}} disabled" data-action="{{name}}">
7+
{{else}}
48
<a href="#" class="menuitem action action-{{name}} permanent {{#if active}}active{{/if}}" data-action="{{name}}">
9+
{{/if}}
510
{{#if iconClass}}
611
<span class="icon {{iconClass}}"></span>
712
{{else}}
@@ -11,7 +16,12 @@
1116
<strong class="menuitem-text">{{displayName}}</strong><br>
1217
<span class="menuitem-text-detail">{{tooltip}}</span>
1318
</p>
19+
{{#if disabled}}
20+
</div>
21+
{{else}}
1422
</a>
23+
{{/if}}
1524
</li>
25+
{{/unless}}
1626
{{/each}}
1727
</ul>

apps/settings/templates/settings/personal/personal.info.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@
122122
<?php } ?>
123123
<span class="icon-checkmark hidden"></span>
124124
<span class="icon-error hidden" ></span>
125-
<?php if ($_['lookupServerUploadEnabled']) { ?>
126125
<input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>">
127-
<?php } ?>
128126
</form>
129127
</div>
130128
<div class="personal-settings-setting-box">
@@ -172,9 +170,7 @@
172170
<?php if ($_['displayNameChangeSupported']) { ?>
173171
<em><?php p($l->t('For password reset and notifications')); ?></em>
174172
<?php } ?>
175-
<?php if ($_['lookupServerUploadEnabled']) { ?>
176-
<input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
177-
<?php } ?>
173+
<input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
178174
</form>
179175
</div>
180176
<div class="personal-settings-setting-box">

0 commit comments

Comments
 (0)