Schedule send
This commit is contained in:
parent
04b8a6401b
commit
94b70a2509
|
|
@ -3,9 +3,11 @@ import 'package:built_collection/built_collection.dart';
|
|||
import 'package:built_value/serializer.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
|
||||
import 'package:invoiceninja_flutter/main_app.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/utils/strings.dart';
|
||||
|
||||
part 'schedule_model.g.dart';
|
||||
|
|
@ -65,7 +67,6 @@ abstract class ScheduleEntity extends Object
|
|||
archivedAt: 0,
|
||||
frequencyId: kFrequencyMonthly,
|
||||
isPaused: false,
|
||||
name: '',
|
||||
nextRun: '',
|
||||
template: TEMPLATE_EMAIL_STATEMENT,
|
||||
parameters: ScheduleParameters(),
|
||||
|
|
@ -86,8 +87,6 @@ abstract class ScheduleEntity extends Object
|
|||
@memoized
|
||||
int get hashCode;
|
||||
|
||||
String get name;
|
||||
|
||||
@BuiltValueField(wireName: 'frequency_id')
|
||||
String get frequencyId;
|
||||
|
||||
|
|
@ -135,9 +134,6 @@ abstract class ScheduleEntity extends Object
|
|||
final scheduleB = sortAscending ? schedule : this;
|
||||
|
||||
switch (sortField) {
|
||||
case ScheduleFields.name:
|
||||
response = scheduleA.name.compareTo(scheduleB.name);
|
||||
break;
|
||||
case ScheduleFields.template:
|
||||
response = scheduleA.template.compareTo(scheduleB.template);
|
||||
break;
|
||||
|
|
@ -149,7 +145,7 @@ abstract class ScheduleEntity extends Object
|
|||
|
||||
if (response == 0) {
|
||||
// STARTER: sort default - do not remove comment
|
||||
return scheduleA.name.compareTo(scheduleB.name);
|
||||
return scheduleA.template.compareTo(scheduleB.template);
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
|
|
@ -159,7 +155,6 @@ abstract class ScheduleEntity extends Object
|
|||
bool matchesFilter(String filter) {
|
||||
return matchesStrings(
|
||||
haystacks: [
|
||||
name,
|
||||
template,
|
||||
],
|
||||
needle: filter,
|
||||
|
|
@ -177,7 +172,10 @@ abstract class ScheduleEntity extends Object
|
|||
}
|
||||
|
||||
@override
|
||||
String get listDisplayName => name;
|
||||
String get listDisplayName {
|
||||
final localization = AppLocalization.of(navigatorKey.currentContext);
|
||||
return localization.lookup(template);
|
||||
}
|
||||
|
||||
@override
|
||||
double get listDisplayAmount => null;
|
||||
|
|
|
|||
|
|
@ -121,8 +121,6 @@ class _$ScheduleEntitySerializer
|
|||
Iterable<Object> serialize(Serializers serializers, ScheduleEntity object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'name',
|
||||
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||
'frequency_id',
|
||||
serializers.serialize(object.frequencyId,
|
||||
specifiedType: const FullType(String)),
|
||||
|
|
@ -197,10 +195,6 @@ class _$ScheduleEntitySerializer
|
|||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
switch (key) {
|
||||
case 'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'frequency_id':
|
||||
result.frequencyId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
|
|
@ -553,8 +547,6 @@ class ScheduleItemResponseBuilder
|
|||
}
|
||||
|
||||
class _$ScheduleEntity extends ScheduleEntity {
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final String frequencyId;
|
||||
@override
|
||||
|
|
@ -588,8 +580,7 @@ class _$ScheduleEntity extends ScheduleEntity {
|
|||
(new ScheduleEntityBuilder()..update(updates))._build();
|
||||
|
||||
_$ScheduleEntity._(
|
||||
{this.name,
|
||||
this.frequencyId,
|
||||
{this.frequencyId,
|
||||
this.nextRun,
|
||||
this.template,
|
||||
this.isPaused,
|
||||
|
|
@ -604,7 +595,6 @@ class _$ScheduleEntity extends ScheduleEntity {
|
|||
this.assignedUserId,
|
||||
this.id})
|
||||
: super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(name, r'ScheduleEntity', 'name');
|
||||
BuiltValueNullFieldError.checkNotNull(
|
||||
frequencyId, r'ScheduleEntity', 'frequencyId');
|
||||
BuiltValueNullFieldError.checkNotNull(
|
||||
|
|
@ -638,7 +628,6 @@ class _$ScheduleEntity extends ScheduleEntity {
|
|||
bool operator ==(Object other) {
|
||||
if (identical(other, this)) return true;
|
||||
return other is ScheduleEntity &&
|
||||
name == other.name &&
|
||||
frequencyId == other.frequencyId &&
|
||||
nextRun == other.nextRun &&
|
||||
template == other.template &&
|
||||
|
|
@ -660,7 +649,6 @@ class _$ScheduleEntity extends ScheduleEntity {
|
|||
int get hashCode {
|
||||
if (__hashCode != null) return __hashCode;
|
||||
var _$hash = 0;
|
||||
_$hash = $jc(_$hash, name.hashCode);
|
||||
_$hash = $jc(_$hash, frequencyId.hashCode);
|
||||
_$hash = $jc(_$hash, nextRun.hashCode);
|
||||
_$hash = $jc(_$hash, template.hashCode);
|
||||
|
|
@ -682,7 +670,6 @@ class _$ScheduleEntity extends ScheduleEntity {
|
|||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper(r'ScheduleEntity')
|
||||
..add('name', name)
|
||||
..add('frequencyId', frequencyId)
|
||||
..add('nextRun', nextRun)
|
||||
..add('template', template)
|
||||
|
|
@ -705,10 +692,6 @@ class ScheduleEntityBuilder
|
|||
implements Builder<ScheduleEntity, ScheduleEntityBuilder> {
|
||||
_$ScheduleEntity _$v;
|
||||
|
||||
String _name;
|
||||
String get name => _$this._name;
|
||||
set name(String name) => _$this._name = name;
|
||||
|
||||
String _frequencyId;
|
||||
String get frequencyId => _$this._frequencyId;
|
||||
set frequencyId(String frequencyId) => _$this._frequencyId = frequencyId;
|
||||
|
|
@ -775,7 +758,6 @@ class ScheduleEntityBuilder
|
|||
ScheduleEntityBuilder get _$this {
|
||||
final $v = _$v;
|
||||
if ($v != null) {
|
||||
_name = $v.name;
|
||||
_frequencyId = $v.frequencyId;
|
||||
_nextRun = $v.nextRun;
|
||||
_template = $v.template;
|
||||
|
|
@ -814,8 +796,6 @@ class ScheduleEntityBuilder
|
|||
try {
|
||||
_$result = _$v ??
|
||||
new _$ScheduleEntity._(
|
||||
name: BuiltValueNullFieldError.checkNotNull(
|
||||
name, r'ScheduleEntity', 'name'),
|
||||
frequencyId: BuiltValueNullFieldError.checkNotNull(
|
||||
frequencyId, r'ScheduleEntity', 'frequencyId'),
|
||||
nextRun: BuiltValueNullFieldError.checkNotNull(
|
||||
|
|
@ -832,8 +812,8 @@ class ScheduleEntityBuilder
|
|||
createdAt, r'ScheduleEntity', 'createdAt'),
|
||||
updatedAt: BuiltValueNullFieldError.checkNotNull(
|
||||
updatedAt, r'ScheduleEntity', 'updatedAt'),
|
||||
archivedAt:
|
||||
BuiltValueNullFieldError.checkNotNull(archivedAt, r'ScheduleEntity', 'archivedAt'),
|
||||
archivedAt: BuiltValueNullFieldError.checkNotNull(
|
||||
archivedAt, r'ScheduleEntity', 'archivedAt'),
|
||||
isDeleted: isDeleted,
|
||||
createdUserId: createdUserId,
|
||||
assignedUserId: assignedUserId,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
|||
import 'package:invoiceninja_flutter/redux/project/project_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/recurring_invoice/recurring_invoice_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/schedule/schedule_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/subscription/subscription_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/task/task_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/task_status/task_status_actions.dart';
|
||||
|
|
@ -192,9 +193,12 @@ class EntityActionListTile extends StatelessWidget {
|
|||
case EntityType.transactionRule:
|
||||
handleTransactionRuleAction(mainContext, entities, action);
|
||||
break;
|
||||
case EntityType.schedule:
|
||||
handleScheduleAction(mainContext, entities, action);
|
||||
break;
|
||||
// TODO add to starter.sh
|
||||
default:
|
||||
throw 'Error: unhandled entity type ${first.entityType}';
|
||||
throw '## Error: unhandled entity action type ${first.entityType}';
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company/company_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
class ScheduleListItem extends StatelessWidget {
|
||||
const ScheduleListItem({
|
||||
|
|
@ -41,13 +43,35 @@ class ScheduleListItem extends StatelessWidget {
|
|||
|
||||
final filterMatch = filter != null && filter.isNotEmpty
|
||||
? schedule.matchesFilterValue(filter)
|
||||
: localization.lookup(schedule.template) +
|
||||
(schedule.frequencyId.isEmpty
|
||||
: formatDate(schedule.nextRun, context) +
|
||||
(schedule.template == ScheduleEntity.TEMPLATE_EMAIL_RECORD
|
||||
? ''
|
||||
: ' • ' +
|
||||
localization.lookup(kFrequencies[schedule.frequencyId]));
|
||||
final subtitle = filterMatch;
|
||||
|
||||
String title = localization.lookup(schedule.template);
|
||||
if (schedule.template == ScheduleEntity.TEMPLATE_EMAIL_RECORD) {
|
||||
final entityType = EntityType.valueOf(schedule.parameters.entityType);
|
||||
final entity =
|
||||
state.getEntityMap(entityType)[schedule.parameters.entityId];
|
||||
|
||||
title += ': ' +
|
||||
localization.lookup(schedule.parameters.entityType) +
|
||||
' ' +
|
||||
(entity?.listDisplayName ?? '');
|
||||
} else if (schedule.template == ScheduleEntity.TEMPLATE_EMAIL_STATEMENT) {
|
||||
if (schedule.parameters.clients.isEmpty) {
|
||||
title += ': ' + localization.allClients;
|
||||
} else if (schedule.parameters.clients.length == 1) {
|
||||
final clientId = schedule.parameters.clients.first;
|
||||
title += ': ' + state.clientState.get(clientId).displayName;
|
||||
} else {
|
||||
title +=
|
||||
': ${schedule.parameters.clients.length} ${localization.clients}';
|
||||
}
|
||||
}
|
||||
|
||||
return DismissibleEntity(
|
||||
userCompany: state.userCompany,
|
||||
entity: schedule,
|
||||
|
|
@ -55,6 +79,8 @@ class ScheduleListItem extends StatelessWidget {
|
|||
(uiState.isEditing
|
||||
? scheduleUIState.editing.id
|
||||
: scheduleUIState.selectedId),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: ListTile(
|
||||
onTap: () => onTap != null ? onTap() : selectEntity(entity: schedule),
|
||||
onLongPress: () => onLongPress != null
|
||||
|
|
@ -71,21 +97,12 @@ class ScheduleListItem extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
: null,
|
||||
title: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
schedule.name,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
),
|
||||
Text(formatNumber(schedule.listDisplayAmount, context),
|
||||
style: Theme.of(context).textTheme.subtitle1),
|
||||
],
|
||||
),
|
||||
),
|
||||
title: Text(title),
|
||||
trailing: Text(timeago.format(
|
||||
convertSqlDateToDateTime(schedule.nextRun),
|
||||
locale: localeSelector(state, twoLetter: true),
|
||||
allowFromNow: true,
|
||||
)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
|
|
@ -100,6 +117,7 @@ class ScheduleListItem extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue