Explorar o código

Ahora se muestran todas las acciones de los workflow agrupadas

Cambio delete por erase
Your Name %!s(int64=7) %!d(string=hai) anos
pai
achega
447b8ceb86
Modificáronse 2 ficheiros con 31 adicións e 15 borrados
  1. 27 14
      Admin/WorkflowBaseAdmin.php
  2. 4 1
      Resources/translations/WorkflowLabel.es.yml

+ 27 - 14
Admin/WorkflowBaseAdmin.php

@@ -13,6 +13,12 @@ class WorkflowBaseAdmin extends BaseAdmin
     public function getBatchActions()
     {
         $actions = parent::getBatchActions();
+        $tmp = $actions;
+        $actions = [];
+        $actions['Default'] = array(
+            'label' => $this->trans('Default', array(), 'WorkflowLabel'),
+            'group' => $tmp
+        );
 
         $workflows = array();
         $registry = $this->get('workflow.registry');
@@ -25,24 +31,30 @@ class WorkflowBaseAdmin extends BaseAdmin
                 $workflows[] = $registry->get($tmpEntity);
             }
         } catch (\Exception $ex) {
-            // No hay workflows en db, pruebo traer desde el workflow registry 
+        }
+
+        if (isset($this->batchWorkflows)) {
+            // No hay workflows en db, pruebo traer desde el workflow registry
             // con los names definidos en el admin $batchWorkflows
-            if (isset($this->batchWorkflows)) {
-                foreach ($this->batchWorkflows as $name) {
-                    $workflows[] = $registry->get($tmpEntity, $name);
-                }
+            foreach ($this->batchWorkflows as $name) {
+                $workflows[] = $registry->get($tmpEntity, $name);
             }
         }
-        
+
         foreach ($workflows as $workflow) {
-            $definition = method_exists($workflow, 'getSubject') 
-                    ? $workflow->getDefinition($workflow->getSubject())
-                    : $workflow->getDefinition();
+            $definition = method_exists($workflow, 'getSubject')
+                ? $workflow->getDefinition($workflow->getSubject())
+                : $workflow->getDefinition();
             $transitions = $definition ? $definition->getTransitions() : array();
+            $tmp = array();
             foreach ($transitions as $transition) {
-                $label = $this->trans('workflow.' . $workflow->getName() . '.transitions.' . $transition->getName(), array(), 'WorkflowLabel');
+                $id = 'workflow.' . $workflow->getName() . '.transitions.' . $transition->getName();
+                $label = $this->trans($id, array(), 'WorkflowLabel');
+                if ($label == $id) {
+                    $label = $transition->getName();
+                }
                 $label .= " ( {$transition->getName()} )";
-                $actions[$transition->getName()] = array(
+                $tmp[$transition->getName()] = array(
                     'label' => $label,
                     'ask_confirmation' => true,
                     'workflow' => array(
@@ -51,10 +63,11 @@ class WorkflowBaseAdmin extends BaseAdmin
                     ),
                 );
             }
+            $actions[$workflow->getName()] = array(
+                'label' => $this->trans($workflow->getName(), array(), 'WorkflowLabel'),
+                'group' => $tmp
+            );
         }
-        asort($actions);
-        
         return $actions;
     }
-
 }

+ 4 - 1
Resources/translations/WorkflowLabel.es.yml

@@ -15,7 +15,7 @@ workflow:
       pre_notice_to_active: Activar
       pre_notice_to_suspend: Suspender
       suspend_to_active: Activar
-      delete: Eliminar
+      erase: Eliminar
   transition_state:
     places:
       pending: Pendiente
@@ -43,3 +43,6 @@ workflow:
       add_config: Configurar
       disable: Deshabilitar
       active: Activar
+
+administrative_state: Estado Administrativo
+Default: Por defecto