Client activity
This commit is contained in:
parent
a5208884cb
commit
1cd3787668
|
|
@ -15,10 +15,16 @@ class ClientRepository {
|
|||
this.webClient = const WebClient(),
|
||||
});
|
||||
|
||||
Future<ClientEntity> loadItem(CompanyEntity company, AuthState auth, int entityId) async {
|
||||
Future<ClientEntity> loadItem(CompanyEntity company, AuthState auth, int entityId, bool loadActivities) async {
|
||||
|
||||
String url = '${auth.url}/clients/$entityId';
|
||||
|
||||
if (loadActivities) {
|
||||
url += '?include=activities';
|
||||
}
|
||||
|
||||
final dynamic response = await webClient.get(
|
||||
'${auth.url}/clients/$entityId?include=activities', company.token);
|
||||
url, company.token);
|
||||
|
||||
final ClientItemResponse clientResponse = serializers.deserializeWith(
|
||||
ClientItemResponse.serializer, response);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ class UpdateClient implements PersistUI {
|
|||
class LoadClient {
|
||||
final Completer completer;
|
||||
final int clientId;
|
||||
final bool loadActivities;
|
||||
|
||||
LoadClient({this.completer, this.clientId});
|
||||
LoadClient({this.completer, this.clientId, this.loadActivities});
|
||||
}
|
||||
|
||||
class LoadClientActivity {
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ Middleware<AppState> _loadClient(ClientRepository repository) {
|
|||
|
||||
store.dispatch(LoadClientRequest());
|
||||
repository
|
||||
.loadItem(state.selectedCompany, state.authState, action.clientId)
|
||||
.loadItem(state.selectedCompany, state.authState, action.clientId, action.loadActivities)
|
||||
.then((client) {
|
||||
store.dispatch(LoadClientSuccess(client));
|
||||
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ class _ClientViewState extends State<ClientView>
|
|||
return true;
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme
|
||||
.of(context)
|
||||
.backgroundColor,
|
||||
appBar: _CustomAppBar(
|
||||
viewModel: viewModel,
|
||||
controller: _controller,
|
||||
|
|
@ -155,7 +152,7 @@ class _CustomTabBarViewState extends State<CustomTabBarView> {
|
|||
|
||||
if (widget.controller.index == 2 && viewModel.client.activities.isEmpty &&
|
||||
!viewModel.isLoading) {
|
||||
viewModel.onRefreshed(context);
|
||||
viewModel.onRefreshed(context, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,15 +164,15 @@ class _CustomTabBarViewState extends State<CustomTabBarView> {
|
|||
controller: widget.controller,
|
||||
children: <Widget>[
|
||||
RefreshIndicator(
|
||||
onRefresh: () => viewModel.onRefreshed(context),
|
||||
onRefresh: () => viewModel.onRefreshed(context, false),
|
||||
child: ClientOverview(viewModel: viewModel),
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: () => viewModel.onRefreshed(context),
|
||||
onRefresh: () => viewModel.onRefreshed(context, false),
|
||||
child: ClientViewDetails(client: viewModel.client),
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: () => viewModel.onRefreshed(context),
|
||||
onRefresh: () => viewModel.onRefreshed(context, true),
|
||||
child: ClientViewActivity(client: viewModel.client),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -45,11 +45,8 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
|||
|
||||
List<Widget> _buildDetailsList() {
|
||||
final listTiles = <Widget>[];
|
||||
|
||||
listTiles
|
||||
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
||||
|
||||
final contacts = client.contacts;
|
||||
|
||||
contacts.forEach((contact) {
|
||||
if ((contact.email ?? '').isNotEmpty) {
|
||||
listTiles.add(AppListTile(
|
||||
|
|
@ -102,6 +99,7 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
|||
));
|
||||
}
|
||||
|
||||
/*
|
||||
if (listTiles.isNotEmpty) {
|
||||
listTiles.add(
|
||||
Container(
|
||||
|
|
@ -110,6 +108,7 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
|||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
if ((client.vatNumber ?? '').isNotEmpty) {
|
||||
listTiles.add(AppListTile(
|
||||
|
|
@ -158,6 +157,9 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
|||
}));
|
||||
}
|
||||
|
||||
listTiles
|
||||
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
||||
|
||||
return listTiles;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class ClientViewVM {
|
|||
final Function(BuildContext) onEditPressed;
|
||||
final Function onBackPressed;
|
||||
final Function(BuildContext) onInvoicesPressed;
|
||||
final Function(BuildContext) onRefreshed;
|
||||
final Function(BuildContext, bool) onRefreshed;
|
||||
final bool isSaving;
|
||||
final bool isLoading;
|
||||
final bool isDirty;
|
||||
|
|
@ -62,9 +62,9 @@ class ClientViewVM {
|
|||
final state = store.state;
|
||||
final client = state.clientState.map[state.clientUIState.selectedId];
|
||||
|
||||
Future<Null> _handleRefresh(BuildContext context) {
|
||||
Future<Null> _handleRefresh(BuildContext context, bool loadActivities) {
|
||||
final Completer<ClientEntity> completer = Completer<ClientEntity>();
|
||||
store.dispatch(LoadClient(completer: completer, clientId: client.id));
|
||||
store.dispatch(LoadClient(completer: completer, clientId: client.id, loadActivities: loadActivities));
|
||||
return completer.future.then((_) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
|
|
@ -94,7 +94,7 @@ class ClientViewVM {
|
|||
store.dispatch(FilterInvoicesByClient(client.id));
|
||||
store.dispatch(ViewInvoiceList(context));
|
||||
},
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onRefreshed: (context, loadActivities) => _handleRefresh(context, loadActivities),
|
||||
onBackPressed: () =>
|
||||
store.dispatch(UpdateCurrentRoute(ClientScreen.route)),
|
||||
onActionSelected: (BuildContext context, EntityAction action) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue