From 018e24f434fd1a40e46a2dc5a12e14d6ce90114a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= Date: Mon, 5 Sep 2016 16:23:37 +0300 Subject: [PATCH] moved profiles page js to script file --- Resources/js/script.js | 78 ++++++++++++++++++++++--- Resources/public/script.js | 2 +- Resources/views/Profiles/list.html.twig | 68 ++------------------- Resources/views/Settings/list.html.twig | 5 ++ 4 files changed, 82 insertions(+), 71 deletions(-) diff --git a/Resources/js/script.js b/Resources/js/script.js index effb74a..80f6cd6 100644 --- a/Resources/js/script.js +++ b/Resources/js/script.js @@ -1,5 +1,5 @@ $(document).ready(function () { - var table = $('#settings').DataTable( { + var settingTable = $('#settings').DataTable( { ajax: { url: Routing.generate('ongr_settings_search_page'), dataSrc: 'documents' @@ -141,18 +141,18 @@ $(document).ready(function () { data: data, success: function (response) { if (response.error == false) { - table.ajax.reload(); + settingTable.ajax.reload(); $('#setting-form-modal').modal('hide') } else { - $('#setting-form-error').show(); $('#setting-form-error-message').html(response.message); + $('#setting-form-error').show(); } } }); }); $('#settings tbody').on( 'click', 'a.edit', function () { - var data = table.row( $(this).parents('tr') ).data(); + var data = settingTable.row( $(this).parents('tr') ).data(); reloadProfiles(data.profile); $('#setting-action-title').text('Setting edit'); $('#force-update').val('1'); @@ -188,15 +188,14 @@ $(document).ready(function () { $('#settings tbody').on( 'click', 'a.delete-setting', function (e) { e.preventDefault(); - var name = $(this).data('name'); $.confirm({ - text: "Are you sure you want to delete "+name+" setting?", + text: "Are you sure you want to delete setting?", title: "Confirmation required", confirm: function(button) { $.post(Routing.generate('ongr_settings_settings_delete'), {name: name}, function(data) { if (data.error == false) { - table.ajax.reload(); + settingTable.ajax.reload(); } }); }, @@ -206,4 +205,69 @@ $(document).ready(function () { dialogClass: "modal-dialog modal-lg" }); }); + + + + //Profile section + var profileTable = $('#profiles').DataTable( { + ajax: { + url: Routing.generate('ongr_settings_profiles_get_all_detailed'), + dataSrc: 'documents' + }, + stateSave: true, + order: [[ 1, "asc" ]], + columns: [ + { data: 'name' }, + { data: 'name' }, + { data: 'settings' }, + {} + ], + columnDefs: [ + { + "targets": 0, + "orderable": false, + "render": function ( data, type, row ) { + var className = 'toggle-profile'; + var label = $('