summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/mixins/autosave.js
blob: 36cc8d5d0562896dd9f67b58468f78f2ecec4333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import $ from 'jquery';
import Autosave from '../../autosave';
import { capitalizeFirstCharacter } from '../../lib/utils/text_utility';

export default {
  methods: {
    initAutoSave(noteable) {
      this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), [
        'Note',
        capitalizeFirstCharacter(noteable.noteable_type),
        noteable.id,
      ]);
    },
    resetAutoSave() {
      this.autosave.reset();
    },
    setAutoSave() {
      this.autosave.save();
    },
  },
};