(self["webpackChunk"] = self["webpackChunk"] || []).push([["adminlte-index"],{

/***/ "../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/app.index.js":
/*!***********************************************************************************!*\
  !*** ../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/app.index.js ***!
  \***********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.js */ "../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.js");
/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_index_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _index_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index.scss */ "../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.scss");



/***/ }),

/***/ "../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.js":
/*!*******************************************************************************!*\
  !*** ../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.js ***!
  \*******************************************************************************/
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {

__webpack_require__(/*! core-js/modules/es.date.to-string.js */ "./node_modules/core-js/modules/es.date.to-string.js");

__webpack_require__(/*! core-js/modules/es.object.to-string.js */ "./node_modules/core-js/modules/es.object.to-string.js");

__webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ "./node_modules/core-js/modules/es.regexp.to-string.js");

__webpack_require__(/*! core-js/modules/es.array.find.js */ "./node_modules/core-js/modules/es.array.find.js");

__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");

__webpack_require__(/*! core-js/modules/es.string.split.js */ "./node_modules/core-js/modules/es.string.split.js");

__webpack_require__(/*! core-js/modules/es.array.index-of.js */ "./node_modules/core-js/modules/es.array.index-of.js");

__webpack_require__(/*! core-js/modules/es.array.filter.js */ "./node_modules/core-js/modules/es.array.filter.js");

__webpack_require__(/*! core-js/modules/es.array.join.js */ "./node_modules/core-js/modules/es.array.join.js");

__webpack_require__(/*! core-js/modules/es.string.replace.js */ "./node_modules/core-js/modules/es.string.replace.js");

$(document).ready(function () {
  lcCrudIndexToggle();
  lcCrudIndexBatchActions();
});

function lcCrudIndexToggle() {
  var toggles = document.querySelectorAll('.custom-switch input[type="checkbox"]');

  for (i = 0; i < toggles.length; i++) {
    toggles[i].addEventListener('change', function () {
      var toggle = this;
      var newValue = this.checked;
      var oldValue = !newValue;
      var toggleUrl = this.closest('.custom-switch').dataset.url + "&newValue=" + newValue.toString();
      var toggleRequest = $.ajax({
        type: "POST",
        url: toggleUrl,
        data: {},
        dataType: 'json'
      });
      toggleRequest.done(function (response) {
        Notification.add('success', 'La propriété a bien été mise à jour.');
      });
      toggleRequest.fail(function () {
        toggle.checked = oldValue;
        toggle.disabled = true;
        toggle.closest('.checkbox-switch').classList.add('disabled');
        Notification.add('error', 'Une erreur est survenue.');
      });
    });
  }
}

function lcCrudIndexBatchActions() {
  var titleContent = $('.content-header-title > .title').html();
  $(document).on('click', '.deselect-batch-button', function () {
    $(this).closest('.content').find(':checkbox.form-batch-checkbox-all').prop('checked', false).trigger('change');
  });
  $(document).on('change', '.form-batch-checkbox-all', function () {
    $(this).closest('.content').find(':checkbox.form-batch-checkbox').prop('checked', $(this).prop('checked')).trigger('change');
  });
  $(document).on('change', '.form-batch-checkbox', function () {
    var $content = $(this).closest('.content-wrapper');
    var $input = $content.find(':hidden#batch_form_entityIds');
    var ids = $input.val() ? $input.val().split(',') : [];
    var id = $(this).val();

    if ($(this).prop('checked')) {
      $(this).closest('tr').addClass('selected-row');

      if (-1 === ids.indexOf(id)) {
        ids.push(id);
      }
    } else {
      $(this).closest('tr').removeClass('selected-row');
      ids = ids.filter(function (value) {
        return value !== id;
      });
      $content.find(':checkbox.form-batch-checkbox-all').prop('checked', false);
    }

    if (0 === ids.length) {
      $content.find('.global-actions').show();
      $content.find('.batch-actions').hide();
      $content.find('table').removeClass('table-batch');
    } else {
      $content.find('.batch-actions').show();
      $content.find('.global-actions').hide();
      $content.find('table').addClass('table-batch');
    }

    $input.val(ids.join(','));
    $content.find('.content-header-title > .title').html(0 === ids.length ? titleContent : '');
  });
  var modalTitle = $('#batch-action-confirmation-title');
  var titleContentWithPlaceholders = modalTitle.text();
  $('[data-action-batch]').on('click', function (event) {
    event.preventDefault();
    event.stopPropagation();
    var $actionElement = $(this);
    var actionName = $actionElement.attr('data-action-name');
    var selectedItems = $('input[type="checkbox"].form-batch-checkbox:checked');
    modalTitle.text(titleContentWithPlaceholders.replace('%action_name%', actionName).replace('%num_items%', selectedItems.length));
    $('#modal-batch-action').modal({
      backdrop: true,
      keyboard: true
    }).off('click', '#modal-batch-action-button').on('click', '#modal-batch-action-button', function () {
      $actionElement.unbind('click');
      $form = document.createElement('form');
      $form.setAttribute('action', $actionElement.attr('data-action-url'));
      $form.setAttribute('method', 'POST');
      $actionNameInput = document.createElement('input');
      $actionNameInput.setAttribute('type', 'hidden');
      $actionNameInput.setAttribute('name', 'batchActionName');
      $actionNameInput.setAttribute('value', $actionElement.attr('data-action-name'));
      $form.appendChild($actionNameInput);
      $entityFqcnInput = document.createElement('input');
      $entityFqcnInput.setAttribute('type', 'hidden');
      $entityFqcnInput.setAttribute('name', 'entityFqcn');
      $entityFqcnInput.setAttribute('value', $actionElement.attr('data-entity-fqcn'));
      $form.appendChild($entityFqcnInput);
      $actionUrlInput = document.createElement('input');
      $actionUrlInput.setAttribute('type', 'hidden');
      $actionUrlInput.setAttribute('name', 'batchActionUrl');
      $actionUrlInput.setAttribute('value', $actionElement.attr('data-action-url'));
      $form.appendChild($actionUrlInput);
      $csrfTokenInput = document.createElement('input');
      $csrfTokenInput.setAttribute('type', 'hidden');
      $csrfTokenInput.setAttribute('name', 'batchActionCsrfToken');
      $csrfTokenInput.setAttribute('value', $actionElement.attr('data-action-csrf-token'));
      $form.appendChild($csrfTokenInput);
      selectedItems.each(function (i, item) {
        $entityIdInput = document.createElement('input');
        $entityIdInput.setAttribute('type', 'hidden');
        $entityIdInput.setAttribute('name', "batchActionEntityIds[".concat(i, "]"));
        $entityIdInput.setAttribute('value', item.value);
        $form.appendChild($entityIdInput);
      });
      document.body.appendChild($form); //modalTitle.text(titleContentWithPlaceholders);

      $form.submit();
    });
  });
}

/***/ }),

/***/ "../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.scss":
/*!*********************************************************************************!*\
  !*** ../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/index.scss ***!
  \*********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ })

},
/******/ __webpack_require__ => { // webpackRuntimeModules
/******/ "use strict";
/******/ 
/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
/******/ __webpack_require__.O(0, ["vendors-node_modules_core-js_internals_a-function_js-node_modules_core-js_internals_export_js","vendors-node_modules_core-js_modules_es_array_find_js","vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-bed4a0","vendors-node_modules_core-js_modules_es_array_filter_js-node_modules_core-js_modules_es_array-87c47e"], () => (__webpack_exec__("../LaclicBundles/SovBundle/Resources/assets/app/adminlte/index/app.index.js")));
/******/ var __webpack_exports__ = __webpack_require__.O();
/******/ }
]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 17288 characters]