<div class="modal fade addressModal"  tabindex="-1" role="dialog" aria-labelledby="addressModalLabel"
     aria-hidden="true">

    <div class="modal-dialog modal-dialog-centered" role="document">

        <div class="modal-content">

            <div class="modal-header">
                <h5 class="modal-title" id="addressModalLabel">Cím kezelése</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="text-center d-none spinnerDiv">
                    <strong style="vertical-align: super;padding-right: 1em;">Betöltés...</strong>
                    <div class="spinner-border text-success" role="status" aria-hidden="true"></div>
                </div>
                <form class="addressModalForm" action="{{route('admin.address.store')}}">
                    <input type="text" name="addressId" value="">
                    <div class="form-group">
                        <label for="addressModal-postCode" class="col-form-label">Irányítószám:</label>
                        <input type="text" class="form-control" id="addressModal-postCode"
                               name="addressPostCode" value="1234">
                    </div>
                    <div class="form-group">
                        <label for="addressModal-city" class="col-form-label">Település:</label>
                        <input type="text" class="form-control" id="addressModal-city"
                               name="addressCity" value="Kapuvár">
                    </div>

                    <div class="form-group">
                        <label for="addressModal-street" class="col-form-label">Cím:</label>
                        <input type="text" class="form-control" id="addressModal-street"
                               name="addressStreet"
                               data-inputmask="'mask': 'x{2,250}', 'greedy' : true"
                               data-required="true" value="Kapcsolattartó Béla">
                    </div>
                    <div class="form-group">
                        <label for="addressModal-name" class="col-form-label">Elnevezés (opcionális):</label>
                        <input type="text" class="form-control" id="addressModal-name"
                               name="addressName" value="Fő utca 12.">
                    </div>

                    <div class="form-group">
                        <label for="addressModal-note" class="col-form-label">Megjegyzés:</label>
                        <textarea class="form-control" id="addressModal-note"
                                  name="addressNote">Ez a megjegyzés</textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary buttonClose" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary buttonSave">Mentés</button>
            </div>

        </div>

    </div>

</div>

<script>
    $(document).ready(function () {
        //console.error('ez meg mikor');
        $('[data-toggle="tooltip"]').tooltip();
        debug()
        $(".addressModal :input").inputmask({
            /*"placeholder": "#",*/
            "onincomplete": function () {
                debug('incomplette');
                debug($(this).val().length);
                debug($(this).data('required'));
                if ($(this).val().length > 0 || $(this).data('required') === true) {
                    $(this).addClass('is-invalid');
                }
            },
            "oncomplete": function () {
                debug('oncomplete');
                debug($(this).val().length);

                $(this).removeClass('is-invalid');
                $(this).addClass('is-valid');
            },
            "oncleared": function () {
                debug('oncomplete');
                debug($(this).val().length);

                $(this).removeClass('is-invalid');
            }
        });
    });



    window.ajaxErrorFieldHandler = function (errors, container) {
        let toastBodyHtml = '';
        $.each(errors, function (index, value) {
            toastBodyHtml += '<div>' + value.detail + '<div>';
        });
        Toast.create("Hiba!", toastBodyHtml, TOAST_STATUS.DANGER, 10000);
    }

    /*

        if(!$.fn.jstree){
            $.getScript('https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js',
                function(){
                    APP.initProductGroupTree();
                }
            );
        }else{
            APP.initProductGroupTree();
        }
        */
</script>

