Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/javascript/controller/cat-base-list-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ function CatBaseListController($scope, $state, $controller, $log, catBreadcrumbs
return this.getUrlForId('new');
};

this.remove = function (id) {
this.remove = function (id, message) {
message = message || 'Successfully deleted entry.';
config.listData.endpoint.remove(id)
.then(function () {
$globalMessages.addMessage('success', message, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$globalMessages is undefined, please check travis build (or local gulp build)

catListDataLoadingService.load(config.listData.endpoint, config.listData.searchRequest).then(
function (data) {
_.assign($scope.listData, data);
Expand Down
21 changes: 18 additions & 3 deletions src/main/javascript/directives/cat-confirm-click.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
/**
* @ngdoc directive
* @name cat.directives.confirmClick:catConfirmClick
* @cat-i18n-params cat-i18n-params will be parsed as an angular expression. $parse constructs a function which I call to return the i18n params.
*/
angular.module('cat.directives.confirmClick', [])
.directive('catConfirmClick', function CatConfirmClickDirective() {
.directive('catConfirmClick', function CatConfirmClickDirective(catI18nService, $parse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the array notation

.directive('catConfirmClick', [
    'catI18nService',
    '$parse',
    function CatConfirmClickDirective(catI18nService, $parse) { /*...*/}
])

return {
restrict: 'A',
link: function CatConfirmClickLink(scope, element, attr) {
var msg = attr.catConfirmClick || 'Are you sure?';
var clickAction = attr.catOnConfirm;
var params = undefined;
if (!!attr.catI18nParams) {
params = $parse(attr.catI18nParams)();
}
element.bind('click', function (event) {
if (window.confirm(msg)) {
scope.$eval(clickAction);
function dialog(dialogMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please renamde dialog to something more specific like showConfirmationDialog or similar

if (window.confirm(dialogMessage)) {
scope.$eval(clickAction);
}
}

catI18nService.translate(msg, params).then(
function (message) {
dialog(message);
}, function (reason) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't provide unused parameters

dialog(msg);
}
);
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/template/cat-base-detail.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="panel-heading">
<div class="pull-right edit-buttons" ng-if="!editDetail && !!editTemplate">
<div class="btn-group">
<button type="button" class="btn btn-xs btn-default" cat-confirm-click cat-on-confirm="remove()"
<button type="button" class="btn btn-xs btn-default" cat-confirm-click="{{catConfirmDeleteMessage}}" cat-on-confirm="remove()"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does catConfirmDeleteMessage come from?
as far as i can see it will always be empty by default, and doe to the fact that we only access the attributes, the confirm message now will defualt to {{catConfirmDeleteMessage}} (unevaluated) and the real fallback 'Are you sure?' will never be used

cat-element-visible="cat.base.delete" cat-element-data="config">
<span cat-icon="remove" size="xs"></span>
<span cat-i18n="cc.catalysts.general.delete">Delete</span>
Expand Down