Commit ba17c97f authored by Curtis Adam's avatar Curtis Adam

Update card impot formular to support different file types

parent 311e53db
......@@ -173,5 +173,10 @@ $themes: (
#showPreviewHelp {
color: $primary-color !important;
}
.import-type.active {
color: white !important;
background-color: $primary-color !important;
}
}
}
......@@ -81,6 +81,9 @@
"upload-form": {
"popover-content": "Unterstützt werden die Dateiformate JSON und CSV (Excel, kommagetrennt). Die folgenden Links zeigen die erforderliche Dateistruktur:",
"upload-title": "Karten importieren",
"upload-type": "Dateityp",
"upload-type1": ".cards",
"upload-type2": "Mnemosyne",
"wait": "Dateien werden hochgeladen",
"select-file": "Datei auswählen",
"success": "Karten erfolgreich importiert!",
......
......@@ -89,6 +89,9 @@
"upload-form": {
"popover-content": "Here you can upload your own cards to the cardset. Currently the formats JSON and CSV (Excel, comma-separated) are supported. Please have a look at these templates:",
"upload-title": "Import cards",
"upload-type": "File type",
"upload-type1": ".cards",
"upload-type2": "Mnemosyne",
"wait": "Uploading files…",
"select-file": "Select file",
"success": "Cards successfully imported!",
......
......@@ -1153,11 +1153,36 @@
<p>{{_ "upload-form.popover-content"}}</p>
<a role='button' target='_blank' class='btn btn-default' href='/examples/example.json'>JSON</a>
<a role='button' target='_blank' class='btn btn-default' href='/examples/example.csv.txt'>CSV</a>
<hr/>
<h4>{{_ "upload-form.upload-type"}}</h4>
<div id="importTypeGroup" class="form-group btn-group" role="group" data-toggle="buttons">
<label id="importType1"
class="btn btn-default btn-white import-type {{#if importType 1}}active{{/if}}"
data-type="1">
{{#if importType 1}}
<input type="radio" id="tabFocus" name="cardType" value="1" checked
data-type="1">
{{else}}
<input type="radio" name="cardType" value="1" data-type="1">
{{/if}}
{{_ "upload-form.upload-type1"}}
</label>
<label id="importType2"
class="btn btn-default btn-white import-type {{#if importType 2}}active{{/if}}"
data-type="2">
{{#if importType 2}}
<input type="radio" id="tabFocus" name="cardType" value="2" checked
data-type="2">
{{else}}
<input type="radio" name="cardType" value="2" data-type="2">
{{/if}}
{{_ "upload-form.upload-type2"}}
</label>
</div>
</div>
<hr/>
<div class="modal-footer">
{{#unless uploading}}
<button id="importCancel" class="btn btn-default btn-raised col-xs-12 col-sm-3 "
<button id="importCancel" class="btn btn-default btn-raised btn-block col-xs-12 col-sm-4"
data-dismiss="modal">{{_
"modal-dialog.cancel"}}</button>
<span class="btn btn-success btn-file btn-raised col-xs-12 col-sm-4 pull-right">
......@@ -1166,7 +1191,8 @@
{{else}}
<p><i class="fa fa-spin fa-refresh"></i>{{_ "upload-form.wait"}}</p>
{{/unless}}
<br>
<br>
<div id="uploadError"></div>
</div>
</div>
......
......@@ -1068,6 +1068,7 @@ Template.cardsetEndLearnForm.events({
}
});
Session.setDefault('importType', 1);
/*
* ############################################################################
* cardsetImportForm
......@@ -1087,10 +1088,19 @@ Template.cardsetImportForm.onRendered(function () {
Template.cardsetImportForm.helpers({
uploading: function () {
return Template.instance().uploading.get();
},
importType: function (importType) {
return Session.get('importType') === importType;
}
});
Template.cardsetImportForm.events({
"click #importType1": function () {
Session.set('importType', 1);
},
"click #importType2": function () {
Session.set('importType', 2);
},
'change [name="uploadFile"]': function (evt, tmpl) {
tmpl.uploading.set(true);
var cardset_id = Template.parentData(1)._id;
......
......@@ -80,14 +80,13 @@ $font_5: sans-serif;
}
.btn-file {
margin-top: 0;
position: relative;
overflow: hidden;
input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
......@@ -99,6 +98,10 @@ $font_5: sans-serif;
}
}
#uploadError {
text-align: center;
}
#pictureModal .modal-header {
min-height: 50px;
}
......@@ -470,3 +473,7 @@ th .field-tip .tip-content {
.fa-square {
transform: scale(1.35, 1) !important;
}
.import-type:last-child {
border-right: 0 !important;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment