Added following three files that make up the entire project so far…
process.html
<ion-view title="{{processName}}">
<ion-content class="has-header" pdk-next-input-on-enter>
<div ng-repeat="row in rows" class="row">
<div ng-repeat="content in row.widgets" class="col col-{{content.percentage}}">
<div ng-switch on="content.type">
<div ng-switch-when="label">
<div class="input-label" style="white-space: nowrap;color: {{content.foreColor}}">{{content.value}}</div>
</div>
<div ng-switch-when="text" class="list">
<label class="item item-input"> <!-- style="padding: 0px 0 0px 0px;" -->
<span class="input-label">{{content.label}}</span>
<div ng-switch on="content.tabOrder" style="width:{{content.percentage}}%">
<div ng-switch-when="1">
<input type="text" name="{{content.name}}" placeholder="{{content.toolTip}}" ng-value="{{content.value}}" tabindex="{{content.tabOrder}}" autofocus
ng-model="content.value" ng-blur="onTextBlur(content.name, content.value)">
</div>
<div ng-switch-default>
<input type="text" name="{{content.name}}" placeholder="{{content.toolTip}}" ng-value="{{content.value}}" tabindex="{{content.tabOrder}}"
ng-model="content.value" ng-blur="onTextBlur(content.name, content.value)">
</div>
</div>
</label>
</div>
<div ng-switch-when="combobox" class="list">
<label class="item item-input item-select">
<div class="input-label">
{{content.label}}
</div>
<select name="{{content.name}}" ng-model="content.list" ng-options="option.value as option.name for option in content.params"
ng-change="onListChange(content.name, content.list)">
</select>
</label>
</div>
<div ng-switch-when="listbox">
<ion-scroll style="height: 180px" style="padding-top: 0px">
<label class="item item-radio" ng-repeat="param in content.params" style="height: 35px;font-size: 14px;">
<input type="radio" name="{{content.name}}">
<div class="item-content">
{{param.value}}
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
<!--<table border="1">-->
<!--<tr ng-repeat="param in content.params">-->
<!--<td>{{param.value}}</td>-->
<!--</tr>-->
<!--</table>-->
</ion-scroll>
<!--<select name="{{content.name}}" ng-model="content.list" ng-options="option.value as option.name for option in content.params"-->
<!--ng-change="onListChange(content.name, content.list)" size="7" class="col col-{{content.percentage}}" style="white-space: nowrap;">-->
<!--</select>-->
</div>
</div>
</div>
</div>
<div class="row" ng-show="messageRow">
<div class="col">
<p ng-repeat="message in messageRow.widgets" style="color:red">{{message.value}}</p>
</div>
</div>
</ion-content>
<footer class="bar bar-footer bar-stable" style="height:50px">
<div class="button-bar">
<a class="button" ng-repeat="content in bottomRow.widgets" ng-click="submit(content)" style="padding-top:2px;color:{{content.foreColor}};background: {{content.backColor}}">{{content.value}}</a>
</div>
</footer>
</ion-view>
app.js
angular.module('starter', [
'ionic',
'starter.controllers',
'ngResource'
])
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
.directive('pdkNextInputOnEnter', function (ProcessService) {
var includeTags = ['INPUT', 'SELECT'];
function link(scope, element, attrs) {
element.on('keydown', function (e) {
// Go to next form element on enter and only for included tags
if (e.keyCode == 13 && includeTags.indexOf(e.target.tagName) != -1) {
// Find all form elements that can receive focus
var focusable = element[0].querySelectorAll('input'); //,select,button
// Get the index of the currently focused element
var currentIndex = Array.prototype.indexOf.call(focusable, e.target)
// Find the next items in the list
var nextIndex = currentIndex == focusable.length - 1 ? 0 : currentIndex + 1;
if (focusable[currentIndex]) {
scope.$parent.request[focusable[currentIndex].name] = focusable[currentIndex].value;
}
// Focus the next element
if (nextIndex >= 0 && nextIndex < focusable.length) {
focusable[nextIndex].focus();
}
if (focusable[currentIndex]) {
var keyName = focusable[currentIndex].name;
if (keyName in scope.inputWidgets) {
var widget = scope.inputWidgets[keyName];
for (var i = 0; i < widget.params.length; i++) {
var param = widget.params[i];
scope.$parent.request[param.name] = param.value;
}
scope.$parent.request['processName'] = scope.processName;
ProcessService.continue(scope.$parent.request, function (process) {
if (process) {
scope.$parent.processName = process.processName;
scope.$parent.rows = process.rows;
scope.$parent.bottomRow = process.bottomRow;
scope.$parent.messageRow = process.messageRow;
scope.$parent.request = {};
scope.$parent.inputWidgets = {};
// if the size is one, then add to the request automatically
for (var i = 0; i < process.rows.length; i++) {
var row = process.rows[i];
if (row.widgets) {
for (var j = 0; j < row.widgets.length; j++) {
var widget = row.widgets[j];
if (widget.type == 'combobox' || widget.type == 'listbox') {
if (widget.params && widget.params.length > 0) {
widget.list = widget.params[0].value;
scope.$parent.request[widget.name] = widget.params[0].value;
}
}
else if (widget.type == 'text') {
if (widget.params && widget.params.length > 0) {
scope.$parent.inputWidgets[widget.name] = widget;
}
if (widget.value) {
scope.$parent.request[widget.name] = widget.value;
}
}
}
}
}
}
});
}
}
return false;
}
});
}
return {
restrict: 'A',
link: link
};
})
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app.process', {
url: "/process/:processName",
views: {
'menuContent': {
controller: 'ProcessCtrl',
templateUrl: "templates/process.html"
}
}
})
.state('app.tasks', {
url: "/tasks",
views: {
'menuContent': {
templateUrl: "templates/tasks.html",
controller: 'TaskListCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/tasks');
})
.factory('ProcessService', function ($resource) {
return $resource('', {}, {
query: {
url: 'http://10.1.1.34:8080/solution/resources/handheld',
method: 'GET',
isArray: false,
params: {
sessionKey: 'SBI|support|5471044a-d3b3-4927-9ef6-500b32b05637',
processName: '',
action: 'startProcess',
platform: 'ionic',
screenname: 'UserMainMenu'
}
},
continue: {
url: 'http://10.1.1.34:8080/solution/resources/handheld',
method: 'GET',
isArray: false,
params: {
sessionKey: 'SBI|support|5471044a-d3b3-4927-9ef6-500b32b05637',
action: 'continueProcess',
platform: 'ionic',
ProcessInstance: '',
transition: '',
screenname: 'UserMainMenu'
}
}
});
}
);
controller.js
angular.module('starter.controllers', [])
.controller('AppCtrl', function ($scope) {
$scope.processes = [
{
"title": "Receiving",
"name": "GeneralReceiving",
"global": true
},
{
"title": "Picking",
"name": "SingleScanPicking",
"global": true
}
];
})
.controller('TaskListCtrl', function ($scope) {
$scope.playlists = [
{ title: 'Receiving', id: 1 },
{ title: 'Pick by Task', id: 2 },
{ title: 'Replenishment', id: 3 },
{ title: 'Cycle Count', id: 4 }
];
})
.controller('ProcessCtrl', function ($scope, $stateParams, $location, ProcessService) {
ProcessService.query({processName: $stateParams.processName}, function (process) {
if (process) {
$scope.processName = process.processName;
$scope.rows = process.rows;
$scope.bottomRow = process.bottomRow;
$scope.messageRow = process.messageRow;
$scope.request = {};
$scope.inputWidgets = {};
// if the size is one, then add to the request automatically
for (var i = 0; i < process.rows.length; i++) {
var row = process.rows[i];
if (row.widgets) {
for (var j = 0; j < row.widgets.length; j++) {
var widget = row.widgets[j];
if (widget.type == 'combobox' || widget.type == 'listbox') {
if (widget.params && widget.params.length > 0) {
widget.list = widget.params[0].value;
$scope.request[widget.name] = widget.params[0].value;
}
}
else if (widget.type == 'text') {
if (widget.params && widget.params.length > 0) {
$scope.inputWidgets[widget.name] = widget;
}
if (widget.value) {
$scope.request[widget.name] = widget.value;
}
}
}
}
}
}
});
$scope.onTextBlur = function(name, value) {
$scope.request[name] = value;
console.log($scope.request);
};
$scope.onListChange = function (name, value) {
$scope.request[name] = value;
};
$scope.submit = function(widget) {
for (var i = 0; i < widget.params.length; i++) {
var param = widget.params[i];
$scope.request[param.name] = param.value;
}
$scope.request['processName'] = $scope.processName;
console.log($scope.request);
ProcessService.continue($scope.request, function (process) {
if (process) {
if ("UserMainMenu" == process.processName) {
$location.path( "/" );
}
else {
$scope.processName = process.processName;
$scope.rows = process.rows;
$scope.bottomRow = process.bottomRow;
$scope.messageRow = process.messageRow;
$scope.request = {};
$scope.inputWidgets = {};
// if the size is one, then add to the request automatically
for (var i = 0; i < process.rows.length; i++) {
var row = process.rows[i];
if (row.widgets) {
for (var j = 0; j < row.widgets.length; j++) {
var widget = row.widgets[j];
if (widget.type == 'combobox' || widget.type == 'listbox') {
if (widget.params && widget.params.length > 0) {
widget.list = widget.params[0].value;
$scope.request[widget.name] = widget.params[0].value;
}
}
else if (widget.type == 'text') {
if (widget.params && widget.params.length > 0) {
$scope.inputWidgets[widget.name] = widget;
}
if (widget.value) {
$scope.request[widget.name] = widget.value;
}
}
}
}
}
}
}
});
};
$scope.foo = function() {
console.log("FOO");
}
}
);
menu.html
<ion-side-menus>
<ion-pane ion-side-menu-content>
<ion-nav-bar class="bar-stable">
<!--<ion-nav-back-button class="button-clear"><i class="icon ion-chevron-left"></i> Back</ion-nav-back-button>-->
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-pane>
<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
<h1 class="title">Main</h1>
</header>
<ion-content class="has-header">
<ion-list>
<ion-item nav-clear href="">Processes</ion-item>
<ion-item nav-clear menu-close href="#/app/process/{{process.name}}?global={{process.global}}" ng-repeat="process in processes"> {{process.title}}</ion-item>
</ion-list>
</ion-content>
<footer class="bar bar-footer bar-stable">
<ion-content>
<div class="list">
<label class="item item-input item-select">
<div class="input-label">
Assigned Zone
</div>
<select>
<option>Zone1</option>
<option>Zone2</option>
</select>
</label>
</div>
</ion-content>
</footer>
</ion-side-menu>
That’s all the files that were created, modified, along with corresponding scripts…
I am totally stuck on this, and any HELP is greatly appreciated…
Thanks!