Creates a re-usable dropdown/multilist for any type of Entity that uses the entityResource, so now user picker, property type (+ multiple) param editor, content type (+multiple) param editor all use this. Fixes: U4-3268 UserPicker doesn't actually persist a value
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-body no-header umb-scrollable" auto-scale="1" ng-switch="wizardStep">
|
||||
<div class="umb-panel-body no-header umb-scrollable" auto-scale="90" ng-switch="wizardStep">
|
||||
|
||||
<umb-control-group label="Choose a macro" ng-switch-when="macroSelect">
|
||||
<select class="umb-editor" ng-change="submitForm()" name="selectedMacro" ng-model="$parent.$parent.selectedMacro" ng-options="m as m.name for m in macros" required>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
function contentTypePicker($scope, entityResource) {
|
||||
|
||||
entityResource.getAll("DocumentType").then(function (data) {
|
||||
//convert the ids to strings so the drop downs work properly when comparing
|
||||
_.each(data, function(d) {
|
||||
d.id = d.id.toString();
|
||||
});
|
||||
$scope.contentTypes = data;
|
||||
});
|
||||
|
||||
if ($scope.model.value === null || $scope.model.value === undefined) {
|
||||
if ($scope.model.config.multiple) {
|
||||
$scope.model.value = [];
|
||||
}
|
||||
else {
|
||||
$scope.model.value = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if it's multiple, change the value to an array
|
||||
if ($scope.model.config.multiple) {
|
||||
$scope.model.value = $scope.model.value.split(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.ContentTypeController", contentTypePicker);
|
||||
@@ -0,0 +1,40 @@
|
||||
/** A drop down list or multi value select list based on an entity type, this can be re-used for any entity types */
|
||||
function entityPicker($scope, entityResource) {
|
||||
|
||||
//set the default to DocumentType
|
||||
if (!$scope.model.config.entityType) {
|
||||
$scope.model.config.entityType = "DocumentType";
|
||||
}
|
||||
|
||||
//Determine the select list options and which value to publish
|
||||
if (!$scope.model.config.publishBy) {
|
||||
$scope.selectOptions = "entity.id as entity.name for entity in entities";
|
||||
}
|
||||
else {
|
||||
$scope.selectOptions = "entity." + $scope.model.config.publishBy + " as entity.name for entity in entities";
|
||||
}
|
||||
|
||||
entityResource.getAll($scope.model.config.entityType).then(function (data) {
|
||||
//convert the ids to strings so the drop downs work properly when comparing
|
||||
_.each(data, function(d) {
|
||||
d.id = d.id.toString();
|
||||
});
|
||||
$scope.entities = data;
|
||||
});
|
||||
|
||||
if ($scope.model.value === null || $scope.model.value === undefined) {
|
||||
if ($scope.model.config.multiple) {
|
||||
$scope.model.value = [];
|
||||
}
|
||||
else {
|
||||
$scope.model.value = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if it's multiple, change the value to an array
|
||||
if ($scope.model.config.multiple === "1") {
|
||||
$scope.model.value = $scope.model.value.split(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.EntityPickerController", entityPicker);
|
||||
@@ -1,10 +1,10 @@
|
||||
<div ng-controller="Umbraco.PropertyEditors.ContentTypeController" ng-switch="model.config.multiple">
|
||||
<div ng-controller="Umbraco.PropertyEditors.EntityPickerController" ng-switch="model.config.multiple">
|
||||
|
||||
<select name="contentTypeList"
|
||||
class="umb-editor umb-dropdown"
|
||||
ng-switch-default
|
||||
ng-model="model.value"
|
||||
ng-options="contentType.id as contentType.name for contentType in contentTypes">
|
||||
ng-options="{{selectOptions}}">
|
||||
</select>
|
||||
|
||||
<!--NOTE: This ng-switch is required because ng-multiple doesn't actually support dynamic bindings with multi-select lists -->
|
||||
@@ -13,7 +13,7 @@
|
||||
ng-switch-when="1"
|
||||
multiple
|
||||
ng-model="model.value"
|
||||
ng-options="contentType.id as contentType.name for contentType in contentTypes">
|
||||
ng-options="{{selectOptions}}">
|
||||
</select>
|
||||
|
||||
</div>
|
||||
@@ -1,11 +0,0 @@
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.UserPickerController",
|
||||
function($rootScope, $scope, $log, userResource){
|
||||
|
||||
userResource.getAll().then(function (userArray) {
|
||||
$scope.users = userArray;
|
||||
});
|
||||
|
||||
if ($scope.model.value === null || $scope.model.value === undefined) {
|
||||
$scope.model.value = "";
|
||||
}
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
<select
|
||||
ng-controller="Umbraco.PropertyEditors.UserPickerController"
|
||||
name="{{ model.alias }}"
|
||||
ng-model=" model.value"
|
||||
ng-options="user.id as user.name for user in users">
|
||||
<option value="">Select User</option>
|
||||
</select>
|
||||
Reference in New Issue
Block a user