Adding confirm-link directive

This commit is contained in:
Rob Harrington
2015-11-12 09:49:36 +11:00
parent b5aaf36bd2
commit 5a7cac652c
2 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
# Used on a link to prevent link clicks unless a callback returns true (probably asking for user confirmation)
angular.module("admin.lineItems").directive "confirmLinkClick", ->
restrict: "A"
scope:
confirmLinkClick: "&"
link: (scope, element, attrs) ->
element.bind "click", (event) ->
unless scope.confirmLinkClick()
event.preventDefault()

View File

@@ -153,7 +153,7 @@
%td.price{ 'ng-show' => 'columns.price.visible' }
%input{ :type => 'text', :name => 'price', :id => 'price', :value => '{{ line_item.price * line_item.quantity | currency }}', 'ng-readonly' => "true", 'obj-for-update' => "line_item", "attr-for-update" => "price" }
%td.actions
%a{ :class => "edit-order icon-edit no-text", 'ofn-confirm-link-path' => "/admin/orders/{{line_item.order.number}}/edit" }
%a{ href: "/admin/orders/{{line_item.order.number}}/edit", :class => "edit-order icon-edit no-text", 'confirm-link-click' => 'confirmRefresh()' }
%td.actions
%a{ 'ng-click' => "deleteLineItem(line_item)", :class => "delete-line-item icon-trash no-text" }
%input{ :type => "button", 'value' => 'Update', 'ng-click' => 'submit()' }