From 779e5e84e37278b8f3255a1061f2137f5b6a3a7d Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Tue, 16 Aug 2016 12:37:35 +0200
Subject: refactor file up and download

---
 web/src/js/components/common/FileChooser.jsx | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 web/src/js/components/common/FileChooser.jsx

(limited to 'web/src/js/components/common/FileChooser.jsx')

diff --git a/web/src/js/components/common/FileChooser.jsx b/web/src/js/components/common/FileChooser.jsx
new file mode 100644
index 00000000..d8a80ad7
--- /dev/null
+++ b/web/src/js/components/common/FileChooser.jsx
@@ -0,0 +1,27 @@
+import React, { PropTypes } from 'react'
+
+FileChooser.propTypes = {
+    icon: PropTypes.string,
+    text: PropTypes.string,
+    className: PropTypes.string,
+    title: PropTypes.string,
+    onOpenFile: PropTypes.func.isRequired
+}
+
+export default function FileChooser({ icon, text, className, title, onOpenFile }) {
+    let fileInput;
+    return (
+        <a onClick={() => fileInput.click()}
+           className={className}
+           title={title}>
+            <i className={'fa fa-fw ' + icon}></i>
+            {text}
+             <input
+                ref={ref => fileInput = ref}
+                className="hidden"
+                type="file"
+                onChange={e => { e.preventDefault(); if(e.target.files.length > 0) onOpenFile(e.target.files[0]); fileInput = "";}}
+            />
+        </a>
+    )
+}
-- 
cgit v1.2.3


From a416732665aa7a0fb56e20f9888fd9488750a4df Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 18 Aug 2016 16:44:49 +0200
Subject: refactor dropdown menu, view selector

---
 web/src/js/components/common/FileChooser.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/src/js/components/common/FileChooser.jsx')

diff --git a/web/src/js/components/common/FileChooser.jsx b/web/src/js/components/common/FileChooser.jsx
index d8a80ad7..d59d2d6d 100644
--- a/web/src/js/components/common/FileChooser.jsx
+++ b/web/src/js/components/common/FileChooser.jsx
@@ -11,7 +11,7 @@ FileChooser.propTypes = {
 export default function FileChooser({ icon, text, className, title, onOpenFile }) {
     let fileInput;
     return (
-        <a onClick={() => fileInput.click()}
+        <a href='#' onClick={() => fileInput.click()}
            className={className}
            title={title}>
             <i className={'fa fa-fw ' + icon}></i>
-- 
cgit v1.2.3

