Author: sevein
Date: Fri Sep 16 21:50:22 2011
New Revision: 9753

Log:
Render restriction as a boolean, needs some fixes and be shown as a dropdown

Modified:
   trunk/apps/qubit/modules/right/actions/editComponent.class.php
   trunk/apps/qubit/modules/right/actions/indexAction.class.php
   trunk/apps/qubit/modules/right/templates/_edit.php
   trunk/apps/qubit/modules/right/templates/_right.php

Modified: trunk/apps/qubit/modules/right/actions/editComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/right/actions/editComponent.class.php      Fri Sep 
16 21:35:02 2011        (r9752)
+++ trunk/apps/qubit/modules/right/actions/editComponent.class.php      Fri Sep 
16 21:50:22 2011        (r9753)
@@ -61,6 +61,13 @@
 
         break;
 
+      case 'restriction':
+        $this->form->setDefault('restriction', true);
+        $this->form->setValidator('restriction', new sfValidatorBoolean);
+        $this->form->setWidget('restriction', new sfWidgetFormInputCheckbox);
+
+        break;
+
       case 'statuteDeterminationDate':
       case 'copyrightStatusDate':
         $this->form->setValidator($name, new sfValidatorString);
@@ -131,7 +138,6 @@
 
       case 'licenseIdentifier':
       case 'licenseTerms':
-      case 'restriction':
         $this->form->setValidator($name, new sfValidatorString);
         $this->form->setWidget($name, new sfWidgetFormInput);
 

Modified: trunk/apps/qubit/modules/right/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/right/actions/indexAction.class.php        Fri Sep 
16 21:35:02 2011        (r9752)
+++ trunk/apps/qubit/modules/right/actions/indexAction.class.php        Fri Sep 
16 21:50:22 2011        (r9753)
@@ -30,16 +30,12 @@
       $value['act'] = $this->context->routing->generate(null, 
array($this->resource->act, 'module' => 'term'));
     }
 
-    if (isset($this->resource->restriction))
-    {
-      $value['restriction'] = $this->resource->restriction;
-    }
+    $value['restriction'] = (boolean) $this->resource->restriction;
 
     $value['startDate'] = Qubit::renderDate($this->resource->startDate);
 
     $value['endDate'] = Qubit::renderDate($this->resource->endDate);
 
- 
     if (isset($this->resource->rightsHolder))
     {
       $value['rightsHolder'] = $this->context->routing->generate(null, 
array($this->resource->rightsHolder, 'module' => 'rightsholder'));

Modified: trunk/apps/qubit/modules/right/templates/_edit.php
==============================================================================
--- trunk/apps/qubit/modules/right/templates/_edit.php  Fri Sep 16 21:35:02 
2011        (r9752)
+++ trunk/apps/qubit/modules/right/templates/_edit.php  Fri Sep 16 21:50:22 
2011        (r9753)
@@ -22,6 +22,8 @@
         <th>
           <?php echo __('Act') ?>
         </th><th>
+          <?php echo __('Restriction') ?>
+        </th><th>
           <?php echo __('Start') ?>
         </th><th>
           <?php echo __('End') ?>
@@ -35,6 +37,8 @@
           <td>
             <?php echo $item->object->act ?>
           </td><td>
+            <?php echo $item->object->restriction ? __('Allow') : 
__('Disallow') ?>
+          </td><td>
             <?php echo Qubit::renderDate($item->object->startDate) ?>
           </td><td>
             <?php echo Qubit::renderDate($item->object->endDate) ?>
@@ -56,6 +60,8 @@
   <td>
     {{$form->act->renderName()}}
   </td><td>
+    {{$form->restriction->renderName()}}
+  </td><td>
     {{$form->startDate->renderName()}}
   </td><td>
     {{$form->endDate->renderName()}}
@@ -88,11 +94,23 @@
 Drupal.behaviors.rights$suffix = {
   attach: function (context)
     {
+      // Add special rendering rules
+      var handleFieldRender = function (fname)
+        {
+          if (-1 !== fname.indexOf('restriction'))
+          { alert(this.getField(fname).value);
+            return this.getField(fname).value ? 'Allow' : 'Disallow';
+          }
+
+          return this.renderField(fname);
+        }
+
       // Define dialog
       var dialog = new QubitDialog('updateRights$suffix', {
         'displayTable': 'rightsDisplay$suffix',
         'newRowTemplate': $rowTemplate,
         'height': '400px',
+        'handleFieldRender': handleFieldRender,
         'showEvent': function()
           {
             this.body.scrollTop = 0;

Modified: trunk/apps/qubit/modules/right/templates/_right.php
==============================================================================
--- trunk/apps/qubit/modules/right/templates/_right.php Fri Sep 16 21:35:02 
2011        (r9752)
+++ trunk/apps/qubit/modules/right/templates/_right.php Fri Sep 16 21:50:22 
2011        (r9753)
@@ -8,7 +8,7 @@
 
     <?php echo render_show(__('Act'), render_value($resource->act)) ?>
 
-    <?php echo render_show(__('Restriction'), 
render_value($resource->getRestriction(array('cultureFallback' => true)))) ?>
+    <?php echo render_show(__('Restriction'), 
render_value($resource->restriction ? __('Allow') : __('Disallow'))) ?>
 
     <?php echo render_show(__('Start date'), 
render_value(Qubit::renderDate($resource->startDate))) ?>
 

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" 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/qubit-commits?hl=en.

Reply via email to