Improve documents
This commit is contained in:
parent
79d3008a2d
commit
fb0418c3d7
|
|
@ -544,7 +544,7 @@ abstract class CompanyEntity extends Object
|
||||||
FormatNumberType get listDisplayAmountType => null;
|
FormatNumberType get listDisplayAmountType => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get listDisplayName => null;
|
String get listDisplayName => settings?.name ?? '';
|
||||||
|
|
||||||
bool hasCustomField(String field) => getCustomFieldLabel(field).isNotEmpty;
|
bool hasCustomField(String field) => getCustomFieldLabel(field).isNotEmpty;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class DocumentFields {
|
||||||
static const String width = 'width';
|
static const String width = 'width';
|
||||||
static const String height = 'height';
|
static const String height = 'height';
|
||||||
static const String hash = 'hash';
|
static const String hash = 'hash';
|
||||||
|
static const String linkedTo = 'linked_to';
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class DocumentEntity extends Object
|
abstract class DocumentEntity extends Object
|
||||||
|
|
|
||||||
|
|
@ -293,22 +293,16 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
// STARTER: states switch map - do not remove comment
|
// STARTER: states switch map - do not remove comment
|
||||||
case EntityType.schedule:
|
case EntityType.schedule:
|
||||||
return scheduleState.map;
|
return scheduleState.map;
|
||||||
|
|
||||||
case EntityType.transactionRule:
|
case EntityType.transactionRule:
|
||||||
return transactionRuleState.map;
|
return transactionRuleState.map;
|
||||||
|
|
||||||
case EntityType.transaction:
|
case EntityType.transaction:
|
||||||
return transactionState.map;
|
return transactionState.map;
|
||||||
|
|
||||||
case EntityType.bankAccount:
|
case EntityType.bankAccount:
|
||||||
return bankAccountState.map;
|
return bankAccountState.map;
|
||||||
|
|
||||||
case EntityType.purchaseOrder:
|
case EntityType.purchaseOrder:
|
||||||
return purchaseOrderState.map;
|
return purchaseOrderState.map;
|
||||||
|
|
||||||
case EntityType.recurringExpense:
|
case EntityType.recurringExpense:
|
||||||
return recurringExpenseState.map;
|
return recurringExpenseState.map;
|
||||||
|
|
||||||
case EntityType.subscription:
|
case EntityType.subscription:
|
||||||
return subscriptionState.map;
|
return subscriptionState.map;
|
||||||
case EntityType.taskStatus:
|
case EntityType.taskStatus:
|
||||||
|
|
@ -367,6 +361,12 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
return staticState.dateFormatMap;
|
return staticState.dateFormatMap;
|
||||||
case EntityType.timezone:
|
case EntityType.timezone:
|
||||||
return staticState.timezoneMap;
|
return staticState.timezoneMap;
|
||||||
|
case EntityType.company:
|
||||||
|
return BuiltMap(Map<String, SelectableEntity>.fromIterable(
|
||||||
|
companies,
|
||||||
|
key: (dynamic item) => item.id,
|
||||||
|
value: (dynamic item) => item,
|
||||||
|
));
|
||||||
case EntityType.dashboard:
|
case EntityType.dashboard:
|
||||||
case EntityType.reports:
|
case EntityType.reports:
|
||||||
case EntityType.settings:
|
case EntityType.settings:
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,110 @@ DocumentState _setLoadedCompany(
|
||||||
..parentType = EntityType.company));
|
..parentType = EntityType.company));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
company.clients.forEach((client) {
|
||||||
|
client.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = client.id
|
||||||
|
..parentType = EntityType.client));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.credits.forEach((credit) {
|
||||||
|
credit.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = credit.id
|
||||||
|
..parentType = EntityType.credit));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.expenses.forEach((expense) {
|
||||||
|
expense.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = expense.id
|
||||||
|
..parentType = EntityType.expense));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.groups.forEach((group) {
|
||||||
|
group.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = group.id
|
||||||
|
..parentType = EntityType.group));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.invoices.forEach((invoice) {
|
||||||
|
invoice.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = invoice.id
|
||||||
|
..parentType = EntityType.invoice));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.products.forEach((product) {
|
||||||
|
product.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = product.id
|
||||||
|
..parentType = EntityType.product));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.projects.forEach((project) {
|
||||||
|
project.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = project.id
|
||||||
|
..parentType = EntityType.project));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.purchaseOrders.forEach((purchaseOrder) {
|
||||||
|
purchaseOrder.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = purchaseOrder.id
|
||||||
|
..parentType = EntityType.purchaseOrder));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.quotes.forEach((quote) {
|
||||||
|
quote.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = quote.id
|
||||||
|
..parentType = EntityType.quote));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.recurringExpenses.forEach((recurringExpense) {
|
||||||
|
recurringExpense.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = recurringExpense.id
|
||||||
|
..parentType = EntityType.recurringExpense));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.recurringInvoices.forEach((recurringInvoice) {
|
||||||
|
recurringInvoice.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = recurringInvoice.id
|
||||||
|
..parentType = EntityType.recurringInvoice));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.tasks.forEach((task) {
|
||||||
|
task.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = task.id
|
||||||
|
..parentType = EntityType.task));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
company.vendors.forEach((vendor) {
|
||||||
|
vendor.documents.forEach((document) {
|
||||||
|
documents.add(document.rebuild((b) => b
|
||||||
|
..parentId = vendor.id
|
||||||
|
..parentType = EntityType.vendor));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
final state = documentState.rebuild((b) => b
|
final state = documentState.rebuild((b) => b
|
||||||
..map.addAll(Map.fromIterable(
|
..map.addAll(Map.fromIterable(
|
||||||
documents,
|
documents,
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ Middleware<AppState> _saveDocument(RecurringExpenseRepository repository) {
|
||||||
expense.documents.forEach((document) {
|
expense.documents.forEach((document) {
|
||||||
documents.add(document.rebuild((b) => b
|
documents.add(document.rebuild((b) => b
|
||||||
..parentId = expense.id
|
..parentId = expense.id
|
||||||
..parentType = EntityType.expense));
|
..parentType = EntityType.recurringExpense));
|
||||||
});
|
});
|
||||||
store.dispatch(LoadDocumentsSuccess(documents));
|
store.dispatch(LoadDocumentsSuccess(documents));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,7 @@ Middleware<AppState> _saveDocument(RecurringInvoiceRepository repository) {
|
||||||
invoice.documents.forEach((document) {
|
invoice.documents.forEach((document) {
|
||||||
documents.add(document.rebuild((b) => b
|
documents.add(document.rebuild((b) => b
|
||||||
..parentId = invoice.id
|
..parentId = invoice.id
|
||||||
..parentType = EntityType.invoice));
|
..parentType = EntityType.recurringInvoice));
|
||||||
});
|
});
|
||||||
store.dispatch(LoadDocumentsSuccess(documents));
|
store.dispatch(LoadDocumentsSuccess(documents));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ Middleware<AppState> _saveDocument(SettingsRepository repository) {
|
||||||
company.documents.forEach((document) {
|
company.documents.forEach((document) {
|
||||||
documents.add(document.rebuild((b) => b
|
documents.add(document.rebuild((b) => b
|
||||||
..parentId = company.id
|
..parentId = company.id
|
||||||
..parentType = EntityType.document));
|
..parentType = EntityType.company));
|
||||||
});
|
});
|
||||||
store.dispatch(LoadDocumentsSuccess(documents));
|
store.dispatch(LoadDocumentsSuccess(documents));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
// Flutter imports:
|
// Flutter imports:
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/link_text.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
||||||
|
|
||||||
class DocumentPresenter extends EntityPresenter {
|
class DocumentPresenter extends EntityPresenter {
|
||||||
|
|
@ -10,6 +13,7 @@ class DocumentPresenter extends EntityPresenter {
|
||||||
return [
|
return [
|
||||||
DocumentFields.name,
|
DocumentFields.name,
|
||||||
DocumentFields.type,
|
DocumentFields.type,
|
||||||
|
DocumentFields.linkedTo,
|
||||||
DocumentFields.size,
|
DocumentFields.size,
|
||||||
DocumentFields.width,
|
DocumentFields.width,
|
||||||
DocumentFields.height,
|
DocumentFields.height,
|
||||||
|
|
@ -30,6 +34,8 @@ class DocumentPresenter extends EntityPresenter {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget getField({String field, BuildContext context}) {
|
Widget getField({String field, BuildContext context}) {
|
||||||
|
final store = StoreProvider.of<AppState>(context);
|
||||||
|
final state = store.state;
|
||||||
final document = entity as DocumentEntity;
|
final document = entity as DocumentEntity;
|
||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
|
|
@ -47,6 +53,12 @@ class DocumentPresenter extends EntityPresenter {
|
||||||
return Text(document.id);
|
return Text(document.id);
|
||||||
case DocumentFields.hash:
|
case DocumentFields.hash:
|
||||||
return Text(document.hash);
|
return Text(document.hash);
|
||||||
|
case DocumentFields.linkedTo:
|
||||||
|
final parentEntity =
|
||||||
|
state.getEntity(document.parentType, document.parentId);
|
||||||
|
print(
|
||||||
|
'## ${document.parentType} ${document.parentId} => $parentEntity');
|
||||||
|
return LinkTextRelatedEntity(entity: parentEntity, relation: document);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getField(field: field, context: context);
|
return super.getField(field: field, context: context);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
|
'linked_to': 'Linked To',
|
||||||
'file_saved_in_path': 'The file has been saved in :path',
|
'file_saved_in_path': 'The file has been saved in :path',
|
||||||
'unlinked_transactions': 'Successfully unlinked :count transactions',
|
'unlinked_transactions': 'Successfully unlinked :count transactions',
|
||||||
'unlinked_transaction': 'Successfully unlinked transaction',
|
'unlinked_transaction': 'Successfully unlinked transaction',
|
||||||
|
|
@ -108942,6 +108943,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
_localizedValues[localeCode]['file_saved_in_path'] ??
|
_localizedValues[localeCode]['file_saved_in_path'] ??
|
||||||
_localizedValues['en']['file_saved_in_path'];
|
_localizedValues['en']['file_saved_in_path'];
|
||||||
|
|
||||||
|
String get linkedTo =>
|
||||||
|
_localizedValues[localeCode]['linked_to'] ??
|
||||||
|
_localizedValues['en']['linked_to'];
|
||||||
|
|
||||||
|
|
||||||
// STARTER: lang field - do not remove comment
|
// STARTER: lang field - do not remove comment
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue