Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial import for basic mobile UI served from web application * Added product list and details pages; improved dashboard and choose location pages; added library to detect barcode scans * Added improvements to mobile UI * Improvements for mobile UI * #437 Fixed a few issues with the basic mobile UI before merging * #437 Reverted changes to inventory snapshot page
- Loading branch information
Showing
18 changed files
with
583 additions
and
15 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
95 changes: 95 additions & 0 deletions
95
grails-app/controllers/org/pih/warehouse/MobileController.groovy
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,95 @@ | ||
/** | ||
* Copyright (c) 2012 Partners In Health. All rights reserved. | ||
* The use and distribution terms for this software are covered by the | ||
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | ||
* which can be found in the file epl-v10.html at the root of this distribution. | ||
* By using this software in any fashion, you are agreeing to be bound by | ||
* the terms of this license. | ||
* You must not remove this notice, or any other, from this software. | ||
**/ | ||
package org.pih.warehouse | ||
|
||
import org.pih.warehouse.core.Location | ||
import org.pih.warehouse.core.User | ||
import org.pih.warehouse.order.Order | ||
import org.pih.warehouse.order.OrderTypeCode | ||
import org.pih.warehouse.product.Product | ||
import org.pih.warehouse.product.ProductSummary | ||
import org.pih.warehouse.requisition.Requisition | ||
|
||
class MobileController { | ||
|
||
def userService | ||
def productService | ||
def inventoryService | ||
def locationService | ||
def megamenuService | ||
|
||
def index = { | ||
|
||
Location location = Location.get(session.warehouse.id) | ||
def productCount = ProductSummary.countByLocation(location) | ||
def productListUrl = g.createLink(controller: "mobile", action: "productList") | ||
|
||
def orderCount = Order.createCriteria().count { | ||
eq("destination", location) | ||
orderType { | ||
eq("orderTypeCode", OrderTypeCode.PURCHASE_ORDER) | ||
} | ||
} | ||
|
||
def requisitionCount = Requisition.createCriteria().count { | ||
eq("origin", location) | ||
} | ||
|
||
[ | ||
data: [ | ||
[name: "Inventory Items", class: "fa fa-box", count: productCount, url: g.createLink(controller: "mobile", action: "productList")], | ||
[name: "Purchase Orders", class: "fa fa-shopping-cart", count: orderCount, url: g.createLink(controller: "order", action: "list", params: ['origin.id', location.id])], | ||
[name: "Replenishment Orders", class: "fa fa-truck", count: requisitionCount, url: g.createLink(controller: "stockMovement", action: "list", params: ['origin.id', location.id])], | ||
] | ||
] | ||
} | ||
|
||
def login = { | ||
|
||
} | ||
|
||
def menu = { | ||
Map menuConfig = grailsApplication.config.openboxes.megamenu | ||
//User user = User.get(session?.user?.id) | ||
//Location location = Location.get(session.warehouse?.id) | ||
//List translatedMenu = megamenuService.buildAndTranslateMenu(menuConfig, user, location) | ||
[menuConfig:menuConfig] | ||
} | ||
|
||
def chooseLocation = { | ||
User user = User.get(session.user.id) | ||
Location warehouse = Location.get(session.warehouse.id) | ||
render (view: "/mobile/chooseLocation", | ||
model: [savedLocations: user.warehouse ? [user.warehouse] : null, loginLocationsMap: locationService.getLoginLocationsMap(user, warehouse)]) | ||
} | ||
|
||
def productList = { | ||
Location location = Location.get(session.warehouse.id) | ||
def terms = params?.q ? params?.q?.split(" ") : "".split(" ") | ||
def productSummaries = ProductSummary.createCriteria().list(max: params.max ?: 10, offset: params.offset ?: 0) { | ||
eq("location", location) | ||
order("product", "asc") | ||
} | ||
[productSummaries:productSummaries] | ||
} | ||
|
||
def productDetails = { | ||
Product product = Product.findByIdOrProductCode(params.id, params.id) | ||
Location location = Location.get(session.warehouse.id) | ||
def productSummary = ProductSummary.findByProductAndLocation(product, location) | ||
if (productSummary) { | ||
[productSummary: productSummary] | ||
} | ||
else { | ||
flash.message = "Product ${product.productCode} is not available in ${location.locationNumber}" | ||
redirect(action: "productList") | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
<body> | ||
|
||
</body> | ||
</html> | ||
</html> |
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,60 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" %> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title><g:layoutTitle default="OpenBoxes"/></title> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" | ||
crossorigin="anonymous"> | ||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" | ||
rel="stylesheet"/> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
<g:include controller="mobile" action="menu"/> | ||
<h1><g:layoutTitle/></h1> | ||
<g:layoutBody/> | ||
<script | ||
src="https://code.jquery.com/jquery-3.5.1.slim.min.js" | ||
integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/js/all.min.js"></script> | ||
<script src="/openboxes/js/onScan/onScan.min.js" type="text/javascript"></script> | ||
<script> | ||
$(document).ready(function() { | ||
// Enable scan events for the entire document | ||
console.log("initialize onScan"); | ||
onScan.attachTo(document, { | ||
minLength: 3, | ||
suffixKeyCodes: [13], // enter-key expected at the end of a scan | ||
//reactToPaste: true, // Compatibility to built-in scanners in paste-mode (as opposed to keyboard-mode) | ||
onScan: function(scanned, count) { | ||
console.log('Scanned: ', count, 'x ', scanned); | ||
alert("Scanned " + scanned) | ||
}, | ||
onKeyDetect: function(keyCode, event){ | ||
console.log('Pressed: ', keyCode, event); | ||
}, | ||
onScanError: function(obj) { | ||
console.log('onScanError: ', obj); | ||
}, | ||
onScanButtonLongPress: function(obj) { | ||
console.log('onScanButtonLongPress: ', obj); | ||
}, | ||
onKeyProcess: function(char, event) { | ||
console.log('onKeyProcess: ', char, event); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.