Updates PR with fixes for code and implementation logic for the url list.

This commit is contained in:
Shannon
2015-10-28 12:28:29 +01:00
parent e25222162c
commit 64c983eb07
6 changed files with 189 additions and 152 deletions

View File

@@ -1,14 +1,29 @@
angular.module('umbraco').controller("Umbraco.PropertyEditors.UrlListController",
function($rootScope, $scope, $filter) {
function formatDisplayValue() {
$scope.renderModel = _.map($scope.model.value.split(","), function (item) {
return {
url: item,
linkText: $scope.model.linkText,
urlTarget: ($scope.config && $scope.config.target) ? $scope.config.target : "_blank"
};
});
function formatDisplayValue() {
if (angular.isArray($scope.model.value)) {
//it's the json value
$scope.renderModel = _.map($scope.model.value, function (item) {
return {
url: item.url,
linkText: item.linkText,
urlTarget: (item.target) ? item.target : "_blank",
icon: (item.icon) ? item.icon : "icon-out"
};
});
}
else {
//it's the default csv value
$scope.renderModel = _.map($scope.model.value.split(","), function (item) {
return {
url: item,
linkText: "",
urlTarget: ($scope.config && $scope.config.target) ? $scope.config.target : "_blank",
icon: ($scope.config && $scope.config.icon) ? $scope.config.icon : "icon-out"
};
});
}
}
$scope.getUrl = function(valueUrl) {

View File

@@ -1,15 +1,11 @@
<div ng-controller="Umbraco.PropertyEditors.UrlListController">
<ul class="nav nav-stacked">
<li ng-repeat="value in renderModel">
<div ng-if="value.url != ''">
<a href="{{getUrl(value.url)}}" prevent-default="{{value.url.indexOf('/') == -1}}" target="{{value.urlTarget}}">
<i class="icon-out"></i>
{{ value.linkText }}
</a>
</div>
<div ng-if="value.url == ''">
<p>{{ value.linkText }}</p>
</div>
<a href="{{getUrl(value.url)}}" prevent-default="{{value.url.indexOf('/') == -1}}" target="{{value.urlTarget}}">
<i ng-class="value.icon"></i>
<span ng-if="value.linkText">{{value.linkText}}</span>
<span ng-if="!value.linkText">{{value.url}}</span>
</a>
</li>
</ul>
</div>