debian-mirror-gitlab/app/assets/javascripts/notes/mixins/autosave.js

32 lines
741 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2021-03-11 19:13:27 +05:30
import { s__ } from '~/locale';
2022-06-21 17:19:12 +05:30
import Autosave from '~/autosave';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
2018-03-17 18:26:18 +05:30
export default {
methods: {
2018-11-18 11:00:15 +05:30
initAutoSave(noteable, extraKeys = []) {
let keys = [
2019-07-31 22:56:46 +05:30
s__('Autosave|Note'),
2018-11-18 11:00:15 +05:30
capitalizeFirstCharacter(noteable.noteable_type || noteable.noteableType),
2018-11-08 19:23:39 +05:30
noteable.id,
2018-11-18 11:00:15 +05:30
];
if (extraKeys) {
keys = keys.concat(extraKeys);
}
this.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), keys);
2018-03-17 18:26:18 +05:30
},
resetAutoSave() {
this.autosave.reset();
},
setAutoSave() {
this.autosave.save();
},
2018-11-18 11:00:15 +05:30
disposeAutoSave() {
this.autosave.dispose();
},
2018-03-17 18:26:18 +05:30
},
};