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

Commit 07195d5

Browse files
committed
Add edit check to the edit activities
1 parent 592099e commit 07195d5

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

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

Lines changed: 9 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,12 @@ 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] != initCustomerStr) {
118+
createCustomerPresenter.updateCustomer(customerIdentifier, customer);
119+
} else {
120+
Toast.makeText(this, "The customer is not edited", Toast.LENGTH_SHORT).show();
121+
}
114122
break;
115123
}
116124
}

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
@@ -2,6 +2,7 @@ package org.apache.fineract.ui.online.customers.customerpayroll.editcustomerpayr
22

33
import android.os.Bundle
44
import android.view.View
5+
import android.widget.Toast
56
import com.stepstone.stepper.StepperLayout
67
import com.stepstone.stepper.VerificationError
78
import kotlinx.android.synthetic.main.activity_edit_payroll.*
@@ -20,6 +21,7 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
2021

2122
lateinit var payrollConfig: PayrollConfiguration
2223
lateinit var customerIdentifier: String
24+
private lateinit var initPayrollStr: String
2325

2426
@Inject
2527
lateinit var editPayrollPresenter: EditPayrollPresenter
@@ -35,7 +37,11 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
3537
}
3638

3739
override fun onCompleted(completeButton: View?) {
38-
editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig)
40+
if (payrollConfig.toString().split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0] != initPayrollStr) {
41+
editPayrollPresenter.updatePayrollConfiguration(customerIdentifier, payrollConfig)
42+
} else {
43+
Toast.makeText(this, "The payroll is not edited", Toast.LENGTH_SHORT).show()
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: 13 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,14 @@ 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+
Toast.makeText(this, "There is nothing edited in the group", Toast.LENGTH_SHORT).show()
112+
}
102113
}
103114
GroupAction.CREATE -> viewModel.createGroup(group)
104115
}

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
}

0 commit comments

Comments
 (0)