Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit 2e5a016

Browse files
committed
Add edit check to the edit activities
1 parent 592099e commit 2e5a016

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/customeractivity/CreateCustomerActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class CreateCustomerActivity extends FineractBaseActivity
5151
private Customer customer;
5252
private CustomerAction customerAction;
5353
private String customerIdentifier;
54+
private String initCustomerStr;
5455

5556
@Override
5657
protected void onCreate(Bundle savedInstanceState) {
@@ -82,6 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
8283
break;
8384
case EDIT:
8485
setToolbarTitle(getString(R.string.edit_customer));
86+
initCustomerStr = customer.toString()
87+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0];
8588
break;
8689
}
8790

@@ -110,7 +113,14 @@ public void onCompleted(View completeButton) {
110113
createCustomerPresenter.createCustomer(customer);
111114
break;
112115
case EDIT:
113-
createCustomerPresenter.updateCustomer(customerIdentifier, customer);
116+
if (customer.toString()
117+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0]
118+
.equals(initCustomerStr)) {
119+
createCustomerPresenter.updateCustomer(customerIdentifier, customer);
120+
} else {
121+
Toaster.show(findViewById(android.R.id.content),
122+
getString(R.string.customer_edit_check_msg, customer.getGivenName()));
123+
}
114124
break;
115125
}
116126
}

app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/EditPayrollActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
2020

2121
lateinit var payrollConfig: PayrollConfiguration
2222
lateinit var customerIdentifier: String
23+
private lateinit var initPayrollStr: String
2324

2425
@Inject
2526
lateinit var editPayrollPresenter: EditPayrollPresenter
@@ -35,7 +36,12 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
3536
}
3637

3738
override fun onCompleted(completeButton: View?) {
38-
editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig)
39+
if (payrollConfig.toString().split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] != initPayrollStr) {
40+
editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig)
41+
} else {
42+
Toaster.show(findViewById(android.R.id.content),
43+
getString(R.string.payroll_edit_check_msg, customerIdentifier))
44+
}
3945
}
4046

4147
override fun onCreate(savedInstanceState: Bundle?) {
@@ -47,6 +53,8 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
4753
editPayrollPresenter.attachView(this)
4854
val payrollConfig = intent.getParcelableExtra<PayrollConfiguration>(ConstantKeys
4955
.PAYROLL_CONFIG)
56+
initPayrollStr = payrollConfig.toString()
57+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0]
5058

5159
customerIdentifier = intent.getStringExtra(ConstantKeys.CUSTOMER_IDENTIFIER)
5260

app/src/main/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivity.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.apache.fineract.ui.base.Toaster
1717
import org.apache.fineract.ui.online.groups.GroupAction
1818
import org.apache.fineract.ui.online.groups.grouplist.GroupViewModelFactory
1919
import org.apache.fineract.ui.online.groups.grouplist.GroupViewModel
20+
import org.apache.fineract.utils.ConstantKeys
2021
import org.apache.fineract.utils.Constants
2122
import org.apache.fineract.utils.DateUtils
2223
import javax.inject.Inject
@@ -30,6 +31,8 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene
3031
private var group = Group()
3132
private var groupAction = GroupAction.CREATE
3233

34+
private lateinit var initGroupStr: String
35+
3336
@Inject
3437
lateinit var groupViewModelFactory: GroupViewModelFactory
3538

@@ -49,6 +52,8 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene
4952
intent?.extras?.getParcelable<Group>(Constants.GROUP)?.let {
5053
group = it
5154
}
55+
initGroupStr = group.toString()
56+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0]
5257
}
5358
}
5459
viewModel = ViewModelProviders.of(this, groupViewModelFactory).get(GroupViewModel::class.java)
@@ -97,8 +102,15 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene
97102

98103
override fun onCompleted(completeButton: View?) {
99104
when (groupAction) {
100-
GroupAction.EDIT -> group.identifier?.let {
101-
viewModel.updateGroup(it, group)
105+
GroupAction.EDIT -> {
106+
if (group.toString().split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] != initGroupStr) {
107+
group.identifier?.let {
108+
viewModel.updateGroup(it, group)
109+
}
110+
} else {
111+
Toaster.show(findViewById(android.R.id.content),
112+
getString(R.string.group_edit_check_msg, group.name))
113+
}
102114
}
103115
GroupAction.CREATE -> viewModel.createGroup(group)
104116
}

app/src/main/java/org/apache/fineract/ui/online/identification/createidentification/identificationactivity/CreateIdentificationActivity.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class CreateIdentificationActivity extends FineractBaseActivity
4747
private CreateIdentificationStepAdapter stepAdapter;
4848
private String customerIdentifier;
4949
private Action action;
50+
private String initIdentificationStr;
5051

5152
@Override
5253
protected void onCreate(Bundle savedInstanceState) {
@@ -78,6 +79,8 @@ protected void onCreate(Bundle savedInstanceState) {
7879
break;
7980
case EDIT:
8081
setToolbarTitle(getString(R.string.edit_identification));
82+
initIdentificationStr = identification.toString()
83+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0];
8184
break;
8285
}
8386

@@ -104,8 +107,17 @@ public void onCompleted(View completeButton) {
104107
identification);
105108
break;
106109
case EDIT:
107-
createIdentificationPresenter.updateIdentificationCard(customerIdentifier,
108-
identification.getNumber(), identification);
110+
if (!identification.toString()
111+
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDBY)[0]
112+
.equals(initIdentificationStr)) {
113+
createIdentificationPresenter.updateIdentificationCard(customerIdentifier,
114+
identification.getNumber(), identification);
115+
} else {
116+
Toaster.show(findViewById(android.R.id.content),
117+
getString(R.string.identification_edit_check_msg,
118+
identification.getType()));
119+
return;
120+
}
109121
break;
110122
}
111123
stepperLayout.setNextButtonEnabled(false);

app/src/main/java/org/apache/fineract/utils/ConstantKeys.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ public class ConstantKeys {
4040
public static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 3;
4141
public static final String PERMISSIONS_READ_EXTERNAL_STORAGE_STATUS = "read_status";
4242

43+
public static final String STRING_SEPARATOR_FROM_CREATEDON = ", createdOn";
44+
public static final String STRING_SEPARATOR_FROM_CREATEDBY = ", createdBy";
4345
}

app/src/main/res/values-ml-rIN/strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,10 @@
307307
<string name="hello_blank_fragment">ഹലോ ശൂന്യമായ ശകലം</string>
308308
<string name="dialog_message_camera_permission_never_ask_again">നിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുകനിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുക</string>
309309
<string name="msg_setting_activity_not_found">ക്രമീകരണ പ്രവർത്തനം എന്തോ തെറ്റായി സംഭവിച്ചു. \'ക്രമീകരണങ്ങൾ\' എന്നതിലേക്ക് പോയി സ്വമേധയാ അനുമതി അനുവദിക്കുക.</string>
310+
311+
<!--Edit Check Messages-->
312+
<string name="customer_edit_check_msg">%1$s ഉപഭോക്താവിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
313+
<string name="group_edit_check_msg">%1$s ഗ്രൂപ്പിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
314+
<string name="payroll_edit_check_msg">ഉപഭോക്തൃ ഐഡന്റിഫയർ %1$s ഉപയോഗിച്ച് പേറോളിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
315+
<string name="identification_edit_check_msg">തിരിച്ചറിയൽ തരം %1$s നായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
310316
</resources>

app/src/main/res/values/strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@
412412
<string name="please_wait">Please wait &#8230;</string>
413413
<string name="logging_in">Logging in…</string>
414414

415+
<!--Edit Check Messages-->
416+
<string name="customer_edit_check_msg">Information not edited for the customer %1$s</string>
417+
<string name="group_edit_check_msg">Information not edited for the group %1$s</string>
418+
<string name="payroll_edit_check_msg">Information not edited for the payroll with customer identifier %1$s</string>
419+
<string name="identification_edit_check_msg">Information not edited for the identification type %1$s</string>
420+
415421
<string name="restrict_a_zA_Z" translatable="false">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
416422
<string name="restrict_a_zA_Z0_9" translatable="false">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890</string>
417423

0 commit comments

Comments
 (0)