Add download button in advanced actins for map and datalayer

This commit is contained in:
Yohan Boniface 2018-06-16 12:45:19 +02:00
parent ac8b68b0e5
commit cc71c40670
8 changed files with 78 additions and 54 deletions

View file

@ -334,6 +334,19 @@ input.switch:checked ~ label:after {
}
.button-bar {
margin-top: 5px;
text-align: center;
display: grid;
grid-gap: 7px;
width: 100%
}
.button-bar.half {
grid-template-columns: 1fr 1fr;
}
.button-bar.third {
grid-template-columns: 1fr 1fr 1fr;
}
.button-bar .button {
display: inline-block;
}
.umap-multiplechoice input[type='radio'] {
display: none;
@ -421,7 +434,7 @@ i.info {
}
.umap-delete:before, .umap-empty:before, .umap-to-polygon:before,
.umap-clone:before, .umap-edit:before,
.umap-clone:before, .umap-edit:before, .umap-download:before,
.umap-to-polyline:before {
background-repeat: no-repeat;
text-indent: 38px;
@ -435,7 +448,7 @@ i.info {
.dark .umap-delete:before, .dark .umap-empty:before,
.dark .umap-to-polygon:before,
.dark .umap-clone:before,
.dark .umap-edit:before,
.dark .umap-edit:before, .dark .umap-download:before,
.dark .umap-to-polyline:before {
background-image: url('./img/24-white.png');
vertical-align: middle;
@ -458,6 +471,9 @@ i.info {
.umap-empty:before {
background-position: -160px -126px;
}
.umap-download:before {
background-position: -88px -168px;
}
.umap-edit-actions {
padding-top: 5px;
clear: both;

View file

@ -143,21 +143,6 @@ h2.section {
display: inline-block;
height: 128px;
}
.button-bar {
text-align: center;
}
.button-bar .button {
display: inline-block;
}
.button-bar .button + .button {
margin-left: 14px;
}
.button-bar .button.half {
width: calc(50% - 7px);
}
.button-bar .button.third {
width: calc(100% / 3 - 10px);
}
.demo-instance-warning {
background-color: #c0392b;
color: #efefef;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -13,9 +13,9 @@
height="200"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="24-white.svg"
inkscape:export-filename="/home/ybon/Code/js/Leaflet.Storage/src/img/24-white.png"
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">
<defs
@ -27,9 +27,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.2"
inkscape:cx="79.721584"
inkscape:cy="82.838267"
inkscape:zoom="22.4"
inkscape:cx="92.77801"
inkscape:cy="34.445334"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@ -50,35 +50,43 @@
<sodipodi:guide
orientation="1,0"
position="80,112"
id="guide3084" />
id="guide3084"
inkscape:locked="false" />
<sodipodi:guide
orientation="0,1"
position="0,40"
id="guide3086" />
id="guide3086"
inkscape:locked="false" />
<sodipodi:guide
orientation="1,0"
position="40,104"
id="guide3088" />
id="guide3088"
inkscape:locked="false" />
<sodipodi:guide
orientation="0,1"
position="0,80"
id="guide3090" />
id="guide3090"
inkscape:locked="false" />
<sodipodi:guide
orientation="1,0"
position="120,84"
id="guide3512" />
id="guide3512"
inkscape:locked="false" />
<sodipodi:guide
orientation="1,0"
position="160,84"
id="guide3872" />
id="guide3872"
inkscape:locked="false" />
<sodipodi:guide
orientation="0,1"
position="0,120"
id="guide25561" />
id="guide25561"
inkscape:locked="false" />
<sodipodi:guide
orientation="0,1"
position="-12,160"
id="guide25563" />
id="guide25563"
inkscape:locked="false" />
</sodipodi:namedview>
<metadata
id="metadata7">
@ -105,15 +113,15 @@
sodipodi:nodetypes="cccccccccccccc" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
x="13.786797"
y="953.80786"
id="text4457"
sodipodi:linespacing="125%"><tspan
id="text4457"><tspan
y="953.80786"
x="13.786797"
sodipodi:role="line"
id="tspan4459" /></text>
id="tspan4459"
style="font-size:40px;line-height:1.25;font-family:sans-serif"> </tspan></text>
<path
style="fill:#f2f2f2;fill-opacity:1;fill-rule:nonzero;stroke:#999999;stroke-opacity:1;stroke-width:0.25;stroke-miterlimit:4;stroke-dasharray:none"
d="m 58,862.36216 0,2 c -2,0 -4,0 -5,2 l 0,1 14,0 0,-1 c -1,-2 -3,-2 -5,-2 l 0,-2 z m -5,6 3,14.00002 8,0 3,-14.00002 z"
@ -131,29 +139,27 @@
d="m 47.999998,965.36218 3.000002,0 0,8 2,0 0,-8 2,0 0,5 1,0 0,-5 2,0 0,5 1,0 0,-5 2,0 0,5 1,0 0,-5 2,0 0,5 1,0 0,-5 2,0 0,8 2,0 0,-8 3,0 0,11 -24,0 z"
style="fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none" />
<text
sodipodi:linespacing="125%"
id="text4455"
y="964.36218"
x="49.170559"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Sans"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none"
xml:space="preserve"><tspan
style="font-size:8px;font-weight:bold;fill:#4d4d4d;fill-opacity:1;-inkscape-font-specification:Sans Bold"
style="font-weight:bold;font-size:8px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';fill:#4d4d4d;fill-opacity:1"
y="964.36218"
x="49.170559"
id="tspan4457"
sodipodi:role="line">0</tspan></text>
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Sans"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none"
x="65.048965"
y="964.36218"
id="text4459"
sodipodi:linespacing="125%"><tspan
id="text4459"><tspan
sodipodi:role="line"
id="tspan4461"
x="65.048965"
y="964.36218"
style="font-size:8px;font-weight:bold;fill:#4d4d4d;fill-opacity:1;-inkscape-font-specification:Sans Bold">1</tspan></text>
style="font-weight:bold;font-size:8px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';fill:#4d4d4d;fill-opacity:1">1</tspan></text>
</g>
<g
id="g3702"
@ -459,5 +465,11 @@
id="path5957"
style="fill:#f2f2f2;fill-opacity:1;stroke:#999999;stroke-opacity:1;stroke-width:0.80268166;stroke-miterlimit:4;stroke-dasharray:none" />
</g>
<path
style="fill:#f2f2f2;fill-opacity:1;stroke:#999999;stroke-width:0.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 100.125,1044.2372 c 6.62742,0 12,-5.3726 12,-12 0,-6.6274 -5.37258,-12 -12,-12 -6.62742,0 -12,5.3726 -12,12 0,6.6274 5.37258,12 12,12 z m 0,-5 -7,-7 h 5 v -6 h 4 v 6 h 5 z"
id="path4700-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ssssscccccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -88,7 +88,7 @@ L.U.UpdatePermsAction = L.U.BaseAction.extend({
},
addHooks: function () {
this.map.permissions.panel();
this.map.permissions.edit();
}
});

View file

@ -1263,8 +1263,8 @@ L.U.Map.include({
callbackContext: this
});
limitBounds.appendChild(boundsBuilder.build());
var boundsButtons = L.DomUtil.create('div', 'button-bar', limitBounds);
var setCurrentButton = L.DomUtil.add('a', 'button half', boundsButtons, L._('Use current bounds'));
var boundsButtons = L.DomUtil.create('div', 'button-bar half', limitBounds);
var setCurrentButton = L.DomUtil.add('a', 'button', boundsButtons, L._('Use current bounds'));
setCurrentButton.href = '#';
L.DomEvent.on(setCurrentButton, 'click', function () {
var bounds = this.getBounds();
@ -1276,7 +1276,7 @@ L.U.Map.include({
this.isDirty = true;
this.handleLimitBounds();
}, this);
var emptyBounds = L.DomUtil.add('a', 'button half', boundsButtons, L._('Empty'));
var emptyBounds = L.DomUtil.add('a', 'button', boundsButtons, L._('Empty'));
emptyBounds.href = '#';
L.DomEvent.on(emptyBounds, 'click', function () {
this.options.limitBounds.south = null;
@ -1318,27 +1318,34 @@ L.U.Map.include({
credits.appendChild(creditsBuilder.build());
var advancedActions = L.DomUtil.createFieldset(container, L._('Advanced actions'));
var advancedButtons = L.DomUtil.create('div', 'button-bar', advancedActions);
var del = L.DomUtil.create('a', 'button third umap-delete', advancedButtons);
var advancedButtons = L.DomUtil.create('div', 'button-bar half', advancedActions);
var del = L.DomUtil.create('a', 'button umap-delete', advancedButtons);
del.href = '#';
del.innerHTML = L._('Delete');
L.DomEvent
.on(del, 'click', L.DomEvent.stop)
.on(del, 'click', this.del, this);
var clone = L.DomUtil.create('a', 'button third umap-clone', advancedButtons);
var clone = L.DomUtil.create('a', 'button umap-clone', advancedButtons);
clone.href = '#';
clone.innerHTML = L._('Clone');
clone.title = L._('Clone this map');
L.DomEvent
.on(clone, 'click', L.DomEvent.stop)
.on(clone, 'click', this.clone, this);
var empty = L.DomUtil.create('a', 'button third umap-empty', advancedButtons);
var empty = L.DomUtil.create('a', 'button umap-empty', advancedButtons);
empty.href = '#';
empty.innerHTML = L._('Empty');
empty.title = L._('Delete all layers');
L.DomEvent
.on(empty, 'click', L.DomEvent.stop)
.on(empty, 'click', this.empty, this);
var download = L.DomUtil.create('a', 'button umap-download', advancedButtons);
download.href = '#';
download.innerHTML = L._('Download');
download.title = L._('Open download panel');
L.DomEvent
.on(download, 'click', L.DomEvent.stop)
.on(download, 'click', this.renderShareBox, this);
this.ui.openPanel({data: {html: container}, className: 'dark'});
},

View file

@ -796,8 +796,8 @@ L.U.DataLayer = L.Class.extend({
if (this.map.options.urls.datalayer_versions) this.buildVersionsFieldset(container);
var advancedActions = L.DomUtil.createFieldset(container, L._('Advanced actions'));
var advancedButtons = L.DomUtil.create('div', 'button-bar', advancedActions);
var deleteLink = L.DomUtil.create('a', 'button third delete_datalayer_button umap-delete', advancedButtons);
var advancedButtons = L.DomUtil.create('div', 'button-bar half', advancedActions);
var deleteLink = L.DomUtil.create('a', 'button delete_datalayer_button umap-delete', advancedButtons);
deleteLink.innerHTML = L._('Delete');
deleteLink.href = '#';
L.DomEvent.on(deleteLink, 'click', L.DomEvent.stop)
@ -806,13 +806,13 @@ L.U.DataLayer = L.Class.extend({
this.map.ui.closePanel();
}, this);
if (!this.isRemoteLayer()) {
var emptyLink = L.DomUtil.create('a', 'button third umap-empty', advancedButtons);
var emptyLink = L.DomUtil.create('a', 'button umap-empty', advancedButtons);
emptyLink.innerHTML = L._('Empty');
emptyLink.href = '#';
L.DomEvent.on(emptyLink, 'click', L.DomEvent.stop)
.on(emptyLink, 'click', this.empty, this);
}
var cloneLink = L.DomUtil.create('a', 'button third umap-clone', advancedButtons);
var cloneLink = L.DomUtil.create('a', 'button umap-clone', advancedButtons);
cloneLink.innerHTML = L._('Clone');
cloneLink.href = '#';
L.DomEvent.on(cloneLink, 'click', L.DomEvent.stop)
@ -820,6 +820,10 @@ L.U.DataLayer = L.Class.extend({
var datalayer = this.clone();
datalayer.edit();
}, this);
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'});
},

View file

@ -43,7 +43,7 @@ L.U.MapPermissions = L.Class.extend({
return this.map;
},
panel: function () {
edit: function () {
if (!this.map.options.umap_id) return this.map.ui.alert({content: L._('Please save the map before'), level: 'info'});
var container = L.DomUtil.create('div', 'permissions-panel'),
fields = [],