mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-10 13:43:38 +08:00
Attachments: Hid edit/delete controls where lacking permission
Some checks failed
analyse-php / build (push) Waiting to run
lint-php / build (push) Waiting to run
test-migrations / build (8.1) (push) Waiting to run
test-migrations / build (8.2) (push) Waiting to run
test-migrations / build (8.3) (push) Waiting to run
test-migrations / build (8.4) (push) Waiting to run
test-php / build (8.1) (push) Waiting to run
test-php / build (8.2) (push) Waiting to run
test-php / build (8.3) (push) Waiting to run
test-php / build (8.4) (push) Waiting to run
lint-js / build (push) Has been cancelled
test-js / build (push) Has been cancelled
Some checks failed
analyse-php / build (push) Waiting to run
lint-php / build (push) Waiting to run
test-migrations / build (8.1) (push) Waiting to run
test-migrations / build (8.2) (push) Waiting to run
test-migrations / build (8.3) (push) Waiting to run
test-migrations / build (8.4) (push) Waiting to run
test-php / build (8.1) (push) Waiting to run
test-php / build (8.2) (push) Waiting to run
test-php / build (8.3) (push) Waiting to run
test-php / build (8.4) (push) Waiting to run
lint-js / build (push) Has been cancelled
test-js / build (push) Has been cancelled
Added test to cover. Also migrated related ajax-delete-row component to ts. For #5323
This commit is contained in:
33
resources/js/components/ajax-delete-row.ts
Normal file
33
resources/js/components/ajax-delete-row.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import {onSelect} from '../services/dom';
|
||||
import {Component} from './component';
|
||||
|
||||
export class AjaxDeleteRow extends Component {
|
||||
|
||||
protected row!: HTMLElement;
|
||||
protected url!: string;
|
||||
protected deleteButtons: HTMLElement[] = [];
|
||||
|
||||
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.removeProperty('opacity');
|
||||
this.row.style.removeProperty('pointer-events');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user