annotate client/src/pdftool/Pdftool.vue @ 1191:b23622905a3f

switched entirely to sass instead of scss for cleaner code/less lines, just removed all ; and {}
author Markus Kottlaender <markus@intevation.de>
date Fri, 16 Nov 2018 14:37:07 +0100
parents 2e06bc53b002
children 4f666dbb9abd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1123
diff changeset
2 <div class="pdftool" :style="selectedSurvey ? 'bottom: 140px' : ''">
1123
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
3 <div @click="$store.commit('application/showPdfTool', !showPdfTool)" class="d-flex flex-column ui-element minimizer">
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
4 <i :class="['fa', 'mt-1', {'fa-file-pdf-o': !showPdfTool}, {'fa-close': showPdfTool}]"></i>
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
5 </div>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
6 <div :class="style">
1123
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
7 <div v-if="showPdfTool" class="card-body">
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
8 <div class="headline">
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
9 <h4 class="card-title">Generate PDF</h4>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
10 </div>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
11 <hr>
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
12 <b>Chose format:</b>
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
13 <br>
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
14 <select v-model="form.format" class="d-block w-100">
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
15 <option>landscape</option>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
16 <option>portrait</option>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
17 </select>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
18 <small class="d-block my-2">
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
19 <input
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
20 type="radio"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
21 id="pdfexport-downloadtype-download"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
22 value="download"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
23 v-model="form.downloadType"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
24 selected
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
25 >
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
26 <label for="pdfexport-downloadtype-download" class="ml-1 mr-2">Download</label>
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
27 <input
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
28 type="radio"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
29 id="pdfexport-downloadtype-open"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
30 value="open"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
31 v-model="form.downloadType"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
32 >
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
33 <label for="pdfexport-downloadtype-open" class="ml-1">Open in new window</label>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
34 </small>
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
35 <button
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
36 @click="download"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
37 type="button"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
38 class="btn btn-sm btn-info d-block w-100"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
39 >Generate PDF</button>
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
40 </div>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
41 </div>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
42 </div>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
43 </template>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
44
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
45 <style lang="sass" scoped>
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
46 .pdftool
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
47 position: absolute
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
48 margin-right: $offset
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
49 margin-bottom: $offset
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
50 bottom: 96px
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
51 right: 0
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
52
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
53 .inner
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
54 background-color: white
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
55 margin-left: $small-offset
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
56 opacity: $slight-transparent
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
57 text-align: left
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
58
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
59 .pdftoolcollapsed
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
60 min-height: $icon-height
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
61 width: $icon-width
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
62 transition: $transition-fast
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
63
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
64 .pdftoolexpanded
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
65 width: $identify-width
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
66
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
67 .minimizer
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
68 position: absolute
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
69 z-index: 2
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
70 right: 0
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
71 top: 0
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
72 margin-top: $x-small-offset
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
73 border-radius: $border-radius
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
74 height: $icon-width
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
75 width: $icon-height
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
76 </style>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
77
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
78 <script>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
79 /*
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
80 * This is Free Software under GNU Affero General Public License v >= 3.0
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
81 * without warranty, see README.md and license for details.
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
82 *
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
83 * SPDX-License-Identifier: AGPL-3.0-or-later
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
84 * License-Filename: LICENSES/AGPL-3.0.txt
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
85 *
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
86 * Copyright (C) 2018 by via donau
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
87 * – Österreichische Wasserstraßen-Gesellschaft mbH
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
88 * Software engineering by Intevation GmbH
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
89 *
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
90 * Author(s):
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
91 * Markus Kottländer <markus.kottlaender@intevation.de>
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
92 */
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
93 import { mapState } from "vuex";
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
94 //import { HTTP } from "../application/lib/http";
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
95
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
96 export default {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
97 name: "pdftool",
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
98 data() {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
99 return {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
100 form: {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
101 format: "landscape",
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
102 downloadType: "download"
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
103 }
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
104 };
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
105 },
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
106 computed: {
1123
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
107 ...mapState("application", ["showPdfTool"]),
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1123
diff changeset
108 ...mapState("bottlenecks", ["selectedSurvey"]),
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
109 style() {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
110 return {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
111 "ui-element": true,
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
112 card: true,
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
113 inner: true,
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
114 shadow: true,
1123
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
115 pdftoolexpanded: this.showPdfTool,
d9e6a1f6f394 moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents: 1039
diff changeset
116 pdftoolcollapsed: !this.showPdfTool
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
117 };
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
118 }
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
119 },
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
120 methods: {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
121 download() {
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
122 // generate PDF and open it
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
123 // TODO: replace this src with an API reponse after actually generating PDFs
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
124 let src =
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
125 this.form.format === "landscape"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
126 ? "/img/PrintTemplate-Var2-Landscape.pdf"
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
127 : "/img/PrintTemplate-Var2-Portrait.pdf";
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
128
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
129 let a = document.createElement("a");
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
130 a.href = src;
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
131
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
132 if (this.form.downloadType === "download")
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
133 a.download = src.substr(src.lastIndexOf("/") + 1);
1039
Thomas Junk <thomas.junk@intevation.de>
parents: 1033
diff changeset
134 else a.target = "_blank";
1033
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
135
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
136 document.body.appendChild(a);
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
137 a.click();
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
138 document.body.removeChild(a);
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 }
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 }
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
141 };
fd7059f7cbdc added UI for PDF export (with static PDFs)
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
142 </script>