Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #273 from EC-Nordbund/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
mathe42 authored Nov 29, 2018
2 parents 22a3d58 + 77d74dd commit 489cf4c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 5 deletions.
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ec-verwaltungs-app",
"version": "1.1.0",
"version": "1.1.1",
"description": "EC-Verwaltungs Application",
"keywords": [],
"homepage": "https://ec-nordbund.de",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ec-verwaltungs-app",
"version": "1.1.0",
"version": "1.1.1",
"description": "EC-Verwaltungs Application",
"keywords": [],
"homepage": "https://ec-nordbund.de",
Expand Down Expand Up @@ -53,9 +53,11 @@
"apollo-link-error": "^1.1.0",
"apollo-link-http": "^1.5.4",
"apollo-utilities": "^1.0.15",
"docxtemplater": "^3.9.4",
"electron-settings": "^3.2.0",
"electron-unhandled": "^1.1.0",
"js-sha3": "^0.8.0",
"jszip": "2",
"lazyfilter": "https://github.com/ecnordbund/lazyFilter.git",
"node-fetch": "^2.1.2",
"vue": "^2.5.16",
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/docx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const jsZip: any
export declare const Docxtemplater: any
5 changes: 5 additions & 0 deletions src/plugins/docx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as _1 from 'jszip'
import * as _2 from 'docxtemplater'

export const jsZip = _1
export const Docxtemplater = _2
57 changes: 56 additions & 1 deletion src/views/anmeldungen/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
{subTitle: 'Klettern', title: data.anmeldung.klettern?'Ja':'Nein'},
{subTitle: 'Sich Entfenen (in 3er Gruppen)', title: data.anmeldung.sichEntfernen?'Ja':'Nein'},
{subTitle: 'Boot-Fahren', title: data.anmeldung.bootFahren?'Ja':'Nein'},
{subTitle: 'Schwimmen', title: 'N/A'},
{subTitle: 'Schwimmen', title: ['Nicht erlaubt', 'Nichtschwimmer', 'Mittelmäßig', 'Gut'][data.anmeldung.schwimen]},
{subTitle: 'Adresse in TN-Liste', title: data.anmeldung.fahrgemeinschaften?'Ja':'Nein'}
]"
:mapper="item=>item"
Expand Down Expand Up @@ -167,6 +167,9 @@
<!-- <v-btn @click="soon">Aus Warteliste entfernen</v-btn> -->
<v-btn @click="nachruecken" v-if="data.anmeldung.wartelistenPlatz > 0">Nachrücken</v-btn>
<v-btn @click="soon">Zahlung</v-btn>
<v-btn @click="createLetter">
(Workaround) Brief generieren
</v-btn>
</template>

<template slot="forms">
Expand Down Expand Up @@ -205,6 +208,9 @@ import {} from '@/plugins/formConfig/index'
import { getClient } from '@/plugins/apollo'
import event from '@/plugins/eventbus'
import {jsZip, Docxtemplater} from '@/plugins/docx'
import {exec} from 'child_process'
const loadGQL = gql`
query($authToken: String!, $anmeldeID: String!) {
anmeldung(
Expand Down Expand Up @@ -451,5 +457,54 @@ export default class anmeldungsDetails extends reloaderBase {
)
}
}
createLetter(){
const filenames = electron.remote.dialog.showOpenDialog(
{
title: 'Word Datei des Briefes auswählen',
filters: [
{name: 'Word', extensions : ['docx']}
],
properties : ['openFile']
}
)
if(filenames){
const fs = eval('require("fs")')
const file = filenames[0]
const fileContent = fs.readFileSync(file, 'binary')
const zipData = new jsZip(fileContent)
const briefTemplate = new Docxtemplater()
briefTemplate.loadZip(zipData)
console.log(this.data.anmeldung)
briefTemplate.setData(this.manageData(this.data.anmeldung))
briefTemplate.render()
const fertigerBrief = briefTemplate.getZip().generate({type: 'nodebuffer'});
const tmpPath = electron.remote.app.getPath('temp').split('\\').join('/')
const tmpFile = tmpPath + '/' + Math.random().toString(36).substring(7) + '.docx'
fs.writeFileSync(tmpFile, fertigerBrief)
console.log(tmpFile)
eval(`require('child_process').exec('start ${tmpFile}')`)
} else {
alert('Kein Brief ausgewählt.')
}
}
manageData(data:any) {
const nData: any = {}
Object.keys(data).forEach(key=>{
if(data[key] && typeof data[key]==='object') {
const rec = this.manageData(data[key])
Object.keys(rec).forEach(nKey=>{
nData[key + '.' + nKey] = rec[nKey]
})
} else {
nData[key] = data[key]
}
})
return nData
}
}
</script>
9 changes: 8 additions & 1 deletion src/views/veranstaltungen/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
{name: 'person.nachname', label: 'Nachname'},
{name: 'person.gebDat.german', label: 'GebDat'},
{name: 'role', label: 'Role', handleOutside: true},
{name: 'wartelistenPlatz', label: 'Position auf Warteliste', width: '100px'}
{name: 'wartelistenPlatz', label: 'Position auf Warteliste', width: '100px'},
{name: 'anmeldeZeitpunkt.german', label: 'Anmeldezeitpunkt', width: '75px'}
]"
:countAnpassung="-3"
title="..."
Expand Down Expand Up @@ -336,6 +337,12 @@ const loadGQL = gql`
}
}
wartelistenPlatz
anmeldeZeitpunkt {
german
day
month
year
}
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2941,6 +2941,12 @@ docsearch.js@^2.5.2:
hogan.js "^3.0.2"
to-factory "^1.0.0"

docxtemplater@^3.9.4:
version "3.9.4"
resolved "https://registry.yarnpkg.com/docxtemplater/-/docxtemplater-3.9.4.tgz#3ba3e236dd74ed0b964eada9590dd1c4fa5b9d27"
dependencies:
xmldom "^0.1.27"

dom-converter@~0.2:
version "0.2.0"
resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768"
Expand Down Expand Up @@ -4791,7 +4797,7 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"

jszip@^2.6.1:
jszip@2, jszip@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-2.6.1.tgz#b88f3a7b2e67a2a048152982c7a3756d9c4828f0"
dependencies:
Expand Down Expand Up @@ -9051,6 +9057,10 @@ xlsx-template@^0.3.1:
elementtree "0.1.6"
jszip "^2.6.1"

xmldom@^0.1.27:
version "0.1.27"
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9"

[email protected]:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"
Expand Down

0 comments on commit 489cf4c

Please sign in to comment.