U4-8749: Fixes by @AndyButland
This commit is contained in:
@@ -151,7 +151,6 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
layouts: $scope.model.config.layouts,
|
||||
activeLayout: listViewHelper.getLayout($routeParams.id, $scope.model.config.layouts)
|
||||
},
|
||||
orderBySystemField: true,
|
||||
allowBulkPublish: $scope.entityType === 'content' && $scope.model.config.bulkActionPermissions.allowBulkPublish,
|
||||
allowBulkUnpublish: $scope.entityType === 'content' && $scope.model.config.bulkActionPermissions.allowBulkUnpublish,
|
||||
allowBulkCopy: $scope.entityType === 'content' && $scope.model.config.bulkActionPermissions.allowBulkCopy,
|
||||
@@ -159,6 +158,15 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
allowBulkDelete: $scope.model.config.bulkActionPermissions.allowBulkDelete
|
||||
};
|
||||
|
||||
// Check if selected order by field is actually custom field
|
||||
for (var j = 0; j < $scope.options.includeProperties.length; j++) {
|
||||
var includedProperty = $scope.options.includeProperties[j];
|
||||
if (includedProperty.alias.toLowerCase() === $scope.options.orderBy.toLowerCase()) {
|
||||
$scope.options.orderBySystemField = includedProperty.isSystem === 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//update all of the system includeProperties to enable sorting
|
||||
_.each($scope.options.includeProperties, function (e, i) {
|
||||
|
||||
@@ -180,12 +188,12 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
}
|
||||
|
||||
if (e.isSystem) {
|
||||
//localize the header
|
||||
var key = getLocalizedKey(e.alias);
|
||||
localizationService.localize(key).then(function (v) {
|
||||
e.header = v;
|
||||
});
|
||||
}
|
||||
//localize the header
|
||||
var key = getLocalizedKey(e.alias);
|
||||
localizationService.localize(key).then(function (v) {
|
||||
e.header = v;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.selectLayout = function (selectedLayout) {
|
||||
|
||||
@@ -1,31 +1,77 @@
|
||||
function sortByPreValsController($rootScope, $scope, localizationService, editorState) {
|
||||
// Helper to find a particular value from the list of sort by options
|
||||
function findFromSortByFields(value) {
|
||||
return _.find($scope.sortByFields, function (e) {
|
||||
return e.value.toLowerCase() === value.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
// Get list of properties assigned as columns of the list view
|
||||
var propsPreValue = _.findWhere(editorState.current.preValues, { key: "includeProperties" });
|
||||
|
||||
if(propsPreValue != undefined){
|
||||
$scope.sortByFields = propsPreValue.value;
|
||||
}
|
||||
else {
|
||||
$scope.sortByFields = [];
|
||||
// Populate list of options for the default sort (all the columns plus then node name)
|
||||
$scope.sortByFields = [];
|
||||
$scope.sortByFields.push({ value: "name", name: "Name", isSystem: 1 });
|
||||
if (propsPreValue != undefined) {
|
||||
for (var i = 0; i < propsPreValue.value.length; i++) {
|
||||
var value = propsPreValue.value[i];
|
||||
$scope.sortByFields.push({
|
||||
value: value.alias,
|
||||
name: value.header,
|
||||
isSystem: value.isSystem
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var existingValue = _.find($scope.sortByFields, function (e) {
|
||||
return e.alias.toLowerCase() === $scope.model.value;
|
||||
// Localize the system fields, for some reason the directive doesn't work inside of the select group with an ng-model declared
|
||||
var systemFields = [
|
||||
{ value: "SortOrder", key: "general_sort" },
|
||||
{ value: "Name", key: "general_name" },
|
||||
{ value: "VersionDate", key: "content_updateDate" },
|
||||
{ value: "Updater", key: "content_updatedBy" },
|
||||
{ value: "CreateDate", key: "content_createDate" },
|
||||
{ value: "Owner", key: "content_createBy" },
|
||||
{ value: "ContentTypeAlias", key: "content_documentType" },
|
||||
{ value: "Published", key: "content_isPublished" },
|
||||
{ value: "Email", key: "general_email" },
|
||||
{ value: "Username", key: "general_username" }
|
||||
];
|
||||
_.each(systemFields, function (e) {
|
||||
localizationService.localize(e.key).then(function (v) {
|
||||
|
||||
var sortByListValue = findFromSortByFields(e.value);
|
||||
if (sortByListValue) {
|
||||
sortByListValue.name = v;
|
||||
switch (e.value) {
|
||||
case "Updater":
|
||||
e.name += " (Content only)";
|
||||
break;
|
||||
case "Published":
|
||||
e.name += " (Content only)";
|
||||
break;
|
||||
case "Email":
|
||||
e.name += " (Members only)";
|
||||
break;
|
||||
case "Username":
|
||||
e.name += " (Members only)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (existingValue === undefined) {
|
||||
//Existing value not found
|
||||
|
||||
//Set to first value
|
||||
if($scope.sortByFields.length > 0){
|
||||
$scope.model.value = $scope.sortByFields[0].alias;
|
||||
}
|
||||
|
||||
// Check existing model value is available in list and ensure a value is set
|
||||
var existingValue = findFromSortByFields($scope.model.value);
|
||||
if (existingValue) {
|
||||
// Set the existing value
|
||||
// The old implementation pre Umbraco 7.5 used PascalCase aliases, this uses camelCase, so this ensures that any previous value is set
|
||||
$scope.model.value = existingValue.value;
|
||||
}
|
||||
else {
|
||||
//Set the existing value
|
||||
//The old implementation pre Umbraco 7.5 used PascalCase aliases, this uses camelCase, so this ensures that any previous value is set
|
||||
$scope.model.value = existingValue.alias;
|
||||
// Existing value not found, set to first value
|
||||
$scope.model.value = $scope.sortByFields[0].value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user