]> _ Git - cubist_cms-back.git/commitdiff
wip #5750 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 18:24:13 +0000 (19:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 18:24:13 +0000 (19:24 +0100)
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Magic/Models/Translate.php
src/resources/views/track-empty-values.blade.php [new file with mode: 0644]

index 3b395ebdb548edb643c7e68f8554bb7abe7e8b92..23b8f72bd4f5c31f24334c0e4c657d16b434145a 100644 (file)
@@ -73,6 +73,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     public $timestamps = true;
 
     protected $_enableTrackNonDefaultValues = false;
+    protected $_enableTracEmptyValues = false;
 
     protected static $_ownerAttribute = null;
 
@@ -217,7 +218,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return 'text';
     }
 
-    public function showPrimaryColumn(){
+    public function showPrimaryColumn()
+    {
         return true;
     }
 
@@ -1026,6 +1028,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         if ($this->_enableTrackNonDefaultValues) {
             $res[] = 'cubist_back::track-non-default-values';
         }
+        if ($this->_enableTracEmptyValues) {
+            $res[] = 'cubist_back::track-empty-values';
+        }
         return array_unique($res);
     }
 
index 66cf6cc98c2bc4212b96811b02faecc6a751ecf6..3db5934a44a188f3a7e83078161a2b11e6124d4f 100644 (file)
@@ -81,7 +81,7 @@ class Translate extends CubistMagicTranslatableModel
 
             foreach ($toTranslate as $string) {
                 if (str_starts_with($string, '!!')) {
-                    $currentSection = ltrim($string, '!');
+                    $currentSection = ltrim($string, '! ');
                     if (!isset($sections[$currentSection])) {
                         $sections[$currentSection] = [];
                     }
diff --git a/src/resources/views/track-empty-values.blade.php b/src/resources/views/track-empty-values.blade.php
new file mode 100644 (file)
index 0000000..49ca580
--- /dev/null
@@ -0,0 +1,106 @@
+@push('crud_fields_scripts')
+    <script type="text/javascript">
+        jQuery('document').ready(function ($) {
+            alert(':)');
+
+            $(document).on('change', 'select,input,textarea', function () {
+                $(this).addClass('live-change')
+                markEmptyChangedFields();
+            });
+
+            markEmptyChangedFields();
+            setTimeout(function () {
+                markEmptyChangedFields();
+            }, 1000);
+        });
+
+        function markEmptyChangedFields() {
+            $('select,input,textarea').find(':not([data-empty-tracking="0"])').each(function () {
+                var v = '';
+                $(this).find('[name="' + $(this).data('name') + '"]').each(function () {
+                    v = $(this).val();
+                });
+
+                if (v != '') {
+                    $(this).removeClass('empty');
+                } else {
+                    $(this).addClass('empty');
+                }
+            });
+
+            $('.dropzone').each(function () {
+                if ($(this).find('.dz-preview').length > 0) {
+                    $(this).closest('.form-group').addClass('empty');
+                } else {
+                    $(this).closest('.form-group').removeClass('empty');
+                }
+            });
+
+            $('.bunchmultiple__items').each(function () {
+                if ($(this).find('.item:not(.sample)').length > 0) {
+                    $(this).closest('.form-group').addClass('empty');
+                } else {
+                    $(this).closest('.form-group').removeClass('empty');
+                }
+            });
+
+            $("#form_shortcuts nav a").each(function () {
+                var hasNonDefault = $($(this).attr('href')).closest('.card').find('.empty').length > 0;
+                if (hasNonDefault) {
+                    $(this).addClass('empty');
+                } else {
+                    $(this).removeClass('empty');
+                }
+            });
+        }
+
+    </script>
+@endpush
+
+@push('crud_fields_styles')
+    <style type="text/css">
+        .empty, .live-change {
+            position: relative;
+        }
+
+        .empty::after, .live-change:after {
+            content: '';
+
+            position: absolute;
+            display: block;
+            background-color: crimson;
+            width: 3px;
+
+            left: -5px;
+            top: -8px;
+            bottom: -8px;
+        }
+
+        .empty .restoreNonDefault {
+            visibility: visible;
+        }
+
+
+        .bunchfields .empty::after, .bunchfields .live-change::after {
+            display: none;
+        }
+
+        .bunchmultiple__wrapper .empty::after, .bunchmultiple__wrapper .live-change::after {
+            left: -20px;
+        }
+
+        #form_shortcuts .empty::after {
+            left: -30px;
+            top: -0px;
+            bottom: -0px;
+        }
+
+        .empty.live-change:after {
+            background-color: darkorange;
+        }
+
+        .live-change:after {
+            background-color: darkgreen;
+        }
+    </style>
+@endpush