TF-3051 Fix should not allow create rule with no actions
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/rule_filter_action_arguments.dart';
|
||||||
|
|
||||||
|
extension ListRuleFilterActionArgumentExtension on List<RuleFilterActionArguments> {
|
||||||
|
|
||||||
|
bool isEmptySelectedRuleAction() => every((argument) => argument is EmptyRuleFilterActionArguments);
|
||||||
|
}
|
||||||
+66
-51
@@ -32,6 +32,7 @@ import 'package:tmail_ui_user/features/manage_account/domain/model/create_new_em
|
|||||||
import 'package:tmail_ui_user/features/manage_account/domain/model/edit_email_rule_filter_request.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/model/edit_email_rule_filter_request.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_rules_state.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_rules_state.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_rules_interactor.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_rules_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/extensions/list_rule_filter_action_argument_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/creator_action_type.dart';
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/creator_action_type.dart';
|
||||||
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/email_rule_filter_action.dart';
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/email_rule_filter_action.dart';
|
||||||
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/rule_filter_action_arguments.dart';
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/rule_filter_action_arguments.dart';
|
||||||
@@ -442,66 +443,80 @@ class RulesFilterCreatorController extends BaseMailboxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listRuleCondition.isNotEmpty) {
|
if (listRuleCondition.isEmpty
|
||||||
String? errorConditionString;
|
&& currentOverlayContext != null
|
||||||
for (var ruleCondition in listRuleCondition) {
|
&& currentContext != null
|
||||||
errorConditionString = _getErrorStringByInputValue(context, ruleCondition.value);
|
) {
|
||||||
log('RulesFilterCreatorController::createNewRuleFilter:errorConditionString: $errorConditionString');
|
appToast.showToastErrorMessage(
|
||||||
if (errorConditionString != null) {
|
currentOverlayContext!,
|
||||||
int ruleConditionIndex = listRuleCondition.indexOf(ruleCondition);
|
AppLocalizations.of(currentContext!).youHaveNotAddedConditionToRule);
|
||||||
RulesFilterInputFieldArguments newRuleConditionValueArguments = RulesFilterInputFieldArguments(
|
return;
|
||||||
focusNode: listRuleConditionValueArguments[ruleConditionIndex].focusNode,
|
}
|
||||||
errorText: errorConditionString,
|
|
||||||
controller: listRuleConditionValueArguments[ruleConditionIndex].controller,
|
for (var ruleCondition in listRuleCondition) {
|
||||||
);
|
final errorConditionString = _getErrorStringByInputValue(context, ruleCondition.value);
|
||||||
listRuleConditionValueArguments[ruleConditionIndex] = newRuleConditionValueArguments;
|
log('RulesFilterCreatorController::createNewRuleFilter:errorConditionString: $errorConditionString');
|
||||||
listRuleConditionValueArguments[listRuleCondition.indexOf(ruleCondition)].focusNode.requestFocus();
|
if (errorConditionString != null) {
|
||||||
}
|
int ruleConditionIndex = listRuleCondition.indexOf(ruleCondition);
|
||||||
}
|
RulesFilterInputFieldArguments newRuleConditionValueArguments = RulesFilterInputFieldArguments(
|
||||||
if (errorConditionString?.isNotEmpty == true) {
|
focusNode: listRuleConditionValueArguments[ruleConditionIndex].focusNode,
|
||||||
|
errorText: errorConditionString,
|
||||||
|
controller: listRuleConditionValueArguments[ruleConditionIndex].controller,
|
||||||
|
);
|
||||||
|
listRuleConditionValueArguments[ruleConditionIndex] = newRuleConditionValueArguments;
|
||||||
|
listRuleConditionValueArguments[listRuleCondition.indexOf(ruleCondition)].focusNode.requestFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listRuleCondition.isEmpty == true || listEmailRuleFilterActionSelected.isEmpty == true) {
|
if (listEmailRuleFilterActionSelected.isEmpty
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
&& currentOverlayContext != null
|
||||||
appToast.showToastErrorMessage(
|
&& currentContext != null
|
||||||
currentOverlayContext!,
|
) {
|
||||||
AppLocalizations.of(currentContext!).toastErrorMessageWhenCreateNewRule);
|
appToast.showToastErrorMessage(
|
||||||
}
|
currentOverlayContext!,
|
||||||
|
AppLocalizations.of(currentContext!).youHaveNotAddedActionToRule);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listEmailRuleFilterActionSelected.isNotEmpty == true) {
|
if (listEmailRuleFilterActionSelected.isEmptySelectedRuleAction()
|
||||||
for (var ruleFilterAction in listEmailRuleFilterActionSelected) {
|
&& currentOverlayContext != null
|
||||||
if (ruleFilterAction is MoveMessageActionArguments) {
|
&& currentContext != null
|
||||||
final errorAction = _getErrorStringByInputValue(context, mailboxSelected.value?.getDisplayName(context));
|
) {
|
||||||
log('RulesFilterCreatorController::createNewRuleFilter:errorAction: $errorAction');
|
appToast.showToastErrorMessage(
|
||||||
if (errorAction?.isNotEmpty == true) {
|
currentOverlayContext!,
|
||||||
appToast.showToastErrorMessage(
|
AppLocalizations.of(currentContext!).youHaveNotSelectedAnyActionForRule);
|
||||||
context,
|
return;
|
||||||
AppLocalizations.of(context).notSelectedMailboxToMoveMessage);
|
}
|
||||||
return;
|
|
||||||
}
|
for (var ruleFilterAction in listEmailRuleFilterActionSelected) {
|
||||||
|
if (ruleFilterAction is MoveMessageActionArguments) {
|
||||||
|
final errorAction = _getErrorStringByInputValue(context, mailboxSelected.value?.getDisplayName(context));
|
||||||
|
log('RulesFilterCreatorController::createNewRuleFilter:errorAction: $errorAction');
|
||||||
|
if (errorAction?.isNotEmpty == true) {
|
||||||
|
appToast.showToastErrorMessage(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context).notSelectedMailboxToMoveMessage);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (ruleFilterAction is MarkAsSpamActionArguments) {
|
}
|
||||||
final spamMailboxId = getSpamMailboxId();
|
if (ruleFilterAction is MarkAsSpamActionArguments) {
|
||||||
log('RulesFilterCreatorController::createNewRuleFilter:spamMailboxId: ${spamMailboxId?.asString}');
|
final spamMailboxId = getSpamMailboxId();
|
||||||
if (spamMailboxId == null) {
|
log('RulesFilterCreatorController::createNewRuleFilter:spamMailboxId: ${spamMailboxId?.asString}');
|
||||||
appToast.showToastErrorMessage(
|
if (spamMailboxId == null) {
|
||||||
context,
|
appToast.showToastErrorMessage(
|
||||||
AppLocalizations.of(context).spamFolderNotFound);
|
context,
|
||||||
return;
|
AppLocalizations.of(context).spamFolderNotFound);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
if (ruleFilterAction is ForwardActionArguments) {
|
}
|
||||||
final errorAction = _getErrorStringByInputValue(context, ruleFilterAction.forwardEmail);
|
if (ruleFilterAction is ForwardActionArguments) {
|
||||||
log('RulesFilterCreatorController::createNewRuleFilter:errorAction: $errorAction');
|
final errorAction = _getErrorStringByInputValue(context, ruleFilterAction.forwardEmail);
|
||||||
if (errorAction?.isNotEmpty == true) {
|
log('RulesFilterCreatorController::createNewRuleFilter:errorAction: $errorAction');
|
||||||
errorForwardEmailValue.value = errorAction;
|
if (errorAction?.isNotEmpty == true) {
|
||||||
forwardEmailFocusNode.requestFocus();
|
errorForwardEmailValue.value = errorAction;
|
||||||
return;
|
forwardEmailFocusNode.requestFocus();
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2024-08-23T16:45:33.629548",
|
"@@last_modified": "2024-09-10T15:59:25.469570",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2134,12 +2134,6 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
"toastErrorMessageWhenCreateNewRule": "You have not filled in the information completely.",
|
|
||||||
"@toastErrorMessageWhenCreateNewRule": {
|
|
||||||
"type": "text",
|
|
||||||
"placeholders_order": [],
|
|
||||||
"placeholders": {}
|
|
||||||
},
|
|
||||||
"vacationSettingExplanation": "Sends an automated reply to incoming messages.",
|
"vacationSettingExplanation": "Sends an automated reply to incoming messages.",
|
||||||
"@vacationSettingExplanation": {
|
"@vacationSettingExplanation": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -3993,5 +3987,23 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"youHaveNotAddedConditionToRule": "You have not added a condition to the rule.",
|
||||||
|
"@youHaveNotAddedConditionToRule": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"youHaveNotAddedActionToRule": "You have not added a action to the rule.",
|
||||||
|
"@youHaveNotAddedActionToRule": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"youHaveNotSelectedAnyActionForRule": "You have not selected any action for the rule.",
|
||||||
|
"@youHaveNotSelectedAnyActionForRule": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2192,12 +2192,6 @@ class AppLocalizations {
|
|||||||
name: 'toastMessageDeleteEmailRuleSuccessfully');
|
name: 'toastMessageDeleteEmailRuleSuccessfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
String get toastErrorMessageWhenCreateNewRule {
|
|
||||||
return Intl.message(
|
|
||||||
'You have not filled in the information completely.',
|
|
||||||
name: 'toastErrorMessageWhenCreateNewRule');
|
|
||||||
}
|
|
||||||
|
|
||||||
String get vacationSettingExplanation {
|
String get vacationSettingExplanation {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'Sends an automated reply to incoming messages.',
|
'Sends an automated reply to incoming messages.',
|
||||||
@@ -4187,4 +4181,22 @@ class AppLocalizations {
|
|||||||
name: 'spamFolderNotFound',
|
name: 'spamFolderNotFound',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get youHaveNotAddedConditionToRule {
|
||||||
|
return Intl.message(
|
||||||
|
'You have not added a condition to the rule.',
|
||||||
|
name: 'youHaveNotAddedConditionToRule');
|
||||||
|
}
|
||||||
|
|
||||||
|
String get youHaveNotAddedActionToRule {
|
||||||
|
return Intl.message(
|
||||||
|
'You have not added a action to the rule.',
|
||||||
|
name: 'youHaveNotAddedActionToRule');
|
||||||
|
}
|
||||||
|
|
||||||
|
String get youHaveNotSelectedAnyActionForRule {
|
||||||
|
return Intl.message(
|
||||||
|
'You have not selected any action for the rule.',
|
||||||
|
name: 'youHaveNotSelectedAnyActionForRule');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user