mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
allow user to limit time scope for editing transaction
This commit is contained in:
+14
-8
@@ -2,6 +2,7 @@ import axios from 'axios';
|
||||
|
||||
import api from "../consts/api.js";
|
||||
import userState from "./userstate.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
let needBlockRequest = false;
|
||||
let blockedRequests = [];
|
||||
@@ -130,14 +131,15 @@ export default {
|
||||
getProfile: () => {
|
||||
return axios.get('v1/users/profile/get.json');
|
||||
},
|
||||
updateProfile: ({ email, nickname, password, oldPassword, defaultCurrency, firstDayOfWeek }) => {
|
||||
updateProfile: ({ email, nickname, password, oldPassword, defaultCurrency, firstDayOfWeek, transactionEditScope }) => {
|
||||
return axios.post('v1/users/profile/update.json', {
|
||||
email,
|
||||
nickname,
|
||||
password,
|
||||
oldPassword,
|
||||
defaultCurrency,
|
||||
firstDayOfWeek
|
||||
firstDayOfWeek,
|
||||
transactionEditScope
|
||||
});
|
||||
},
|
||||
get2FAStatus: () => {
|
||||
@@ -249,12 +251,14 @@ export default {
|
||||
});
|
||||
},
|
||||
getTransactions: ({ maxTime, minTime, type, categoryId, accountId, keyword }) => {
|
||||
return axios.get(`v1/transactions/list.json?max_time=${maxTime}&min_time=${minTime}&type=${type}&category_id=${categoryId}&account_id=${accountId}&keyword=${keyword}&count=50`);
|
||||
const utcOffset = utils.getTimezoneOffsetMinutes();
|
||||
return axios.get(`v1/transactions/list.json?max_time=${maxTime}&min_time=${minTime}&type=${type}&category_id=${categoryId}&account_id=${accountId}&keyword=${keyword}&count=50&utc_offset=${utcOffset}`);
|
||||
},
|
||||
getTransaction: ({ id }) => {
|
||||
return axios.get('v1/transactions/get.json?id=' + id);
|
||||
const utcOffset = utils.getTimezoneOffsetMinutes();
|
||||
return axios.get(`v1/transactions/get.json?id=${id}&utc_offset=${utcOffset}`);
|
||||
},
|
||||
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment }) => {
|
||||
addTransaction: ({ type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment, utcOffset }) => {
|
||||
return axios.post('v1/transactions/add.json', {
|
||||
type,
|
||||
categoryId,
|
||||
@@ -264,10 +268,11 @@ export default {
|
||||
sourceAmount,
|
||||
destinationAmount,
|
||||
tagIds,
|
||||
comment
|
||||
comment,
|
||||
utcOffset
|
||||
});
|
||||
},
|
||||
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment }) => {
|
||||
modifyTransaction: ({ id, type, categoryId, time, sourceAccountId, destinationAccountId, sourceAmount, destinationAmount, tagIds, comment, utcOffset }) => {
|
||||
return axios.post('v1/transactions/modify.json', {
|
||||
id,
|
||||
type,
|
||||
@@ -278,7 +283,8 @@ export default {
|
||||
sourceAmount,
|
||||
destinationAmount,
|
||||
tagIds,
|
||||
comment
|
||||
comment,
|
||||
utcOffset
|
||||
});
|
||||
},
|
||||
deleteTransaction: ({ id }) => {
|
||||
|
||||
@@ -42,6 +42,22 @@ function getTimezoneOffset(timezone) {
|
||||
}
|
||||
}
|
||||
|
||||
function getTimezoneOffsetMinutes(timezone) {
|
||||
const offset = getTimezoneOffset(timezone);
|
||||
|
||||
if (!offset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const parts = offset.split(':');
|
||||
|
||||
if (parts.length !== 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return parseInt(parts[0]) * 60 + parseInt(parts[1]);
|
||||
}
|
||||
|
||||
function getCurrentUnixTime() {
|
||||
return moment().unix();
|
||||
}
|
||||
@@ -571,6 +587,7 @@ export default {
|
||||
isNumber,
|
||||
isBoolean,
|
||||
getTimezoneOffset,
|
||||
getTimezoneOffsetMinutes,
|
||||
getCurrentUnixTime,
|
||||
parseDateFromUnixTime,
|
||||
formatUnixTime,
|
||||
|
||||
@@ -546,6 +546,8 @@ export default {
|
||||
'cannot add transaction to hidden account': 'You cannot add transaction to an hidden account',
|
||||
'cannot modify transaction of hidden account': 'You cannot modify transaction of an hidden account',
|
||||
'cannot delete transaction in hidden account': 'You cannot delete transaction in an hidden account',
|
||||
'cannot add transaction with this transaction time': 'You cannot add transaction with this transaction time',
|
||||
'cannot modify transaction with this transaction time ': 'You cannot modify this transaction with this transaction time',
|
||||
'transaction category id is invalid': 'Transaction category ID is invalid',
|
||||
'transaction category not found': 'Transaction category is not found',
|
||||
'transaction category type is invalid': 'Transaction category type is invalid',
|
||||
@@ -571,6 +573,7 @@ export default {
|
||||
'oldPassword': 'Current Password',
|
||||
'defaultCurrency': 'Default Currency',
|
||||
'firstDayOfWeek': 'First Day of Week',
|
||||
'transactionEditScope': 'Transaction Edit Scope',
|
||||
'name': 'Name',
|
||||
'category': 'Category',
|
||||
'type': 'Type',
|
||||
@@ -678,6 +681,12 @@ export default {
|
||||
'Your nickname': 'Your nickname',
|
||||
'Default Currency': 'Default Currency',
|
||||
'First Day of Week': 'First Day of Week',
|
||||
'Transaction Edit Scope': 'Transaction Edit Scope',
|
||||
'Today or later': 'Today or later',
|
||||
'Recent 24 hours or later': 'Recent 24 hours or later',
|
||||
'This week or later': 'This week or later',
|
||||
'This month or later': 'This month or later',
|
||||
'This year or later': 'This year or later',
|
||||
'Log In': 'Log In',
|
||||
'Don\'t have an account?': 'Don\'t have an account?',
|
||||
'Create an account': 'Create an account',
|
||||
|
||||
@@ -546,6 +546,8 @@ export default {
|
||||
'cannot add transaction to hidden account': '您不能在隐藏账户中添加交易',
|
||||
'cannot modify transaction of hidden account': '您不能修改隐藏账户中的交易',
|
||||
'cannot delete transaction in hidden account': '您不能删除隐藏账户中的交易',
|
||||
'cannot add transaction with this transaction time': '您不能添加有该交易时间的交易',
|
||||
'cannot modify transaction with this transaction time ': '您不能修改有该交易时间的交易',
|
||||
'transaction category id is invalid': '交易分类ID无效',
|
||||
'transaction category not found': '交易分类不存在',
|
||||
'transaction category type is invalid': '交易分类类型无效',
|
||||
@@ -571,6 +573,7 @@ export default {
|
||||
'oldPassword': '当前密码',
|
||||
'defaultCurrency': '默认货币',
|
||||
'firstDayOfWeek': '每周第一天',
|
||||
'transactionEditScope': '交易编辑范围',
|
||||
'name': '名称',
|
||||
'category': '分类',
|
||||
'type': '类型',
|
||||
@@ -678,6 +681,12 @@ export default {
|
||||
'Your nickname': '你的昵称',
|
||||
'Default Currency': '默认货币',
|
||||
'First Day of Week': '每周第一天',
|
||||
'Transaction Edit Scope': '交易编辑范围',
|
||||
'Today or later': '今天或更晚',
|
||||
'Recent 24 hours or later': '最近24小时或更晚',
|
||||
'This week or later': '本周或更晚',
|
||||
'This month or later': '本月或更晚',
|
||||
'This year or later': '今年或更晚',
|
||||
'Log In': '登录',
|
||||
'Don\'t have an account?': '还没有账号?',
|
||||
'Create an account': '创建新账号',
|
||||
|
||||
+2
-1
@@ -236,7 +236,8 @@ export function updateUserProfile(context, { profile, currentPassword }) {
|
||||
email: profile.email,
|
||||
nickname: profile.nickname,
|
||||
defaultCurrency: profile.defaultCurrency,
|
||||
firstDayOfWeek: profile.firstDayOfWeek
|
||||
firstDayOfWeek: profile.firstDayOfWeek,
|
||||
transactionEditScope: profile.transactionEditScope
|
||||
}).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
|
||||
@@ -662,7 +662,8 @@ export default {
|
||||
destinationAccountId: '0',
|
||||
destinationAmount: 0,
|
||||
tagIds: self.transaction.tagIds,
|
||||
comment: self.transaction.comment
|
||||
comment: self.transaction.comment,
|
||||
utcOffset: self.$utilities.getTimezoneOffsetMinutes()
|
||||
};
|
||||
|
||||
if (self.transaction.type === self.$constants.transaction.allTransactionTypes.Expense) {
|
||||
|
||||
@@ -86,6 +86,21 @@
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
:title="$t('Transaction Edit Scope')"
|
||||
smart-select :smart-select-params="{ openIn: 'popup', closeOnSelect: true, popupCloseLinkText: $t('Close'), scrollToSelectedItem: true }"
|
||||
>
|
||||
<select v-model="newProfile.transactionEditScope">
|
||||
<option :value="0">{{ $t('None') }}</option>
|
||||
<option :value="1">{{ $t('All') }}</option>
|
||||
<option :value="2">{{ $t('Today or later') }}</option>
|
||||
<option :value="3">{{ $t('Recent 24 hours or later') }}</option>
|
||||
<option :value="4">{{ $t('This week or later') }}</option>
|
||||
<option :value="5">{{ $t('This month or later') }}</option>
|
||||
<option :value="6">{{ $t('This year or later') }}</option>
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item class="lab-list-item-error-info" v-if="inputIsInvalid" :footer="$t(inputInvalidProblemMessage)"></f7-list-item>
|
||||
</f7-list>
|
||||
</f7-card-content>
|
||||
@@ -112,13 +127,15 @@ export default {
|
||||
email: '',
|
||||
nickname: '',
|
||||
defaultCurrency: '',
|
||||
firstDayOfWeek: 0
|
||||
firstDayOfWeek: 0,
|
||||
transactionEditScope: 1
|
||||
},
|
||||
oldProfile: {
|
||||
email: '',
|
||||
nickname: '',
|
||||
defaultCurrency: '',
|
||||
firstDayOfWeek: 0
|
||||
firstDayOfWeek: 0,
|
||||
transactionEditScope: 1
|
||||
},
|
||||
currentPassword: '',
|
||||
loading: true,
|
||||
@@ -147,7 +164,8 @@ export default {
|
||||
this.newProfile.email === this.oldProfile.email &&
|
||||
this.newProfile.nickname === this.oldProfile.nickname &&
|
||||
this.newProfile.defaultCurrency === this.oldProfile.defaultCurrency &&
|
||||
this.newProfile.firstDayOfWeek === this.oldProfile.firstDayOfWeek) {
|
||||
this.newProfile.firstDayOfWeek === this.oldProfile.firstDayOfWeek &&
|
||||
this.newProfile.transactionEditScope === this.oldProfile.transactionEditScope) {
|
||||
return 'Nothing has been modified';
|
||||
} else if (!this.newProfile.password && this.newProfile.confirmPassword) {
|
||||
return 'Password cannot be empty';
|
||||
@@ -181,11 +199,13 @@ export default {
|
||||
self.oldProfile.nickname = profile.nickname;
|
||||
self.oldProfile.defaultCurrency = profile.defaultCurrency;
|
||||
self.oldProfile.firstDayOfWeek = profile.firstDayOfWeek;
|
||||
self.oldProfile.transactionEditScope = profile.transactionEditScope;
|
||||
|
||||
self.newProfile.email = self.oldProfile.email
|
||||
self.newProfile.nickname = self.oldProfile.nickname;
|
||||
self.newProfile.defaultCurrency = self.oldProfile.defaultCurrency;
|
||||
self.newProfile.firstDayOfWeek = self.oldProfile.firstDayOfWeek;
|
||||
self.newProfile.transactionEditScope = self.oldProfile.transactionEditScope;
|
||||
|
||||
self.loading = false;
|
||||
}).catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user