Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17135 | Rev 17137 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17135 Rev 17136
Línea 81... Línea 81...
81
                },
81
                },
82
                'beforeSend': function (request) {
82
                'beforeSend': function (request) {
83
                  NProgress.start();
83
                  NProgress.start();
84
                },
84
                },
85
                'dataFilter': function(response) {
85
                'dataFilter': function(response) {
86
                    var response = jQuery.parseJSON( response );
86
                    var response = jQuery.parseJSON(response);
Línea 87... Línea 87...
87
                    
87
                    
88
                    var json                = {};
88
                    var json = {};
89
                    json.recordsTotal       = 0;
89
                    json.recordsTotal = 0;
90
                    json.recordsFiltered    = 0;
90
                    json.recordsFiltered = 0;
Línea 91... Línea 91...
91
                    json.data               = [];
91
                    json.data = [];
92
                    
92
                    
Línea 93... Línea 93...
93
                    if(response.success) {
93
                    if(response.success) {
94
                        $('#form-capsule-add').attr('action', response.data.link_add ); 
94
                        $('#form-capsule-add').attr('action', response.data.link_add); 
-
 
95
 
-
 
96
                        if(response.data.capsules) {
95
 
97
                            var $select = $('#form-filter #capsule_uuid');
96
                        if(response.data.capsules) {
98
                            $select.empty();
97
                            $('#form-filter #capsule_uuid').empty();
99
                            $select.append('<option value="">LABEL_SELECT_CAPSULE</option>');
-
 
100
                            $.each(response.data.capsules, function(index, value) {
-
 
101
                                $select.append('<option value="' + index + '">' + value + '</option>');
-
 
102
                            });
-
 
103
                            
-
 
104
                            // Si hay una cápsula seleccionada en la URL, seleccionarla
-
 
105
                            var urlParams = new URLSearchParams(window.location.search);
-
 
106
                            var selectedCapsule = urlParams.get('capsule_uuid');
98
                            $.each(response.data.capsules, function(index, value) {
107
                            if (selectedCapsule) {
Línea 99... Línea 108...
99
                                  $('#form-filter #capsule_uuid').append('<option value="' + index + '">' + value + '</option>')
108
                                $select.val(selectedCapsule);
100
                            });
109
                            }
101
                        } 
-
 
102
 
110
                        }
103
                        routeAdd = response.data.link_add;
111
 
104
                        if(response.data.link_add) {
112
                        routeAdd = response.data.link_add;
105
                            
113
                        if(response.data.link_add) {
Línea 106... Línea 114...
106
                            $('button.btn-add').removeAttr('disabled'); 
114
                            $('button.btn-add').removeAttr('disabled'); 
107
                        } else {
115
                        } else {
108
                            $('button.btn-add').attr('disabled', 'disabled'); 
116
                            $('button.btn-add').attr('disabled', 'disabled'); 
109
                        } 
117
                        }
110
 
118
 
-
 
119
                        json.recordsTotal = response.data.total;
-
 
120
                        json.recordsFiltered = response.data.total;
-
 
121
                        json.data = response.data.items;
-
 
122
                    } else {
111
                        json.recordsTotal       = response.data.total;
123
                        $.fn.showError(response.data || 'ERROR_UNKNOWN');
Línea 112... Línea 124...
112
                        json.recordsFiltered    = response.data.total;
124
                        // Limpiar la tabla en caso de error
113
                        json.data               = response.data.items;
125
                        json.recordsTotal = 0;
114
                    } else {
126
                        json.recordsFiltered = 0;
115
                        $.fn.showError(response.data)
127
                        json.data = [];
116
                    }
128
                    }
117
                    
129
                    
Línea 1884... Línea 1896...
1884
 
1896
 
1885
 
1897
 
1886
 
-
 
-
 
1898
 
1887
    $('#form-filter #capsule_uuid').change(function(e) {
1899
    $('#form-filter #capsule_uuid').change(function(e) {
-
 
1900
        e.preventDefault();
-
 
1901
        if ($(this).val()) {
-
 
1902
            gridTable.api().ajax.reload(null, false);
-
 
1903
        } else {
1888
        e.preventDefault();
1904
            // Si no hay cápsula seleccionada, limpiar la tabla
Línea 1889... Línea 1905...
1889
 
1905
            gridTable.api().clear().draw();
1890
        gridTable.api().ajax.reload(null, false);
1906
        }
Línea 1891... Línea 1907...
1891
    })
1907
    });
Línea 1937... Línea 1953...
1937
    $('body').on('click', 'button.btn-refresh', function(e) {
1953
    $('body').on('click', 'button.btn-refresh', function(e) {
1938
        e.preventDefault();
1954
        e.preventDefault();
1939
        gridTable.api().ajax.reload(null, false);
1955
        gridTable.api().ajax.reload(null, false);
1940
    });
1956
    });
Línea -... Línea 1957...
-
 
1957
 
-
 
1958
    var validatorFilter = $('#form-filter').validate({
-
 
1959
        debug: true,
-
 
1960
        onclick: false,
-
 
1961
        onkeyup: false,
-
 
1962
        ignore: [],
-
 
1963
        rules: {
-
 
1964
            'capsule_uuid': {
-
 
1965
                required: true
-
 
1966
            }
-
 
1967
        },
-
 
1968
        submitHandler: function(form) {
-
 
1969
            return false;
-
 
1970
        }
-
 
1971
    });
-
 
1972
 
-
 
1973
    $('#form-filter').on('submit', function(e) {
-
 
1974
        e.preventDefault();
-
 
1975
        if (validatorFilter.valid()) {
-
 
1976
            gridTable.api().ajax.reload(null, false);
-
 
1977
        }
-
 
1978
        return false;
Línea 1941... Línea 1979...
1941
 
1979
    });
1942
 
1980
 
1943
});
1981
});
1944
JS;
1982
JS;