Skip to content

Commit

Permalink
Merge pull request #553 from freefony/refactor/change-vvm-values-to-v…
Browse files Browse the repository at this point in the history
…ariables

Refactor/change vvm values to variables
  • Loading branch information
jofomah committed Oct 27, 2014
2 parents 163fbf1 + 0d1140b commit 3c3d009
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 52 deletions.
15 changes: 9 additions & 6 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,16 +590,16 @@
"message": "Select facility cold chain units"
},
"reportCcuBreakdown": {
"message": "Report CCE breakdown"
"message": "Report CCU breakdown"
},
"ccuBreakdown": {
"message": "CCE Breakdown"
"message": "CCU Breakdown"
},
"selectFacultyCcu": {
"message": "Select faulty CCE"
"message": "Select faulty CCU"
},
"selectCcu": {
"message": "Select CCE"
"message": "Select CCU"
},
"confirmCcuBreakdownReportHeader": {
"message": "Confirm '$ccuIdentifier$' breakdown report",
Expand All @@ -613,10 +613,10 @@
"message": "are you sure?"
},
"ccuBreakdownReportSuccessMsg": {
"message": "CCE breakdown report sent successfully!"
"message": "CCU breakdown report sent successfully!"
},
"ccuBreakdownReportFailedMsg": {
"message": "CCE breakdown report failed, please contact support"
"message": "CCU breakdown report failed, please contact support"
},
"stockCountHistory": {
"message": "Stock Count History"
Expand Down Expand Up @@ -740,6 +740,9 @@
"specifyBundleType":{
"message": "Please specify if its receiving or sending"
},
"CcuBreakdown": {
"message": "Cold Chain Unit Breakdown"
},
"selectZones":{
"message": "Select Zones"
}
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/app-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ angular.module('lmisChromeApp')

$scope.spaceOutUpperCaseWords = utility.spaceOutUpperCaseWords;
var oldLgas = [];
//console.log(appConfig);
if (utility.has(appConfig.facility, 'selectedLgas')) {
oldLgas = angular.copy(appConfig.facility.selectedLgas);
}
Expand Down
96 changes: 56 additions & 40 deletions app/scripts/controllers/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,46 @@ angular.module('lmisChromeApp')
setUITexts($stateParams.type);

bundleService.getRecentFacilityIds($stateParams.type)
.then(function(res) {
.then(function (res) {
facilityFactory.getFacilities(res)
.then(function(facilities) {
.then(function (facilities) {
$scope.recentFacilities = facilities;
})
.catch(function(err){
.catch(function (err) {
console.error(err);
});
})
.catch(function(err) {
.catch(function (err) {
console.error(err);
});

$scope.getWards = function(lga) {
$scope.facilities= [];
$scope.getWards = function (lga) {
$scope.facilities = [];
locationService.getWards(lga)
.then(function(wards) {
.then(function (wards) {
$scope.wards = wards;
});
};
$scope.getFacilities = function(ward) {
$scope.getFacilities = function (ward) {
ward = JSON.parse(ward);
$scope.facilities= [];
facilityFactory.find(function(result){
result.forEach(function(row){
if(row.wardUUID === ward.uuid){
$scope.facilities = [];
facilityFactory.find(function (result) {
result.forEach(function (row) {
if (row.wardUUID === ward.uuid) {
$scope.facilities.push(row);
}
});
});
};
$scope.ccoFacilities = [];
facilityFactory.find(function(result){
result.forEach(function(row){
if(row.doc_type ==='cco'){
facilityFactory.find(function (result) {
result.forEach(function (row) {
if (row.doc_type === 'cco') {
$scope.ccoFacilities.push(row);
}
});
});
$scope.setFacility = function() {
$scope.setFacility = function () {
if ($scope.placeholder.selectedFacility === '-1') {
$scope.showAddNew = true;
$scope.selectFacilityError = false;
Expand All @@ -130,7 +130,7 @@ angular.module('lmisChromeApp')
}
};

$scope.showLogBundleForm = function() {
$scope.showLogBundleForm = function () {
if ($scope.placeholder.selectedFacility === '-1' || $scope.placeholder.selectedFacility === '') {
$scope.selectFacilityError = true;
return;
Expand All @@ -139,39 +139,46 @@ angular.module('lmisChromeApp')
};

$scope.bundles = bundles
.filter(function(e) {
.filter(function (e) {
//TODO: move to service getByType()
return e.type === $stateParams.type;
})
.sort(function(a, b) {
.sort(function (a, b) {
//desc order
return -(new Date(a.created) - new Date(b.created));
});
$scope.previewBundle = {};
$scope.preview = false;

$scope.showBundle = function(bundle) {
$scope.showBundle = function (bundle) {
for (var i in bundle.bundleLines) {
var ppUuid = bundle.bundleLines[i].productProfile;
bundle.bundleLines[i].productProfile = productProfileFactory.get(ppUuid);
}
bundle.bundleLines
.sort(function(a,b) {
return (a.productProfile.category.name > b.productProfile.category.name);
});
.sort(function (a, b) {
return (a.productProfile.category.name > b.productProfile.category.name);
})
$scope.previewBundle = angular.copy(bundle);
$scope.preview = true;
};
$scope.getCategoryColor = productCategoryFactory.getCategoryColor;
$scope.hidePreview = function() {
$scope.hidePreview = function () {
$scope.preview = false;
};
$scope.expiredProductAlert = productProfileFactory.compareDates;
$scope.VVMStatus = [
'Stage 1',
'Stage 2',
'Stage 3'
];
$scope.VVMStatus = {
freshLevel1: '1.1',
freshLevel2: '1.2',
freshLevel3: '1.3',
freshLevel4: '1.4',
freshLevel5: '1.5',
expired1: '2.1',
expired2: '2.2',
expired3: '2.3',
NoVVM : '3'
}

})
.controller('LogBundleCtrl', function($scope, batchStore, utility, batchService, appConfig, i18n, productProfileFactory, bundleService, growl, $state, alertFactory, syncService, $stateParams, $filter, locationService, facilityFactory,appConfigService,productCategoryFactory, VVM_OPTIONS) {

Expand Down Expand Up @@ -241,7 +248,6 @@ angular.module('lmisChromeApp')
setFacility();
$scope.selectedProduct = [];
$scope.getUnitQty = function(bundleLine) {

$scope.productProfiles.map(function(product) {
if (product.uuid === bundleLine.productProfile) {
$scope.selectedProduct[bundleLine.id] = product;
Expand All @@ -250,24 +256,20 @@ angular.module('lmisChromeApp')
$scope.selectedProductUOMName[bundleLine.id] = product.presentation.uom.name;
$scope.selectedProductUOMVal[bundleLine.id] = product.presentation.value;
}

});

};

var getLGAs = function() {
$scope.lgas = appConfig.facility.selectedLgas;
};
getLGAs();

$scope.getWards = function(lga) {
locationService.getWards(lga)
.then(function(wards) {
$scope.wards = wards;
});
};

var getLGAs = function() {
$scope.lgas = appConfig.facility.selectedLgas;
};

getLGAs();

$scope.getFacilities = function(ward) {
ward = JSON.parse(ward);
facilityFactory.getFacilities(ward.facilities)
Expand All @@ -285,7 +287,9 @@ angular.module('lmisChromeApp')
growl.error(i18n('specifyBundleType'));
return;
}
$scope.placeholder = { selectedFacility: '' };
$scope.placeholder = {
selectedFacility: ''
};
$scope.previewFacilityLabel = '';

function setUIText(type) {
Expand Down Expand Up @@ -366,6 +370,18 @@ angular.module('lmisChromeApp')
});
};

$scope.isSelectedFacility = function(fac) {
//TODO: refactor
var sendingFacObj = $scope.bundle.sendingFacility;
if (angular.isDefined(sendingFacObj) && angular.isDefined(fac)) {
if (angular.isString(sendingFacObj) && sendingFacObj.length > 0) {
sendingFacObj = JSON.parse(sendingFacObj);
}
return sendingFacObj.uuid === fac.uuid;
}
return false;
};

var updateBundleLines = function(bundle) {
for (var i in bundle.bundleLines) {
var ppUuid = bundle.bundleLines[i].productProfile;
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/controllers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ angular.module('lmisChromeApp')
};

$scope.productTypesChart = dashboardfactory.chart(keys, values);
console.log($scope.productTypesChart);
})
.catch(function(err) {
console.log('getProductTypeCounts Error: ' + err);
Expand Down Expand Up @@ -274,6 +275,7 @@ angular.module('lmisChromeApp')
templateUrl: 'views/home/dashboard/chart.html',
controller: function($scope, $log, dashboardfactory, keys, aggregatedInventory) {
$scope.inventoryChart = dashboardfactory.chart(keys, aggregatedInventory);

}
},
'table': {
Expand Down
1 change: 1 addition & 0 deletions app/scripts/services/dashboardfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ angular.module('lmisChromeApp')
};

var chart = function(keys, values) {
console.log(keys)
var chart = [];
for (var i = 0, len = keys.length; i < len; i++) {
chart.push(series(keys[i], values));
Expand Down
8 changes: 3 additions & 5 deletions app/views/bundles/partials/bundle-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ <h4 class="panel-title pull-left">Product {{ $index + 1 }}</h4>
<span class="dropdown">
<a href class="dropdown-toggle form-control clearfix">
<span ng-if="bundleLine.VVMStatus" class="pull-left">
<span ng-if="bundleLine.VVMStatus.value === '3'">No VVM Status</span>
<span ng-if="bundleLine.VVMStatus.value !== '3'">
<img ng-src="images/vvm-icons/{{bundleLine.VVMStatus.imageSrc}}" class="vvm-icon-sm" />
</span>
<span ng-if="bundleLine.VVMStatus.value === VVMStatus.NoVVM">No VVM Status</span>
<span ng-if="bundleLine.VVMStatus.value !== VVMStatus.NoVVM"><img ng-src="images/vvm-icons/{{bundleLine.VVMStatus.imageSrc}}" class="vvm-icon-sm" /></span>
</span>
<span class="pull-right"><i class="caret"></i></span>
</a>
<ul class="dropdown-menu vvm-icon-dropdown">
<li ng-repeat="vvm in vvmOptions">
<li ng-repeat="vvm in vvmOptions">
<a href ng-click="selectVVMOption(bundleLine, {value: vvm.value, imageSrc: vvm.imageSrc})" class="dropdown-toggle">
<span ng-if="vvm.value === '3'" ng-bind="vvm.imageSrc"></span>
<img ng-if="vvm.value !== '3'" ng-src="images/vvm-icons/{{vvm.imageSrc}}" />
Expand Down
1 change: 0 additions & 1 deletion app/views/home/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
</a>
</div>
</div>

<div ui-view="chart"></div>
<div ui-view="table"></div>
3 changes: 3 additions & 0 deletions app/views/home/dashboard/chart.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<nvd3-multi-bar-horizontal-chart
id="inventory-chart"
data="inventoryChart"
showControls = true
showValues = true
tooltips="true"
showLegend = true
stacked="true">
</nvd3-multi-bar-horizontal-chart>
1 change: 1 addition & 0 deletions app/views/home/home.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

<div ui-view="charts"></div>
<div ui-view="activities"></div>

0 comments on commit 3c3d009

Please sign in to comment.