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

add dialog for edit and delete debt and income factors #174

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 @@ -16,6 +16,7 @@
import org.apache.fineract.R;
import org.apache.fineract.data.models.loan.CreditWorthinessFactor;
import org.apache.fineract.ui.base.Toaster;
import org.apache.fineract.utils.MaterialDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -106,18 +107,17 @@ void addDebtIncome() {
switch (creditWorthinessSource) {
case DEBT:
debtListener.addDebt(creditWorthinessFactor);
dismiss();
break;
case INCOME:
incomeListener.addIncome(creditWorthinessFactor);
dismiss();
break;
case EDIT_DEBT:
debtListener.editDebt(creditWorthinessFactor, position);
break;
case EDIT_INCOME:
incomeListener.editIncome(creditWorthinessFactor, position);
showEditDialog(creditWorthinessFactor);
break;
}
dismiss();
}

public void setCreditWorthinessSource(CreditWorthinessSource creditWorthinessSource) {
Expand Down Expand Up @@ -150,4 +150,27 @@ public void onStart() {
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
}

private void showEditDialog(CreditWorthinessFactor creditWorthinessFactor) {
new MaterialDialog.Builder()
.init(getContext())
.setTitle(getString(R.string.dialog_title_confirm_updation))
.setMessage(getString(R.string.dialog_message_confirm_name_updation,
creditWorthinessFactor.getDescription()))
.setPositiveButton(getString(R.string.update),
(dialog, which) -> {
switch (creditWorthinessSource) {
case EDIT_DEBT:
debtListener.editDebt(creditWorthinessFactor, position);
break;
case EDIT_INCOME:
incomeListener.editIncome(creditWorthinessFactor, position);
break;
}
dismiss();
})
.setNegativeButton(getString(R.string.dialog_action_cancel))
.createMaterialDialog()
.show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.fineract.ui.adapters.LoanDebtIncomeAdapter;
import org.apache.fineract.ui.base.FineractBaseActivity;
import org.apache.fineract.ui.base.FineractBaseFragment;
import org.apache.fineract.utils.MaterialDialog;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -194,26 +195,45 @@ public void onClickEdit(CreditWorthinessSource creditWorthinessSource, int posit

@Override
public void onClickDelete(CreditWorthinessSource creditWorthinessSource, int position) {
String msg = "";
switch (creditWorthinessSource) {
case DEBT:
debtCreditWorthinessFactors.remove(position);
debtAdapter.notifyDataSetChanged();
if (debtAdapter.getItemCount() == 0) {
tvEmptyDebtList.setVisibility(View.VISIBLE);
rvDebt.setVisibility(View.GONE);
}
updateDebtsAndRatio();
msg = debtCreditWorthinessFactors.get(position).getDescription();
break;
case INCOME:
incomeCreditWorthinessFactors.remove(position);
incomeAdapter.notifyDataSetChanged();
if (incomeAdapter.getItemCount() == 0) {
tvEmptyIncomeList.setVisibility(View.VISIBLE);
rvIncome.setVisibility(View.GONE);
}
updateIncomeAndRatio();
msg = incomeCreditWorthinessFactors.get(position).getDescription();
break;
}
new MaterialDialog.Builder()
.init(getContext())
.setTitle(getString(R.string.dialog_title_confirm_deletion))
.setMessage(getString(R.string.dialog_message_confirm_name_deletion, msg))
.setPositiveButton(getString(R.string.delete),
(dialog, which) -> {
switch (creditWorthinessSource) {
case DEBT:
debtCreditWorthinessFactors.remove(position);
debtAdapter.notifyDataSetChanged();
if (debtAdapter.getItemCount() == 0) {
tvEmptyDebtList.setVisibility(View.VISIBLE);
rvDebt.setVisibility(View.GONE);
}
updateDebtsAndRatio();
break;
case INCOME:
incomeCreditWorthinessFactors.remove(position);
incomeAdapter.notifyDataSetChanged();
if (incomeAdapter.getItemCount() == 0) {
tvEmptyIncomeList.setVisibility(View.VISIBLE);
rvIncome.setVisibility(View.GONE);
}
updateIncomeAndRatio();
break;
}
})
.setNegativeButton(getString(R.string.dialog_action_cancel))
.createMaterialDialog()
.show();
}

public void showDebtIncomeBottomSheet(CreditWorthinessSource creditWorthinessSource,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ml-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
<string name="dialog_action_delete">ഇല്ലാതാക്കുക</string>
<string name="dialog_action_logout">പുറത്തുകടക്കുക</string>
<string name="dialog_title_confirm_deletion">ഇല്ലാതാക്കൽ സ്ഥിരീകരിക്കുക</string>
<string name="dialog_title_confirm_updation">അപ്‌ഡേറ്റ് സ്ഥിരീകരിക്കുക</string>
<string name="dialog_title_confirm_logout">ലോഗ്ഔട്ട് സ്ഥിരീകരിക്കുക</string>
<string name="dialog_message_confirmation_delete_identification_card">ഈ തിരിച്ചറിയൽ കാർഡ് ഇല്ലാതാക്കാൻ ആഗ്രഹിക്കുന്നുവോ?</string>
<string name="dialog_message_confirmation_delete_identification_card_scan">ഈ ഐഡന്റിഫിക്കേഷൻ കാർഡ് സ്കാൻ ഇല്ലാതാക്കാൻ നിങ്ങൾക്ക് താൽപ്പര്യമുണ്ടോ?</string>
Expand Down Expand Up @@ -307,4 +308,5 @@
<string name="hello_blank_fragment">ഹലോ ശൂന്യമായ ശകലം</string>
<string name="dialog_message_camera_permission_never_ask_again">നിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുകനിങ്ങൾ അനുമതി നിഷേധിച്ചു ഈ അനുമതിയില്ലാതെ നിങ്ങൾക്ക് ക്യാമറ സ്കാൻ ചെയ്യാൻ കഴിയില്ല. ഇത് സജ്ജീകരണങ്ങളിൽ പ്രാപ്തമാക്കുക</string>
<string name="msg_setting_activity_not_found">ക്രമീകരണ പ്രവർത്തനം എന്തോ തെറ്റായി സംഭവിച്ചു. \'ക്രമീകരണങ്ങൾ\' എന്നതിലേക്ക് പോയി സ്വമേധയാ അനുമതി അനുവദിക്കുക.</string>
<string name="dialog_message_confirm_name_updation">നിങ്ങൾക്ക് അപ്‌ഡേറ്റ് ചെയ്യണോ %s?</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
<string name="dialog_action_delete">Delete</string>
<string name="dialog_action_logout">Logout</string>
<string name="dialog_title_confirm_deletion">Confirm deletion</string>
<string name="dialog_title_confirm_updation">Confirm update</string>
<string name="dialog_title_confirm_logout">Confirm logout</string>
<string name="dialog_message_confirmation_delete_identification_card">Do you want to delete this identification card?</string>
<string name="dialog_message_confirmation_delete_identification_card_scan">Do you want to delete this identification card scan?</string>
Expand Down Expand Up @@ -535,6 +536,7 @@
<string name="please_click_back_again_to_exit">Please click BACK again to exit</string>
<string name="update">Update</string>
<string name="dialog_message_confirm_name_deletion">Do you want to delete %s?</string>
<string name="dialog_message_confirm_name_updation">Do you want to update %s?</string>
<string name="edit_group">Edit Group</string>
<string name="updating_group_please_wait">Updating Group, please wait...</string>
<string name="please_verify_following_group_task">Please verify the following tasks before you can %1$s this group</string>
Expand Down