mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
Closes #125: Confirmation before deleting a comment
This commit is contained in:
parent
3274b4c79a
commit
dcc7fe55f4
@ -23,7 +23,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
*/
|
*/
|
||||||
$scope.comment = '';
|
$scope.comment = '';
|
||||||
$scope.addComment = function() {
|
$scope.addComment = function() {
|
||||||
if ($scope.comment.length == 0) {
|
if ($scope.comment.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +40,19 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
* Delete a comment.
|
* Delete a comment.
|
||||||
*/
|
*/
|
||||||
$scope.deleteComment = function(comment) {
|
$scope.deleteComment = function(comment) {
|
||||||
Restangular.one('comment', comment.id).remove().then(function() {
|
var title = 'Delete comment';
|
||||||
$scope.comments.splice($scope.comments.indexOf(comment), 1);
|
var msg = 'Do you really want to delete this comment?';
|
||||||
|
var btns = [
|
||||||
|
{result: 'cancel', label: 'Cancel'},
|
||||||
|
{result: 'ok', label: 'OK', cssClass: 'btn-primary'}
|
||||||
|
];
|
||||||
|
|
||||||
|
$dialog.messageBox(title, msg, btns, function (result) {
|
||||||
|
if (result === 'ok') {
|
||||||
|
Restangular.one('comment', comment.id).remove().then(function() {
|
||||||
|
$scope.comments.splice($scope.comments.indexOf(comment), 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,7 +68,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
];
|
];
|
||||||
|
|
||||||
$dialog.messageBox(title, msg, btns, function (result) {
|
$dialog.messageBox(title, msg, btns, function (result) {
|
||||||
if (result == 'ok') {
|
if (result === 'ok') {
|
||||||
Restangular.one('document', document.id).remove().then(function() {
|
Restangular.one('document', document.id).remove().then(function() {
|
||||||
$scope.loadDocuments();
|
$scope.loadDocuments();
|
||||||
$state.go('document.default');
|
$state.go('document.default');
|
||||||
@ -74,7 +85,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
templateUrl: 'partial/docs/document.share.html',
|
templateUrl: 'partial/docs/document.share.html',
|
||||||
controller: 'DocumentModalShare'
|
controller: 'DocumentModalShare'
|
||||||
}).result.then(function (name) {
|
}).result.then(function (name) {
|
||||||
if (name == null) {
|
if (name === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,11 +119,11 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
];
|
];
|
||||||
|
|
||||||
$dialog.messageBox(title, msg, btns, function (result) {
|
$dialog.messageBox(title, msg, btns, function (result) {
|
||||||
if (result == 'unshare') {
|
if (result === 'unshare') {
|
||||||
// Unshare this document and update the local shares
|
// Unshare this document and update the local shares
|
||||||
Restangular.one('share', share.id).remove().then(function () {
|
Restangular.one('share', share.id).remove().then(function () {
|
||||||
$scope.document.acls = _.reject($scope.document.acls, function(s) {
|
$scope.document.acls = _.reject($scope.document.acls, function(s) {
|
||||||
return share.id == s.id;
|
return share.id === s.id;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user