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