fixed page asset reference paths for saving

switched to using sortjs method for collecting urls for assets
associated with page
This commit is contained in:
ro 2024-03-10 18:47:40 -06:00
parent 7024285b70
commit bd5f57b9ac
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
2 changed files with 18 additions and 28 deletions

View file

@ -64,23 +64,13 @@ export default class FileManager {
getFileOrder() { getFileOrder() {
let imgList = ''; let imgList = '';
let fileList = ''; let fileList = '';
//change file order this and chance data-source to data-id let mediaArray = this.mediaSort.toArray();
//console.log('ORDER', this.mediaSort.toArray()); let fileArray = this.fileSort.toArray();
for (var i = 0, length = this.imageList.childNodes.length; i < length; i++) { for (var i = 0, length = mediaArray.length; i < length; i++) {
try { imgList = imgList + mediaArray[i] + ',';
let div = this.imageList.childNodes[i];
imgList = imgList + div.getAttribute('data-source') + ',';
} catch (e) {
//something is function
}
} }
for (var i = 0, length = this.fileList.childNodes.length; i < length; i++) { for (var i = 0, length = fileArray.length; i < length; i++) {
try { fileList = fileList + fileArray[i] + ',';
let div = this.fileList.childNodes[i];
fileList = fileList + div.getAttribute('data-source') + ',';
} catch (e) {
//something is function
}
} }
let media = { images: imgList, files: fileList }; let media = { images: imgList, files: fileList };
return media; return media;

View file

@ -50,7 +50,7 @@
@if(count($media)>1) @if(count($media)>1)
@foreach($media as $item) @foreach($media as $item)
@if($item['type'] == "mp4") @if($item['type'] == "mp4")
<div id="{{ $loop->index }}" class="video-item" data-source="{{ $item['file'] }}"> <div id="{{ $loop->index }}" class="video-item" data-id="{{ $item['file'] }}">
<video> <video>
<source src="{{ $item['file'] }}"/> <source src="{{ $item['file'] }}"/>
</video> </video>
@ -59,7 +59,7 @@
</button> </button>
</div> </div>
@else @else
<div id="{{ $loop->index }}" class="img-item" data-source="{{ $item['file'] }}" style="background: url({{ $item['file'] }}) no-repeat center center / cover"> <div id="{{ $loop->index }}" class="img-item" data-id="{{ $item['file'] }}" style="background: url({{ $item['file'] }}) no-repeat center center / cover">
<button id="{{ $loop->index }}" class="media-remove"> <button id="{{ $loop->index }}" class="media-remove">
<i class="ti ti-x"></i> <i class="ti ti-x"></i>
</button> </button>
@ -67,14 +67,14 @@
@endif @endif
@endforeach @endforeach
@else @else
@if(media[0] != '') @if($media[0] != '')
@if(media[0]['type'] == "mp4") @if($media[0]['type'] == "mp4")
<div id="0" class="video-item" data-source="{{ media[0]['file'] }}"> <div id="0" class="video-item" data-id="{{ $media[0]['file'] }}">
<button id="{{ $loop->index }}" class="media-remove">X</button> <button id="0" class="media-remove">X</button>
</div> </div>
@else @else
<div id="0" class="img-item" data-source="{{ media[0]['file'] }}" style="background: url({{ media[0]['file'] }}) no-repeat center center / cover"> <div id="0" class="img-item" data-id="{{ $media[0]['file'] }}" style="background: url({{ $media[0]['file'] }}) no-repeat center center / cover">
<button id="{{ $loop->index }}" class="media-remove"> <button id="0" class="media-remove">
<i class="ti ti-x"></i> <i class="ti ti-x"></i>
</button> </button>
</div> </div>
@ -90,7 +90,7 @@
$fileName = explode("/", $item['file']); $fileName = explode("/", $item['file']);
@endphp @endphp
@if($item['type'] == "mp3") @if($item['type'] == "mp3")
<div id="{{ $loop->index }}" class="audio-item" data-source="{{ $item['file'] }}"> <div id="{{ $loop->index }}" class="audio-item" data-id="{{ $item['file'] }}">
<audio controls> <audio controls>
<source src="{{ $item['file'] }}"/> <source src="{{ $item['file'] }}"/>
</audio> </audio>
@ -99,7 +99,7 @@
</button> </button>
</div> </div>
@else @else
<div id="{{ $loop->index }}" class="file-item" data-source="{{ $item['file'] }}"> <div id="{{ $loop->index }}" class="file-item" data-id="{{ $item['file'] }}">
<a href="{{ $item['file'] }}" target="_blank">{{ $fileName[6] }}"</a> <a href="{{ $item['file'] }}" target="_blank">{{ $fileName[6] }}"</a>
<button id="{{ $loop->index }}" class="media-remove"> <button id="{{ $loop->index }}" class="media-remove">
<i class="ti ti-x"></i> <i class="ti ti-x"></i>
@ -113,7 +113,7 @@
$fileName = explode("/", $item['file']); $fileName = explode("/", $item['file']);
@endphp @endphp
@if($files[0]['type'] == "mp3") @if($files[0]['type'] == "mp3")
<div id="0" class="audio-item" data-source="{{ $files[0]['file'] }}"> <div id="0" class="audio-item" data-id="{{ $files[0]['file'] }}">
<audio controls> <audio controls>
<source src="{{ $files[0]['file'] }}"/> <source src="{{ $files[0]['file'] }}"/>
</audio> </audio>
@ -122,7 +122,7 @@
</button> </button>
</div> </div>
@else @else
<div id="0" class="file-item" data-source="{{ $files[0]['file'] }}"> <div id="0" class="file-item" data-id="{{ $files[0]['file'] }}">
<a href="{{ $item['file'] }}" target="_blank">{{ $fileName[6] }}"</a> <a href="{{ $item['file'] }}" target="_blank">{{ $fileName[6] }}"</a>
<button id="{{ $loop->index }}" class="media-remove"> <button id="{{ $loop->index }}" class="media-remove">
<i class="ti ti-x"></i> <i class="ti ti-x"></i>