Author: Jonathan.Wage
Date: 2010-01-30 09:14:08 +0100 (Sat, 30 Jan 2010)
New Revision: 27322

Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/css/editor.css
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js
   plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
Log:
[1.4][sfSympalPlugin][1.0] Enhancing content slot validation ui!


Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
    2010-01-30 07:05:38 UTC (rev 27321)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
    2010-01-30 08:14:08 UTC (rev 27322)
@@ -30,7 +30,7 @@
   {
     $this->contentSlots = array();
     $this->failedContentSlots = array();
-    $errors = array();
+    $this->errors = array();
 
     $content = 
Doctrine_Core::getTable('sfSympalContent')->find($request->getParameter('content_id'));
     $slotIds = $request->getParameter('slots');
@@ -55,20 +55,10 @@
         {
           if ($field->hasError())
           {
-            $errors[$contentSlot->getName()] = $field->getError();
+            $this->errors[$contentSlot->getName()] = $field->getError();
           }
         }
       }
     }
-
-    $this->errorString = null;
-    if ($errors)
-    {
-      $this->errorString = count($errors).' error'.(count($errors) > 1 ? 's' : 
null).' occurred:\n\n';
-      foreach ($errors as $name => $error)
-      {
-        $this->errorString .= ' * '.$name.': '.$error.'\n';
-      }
-    }
   }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
      2010-01-30 07:05:38 UTC (rev 27321)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
      2010-01-30 08:14:08 UTC (rev 27322)
@@ -10,7 +10,22 @@
   $('#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor input, 
#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor 
textarea').css('border', '1px solid #ccc');
 <?php endforeach; ?>
 
-<?php /* Output the error string if errors occurred */ ?>
-<?php if ($errorString): ?>
-  alert('<?php echo $errorString ?>');
+<?php /* Output the errors if errors occurred */ ?>
+<?php if (count($errors)): ?>
+  <!--- !Errors! ---> 
+
+  <?php
+  $errorString  = '<h2>'.count($errors).' Error'.(count($errors) > 1 ? 's' : 
null).' Occurred</h2>';
+  $errorString .= '<ul>';
+  foreach ($failedContentSlots as $slot)
+  {
+    $error = $errors[$slot->getName()];
+    $errorString .= '<li rel="'.$slot->getId().'" 
class="sympal_content_slot_error">'.__($slot->getName()).': 
'.__($error).'</li>';
+  }
+  $errorString .= '</ul>';
+  $errorString .= '<a id="close">'.__('Close').'</a>'
+  ?>
+  $('#sympal_slot_errors').html('<?php echo $errorString ?>');
+  $('#sympal_slot_errors').slideDown();
+  $('#sympal_slot_errors_icon').show();
 <?php endif; ?>
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-30 07:05:38 UTC (rev 27321)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-30 08:14:08 UTC (rev 27322)
@@ -80,4 +80,6 @@
 
 <div id="sympal_assets"></div>
 <div id="sympal_links"></div>
-<div id="sympal_dashboard"></div>
\ No newline at end of file
+<div id="sympal_dashboard"></div>
+<div id="sympal_slot_errors"></div>
+<div id="sympal_slot_errors_icon"></div>
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/css/editor.css
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/css/editor.css
    2010-01-30 07:05:38 UTC (rev 27321)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/css/editor.css
    2010-01-30 08:14:08 UTC (rev 27322)
@@ -372,4 +372,39 @@
 
 #sympal_ask_confirmation p {
   margin-bottom: 10px;
+}
+
+#sympal_slot_errors {
+  position: fixed;
+  top: 30px;
+  width: 100%;
+  display: none;
+  padding: 10px;
+  background: #ffc;
+  border-bottom: 1px solid #ccc;
+}
+
+.sympal_content_slot_error {
+  font-weight: bold;
+  cursor: pointer;
+}
+
+#sympal_slot_errors #close {
+  border: 1px solid #ccc;
+  background: #ffc;
+  padding: 3px 3px 3px 23px;
+  background: #fff 3px 3px url(../../sfSympalPlugin/images/cancel.png) 
no-repeat;
+  cursor: pointer;
+}
+
+#sympal_slot_errors_icon {
+  background: url(../../sfSympalPlugin/images/error.png) no-repeat;
+  position: fixed;
+  top: 8px;
+  left: 30px;
+  z-index: 9999999;
+  width: 20px;
+  height: 20px;
+  cursor: pointer;
+  display: none;
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js  
    2010-01-30 07:05:38 UTC (rev 27321)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js  
    2010-01-30 08:14:08 UTC (rev 27322)
@@ -94,6 +94,19 @@
     sympalCloseAllDropdowns();
   });
 
+  $('.sympal_content_slot_error').live('mouseover', function () {
+    sympalHighlightContentSlot($(this).attr('rel'));
+  });
+
+  $('#sympal_slot_errors #close').live('click', function() {
+    $('#sympal_slot_errors_icon').show();
+    $('#sympal_slot_errors').slideToggle();
+  });
+  
+  $('#sympal_slot_errors_icon').live('click', function() {
+    $('#sympal_slot_errors').slideToggle();
+  });
+
   // Setup the sympal dropdown menu panels (assets and links)
   sympalSetupDropdownMenus();
 });
@@ -133,10 +146,12 @@
   var url = $('#sympal_save_slots_url').attr('value');
   url = preview ? url + '?preview=1' : url;
   $.post(url, queryString, function(response) {
-    // If response doesn't contain an alert( then we know no errors occurred
+    // If response doesn't contain !Errors! then we know no errors occurred
     // so we can disable edit mode
-    if (response.indexOf('alert(') == -1)
+    if (response.indexOf('!Errors!') == -1)
     {
+      $('#sympal_slot_errors').html('');
+
       sympalDisableEditMode();
     }
 
@@ -144,6 +159,11 @@
   });
 }
 
+function sympalHighlightContentSlot(id)
+{
+  $('#sympal_content_slot_' + id + ' input, #sympal_content_slot_' + id + ' 
textarea').focus();
+}
+
 function sympalDisableEditMode()
 {
   $('.toggle_edit_mode').show();
@@ -151,6 +171,9 @@
   $('.sympal_inline_edit_bar_buttons').hide();
   $('.sympal_content_slot .editor').hide();
 
+  $('#sympal_slot_errors').slideUp();
+  $('#sympal_slot_errors_icon').hide();
+
   $.cookie('sympal_inline_edit_mode', 'false');
   sympalCloseAllDropdowns();
 }
@@ -162,6 +185,12 @@
   $('.sympal_inline_edit_bar_buttons').show();
   $('.sympal_content_slot .editor').show();
 
+  if ($('#sympal_slot_errors').html())
+  {
+    $('#sympal_slot_errors_icon').show();
+    $('#sympal_slot_errors').slideDown();
+  }
+
   $.cookie('sympal_inline_edit_mode', 'true');
 }
 

Modified: plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-01-30 07:05:38 UTC (rev 27321)
+++ plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-01-30 08:14:08 UTC (rev 27322)
@@ -136,6 +136,7 @@
 
     $validatorClass = isset($options['validator_class']) ? 
$options['validator_class'] : 'sfValidatorFormSympal'.$type;
     $validatorOptions = isset($options['validator_options']) ? 
$options['validator_options'] : array();
+    $validatorOptions['required'] = false;
 
     $widgetSchema['value'] = new $widgetClass($widgetOptions);
     $validatorSchema['value'] = new $validatorClass($validatorOptions);

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to