fix: [UI] Empty form

pull/8299/head
Jakub Onderka 2022-04-25 10:31:39 +02:00
parent 270080bce4
commit 51a2ec92f3
3 changed files with 33 additions and 40 deletions

View File

@ -547,17 +547,17 @@ class GalaxyClustersController extends AppController
public function detach($target_id, $target_type, $tag_id)
{
if ($this->request->is("ajax") && $this->request->is("get")) {
$this->set("url", $this->request->url);
return $this->render("/Elements/emtpyForm", false);
if ($this->request->is('ajax') && $this->request->is('get')) {
$this->set('url', Router::url());
return $this->render('/Elements/emptyForm', false);
}
$this->request->allowMethod(["post"]);
$this->request->allowMethod(['post']);
try {
$this->GalaxyCluster->Galaxy->detachClusterByTagId($this->Auth->user(), $target_id, $target_type, $tag_id);
} catch (NotFoundException $e) {
if (!$this->request->is("ajax")) {
if (!$this->request->is('ajax')) {
$this->Flash->error($e->getMessage());
} else {
throw $e;
@ -566,8 +566,8 @@ class GalaxyClustersController extends AppController
$message = __('Galaxy successfully detached.');
if ($this->request->is("ajax")) {
return $this->RestResponse->viewData(["saved" => true, "check_publish" => true, "success" => $message], "json");
if ($this->request->is('ajax')) {
return $this->RestResponse->viewData(['saved' => true, 'check_publish' => true, 'success' => $message], 'json');
}
$this->Flash->success($message);

View File

@ -547,7 +547,7 @@ class Galaxy extends AppModel
/**
* @param array $user
* @param int $targetId
* @param string $targetType
* @param string $targetType Can be 'attribute', 'event' or 'tag_collection'
* @param int $tagId
* @return void
* @throws Exception
@ -567,20 +567,20 @@ class Galaxy extends AppModel
} elseif ($targetType === 'event') {
$event_id = $targetId;
} elseif ($targetType !== 'tag_collection') {
throw new NotFoundException('Invalid options');
throw new InvalidArgumentException('Invalid target type');
}
if ($targetType === 'tag_collection') {
$tag_collection = $this->GalaxyCluster->Tag->TagCollectionTag->TagCollection->fetchTagCollection($user, array(
'conditions' => array('TagCollection.id' => $targetId),
'recusive' => -1,
'recursive' => -1,
));
if (empty($tag_collection)) {
throw new NotFoundException('Invalid Tag Collection');
}
$tag_collection = $tag_collection[0];
if (!$user["Role"]["perm_site_admin"]) {
if (!$user["Role"]['perm_tag_editor'] || $user['org_id'] !== $tag_collection['TagCollection']['org_id']) {
if (!$user['Role']['perm_site_admin']) {
if (!$user['Role']['perm_tag_editor'] || $user['org_id'] !== $tag_collection['TagCollection']['org_id']) {
throw new NotFoundException('Invalid Tag Collection');
}
}
@ -589,8 +589,8 @@ class Galaxy extends AppModel
if (empty($event)) {
throw new NotFoundException('Invalid Event.');
}
if (!$user["Role"]["perm_site_admin"] && !$user["Role"]['perm_sync']) {
if (!$user["Role"]['perm_tagger'] || ($user['org_id'] !== $event['Event']['org_id'] && $user['org_id'] !== $event['Event']['orgc_id'])) {
if (!$user['Role']['perm_site_admin'] && !$user['Role']['perm_sync']) {
if (!$user['Role']['perm_tagger'] || ($user['org_id'] !== $event['Event']['org_id'] && $user['org_id'] !== $event['Event']['orgc_id'])) {
throw new NotFoundException('Invalid Event.');
}
}
@ -625,7 +625,7 @@ class Galaxy extends AppModel
'conditions' => array('GalaxyCluster.tag_name' => $existingTargetTag['Tag']['name'])
));
if (empty($cluster)) {
throw new NotFoundException("Tag is not cluster");
throw new NotFoundException('Tag is not cluster');
}
if ($targetType === 'event') {

View File

@ -5,7 +5,7 @@
$searchUrl = '/events/index/searchtag:';
switch ($scope) {
case 'event':
$id = h($event['Event']['id']);
$id = intval($event['Event']['id']);
if (!empty($missingTaxonomies)) {
echo __(
'Missing taxonomies: <span class="red bold">%s</span><br>',
@ -32,7 +32,7 @@
if (empty($tag['Tag']['colour'])) {
$tag['Tag']['colour'] = '#0088cc';
}
$aStyle = 'background-color:' . h($tag['Tag']['colour']) . ';color:' . $this->TextColour->getTextColour($tag['Tag']['colour']) . ';';
$aStyle = 'background-color:' . h($tag['Tag']['colour']) . ';color:' . $this->TextColour->getTextColour($tag['Tag']['colour']);
$aClass = 'tag nowrap';
$aText = trim($tag['Tag']['name']);
$aTextModified = null;
@ -65,16 +65,11 @@
if (!empty($tag['Tag']['id'])) {
$span_tag = sprintf(
'<a href="%s" style="%s" class="%s"%s data-tag-id="%s">%s</a>',
sprintf(
'%s%s%s',
$baseurl,
$searchUrl,
h($tag['Tag']['id'])
),
$baseurl . $searchUrl . intval($tag['Tag']['id']),
$aStyle,
$aClass,
isset($aTextModified) ? ' title="' . $aText . '"' : '',
h($tag['Tag']['id']),
intval($tag['Tag']['id']),
isset($aTextModified) ? $aTextModified : $aText
);
} else {
@ -95,10 +90,10 @@
"0",
__('Remove tag %s', h($tag['Tag']['name'])),
sprintf(
"removeObjectTagPopup(this, '%s', '%s', '%s')",
"removeObjectTagPopup(this, '%s', %s, %s)",
$scope,
$id,
h($tag['Tag']['id'])
intval($tag['Tag']['id'])
)
);
}
@ -132,35 +127,33 @@
'<span class="tag-list-container">%s</span>',
$tagData
);
$tagConflictData = '';
if (!empty($tagConflicts['global'])) {
$tagConflictData .= '<div><div class="alert alert-error tag-conflict-notice">';
$tagConflictData .= '<i class="fas fa-globe-americas icon"></i>';
$tagConflictData .= '<div class="text-container">';
echo '<div><div class="alert alert-error tag-conflict-notice">';
echo '<i class="fas fa-globe-americas icon"></i>';
echo '<div class="text-container">';
foreach ($tagConflicts['global'] as $tagConflict) {
$tagConflictData .= sprintf(
echo sprintf(
'<strong>%s</strong><br>',
h($tagConflict['conflict'])
);
foreach ($tagConflict['tags'] as $tag) {
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
echo sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
}
}
$tagConflictData .= '</div></div></span>';
echo '</div></div></span>';
}
if (!empty($tagConflicts['local'])) {
$tagConflictData .= '<div><div class="alert alert-error tag-conflict-notice">';
$tagConflictData .= '<i class="fas fa-user icon"></i>';
$tagConflictData .= '<div class="text-container">';
echo '<div><div class="alert alert-error tag-conflict-notice">';
echo '<i class="fas fa-user icon"></i>';
echo '<div class="text-container">';
foreach ($tagConflicts['local'] as $tagConflict) {
$tagConflictData .= sprintf(
echo sprintf(
'<strong>%s</strong><br>',
h($tagConflict['conflict'])
);
foreach ($tagConflict['tags'] as $tag) {
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
echo sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
}
}
$tagConflictData .= '</div></div></span>';
echo '</div></div></span>';
}
echo $tagConflictData;