chg: [UI] Small refactor of the event add/edit views

- added new flag to form elements for the generator: stayInLine:1 - skip linebreak after field
- removed edit view
- modified add view to work as both add/edit
pull/5404/head
iglocska 2019-11-13 09:38:46 +01:00
parent 222dd10977
commit 936a7faca0
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
5 changed files with 14 additions and 91 deletions

View File

@ -2423,6 +2423,7 @@ class EventsController extends AppController
$this->set('fieldDesc', $fieldDesc);
$this->set('eventDescriptions', $this->Event->fieldDescriptions);
$this->set('event', $this->Event->data);
$this->render('add');
}
public function delete($id = null)

View File

@ -17,7 +17,7 @@
}
}
echo sprintf(
'<span id = "%sInfoPopover" class="icon-info-sign" data-toggle="popover" data-trigger="hover" ></span>',
'<span id = "%sInfoPopover" class="icon-info-sign" data-toggle="popover" data-trigger="hover" style="margin-left:2px;"></span>',
h($field['field'])
);
?>

View File

@ -58,7 +58,9 @@
} else {
$fieldsString .= $fieldData;
}
$fieldsString .= '<div class="clear"></div>';
if (empty($fieldData['stayInLine'])) {
$fieldsString .= '<div class="clear"></div>';
}
}
}
$metaFieldString = '';

View File

@ -15,13 +15,15 @@
array(
'field' => 'date',
'class' => 'datepicker',
'type' => 'text'
'type' => 'text',
'stayInLine' => 1
),
array(
'field' => 'distribution',
'class' => 'input',
'options' => $distributionLevels,
'default' => $initialDistribution
'default' => isset($event['Event']['distribution']) ? $event['Event']['distribution'] : $initialDistribution,
'stayInLine' => 1
),
array(
'field' => 'sharing_group_id',
@ -33,7 +35,8 @@
'field' => 'threat_level_id',
'class' => 'input',
'options' => $threatLevels,
'label' => __("Threat Level")
'label' => __("Threat Level"),
'stayInLine' => 1
),
array(
'field' => 'analysis',
@ -43,13 +46,13 @@
array(
'field' => 'info',
'label' => __('Event Info'),
'class' => 'input-xxlarge',
'class' => 'input span6',
'type' => 'text',
'placeholder' => __('Quick Event Description or Tracking Info')
),
array(
'field' => 'extends_uuid',
'class' => 'input-xxlarge',
'class' => 'input span6',
'placeholder' => __('Event UUID or ID. Leave blank if not applicable.'),
'label' => __("Extends Event")
)
@ -59,7 +62,7 @@
)
)
));
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event-collection', 'menuItem' => 'add'));
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event-collection', 'menuItem' => $this->action === 'add' ? 'add' : 'editEvent'));
?>
<script type="text/javascript">

View File

@ -1,83 +0,0 @@
<?php
$mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id'] && $event['Event']['orgc_id'] == $me['org_id']) || ($isAclModifyOrg && $event['Event']['orgc_id'] == $me['org_id']));
$mayPublish = ($isAclPublish && $event['Event']['orgc_id'] == $me['org_id']);
$modelForForm = 'Event';
echo $this->element('genericElements/Form/genericForm', array(
'form' => $this->Form,
'data' => array(
'title' => __('Edit Event'),
'model' => $modelForForm,
'fields' => array(
array(
'field' => 'event_id',
'type' => 'text',
'hidden' => true
),
array(
'field' => 'date',
'class' => 'datepicker',
'type' => 'text'
),
array(
'field' => 'distribution',
'class' => 'input',
'options' => $distributionLevels,
'default' => $event['Event']['distribution']
),
array(
'field' => 'sharing_group_id',
'class' => 'input',
'options' => $sharingGroups,
'default' => $event['Event']['sharing_group_id'],
'label' => __("Sharing Group")
),
array(
'field' => 'threat_level_id',
'class' => 'input',
'options' => $threatLevels,
'default' => $event['Event']['threat_level_id'],
'label' => __("Threat Level")
),
array(
'field' => 'analysis',
'class' => 'input',
'options' => $analysisLevels,
'default' => $event['Event']['analysis']
),
array(
'field' => 'info',
'label' => __('Event Info'),
'class' => 'input-xxlarge',
'type' => 'text',
'placeholder' => __('Quick Event Description or Tracking Info')
),
array(
'field' => 'extends_uuid',
'class' => 'input-xxlarge',
'placeholder' => __('Event UUID or ID. Leave blank if not applicable.'),
'label' => __("Extends Event")
)
),
'submit' => array(
'action' => $this->request->params['action']
)
)
));
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'editEvent', 'mayModify' => $mayModify, 'mayPublish' => $mayPublish));
?>
<script type="text/javascript">
$('#EventDistribution').change(function() {
checkSharingGroup('Event');
});
$("#EventExtendsUuid").keyup(function() {
previewEventBasedOnUuids();
});
$(document).ready(function() {
checkSharingGroup('Event');
previewEventBasedOnUuids();
});
</script>
<?php echo $this->Js->writeBuffer();