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