Skip to content

Commit

Permalink
fix: widget/stickynote - save immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
fs5m8 committed Dec 5, 2022
1 parent 24021b9 commit 63dfef9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 61 deletions.
3 changes: 1 addition & 2 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,7 @@ common/views/widgets/server.vue:
toggle: "Toggle views"
common/views/widgets/memo.vue:
title: "Sticky note"
memo: "Write here!"
save: "Save"
placeholder: "Write here"
common/views/widgets/slideshow.vue:
folder-customize-mode: "To specify a folder, please exit customization mode"
folder: "Please click and specify a folder"
Expand Down
3 changes: 1 addition & 2 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,7 @@ common/views/widgets/server.vue:

common/views/widgets/memo.vue:
title: "付箋"
memo: "ここに入力"
save: "保存"
placeholder: "ここに入力"

common/views/widgets/slideshow.vue:
folder-customize-mode: "フォルダを指定するには、カスタマイズモードを終了してください"
Expand Down
71 changes: 14 additions & 57 deletions src/client/app/common/views/widgets/memo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<div class="mkw-memo--body">
<textarea v-model="text" :placeholder="$t('placeholder')" @input="onChange"></textarea>
<button @click="saveMemo" :disabled="!changed">{{ $t('save') }}</button>
</div>
</ui-container>
</div>
Expand All @@ -18,44 +17,32 @@ import i18n from '../../../i18n';
export default define({
name: 'memo',
props: () => ({
compact: false
compact: false,
memo: ''
})
}).extend({
i18n: i18n('common/views/widgets/memo.vue'),
data() {
return {
text: null,
changed: false,
timeoutId: null
};
},
created() {
this.text = this.$store.state.settings.memo;
if (this.text === null) {
this.text = this.$store.state.settings.memo;
}
},
this.$watch('$store.state.settings.memo', text => {
this.text = text;
});
computed: {
text: {
get() { return this.props.memo; },
set(value: string) {
this.props.memo = value;
this.save();
}
}
},
methods: {
func() {
this.props.compact = !this.props.compact;
this.save();
},
onChange() {
this.changed = true;
clearTimeout(this.timeoutId);
this.timeoutId = setTimeout(this.saveMemo, 1000);
},
saveMemo() {
this.$store.dispatch('settings/set', {
key: 'memo',
value: this.text
});
this.changed = false;
}
}
});
Expand All @@ -64,8 +51,6 @@ export default define({
<style lang="stylus" scoped>
.mkw-memo
.mkw-memo--body
padding-bottom 28px + 16px
> textarea
display block
width 100%
Expand All @@ -77,32 +62,4 @@ export default define({
border none
border-bottom solid var(--lineWidth) var(--faceDivider)
border-radius 0
> button
display block
position absolute
bottom 8px
right 8px
margin 0
padding 0 10px
height 28px
color var(--primaryForeground)
background var(--primary) !important
outline none
border none
border-radius 4px
transition background 0.1s ease
cursor pointer
&:hover
background var(--primaryLighten10) !important
&:active
background var(--primaryDarken10) !important
transition background 0s ease
&:disabled
opacity 0.7
cursor default
</style>

0 comments on commit 63dfef9

Please sign in to comment.