Undoes the comma encoding for tags and istead adds support to store the tags as json or csv (U4-4741)
This commit is contained in:
@@ -12,15 +12,21 @@ angular.module("umbraco")
|
||||
//load current value
|
||||
$scope.currentTags = [];
|
||||
if ($scope.model.value) {
|
||||
$scope.currentTags = $scope.model.value.split(",");
|
||||
if ($scope.model.config.storageType && $scope.model.config.storageType === "Json") {
|
||||
//it's a json array already
|
||||
$scope.currentTags = $scope.model.value;
|
||||
}
|
||||
else {
|
||||
//it is csv
|
||||
$scope.currentTags = $scope.model.value.split(",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Helper method to add a tag on enter or on typeahead select
|
||||
function addTag(tagToAdd) {
|
||||
if (tagToAdd.length > 0) {
|
||||
if ($scope.currentTags.indexOf(tagToAdd) < 0) {
|
||||
//we need to html encode any tag containing commas: http://issues.umbraco.org/issue/U4-4741
|
||||
tagToAdd = tagToAdd.replace(/\,/g, ",");
|
||||
if ($scope.currentTags.indexOf(tagToAdd) < 0) {
|
||||
$scope.currentTags.push(tagToAdd);
|
||||
}
|
||||
}
|
||||
@@ -49,16 +55,24 @@ angular.module("umbraco")
|
||||
}
|
||||
};
|
||||
|
||||
//sync model on submit (needed since we convert an array to string)
|
||||
//sync model on submit, always push up a json array
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
$scope.model.value = $scope.currentTags.join();
|
||||
$scope.model.value = $scope.currentTags;
|
||||
});
|
||||
|
||||
//vice versa
|
||||
$scope.model.onValueChanged = function (newVal, oldVal) {
|
||||
//update the display val again if it has changed from the server
|
||||
$scope.model.val = newVal;
|
||||
$scope.currentTags = $scope.model.value.split(",");
|
||||
$scope.model.value = newVal;
|
||||
|
||||
if ($scope.model.config.storageType && $scope.model.config.storageType === "Json") {
|
||||
//it's a json array already
|
||||
$scope.currentTags = $scope.model.value;
|
||||
}
|
||||
else {
|
||||
//it is csv
|
||||
$scope.currentTags = $scope.model.value.split(",");
|
||||
}
|
||||
};
|
||||
|
||||
//configure the tags data source
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<div >
|
||||
|
||||
<select name="dropDownList"
|
||||
class="umb-editor umb-dropdown"
|
||||
ng-model="model.value">
|
||||
<option>Csv</option>
|
||||
<option>Json</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user