Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jul 6, 2023
2 parents ed217cd + e82cc82 commit 9962016
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 197 deletions.
3 changes: 3 additions & 0 deletions lib/data/models/document_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ abstract class DocumentEntity extends Object

String get downloadUrl => '/documents/$hash';

bool get isImage =>
name.endsWith('.png') || name.endsWith('.jpg') || name.endsWith('.jpeg');

int compareTo(DocumentEntity document,
[String sortField, bool sortAscending = true]) {
int response = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/data/models/product_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ abstract class ProductEntity extends Object
}

if (response == 0) {
response = product.createdAt.compareTo(createdAt);
response = productA.price.compareTo(productB.price);
}

return response;
Expand Down
4 changes: 2 additions & 2 deletions lib/redux/app/app_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Middleware<AppState> _createAccountLoaded() {

next(action);

updateWidgetData();
WidgetUtils.updateData();
};
}

Expand Down Expand Up @@ -521,7 +521,7 @@ Middleware<AppState> _createDataRefreshed() {

next(action);

updateWidgetData();
WidgetUtils.updateData();

if (store.state.company.isLarge && !store.state.isLoaded) {
store.dispatch(LoadClients());
Expand Down
5 changes: 3 additions & 2 deletions lib/redux/auth/auth_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:async';
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
import 'package:invoiceninja_flutter/utils/widgets.dart';

// Package imports:
import 'package:redux/redux.dart';
Expand Down Expand Up @@ -74,6 +75,8 @@ Middleware<AppState> _createUserLogout() {
LoginScreen.route, (Route<dynamic> route) => false);

store.dispatch(UpdateCurrentRoute(LoginScreen.route));

WidgetUtils.clearData();
};
}

Expand All @@ -84,8 +87,6 @@ Middleware<AppState> _createUserLogoutAll(AuthRepository repository) {
repository
.logout(credentials: store.state.credentials)
.then((dynamic response) {
print('## DONE MIDDLE');

store.dispatch(UserLogoutAllSuccess());
store.dispatch(UserLogout());
}).catchError((Object error) {
Expand Down
4 changes: 2 additions & 2 deletions lib/redux/settings/settings_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Middleware<AppState> _saveCompany(SettingsRepository settingsRepository) {
.then((company) {
store.dispatch(SaveCompanySuccess(company));
action.completer.complete();
updateWidgetData();
WidgetUtils.updateData();
}).catchError((Object error) {
print(error);
store.dispatch(SaveCompanyFailure(error));
Expand Down Expand Up @@ -152,7 +152,7 @@ Middleware<AppState> _saveAuthUser(SettingsRepository settingsRepository) {
if (action.completer != null) {
action.completer.complete();
}
updateWidgetData();
WidgetUtils.updateData();
}).catchError((Object error) {
print(error);
store.dispatch(SaveAuthUserFailure(error));
Expand Down
40 changes: 28 additions & 12 deletions lib/ui/app/document_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
import 'package:invoiceninja_flutter/ui/app/dashed_rect.dart';
import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pinch_zoom/pinch_zoom.dart';
import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart';

// Project imports:
import 'package:invoiceninja_flutter/data/models/models.dart';
Expand Down Expand Up @@ -304,9 +305,25 @@ class DocumentTile extends StatelessWidget {
child: PopupMenuButton<String>(
onSelected: (value) async {
if (value == localization.view) {
launchUrl(Uri.parse(state.account.defaultUrl +
document.downloadUrl +
'?inline=true'));
final http.Response response = await WebClient()
.get(document.url, state.credentials.token,
rawResponse: true);
showDialog<void>(
context: navigatorKey.currentContext,
builder: (context) {
return AlertDialog(
actions: [
TextButton(
onPressed: () =>
Navigator.of(context).pop(),
child: Text(localization.close
.toUpperCase())),
],
content: PinchZoom(
child: Image.memory(
response.bodyBytes),
));
});
} else if (value == localization.download) {
final http.Response response = await WebClient()
.get(document.url, state.credentials.token,
Expand Down Expand Up @@ -382,15 +399,14 @@ class DocumentTile extends StatelessWidget {
},
itemBuilder: (context) {
return [
/*
PopupMenuItem<String>(
child: IconText(
text: localization.view,
icon: Icons.open_in_browser,
if (document.isImage)
PopupMenuItem<String>(
child: IconText(
text: localization.view,
icon: Icons.open_in_browser,
),
value: localization.view,
),
value: localization.view,
),
*/
PopupMenuItem<String>(
child: IconText(
text: localization.download,
Expand Down
18 changes: 13 additions & 5 deletions lib/ui/app/menu_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -980,10 +980,16 @@ class _DrawerTileState extends State<DrawerTile> {
),
);

if (state.isMenuCollapsed) {
child = Tooltip(
message: widget.title,
child: child,
if (isSelected) {
child = Stack(
children: [
child,
SizedBox(
width: 6,
height: 40,
child: ColoredBox(color: state.accentColor),
),
],
);
}

Expand Down Expand Up @@ -1014,7 +1020,9 @@ class SidebarFooter extends StatelessWidget {
Expanded(child: SizedBox())
] else ...[
if (!Config.DEMO_MODE && !state.isDemo && account.isOld)
if (state.isSelfHosted && !account.isSchedulerRunning)
if (state.isSelfHosted &&
!account.isSchedulerRunning &&
state.userCompany.isAdmin)
IconButton(
tooltip: prefState.enableTooltips ? localization.error : '',
icon: Icon(
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/product/product_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ProductPresenter extends EntityPresenter {
}

static List<String> getAllTableFields(UserCompanyEntity userCompany) {
final company = userCompany.company;

return [
...getDefaultTableFields(userCompany),
...EntityPresenter.getBaseFields(),
Expand All @@ -41,7 +43,7 @@ class ProductPresenter extends EntityPresenter {
ProductFields.taxName3,
ProductFields.stockQuantity,
ProductFields.notificationThreshold,
ProductFields.taxCategory,
if (company.calculateTaxes) ProductFields.taxCategory,
];
}

Expand Down
54 changes: 27 additions & 27 deletions lib/ui/settings/payment_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,32 @@ class _PaymentSettingsState extends State<PaymentSettings> {
),
SizedBox(height: 8),
FormCard(children: [
if (!state.uiState.settingsUIState.isFiltered) ...[
if (!state.uiState.settingsUIState.isFiltered)
BoolDropdownButton(
label: localization.enableApplyingPaymentsLater,
label: localization.adminInitiatedPayments,
value: company.enableApplyingPayments,
helpLabel: localization.enableApplyingPaymentsHelp,
helpLabel: localization.adminInitiatedPaymentsHelp,
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..enableApplyingPayments = value)),
),
BoolDropdownButton(
label: localization.convertCurrency,
value: company.convertPaymentCurrency,
helpLabel: localization.convertPaymentCurrencyHelp,
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..convertPaymentCurrency = value)),
BoolDropdownButton(
label: localization.clientInitiatedPayments,
value: settings.clientInitiatedPayments,
helpLabel: localization.clientInitiatedPaymentsHelp,
onChanged: (value) => viewModel.onSettingsChanged(
settings.rebuild((b) => b..clientInitiatedPayments = value)),
),
if (settings.clientInitiatedPayments == true)
Padding(
padding: const EdgeInsets.only(top: 16),
child: DecoratedFormField(
label: localization.minimumPaymentAmount,
controller: _minimumPaymentAmountController,
isMoney: true,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
),
),
],
BoolDropdownButton(
label: localization.allowOverPayment,
value: settings.clientPortalAllowOverPayment,
Expand All @@ -246,23 +256,13 @@ class _PaymentSettingsState extends State<PaymentSettings> {
decimal: true, signed: true),
),
),
BoolDropdownButton(
label: localization.clientInitiatedPayments,
value: settings.clientInitiatedPayments,
helpLabel: localization.clientInitiatedPaymentsHelp,
onChanged: (value) => viewModel.onSettingsChanged(
settings.rebuild((b) => b..clientInitiatedPayments = value)),
),
if (settings.clientInitiatedPayments == true)
Padding(
padding: const EdgeInsets.only(top: 16),
child: DecoratedFormField(
label: localization.minimumPaymentAmount,
controller: _minimumPaymentAmountController,
isMoney: true,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
),
if (!state.uiState.settingsUIState.isFiltered)
BoolDropdownButton(
label: localization.convertCurrency,
value: company.convertPaymentCurrency,
helpLabel: localization.convertPaymentCurrencyHelp,
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..convertPaymentCurrency = value)),
),
]),
FormCard(
Expand Down
Loading

0 comments on commit 9962016

Please sign in to comment.