From: Vincent Vanwaelscappel Date: Mon, 30 Mar 2020 18:35:53 +0000 (+0200) Subject: wip #3531 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=0c5d3e6d56e462aa10a39588f9d1700def0e50f3;p=cubist_cms-back.git wip #3531 @2 --- diff --git a/composer.json b/composer.json index 25f53a0..741a7db 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": ">=7.3.0", + "php": ">=7.4", "ext-dom": "*", "ext-libxml": "*", "ext-json": "*", diff --git a/src/app/Console/Commands/MigrateCommand.php b/src/app/Console/Commands/MigrateCommand.php index 1d1469d..5ccd8c7 100644 --- a/src/app/Console/Commands/MigrateCommand.php +++ b/src/app/Console/Commands/MigrateCommand.php @@ -6,6 +6,8 @@ use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; +use Illuminate\Support\Str; +use Spatie\MediaLibrary\MediaCollections\Models\Media; class MigrateCommand extends CubistMagicCommand { @@ -59,6 +61,10 @@ class MigrateCommand extends CubistMagicCommand foreach ($queries as $q) { $connection->exec($q); } + + Media::whereNull('uuid')->cursor()->each( + fn(Media $media) => $media->update(['uuid' => Str::uuid()]) + ); } /** diff --git a/src/public/bunchmultiple/bunchmultiple.js b/src/public/bunchmultiple/bunchmultiple.js index ce87b9c..bffcb84 100644 --- a/src/public/bunchmultiple/bunchmultiple.js +++ b/src/public/bunchmultiple/bunchmultiple.js @@ -10,6 +10,8 @@ this.id = $(this.element).attr('id'); this.bmidselector = '[data-bmid="' + this.id + '"]'; + this.cleanTemplate(); + var initValues = this.element.data('values'); $.each(initValues, function (k, v) { $this.initItem(v); @@ -69,6 +71,10 @@ } }, + cleanTemplate: function () { + this.element.find('.sample' + this.bmidselector).find('[data-init-function]').removeAttr('data-init-function'); + }, + update: function () { this.serialize(); this.updateLegends(); @@ -79,6 +85,11 @@ var $this = this; var id = this.element.attr('id'); $.each(this.element.find('.item' + this.bmidselector + ':not(.sample) .subform' + this.bmidselector), function () { + + $(this).find('.bunchmultiple').each(function () { + $(this).data('bunchmultiple').serialize(); + }); + var data = $(this).find(':input' + $this.bmidselector).serializeArray(); var filteredData = {}; $.each(data, function (k, v) { @@ -160,6 +171,7 @@ $(this.element).find(".bunchmultiple__items" + this.bmidselector).append($(item)); this.setValues(item, values); + $(item).find('.subform>.bunchmultiple').bunchmultiple(); $(item).find('.form-group').find('input, select, .dropzone, textarea').each(function () { @@ -169,9 +181,11 @@ $(this).attr('data-bmid', $this.id); }); - - $(document).trigger('cubist.bunchmultiple.added'); - $(this).trigger('change'); + setTimeout(function () { + $this.setValues(item, values); + $(document).trigger('cubist.bunchmultiple.added'); + $($this).trigger('change'); + }, 500); }, setValues(item, values) { @@ -181,14 +195,16 @@ var input = $(item).find('[name="' + id + '___' + k + '"]'); if (input.is('.hiddenfield')) { $(input).parent().attr('data-values', JSON.stringify(v)); - } else if (input.filter('[type="checkbox"]').length > 0) { - input.filter('[type="checkbox"]').prop('checked', v === '1'); + } else if ($(input).nextAll('[type="checkbox"]').length > 0) { + var cb = $(input).nextAll('[type="checkbox"]'); + cb.attr('name', cb.prev('[type="hidden"]').attr('name')).attr('value', '1'); + cb.prop('checked', v === true || v === '1' || v === 1); } else { input.val(v); } }); } catch (e) { - + console.log(e); } this.updateLegends(); }, diff --git a/src/resources/views/fields/dropzone_media.blade.php b/src/resources/views/fields/dropzone_media.blade.php index 8ff0d0b..2283b85 100644 --- a/src/resources/views/fields/dropzone_media.blade.php +++ b/src/resources/views/fields/dropzone_media.blade.php @@ -170,7 +170,7 @@ $collection = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? } try { - $thumb_url = $media->getUrl($field['thumb_collection'] ?? ''); + $thumb_url = $media->getUrl($field['thumb_collection'] ?? null); } catch (Exception $e) { $thumb_url = ''; }