Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16841 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15337 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
$routeSave       = $this->url('settings/my-private-network/intro');
9
 
16822 efrain 10
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
11
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15337 efrain 12
 
16822 efrain 13
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
15337 efrain 14
 
15
 
16
 
16929 efrain 17
 
18
 
19
 
15337 efrain 20
$this->inlineScript()->captureStart();
21
echo <<<JS
22
    jQuery( document ).ready(function( $ ) {
23
 
24
        $.validator.setDefaults({
25
            debug: true,
26
            highlight: function(element) {
27
                $(element).addClass('is-invalid');
28
            },
29
            unhighlight: function(element) {
30
                $(element).removeClass('is-invalid');
31
            },
32
            errorElement: 'span',
33
            errorClass: 'error invalid-feedback',
34
            errorPlacement: function(error, element) {
35
                if(element.parent('.btn-file').length) {
36
                    error.insertAfter(element.parent().parent());
37
                } else if(element.parent('.toggle').length) {
38
                    error.insertAfter(element.parent().parent());
39
                } else {
40
                    error.insertAfter(element.parent());
41
                }
42
            }
43
        });
44
 
15423 stevensc 45
        $.fn.handleDisable = function() {
46
            const disabledValue = $('button[type="submit"]').prop('disabled')
47
            $('button[type="submit"]').prop('disabled', !disabledValue);
48
        }
15337 efrain 49
 
50
 
16929 efrain 51
    var validator  = $('#form').validate({
15337 efrain 52
        debug: true,
53
        onclick: false,
54
        onkeyup: false,
55
        ignore: [],
56
        rules: {
57
            'intro': {
58
                updateCkeditor:function() {
59
                        CKEDITOR.instances.intro.updateElement();
60
                },
61
                required: true
62
            },
63
 
64
 
65
        },
66
        submitHandler: function(form)
67
        {
68
            var formdata = false;
69
            if (window.FormData){
70
                formdata = new FormData(form); //form[0]);
71
            }
72
 
15423 stevensc 73
            $.fn.handleDisable()
15337 efrain 74
 
75
            $.ajax({
76
                'dataType'  : 'json',
77
                'accept'    : 'application/json',
78
                'method'    : 'post',
79
                'url'       :  $('#form').attr('action'),
80
                'data'      :  formdata,
81
                'processData': false,
82
                'contentType': false,
83
            }).done(function(response) {
84
                if(response['success']) {
15423 stevensc 85
                    $.fn.showSuccess(response['data'], $.fn.handleDisable);
15337 efrain 86
 
87
                } else {
88
                    validator.resetForm();
89
                    if(jQuery.type(response['data']) == 'string') {
90
                        $.fn.showError(response['data']);
91
                    } else  {
92
                        $.each(response['data'], function( fieldname, errors ) {
93
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
94
                        });
95
                    }
96
                }
97
            }).fail(function( jqXHR, textStatus, errorThrown) {
98
                $.fn.showError(textStatus);
99
            }).always(function() {
100
                NProgress.done();
101
            });
102
            return false;
103
        },
104
        invalidHandler: function(form, validator) {
105
 
106
        }
107
    });
108
 
109
 
110
    CKEDITOR.replace('intro');
111
 
112
});
113
JS;
114
$this->inlineScript()->captureEnd();
115
?>
116
 
117
<!-- Content Header (Page header) -->
16822 efrain 118
<div class="container">
119
	<div class="card">
120
		<?php
121
               	    $form = $this->form;
122
                    $form->setAttributes([
123
                        'method'  => 'post',
124
                    	'action'  => $routeSave,
125
                        'name'    => 'form',
126
                        'id'      => 'form',
127
                    ]);
128
 
129
                    $form->prepare();
130
                    echo $this->form()->openTag($form);
131
        ?>
132
		<div class="card-body">
133
      		<h6 class="card-title">LABEL_MY_PRIVATE_NETWORK_INTRO</h6>
134
    		<div class="row">
16841 efrain 135
            	<div class="col-12  mt-3">
16822 efrain 136
              		<?php
137
                    $element = $form->get('intro');
138
                    $element->setAttributes(['id' => 'intro', 'class' => 'form-control', 'rows' => '2','class' => 'form-control']);
139
                    // $element->setOptions(['label' => 'LABEL_INTRO']);
140
                    // echo $this->formLabel($element);
141
                    echo $this->formTextArea($element);
142
                    ?>
143
     		</div>
144
 
15337 efrain 145
			</div>
16822 efrain 146
		</div>
147
		<div class="card-footer text-right">
148
     		<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
149
    	</div>
150
    	<?php echo $this->form()->closeTag($form); ?>
15337 efrain 151
	</div><!-- /.container-fluid -->
16822 efrain 152
</div>