U4-8749: Add a service to allow acces to prevalues from inline listview editor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function ListViewSettingsDirective(contentTypeResource, dataTypeResource, dataTypeHelper) {
|
||||
function ListViewSettingsDirective(contentTypeResource, dataTypeResource, dataTypeHelper, listViewPrevalueHelper) {
|
||||
|
||||
function link(scope, el, attr, ctrl) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
scope.dataType = dataType;
|
||||
|
||||
listViewPrevalueHelper.setPrevalues(dataType.preValues);
|
||||
scope.customListViewCreated = checkForCustomListView();
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
@ngdoc service
|
||||
* @name umbraco.services.listViewPrevalueHelper
|
||||
*
|
||||
*
|
||||
* @description
|
||||
* Service for accessing the prevalues of a list view being edited in the inline list view editor in the doctype editor
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function listViewPrevalueHelper() {
|
||||
|
||||
var prevalues = [];
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.listViewPrevalueHelper#getPrevalues
|
||||
* @methodOf umbraco.services.listViewPrevalueHelper
|
||||
*
|
||||
* @description
|
||||
* Set the collection of prevalues
|
||||
*/
|
||||
|
||||
function getPrevalues() {
|
||||
return prevalues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.listViewPrevalueHelper#setPrevalues
|
||||
* @methodOf umbraco.services.listViewPrevalueHelper
|
||||
*
|
||||
* @description
|
||||
* Changes the current layout used by the listview to the layout passed in. Stores selection in localstorage
|
||||
*
|
||||
* @param {Array} values Array of prevalues
|
||||
*/
|
||||
|
||||
function setPrevalues(values) {
|
||||
prevalues = values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var service = {
|
||||
|
||||
getPrevalues: getPrevalues,
|
||||
setPrevalues: setPrevalues
|
||||
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
}
|
||||
|
||||
|
||||
angular.module('umbraco.services').factory('listViewPrevalueHelper', listViewPrevalueHelper);
|
||||
|
||||
|
||||
})();
|
||||
@@ -1,7 +1,17 @@
|
||||
function sortByPreValsController($rootScope, $scope, localizationService, editorState) {
|
||||
function sortByPreValsController($rootScope, $scope, localizationService, editorState, listViewPrevalueHelper) {
|
||||
//Get the prevalue from the correct place
|
||||
function getPrevalues() {
|
||||
if (editorState.current.preValues) {
|
||||
return editorState.current.preValues;
|
||||
}
|
||||
else {
|
||||
return listViewPrevalueHelper.getPrevalues();
|
||||
}
|
||||
}
|
||||
|
||||
//Watch the prevalues
|
||||
$scope.$watch(function () {
|
||||
return _.findWhere(editorState.current.preValues, { key: "includeProperties" }).value;
|
||||
return _.findWhere(getPrevalues(), { key: "includeProperties" }).value;
|
||||
}, function () {
|
||||
populateFields();
|
||||
}, true); //Use deep watching, otherwise we won't pick up header changes
|
||||
@@ -15,7 +25,7 @@ function sortByPreValsController($rootScope, $scope, localizationService, editor
|
||||
}
|
||||
|
||||
// Get list of properties assigned as columns of the list view
|
||||
var propsPreValue = _.findWhere(editorState.current.preValues, { key: "includeProperties" });
|
||||
var propsPreValue = _.findWhere(getPrevalues(), { key: "includeProperties" });
|
||||
|
||||
// Populate list of options for the default sort (all the columns plus then node name)
|
||||
$scope.sortByFields = [];
|
||||
|
||||
Reference in New Issue
Block a user