-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bhReceipt): implement receipt component
This commit implements a receipt-rendering component that opens the receipt modal when a link is clicked. It supports three values: 1. value - the ID or UUID for the receipt 2. displayValue - whatever you would like to show. 3. type - a string denoting what kind of receipt it is. A prototype implementation is found on the cash registry page. I thought there was an issue for this, but cannot find it.
- Loading branch information
Showing
3 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var bhReceiptTemplate = | ||
'<a ng-click="$ctrl.open()" href="">{{ $ctrl.displayValue }}</a>'; | ||
|
||
angular.module('bhima.components') | ||
.component('bhReceipt', { | ||
template : bhReceiptTemplate, | ||
controller : bhReceiptController, | ||
bindings : { | ||
value : '<', | ||
displayValue : '<', | ||
type : '@', | ||
}, | ||
}); | ||
|
||
bhReceiptController.$inject = ['ReceiptModal', '$log']; | ||
|
||
function bhReceiptController(ReceiptModal, $log) { | ||
var $ctrl = this; | ||
|
||
$ctrl.$onInit = function $onInit() { | ||
// make sure the receipt type exists before it is clicked | ||
var hasCallbackFn = ReceiptModal[$ctrl.type]; | ||
if (!hasCallbackFn) { | ||
$log.warn('Warning: Cannot find ' | ||
.concat($ctrl.type) | ||
.concat(' in ReceiptModalService.')); | ||
} | ||
}; | ||
|
||
$ctrl.open = function open() { | ||
ReceiptModal[$ctrl.type]($ctrl.value); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
<div class="ui-grid-cell-contents text-action"> | ||
<a ng-click="grid.appScope.openReceiptModal(row.entity.uuid)" href> | ||
{{ row.entity.reference }} | ||
</a> | ||
<div class="ui-grid-cell-contents"> | ||
<bh-receipt value="row.entity.uuid" display-value="row.entity.reference" type="cash"> | ||
</div> |