- Timestamp:
- Aug 6, 2015, 3:08:52 PM (9 years ago)
- Branches:
- master
- Children:
- 86b243a
- Parents:
- 5ebd094
- Location:
- static/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
static/js/ajax-request.js
rb9cfa95 r59e5a1e 66 66 * @param anho Variable de tipo string que indica el año de consulta de la cadena productiva 67 67 */ 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 }); 68 function 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 }); 81 85 } 82 86 -
static/js/funciones.js
r315a7c8 r59e5a1e 331 331 $('#tree').treeview('expandNode', [ nodeId, { silent: true } ]); 332 332 }); 333 bootbox.alert(MSG_DELETE_NODES); 333 334 } 334 335 else { … … 373 374 var confirm = bootbox.confirm(MSG_SURE_MOD_CADENA, function(result) { 374 375 if (result) { 375 var modal = bootbox.dialog({ 376 var box = bootbox.prompt({ 377 label: "OKi docky", 376 378 title: TITLE_BOOTBOX_MODIFICAR_CADENA, 377 message: template,378 379 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' 428 382 } 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); 429 396 } 430 397 }); 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>"); 434 400 // Centra la ventana modal verticalmente 435 modal.css({401 box.css({ 436 402 'top': '50%', 437 403 'margin-top': function () { 438 return -( modal.height() / 2);404 return -(box.height() / 2); 439 405 } 440 406 });
Note: See TracChangeset
for help on using the changeset viewer.