First (almost) functional CSV importer.

This commit is contained in:
James Cole
2015-07-04 07:53:37 +02:00
parent 26c9b2c353
commit d2c018f7da
12 changed files with 664 additions and 44 deletions

View File

@@ -20,7 +20,9 @@
</div>
<div class="box-body">
{{ 'csv_process_text'|_ }}
<p>{{ 'csv_process_text'|_ }}</p>
<h4>{{ 'csv_more_information' }}</h4>
<p>{{ 'csv_more_information_text'|_ }}</p>
</div>
</div>
@@ -39,7 +41,8 @@
</div>
<div class="box-body">
<form action="{{ route('csv.initial_parse') }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<table class="table">
<thead>
<th>{{ 'cvs_column_name'|_ }}</th>
@@ -52,16 +55,21 @@
<td>{{ header }}</td>
<td>{{ example[index] }}</td>
<td>
{{ Form.select(('role_'~index), roles) }}
{{ Form.select(('role['~index~']'), roles) }}
</td>
<td>
{{ Form.checkbox(('map_'~index),false) }}
{{ Form.checkbox(('map['~index~']'),1,false) }}
</td>
</tr>
{% endfor %}
</table>
<p>
<button type="submit" class="btn btn-success">
{{ 'process_csv_file'|_ }}
</button>
</p>
</form>
</div>
</div>

View File

@@ -21,6 +21,8 @@
</div>
<div class="box-body">
{{ 'csv_index_text'|_ }}
<h4>{{ 'csv_more_information' }}</h4>
{{ 'csv_more_information_text'|_ }}
</div>
</div>
@@ -44,6 +46,7 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
{{ ExpandedForm.checkbox('has_headers',false,null,{helpText: 'csv_header_help'|_}) }}
{{ ExpandedForm.text('date_format','Ymd',{helpText: 'csv_date_help'|_}) }}
{{ ExpandedForm.file('csv') }}

View File

@@ -0,0 +1,83 @@
{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'csv_map'|_ }}</h3>
<!-- ACTIONS MENU -->
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="box-body">
<p>{{ 'csv_map_text'|_ }}</p>
<h4>{{ 'csv_more_information' }}</h4>
<p>{{ 'csv_more_information_text'|_ }}</p>
</div>
</div>
</div>
</div>
<form action="{{ route('csv.save_mapping') }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
{% for index,columnName in map %}
<div class="row">
<div class="col-lg-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ columnName }}</h3>
<!-- ACTIONS MENU -->
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="box-body">
<table class="table">
<thead>
<th>{{ 'cvs_field_value'|_ }}</th>
<th>{{ 'csv_field_mapped_to'|_ }}</th>
</thead>
<tbody>
{% for value in values[index] %}
<tr>
<td>{{ value }}</td>
<td>
{{ Form.select('mapping['~index~']['~value~']',options[index]) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endfor %}
<p>
<button type="submit" class="btn btn-success">
{{ 'save_mapping'|_ }}
</button>
</p>
</form>
{% endblock %}