BookStack/resources/js/components/ajax-delete-row.js
Dan Brown 209fa04752
Some checks failed
lint-js / build (push) Has been cancelled
test-js / build (push) Has been cancelled
TS: Converted dom and keyboard nav services
2024-10-11 21:55:51 +01:00

30 lines
815 B
JavaScript

import {onSelect} from '../services/dom.ts';
import {Component} from './component';
export class AjaxDeleteRow extends Component {
setup() {
this.row = this.$el;
this.url = this.$opts.url;
this.deleteButtons = this.$manyRefs.delete;
onSelect(this.deleteButtons, this.runDelete.bind(this));
}
runDelete() {
this.row.style.opacity = '0.7';
this.row.style.pointerEvents = 'none';
window.$http.delete(this.url).then(resp => {
if (typeof resp.data === 'object' && resp.data.message) {
window.$events.emit('success', resp.data.message);
}
this.row.remove();
}).catch(() => {
this.row.style.opacity = null;
this.row.style.pointerEvents = null;
});
}
}