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

Commit

Permalink
Add edit check to the edit activities
Browse files Browse the repository at this point in the history
  • Loading branch information
EGOR-IND committed Apr 21, 2021
1 parent 592099e commit 2e5a016
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?) {
Expand All @@ -47,6 +53,8 @@ class EditPayrollActivity : FineractBaseActivity(), StepperLayout.StepperListene
editPayrollPresenter.attachView(this)
val payrollConfig = intent.getParcelableExtra<PayrollConfiguration>(ConstantKeys
.PAYROLL_CONFIG)
initPayrollStr = payrollConfig.toString()
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0]

customerIdentifier = intent.getStringExtra(ConstantKeys.CUSTOMER_IDENTIFIER)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -49,6 +52,8 @@ class CreateGroupActivity : FineractBaseActivity(), StepperLayout.StepperListene
intent?.extras?.getParcelable<Group>(Constants.GROUP)?.let {
group = it
}
initGroupStr = group.toString()
.split(ConstantKeys.STRING_SEPARATOR_FROM_CREATEDON)[0]
}
}
viewModel = ViewModelProviders.of(this, groupViewModelFactory).get(GroupViewModel::class.java)
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/apache/fineract/utils/ConstantKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
6 changes: 6 additions & 0 deletions app/src/main/res/values-ml-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@
<string name="hello_blank_fragment">ഹലോ ശൂന്യമായ ശകലം</string>
<string name="dialog_message_camera_permission_never_ask_again">നിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുകനിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുക</string>
<string name="msg_setting_activity_not_found">ക്രമീകരണ പ്രവർത്തനം എന്തോ തെറ്റായി സംഭവിച്ചു. \'ക്രമീകരണങ്ങൾ\' എന്നതിലേക്ക് പോയി സ്വമേധയാ അനുമതി അനുവദിക്കുക.</string>

<!--Edit Check Messages-->
<string name="customer_edit_check_msg">%1$s ഉപഭോക്താവിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
<string name="group_edit_check_msg">%1$s ഗ്രൂപ്പിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
<string name="payroll_edit_check_msg">ഉപഭോക്തൃ ഐഡന്റിഫയർ %1$s ഉപയോഗിച്ച് പേറോളിനായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
<string name="identification_edit_check_msg">തിരിച്ചറിയൽ തരം %1$s നായി വിവരങ്ങൾ എഡിറ്റുചെയ്തിട്ടില്ല</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@
<string name="please_wait">Please wait &#8230;</string>
<string name="logging_in">Logging in…</string>

<!--Edit Check Messages-->
<string name="customer_edit_check_msg">Information not edited for the customer %1$s</string>
<string name="group_edit_check_msg">Information not edited for the group %1$s</string>
<string name="payroll_edit_check_msg">Information not edited for the payroll with customer identifier %1$s</string>
<string name="identification_edit_check_msg">Information not edited for the identification type %1$s</string>

<string name="restrict_a_zA_Z" translatable="false">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
<string name="restrict_a_zA_Z0_9" translatable="false">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890</string>

Expand Down

0 comments on commit 2e5a016

Please sign in to comment.