mirror of https://github.com/MISP/MISP
Fixed adding / removing tags to a template, fixes #898
parent
b8591674ef
commit
07a03abdc7
|
@ -49,7 +49,6 @@ class TemplatesController extends AppController {
|
|||
|
||||
if ($this->request->is('post') || $this->request->is('put')) {
|
||||
$this->request->data['Template']['id'] = $id;
|
||||
|
||||
unset($this->request->data['Template']['tagsPusher']);
|
||||
$tags = $this->request->data['Template']['tags'];
|
||||
unset($this->request->data['Template']['tags']);
|
||||
|
@ -67,7 +66,7 @@ class TemplatesController extends AppController {
|
|||
|
||||
$newTags = $this->TemplateTag->Tag->find('all', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('name' => $tagArray)
|
||||
'conditions' => array('id' => $tagArray)
|
||||
));
|
||||
|
||||
foreach($oldTags as $k => $oT) {
|
||||
|
@ -147,7 +146,7 @@ class TemplatesController extends AppController {
|
|||
$this->loadModel('Tag');
|
||||
foreach ($tagArray as $t) {
|
||||
$tag = $this->Tag->find('first', array(
|
||||
'conditions' => array('name' => $t),
|
||||
'conditions' => array('id' => $t),
|
||||
'fields' => array('id', 'name'),
|
||||
'recursive' => -1,
|
||||
));
|
||||
|
|
|
@ -56,7 +56,7 @@ var selectedTags = [
|
|||
<?php
|
||||
foreach ($currentTags as $k => $t) {
|
||||
if ($k != 0) echo ', ';
|
||||
echo '"' . $t['Tag']['name'] . '"';
|
||||
echo '"' . $t['Tag']['id'] . '"';
|
||||
}
|
||||
?>
|
||||
];
|
||||
|
|
|
@ -720,26 +720,38 @@ function cancelPopoverForm() {
|
|||
$('#popover_form').fadeOut();
|
||||
}
|
||||
|
||||
function activateTagField() {
|
||||
$("#addTagButton").hide();
|
||||
$("#addTagField").show();
|
||||
}
|
||||
|
||||
function appendTemplateTag(selected) {
|
||||
var selectedTag;
|
||||
allTags.forEach(function(tag) {
|
||||
if (tag.name == selected) {
|
||||
$.ajax({
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
$(".loading").show();
|
||||
},
|
||||
dataType:"html",
|
||||
cache: false,
|
||||
success:function (data, textStatus) {
|
||||
$(".loading").hide();
|
||||
$("#tags").append(data);
|
||||
},
|
||||
url:"/tags/viewTag/" + tag.id,
|
||||
});
|
||||
updateSelectedTags();
|
||||
function tagFieldChange() {
|
||||
if ($("#addTagField :selected").val() > 0) {
|
||||
var selected_id = $("#addTagField :selected").val();
|
||||
var selected_text = $("#addTagField :selected").text();
|
||||
if ($.inArray(selected_id, selectedTags)==-1) {
|
||||
selectedTags.push(selected_id);
|
||||
appendTemplateTag(selected_id);
|
||||
}
|
||||
}
|
||||
$("#addTagButton").show();
|
||||
$("#addTagField").hide();
|
||||
}
|
||||
|
||||
function appendTemplateTag(selected_id) {
|
||||
$.ajax({
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
$(".loading").show();
|
||||
},
|
||||
dataType:"html",
|
||||
cache: false,
|
||||
success:function (data, textStatus) {
|
||||
$(".loading").hide();
|
||||
$("#tags").append(data);
|
||||
},
|
||||
url:"/tags/viewTag/" + selected_id,
|
||||
});
|
||||
updateSelectedTags();
|
||||
}
|
||||
|
||||
function addAllTags(tagArray) {
|
||||
|
@ -751,8 +763,8 @@ function addAllTags(tagArray) {
|
|||
|
||||
function removeTemplateTag(id, name) {
|
||||
selectedTags.forEach(function(tag) {
|
||||
if (tag == name) {
|
||||
var index = selectedTags.indexOf(name);
|
||||
if (tag == id) {
|
||||
var index = selectedTags.indexOf(id);
|
||||
if (index > -1) {
|
||||
selectedTags.splice(index, 1);
|
||||
updateSelectedTags();
|
||||
|
@ -2187,3 +2199,4 @@ function mergeOrganisationTypeToggle() {
|
|||
$('#orgsExternal').show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue