Schedule send

This commit is contained in:
Hillel Coren 2023-03-22 13:58:46 +02:00
parent 94b70a2509
commit cdd81fe56d
4 changed files with 7 additions and 4 deletions

View File

@ -47,8 +47,8 @@ abstract class ScheduleItemResponse
} }
class ScheduleFields { class ScheduleFields {
static const String name = 'name';
static const String template = 'template'; static const String template = 'template';
static const String nextRun = 'next_run';
} }
abstract class ScheduleEntity extends Object abstract class ScheduleEntity extends Object
@ -137,6 +137,9 @@ abstract class ScheduleEntity extends Object
case ScheduleFields.template: case ScheduleFields.template:
response = scheduleA.template.compareTo(scheduleB.template); response = scheduleA.template.compareTo(scheduleB.template);
break; break;
case ScheduleFields.nextRun:
response = scheduleA.nextRun.compareTo(scheduleB.nextRun);
break;
default: default:
print('## ERROR: sort by schedule.$sortField is not implemented'); print('## ERROR: sort by schedule.$sortField is not implemented');

View File

@ -33,7 +33,7 @@ List<String> dropdownSchedulesSelector(
list.sort((scheduleAId, scheduleBId) { list.sort((scheduleAId, scheduleBId) {
final scheduleA = scheduleMap[scheduleAId]; final scheduleA = scheduleMap[scheduleAId];
final scheduleB = scheduleMap[scheduleBId]; final scheduleB = scheduleMap[scheduleBId];
return scheduleA.compareTo(scheduleB, ScheduleFields.name, true); return scheduleA.compareTo(scheduleB, ScheduleFields.template, true);
}); });
return list; return list;

View File

@ -54,7 +54,7 @@ abstract class ScheduleUIState extends Object
implements Built<ScheduleUIState, ScheduleUIStateBuilder> { implements Built<ScheduleUIState, ScheduleUIStateBuilder> {
factory ScheduleUIState(PrefStateSortField sortField) { factory ScheduleUIState(PrefStateSortField sortField) {
return _$ScheduleUIState._( return _$ScheduleUIState._(
listUIState: ListUIState(sortField?.field ?? ScheduleFields.name, listUIState: ListUIState(sortField?.field ?? ScheduleFields.template,
sortAscending: sortField?.ascending), sortAscending: sortField?.ascending),
editing: ScheduleEntity(), editing: ScheduleEntity(),
selectedId: '', selectedId: '',

View File

@ -63,8 +63,8 @@ class ScheduleScreen extends StatelessWidget {
store.dispatch(SortSchedules(value)); store.dispatch(SortSchedules(value));
}, },
sortFields: [ sortFields: [
ScheduleFields.name,
ScheduleFields.template, ScheduleFields.template,
ScheduleFields.nextRun,
], ],
onSelectedState: (EntityState state, value) { onSelectedState: (EntityState state, value) {
store.dispatch(FilterSchedulesByState(state)); store.dispatch(FilterSchedulesByState(state));