Implements a validation for empty titles input at the side bar
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
This commit is contained in:
committed by
Julius Härtl
parent
d17cd78605
commit
df43e07057
@@ -26,6 +26,7 @@ import app from '../app/App.js';
|
||||
app.controller('CardController', function ($scope, $rootScope, $sce, $location, $stateParams, $state, $interval, $timeout, $filter, BoardService, CardService, StackService, StatusService, markdownItConverter, FileService) {
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
$scope.status = {
|
||||
renameTitle: '',
|
||||
lastEdit: 0,
|
||||
lastSave: Date.now()
|
||||
};
|
||||
@@ -89,9 +90,10 @@ app.controller('CardController', function ($scope, $rootScope, $sce, $location,
|
||||
});
|
||||
|
||||
$scope.cardRenameShow = function () {
|
||||
if ($scope.archived || !BoardService.canEdit())
|
||||
{return false;}
|
||||
else {
|
||||
if ($scope.archived || !BoardService.canEdit()) {
|
||||
return false;
|
||||
} else {
|
||||
$scope.status.renameTitle = CardService.getCurrent().title;
|
||||
$scope.status.cardRename = true;
|
||||
}
|
||||
};
|
||||
@@ -167,9 +169,27 @@ app.controller('CardController', function ($scope, $rootScope, $sce, $location,
|
||||
|
||||
// handle rename to update information on the board as well
|
||||
$scope.cardRename = function (card) {
|
||||
CardService.rename(card).then(function (data) {
|
||||
var newTitle;
|
||||
if (!$scope.status.renameTitle || !$scope.status.renameTitle.trim()) {
|
||||
newTitle = '';
|
||||
} else {
|
||||
newTitle = $scope.status.renameTitle.trim();
|
||||
}
|
||||
|
||||
if (newTitle === card.title) {
|
||||
// title unchanged
|
||||
$scope.status.renameCard = false;
|
||||
});
|
||||
} else if (newTitle !== '') {
|
||||
// title changed
|
||||
card.title = newTitle;
|
||||
CardService.rename(card).then(function (data) {
|
||||
$scope.status.renameCard = false;
|
||||
});
|
||||
} else {
|
||||
// empty title
|
||||
$scope.status.renameTitle = card.title;
|
||||
$scope.status.renameCard = false;
|
||||
}
|
||||
};
|
||||
$scope.cardUpdate = function (card) {
|
||||
CardService.update(card).then(function (data) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<!-- TODO: change to textarea elastic //-->
|
||||
<form ng-submit="cardRename(cardservice.getCurrent())">
|
||||
<input class="input-inline" type="text" ng-if="status.cardRename"
|
||||
ng-model="cardservice.getCurrent().title"
|
||||
ng-model="status.renameTitle"
|
||||
ng-blur="cardRename(cardservice.getCurrent())"
|
||||
autofocus-on-insert required maxlength="100">
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user