diff --git a/src/UnicaenImport/Form/TableForm.php b/src/UnicaenImport/Form/TableForm.php index 0c59d4ea451d46a226c7fd0bc35c86f6b6709214..0f4dbc30d89e02387ecd3b5c3f1939f5b21eb6b1 100755 --- a/src/UnicaenImport/Form/TableForm.php +++ b/src/UnicaenImport/Form/TableForm.php @@ -20,6 +20,7 @@ class TableForm extends Form implements InputFilterProviderInterface { $hydrator = new TableFormHydrator; $this->setHydrator($hydrator); + $this->setAttribute('class', 'tables-edit'); $this->add([ 'name' => 'syncEnabled', @@ -40,7 +41,7 @@ class TableForm extends Form implements InputFilterProviderInterface $this->add([ 'name' => 'syncFiltre', 'options' => [ - 'label' => 'Filtre de synchronisation', + 'label' => 'Filtre de synchronisation (SQL partiel)', ], 'attributes' => [ 'id' => 'sync_filtre', @@ -52,7 +53,7 @@ class TableForm extends Form implements InputFilterProviderInterface $this->add([ 'name' => 'syncHookBefore', 'options' => [ - 'label' => 'À exécuter avant la synchro', + 'label' => 'À exécuter avant la synchro (code PL/SQL)', ], 'attributes' => [ 'id' => 'sync_hook_before', @@ -64,7 +65,7 @@ class TableForm extends Form implements InputFilterProviderInterface $this->add([ 'name' => 'syncHookAfter', 'options' => [ - 'label' => 'À exécuter après la synchro', + 'label' => 'À exécuter après la synchro (code PL/SQL)', ], 'attributes' => [ 'id' => 'sync_hook_after', @@ -73,14 +74,14 @@ class TableForm extends Form implements InputFilterProviderInterface 'type' => 'TextArea', ]); -// $this->add([ -// 'name' => 'submit', -// 'type' => 'Submit', -// 'attributes' => [ -// 'value' => 'Enregistrer', -// 'class' => 'btn btn-primary', -// ], -// ]); + $this->add([ + 'name' => 'submit', + 'type' => 'Submit', + 'attributes' => [ + 'value' => 'Enregistrer', + 'class' => 'btn btn-primary btn-save', + ], + ]); } diff --git a/view/unicaen-import/table/index.phtml b/view/unicaen-import/table/index.phtml index 5b717d574f91bd295c44a8920f48aee8012832bd..54d50a6648030fb43d8e480133fe807f2913a47b 100644 --- a/view/unicaen-import/table/index.phtml +++ b/view/unicaen-import/table/index.phtml @@ -68,6 +68,7 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] ); title="Vous pouvez trier les tables en déplaçant les lignes du tableau"></span> <a class="ajax-modal" + data-event="table-modifier" href="<?= $this->url('import/tables/modifier',['table' => $table->getName()]) ?>" title="Modifier le paramétrage de la table" ><span class="glyphicon glyphicon-edit"></span></a> @@ -162,6 +163,11 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] ); }); WidgetInitializer.add('tables-config', 'tablesConfig'); + + $("body").on("table-modifier", function(event, data) { + window.location.reload(); + }); + }); diff --git a/view/unicaen-import/table/modifier.phtml b/view/unicaen-import/table/modifier.phtml index 465c60fc91f658b1e734b85ea5856e0a9d936623..8a2c89c38a34e19ca36fcc36bfa8d9220aeaf7c9 100644 --- a/view/unicaen-import/table/modifier.phtml +++ b/view/unicaen-import/table/modifier.phtml @@ -3,7 +3,7 @@ use UnicaenImport\Form\TableForm; /** - * @var $form TableForm + * @var $form TableForm * @var $title string */ @@ -14,37 +14,62 @@ echo $this->form($form); ?> <script> - var options = { - minLines: 10, maxLines: 10, - }; + $(function () + { + $.widget("unicaenImport.tablesEdit", { + filtreEditor: null, + hookBeforeEditor: null, + hookAfterEditor: null, - var filtreEditor = ace.edit("sync_filtre"); - filtreEditor.setTheme("ace/theme/github"); - filtreEditor.getSession().setMode("ace/mode/sql"); - filtreEditor.setOptions(options); + save: function () + { + var filtre = $("<input>") + .attr("type", "hidden") + .attr("name","syncFiltre") + .val(this.filtreEditor.getSession().getValue()); + this.element.append($(filtre)); - var hookBeforeEditor = ace.edit("sync_hook_before"); - hookBeforeEditor.setTheme("ace/theme/github"); - hookBeforeEditor.getSession().setMode("ace/mode/sql"); - hookBeforeEditor.setOptions(options); + var hookBefore = $("<input>") + .attr("type", "hidden") + .attr("name","syncHookBefore") + .val(this.hookBeforeEditor.getSession().getValue()); + this.element.append($(hookBefore)); - var hookAfterEditor = ace.edit("sync_hook_after"); - hookAfterEditor.setTheme("ace/theme/github"); - hookAfterEditor.getSession().setMode("ace/mode/sql"); - hookAfterEditor.setOptions(options); + var hookAfter = $("<input>") + .attr("type", "hidden") + .attr("name","syncHookAfter") + .val(this.hookAfterEditor.getSession().getValue()); + this.element.append($(hookAfter)); + }, - function posterForm() - { - //var url = '<?php echo $this->url(null, [], [], true); ?>'; - //var regles = editor.getSession().getValue(); + _create: function () + { + var that = this; + + that.element.find('.btn-save').click(function () { that.save();}); + + var options = { + minLines: 10, maxLines: 10, + }; + + that.filtreEditor = ace.edit("sync_filtre"); + that.filtreEditor.setTheme("ace/theme/github"); + that.filtreEditor.getSession().setMode("ace/mode/sql"); + that.filtreEditor.setOptions(options); + + that.hookBeforeEditor = ace.edit("sync_hook_before"); + that.hookBeforeEditor.setTheme("ace/theme/github"); + that.hookBeforeEditor.getSession().setMode("ace/mode/sql"); + that.hookBeforeEditor.setOptions(options); - //$.post(url, {regles: regles}); - } + that.hookAfterEditor = ace.edit("sync_hook_after"); + that.hookAfterEditor.setTheme("ace/theme/github"); + that.hookAfterEditor.getSession().setMode("ace/mode/sql"); + that.hookAfterEditor.setOptions(options); + } + }); - function test(){ - console.log($('#sync_hook_after').val()); - console.log(hookAfterEditor.getSession().getValue() ); - } + WidgetInitializer.add('tables-edit', 'tablesEdit'); + }); -</script> -<button class="btn btn-primary" type="button" onclick="test()">Enregistrer</button> \ No newline at end of file +</script> \ No newline at end of file