CSV import

This commit is contained in:
Hillel Coren 2020-12-14 19:42:50 +02:00
parent 2cbad5bf9c
commit df0d8e5d07
2 changed files with 11 additions and 10 deletions

View File

@ -37,7 +37,6 @@ class EntityType extends EnumClass {
static const EntityType gatewayToken = _$gatewayToken; static const EntityType gatewayToken = _$gatewayToken;
static const EntityType invoiceItem = _$invoiceItem; static const EntityType invoiceItem = _$invoiceItem;
static const EntityType design = _$design; static const EntityType design = _$design;
// STARTER: entity type - do not remove comment // STARTER: entity type - do not remove comment
static const EntityType webhook = _$webhook; static const EntityType webhook = _$webhook;
static const EntityType token = _$token; static const EntityType token = _$token;

View File

@ -19,6 +19,7 @@ import 'package:invoiceninja_flutter/ui/settings/import_export_vm.dart';
import 'package:invoiceninja_flutter/utils/dialogs.dart'; import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart';
import 'package:invoiceninja_flutter/utils/strings.dart';
class ImportExport extends StatefulWidget { class ImportExport extends StatefulWidget {
const ImportExport({ const ImportExport({
@ -95,6 +96,7 @@ class _FileImport extends StatefulWidget {
} }
class _FileImportState extends State<_FileImport> { class _FileImportState extends State<_FileImport> {
var _entityType = EntityType.client;
String _filePath; String _filePath;
String _fileName; String _fileName;
bool _isLoading = false; bool _isLoading = false;
@ -108,14 +110,15 @@ class _FileImportState extends State<_FileImport> {
setState(() => _isLoading = true); setState(() => _isLoading = true);
webClient webClient.post(
.post(
url, url,
credentials.token, credentials.token,
filePath: _filePath, filePath: _filePath,
fileIndex: 'file', fileIndex: 'file',
) data: {
.then((dynamic result) { 'entity_type': toSnakeCase('$_entityType'),
},
).then((dynamic result) {
setState(() => _isLoading = false); setState(() => _isLoading = false);
final response = final response =
serializers.deserializeWith(PreImportResponse.serializer, result); serializers.deserializeWith(PreImportResponse.serializer, result);
@ -152,10 +155,8 @@ class _FileImportState extends State<_FileImport> {
child: DropdownButtonHideUnderline( child: DropdownButtonHideUnderline(
child: DropdownButton<EntityType>( child: DropdownButton<EntityType>(
isDense: true, isDense: true,
value: EntityType.client, value: _entityType,
onChanged: (dynamic value) { onChanged: (dynamic value) => _entityType = value,
//
},
items: [EntityType.client] items: [EntityType.client]
.map((entityType) => DropdownMenuItem<EntityType>( .map((entityType) => DropdownMenuItem<EntityType>(
value: entityType, value: entityType,
@ -362,7 +363,8 @@ class _FieldMapper extends StatelessWidget {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final sorted = available.toList(); final sorted = available.toList();
sorted.sort((a, b) => localization.lookup(a).compareTo(localization.lookup(b))); sorted.sort(
(a, b) => localization.lookup(a).compareTo(localization.lookup(b)));
return Row( return Row(
children: [ children: [