Skip to content

Commit

Permalink
Fix #98 (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloalonsod authored and alterphp committed Mar 13, 2019
1 parent 43713ec commit b97090d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
11 changes: 8 additions & 3 deletions src/Resources/public/js/autocomplete-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ function switchToEntityCreation(url_action, select_id, field_name) {
}

function openCreateEntityModal(data, url_action, field_name, select_id) {
$('#create-entity-modal .modal-body').html(data.html);
var data_html = $(data.html);
data_html.find('.form-actions > a[name=list]').remove();
data_html.find('.form-actions > a[name=delete]').remove();
$('#create-entity-modal .modal-body').html(data_html);
$('form[name="'+field_name+'"]').attr('action', url_action);
initCreateEntityAjaxForm(field_name, select_id);
}
Expand Down Expand Up @@ -95,6 +98,8 @@ function initCreateEntityAjaxForm(field_name, select_id) {
});
}

$(function () {
createAutoCompleteCreateFields();
window.addEventListener('load', function() {
$(function () {
createAutoCompleteCreateFields();
});
});
32 changes: 17 additions & 15 deletions src/Resources/public/js/easyadmin-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,27 @@ function reloadEmbeddedList(identifier, toggleBaseUrl) {
}
}

$(function() {
$('[data-confirm]').on('click', function(e) {
e.preventDefault();
window.addEventListener('load', function() {
$(function() {
$('[data-confirm]').on('click', function(e) {
e.preventDefault();

var message = $(this).data('confirm');
var content = $('#modal-confirm p.modal-body-content');
content.html(message);
var message = $(this).data('confirm');
var content = $('#modal-confirm p.modal-body-content');
content.html(message);

var confirmButton = $('#modal-confirm #modal-confirm-button');
if (!confirmButton.find('i').length) { confirmButton.prepend('<i></i>'); }
confirmButton.find('i')
.removeClass()
.addClass($(this).find('i').attr('class'))
;
var confirmButton = $('#modal-confirm #modal-confirm-button');
if (!confirmButton.find('i').length) { confirmButton.prepend('<i></i>'); }
confirmButton.find('i')
.removeClass()
.addClass($(this).find('i').attr('class'))
;

var href = $(this).data('href');
$('#modal-confirm #confirm-form').attr('action', href);
var href = $(this).data('href');
$('#modal-confirm #confirm-form').attr('action', href);

$('#modal-confirm').modal({ backdrop: true, keyboard: true });
$('#modal-confirm').modal({ backdrop: true, keyboard: true });
});
});
});

Expand Down
10 changes: 8 additions & 2 deletions src/Resources/views/default/new_ajax.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

{% block head_stylesheets %}
<style>
#create-entity-modal .main-sidebar {
#create-entity-modal .main-sidebar,
#create-entity-modal .main-header {
display: none !important;
}
#create-entity-modal .wrapper {
grid-template-columns: none !important;
grid-column-gap: none !important;
grid-template-areas: none !important;
}
#create-entity-modal .content-wrapper,
#create-entity-modal .main-footer {
margin-left: 0 !important;
Expand All @@ -26,7 +32,7 @@
: _app_language in _select2_locales ? _app_language : 'en'
%}

<script src="{{ asset('bundles/easyadmin/javascript/select2/i18n/' ~ _select2_locale ~ '.js') }}"></script>
<script src="{{ asset('bundles/easyadmin/select2/i18n/' ~ _select2_locale ~ '.js') }}"></script>

<script type="text/javascript">
$(function() {
Expand Down

0 comments on commit b97090d

Please sign in to comment.