This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
307 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
(function(){ | ||
var fileUploadObj = $('#fileupload'), dropArea = $('.drop-area'), uploadButton = $('#upload-button'), | ||
processingModal = $('#processing-modal'); | ||
var selectedFile; | ||
|
||
function transformInServer() { | ||
// mask the page | ||
processingModal.modal('show'); | ||
$.ajax('/to-spreadsheet/go/', { | ||
'dataType': 'json', | ||
'data': $('#unflatten-options').serialize(), | ||
'method': 'POST' | ||
}) | ||
.done(showLinksToResults) | ||
.fail(showErrors) | ||
; | ||
} | ||
|
||
function showLinksToResults(data) { | ||
if (data.xlsx) { | ||
$('.response-success .download-xlsx').attr('href', data.xlsx.url); | ||
$('.response-success .file-size-xlsx').html(utils.readableFileSize(data.xlsx.size)); | ||
} | ||
if (data.xlsx) { | ||
$('.response-success .download-csv').attr('href', data.csv.url); | ||
$('.response-success .file-size-csv').html(utils.readableFileSize(data.csv.size)); | ||
} | ||
$('.response-success').removeClass('hidden'); | ||
} | ||
|
||
function showErrors() { | ||
|
||
} | ||
|
||
/* listen when a file is selected or dropped in the designated area */ | ||
fileUploadObj.bind('fileuploadadd', function (e, data) { | ||
dropArea.removeClass('empty'); | ||
// hide default message | ||
dropArea.children('.msg-empty').addClass('hidden'); | ||
// fill area with file's name and size | ||
dropArea.children('file-selected') | ||
.prepend(data.files[0].name) | ||
.children('small') | ||
.html(utils.readableFileSize(data.files[0].size)) | ||
; | ||
// show "Start" button | ||
uploadButton.removeClass('hidden'); | ||
selectedFile = data; | ||
}); | ||
|
||
/* "Start" button click listener */ | ||
uploadButton.click(function () { | ||
// we don't want to add any more files | ||
fileUploadObj.fileupload('disable'); | ||
|
||
selectedFile.submit() // send the file | ||
.done() | ||
; | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
default/templates/default/snippets/unflatten-options-modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{% load i18n %} | ||
|
||
<div class="modal fade" tabindex="-1" role="dialog" id="unflatten-options-modal"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> | ||
</button> | ||
<h4 class="modal-title">{% trans "Options" %}</h4> | ||
</div> | ||
<div class="modal-body form-horizontal"> | ||
<form id="unflatten-options"> | ||
<input type="hidden" name="csrfmiddlewaretoken" value="{{csrf_token}}"> | ||
<div class="form-group"> | ||
<label for="{{ form.schema_version.id_for_label }}" class="col-sm-4"> | ||
{{ form.schema_version.label }} | ||
</label> | ||
<div class="col-sm-8"> | ||
{{ form.schema_version }} | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.output_format.id_for_label }}" class="col-sm-4"> | ||
{{ form.output_format.label }} | ||
</label> | ||
<div class="col-sm-8"> | ||
{{ form.output_format }} | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.use_titles.id_for_label }}" | ||
class="col-sm-4">{{ form.use_titles.label }}</label> | ||
<div class="col-sm-8"> | ||
{{ form.use_titles }} | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-4">{% trans "Filter data by field" %}</label> | ||
<div class="col-sm-8"> | ||
{{ form.filter_field }} | ||
<span class="help-block">{{ form.filter_field.help_text }}</span> | ||
{{ form.filter_value }} | ||
<span class="help-block"> {{ form.filter_value.help_text }}</span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.preserve_fields.id_for_label }}" class="col-sm-4"> | ||
{{ form.preserve_fields.label }} | ||
</label> | ||
<div class="col-sm-8"> | ||
{{ form.preserve_fields }} | ||
<span class="help-block"> {{ form.preserve_fields.help_text }}</span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.remove_empty_schema_columns.id_for_label }}" class="col-sm-4"> | ||
{{ form.remove_empty_schema_columns.label }} | ||
</label> | ||
<div class="col-sm-8"> | ||
{{ form.remove_empty_schema_columns }} | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" data-dismiss="modal">{% trans "Close" %}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% with id=widget.attrs.id %} | ||
<div{% if id %} id="{{ id }}"{% endif %}{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}> | ||
{% for group, options, index in widget.optgroups %} | ||
{% if group %} | ||
<div>{{ group }}<div{% if id %} id="{{ id }}_{{ index }}"{% endif %}> | ||
{% endif %} | ||
{% for option in options %} | ||
{% include option.template_name with widget=option %} | ||
{% endfor %} | ||
{% if group %} | ||
</div></div> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
{% endwith %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<label {% if widget.attrs.id %}for="{{ widget.attrs.id }}" {% endif %} | ||
{% if widget.attrs.option_class %} class="{{ widget.attrs.option_class }}"{% endif %}> | ||
{% include "django/forms/widgets/input.html" %} | ||
{{ widget.label }} | ||
</label> |
Oops, something went wrong.