Documents
This commit is contained in:
parent
1a91daa91b
commit
954df45b64
|
|
@ -343,3 +343,27 @@ class RemoveFromExpenseMultiselect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearExpenseMultiselect {}
|
class ClearExpenseMultiselect {}
|
||||||
|
|
||||||
|
class SaveExpenseDocumentRequest implements StartSaving {
|
||||||
|
SaveExpenseDocumentRequest({
|
||||||
|
@required this.completer,
|
||||||
|
@required this.filePath,
|
||||||
|
@required this.expense,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Completer completer;
|
||||||
|
final String filePath;
|
||||||
|
final ExpenseEntity expense;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveExpenseDocumentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
|
SaveExpenseDocumentSuccess(this.document);
|
||||||
|
|
||||||
|
final DocumentEntity document;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveExpenseDocumentFailure implements StopSaving {
|
||||||
|
SaveExpenseDocumentFailure(this.error);
|
||||||
|
|
||||||
|
final Object error;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -388,3 +388,27 @@ class RemoveFromProjectMultiselect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearProjectMultiselect {}
|
class ClearProjectMultiselect {}
|
||||||
|
|
||||||
|
class SaveProjectDocumentRequest implements StartSaving {
|
||||||
|
SaveProjectDocumentRequest({
|
||||||
|
@required this.completer,
|
||||||
|
@required this.filePath,
|
||||||
|
@required this.project,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Completer completer;
|
||||||
|
final String filePath;
|
||||||
|
final ProjectEntity project;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveProjectDocumentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
|
SaveProjectDocumentSuccess(this.document);
|
||||||
|
|
||||||
|
final DocumentEntity document;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveProjectDocumentFailure implements StopSaving {
|
||||||
|
SaveProjectDocumentFailure(this.error);
|
||||||
|
|
||||||
|
final Object error;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -405,3 +405,27 @@ class RemoveFromTaskMultiselect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearTaskMultiselect {}
|
class ClearTaskMultiselect {}
|
||||||
|
|
||||||
|
class SaveTaskDocumentRequest implements StartSaving {
|
||||||
|
SaveTaskDocumentRequest({
|
||||||
|
@required this.completer,
|
||||||
|
@required this.filePath,
|
||||||
|
@required this.task,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Completer completer;
|
||||||
|
final String filePath;
|
||||||
|
final TaskEntity task;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveTaskDocumentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
|
SaveTaskDocumentSuccess(this.document);
|
||||||
|
|
||||||
|
final DocumentEntity document;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveTaskDocumentFailure implements StopSaving {
|
||||||
|
SaveTaskDocumentFailure(this.error);
|
||||||
|
|
||||||
|
final Object error;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,3 +360,27 @@ class RemoveFromVendorMultiselect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearVendorMultiselect {}
|
class ClearVendorMultiselect {}
|
||||||
|
|
||||||
|
class SaveVendorDocumentRequest implements StartSaving {
|
||||||
|
SaveVendorDocumentRequest({
|
||||||
|
@required this.completer,
|
||||||
|
@required this.filePath,
|
||||||
|
@required this.vendor,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Completer completer;
|
||||||
|
final String filePath;
|
||||||
|
final VendorEntity vendor;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveVendorDocumentSuccess implements StopSaving, PersistData, PersistUI {
|
||||||
|
SaveVendorDocumentSuccess(this.document);
|
||||||
|
|
||||||
|
final DocumentEntity document;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveVendorDocumentFailure implements StopSaving {
|
||||||
|
SaveVendorDocumentFailure(this.error);
|
||||||
|
|
||||||
|
final Object error;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/document_grid.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/project/view/project_view_vm.dart';
|
||||||
|
|
||||||
|
class ProjectViewDocuments extends StatelessWidget {
|
||||||
|
const ProjectViewDocuments({Key key, @required this.viewModel})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
final ProjectViewVM viewModel;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final project = viewModel.project;
|
||||||
|
|
||||||
|
return DocumentGrid(
|
||||||
|
documents: project.documents.toList(),
|
||||||
|
onUploadDocument: (path) => viewModel.onUploadDocument(context, path),
|
||||||
|
onDeleteDocument: (document, password) =>
|
||||||
|
viewModel.onDeleteDocument(context, document, password),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
@ -5,7 +7,10 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/project_model.dart';
|
import 'package:invoiceninja_flutter/data/models/project_model.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/project/project_actions.dart';
|
import 'package:invoiceninja_flutter/redux/project/project_actions.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/snackbar_row.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/project/view/project_view.dart';
|
import 'package:invoiceninja_flutter/ui/project/view/project_view.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
@ -48,6 +53,8 @@ class ProjectViewVM {
|
||||||
@required this.isSaving,
|
@required this.isSaving,
|
||||||
@required this.isLoading,
|
@required this.isLoading,
|
||||||
@required this.isDirty,
|
@required this.isDirty,
|
||||||
|
@required this.onUploadDocument,
|
||||||
|
@required this.onDeleteDocument,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ProjectViewVM.fromStore(Store<AppState> store) {
|
factory ProjectViewVM.fromStore(Store<AppState> store) {
|
||||||
|
|
@ -93,6 +100,35 @@ class ProjectViewVM {
|
||||||
},
|
},
|
||||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||||
handleEntitiesActions(context, [project], action, autoPop: true),
|
handleEntitiesActions(context, [project], action, autoPop: true),
|
||||||
|
onUploadDocument: (BuildContext context, String filePath) {
|
||||||
|
final Completer<DocumentEntity> completer = Completer<DocumentEntity>();
|
||||||
|
store.dispatch(SaveProjectDocumentRequest(
|
||||||
|
filePath: filePath, project: project, completer: completer));
|
||||||
|
completer.future.then((client) {
|
||||||
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
|
content: SnackBarRow(
|
||||||
|
message: AppLocalization.of(context).uploadedDocument,
|
||||||
|
)));
|
||||||
|
}).catchError((Object error) {
|
||||||
|
showDialog<ErrorDialog>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ErrorDialog(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onDeleteDocument:
|
||||||
|
(BuildContext context, DocumentEntity document, String password) {
|
||||||
|
final completer = snackBarCompleter<Null>(
|
||||||
|
context, AppLocalization.of(context).deletedDocument);
|
||||||
|
completer.future.then<Null>(
|
||||||
|
(value) => store.dispatch(LoadProject(projectId: project.id)));
|
||||||
|
store.dispatch(DeleteDocumentRequest(
|
||||||
|
completer: completer,
|
||||||
|
documentIds: [document.id],
|
||||||
|
password: password,
|
||||||
|
));
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,4 +143,6 @@ class ProjectViewVM {
|
||||||
final bool isSaving;
|
final bool isSaving;
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
final bool isDirty;
|
final bool isDirty;
|
||||||
|
final Function(BuildContext, String) onUploadDocument;
|
||||||
|
final Function(BuildContext, DocumentEntity, String) onDeleteDocument;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue