Skip to content

Content management UI enhancement #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0ad8093
refactor(content_management): remove unused country search changed event
fulleni Aug 1, 2025
0004980
refactor(content_management): remove country search functionality
fulleni Aug 1, 2025
2598648
refactor(create_headline): remove unused country search term
fulleni Aug 1, 2025
5b3b67c
refactor(content_management): replace SearchableDropdownFormField wit…
fulleni Aug 1, 2025
5628a41
refactor(content_management): remove unused country search event
fulleni Aug 1, 2025
9474d04
fix(content_management): replace localization with static text for co…
fulleni Aug 1, 2025
5fdc6ec
refactor(content_management): remove unused country search term from …
fulleni Aug 1, 2025
f7ff2b7
refactor(content_management): remove country search functionality
fulleni Aug 1, 2025
2828084
refactor(content_management): replace SearchableDropdownFormField wit…
fulleni Aug 1, 2025
720d239
refactor(content_management): remove unused search change events
fulleni Aug 1, 2025
0e0cb37
refactor(content_management): remove country and language search terms
fulleni Aug 1, 2025
beec0e6
refactor(content_management): remove unused search event handlers
fulleni Aug 1, 2025
b0b3e59
refactor(content_management): replace SearchableDropdownFormField wit…
fulleni Aug 1, 2025
99d68fa
refactor(content_management): remove unused search change events
fulleni Aug 1, 2025
8f4e72a
refactor(content_management): remove country and language search terms
fulleni Aug 1, 2025
a743aec
refactor(content_management): remove unused search event handlers
fulleni Aug 1, 2025
d34651f
refactor(content_management): replace SearchableDropdownFormField wit…
fulleni Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class CreateHeadlineBloc
on<CreateHeadlineCountryChanged>(_onCountryChanged);
on<CreateHeadlineStatusChanged>(_onStatusChanged);
on<CreateHeadlineSubmitted>(_onSubmitted);
on<CreateHeadlineCountrySearchChanged>(
_onCountrySearchChanged,
transformer: droppable(),
);
on<CreateHeadlineLoadMoreCountriesRequested>(_onLoadMoreCountriesRequested);
}

Expand Down Expand Up @@ -195,37 +191,6 @@ class CreateHeadlineBloc
}
}

Future<void> _onCountrySearchChanged(
CreateHeadlineCountrySearchChanged event,
Emitter<CreateHeadlineState> emit,
) async {
await Future<void>.delayed(_searchDebounceDuration);
emit(state.copyWith(countrySearchTerm: event.searchTerm));
try {
final countriesResponse = await _countriesRepository.readAll(
filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null,
sort: [const SortOption('name', SortOrder.asc)],
);

emit(
state.copyWith(
countries: countriesResponse.items,
countriesCursor: countriesResponse.cursor,
countriesHasMore: countriesResponse.hasMore,
),
);
} on HttpException catch (e) {
emit(state.copyWith(status: CreateHeadlineStatus.failure, exception: e));
} catch (e) {
emit(
state.copyWith(
status: CreateHeadlineStatus.failure,
exception: UnknownException('An unexpected error occurred: $e'),
),
);
}
}

Future<void> _onLoadMoreCountriesRequested(
CreateHeadlineLoadMoreCountriesRequested event,
Emitter<CreateHeadlineState> emit,
Expand All @@ -239,9 +204,6 @@ class CreateHeadlineBloc
pagination: state.countriesCursor != null
? PaginationOptions(cursor: state.countriesCursor)
: null,
filter: state.countrySearchTerm.isNotEmpty
? {'name': state.countrySearchTerm}
: null,
sort: [const SortOption('name', SortOrder.asc)],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ final class CreateHeadlineSubmitted extends CreateHeadlineEvent {
const CreateHeadlineSubmitted();
}

/// Event for when the country search term is changed.
final class CreateHeadlineCountrySearchChanged extends CreateHeadlineEvent {
const CreateHeadlineCountrySearchChanged(this.searchTerm);
final String searchTerm;
@override
List<Object?> get props => [searchTerm];
}

/// Event to request loading more countries.
final class CreateHeadlineLoadMoreCountriesRequested
extends CreateHeadlineEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ final class CreateHeadlineState extends Equatable {
this.countriesHasMore = true,
this.countriesIsLoadingMore = false,
this.countriesCursor,
this.countrySearchTerm = '',
this.contentStatus = ContentStatus.active,
this.exception,
this.createdHeadline,
Expand All @@ -55,7 +54,6 @@ final class CreateHeadlineState extends Equatable {
final bool countriesHasMore;
final bool countriesIsLoadingMore;
final String? countriesCursor;
final String countrySearchTerm;
final ContentStatus contentStatus;
final HttpException? exception;
final Headline? createdHeadline;
Expand Down Expand Up @@ -85,7 +83,6 @@ final class CreateHeadlineState extends Equatable {
bool? countriesHasMore,
bool? countriesIsLoadingMore,
String? countriesCursor,
String? countrySearchTerm,
ContentStatus? contentStatus,
HttpException? exception,
Headline? createdHeadline,
Expand All @@ -106,7 +103,6 @@ final class CreateHeadlineState extends Equatable {
countriesIsLoadingMore:
countriesIsLoadingMore ?? this.countriesIsLoadingMore,
countriesCursor: countriesCursor ?? this.countriesCursor,
countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm,
contentStatus: contentStatus ?? this.contentStatus,
exception: exception,
createdHeadline: createdHeadline ?? this.createdHeadline,
Expand All @@ -129,7 +125,6 @@ final class CreateHeadlineState extends Equatable {
countriesHasMore,
countriesIsLoadingMore,
countriesCursor,
countrySearchTerm,
contentStatus,
exception,
createdHeadline,
Expand Down
76 changes: 0 additions & 76 deletions lib/content_management/bloc/create_source/create_source_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
on<CreateSourceHeadquartersChanged>(_onHeadquartersChanged);
on<CreateSourceStatusChanged>(_onStatusChanged);
on<CreateSourceSubmitted>(_onSubmitted);
on<CreateSourceCountrySearchChanged>(
_onCountrySearchChanged,
transformer: droppable(),
);
on<CreateSourceLoadMoreCountriesRequested>(
_onLoadMoreCountriesRequested,
);
on<CreateSourceLanguageSearchChanged>(
_onLanguageSearchChanged,
transformer: droppable(),
);
on<CreateSourceLoadMoreLanguagesRequested>(
_onLoadMoreLanguagesRequested,
);
Expand Down Expand Up @@ -186,37 +178,6 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
}
}

Future<void> _onCountrySearchChanged(
CreateSourceCountrySearchChanged event,
Emitter<CreateSourceState> emit,
) async {
await Future<void>.delayed(_searchDebounceDuration);
emit(state.copyWith(countrySearchTerm: event.searchTerm));
try {
final countriesResponse = await _countriesRepository.readAll(
filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null,
sort: [const SortOption('name', SortOrder.asc)],
);

emit(
state.copyWith(
countries: countriesResponse.items,
countriesCursor: countriesResponse.cursor,
countriesHasMore: countriesResponse.hasMore,
),
);
} on HttpException catch (e) {
emit(state.copyWith(status: CreateSourceStatus.failure, exception: e));
} catch (e) {
emit(
state.copyWith(
status: CreateSourceStatus.failure,
exception: UnknownException('An unexpected error occurred: $e'),
),
);
}
}

Future<void> _onLoadMoreCountriesRequested(
CreateSourceLoadMoreCountriesRequested event,
Emitter<CreateSourceState> emit,
Expand All @@ -230,9 +191,6 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
pagination: state.countriesCursor != null
? PaginationOptions(cursor: state.countriesCursor)
: null,
filter: state.countrySearchTerm.isNotEmpty
? {'name': state.countrySearchTerm}
: null,
sort: [const SortOption('name', SortOrder.asc)],
);

Expand Down Expand Up @@ -263,37 +221,6 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
}
}

Future<void> _onLanguageSearchChanged(
CreateSourceLanguageSearchChanged event,
Emitter<CreateSourceState> emit,
) async {
await Future<void>.delayed(_searchDebounceDuration);
emit(state.copyWith(languageSearchTerm: event.searchTerm));
try {
final languagesResponse = await _languagesRepository.readAll(
filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null,
sort: [const SortOption('name', SortOrder.asc)],
);

emit(
state.copyWith(
languages: languagesResponse.items,
languagesCursor: languagesResponse.cursor,
languagesHasMore: languagesResponse.hasMore,
),
);
} on HttpException catch (e) {
emit(state.copyWith(status: CreateSourceStatus.failure, exception: e));
} catch (e) {
emit(
state.copyWith(
status: CreateSourceStatus.failure,
exception: UnknownException('An unexpected error occurred: $e'),
),
);
}
}

Future<void> _onLoadMoreLanguagesRequested(
CreateSourceLoadMoreLanguagesRequested event,
Emitter<CreateSourceState> emit,
Expand All @@ -307,9 +234,6 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
pagination: state.languagesCursor != null
? PaginationOptions(cursor: state.languagesCursor)
: null,
filter: state.languageSearchTerm.isNotEmpty
? {'name': state.languageSearchTerm}
: null,
sort: [const SortOption('name', SortOrder.asc)],
);

Expand Down
16 changes: 0 additions & 16 deletions lib/content_management/bloc/create_source/create_source_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,11 @@ final class CreateSourceSubmitted extends CreateSourceEvent {
const CreateSourceSubmitted();
}

/// Event for when the country search term is changed.
final class CreateSourceCountrySearchChanged extends CreateSourceEvent {
const CreateSourceCountrySearchChanged(this.searchTerm);
final String searchTerm;
@override
List<Object?> get props => [searchTerm];
}

/// Event to request loading more countries.
final class CreateSourceLoadMoreCountriesRequested extends CreateSourceEvent {
const CreateSourceLoadMoreCountriesRequested();
}

/// Event for when the language search term is changed.
final class CreateSourceLanguageSearchChanged extends CreateSourceEvent {
const CreateSourceLanguageSearchChanged(this.searchTerm);
final String searchTerm;
@override
List<Object?> get props => [searchTerm];
}

/// Event to request loading more languages.
final class CreateSourceLoadMoreLanguagesRequested extends CreateSourceEvent {
const CreateSourceLoadMoreLanguagesRequested();
Expand Down
26 changes: 8 additions & 18 deletions lib/content_management/bloc/create_source/create_source_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ final class CreateSourceState extends Equatable {
this.countriesHasMore = true,
this.countriesIsLoadingMore = false,
this.countriesCursor,
this.countrySearchTerm = '',
this.languages = const [],
this.languagesHasMore = true,
this.languagesIsLoadingMore = false,
this.languagesCursor,
this.languageSearchTerm = '',
this.contentStatus = ContentStatus.active,
this.exception,
this.createdSource,
Expand All @@ -55,12 +53,10 @@ final class CreateSourceState extends Equatable {
final bool countriesHasMore;
final bool countriesIsLoadingMore;
final String? countriesCursor;
final String countrySearchTerm;
final List<Language> languages;
final bool languagesHasMore;
final bool languagesIsLoadingMore;
final String? languagesCursor;
final String languageSearchTerm;
final ContentStatus contentStatus;
final HttpException? exception;
final Source? createdSource;
Expand All @@ -86,12 +82,10 @@ final class CreateSourceState extends Equatable {
bool? countriesHasMore,
bool? countriesIsLoadingMore,
String? countriesCursor,
String? countrySearchTerm,
List<Language>? languages,
bool? languagesHasMore,
bool? languagesIsLoadingMore,
String? languagesCursor,
String? languageSearchTerm,
ContentStatus? contentStatus,
HttpException? exception,
Source? createdSource,
Expand All @@ -109,13 +103,11 @@ final class CreateSourceState extends Equatable {
countriesIsLoadingMore:
countriesIsLoadingMore ?? this.countriesIsLoadingMore,
countriesCursor: countriesCursor ?? this.countriesCursor,
countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm,
languages: languages ?? this.languages,
languagesHasMore: languagesHasMore ?? this.languagesHasMore,
languagesIsLoadingMore:
languagesIsLoadingMore ?? this.languagesIsLoadingMore,
languagesCursor: languagesCursor ?? this.languagesCursor,
languageSearchTerm: languageSearchTerm ?? this.languageSearchTerm,
contentStatus: contentStatus ?? this.contentStatus,
exception: exception,
createdSource: createdSource ?? this.createdSource,
Expand All @@ -133,16 +125,14 @@ final class CreateSourceState extends Equatable {
headquarters,
countries,
countriesHasMore,
countriesIsLoadingMore,
countriesCursor,
countrySearchTerm,
languages,
languagesHasMore,
languagesIsLoadingMore,
languagesCursor,
languageSearchTerm,
contentStatus,
exception,
countriesIsLoadingMore,
countriesCursor,
languages,
languagesHasMore,
languagesIsLoadingMore,
languagesCursor,
contentStatus,
exception,
createdSource,
];
}
38 changes: 0 additions & 38 deletions lib/content_management/bloc/edit_headline/edit_headline_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class EditHeadlineBloc extends Bloc<EditHeadlineEvent, EditHeadlineState> {
on<EditHeadlineCountryChanged>(_onCountryChanged);
on<EditHeadlineStatusChanged>(_onStatusChanged);
on<EditHeadlineSubmitted>(_onSubmitted);
on<EditHeadlineCountrySearchChanged>(
_onCountrySearchChanged,
transformer: droppable(),
);
on<EditHeadlineLoadMoreCountriesRequested>(
_onLoadMoreCountriesRequested,
);
Expand Down Expand Up @@ -245,37 +241,6 @@ class EditHeadlineBloc extends Bloc<EditHeadlineEvent, EditHeadlineState> {
}
}

Future<void> _onCountrySearchChanged(
EditHeadlineCountrySearchChanged event,
Emitter<EditHeadlineState> emit,
) async {
await Future<void>.delayed(_searchDebounceDuration);
emit(state.copyWith(countrySearchTerm: event.searchTerm));
try {
final countriesResponse = await _countriesRepository.readAll(
filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null,
sort: [const SortOption('name', SortOrder.asc)],
);

emit(
state.copyWith(
countries: countriesResponse.items,
countriesCursor: countriesResponse.cursor,
countriesHasMore: countriesResponse.hasMore,
),
);
} on HttpException catch (e) {
emit(state.copyWith(status: EditHeadlineStatus.failure, exception: e));
} catch (e) {
emit(
state.copyWith(
status: EditHeadlineStatus.failure,
exception: UnknownException('An unexpected error occurred: $e'),
),
);
}
}

Future<void> _onLoadMoreCountriesRequested(
EditHeadlineLoadMoreCountriesRequested event,
Emitter<EditHeadlineState> emit,
Expand All @@ -289,9 +254,6 @@ class EditHeadlineBloc extends Bloc<EditHeadlineEvent, EditHeadlineState> {
pagination: state.countriesCursor != null
? PaginationOptions(cursor: state.countriesCursor)
: null,
filter: state.countrySearchTerm.isNotEmpty
? {'name': state.countrySearchTerm}
: null,
sort: [const SortOption('name', SortOrder.asc)],
);

Expand Down
Loading
Loading