This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work for #75
- Loading branch information
Showing
13 changed files
with
315 additions
and
48 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
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller'; | ||
import InventorySelection from 'hospitalrun/mixins/inventory-selection'; | ||
import Ember from 'ember'; | ||
|
||
export default AbstractEditController.extend(InventorySelection, { | ||
needs: ['inventory','pouchdb'], | ||
|
||
warehouseList: Ember.computed.alias('controllers.inventory.warehouseList'), | ||
aisleLocationList: Ember.computed.alias('controllers.inventory.aisleLocationList'), | ||
|
||
|
||
inventoryList: function() { | ||
var inventoryItems = this.get('inventoryItems'); | ||
if (!Ember.isEmpty(inventoryItems)) { | ||
var mappedItems = inventoryItems.map(function(item) { | ||
return item.doc; | ||
}); | ||
return mappedItems; | ||
} | ||
}.property('inventoryItems.[]'), | ||
|
||
lookupListsToUpdate: [{ | ||
name: 'aisleLocationList', //Name of property containing lookup list | ||
property: 'deliveryAisle', //Corresponding property on model that potentially contains a new value to add to the list | ||
id: 'aisle_location_list' //Id of the lookup list to update | ||
}, { | ||
name: 'warehouseList', //Name of property containing lookup list | ||
property: 'deliveryLocation', //Corresponding property on model that potentially contains a new value to add to the list | ||
id: 'warehouse_list' //Id of the lookup list to update | ||
}], | ||
|
||
|
||
showInvoiceItems: function() { | ||
var invoiceItems = this.get('invoiceItems'); | ||
return !Ember.isEmpty(invoiceItems); | ||
}.property('invoiceItems.@each'), | ||
|
||
updateCapability: 'add_inventory_item', | ||
|
||
_addNewInventoryItem: function() { | ||
var inventoryItem = this.store.createRecord('inventory', { | ||
name: this.get('inventoryItemTypeAhead'), | ||
quantity: this.get('quantity') | ||
}); | ||
this.send('openModal', 'inventory.quick-add', inventoryItem); | ||
}, | ||
|
||
_addInvoiceItem: function() { | ||
var inventoryItem = this.get('inventoryItem'), | ||
invoiceItems = this.get('invoiceItems'), | ||
purchaseCost = this.get('purchaseCost'), | ||
quantity = this.get('quantity'), | ||
vendorItemNo = this.get('vendorItemNo'), | ||
invoiceItem = Ember.Object.create({ | ||
item: inventoryItem, | ||
quantity: quantity, | ||
purchaseCost: purchaseCost, | ||
vendorItemNo: vendorItemNo | ||
}); | ||
invoiceItems.addObject(invoiceItem); | ||
this.set('inventoryItem'); | ||
this.set('inventoryItemTypeAhead'); | ||
this.set('purchaseCost'); | ||
this.set('quantity'); | ||
this.set('selectedInventoryItem'); | ||
this.set('vendorItemNo'); | ||
}, | ||
|
||
actions: { | ||
addInventoryItem: function() { | ||
var model = this.get('model'), | ||
inventoryItemTypeAhead = this.get('inventoryItemTypeAhead'), | ||
purchaseCost = this.get('purchaseCost'), | ||
quantity = this.get('quantity'); | ||
model.validate(); | ||
if (this.get('isValid') && !Ember.isEmpty(inventoryItemTypeAhead) && !Ember.isEmpty(quantity) && !Ember.isEmpty(purchaseCost)) { | ||
if (Ember.isEmpty(this.get('selectedInventoryItem'))) { | ||
this._addNewInventoryItem(); | ||
} else { | ||
this._addInvoiceItem(); | ||
} | ||
} | ||
}, | ||
|
||
addedNewInventoryItem: function(inventoryItem) { | ||
this.set('inventoryItem', inventoryItem); | ||
this._addInvoiceItem(); | ||
this.send('closeModal'); | ||
}, | ||
|
||
removeItem: function(removeInfo) { | ||
var invoiceItems = this.get('invoiceItems'), | ||
item = removeInfo.itemToRemove; | ||
invoiceItems.removeObject(item); | ||
this.send('closeModal'); | ||
}, | ||
|
||
showRemoveItem: function(item) { | ||
var message= 'Are you sure you want to remove this item from this invoice?', | ||
model = Ember.Object.create({ | ||
itemToRemove: item | ||
}), | ||
title = 'Remove Item'; | ||
this.displayConfirm(title, message, 'removeItem', model); | ||
}, | ||
} | ||
}); |
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,18 @@ | ||
import InventoryRequestRoute from 'hospitalrun/inventory/request/route'; | ||
import Ember from 'ember'; | ||
export default InventoryRequestRoute.extend({ | ||
editTitle: 'Invoice Received', | ||
modelName: 'inventory-invoice', | ||
newTitle: 'Invoice Received', | ||
getNewData: function() { | ||
return Ember.RSVP.resolve({ | ||
invoiceItems: [] | ||
}); | ||
}, | ||
|
||
actions: { | ||
addedNewInventoryItem: function(model) { | ||
this.controller.send('addedNewInventoryItem', model); | ||
} | ||
}, | ||
}); |
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,78 @@ | ||
{{#em-form model=this submit_button=false }} | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
{{em-input property="vendor" label="Vendor"}} | ||
</div> | ||
<div class="col-sm-6"> | ||
{{em-input property="invoiceNo" label="Invoice Number"}} | ||
</div> | ||
</div> | ||
<div class="row"> | ||
{{inventory-typeahead | ||
class="col-sm-4 required" | ||
property="inventoryItemTypeAhead" | ||
label="Inventory Item" | ||
content=inventoryList | ||
selection=selectedInventoryItem | ||
showQuantity=false | ||
}} | ||
{{em-input property="quantity" label="Quantity" class="col-sm-2 required"}} | ||
{{em-input property="purchaseCost" label="Purchase Cost" class="col-sm-2 required"}} | ||
{{em-input property="vendorItemNo" label="Vendor Item Number" class="col-sm-3"}} | ||
<div class="form-group col-sm-1"> | ||
<label class="control-label"></label> | ||
<h4 class="form-control-static"> | ||
<span class="glyphicon glyphicon-plus" {{action 'addInventoryItem'}}></span> | ||
</h4> | ||
</div> | ||
</div> | ||
<textarea> | ||
name | ||
quantity | ||
price | ||
item number | ||
|
||
Need for new item type | ||
Need to new item unit | ||
</textarea> | ||
{{#if invoiceItems}} | ||
<h3>Invoice Items</h3> | ||
<table class="table"> | ||
<tr class="table-header"> | ||
<th>Name</th> | ||
<th>Quantity</th> | ||
<th>Cost</th> | ||
<th>Item Number</th> | ||
<th>Action</th> | ||
</tr> | ||
{{#each invoiceItems}} | ||
<tr> | ||
<td class="col-sm-4"> | ||
{{item.name}} | ||
</td> | ||
<td class="col-sm-2"> | ||
<div class="form-group"> | ||
{{input class="form-control" value=quantity }} | ||
</div> | ||
</td> | ||
<td class="col-sm-2"> | ||
<div class="form-group"> | ||
{{input class="form-control" value=purchaseCost }} | ||
</div> | ||
</td> | ||
<td class="col-sm-3"> | ||
<div class="form-group"> | ||
{{input class="form-control" value=vendorItemNo }} | ||
</div> | ||
</td> | ||
<td class="col-sm-1"> | ||
<button class="btn btn-default warning" {{action "showRemoveItem" this bubbles=false }}> | ||
<span class="octicon octicon-x"></span>Remove | ||
</button> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</table> | ||
{{/if}} | ||
|
||
{{/em-form}} |
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,2 @@ | ||
import PanelView from 'hospitalrun/views/panel'; | ||
export default PanelView.extend(); |
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,16 @@ | ||
import InventoryEditController from 'hospitalrun/inventory/edit/controller'; | ||
export default InventoryEditController.extend({ | ||
title: 'New Inventory Item', | ||
|
||
updateCapability: 'add_inventory_item', | ||
|
||
actions: { | ||
cancel: function() { | ||
this.send('closeModal'); | ||
} | ||
}, | ||
|
||
afterUpdate: function(record) { | ||
this.send('addedNewInventoryItem', record); | ||
} | ||
}); |
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,3 @@ | ||
{{#em-form model=this submit_button=false }} | ||
{{partial 'inventory-basic'}} | ||
{{/em-form}} |
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,2 @@ | ||
import ModalView from 'hospitalrun/views/modal'; | ||
export default ModalView.extend(); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import AbstractModel from "hospitalrun/models/abstract"; | ||
import Ember from "ember"; | ||
|
||
/** | ||
* Model to represent a request for inventory items. | ||
*/ | ||
export default AbstractModel.extend({ | ||
|
||
haveInvoiceItems: function() { | ||
var invoiceItems = this.get('invoiceItems'); | ||
return (Ember.isEmpty(invoiceItems)); | ||
}, | ||
|
||
validations: { | ||
inventoryItemTypeAhead: { | ||
presence: { | ||
if: function(object) { | ||
return object.haveInvoiceItems(); | ||
} | ||
} | ||
}, | ||
purchaseCost: { | ||
numericality: { | ||
greaterThan: 0, | ||
if: function(object) { | ||
return object.haveInvoiceItems(); | ||
} | ||
} | ||
}, | ||
quantity: { | ||
numericality: { | ||
greaterThan: 0, | ||
if: function(object) { | ||
return object.haveInvoiceItems(); | ||
} | ||
} | ||
} | ||
} | ||
}); |
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
Oops, something went wrong.