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

index 23b8f72bd4f5c31f24334c0e4c657d16b434145a..d49eca7b8d9e362261ec892b127001df98e94705 100644 (file)
@@ -73,7 +73,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     public $timestamps = true;
 
     protected $_enableTrackNonDefaultValues = false;
-    protected $_enableTracEmptyValues = false;
+    protected $_enableTrackEmptyValues = false;
 
     protected static $_ownerAttribute = null;
 
@@ -1028,7 +1028,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         if ($this->_enableTrackNonDefaultValues) {
             $res[] = 'cubist_back::track-non-default-values';
         }
-        if ($this->_enableTracEmptyValues) {
+        if ($this->_enableTrackEmptyValues) {
             $res[] = 'cubist_back::track-empty-values';
         }
         return array_unique($res);
index 3db5934a44a188f3a7e83078161a2b11e6124d4f..9a771e0f8555c41663f19d86681b0bf284844542 100644 (file)
@@ -70,7 +70,7 @@ class Translate extends CubistMagicTranslatableModel
                 continue;
             }
             if (!is_numeric($sectionLabel)) {
-                if (!$sectionLabel || $sectionLabel=='0') {
+                if (!$sectionLabel || $sectionLabel == '0') {
                     $sectionLabel = '-';
                 }
                 $currentSection = $sectionLabel;
@@ -105,17 +105,19 @@ class Translate extends CubistMagicTranslatableModel
             }
         }
 
+        $i = 0;
         foreach ($sections as $section => $fields) {
             if (!count($fields)) {
                 continue;
             }
-            $this->addField($section, FormSection::class, $section);
+            $this->addField('s_s' . $i, FormSection::class, $section);
             foreach ($fields as $field) {
-                if(!$field){
+                if (!$field) {
                     continue;
                 }
                 $this->addField($field);
             }
+            $i++;
         }
     }
 
index 49ca580744c373070068db66054c7ce060f6f122..1e4305dd2dd9676c002c7cc6a023e3bae11e4f55 100644 (file)
@@ -1,7 +1,6 @@
 @push('crud_fields_scripts')
     <script type="text/javascript">
         jQuery('document').ready(function ($) {
-            alert(':)');
 
             $(document).on('change', 'select,input,textarea', function () {
                 $(this).addClass('live-change')
@@ -15,8 +14,8 @@
         });
 
         function markEmptyChangedFields() {
-            $('select,input,textarea').find(':not([data-empty-tracking="0"])').each(function () {
-                var v = '';
+            $('[data-name]:not([data-empty-tracking="0"])').each(function () {
+                var v='undefined';
                 $(this).find('[name="' + $(this).data('name') + '"]').each(function () {
                     v = $(this).val();
                 });
@@ -45,8 +44,8 @@
             });
 
             $("#form_shortcuts nav a").each(function () {
-                var hasNonDefault = $($(this).attr('href')).closest('.card').find('.empty').length > 0;
-                if (hasNonDefault) {
+                var hasEmpty = $($(this).attr('href')).closest('.card').find('.empty').length > 0;
+                if (hasEmpty) {
                     $(this).addClass('empty');
                 } else {
                     $(this).removeClass('empty');