mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Attachments: Hid edit/delete controls where lacking permission
Added test to cover. Also migrated related ajax-delete-row component to ts. For #5323
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
import {onSelect} from '../services/dom.ts';
|
||||
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;
|
||||
this.deleteButtons = this.$manyRefs.delete || [];
|
||||
|
||||
onSelect(this.deleteButtons, this.runDelete.bind(this));
|
||||
}
|
||||
@ -21,8 +25,8 @@ export class AjaxDeleteRow extends Component {
|
||||
}
|
||||
this.row.remove();
|
||||
}).catch(() => {
|
||||
this.row.style.opacity = null;
|
||||
this.row.style.pointerEvents = null;
|
||||
this.row.style.removeProperty('opacity');
|
||||
this.row.style.removeProperty('pointer-events');
|
||||
});
|
||||
}
|
||||
|
@ -8,20 +8,20 @@ export class Component {
|
||||
|
||||
/**
|
||||
* The element that the component is registered upon.
|
||||
* @type {Element}
|
||||
* @type {HTMLElement}
|
||||
*/
|
||||
$el = null;
|
||||
|
||||
/**
|
||||
* Mapping of referenced elements within the component.
|
||||
* @type {Object<string, Element>}
|
||||
* @type {Object<string, HTMLElement>}
|
||||
*/
|
||||
$refs = {};
|
||||
|
||||
/**
|
||||
* Mapping of arrays of referenced elements within the component so multiple
|
||||
* references, sharing the same name, can be fetched.
|
||||
* @type {Object<string, Element[]>}
|
||||
* @type {Object<string, HTMLElement[]>}
|
||||
*/
|
||||
$manyRefs = {};
|
||||
|
||||
|
Reference in New Issue
Block a user