Skip to content

Commit

Permalink
Close GH-235: fix bool attr bugs [#111443058 Delivers].
Browse files Browse the repository at this point in the history
  • Loading branch information
drKnoxy authored and vastbinderj committed Feb 14, 2016
1 parent 50db28f commit 253047a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 62 deletions.
88 changes: 29 additions & 59 deletions src/app/design/directives/editor/guiBoolean.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,36 @@
angular.module("designModule")
/**
* Directive used for automatic attribute editor creation
*/
.directive("guiBoolean", ["$designService", function ($designService) {
return {
restrict: "E",
templateUrl: $designService.getTemplate("design/gui/editor/select.html"),

scope: {
"attribute": "=editorScope",
"item": "=item"
},
.directive("guiBoolean", ["$designService", function($designService) {
return {
restrict: "E",
templateUrl: $designService.getTemplate("design/gui/editor/select.html"),

controller: function ($scope) {
scope: {
"attribute": "=editorScope",
"item": "=item"
},

var init;
controller: function($scope) {
$scope.options = [{
Id: false,
Name: "false"
}, {
Id: true,
Name: "true"
}];

init = function () {
if (typeof $scope.attribute === "undefined" ||
typeof $scope.item === "undefined") {
return false;
}
$scope.$watch("item", init);
$scope.$watch("attribute", init);

if (typeof $scope.item[$scope.attribute.Attribute] === "boolean") {
$scope.options = [
{
Desc: "",
Extra: null,
Id: false,
Image: "",
Name: "false"
},
{
Desc: "",
Extra: null,
Id: true,
Image: "",
Name: "true"
}
];
} else {
$scope.options = [
{
Desc: "",
Extra: null,
Id: "false",
Image: "",
Name: "false"
},
{
Desc: "",
Extra: null,
Id: "true",
Image: "",
Name: "true"
}
];
}
};

$scope.$watch("item", init);
$scope.$watch("attribute", init);
function init() {
if (typeof $scope.attribute === "undefined" ||
typeof $scope.item === "undefined"
) {
return false;
}
};
}]);
}

}
};
}]);

3 changes: 1 addition & 2 deletions src/app/design/directives/editor/guiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ angular.module("designModule")
$scope.options = [];
options = getOptions($scope.attribute.Options);


for (field in options) {
if (options.hasOwnProperty(field)) {
$scope.options.push({
Expand All @@ -61,7 +60,7 @@ angular.module("designModule")
}
}

if ($scope.attribute.Default === ""){
if ($scope.attribute.Default === "" && !$scope.attribute.IsRequired){
$scope.options.unshift({
Desc: "",
Extra: null,
Expand Down
2 changes: 1 addition & 1 deletion src/app/product/controller/attributeEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function ($scope, $routeParams, $location, $productApiService, $dashboardUtilsSe

$scope.attribute = {};
$scope.attributesList = [];
$scope.typesAttribute = ["id", "boolean", "int", "text", "json", "decimal", "datetime", "[]id", "[]integer", "[]text"];
$scope.typesAttribute = ["id", "bool", "int", "text", "json", "decimal", "datetime", "[]id", "[]integer", "[]text"];
$scope.editorsList = [
"text",
"multiline_text",
Expand Down

0 comments on commit 253047a

Please sign in to comment.