Skip to content

Commit

Permalink
Merge pull request #51 from ottemo/develop_20141204
Browse files Browse the repository at this point in the history
fix for edit forms and shipping calc
  • Loading branch information
James Vastbinder committed Dec 4, 2014
2 parents cb1e45f + ee1c803 commit 89ec2d9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 99 deletions.
29 changes: 24 additions & 5 deletions app/scripts/config/directives/guiConfigEditorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
templateUrl: $designService.getTemplate("config/gui/configEditorForm.html"),
controller: function ($scope) {
var updateAttributes;
var updateAttributes, addTab, addFields, sortFieldsInGroups;

$scope.tabs = {};
$scope.click = function (id) {
if (typeof $scope.parent.selectTab === "function") {
Expand All @@ -27,7 +28,7 @@
}
};

var addTab = function(attr) {
addTab = function (attr) {
if (attr.Type === "group") {
if (typeof $scope.tabs[attr.Group] === "undefined") {
$scope.tabs[attr.Group] = [];
Expand All @@ -36,13 +37,32 @@
}
};

var addFields = function(attr) {
addFields = function (attr) {
if (typeof $scope.attributeGroups[attr.Group] === "undefined") {
$scope.attributeGroups[attr.Group] = [];
}
$scope.attributeGroups[attr.Group].push(attr);
};

sortFieldsInGroups = function () {
var sortByLabel, tab;
sortByLabel = function (a, b) {
if (a.Label.toString() < b.Label.toString()) {
return -1;
}
if (a.Label.toString() > b.Label.toString()) {
return 1;
}

return 0;
};
for (tab in $scope.attributeGroups) {
if ($scope.attributeGroups.hasOwnProperty(tab)) {
$scope.attributeGroups[tab].sort(sortByLabel);
}
}
};

updateAttributes = function () {
if ($scope.item === "undefined" ||
JSON.stringify({}) === JSON.stringify($scope.item)) {
Expand All @@ -64,12 +84,11 @@
attr = setAttrValue($scope.attributes[i]);

addFields(attr);

addTab(attr);
}
}


sortFieldsInGroups();
};

$scope.$watchCollection("attributes", updateAttributes);
Expand Down
11 changes: 10 additions & 1 deletion app/scripts/config/service/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
isLoaded = {};

getConfigGroups = function () {
return configGroups;
return configGroups.sort(function(a, b){
if (a.Name.toString() < b.Name.toString()) {
return 1;
}
if (a.Name.toString() > b.Name.toString()) {
return -1;
}

return 0;
});
};

getConfigTabs = function (group) {
Expand Down
42 changes: 41 additions & 1 deletion app/scripts/design/directives/guiPaginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,47 @@
scope: {
'parent': '=object'
},
templateUrl: $designService.getTemplate('design/gui/paginator.html')
templateUrl: $designService.getTemplate('design/gui/paginator.html'),
controller: ["$scope",
function ($scope) {

$scope.pages = $scope.parent.getPages();

var countNeighbors = 2;
$scope.leftBreak = false;
$scope.rightBreak = false;

$scope.isNeighbors = function (page) {
return Math.abs($scope.parent.paginator.page - page) <= countNeighbors;
};

$scope.hasLeftBreak = function () {
return $scope.leftBreak;
};

$scope.hasRightBreak = function () {
return $scope.rightBreak;
};


$scope.$watch("parent.paginator.page", function () {
if (typeof $scope.parent.paginator === "undefined") {
return true;
}

var leftBorder = $scope.parent.paginator.page - countNeighbors;
var rightBorder = $scope.parent.paginator.page + countNeighbors;

if (leftBorder > $scope.parent.getPages()[0] + 1 ) {
$scope.leftBreak = true;
}

if (rightBorder < $scope.parent.getPages()[$scope.parent.getPages().length-1]-1) {
$scope.rightBreak = true;
}
}, true);
}
]
};
}]);

Expand Down
90 changes: 0 additions & 90 deletions app/themes/default/scripts/main-chart.js

This file was deleted.

18 changes: 17 additions & 1 deletion app/themes/default/views/design/gui/paginator.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
<ul class="pagination">
<li class="{{parent.getClass('prev')}}"><a href="" target="_self" ng-click="parent.setPage('prev')">&laquo;</a></li>

<li class="{{parent.getClass(page)}}" ng-repeat="page in parent.getPages()">
<li class="{{parent.getClass(page)}}" ng-repeat="page in parent.getPages()" ng-if="$first">
<a href="" target="_self" ng-click="parent.setPage(page)">{{page}}</a>
</li>

<li ng-if="hasLeftBreak()">
<a href="">...</a>
</li>

<li class="{{parent.getClass(page)}}" ng-repeat="page in parent.getPages()" ng-if="isNeighbors(page) && !$first && !$last">
<a href="" target="_self" ng-click="parent.setPage(page)">{{page}}</a>
</li>

<li ng-if="hasRightBreak()">
<a href="">...</a>
</li>

<li class="{{parent.getClass(page)}}" ng-repeat="page in parent.getPages()" ng-if="$last">
<a href="" target="_self" ng-click="parent.setPage(page)">{{page}}</a>
</li>

Expand Down
5 changes: 4 additions & 1 deletion app/themes/default/views/order/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ <h6>Ship to:</h6>
<div class="od-total">
<span>{{order.subtotal | currency}}</span>
<span>Subtotal:</span>
<div class="clear"></div>
<div class="clear"></div>
<span>{{order.shipping_amount | currency}}</span>
<span>Shipping:</span>
<div class="clear"></div>
<span>{{order.tax_amount | currency}}</span>
<span>Tax:</span>
<div class="clear"></div>
Expand Down

0 comments on commit 89ec2d9

Please sign in to comment.