fix: Fixes to several issues with the template editor, fixes #2387, fixes #2388

pull/2389/head
iglocska 2017-08-10 10:39:19 +02:00
parent 3bec45dafa
commit 010260fbce
3 changed files with 3 additions and 4 deletions

View File

@ -115,7 +115,7 @@ class TemplateElementsController extends AppController {
$this->request->data[$ModelType]['template_element_id'] = $this->TemplateElement->id;
$this->TemplateElement->$ModelType->create();
if ($this->TemplateElement->$ModelType->save($this->request->data)) {
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Element successfully added to template.')), 'status' => 200));
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Element successfully added to template.')), 'status' => 200, 'type' => 'json'));
} else {
$this->TemplateElement->delete($this->TemplateElement->id);
$errorMessage = $this->TemplateElement->$ModelType->validationErrors;
@ -135,7 +135,6 @@ class TemplateElementsController extends AppController {
));
$this->set('template_id', $templateElement['Template']['id']);
if (!$this->_isSiteAdmin() && !$this->TemplateElement->Template->checkAuthorisation($id, $this->Auth->user(), true)) return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => 'You are not authorised to do that.')), 'status' => 200, 'type' => 'json'));
if (!$this->request->is('ajax')) Throw new MethodNotAllowedException('This action is for ajax requests only.');
if ($this->request->is('get')) {
$this->set('id', $id);

View File

@ -1,6 +1,6 @@
<div class="template_element_add_text">
<?php
echo $this->Form->create('TemplateElementText', array('id', 'url' => '/templateElements/add/text/' . $id));
echo $this->Form->create('TemplateElementText', array('url' => '/templateElements/add/text/' . $id));
?>
<legend><?php echo __('Add Text Element To Template'); ?></legend>
<fieldset>

View File

@ -83,7 +83,7 @@
<table>
<tr>
<td style="vertical-align:top">
<span aria-label="Submit attribute element changes" title="Submit attribute element changes" class="btn btn-primary" onClick="return submitPopoverForm('<?php echo $id;?>', 'editAttributeElement', '<?php echo $template_id; ?>')">Submit</span>
<span id="submitButton" aria-label="Submit attribute element changes" title="Submit attribute element changes" class="btn btn-primary" onClick="return submitPopoverForm('<?php echo $id;?>', 'editAttributeElement', '<?php echo $template_id; ?>')">Submit</span>
</td>
<td style="width:540px;">
<p style="color:red;font-weight:bold;display:none;text-align:center" id="warning-message">Warning: You are about to share data that is of a classified nature (Attribution / targeting data). Make sure that you are authorised to share this.</p>