Browse Source

FD3-340 Se agrega campo address en NAP. i18n

Guillermo Espinoza 7 years ago
parent
commit
6188b21e6c

+ 34 - 34
composer.lock

@@ -755,9 +755,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/doctrine/instantiator/doctrine-instantiator-8e884e78f9f0eb1329e445619e04456e64d8051d-zip-681b88.zip",
+                "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
                 "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
-                "shasum": "62a7b8d59ce1dc5627bd2aed2882f18ff1138219"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3,<8.0-DEV"
@@ -1271,9 +1271,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/hwi/oauth-bundle/hwi-oauth-bundle-50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1-zip-0aca95.zip",
+                "url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1",
                 "reference": "50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1",
-                "shasum": "b6918d1815cc36aff59cf0d12764bb0324ff1549"
+                "shasum": ""
             },
             "require": {
                 "kriswallsmith/buzz": "~0.13",
@@ -1510,7 +1510,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
-                "reference": "285c7a279256fc613a0a8e65c6163d5b60361365"
+                "reference": "fdfa90821ff77946aa8a6781da6ac561f52e2b76"
             },
             "type": "library",
             "autoload": {
@@ -1525,7 +1525,7 @@
                 "bundle",
                 "extra-data"
             ],
-            "time": "2017-12-11 15:48:57"
+            "time": "2017-12-27 13:01:33"
         },
         {
             "name": "ik/leaflet-bundle",
@@ -1739,9 +1739,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/incenteev/composer-parameter-handler/incenteev-composer-parameter-handler-d7ce7f06136109e81d1cb9d57066c4d4a99cf1cc-zip-06d0a7.zip",
+                "url": "https://api.github.com/repos/Incenteev/ParameterHandler/zipball/d7ce7f06136109e81d1cb9d57066c4d4a99cf1cc",
                 "reference": "d7ce7f06136109e81d1cb9d57066c4d4a99cf1cc",
-                "shasum": "78accafc69077c94e2b5c40dcac6a23149e62a2d"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.3",
@@ -1884,9 +1884,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/jms/parser-lib/jms-parser-lib-c509473bc1b4866415627af0e1c6cc8ac97fa51d-zip-d6e55f.zip",
+                "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d",
                 "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d",
-                "shasum": "2ea232ddbcd3fb65004c7454244af057fb422817"
+                "shasum": ""
             },
             "require": {
                 "phpoption/phpoption": ">=0.9,<2.0-dev"
@@ -2003,9 +2003,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/jms/serializer-bundle/jms-serializer-bundle-85ee039a2b7f89d77c403e33cee7b43a875c31e5-zip-e99b92.zip",
+                "url": "https://api.github.com/repos/schmittjoh/JMSSerializerBundle/zipball/85ee039a2b7f89d77c403e33cee7b43a875c31e5",
                 "reference": "85ee039a2b7f89d77c403e33cee7b43a875c31e5",
-                "shasum": "8ceb3e6f31ad9b250fe9070661ee2d4b4d52c0f2"
+                "shasum": ""
             },
             "require": {
                 "jms/serializer": "^1.7",
@@ -2919,9 +2919,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/sensio/distribution-bundle/sensio-distribution-bundle-eb6266b3b472e4002538610b28a0a04bcf94891a-zip-b89371.zip",
+                "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/eb6266b3b472e4002538610b28a0a04bcf94891a",
                 "reference": "eb6266b3b472e4002538610b28a0a04bcf94891a",
-                "shasum": "c880207d73e5af5719bf65852f2890e55cb488d6"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.9",
@@ -3686,9 +3686,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/stof/doctrine-extensions-bundle/stof-doctrine-extensions-bundle-4e7499d25dc5d0862da09fa8e336164948a29a25-zip-803a48.zip",
+                "url": "https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/zipball/4e7499d25dc5d0862da09fa8e336164948a29a25",
                 "reference": "4e7499d25dc5d0862da09fa8e336164948a29a25",
-                "shasum": "5f6b05de8625fea312c1ae92066580864eea07d5"
+                "shasum": ""
             },
             "require": {
                 "gedmo/doctrine-extensions": "^2.3.1",
@@ -4192,9 +4192,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/symfony/security-acl/symfony-security-acl-053b49bf4aa333a392c83296855989bcf88ddad1-zip-4a92bd.zip",
+                "url": "https://api.github.com/repos/symfony/security-acl/zipball/053b49bf4aa333a392c83296855989bcf88ddad1",
                 "reference": "053b49bf4aa333a392c83296855989bcf88ddad1",
-                "shasum": "9562593da89cd1ab1a2d69962cc0d933cea99714"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.5.9",
@@ -4582,9 +4582,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/voryx/restgeneratorbundle/voryx-restgeneratorbundle-72b61d2188662da453d2e2a9cd625a60b6f3233b-zip-888957.zip",
+                "url": "https://api.github.com/repos/voryx/restgeneratorbundle/zipball/72b61d2188662da453d2e2a9cd625a60b6f3233b",
                 "reference": "72b61d2188662da453d2e2a9cd625a60b6f3233b",
-                "shasum": "5ca3bc614a05b341c7857876407dc54e73dcde0c"
+                "shasum": ""
             },
             "require": {
                 "friendsofsymfony/rest-bundle": "~1.7",
@@ -4617,7 +4617,7 @@
                 }
             ],
             "description": "REST API Generator for Symfony 2",
-            "time": "2016-04-18T12:29:38+00:00"
+            "time": "2016-04-18 12:29:38"
         },
         {
             "name": "willdurand/jsonp-callback-validator",
@@ -5138,9 +5138,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/phpunit/php-file-iterator/phpunit-php-file-iterator-3cc8f69b3028d0f96a9078e6295d86e9bf019be5-zip-184bc9.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5",
                 "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5",
-                "shasum": "d3ce5a919fe743126f331988b9a0f7b8302b999a"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.3"
@@ -5185,9 +5185,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/phpunit/php-text-template/phpunit-php-text-template-31f8b717e51d9a2afca6c9f046f5d69fc27c8686-zip-c6bcbd.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
                 "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
-                "shasum": "4122b00281fc98e1733bd9ca446002393c452f84"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.3"
@@ -5226,9 +5226,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/phpunit/php-timer/phpunit-php-timer-3dcf38ca72b158baf0bc245e9184d3fdffa9c46f-zip-c27592.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
                 "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
-                "shasum": "f67f992aca05457e1e21f619250770b09092ff7b"
+                "shasum": ""
             },
             "require": {
                 "php": "^5.3.3 || ^7.0"
@@ -5467,9 +5467,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/sebastian/code-unit-reverse-lookup/sebastian-code-unit-reverse-lookup-4419fcdb5eabb9caa61a27c7a1db532a6b55dd18-zip-2b8d33.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
                 "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
-                "shasum": "8470a6b3ca913a110aa2580255552a06e995710c"
+                "shasum": ""
             },
             "require": {
                 "php": "^5.6 || ^7.0"
@@ -5941,9 +5941,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/sebastian/resource-operations/sebastian-resource-operations-ce990bb21759f94aeafd30209e8cfcdfa8bc3f52-zip-4a3a08.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
                 "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
-                "shasum": "248cd12206b575057bf0b19f306d92a2f818dfb1"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.6.0"
@@ -5983,9 +5983,9 @@
             },
             "dist": {
                 "type": "zip",
-                "url": "https://satis.infra.flowdat.com/dist/sebastian/version/sebastian-version-99732be0ddb3361e16ad77b68ba41efc8e979019-zip-0eee83.zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019",
                 "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019",
-                "shasum": "dff8de471afebba9fc6837bb8c886ddc7ebe41bb"
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.6"
@@ -6185,7 +6185,7 @@
         "voryx/restgeneratorbundle": 20
     },
     "prefer-stable": false,
-    "prefer-lowest": true,
+    "prefer-lowest": false,
     "platform": {
         "php": ">=5.5.9"
     },

+ 21 - 6
src/FTTHBundle/Admin/NAPAdmin.php

@@ -22,6 +22,7 @@ class NAPAdmin extends BaseAdmin
             ->add('olt')
             ->add('slot')
             ->add('link')
+            ->add('address')
                 ;
     }
 
@@ -36,6 +37,7 @@ class NAPAdmin extends BaseAdmin
             ->add('olt')
             ->add('slot')
             ->add('link')
+            ->add('address')
             ->add('onus')
             ->add('extraData')
             ->add('_action', null, array(
@@ -53,12 +55,24 @@ class NAPAdmin extends BaseAdmin
     protected function configureFormFields(FormMapper $formMapper)
     {
         $formMapper
-            ->add('name')
-            ->add('parent')
-            ->add('olt')
-            ->add('slot')
-            ->add('link')
-            ->add('extraData');
+        ->tab('default')
+        ->with('')
+        ->add('name')
+        ->add('parent')
+        ->add('olt')
+        ->add('slot')
+        ->add('link')
+        ->add('address', 'text', [
+            'required' => false,
+        ])
+        ->end()
+        ->end()
+        ->tab('Avanzado')
+        ->with('Config')
+        ->add('extraData')
+        ->end()
+        ->end()
+            ;
     }
 
     /**
@@ -72,6 +86,7 @@ class NAPAdmin extends BaseAdmin
             ->add('olt')
             ->add('slot')
             ->add('link')
+            ->add('address')
             ->add('onus')
             ->add('extraData');
     }

+ 27 - 0
src/FTTHBundle/Entity/NAP.php

@@ -92,6 +92,13 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
      */
     protected $link = 0;
 
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    protected $address;
+
 
     /**
      * @return string
@@ -275,4 +282,24 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
 	    return $this->lng;
     }
 
+    /**
+    * @return string
+    */
+    public function getAddress()
+    {
+        return $this->address;
+    }
+
+    /**
+    * @param string $address
+    *
+    * @return Nap
+    */
+    public function setAddress($address)
+    {
+        $this->address = $address;
+
+        return $this;
+    }
+
 }

+ 59 - 0
src/FTTHBundle/EventListener/NAPAddressSubscriber.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace FTTHBundle\EventListener;
+
+use Doctrine\Common\EventSubscriber;
+use Doctrine\ORM\Event\LifecycleEventArgs;
+use FTTHBundle\Entity\NAP;
+
+class NAPAddressSubscriber implements EventSubscriber
+{
+
+    /**
+     * @return array
+     */
+    public function getSubscribedEvents()
+    {
+        return array(
+            'prePersist',
+            'preUpdate',
+        );
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     */
+    public function prePersist(LifecycleEventArgs $args)
+    {
+        $this->execute($args);
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     */
+    public function preUpdate(LifecycleEventArgs $args)
+    {
+        $this->execute($args, 'preUpdate');
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     * @param string $eventName
+     */
+    public function execute(LifecycleEventArgs $args, $eventName = 'prePersist')
+    {
+        $entity = $args->getEntity();
+        if ($entity instanceof NAP) {
+            $address = $entity->getAddress();
+            $address ? $entity->__set('address', $address)
+                     : $entity->__unset('address');
+
+            if ($eventName == 'preUpdate') {
+                $uow = $args->getEntityManager()->getUnitOfWork();
+                $meta = $args->getEntityManager()->getClassMetadata(get_class($entity));
+                $uow->recomputeSingleEntityChangeSet($meta, $entity);
+            }
+        }
+    }
+
+}

+ 7 - 2
src/FTTHBundle/Resources/config/services.yml

@@ -36,7 +36,7 @@ services:
         arguments: [~, FTTHBundle\Entity\ONUModel, BaseAdminBundle:CRUD]
         tags:
             - { name: sonata.admin, manager_type: orm, group: FTTH, label: ONUModel, label_catalogue: FTTHBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
-        calls:    
+        calls:
             - [setTranslationDomain, [FTTHBundle]]
 
     ftth.admin.olt_model:
@@ -44,7 +44,7 @@ services:
         arguments: [~, FTTHBundle\Entity\OLTModel, BaseAdminBundle:CRUD]
         tags:
             - { name: sonata.admin, manager_type: orm, group: FTTH, label: OLTModel, label_catalogue: FTTHBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
-        calls:    
+        calls:
             - [setTranslationDomain, [FTTHBundle]]
 
     ftth.onu.subscriber:
@@ -71,3 +71,8 @@ services:
         class: FTTHBundle\EventListener\ONUSoftDeleteListener
         tags:
             - { name: doctrine.event_listener, event: prePersist }
+
+    ftth.nap.subscriber:
+        class: FTTHBundle\EventListener\NAPAddressSubscriber
+        tags:
+            - { name: doctrine.event_subscriber, connection: default }

+ 8 - 4
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -43,7 +43,8 @@ filter:
     label_library: Librería
     label_slot: Slot
     label_link: Link
-    
+    label_address: Dirección
+
 breadcrumb:
     link_o_n_u_list: Listado ONU
     link_o_n_u_create: Crear ONU
@@ -63,7 +64,7 @@ breadcrumb:
     link_profile_list: Listado Perfiles
     link_profile_create: Crear Perfil
     link_profile_delete: Eliminar Perfil
-    
+
 form:
     label_id: Id
     label_ip: Ip
@@ -106,6 +107,7 @@ form:
     label_slot: Slot
     label_link: Link
     label_enable: Enable
+    label_address: Dirección
 
 list:
     label_id: Id
@@ -144,6 +146,7 @@ list:
     label_slot: Slot
     label_link: Link
     label_enable: Enable
+    label_address: Dirección
 
 show:
     label_id: Id
@@ -182,7 +185,8 @@ show:
     label_slot: Slot
     label_link: Link
     label_enable: Enable
-    
+    label_address: Dirección
+
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.
 error:
@@ -208,4 +212,4 @@ Address: Dirección
 out_of_range: FUERA DE RANGO
 without_olt: SIN OLT
 onu_distance_nap_not_configurated: Requiere configuración de distancia
-nap_not_positioned: NAP no posicionada
+nap_not_positioned: NAP no posicionada