CSV import
This commit is contained in:
parent
03af952bff
commit
6ea4f0ab0f
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
@ -286,10 +287,13 @@ class __FileMapperState extends State<_FileMapper> {
|
||||||
response.fields2.length > i ? response.fields2[i] : null,
|
response.fields2.length > i ? response.fields2[i] : null,
|
||||||
available: response.available,
|
available: response.available,
|
||||||
mappedTo: _mapping[i] ?? '',
|
mappedTo: _mapping[i] ?? '',
|
||||||
|
mapping: _mapping,
|
||||||
onMappedToChanged: (String value) {
|
onMappedToChanged: (String value) {
|
||||||
print('## onMappedToChanged: $value');
|
print('## onMappedToChanged: $value');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_mapping[i] = value;
|
_mapping[i] = value;
|
||||||
|
widget.formKey.currentState.validate();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -334,6 +338,7 @@ class _FieldMapper extends StatelessWidget {
|
||||||
@required this.mappedTo,
|
@required this.mappedTo,
|
||||||
@required this.available,
|
@required this.available,
|
||||||
@required this.onMappedToChanged,
|
@required this.onMappedToChanged,
|
||||||
|
@required this.mapping,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String field1;
|
final String field1;
|
||||||
|
|
@ -341,6 +346,7 @@ class _FieldMapper extends StatelessWidget {
|
||||||
final BuiltList<String> available;
|
final BuiltList<String> available;
|
||||||
final String mappedTo;
|
final String mappedTo;
|
||||||
final Function onMappedToChanged;
|
final Function onMappedToChanged;
|
||||||
|
final Map<int, String> mapping;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -354,7 +360,10 @@ class _FieldMapper extends StatelessWidget {
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: available.contains(mappedTo) ? mappedTo : null,
|
value: available.contains(mappedTo) ? mappedTo : null,
|
||||||
validator: (value) => 'test',
|
validator: (value) => (value ?? '').isNotEmpty &&
|
||||||
|
mapping.values.where((element) => element == value).length > 1
|
||||||
|
? 'ERROR'
|
||||||
|
: null,
|
||||||
onChanged: onMappedToChanged,
|
onChanged: onMappedToChanged,
|
||||||
items: [
|
items: [
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue