Created
November 26, 2016 12:07
-
-
Save nriesco/6c3f43deccf89f45c17a8c08d85a6725 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Component from 'can/component/'; | |
import Map from 'can/map/'; | |
import 'can/map/define/'; | |
import './purchaseOrderDetails.less!'; | |
import DisplayPurchaseOrderItems from '../models/displayPurchaseOrderItems'; | |
import template from './purchaseOrderDetails.stache!'; | |
export const ViewModel = Map.extend({ | |
define: { | |
displayPurchaseOrderItemsPromise: { | |
get: function() { | |
return DisplayPurchaseOrderItems.getList({ purchaseOrderId: this.attr('purchaseOrderId') }); | |
}, | |
}, | |
}, | |
purchaseOrderId: '', | |
removeItem: function(item) { | |
console.log('remove me!', this, item); | |
if (confirm('sure?')) { | |
console.log('about to remove itemid', item._id); | |
console.log('about to remove itemid', item); | |
item.destroy() | |
.then(function(result) { | |
console.log('the item has been destroyed:', result); | |
}, function(err) { | |
console.log('An error ocurred while removing this item:', err); | |
}); | |
} else { | |
// action was cancelled | |
} | |
} | |
}); | |
export default Component.extend({ | |
tag: 'purchase-order-details', | |
viewModel: ViewModel, | |
template | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment