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

Add edit check to the edit activities #186

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>

Comment on lines +416 to +420

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EGOR-IND Its good to check if user has changed so that unnecessary operations are not performed. But it would suggest that its ok if you dont notify user that he/she has not changed info as user would know it. Instead if user changed info save and exit and if not do quiet exit. What do you say are toasts mandatory?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See I think toasts are good, I don't see any harm in that, it's just a simple indicatiin that they haven't change anything, I can add a dialog if you find snackbar inconvenient, the dialog can have an exit and cancel button, user can exit if they don't want any changes or they can simply press cancel and get back to the edit section. What do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont find toast bad but as you suggested it is better to confirm and save change if user edited or else it should show something like "You didn't change any data. Are you sure you want to exit?". It be probably better that this toast.

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

Expand Down