fix some problems

This commit is contained in:
kkzzhizhou 2021-11-30 09:25:31 +08:00
parent 300f44503b
commit 4010f37f68
6 changed files with 24 additions and 19 deletions

View file

@ -30,5 +30,6 @@
"Add Daily Task": "添加每日任务",
"Add Todo": "添加待办事项",
"Add Habit": "添加习惯",
"Add Reward": "添加奖励"
"Add Reward": "添加奖励",
"Click me to refresh": "点我更新数据"
}

View file

@ -56,7 +56,7 @@ class App extends React.Component<any, any> {
if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) {
return (
<div className="cron">
<button onClick={this.runCron}>Refresh</button>
<button onClick={this.runCron}><Trans>Click me to refresh</Trans></button>
</div>
);
}
@ -248,17 +248,17 @@ class App extends React.Component<any, any> {
this.sendDeleteTask(event.target.id, i18next.t('Deleted!'))
} else {
this.state.tasks.habits.forEach((element: any) => {
if (event.target.attributes.title.value == 'submit') {
if (element.id == event.target.id) {
if (event.target.attributes.title && event.target.attributes.title.value == 'submit') {
const task_title = event.target.attributes['data-title'].value ? event.target.attributes['data-title'].value : element.text
const task_notes = event.target.attributes['data-notes'].value ? event.target.attributes['data-notes'].value : element.notes
this.sendUpdateTask(event.target.id, 'daily', i18next.t("Update!"), task_title, task_notes)
} else {
const target_id = event.target.id.slice(4)
if (event.target.id.slice(0, 4) == "plus") {
this.sendScore(target_id, "up", i18next.t('Plus!'))
} else {
this.sendScore(target_id, "down", i18next.t("Minus :("))
} else if (event.target.attributes.title && event.target.attributes.title.value == 'plus') {
this.sendScore(event.target.id, "up", i18next.t('Plus!'))
} else if (event.target.attributes.title && event.target.attributes.title.value == 'mins') {
this.sendScore(event.target.id, "down", i18next.t("Minus :("))
}
}
})
}
@ -278,7 +278,7 @@ class App extends React.Component<any, any> {
} else if (event.target.attributes.title.value == 'submit') {
const task_title = event.target.attributes['data-title'].value ? event.target.attributes['data-title'].value : element.text
const task_notes = event.target.attributes['data-notes'].value ? event.target.attributes['data-notes'].value : element.notes
const task_coin = event.target.attributes['data-coin'].value ? event.target.attributes['data-coin'].value : element.reward_value
const task_coin = event.target.attributes['data-coin'].value ? event.target.attributes['data-coin'].value : element.value
this.sendUpdateTask(event.target.id, 'reward', i18next.t('Edit!'), task_title, task_notes, task_coin)
} else {
this.sendReward(target_id, "down", i18next.t('Cost!'))

View file

@ -9,10 +9,10 @@ function HabitItem(props: any) {
if (state == 'view') {
return (
<div className="habit-item" id={props.id}>
<button className="habit-plus" id={"plus" + props.id} onClick={props.onChange}>
<button className="habit-plus" id={props.id} onClick={props.onChange} title="plus">
+{props.upCount}
</button>
<button className="habit-minus" id={"mins" + props.id} onClick={props.onChange}>
<button className="habit-minus" id={props.id} onClick={props.onChange} title="mins">
-{props.downCount}
</button>
<div>

View file

@ -5,7 +5,7 @@ function RewardItem(props: any) {
const [state, setState] = React.useState('view')
const [title, setTitle] = React.useState('')
const [notes, setNotes] = React.useState('')
const [coin, setCoin] = React.useState(0)
const [coin, setCoin] = React.useState('0')
if (state === 'view') {
return (
<div className="reward-item" id={props.id}>
@ -27,7 +27,7 @@ function RewardItem(props: any) {
<div className="edit-reward-item edit-item">
<input type="text" onChange={event => setTitle(event.target.value)} defaultValue={props.reward_text}></input>
<input type="text" onChange={event => setNotes(event.target.value)} defaultValue={props.reward_notes}></input>
<input type="text" onChange={event => setNotes(event.target.value)} defaultValue={props.reward_value}></input>
<input type="text" onChange={event => setCoin(event.target.value)} defaultValue={props.reward_value}></input>
<div className="edit-reward-button edit-button">
<button className="task-operation" ><span className="material-icons md-24" id={props.id} onClick={function (e) { props.onChange(e); setState('view') }} title="submit" data-title={title} data-notes={notes} data-coin={coin}>check</span></button>
<button className="task-operation"><span className="material-icons md-24" id={props.id} onClick={() => setState('view')} title="cancel">clear</span></button>

View file

@ -95,7 +95,7 @@ export async function updateTask(username: string, credentials: string, id: stri
"x-api-user": username,
"x-api-key": credentials,
},
body: type === 'reward' ? JSON.stringify({id: id,type: type, text: title,notes: notes, coin: coin}):JSON.stringify({id: id,type: type, text: title,notes: notes})
body: type === 'reward' ? JSON.stringify({id: id,type: type, text: title,notes: notes, value: coin}):JSON.stringify({id: id,type: type, text: title,notes: notes})
})
return(response)
}

View file

@ -130,7 +130,7 @@ input[type=checkbox]:focus {
.plugin-root {
min-width: 260px;
display: grid;
grid-template-rows: 97% 1% 0.5%;
grid-template-rows: 94% 4% 1% 1%;
height: inherit;
}
@ -138,6 +138,10 @@ input[type=checkbox]:focus {
height: 100%;
}
.view-content {
margin-bottom: 0;
}
.substats {
font-size: medium;
}