Use a ternary choice for showLabel

fix #553
This commit is contained in:
Yohan Boniface 2018-06-19 09:11:54 +02:00
parent fc2549fce6
commit 67d7ab962c
5 changed files with 42 additions and 25 deletions

View file

@ -16,8 +16,8 @@
inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="24-white.svg"
inkscape:export-filename="/home/ybon/Code/py/umap/umap/static/umap/img/24-white.png"
inkscape:export-xdpi="89.996864"
inkscape:export-ydpi="89.996864">
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs4" />
<sodipodi:namedview
@ -28,8 +28,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="92.77801"
inkscape:cy="34.445334"
inkscape:cx="124.98783"
inkscape:cy="45.00337"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -146,7 +146,6 @@ L.U.FeatureMixin = {
'properties._umap_options.popupTemplate',
'properties._umap_options.showLabel',
'properties._umap_options.labelDirection',
'properties._umap_options.labelHover',
'properties._umap_options.labelInteractive'
];
},
@ -223,7 +222,7 @@ L.U.FeatureMixin = {
},
getOption: function (option, fallback) {
var value = fallback || null;
var value = fallback;
if (typeof this.staticOptions[option] !== 'undefined') {
value = this.staticOptions[option];
}
@ -392,13 +391,16 @@ L.U.FeatureMixin = {
resetTooltip: function () {
var displayName = this.getDisplayName(null),
showLabel = this.getOption('showLabel'),
oldLabelHover = this.getOption('labelHover'),
options = {
permanent: !this.getOption('labelHover'),
direction: this.getOption('labelDirection'),
interactive: this.getOption('labelInteractive')
};
if (oldLabelHover && showLabel) showLabel = null; // Retrocompat.
options.permanent = showLabel === true;
this.unbindTooltip();
if (this.getOption('showLabel') && displayName) this.bindTooltip(L.Util.escapeHTML(displayName), options);
if ((showLabel === true || showLabel === null) && displayName) this.bindTooltip(L.Util.escapeHTML(displayName), options);
},
matchFilter: function (filter, keys) {

View file

@ -532,16 +532,10 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
});
L.FormBuilder.ControlChoice = L.FormBuilder.MultiChoice.extend({
L.FormBuilder.TernaryChoices = L.FormBuilder.MultiChoice.extend({
default: 'null',
choices: [
[true, L._('always')],
[false, L._('never')],
['null', L._('hidden')]
],
toJS: function () {
var value = this.value();
switch (value) {
@ -561,6 +555,29 @@ L.FormBuilder.ControlChoice = L.FormBuilder.MultiChoice.extend({
});
L.FormBuilder.ControlChoice = L.FormBuilder.TernaryChoices.extend({
choices: [
[true, L._('always')],
[false, L._('never')],
['null', L._('hidden')]
]
});
L.FormBuilder.LabelChoice = L.FormBuilder.TernaryChoices.extend({
default: false,
choices: [
[true, L._('always')],
[false, L._('never')],
['null', L._('on hover')]
]
});
L.FormBuilder.DataLayersControl = L.FormBuilder.ControlChoice.extend({
choices: [
@ -688,8 +705,7 @@ L.U.FormBuilder = L.FormBuilder.extend({
displayPopupFooter: {handler: 'Switch', label: L._('Do you want to display popup footer?')},
captionBar: {handler: 'Switch', label: L._('Do you want to display a caption bar?')},
zoomTo: {handler: 'IntInput', placeholder: L._('Inherit'), helpEntries: 'zoomTo', label: L._('Default zoom level'), inheritable: true},
showLabel: {handler: 'Switch', label: L._('Display label'), inheritable: true},
labelHover: {handler: 'Switch', label: L._('Only display label on mouse hover'), inheritable: true},
showLabel: {handler: 'LabelChoice', label: L._('Display label'), inheritable: true},
labelDirection: {handler: 'LabelDirection', label: L._('Label direction'), inheritable: true},
labelInteractive: {handler: 'Switch', label: L._('Labels are clickable'), inheritable: true},
labelKey: {helpEntries: 'labelKey', placeholder: L._('Default: name'), label: L._('Label key'), inheritable: true},

View file

@ -540,7 +540,7 @@ L.U.Map.include({
},
getDefaultOption: function (option) {
return this.options['default_' + option] || null;
return this.options['default_' + option];
},
getOption: function (option) {
@ -1012,7 +1012,6 @@ L.U.Map.include({
'filterKey',
'showLabel',
'labelDirection',
'labelHover',
'labelInteractive',
'shortCredit',
'longCredit',
@ -1217,7 +1216,6 @@ L.U.Map.include({
'options.popupContentTemplate',
'options.showLabel',
'options.labelDirection',
'options.labelHover',
'options.labelInteractive'
];
builder = new L.U.FormBuilder(this, popupFields, {

View file

@ -767,7 +767,6 @@ L.U.DataLayer = L.Class.extend({
'options.popupContentTemplate',
'options.showLabel',
'options.labelDirection',
'options.labelHover',
'options.labelInteractive',
];
builder = new L.U.FormBuilder(this, popupFields, {callback: redrawCallback});
@ -820,10 +819,12 @@ L.U.DataLayer = L.Class.extend({
var datalayer = this.clone();
datalayer.edit();
}, this);
if (this.umap_id) {
var download = L.DomUtil.create('a', 'button umap-download', advancedButtons);
download.innerHTML = L._('Download');
download.href = this._dataUrl();
download.target = '_blank';
}
this.map.ui.openPanel({data: {html: container}, className: 'dark'});
},