-
Notifications
You must be signed in to change notification settings - Fork 17
Added the localized custom delete message functionality with params #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please renamde |
||
| if (window.confirm(dialogMessage)) { | ||
| scope.$eval(clickAction); | ||
| } | ||
| } | ||
|
|
||
| catI18nService.translate(msg, params).then( | ||
| function (message) { | ||
| dialog(message); | ||
| }, function (reason) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't provide unused parameters |
||
| dialog(msg); | ||
| } | ||
| ); | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where does catConfirmDeleteMessage come from? |
||
| 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> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$globalMessagesis undefined, please check travis build (or local gulp build)