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

32 lines
749 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2018-03-17 18:26:18 +05:30
import Autosave from '../../autosave';
2018-03-27 19:54:05 +05:30
import { capitalizeFirstCharacter } from '../../lib/utils/text_utility';
2019-07-31 22:56:46 +05:30
import { s__ } from '~/locale';
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
},
};