Просмотр исходного кода

Se agrega template por defecto para las creaciones de workflow. Se agregan links de interés. Se agrega gráfica de workflow para la vista de edición(para la creación no, el workflow aún no existe)

Maximiliano Schvindt 8 лет назад
Родитель
Сommit
8672a3b35e

+ 30 - 3
Admin/WorkflowAdmin.php

@@ -63,7 +63,34 @@ class WorkflowAdmin extends BaseAdmin
      */
     protected function configureFormFields(FormMapper $formMapper)
     {
-
+        $template_example = 
+"
+initial_place: state_two
+places:
+  - state_one
+  - state_two
+  - state_three
+transitions:
+  one_to_two:
+    from: state_one
+    to: state_two
+  two_to_three:
+    from: state_two
+    to: state_three
+  two_to_one:
+    from: state_two
+    to: state_one
+  three_to_one:
+    from: state_three
+    to: state_one
+";        
+        // Create => template_example
+        $tempate_options = array("attr" => array('style' => 'height:500px;'));
+        if(is_null($this->getSubject()->getId())) {
+            $tempate_options['data'] = $template_example;
+        } else {
+            $this->parameters = array('workflow_name' => $this->getSubject()->getName());
+        }
         $_supports = WorkFlowEntityClasses::getClass();
         $supports = array();
         foreach($_supports as $key => $class) {
@@ -80,14 +107,14 @@ class WorkflowAdmin extends BaseAdmin
             ->add('markingType', 'choice', array('choices' => array('single_state' => 'single_state', 'multiple_state' => 'multiple_state')))
             ->add('markingName', 'choice', array('choices' => array('currentState' => 'currentState')))
             ->add('support', 'choice', array('choices' => $supports,'multiple'   => true, 'required' => true))
-            ->add('template', null, array('attr' => array('style' => 'height:500px;')))
+            ->add('template', null, $tempate_options)
 
             ->setHelps(array(
                'name' => $this->trans("helps.workflow_label_name"),
                'type' => $this->trans("helps.workflow_label_type"),
                'markingType' => $this->trans("helps.workflow_label_marking_type"),
                'markingName' => $this->trans("helps.workflow_label_marking_name"),
-
+               'template' => $this->trans("helps.workflow_label_template"),
             ))
             ;
     }

+ 5 - 1
Resources/translations/WorkflowBundle.es.yml

@@ -90,6 +90,7 @@ helps:
     workflow_label_type: "Tipo de Workflow: state_machine o workflow"
     workflow_label_marking_type: "Tipo de Marcador: single_state o multiple_state"
     workflow_label_marking_name: "Nombre del Marcador, atributo de la entidad que tendrá el estado, por defecto: currentState"
+    workflow_label_template: "Sólo requiere definir 'places', 'transitions' y opcionalmente 'initial_place', el resto se completa desde los campos solicitados arriba"
     action_label_name: Nombre con el que se identificará a una Acción
     action_label_workflow_type: Tipo de Workflow.
     action_label_workflow_name: Nombre del Workflow al cual hace referencia.
@@ -104,4 +105,7 @@ Class not found: Clase no encontrada
 Object not found: Objecto no encontrado
 Undefined State: Sin estado
 Incorrect State: Estado erróneo
-Undefined Workflow: Sin workflow
+Undefined Workflow: Sin workflow
+workflow_edit_create_alert: "Para realizar el template, tenga en cuenta:"
+Workflow Documentation: Documentación sobre Workflows
+YAML Documentation: Sintaxis básica para YAML

+ 46 - 26
Resources/views/Workflow/workflow_edit.html.twig

@@ -1,36 +1,56 @@
 {% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %}
 
-{% block form %}
+{% block parentForm %}
+    <div class="alert alert-info">
+        {{ 'workflow_edit_create_alert'|trans({}, 'WorkflowBundle') }} <br />
+        - {{ 'Workflow Documentation'|trans({}, 'WorkflowBundle') }} <a target="_blank" href="http://symfony.com/blog/new-in-symfony-3-2-workflow-component">http://symfony.com/blog/new-in-symfony-3-2-workflow-component</a><br />
+        - {{ 'YAML Documentation'|trans({}, 'WorkflowBundle') }} <a target="_blank" href="http://docs.ansible.com/ansible/YAMLSyntax.html">http://docs.ansible.com/ansible/YAMLSyntax.html</a>
+    </div>
+
     {{ parent() }}
-     
-     {#https://github.com/ryanburnette/textarea-as-ace-editor#}
-     {#https://ace.c9.io/#}
-     {#https://ace.c9.io/build/kitchen-sink.html#}
-     <script src="{{ asset('bundles/baseadmin') }}/ace_editor/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
-     <script src="{{ asset('bundles/baseadmin') }}/ace_editor/textarea-as-ace-editor.js" type="text/javascript" charset="utf-8"></script>
-     
-     <style type="text/css" media="screen">
-        .ace_editor {
-            height: 250px!important;
-        }
+
+    {#https://github.com/ryanburnette/textarea-as-ace-editor#}
+    {#https://ace.c9.io/#}
+    {#https://ace.c9.io/build/kitchen-sink.html#}
+    <script src="{{ asset('bundles/baseadmin') }}/ace_editor/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
+    <script src="{{ asset('bundles/baseadmin') }}/ace_editor/textarea-as-ace-editor.js" type="text/javascript" charset="utf-8"></script>
+
+    <style type="text/css" media="screen">
+       .ace_editor {
+           height: 250px!important;
+       }
+       
+       .form-actions.stuck {
+           z-index: 99999!important;
+       }
     </style>
     
-     <script type="text/javascript">
-        $( document ).ready(function() {
-            $("textarea").asAceEditor();
-            editor = $('textarea').data('ace-editor');
-            
-            editor.setTheme("ace/theme/github");
-            editor.getSession().setMode("ace/mode/yaml");
-            //editor.setReadOnly(true);
-            editor.setFontSize(14);
-            editor.setShowInvisibles(true);
-            editor.getSession().setTabSize(2);
-            editor.getSession().setUseSoftTabs(true);
-            editor.getSession().setUseWrapMode(true);
-        });
+    <script type="text/javascript">
+    $( document ).ready(function() {
+        $("textarea").asAceEditor();
+        editor = $('textarea').data('ace-editor');
+
+        editor.setTheme("ace/theme/github");
+        editor.getSession().setMode("ace/mode/yaml");
+        //editor.setReadOnly(true);
+        editor.setFontSize(14);
+        editor.setShowInvisibles(true);
+        editor.getSession().setTabSize(2);
+        editor.getSession().setUseSoftTabs(true);
+        editor.getSession().setUseWrapMode(true);
+        
+        
+        {% if admin.parameters.workflow_name is defined %}
+            editor = $( ".ace_editor" );
+            image = "{{ app.request.schemeAndHttpHost ~ app.request.baseUrl }}/../workflows_png/{{admin.parameters.workflow_name}}.png?nocache={{ date().timestamp }}";
+            editor.parent("div").append("<div> <br /> <img src='"+ image +"'</div>");
+        {% endif %}
+        
+    });
     </script>
 
+    
+
 
 {% endblock %}