show a confirmation dialog allowing the user to change the editable transaction range to "All" when unable to add or edit a transaction due to the limitation on the editable transaction range

This commit is contained in:
MaysWind
2024-09-20 00:47:53 +08:00
parent 6655d725ae
commit 5221ab481e
6 changed files with 88 additions and 5 deletions
+4
View File
@@ -8,6 +8,8 @@ const baseAmapApiProxyUrlPath = '/_AMapService';
const apiNotFoundErrorCode = 100001; const apiNotFoundErrorCode = 100001;
const validatorErrorCode = 200000; const validatorErrorCode = 200000;
const userEmailNotVerifiedErrorCode = 201020; const userEmailNotVerifiedErrorCode = 201020;
const transactionCannotCreateInThisTimeErrorCode = 205017;
const transactionCannotModifyInThisTimeErrorCode = 205018;
const transactionPictureNotFoundErrorCode = 211001; const transactionPictureNotFoundErrorCode = 211001;
const googleMapJavascriptUrl = 'https://maps.googleapis.com/maps/api/js'; const googleMapJavascriptUrl = 'https://maps.googleapis.com/maps/api/js';
const baiduMapJavascriptUrl = 'https://api.map.baidu.com/api?v=3.0'; const baiduMapJavascriptUrl = 'https://api.map.baidu.com/api?v=3.0';
@@ -152,6 +154,8 @@ export default {
apiNotFoundErrorCode: apiNotFoundErrorCode, apiNotFoundErrorCode: apiNotFoundErrorCode,
validatorErrorCode: validatorErrorCode, validatorErrorCode: validatorErrorCode,
userEmailNotVerifiedErrorCode: userEmailNotVerifiedErrorCode, userEmailNotVerifiedErrorCode: userEmailNotVerifiedErrorCode,
transactionCannotCreateInThisTimeErrorCode: transactionCannotCreateInThisTimeErrorCode,
transactionCannotModifyInThisTimeErrorCode: transactionCannotModifyInThisTimeErrorCode,
transactionPictureNotFoundErrorCode: transactionPictureNotFoundErrorCode, transactionPictureNotFoundErrorCode: transactionPictureNotFoundErrorCode,
specifiedApiNotFoundErrors: specifiedApiNotFoundErrors, specifiedApiNotFoundErrors: specifiedApiNotFoundErrors,
parameterizedErrors: parameterizedErrors, parameterizedErrors: parameterizedErrors,
+4 -1
View File
@@ -1515,6 +1515,7 @@
"Source account cannot be blank": "Source account cannot be blank", "Source account cannot be blank": "Source account cannot be blank",
"Destination account cannot be blank": "Destination account cannot be blank", "Destination account cannot be blank": "Destination account cannot be blank",
"Are you sure you want to save this transaction with a zero amount?": "Are you sure you want to save this transaction with a zero amount?", "Are you sure you want to save this transaction with a zero amount?": "Are you sure you want to save this transaction with a zero amount?",
"You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?": "You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?",
"Unable to retrieve transaction": "Unable to retrieve transaction", "Unable to retrieve transaction": "Unable to retrieve transaction",
"Unable to add transaction": "Unable to add transaction", "Unable to add transaction": "Unable to add transaction",
"Unable to save transaction": "Unable to save transaction", "Unable to save transaction": "Unable to save transaction",
@@ -1642,12 +1643,14 @@
"Please enter your current password when modifying your password": "Please enter your current password when modifying your password", "Please enter your current password when modifying your password": "Please enter your current password when modifying your password",
"Nothing has been modified": "Nothing has been modified", "Nothing has been modified": "Nothing has been modified",
"Your profile has been successfully updated": "Your profile has been successfully updated", "Your profile has been successfully updated": "Your profile has been successfully updated",
"Unable to update user profile": "Unable to update user profile",
"Your editable transaction range has been set to All": "Your editable transaction range has been set to All",
"Unable to update editable transaction range": "Unable to update editable transaction range",
"Unable to update user avatar": "Unable to update user avatar", "Unable to update user avatar": "Unable to update user avatar",
"Your avatar has been successfully updated": "Your avatar has been successfully updated", "Your avatar has been successfully updated": "Your avatar has been successfully updated",
"Are you sure you want to remove avatar?": "Are you sure you want to remove avatar?", "Are you sure you want to remove avatar?": "Are you sure you want to remove avatar?",
"Unable to remove user avatar": "Unable to remove user avatar", "Unable to remove user avatar": "Unable to remove user avatar",
"Your avatar has been successfully removed": "Your avatar has been successfully removed", "Your avatar has been successfully removed": "Your avatar has been successfully removed",
"Unable to update user profile": "Unable to update user profile",
"After changing the password, other devices will be logged out. Please use the new password to log in on other devices.": "After changing the password, other devices will be logged out. Please use the new password to log in on other devices.", "After changing the password, other devices will be logged out. Please use the new password to log in on other devices.": "After changing the password, other devices will be logged out. Please use the new password to log in on other devices.",
"Data Management": "Data Management", "Data Management": "Data Management",
"Unable to retrieve user statistics data": "Unable to retrieve user statistics data", "Unable to retrieve user statistics data": "Unable to retrieve user statistics data",
+4 -1
View File
@@ -1515,6 +1515,7 @@
"Source account cannot be blank": "来源账户不能为空", "Source account cannot be blank": "来源账户不能为空",
"Destination account cannot be blank": "目标账户不能为空", "Destination account cannot be blank": "目标账户不能为空",
"Are you sure you want to save this transaction with a zero amount?": "您确定要保存这个金额为0的交易?", "Are you sure you want to save this transaction with a zero amount?": "您确定要保存这个金额为0的交易?",
"You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?": "您已经设置不允许修改这个时间范围的交易,是否要将可编辑交易范围设置为全部?",
"Unable to retrieve transaction": "无法获取交易", "Unable to retrieve transaction": "无法获取交易",
"Unable to add transaction": "无法添加交易", "Unable to add transaction": "无法添加交易",
"Unable to save transaction": "无法保存交易", "Unable to save transaction": "无法保存交易",
@@ -1642,12 +1643,14 @@
"Please enter your current password when modifying your password": "修改密码时请输入您的当前密码", "Please enter your current password when modifying your password": "修改密码时请输入您的当前密码",
"Nothing has been modified": "没有修改的项目", "Nothing has been modified": "没有修改的项目",
"Your profile has been successfully updated": "您的用户信息更新成功", "Your profile has been successfully updated": "您的用户信息更新成功",
"Unable to update user profile": "无法更新用户信息",
"Your editable transaction range has been set to All": "您的可编辑交易范围已设置为全部",
"Unable to update editable transaction range": "无法更新可编辑交易范围",
"Unable to update user avatar": "无法更新用户头像", "Unable to update user avatar": "无法更新用户头像",
"Your avatar has been successfully updated": "您的头像更新成功", "Your avatar has been successfully updated": "您的头像更新成功",
"Are you sure you want to remove avatar?": "您确定要删除头像?", "Are you sure you want to remove avatar?": "您确定要删除头像?",
"Unable to remove user avatar": "无法删除用户头像", "Unable to remove user avatar": "无法删除用户头像",
"Your avatar has been successfully removed": "您的用户头像删除成功", "Your avatar has been successfully removed": "您的用户头像删除成功",
"Unable to update user profile": "无法更新用户信息",
"After changing the password, other devices will be logged out. Please use the new password to log in on other devices.": "密码修改后,其他设备将会退出登录,请使用新密码在其他设备上重新登录。", "After changing the password, other devices will be logged out. Please use the new password to log in on other devices.": "密码修改后,其他设备将会退出登录,请使用新密码在其他设备上重新登录。",
"Data Management": "数据管理", "Data Management": "数据管理",
"Unable to retrieve user statistics data": "无法获取用户统计数据", "Unable to retrieve user statistics data": "无法获取用户统计数据",
+35 -1
View File
@@ -5,7 +5,10 @@ import { useSettingsStore } from './setting.js';
import userState from '@/lib/userstate.js'; import userState from '@/lib/userstate.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
import { isNumber } from '@/lib/common.js'; import {
isObject,
isNumber
} from '@/lib/common.js';
export const useUserStore = defineStore('user', { export const useUserStore = defineStore('user', {
state: () => ({ state: () => ({
@@ -126,6 +129,37 @@ export const useUserStore = defineStore('user', {
}); });
}); });
}, },
updateUserTransactionEditScope({ transactionEditScope }) {
return new Promise((resolve, reject) => {
services.updateProfile({
transactionEditScope: transactionEditScope,
}).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to update editable transaction range' });
return;
}
if (data.result.user && isObject(data.result.user)) {
const userStore = useUserStore();
userStore.storeUserBasicInfo(data.result.user);
}
resolve(data.result);
}).catch(error => {
logger.error('failed to save editable transaction range', error);
if (error.response && error.response.data && error.response.data.errorMessage) {
reject({ error: error.response.data });
} else if (!error.processed) {
reject({ message: 'Unable to update editable transaction range' });
} else {
reject(error);
}
});
});
},
updateUserAvatar({ avatarFile }) { updateUserAvatar({ avatarFile }) {
const self = this; const self = this;
@@ -935,10 +935,28 @@ export default {
}).catch(error => { }).catch(error => {
self.submitting = false; self.submitting = false;
if (error.error && (error.error.errorCode === apiConstants.transactionCannotCreateInThisTimeErrorCode || error.error.errorCode === apiConstants.transactionCannotModifyInThisTimeErrorCode)) {
self.$refs.confirmDialog.open('You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?').then(() => {
self.submitting = true;
self.userStore.updateUserTransactionEditScope({
transactionEditScope: transactionConstants.allTransactionEditScopeTypes.All.type
}).then(() => {
self.submitting = false;
self.$refs.snackbar.showMessage('Your editable transaction range has been set to All');
}).catch(error => {
self.submitting = false;
if (!error.processed) { if (!error.processed) {
self.$refs.snackbar.showError(error); self.$refs.snackbar.showError(error);
} }
}); });
});
} else if (!error.processed) {
self.$refs.snackbar.showError(error);
}
});
}; };
if (self.transaction.sourceAmount === 0) { if (self.transaction.sourceAmount === 0) {
@@ -1059,10 +1059,31 @@ export default {
self.submitting = false; self.submitting = false;
self.$hideLoading(); self.$hideLoading();
if (error.error && (error.error.errorCode === apiConstants.transactionCannotCreateInThisTimeErrorCode || error.error.errorCode === apiConstants.transactionCannotModifyInThisTimeErrorCode)) {
self.$confirm('You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?', () => {
self.submitting = true;
self.$showLoading(() => self.submitting);
self.userStore.updateUserTransactionEditScope({
transactionEditScope: transactionConstants.allTransactionEditScopeTypes.All.type
}).then(() => {
self.submitting = false;
self.$hideLoading();
self.$toast('Your editable transaction range has been set to All');
}).catch(error => {
self.submitting = false;
self.$hideLoading();
if (!error.processed) { if (!error.processed) {
self.$toast(error.message || error); self.$toast(error.message || error);
} }
}); });
});
} else if (!error.processed) {
self.$toast(error.message || error);
}
});
}; };
if (self.transaction.sourceAmount === 0) { if (self.transaction.sourceAmount === 0) {