Updates new UDI pickers that have start nodes for pre-values to also store UDIs for their prevalues, this has a knock on effect in that we need to be able to inject some server side config for pre-value editors (otherwise we'd have to make diff udi prevalue editors but that isn't very re-usable), so have implemented that and then updated all of the logic to deal with the udi idType.
This commit is contained in:
@@ -27,7 +27,8 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
|
||||
description: preVals[i].description,
|
||||
label: preVals[i].label,
|
||||
view: preVals[i].view,
|
||||
value: preVals[i].value
|
||||
value: preVals[i].value,
|
||||
config: preVals[i].config,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,15 @@ function mediaPickerController($scope, dialogService, entityResource, $log, icon
|
||||
multiPicker: false,
|
||||
entityType: "Media",
|
||||
section: "media",
|
||||
treeAlias: "media"
|
||||
treeAlias: "media",
|
||||
idType: "int"
|
||||
};
|
||||
|
||||
//combine the dialogOptions with any values returned from the server
|
||||
if ($scope.model.config) {
|
||||
angular.extend(dialogOptions, $scope.model.config);
|
||||
}
|
||||
|
||||
$scope.openContentPicker = function() {
|
||||
$scope.contentPickerOverlay = dialogOptions;
|
||||
$scope.contentPickerOverlay.view = "treePicker";
|
||||
@@ -53,18 +59,21 @@ function mediaPickerController($scope, dialogService, entityResource, $log, icon
|
||||
};
|
||||
|
||||
$scope.add = function (item) {
|
||||
|
||||
var itemId = dialogOptions.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return dialogOptions.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
if (currIds.indexOf(item.id) < 0) {
|
||||
if (currIds.indexOf(itemId) < 0) {
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon, udi: item.udi });
|
||||
}
|
||||
};
|
||||
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return dialogOptions.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
@@ -79,7 +88,7 @@ function mediaPickerController($scope, dialogService, entityResource, $log, icon
|
||||
entityResource.getByIds(modelIds, dialogOptions.entityType).then(function (data) {
|
||||
_.each(data, function (item, i) {
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon });
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon, udi: item.udi });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,26 +12,29 @@ angular.module('umbraco')
|
||||
multiPicker: false,
|
||||
entityType: "Document",
|
||||
type: "content",
|
||||
treeAlias: "content"
|
||||
};
|
||||
treeAlias: "content",
|
||||
idType: "int"
|
||||
};
|
||||
|
||||
//combine the config with any values returned from the server
|
||||
if ($scope.model.config) {
|
||||
angular.extend(config, $scope.model.config);
|
||||
}
|
||||
|
||||
if($scope.model.value){
|
||||
$scope.ids = $scope.model.value.split(',');
|
||||
entityResource.getByIds($scope.ids, config.entityType).then(function (data) {
|
||||
_.each(data, function (item, i) {
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
|
||||
});
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon, udi: item.udi });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.openContentPicker = function() {
|
||||
$scope.treePickerOverlay = {};
|
||||
$scope.treePickerOverlay.section = config.type;
|
||||
$scope.treePickerOverlay.treeAlias = config.treeAlias;
|
||||
$scope.treePickerOverlay.multiPicker = config.multiPicker;
|
||||
$scope.treePickerOverlay = config;
|
||||
$scope.treePickerOverlay.view = "treePicker";
|
||||
$scope.treePickerOverlay.show = true;
|
||||
$scope.treePickerOverlay.show = true;
|
||||
|
||||
$scope.treePickerOverlay.submit = function(model) {
|
||||
|
||||
@@ -64,12 +67,15 @@ angular.module('umbraco')
|
||||
$scope.ids = [];
|
||||
};
|
||||
|
||||
$scope.add =function(item){
|
||||
if($scope.ids.indexOf(item.id) < 0){
|
||||
$scope.add = function (item) {
|
||||
|
||||
var itemId = config.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
if ($scope.ids.indexOf(itemId) < 0){
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
|
||||
$scope.ids.push(item.id);
|
||||
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
|
||||
$scope.ids.push(itemId);
|
||||
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon, udi: item.udi});
|
||||
$scope.model.value = trim($scope.ids.join(), ",");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,7 +12,12 @@ angular.module('umbraco')
|
||||
$scope.model.value = {
|
||||
type: "content"
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!$scope.model.config) {
|
||||
$scope.model.config = {
|
||||
idType: "int"
|
||||
};
|
||||
}
|
||||
|
||||
if($scope.model.value.id && $scope.model.value.type !== "member"){
|
||||
var ent = "Document";
|
||||
@@ -29,7 +34,8 @@ angular.module('umbraco')
|
||||
|
||||
$scope.openContentPicker =function(){
|
||||
$scope.treePickerOverlay = {
|
||||
view: "treepicker",
|
||||
view: "treepicker",
|
||||
idType: $scope.model.config.idType,
|
||||
section: $scope.model.value.type,
|
||||
treeAlias: $scope.model.value.type,
|
||||
multiPicker: false,
|
||||
@@ -67,6 +73,6 @@ angular.module('umbraco')
|
||||
$scope.clear();
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
$scope.node = item;
|
||||
$scope.model.value.id = item.id;
|
||||
$scope.model.value.id = $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
}
|
||||
});
|
||||
@@ -58,7 +58,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
startNode: {
|
||||
query: "",
|
||||
type: "content",
|
||||
id: $scope.model.config.startNodeId ? $scope.model.config.startNodeId : -1 // get start node for simple Content Picker
|
||||
id: $scope.model.config.startNodeId ? $scope.model.config.startNodeId : -1 // get start node for simple Content Picker
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,10 +105,11 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
$scope.clear();
|
||||
$scope.add(data);
|
||||
}
|
||||
angularHelper.getCurrentForm($scope).$setDirty();
|
||||
angularHelper.getCurrentForm($scope).$setDirty();
|
||||
},
|
||||
treeAlias: $scope.model.config.startNode.type,
|
||||
section: $scope.model.config.startNode.type
|
||||
section: $scope.model.config.startNode.type,
|
||||
idType: "int"
|
||||
};
|
||||
|
||||
//since most of the pre-value config's are used in the dialog options (i.e. maxNumber, minNumber, etc...) we'll merge the
|
||||
@@ -147,9 +148,10 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
if ($scope.model.config.startNode.query) {
|
||||
var rootId = $routeParams.id;
|
||||
entityResource.getByQuery($scope.model.config.startNode.query, rootId, "Document").then(function (ent) {
|
||||
dialogOptions.startNodeId = ent.id;
|
||||
dialogOptions.startNodeId = $scope.model.config.idType === "udi" ? ent.udi : ent.id;
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dialogOptions.startNodeId = $scope.model.config.startNode.id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user