Updated some of the property editor API to ensure that when formatting data for persistence we have access to the pre-values as well since these might need to be used to format the persisted data. Completed the new property editor: Multiple text box and it is saving the data in a backwards compatible format. Changed the internal AsDictionary method of the pre value collection to be a public method called FormatAsDictionary.

This commit is contained in:
Shannon
2013-08-28 17:53:31 +10:00
parent bec36fd91b
commit 0ebe9ec0fa
31 changed files with 390 additions and 138 deletions

View File

@@ -1,8 +1,7 @@
angular.module("umbraco").controller("Umbraco.Editors.ColorPickerController",
function($scope) {
$scope.selectItem = function(color) {
$scope.model.value = color;
};
function ColorPickerController($scope) {
$scope.selectItem = function (color) {
$scope.model.value = color;
};
}
});
angular.module("umbraco").controller("Umbraco.Editors.ColorPickerController", ColorPickerController);

View File

@@ -0,0 +1,34 @@
function MultipleTextBoxController($scope) {
if (!$scope.model.value) {
$scope.model.value = [];
}
//add any fields that there isn't values for
if ($scope.model.config.min.value > 0) {
for (var i = 0; i < $scope.model.config.min.value; i++) {
if ((i + 1) > $scope.model.value.length) {
$scope.model.value.push({ value: "" });
}
}
}
$scope.add = function () {
if ($scope.model.config.max.value <= 0 || $scope.model.value.length < $scope.model.config.max.value) {
$scope.model.value.push({ value: "" });
}
};
$scope.remove = function(index) {
var remainder = [];
for (var x = 0; x < $scope.model.value.length; x++) {
if (x !== index) {
remainder.push($scope.model.value[x]);
}
}
$scope.model.value = remainder;
};
}
angular.module("umbraco").controller("Umbraco.Editors.MultipleTextBoxController", MultipleTextBoxController);

View File

@@ -0,0 +1,17 @@
<div ng-controller="Umbraco.Editors.MultipleTextBoxController">
<div class="control-group" ng-repeat="item in model.value">
<input type="text" name="item_{{$index}}" ng-model="item.value" />
<a prevent-default href="" title="Remove this text box"
ng-show="model.value.length > model.config.min.value"
ng-click="remove($index)">
<i class="icon icon-minus"></i>
</a>
</div>
<a prevent-default href="" title="Add another text box"
ng-show="model.config.max.value <= 0 || model.value.length < model.config.max.value"
ng-click="add()">
<i class="icon icon-plus"></i>
</a>
</div>