Merge remote-tracking branch 'refs/remotes/origin/dev-v7.6' into temp-U4-9470
# Conflicts: # src/Umbraco.Web/Editors/EntityController.cs
This commit is contained in:
@@ -185,24 +185,17 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
*/
|
||||
getByIds: function (ids, type) {
|
||||
|
||||
var query = "";
|
||||
_.each(ids, function(item) {
|
||||
query += "ids=" + item + "&";
|
||||
});
|
||||
|
||||
// if ids array is empty we need a empty variable in the querystring otherwise the service returns a error
|
||||
if (ids.length === 0) {
|
||||
query += "ids=&";
|
||||
}
|
||||
|
||||
query += "type=" + type;
|
||||
var query = "type=" + type;
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
$http.post(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"entityApiBaseUrl",
|
||||
"GetByIds",
|
||||
query)),
|
||||
query),
|
||||
{
|
||||
ids: ids
|
||||
}),
|
||||
'Failed to retrieve entity data for ids ' + ids);
|
||||
},
|
||||
|
||||
|
||||
@@ -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(), ",");
|
||||
});
|
||||
@@ -76,12 +85,15 @@ function mediaPickerController($scope, dialogService, entityResource, $log, icon
|
||||
|
||||
//load media data
|
||||
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];
|
||||
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 });
|
||||
if (modelIds.length > 0) {
|
||||
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, udi: item.udi });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,26 +12,30 @@ 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.section = config.type;
|
||||
$scope.treePickerOverlay.view = "treePicker";
|
||||
$scope.treePickerOverlay.show = true;
|
||||
$scope.treePickerOverlay.show = true;
|
||||
|
||||
$scope.treePickerOverlay.submit = function(model) {
|
||||
|
||||
@@ -64,12 +68,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;
|
||||
}
|
||||
});
|
||||
@@ -17,11 +17,11 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
$scope.$watch(function () {
|
||||
//return the joined Ids as a string to watch
|
||||
return _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
}).join();
|
||||
}, function (newVal) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -200,10 +202,12 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
$scope.add = function (item) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
|
||||
if (currIds.indexOf(item.id) < 0) {
|
||||
var itemId = $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
if (currIds.indexOf(itemId) < 0) {
|
||||
setEntityUrl(item);
|
||||
}
|
||||
};
|
||||
@@ -227,7 +231,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
@@ -237,26 +241,36 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
//load current data
|
||||
|
||||
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];
|
||||
|
||||
entityResource.getByIds(modelIds, entityType).then(function (data) {
|
||||
//load current data if anything selected
|
||||
if (modelIds.length > 0) {
|
||||
entityResource.getByIds(modelIds, entityType).then(function(data) {
|
||||
|
||||
_.each(modelIds, function (id, i) {
|
||||
var entity = _.find(data, function (d) {
|
||||
return d.id == id;
|
||||
});
|
||||
|
||||
if (entity) {
|
||||
setEntityUrl(entity);
|
||||
}
|
||||
|
||||
});
|
||||
_.each(modelIds,
|
||||
function(id, i) {
|
||||
var entity = _.find(data,
|
||||
function(d) {
|
||||
return $scope.model.config.idType === "udi" ? (d.udi == id) : (d.id == id);
|
||||
});
|
||||
|
||||
if (entity) {
|
||||
setEntityUrl(entity);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//everything is loaded, start the watch on the model
|
||||
startWatch();
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
//everything is loaded, start the watch on the model
|
||||
startWatch();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setEntityUrl(entity) {
|
||||
|
||||
@@ -304,6 +318,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
$scope.renderModel.push({
|
||||
"name": item.name,
|
||||
"id": item.id,
|
||||
"udi": item.udi,
|
||||
"icon": item.icon,
|
||||
"path": item.path,
|
||||
"url": item.url,
|
||||
|
||||
@@ -40,7 +40,13 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
|
||||
}
|
||||
|
||||
$scope.images.push(media);
|
||||
$scope.ids.push(media.id);
|
||||
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
$scope.ids.push(media.udi);
|
||||
}
|
||||
else {
|
||||
$scope.ids.push(media.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -80,7 +86,13 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
|
||||
}
|
||||
|
||||
$scope.images.push(media);
|
||||
$scope.ids.push(media.id);
|
||||
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
$scope.ids.push(media.udi);
|
||||
}
|
||||
else {
|
||||
$scope.ids.push(media.id);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.sync();
|
||||
|
||||
@@ -68,12 +68,19 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
|
||||
$scope.add = function (item) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
});
|
||||
|
||||
if (currIds.indexOf(item.id) < 0) {
|
||||
var itemId = $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
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, udi: item.udi, icon: item.icon});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,7 +90,12 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
@@ -99,7 +111,7 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
_.each(data, function (item, i) {
|
||||
// set default icon if it's missing
|
||||
item.icon = (item.icon) ? iconHelper.convertFromLegacyIcon(item.icon) : "icon-user";
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon });
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, udi: item.udi, icon: item.icon });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user