Implements the ability to have customized and configurable list views for specific content types
This commit is contained in:
@@ -7,38 +7,17 @@ function contentTypeResource($q, $http, umbRequestHelper) {
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.contentTypeResource#getContentType
|
||||
* @methodOf umbraco.resources.contentTypeResource
|
||||
*
|
||||
* @description
|
||||
* Returns a content type with a given ID
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* contentTypeResource.getContentType(1234)
|
||||
* .then(function(type) {
|
||||
* $scope.type = type;
|
||||
* });
|
||||
* </pre>
|
||||
* @param {Int} id id of the content type to retrieve
|
||||
* @returns {Promise} resourcePromise object.
|
||||
*
|
||||
*/
|
||||
getContentType: function (id) {
|
||||
getAssignedListViewDataType: function (contentTypeId) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
var data = {
|
||||
name: "News Article",
|
||||
alias: "newsArticle",
|
||||
id: id,
|
||||
tabs: []
|
||||
};
|
||||
|
||||
deferred.resolve(data);
|
||||
return deferred.promise;
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentTypeApiBaseUrl",
|
||||
"GetAssignedListViewDataType",
|
||||
[{ contentTypeId: contentTypeId }])),
|
||||
'Failed to retrieve data for content id ' + contentTypeId);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
|
||||
@@ -152,23 +152,11 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.dataTypeResource#deleteById
|
||||
* @name umbraco.resources.dataTypeResource#save
|
||||
* @methodOf umbraco.resources.dataTypeResource
|
||||
*
|
||||
* @description
|
||||
* Saves or update a data typw
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* dataTypeResource.getById(1234)
|
||||
* .then(function(type) {
|
||||
* type.name ="hibba";
|
||||
*
|
||||
* dataTypeResource.save(type, type.preValues, false).then(function(type){
|
||||
* alert('its done!');
|
||||
* }):
|
||||
* });
|
||||
* </pre>
|
||||
* Saves or update a data type
|
||||
*
|
||||
* @param {Object} dataType data type object to create/update
|
||||
* @param {Array} preValues collection of prevalues on the datatype
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name Umbraco.Editors.ContentType.ListViewController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for the customize list view dialog for content types
|
||||
*/
|
||||
function ContentTypeListViewController($scope, contentTypeResource, dataTypeResource) {
|
||||
|
||||
|
||||
function init() {
|
||||
contentTypeResource.getAssignedListViewDataType($scope.dialogOptions.contentTypeId)
|
||||
.then(function(d) {
|
||||
$scope.listViewName = d.name;
|
||||
$scope.isSystem = d.isSystem;
|
||||
$scope.dataTypeId = d.id;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.listViewName = "";
|
||||
$scope.isSystem = true;
|
||||
$scope.dataTypeId = 0;
|
||||
|
||||
$scope.createCustom = function() {
|
||||
dataTypeResource.save({
|
||||
id: 0,
|
||||
name: "List View - " + $scope.dialogOptions.contentTypeAlias,
|
||||
selectedEditor: "Umbraco.ListView"
|
||||
}, [], true)
|
||||
.then(function(d) {
|
||||
$scope.listViewName = d.name;
|
||||
$scope.isSystem = d.isSystem;
|
||||
$scope.dataTypeId = d.id;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.removeCustom = function() {
|
||||
if (!$scope.isSystem && $scope.dataTypeId > 0) {
|
||||
dataTypeResource.deleteById($scope.dataTypeId)
|
||||
.then(function() {
|
||||
init();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.ContentType.ListViewController", ContentTypeListViewController);
|
||||
@@ -0,0 +1,43 @@
|
||||
<div class="umb-panel" ng-controller=" Umbraco.Editors.ContentType.ListViewController">
|
||||
|
||||
<div class="umb-panel-body no-header with-footer compact">
|
||||
|
||||
<h5><localize key="editcontenttype_customizeListView">Customize list view</localize> {{currentNode.name}}</h5>
|
||||
|
||||
<umb-pane>
|
||||
<umb-control-group label="@editcontenttype_currentListView">
|
||||
<strong>{{listViewName}}</strong>
|
||||
<em ng-if="isSystem"> (<localize key="general_default">default</localize>)</em>
|
||||
<br/>
|
||||
<a href="#/developer/datatype/edit/{{dataTypeId}}" class="text-info">
|
||||
<localize key="general_edit">Edit</localize>
|
||||
</a>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group ng-if="isSystem == 1">
|
||||
<div>
|
||||
<button class="btn" type="button" ng-click="createCustom()">
|
||||
<localize key="editcontenttype_createListView">Create custom list view</localize>
|
||||
</button>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group ng-if="isSystem == 0">
|
||||
<button class="btn btn-warning" type="button" ng-click="removeCustom()">
|
||||
<localize key="editcontenttype_removeListView">Remove custom list view</localize>
|
||||
</button>
|
||||
</umb-control-group>
|
||||
|
||||
</umb-pane>
|
||||
|
||||
</div>
|
||||
<div class="umb-panel-footer">
|
||||
<div class="umb-el-wrap umb-panel-buttons">
|
||||
<div class="btn-toolbar umb-btn-toolbar pull-right">
|
||||
<a href ng-click="close()" class="btn btn-link">
|
||||
<localize key="general_close">Close</localize>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -19,20 +19,7 @@ describe('content type factory tests', function () {
|
||||
}));
|
||||
|
||||
describe('global content type factory crud', function () {
|
||||
|
||||
it('should return a content type object, given an id', function () {
|
||||
var ct1;
|
||||
contentTypeResource.getContentType(1234).then(function(result){
|
||||
ct1 = result;
|
||||
});
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(ct1).toNotBe(undefined);
|
||||
expect(ct1.id).toBe(1234);
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('should return a allowed content type collection given a document id', function(){
|
||||
|
||||
// m.expectAllowedChildren();
|
||||
|
||||
Reference in New Issue
Block a user