Skip to content

Commit

Permalink
refs #2867 Disabled drag&drop input for Attach field
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Aug 29, 2024
1 parent 8a786ba commit cc8ec4c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
9 changes: 5 additions & 4 deletions public/css/orchid.rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/orchid.rtl.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/vendor.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion resources/js/controllers/attach_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export default class extends ApplicationController {
this.togglePlaceholderShow();

new Sortable(this.element.querySelector('.sortable-dropzone'), {
disabled: this.filesTarget.disabled === true || this.filesTarget.readonly === true,
filter: ".attach-file-uploader",
draggable:'.pip',
animation: 150,
onEnd: () => {
this.reorderElements();
Expand Down Expand Up @@ -155,7 +158,7 @@ export default class extends ApplicationController {
*/
togglePlaceholderShow() {
this.containerTarget.classList.toggle('d-none', this.attachmentValue.length >= this.countValue);
this.filesTarget.disabled = this.attachmentValue.length > 0;
this.filesTarget.disabled = this.attachmentValue.length >= this.countValue;


// Disable the nullable field if there is at least one valid value and the count equals 1.
Expand Down
4 changes: 2 additions & 2 deletions resources/views/fields/attach.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class="attach"
"
>
<div data-target="attach.preview" class="row row-cols-4 row-cols-lg-6 gy-3 sortable-dropzone">
<div class="col order-last" data-attach-target="container">
<div class="col order-last attach-file-uploader" data-attach-target="container">
<label for="{{$id}}" class="border rounded bg-light attach-image-placeholder pointer-event h-100">
<input class="form-control d-none"
type="file"
Expand All @@ -50,7 +50,7 @@ class="attach"
</div>


<template data-target="attach.template">
<template data-attach-target="template">
<div class="pip col position-relative">
<input type="hidden" name="{name}" value="{id}">

Expand Down

0 comments on commit cc8ec4c

Please sign in to comment.