From b6bb2bb57627d131a80c2e3beec1fb989c6545b7 Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 11 Dec 2019 10:03:43 +0100 Subject: [PATCH] new: [UI] first implementation of the modal forms --- app/Controller/EventsController.php | 1 - app/Model/User.php | 2 +- app/View/Attributes/add.ctp | 2 +- app/View/Elements/eventattributetoolbar.ctp | 7 +- .../genericElements/Form/genericForm.ctp | 50 ++++-- .../genericElements/Form/submitButton.ctp | 8 +- app/webroot/css/main.css | 4 + app/webroot/js/misp.js | 159 +++++++++++------- 8 files changed, 147 insertions(+), 86 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index a144e8ae5..765aa2bd1 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -2420,7 +2420,6 @@ class EventsController extends AppController $fieldDesc['analysis'][$key] = $this->Event->analysisDescriptions[$key]['formdesc']; } $this->set('analysisLevels', $analysisLevels); - $this->set('fieldDesc', $fieldDesc); $this->set('eventDescriptions', $this->Event->fieldDescriptions); $this->set('event', $this->Event->data); diff --git a/app/Model/User.php b/app/Model/User.php index 48a633ce3..273fa3cb8 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -1500,7 +1500,7 @@ class User extends AppModel $endDate = time(); } $dates = array(); - for ($d=$startDate; $d < $endDate; $d=$d+3600*24) { + for ($d=$startDate; $d < $endDate; $d=$d+3600*24) { $dates[] = date('Y-m-d', $d); } $csv = 'Date,Close\n'; diff --git a/app/View/Attributes/add.ctp b/app/View/Attributes/add.ctp index 91216f37a..aa526294f 100644 --- a/app/View/Attributes/add.ctp +++ b/app/View/Attributes/add.ctp @@ -70,7 +70,7 @@ 'submit' => array( 'action' => $action, 'ajaxSubmit' => sprintf( - 'submitPopoverForm(%s, %s)', + 'submitPopoverForm(%s, %s, 0, 1)', "'" . ($action == 'add' ? h($event_id) : h($attribute['Attribute']['id'])) . "'", "'" . h($action) . "'" ) diff --git a/app/View/Elements/eventattributetoolbar.ctp b/app/View/Elements/eventattributetoolbar.ctp index 14c977a9a..a3ff26e83 100644 --- a/app/View/Elements/eventattributetoolbar.ctp +++ b/app/View/Elements/eventattributetoolbar.ctp @@ -49,10 +49,11 @@ 'children' => array( array( 'id' => 'create-button', - 'title' => __('Add attribute'), + 'title' => $possibleAction === 'attribute' ? __('Add attribute') : __('Add proposal'), 'fa-icon' => 'plus', - 'onClick' => 'clickCreateButton', - 'onClickParams' => array($event['Event']['id'], $possibleAction) + //'onClick' => 'clickCreateButton', + 'onClick' => 'openGenericModal', + 'onClickParams' => array('/' . $possibleAction . 's/add/' . h($event['Event']['id'])) ), array( 'id' => 'multi-edit-button', diff --git a/app/View/Elements/genericElements/Form/genericForm.ctp b/app/View/Elements/genericElements/Form/genericForm.ctp index c2be2ec4f..bab2eb85e 100644 --- a/app/View/Elements/genericElements/Form/genericForm.ctp +++ b/app/View/Elements/genericElements/Form/genericForm.ctp @@ -81,24 +81,46 @@ $ajaxFlashMessage = ''; if ($ajax) { $ajaxFlashMessage = sprintf( - '
%s
', + '
%s
', $this->Flash->render() ); } $formEnd = $this->Form->end(); - echo sprintf( - '
%s
%s%s
%s
%s%s%s
', - $ajax ? 'ajax' : 'form', - $formCreate, - empty($data['title']) ? h(Inflector::humanize($this->request->params['action'])) . ' ' . $modelForForm : h($data['title']), - $ajaxFlashMessage, - empty($ajax) ? '' : 'ajax_fieldset', - $fieldsString, - empty($ajax) ? '' : 'ajax_fieldset', - $formEnd, - $metaFieldString, - $this->element('genericElements/Form/submitButton', $submitButtonData) - ); + if (!empty($ajax)) { + echo sprintf( + '', + sprintf( + '', + empty($data['title']) ? h(Inflector::humanize($this->request->params['action'])) . ' ' . $modelForForm : h($data['title']) + ), + sprintf( + '', + sprintf( + '%s
%s%s
%s%s', + $formCreate, + $ajaxFlashMessage, + $fieldsString, + $formEnd, + $metaFieldString + ) + ), + sprintf( + '', + $this->element('genericElements/Form/submitButton', $submitButtonData) + ) + ); + } else { + echo sprintf( + '
%s
%s%s%s
%s%s%s
', + $formCreate, + empty($data['title']) ? h(Inflector::humanize($this->request->params['action'])) . ' ' . $modelForForm : h($data['title']), + $ajaxFlashMessage, + $fieldsString, + $formEnd, + $metaFieldString, + $this->element('genericElements/Form/submitButton', $submitButtonData) + ); + } ?>