1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-24 07:42:07 +03:00
Files
.github
app
bootstrap
database
dev
lang
public
resources
icons
js
code
components
add-remove-rows.js
ajax-delete-row.ts
ajax-form.js
attachments-list.js
attachments.js
auto-submit.js
auto-suggest.js
back-to-top.js
book-sort.js
chapter-contents.js
code-editor.js
code-highlighter.js
code-textarea.js
collapsible.js
component.js
confirm-dialog.js
custom-checkbox.js
details-highlighter.js
dropdown-search.js
dropdown.js
dropzone.js
editor-toolbox.js
entity-permissions.js
entity-search.js
entity-selector-popup.js
entity-selector.js
event-emit-select.js
expand-toggle.js
global-search.js
header-mobile-toggle.js
image-manager.js
image-picker.js
index.ts
list-sort-control.js
loading-button.ts
markdown-editor.js
new-user-password.js
notification.js
optional-input.js
page-comment-reference.ts
page-comment.ts
page-comments.ts
page-display.js
page-editor.js
page-picker.js
permissions-table.js
pointer.ts
popup.js
setting-app-color-scheme.js
setting-color-picker.js
setting-homepage-control.js
shelf-sort.js
shortcut-input.js
shortcuts.js
sort-rule-manager.ts
sortable-list.js
submit-on-change.js
tabs.ts
tag-manager.js
template-manager.js
toggle-switch.js
tri-layout.js
user-select.js
webhook-events.js
wysiwyg-editor-tinymce.js
wysiwyg-editor.js
wysiwyg-input.js
markdown
services
wysiwyg
wysiwyg-tinymce
app.ts
custom.d.ts
global.d.ts
sass
views
routes
storage
tests
themes
.env.example
.env.example.complete
.gitattributes
.gitignore
LICENSE
artisan
bookstack-system-cli
composer.json
composer.lock
crowdin.yml
docker-compose.yml
eslint.config.mjs
jest.config.ts
package-lock.json
package.json
phpcs.xml
phpstan.neon.dist
phpunit.xml
readme.md
tsconfig.json
version
bookstack/resources/js/components/ajax-delete-row.ts
Dan Brown fcf0bf79a9 Attachments: Hid edit/delete controls where lacking permission
Added test to cover.
Also migrated related ajax-delete-row component to ts.

For 
2024-12-11 20:38:30 +00:00

34 lines
952 B
TypeScript

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');
});
}
}