mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed error, when creation of new elements is disabled in collectionTypes.
This for example happens if the user does not have the permission to create new elements.
This commit is contained in:
parent
7dfbb4c536
commit
b51aa0951e
2 changed files with 17 additions and 4 deletions
|
@ -38,6 +38,13 @@ export default class extends Controller {
|
|||
const targetTable = this.targetTarget;
|
||||
const prototype = this.prototypeValue
|
||||
|
||||
if(!prototype) {
|
||||
console.warn("Prototype is not set, we cannot create a new element. This is most likely due to missing permissions.");
|
||||
bootbox.alert("You do not have the permsissions to create a new element. (No protoype element is set)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Apply the index to prototype to create our element to insert
|
||||
const newElementStr = this.htmlDecode(prototype.replace(/__name__/g, this.generateUID()));
|
||||
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
{% macro controller(form, deleteMessage) %}
|
||||
{{ stimulus_controller('elements/collection_type', {
|
||||
'deleteMessage': deleteMessage|trans,
|
||||
'prototype': form_widget(form.vars.prototype)|e('html_attr')
|
||||
}) }}
|
||||
{% if form.vars.prototype is defined %}
|
||||
{{ stimulus_controller('elements/collection_type', {
|
||||
'deleteMessage': deleteMessage|trans,
|
||||
'prototype': form_widget(form.vars.prototype)|e('html_attr')
|
||||
}) }}
|
||||
{% else %} {# If add_element is disabled/forbidden, prototype is not available #}
|
||||
{{ stimulus_controller('elements/collection_type', {
|
||||
'deleteMessage': deleteMessage|trans,
|
||||
}) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro target() %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue