From 2e5a016c460d525a1e391ba8c25487f974e024a4 Mon Sep 17 00:00:00 2001 From: EGOR-IND <56648862+EGOR-IND@users.noreply.github.com> Date: Wed, 21 Apr 2021 23:57:34 +0530 Subject: [PATCH] Add edit check to the edit activities --- .../customeractivity/CreateCustomerActivity.java | 12 +++++++++++- .../editcustomerpayroll/EditPayrollActivity.kt | 10 +++++++++- .../groups/creategroup/CreateGroupActivity.kt | 16 ++++++++++++++-- .../CreateIdentificationActivity.java | 16 ++++++++++++++-- .../org/apache/fineract/utils/ConstantKeys.java | 2 ++ app/src/main/res/values-ml-rIN/strings.xml | 6 ++++++ app/src/main/res/values/strings.xml | 6 ++++++ 7 files changed, 62 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/customeractivity/CreateCustomerActivity.java b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/customeractivity/CreateCustomerActivity.java index 27210085..c46ccd6c 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/customeractivity/CreateCustomerActivity.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/customeractivity/CreateCustomerActivity.java @@ -51,6 +51,7 @@ public class CreateCustomerActivity extends FineractBaseActivity private Customer customer; private CustomerAction customerAction; private String customerIdentifier; + private String initCustomerStr; @Override protected void onCreate(Bundle savedInstanceState) { @@ -82,6 +83,8 @@ protected void onCreate(Bundle savedInstanceState) { break; case EDIT: setToolbarTitle(getString(R.string.edit_customer)); + initCustomerStr = customer.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0]; break; } @@ -110,7 +113,14 @@ public void onCompleted(View completeButton) { createCustomerPresenter.createCustomer(customer); break; case EDIT: - createCustomerPresenter.updateCustomer(customerIdentifier, customer); + if (customer.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0] + .equals(initCustomerStr)) { + createCustomerPresenter.updateCustomer(customerIdentifier, customer); + } else { + Toaster.show(findViewById(android.R.id.content), + getString(R.string.customer_edit_check_msg, customer.getGivenName())); + } break; } } diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/EditPayrollActivity.kt b/app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/EditPayrollActivity.kt index e377a602..aa3928d6 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/EditPayrollActivity.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/EditPayrollActivity.kt @@ -20,6 +20,7 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene lateinit var payrollConfig: PayrollConfiguration lateinit var customerIdentifier: String + private lateinit var initPayrollStr: String @Inject lateinit var editPayrollPresenter: EditPayrollPresenter @@ -35,7 +36,12 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene } override fun onCompleted(completeButton: View?) { - editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig) + if (payrollConfig.toString().split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] != initPayrollStr) { + editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig) + } else { + Toaster.show(findViewById(android.R.id.content), + getString(R.string.payroll_edit_check_msg, customerIdentifier)) + } } override fun onCreate(savedInstanceState: Bundle?) { @@ -47,6 +53,8 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene editPayrollPresenter.attachView(this) val payrollConfig = intent.getParcelableExtra(ConstantKeys .PAYROLL_CONFIG) + initPayrollStr = payrollConfig.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] customerIdentifier = intent.getStringExtra(ConstantKeys.CUSTOMER_IDENTIFIER) diff --git a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivity.kt b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivity.kt index 00e5a8a7..7eef2730 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivity.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivity.kt @@ -17,6 +17,7 @@ import org.apache.fineract.ui.base.Toaster import org.apache.fineract.ui.online.groups.GroupAction import org.apache.fineract.ui.online.groups.grouplist.GroupViewModelFactory import org.apache.fineract.ui.online.groups.grouplist.GroupViewModel +import org.apache.fineract.utils.ConstantKeys import org.apache.fineract.utils.Constants import org.apache.fineract.utils.DateUtils import javax.inject.Inject @@ -30,6 +31,8 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene private var group = Group() private var groupAction = GroupAction.CREATE + private lateinit var initGroupStr: String + @Inject lateinit var groupViewModelFactory: GroupViewModelFactory @@ -49,6 +52,8 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene intent?.extras?.getParcelable(Constants.GROUP)?.let { group = it } + initGroupStr = group.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] } } viewModel = ViewModelProviders.of(this, groupViewModelFactory).get(GroupViewModel::class.java) @@ -97,8 +102,15 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene override fun onCompleted(completeButton: View?) { when (groupAction) { - GroupAction.EDIT -> group.identifier?.let { - viewModel.updateGroup(it, group) + GroupAction.EDIT -> { + if (group.toString().split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] != initGroupStr) { + group.identifier?.let { + viewModel.updateGroup(it, group) + } + } else { + Toaster.show(findViewById(android.R.id.content), + getString(R.string.group_edit_check_msg, group.name)) + } } GroupAction.CREATE -> viewModel.createGroup(group) } diff --git a/app/src/main/java/org/apache/fineract/ui/online/identification/createidentification/identificationactivity/CreateIdentificationActivity.java b/app/src/main/java/org/apache/fineract/ui/online/identification/createidentification/identificationactivity/CreateIdentificationActivity.java index ff2c2a5a..16945447 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/identification/createidentification/identificationactivity/CreateIdentificationActivity.java +++ b/app/src/main/java/org/apache/fineract/ui/online/identification/createidentification/identificationactivity/CreateIdentificationActivity.java @@ -47,6 +47,7 @@ public class CreateIdentificationActivity extends FineractBaseActivity private CreateIdentificationStepAdapter stepAdapter; private String customerIdentifier; private Action action; + private String initIdentificationStr; @Override protected void onCreate(Bundle savedInstanceState) { @@ -78,6 +79,8 @@ protected void onCreate(Bundle savedInstanceState) { break; case EDIT: setToolbarTitle(getString(R.string.edit_identification)); + initIdentificationStr = identification.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0]; break; } @@ -104,8 +107,17 @@ public void onCompleted(View completeButton) { identification); break; case EDIT: - createIdentificationPresenter.updateIdentificationCard(customerIdentifier, - identification.getNumber(), identification); + if (!identification.toString() + .split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0] + .equals(initIdentificationStr)) { + createIdentificationPresenter.updateIdentificationCard(customerIdentifier, + identification.getNumber(), identification); + } else { + Toaster.show(findViewById(android.R.id.content), + getString(R.string.identification_edit_check_msg, + identification.getType())); + return; + } break; } stepperLayout.setNextButtonEnabled(false); diff --git a/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java b/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java index 028076b8..81a7357d 100644 --- a/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java +++ b/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java @@ -40,4 +40,6 @@ public class ConstantKeys { public static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 3; public static final String PERMISSIONS_READ_EXTERNAL_STORAGE_STATUS = "read_status"; + public static final String STRING_SEPARATOR_FROM_CREATEDON = ", createdOn"; + public static final String STRING_SEPARATOR_FROM_CREATEDBY = ", createdBy"; } diff --git a/app/src/main/res/values-ml-rIN/strings.xml b/app/src/main/res/values-ml-rIN/strings.xml index 937afa57..26d8ed11 100644 --- a/app/src/main/res/values-ml-rIN/strings.xml +++ b/app/src/main/res/values-ml-rIN/strings.xml @@ -307,4 +307,10 @@ ഹലോ ശൂന്യമായ ശകലം നിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുകനിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുക ക്രമീകരണ പ്രവർത്തനം എന്തോ തെറ്റായി സംഭവിച്ചു. \'ക്രമീകരണങ്ങൾ\' എന്നതിലേക്ക് പോയി സ്വമേധയാ അനുമതി അനുവദിക്കുക. + + + %1$s ഉപഭോക്താവിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല + %1$s ഗ്രൂപ്പിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല + ഉപഭോക്തൃ ഐഡന്റിഫയർ %1$s ഉപയോഗിച്ച് പേറോളിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല + തിരിച്ചറിയൽ തരം %1$s നായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index af22aaa1..b7034c66 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -412,6 +412,12 @@ Please wait … Logging in… + + Information not edited for the customer %1$s + Information not edited for the group %1$s + Information not edited for the payroll with customer identifier %1$s + Information not edited for the identification type %1$s + abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890