TF-1625 Get capability supported for Identity/set method
(cherry picked from commit 16a77edba891a628b728d05ddd3a61c9ba45b8dc)
This commit is contained in:
@@ -55,6 +55,7 @@ class IdentityCreatorController extends BaseController {
|
||||
final bccOfIdentity = Rxn<EmailAddress>();
|
||||
final actionType = IdentityActionType.create.obs;
|
||||
final isDefaultIdentity = RxBool(false);
|
||||
final isDefaultIdentitySupported = RxBool(false);
|
||||
|
||||
late RichTextController keyboardRichTextController;
|
||||
late RichTextWebController richTextWebController;
|
||||
@@ -120,6 +121,7 @@ class IdentityCreatorController extends BaseController {
|
||||
userProfile = arguments!.userProfile;
|
||||
identity = arguments!.identity;
|
||||
actionType.value = arguments!.actionType;
|
||||
_checkDefaultIdentityIsSupported();
|
||||
_setUpValueFromIdentity();
|
||||
_getAllIdentities();
|
||||
}
|
||||
@@ -147,6 +149,12 @@ class IdentityCreatorController extends BaseController {
|
||||
);
|
||||
}
|
||||
|
||||
void _checkDefaultIdentityIsSupported() {
|
||||
if (session != null && accountId != null) {
|
||||
isDefaultIdentitySupported.value = [CapabilityIdentifier.jamesSortOrder].isSupported(session!, accountId!);
|
||||
}
|
||||
}
|
||||
|
||||
void _setUpValueFromIdentity() {
|
||||
_nameIdentity = identity?.name ?? '';
|
||||
inputNameIdentityController?.text = identity?.name ?? '';
|
||||
@@ -160,21 +168,12 @@ class IdentityCreatorController extends BaseController {
|
||||
}
|
||||
|
||||
void _getAllIdentities() {
|
||||
log('IdentityCreatorController::_getAllIdentities() ');
|
||||
if (accountId != null) {
|
||||
try {
|
||||
requireCapability(session!, accountId!, [CapabilityIdentifier.jamesSortOrder]);
|
||||
consumeState(_getAllIdentitiesInteractor.execute(
|
||||
accountId!,
|
||||
properties: Properties({'email', 'sortOrder'})
|
||||
));
|
||||
} catch (e) {
|
||||
logError('IdentityCreatorController::_getAllIdentities(): exception: $e');
|
||||
consumeState(_getAllIdentitiesInteractor.execute(
|
||||
accountId!,
|
||||
properties: Properties({'email'})
|
||||
));
|
||||
}
|
||||
if (accountId != null && session != null) {
|
||||
final propertiesRequired = isDefaultIdentitySupported.isTrue
|
||||
? Properties({'email', 'sortOrder'})
|
||||
: Properties({'email'});
|
||||
|
||||
consumeState(_getAllIdentitiesInteractor.execute(session!, accountId!, properties: propertiesRequired));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +186,10 @@ class IdentityCreatorController extends BaseController {
|
||||
listEmailAddressOfReplyTo.add(noneEmailAddress);
|
||||
listEmailAddressOfReplyTo.addAll(listEmailAddressDefault);
|
||||
_setUpAllFieldEmailAddress();
|
||||
_setUpDefaultIdentity(success.identities);
|
||||
|
||||
if (isDefaultIdentitySupported.isTrue) {
|
||||
_setUpDefaultIdentity(success.identities);
|
||||
}
|
||||
} else {
|
||||
_setDefaultEmailAddressList();
|
||||
}
|
||||
@@ -319,9 +321,9 @@ class IdentityCreatorController extends BaseController {
|
||||
? {replyToOfIdentity.value!}
|
||||
: <EmailAddress>{};
|
||||
|
||||
final sortOrder = isDefaultIdentity.value
|
||||
? UnsignedInt(0)
|
||||
: UnsignedInt(100);
|
||||
final sortOrder = isDefaultIdentitySupported.isTrue
|
||||
? UnsignedInt(isDefaultIdentity.value ? 0 : 100)
|
||||
: null;
|
||||
|
||||
final newIdentity = Identity(
|
||||
name: _nameIdentity,
|
||||
|
||||
@@ -271,13 +271,20 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController> {
|
||||
child: _buildSignatureHtmlTemplate(context),
|
||||
),
|
||||
if (_responsiveUtils.isTablet(context) || _responsiveUtils.isMobile(context))...[
|
||||
Obx(() => Padding(
|
||||
padding: const EdgeInsets.only(top: 27),
|
||||
child: SetDefaultIdentityCheckboxBuilder(
|
||||
imagePaths: _imagePaths,
|
||||
isCheck: controller.isDefaultIdentity.value,
|
||||
onCheckboxChanged: controller.onCheckboxChanged),
|
||||
)),
|
||||
Obx(() {
|
||||
if (controller.isDefaultIdentitySupported.isTrue) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 27),
|
||||
child: SetDefaultIdentityCheckboxBuilder(
|
||||
imagePaths: _imagePaths,
|
||||
isCheck: controller.isDefaultIdentity.value,
|
||||
onCheckboxChanged: controller.onCheckboxChanged
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
const SizedBox(height: 24),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
@@ -467,10 +474,15 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController> {
|
||||
return Row(
|
||||
children: [
|
||||
Obx(() {
|
||||
return SetDefaultIdentityCheckboxBuilder(
|
||||
imagePaths: _imagePaths,
|
||||
isCheck: controller.isDefaultIdentity.value,
|
||||
onCheckboxChanged: controller.onCheckboxChanged);
|
||||
if (controller.isDefaultIdentitySupported.isTrue) {
|
||||
return SetDefaultIdentityCheckboxBuilder(
|
||||
imagePaths: _imagePaths,
|
||||
isCheck: controller.isDefaultIdentity.value,
|
||||
onCheckboxChanged: controller.onCheckboxChanged
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
|
||||
Reference in New Issue
Block a user