Changeset 59e5a1e in sicp for static


Ignore:
Timestamp:
Aug 6, 2015, 3:08:52 PM (9 years ago)
Author:
Ing. Roldan D. Vargas G <rvargas@…>
Branches:
master
Children:
86b243a
Parents:
5ebd094
Message:

implementación de la función que modifica los nodos de la cadena y almacena la cadena modificada en base de datos

Location:
static/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • static/js/ajax-request.js

    rb9cfa95 r59e5a1e  
    6666 * @param anho          Variable de tipo string que indica el año de consulta de la cadena productiva
    6767 */
    68 function modificar_cadena(url, product_id, fuente, anho) {
    69     $.getJSON(url, {product_id:product_id, fuente:fuente, anho:anho}, function(datos) {
    70         if (datos.resultado) {
    71             bootbox.alert(MSG_EDIT_CADENA);
    72         }
    73         else {
    74             bootbox.alert(datos.error);
    75         }
    76     }).fail(function(jqxhr, textStatus, error) {
    77         var err = textStatus + ", " + error;
    78 
    79         bootbox.alert(ERROR_AJAX_REQUEST + err);
    80     });
     68function guardar_cadena_productiva(url, producto_id, list_pr_ids, fuente, anho, nombre_cadena) {
     69
     70    $.getJSON(
     71        url,
     72        {producto_id:producto_id, list_pr_ids: list_pr_ids, fuente:fuente, anho:anho, nombre_cadena: nombre_cadena},
     73        function(datos) {
     74            if (datos.resultado) {
     75                bootbox.alert(MSG_EDIT_CADENA, function() { location.reload(); });
     76            }
     77            else {
     78                bootbox.alert(datos.error);
     79            }
     80        }).fail(function(jqxhr, textStatus, error) {
     81            var err = textStatus + ", " + error;
     82
     83            bootbox.alert(ERROR_AJAX_REQUEST + err);
     84        });
    8185}
    8286
  • static/js/funciones.js

    r315a7c8 r59e5a1e  
    331331            $('#tree').treeview('expandNode', [ nodeId, { silent: true } ]);
    332332        });
     333        bootbox.alert(MSG_DELETE_NODES);
    333334    }
    334335    else {
     
    373374    var confirm = bootbox.confirm(MSG_SURE_MOD_CADENA, function(result) {
    374375        if (result) {
    375             var modal = bootbox.dialog({
     376            var box = bootbox.prompt({
     377                label: "OKi docky",
    376378                title: TITLE_BOOTBOX_MODIFICAR_CADENA,
    377                 message: template,
    378379                buttons: {
    379                     success: {
    380                         label: BTN_ACEPT,
    381                         className: "btn btn-primary btn-sm",
    382                         callback: function() {
    383 
    384                             $("#mod-cadena-form").validate({
    385                                 rules: {
    386                                     nombre_cadena: {
    387                                         required: true
    388                                     }
    389                                 },
    390                                 messages: {
    391                                     nombre_cadena: {
    392                                         required: ERROR_REQUIRED
    393                                     }
    394                                 },
    395                                 highlight: function(element) {
    396                                     $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
    397                                 },
    398                                 unhighlight: function(element) {
    399                                     $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
    400                                 },
    401                                 errorElement: 'span',
    402                                 errorClass: 'help-block',
    403                                 errorPlacement: function(error, element) {
    404                                     if(element.parent('.input-group').length) {
    405                                         error.insertAfter(element.parent());
    406                                     } else {
    407                                         error.insertAfter(element);
    408                                     }
    409                                 },
    410                                 submitHandler: function(form) {
    411                                     // Instrucción a ejecutar cuando se realiza el submit del formulario
    412                                     /*$("#mod-cadena-form").attr('action', URL_MODIFICAR_CADENA_PRODUCTIVA+"?ciiu="+id+
    413                                         "&narriba="+$(modal).find("#nivelesarriba").val()+
    414                                         "&nabajo="+$(modal).find("#nivelesabajo").val()+
    415                                         "&anho="+$(modal).find(".select2 :selected").text()
    416                                     );*/
    417 
    418                                     form.submit();
    419                                 }
    420                             });
    421                             $("#mod-cadena-form").submit();
    422                             return false;
    423                         }
    424                     },
    425                     main: {
    426                         label: BTN_CANCEL,
    427                         className: "btn btn-warning btn-sm"
     380                    confirm: {
     381                        label: 'guardar cadena'
    428382                    }
     383                },
     384                callback: function(nombre_cadena){
     385                    var list_pr_ids = new Array();
     386                    var anho = parseInt($("#anho").html());
     387                    var tree = $('#tree');
     388                    var prd = tree.treeview('getNode', 0).tags[0].pr_id;
     389
     390                    $('.node-disabled').each(function(index) {
     391                        nodeId = parseInt($(this).attr('data-nodeid'));
     392                        pr_id = tree.treeview('getNode', nodeId).tags[0].pr_id;
     393                        list_pr_ids.push(pr_id);
     394                    });
     395                    guardar_cadena_productiva(URL_EDIT_CADENA, prd, list_pr_ids, 'S', anho, nombre_cadena);
    429396                }
    430397            });
    431 
    432             $(modal).find('[data-toggle="tooltip"]').tooltip({});
    433 
     398            $(box).find('.bootbox-input').addClass('input-sm');
     399            $(box).find('.bootbox-input').before("<label>Nombre</label>");
    434400            // Centra la ventana modal verticalmente
    435             modal.css({
     401            box.css({
    436402                'top': '50%',
    437403                'margin-top': function () {
    438                     return -(modal.height() / 2);
     404                    return -(box.height() / 2);
    439405                }
    440406            });
Note: See TracChangeset for help on using the changeset viewer.