Merge pull request #814 from nextcloud/issue586
Prevent duplicate tag names
This commit is contained in:
@@ -346,11 +346,21 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
|||||||
BoardService.getCurrent().labels.push(data);
|
BoardService.getCurrent().labels.push(data);
|
||||||
$scope.status.createLabel = false;
|
$scope.status.createLabel = false;
|
||||||
$scope.newLabel = {};
|
$scope.newLabel = {};
|
||||||
|
}).catch((err) => {
|
||||||
|
OC.Notification.showTemporary(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.labelUpdateBefore = function (label) {
|
||||||
|
label.renameTitle = label.title;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.labelUpdate = function (label) {
|
$scope.labelUpdate = function (label) {
|
||||||
label.edit = false;
|
label.edit = false;
|
||||||
LabelService.update(label);
|
LabelService.update(label).catch((err) => {
|
||||||
|
label.title = label.renameTitle;
|
||||||
|
OC.Notification.showTemporary(err);
|
||||||
|
});
|
||||||
|
|
||||||
// update labels in UI
|
// update labels in UI
|
||||||
var cards = CardService.data;
|
var cards = CardService.data;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ app.factory('ApiService', function ($http, $q) {
|
|||||||
self.add(response.data);
|
self.add(response.data);
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Fetching' + self.endpoint + ' failed');
|
deferred.reject(error.data.message);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
@@ -131,7 +131,7 @@ app.factory('ApiService', function ($http, $q) {
|
|||||||
self.add(response.data);
|
self.add(response.data);
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Updating ' + self.endpoint + ' failed');
|
deferred.reject(error.data.message);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,17 @@ class LabelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
||||||
|
|
||||||
|
$boardLabels = $this->labelMapper->findAll($boardId);
|
||||||
|
if (\is_array($boardLabels)) {
|
||||||
|
foreach($boardLabels as $boardLabel) {
|
||||||
|
if ($boardLabel->getTitle() === $title) {
|
||||||
|
throw new BadRequestException('title must be unique');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->boardService->isArchived(null, $boardId)) {
|
if ($this->boardService->isArchived(null, $boardId)) {
|
||||||
throw new StatusException('Operation not allowed. This board is archived.');
|
throw new StatusException('Operation not allowed. This board is archived.');
|
||||||
}
|
}
|
||||||
@@ -143,7 +154,7 @@ class LabelService {
|
|||||||
throw new BadRequestException('label id must be a number');
|
throw new BadRequestException('label id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($title === false || $title === null) {
|
if ($title === false || $title === null || $title === "") {
|
||||||
throw new BadRequestException('title must be provided');
|
throw new BadRequestException('title must be provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +163,26 @@ class LabelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
|
|
||||||
|
$label = $this->find($id);
|
||||||
|
|
||||||
|
$boardLabels = $this->labelMapper->findAll($label->getBoardId());
|
||||||
|
if (\is_array($boardLabels)) {
|
||||||
|
foreach($boardLabels as $boardLabel) {
|
||||||
|
if ($boardLabel->getId() === $label->getId()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($boardLabel->getTitle() === $title) {
|
||||||
|
throw new BadRequestException('title must be unique');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
||||||
throw new StatusException('Operation not allowed. This board is archived.');
|
throw new StatusException('Operation not allowed. This board is archived.');
|
||||||
}
|
}
|
||||||
$label = $this->find($id);
|
|
||||||
$label->setTitle($title);
|
$label->setTitle($title);
|
||||||
$label->setColor($color);
|
$label->setColor($color);
|
||||||
$this->changeHelper->boardChanged($label->getBoardId());
|
$this->changeHelper->boardChanged($label->getBoardId());
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a ng-if="boardservice.canManage() && label.edit" ng-click="labelUpdate(label)" class="icon" title="<?php p($l->t('Update tag')); ?>"><i class="icon icon-checkmark" ></i><span class="hidden-visually"><?php p($l->t('Update tag')); ?></span></a>
|
<a ng-if="boardservice.canManage() && label.edit" ng-click="labelUpdate(label)" class="icon" title="<?php p($l->t('Update tag')); ?>"><i class="icon icon-checkmark" ></i><span class="hidden-visually"><?php p($l->t('Update tag')); ?></span></a>
|
||||||
<a ng-if="boardservice.canManage() && !label.edit" ng-click="label.edit=true" class="icon" title="<?php p($l->t('Edit tag')); ?>"><i class="icon icon-rename"></i><span class="hidden-visually"><?php p($l->t('Edit tag')); ?></span></a>
|
<a ng-if="boardservice.canManage() && !label.edit" ng-click="labelUpdateBefore(label); label.edit=true" class="icon" title="<?php p($l->t('Edit tag')); ?>"><i class="icon icon-rename"></i><span class="hidden-visually"><?php p($l->t('Edit tag')); ?></span></a>
|
||||||
<a ng-if="boardservice.canManage()" ng-click="labelDelete(label)" class="icon" title="<?php p($l->t('Delete tag')); ?>"><i class="icon icon-delete" ></i><span class="hidden-visually"><?php p($l->t('Delete tag')); ?></span></a>
|
<a ng-if="boardservice.canManage()" ng-click="labelDelete(label)" class="icon" title="<?php p($l->t('Delete tag')); ?>"><i class="icon icon-delete" ></i><span class="hidden-visually"><?php p($l->t('Delete tag')); ?></span></a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-if="status.createLabel">
|
<li ng-if="status.createLabel">
|
||||||
|
|||||||
Reference in New Issue
Block a user