2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkContainer :show-header="props.showHeader">
|
2020-12-26 03:47:36 +02:00
|
|
|
<template #header><Fa :icon="faStickyNote"/>{{ $ts._widgets.memo }}</template>
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
<div class="otgbylcu">
|
2020-12-26 03:47:36 +02:00
|
|
|
<textarea v-model="text" :placeholder="$ts.placeholder" @input="onChange"></textarea>
|
|
|
|
<button @click="saveMemo" :disabled="!changed" class="_buttonPrimary">{{ $ts.save }}</button>
|
2020-07-11 04:13:11 +03:00
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkContainer>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 21:37:25 +02:00
|
|
|
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 10:30:14 +02:00
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
2020-01-29 21:37:25 +02:00
|
|
|
import define from './define';
|
2021-03-23 10:30:14 +02:00
|
|
|
import * as os from '@client/os';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const widget = define({
|
2020-01-29 21:37:25 +02:00
|
|
|
name: 'memo',
|
|
|
|
props: () => ({
|
2020-07-11 04:13:11 +03:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
})
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
|
|
|
MkContainer
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: null,
|
|
|
|
changed: false,
|
|
|
|
timeoutId: null,
|
|
|
|
faStickyNote
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.text = this.$store.state.memo;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-12-19 03:55:52 +02:00
|
|
|
this.$watch(() => this.$store.reactiveState.memo, text => {
|
2020-01-29 21:37:25 +02:00
|
|
|
this.text = text;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onChange() {
|
|
|
|
this.changed = true;
|
|
|
|
clearTimeout(this.timeoutId);
|
|
|
|
this.timeoutId = setTimeout(this.saveMemo, 1000);
|
|
|
|
},
|
|
|
|
|
|
|
|
saveMemo() {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.$store.set('memo', this.text);
|
2020-01-29 21:37:25 +02:00
|
|
|
this.changed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.otgbylcu {
|
|
|
|
padding-bottom: 28px + 16px;
|
|
|
|
|
|
|
|
> textarea {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
min-width: 100%;
|
|
|
|
padding: 16px;
|
2021-02-06 14:36:47 +02:00
|
|
|
color: var(--fg);
|
|
|
|
background: transparent;
|
2020-01-29 21:37:25 +02:00
|
|
|
border: none;
|
2021-04-10 06:40:50 +03:00
|
|
|
border-bottom: solid 0.5px var(--divider);
|
2020-01-29 21:37:25 +02:00
|
|
|
border-radius: 0;
|
2020-03-29 05:06:58 +03:00
|
|
|
box-sizing: border-box;
|
2021-02-06 14:36:47 +02:00
|
|
|
font: inherit;
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 8px;
|
|
|
|
right: 8px;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0 10px;
|
|
|
|
height: 28px;
|
|
|
|
outline: none;
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
opacity: 0.7;
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|