Explorar o código

FD3-556 Se quita cliente y nap del formulario por motivos de que el nap se ubica en base al cliente y en el uso a futuro sería raro un cliente con muchas onus.

Maxi Schvindt %!s(int64=7) %!d(string=hai) anos
pai
achega
2a7c6587dd

+ 74 - 7
src/FTTHBundle/Admin/ONUAdmin.php

@@ -86,18 +86,26 @@ class ONUAdmin extends WorkflowBaseAdmin
     protected function configureFormFields(FormMapper $formMapper)
     protected function configureFormFields(FormMapper $formMapper)
     {
     {
         $marks = OLTModelMark::getChoices();
         $marks = OLTModelMark::getChoices();
-        foreach ($marks as $m) {
-            $hidden[$m] = 'hidden';
-        }
+        $em = $this->get("doctrine.orm.entity_manager");
+        $template = $em->getRepository('FTTHBundle:ONUTemplate')->findOneBy(array('base'=>true));
         $subject = $this->getSubject();
         $subject = $this->getSubject();
-        if ($subject->getId()) {
-            $olt = $subject->getOlt();
+
+        foreach ($marks as $m) {$hidden[$m] = 'hidden';}
+
+        if ($subject->getId() || $template) {
+            ($subject->getOlt())? $olt = $subject->getOlt() : $olt = $template->getOlt();
             if ($olt && $olt->getModel()) {
             if ($olt && $olt->getModel()) {
                 $mark = $olt->getModel()->getMark();
                 $mark = $olt->getModel()->getMark();
                 $hidden[$mark] = '';
                 $hidden[$mark] = '';
             }
             }
         }
         }
 
 
+        if($template && $this->isCurrentRoute('create')) {
+            $translator = $this->get('translator');
+            $flashbag = $this->get('session')->getFlashBag();
+            $flashbag->add("warning", $translator->trans("msg_use_template_onu_in_create_onu_ftth",array(),"FTTHBundle"));
+        }
+
 
 
         $formMapper
         $formMapper
             ->tab('default')
             ->tab('default')
@@ -136,6 +144,9 @@ class ONUAdmin extends WorkflowBaseAdmin
                         'multiple' => true,
                         'multiple' => true,
                     ))
                     ))
                 ->end()
                 ->end()
+                ->with('Extra')
+                    ->add('extraData')
+                ->end()
             ->end()
             ->end()
             ->setHelps(array(
             ->setHelps(array(
                 'nap' => $this->trans("helps.check_address"),
                 'nap' => $this->trans("helps.check_address"),
@@ -242,12 +253,16 @@ class ONUAdmin extends WorkflowBaseAdmin
          *  Si vienen parámetros por GET de olt=id o psn=string seteamos los campos
          *  Si vienen parámetros por GET de olt=id o psn=string seteamos los campos
          */
          */
         $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA,
         $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA,
-            function (FormEvent $event) use ($formMapper) {
+            function (FormEvent $event) use ($formMapper, $template, $subject) {
                 $form = $event->getForm();
                 $form = $event->getForm();
 
 
+                if($template && $this->isCurrentRoute('create')) {
+                    $this->completeWithTemplate($form, $template);
+                }
+
                 $olt = $this->getRequest()->query->get('olt');
                 $olt = $this->getRequest()->query->get('olt');
                 if(!is_null($olt)) {
                 if(!is_null($olt)) {
-                    $em = $this->get("doctrine.orm.entity_manager");
+                    
                     $query_olt = $em->createQueryBuilder('o')
                     $query_olt = $em->createQueryBuilder('o')
                             ->select('o')
                             ->select('o')
                             ->from('FTTHBundle:OLT', 'o')
                             ->from('FTTHBundle:OLT', 'o')
@@ -539,4 +554,56 @@ class ONUAdmin extends WorkflowBaseAdmin
         return parent::update($object);
         return parent::update($object);
     }
     }
 
 
+    private function completeWithTemplate(&$form, $template){
+        
+
+        /*
+        if($client = $template->getClientId()) {
+            $form->add('clientId', null, array('data' => $client, 'label' => $this->trans("form.label_client")));
+        }
+        */
+        
+        if($profile = $template->getProfile()) {
+            $form->add('profile', null, array('data' => $profile));
+        }
+        
+        if($olt = $template->getOlt()) {
+            $form->add('olt', null, array('data' => $olt));
+        }
+        
+        if($model = $template->getModel()) {
+            $form->add('model', null, array('data' => $model));
+        }
+        
+        /*
+        if($nap = $template->getNap()) {
+            $form->add('nap', null, array('data' => $nap));
+        }
+        */
+        
+        if($vlan = $template->getVlan()) {
+            $form->add('vlan', null, array('data' => $vlan));
+        }
+        
+        if($trafficProfile = $template->getTrafficProfile()) {
+            $form->add('traffic_profile', null, array('data' => $trafficProfile));
+        }
+        
+        if($tcontprofile = $template->getTcontprofile()) {
+            $form->add('tcontprofile', null, array('data' => $tcontprofile));
+        }
+        
+        if($vlans = $template->getVlans()) {
+            $form->add('vlans', null, array('data' => $vlans));
+        }
+        
+        if($position = $template->getPosition()) {
+            $form->add('position', null, array('data' => $position));
+        }
+        
+        if($extraData = $template->getExtraData()) {
+            $form->add('extraData', null, array('data' => $extraData));
+        }
+
+    }
 }
 }

+ 0 - 8
src/FTTHBundle/Admin/ONUTemplateAdmin.php

@@ -29,9 +29,7 @@ class ONUTemplateAdmin extends BaseAdmin
     protected function configureDatagridFilters(DatagridMapper $datagridMapper)
     protected function configureDatagridFilters(DatagridMapper $datagridMapper)
     {
     {
         $datagridMapper
         $datagridMapper
-            ->add('clientId')
             ->add('profile')
             ->add('profile')
-            ->add('nap')
             ->add('model')
             ->add('model')
             ->add('olt');
             ->add('olt');
     }
     }
@@ -42,11 +40,9 @@ class ONUTemplateAdmin extends BaseAdmin
     protected function configureListFields(ListMapper $listMapper)
     protected function configureListFields(ListMapper $listMapper)
     {
     {
         $listMapper
         $listMapper
-            ->add('clientId')
             ->add('model')
             ->add('model')
             ->add('profile')
             ->add('profile')
             ->add('olt')
             ->add('olt')
-            ->add('nap')
             ->add('position')
             ->add('position')
             ->add('vlan')
             ->add('vlan')
             ->add('vlans')
             ->add('vlans')
@@ -84,11 +80,9 @@ class ONUTemplateAdmin extends BaseAdmin
         $formMapper
         $formMapper
             ->tab('default')
             ->tab('default')
                 ->with('')
                 ->with('')
-                    ->add('clientId')
                     ->add('model')
                     ->add('model')
                     ->add('profile')
                     ->add('profile')
                     ->add('olt')
                     ->add('olt')
-                    ->add('nap')
                     ->add('position')
                     ->add('position')
                 ->end()
                 ->end()
                 ->with('ZTE', ['class' => "col-md-12 {$hidden['ZTE']} olt_mark ZTE"])
                 ->with('ZTE', ['class' => "col-md-12 {$hidden['ZTE']} olt_mark ZTE"])
@@ -114,11 +108,9 @@ class ONUTemplateAdmin extends BaseAdmin
         $showMapper
         $showMapper
             ->tab('default')
             ->tab('default')
                 ->with('')
                 ->with('')
-                    ->add('clientId')
                     ->add('model')
                     ->add('model')
                     ->add('profile')
                     ->add('profile')
                     ->add('olt')
                     ->add('olt')
-                    ->add('nap')
                     ->add('position')
                     ->add('position')
                     ->add('created')
                     ->add('created')
                 ->end()
                 ->end()

+ 1 - 2
src/FTTHBundle/Entity/ONUTemplate.php

@@ -38,8 +38,7 @@ class ONUTemplate implements TenancyIdTraitInterface
     private $id;
     private $id;
 
 
     /**
     /**
-     * @ORM\Column(type="integer", nullable=false)
-     * @Assert\NotNull
+     * @ORM\Column(type="integer", nullable=true)
      * 
      * 
      */
      */
     private $clientId;
     private $clientId;

+ 1 - 0
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -312,3 +312,4 @@ Files: Archivos
 sonata.filter.onu_id: Ingrese Identificador|Nro serie|Nro serie PON
 sonata.filter.onu_id: Ingrese Identificador|Nro serie|Nro serie PON
 action_use_template: Usar
 action_use_template: Usar
 action_no_use_template: Deshabilitar base
 action_no_use_template: Deshabilitar base
+msg_use_template_onu_in_create_onu_ftth: Se encuentra en uso una plantilla de ONU y algunos campos se encuentran preseleccionados. Para crear una ONU sin campos preseleccionados acceda a FTTH > Plantilla ONU > Acciones > Deshabilitar Base.

+ 1 - 0
src/FTTHBundle/Resources/translations/messages.es.yml

@@ -6,5 +6,6 @@ form.service_port.gemport: gemport
 tcontprofile: Perfil tcont
 tcontprofile: Perfil tcont
 vlan_id: VLan ID
 vlan_id: VLan ID
 traffic_profile : Perfil de Tráfico
 traffic_profile : Perfil de Tráfico
+ONUTemplate: Plantilla ONU
 
 
 
 

+ 29 - 0
src/FTTHBundle/Resources/views/ONU/form.html.twig

@@ -3,11 +3,27 @@
 
 
 {% block formactions %}
 {% block formactions %}
     {{ parent() }}
     {{ parent() }}
+
+    <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: 450px!important;
+            border: 1px solid #CCCCCC;
+        }
+    </style>
+    
     <script type="text/javascript">
     <script type="text/javascript">
         var modificacion = false;
         var modificacion = false;
         $(function () {
         $(function () {
             // buscar la direccion del cliente y la muestra en el mapa.
             // buscar la direccion del cliente y la muestra en el mapa.
             var objSelectClient = $('input:hidden[id$="clientId"]');
             var objSelectClient = $('input:hidden[id$="clientId"]');
+            
+            if (typeof objSelectClient.val() == 'undefined'){
+                objSelectClient = $('input[id$="clientId"]');
+            }
+            
             if (objSelectClient.val() != "" && parseInt(objSelectClient.val()) > 0) {
             if (objSelectClient.val() != "" && parseInt(objSelectClient.val()) > 0) {
                 modificacion = true;
                 modificacion = true;
                 callbackClientId(objSelectClient.val());
                 callbackClientId(objSelectClient.val());
@@ -20,6 +36,19 @@
                 $("div[id*='_nap']").find(".select2-chosen").html("");
                 $("div[id*='_nap']").find(".select2-chosen").html("");
                 $("select[id*='_nap']").val(0);
                 $("select[id*='_nap']").val(0);
             }
             }
+
+            $("textarea").asAceEditor();
+            editor = $('textarea').data('ace-editor');
+
+            editor.setTheme("ace/theme/github");
+            editor.getSession().setMode("ace/mode/json");
+            editor.setFontSize(14);
+            editor.setShowInvisibles(true);
+            editor.getSession().setTabSize(2);
+            editor.getSession().setUseSoftTabs(true);
+            editor.getSession().setUseWrapMode(true);
+            editor.setShowPrintMargin(false);
+
         });
         });
 
 
         // Al seleccionar una OLT se muestra la config avanzada
         // Al seleccionar una OLT se muestra la config avanzada