Skip to content

Commit

Permalink
umbraco#2927 - Cannot use content templates in list views (umbraco#3173)
Browse files Browse the repository at this point in the history
  • Loading branch information
KimHolzmann authored and nul800sebastiaan committed Oct 23, 2018
1 parent 9230de5 commit 3e14da5
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
items: []
};

$scope.createAllowedButtonSingle = false;
$scope.createAllowedButtonSingleWithBlueprints = false;
$scope.createAllowedButtonMultiWithBlueprints = false;


//when this is null, we don't check permissions
$scope.currentNodePermissions = null;

Expand Down Expand Up @@ -598,7 +603,28 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
id = -1;
}

$scope.listViewAllowedTypes = getContentTypesCallback(id);
//$scope.listViewAllowedTypes = getContentTypesCallback(id);
getContentTypesCallback(id).then(function (listViewAllowedTypes) {
var blueprints = false;
$scope.listViewAllowedTypes = listViewAllowedTypes;

angular.forEach(listViewAllowedTypes, function (allowedType) {
angular.forEach(allowedType.blueprints, function (value, key) {
blueprints = true;
});
});

if (listViewAllowedTypes.length === 1 && blueprints === false) {
$scope.createAllowedButtonSingle = true;
}
if (listViewAllowedTypes.length === 1 && blueprints === true) {
$scope.createAllowedButtonSingleWithBlueprints = true;
}
if (listViewAllowedTypes.length > 1) {
$scope.createAllowedButtonMultiWithBlueprints = true;
}
});


$scope.contentId = id;
$scope.isTrashed = id === "-20" || id === "-21";
Expand Down Expand Up @@ -650,6 +676,22 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
}
}


function createBlank(entityType,docTypeAlias) {
$location
.path("/" + entityType + "/" + entityType + "/edit/" + $scope.contentId)
.search("doctype=" + docTypeAlias + "&create=true");
}

function createFromBlueprint(entityType,docTypeAlias, blueprintId) {
$location
.path("/" + entityType + "/" + entityType + "/edit/" + $scope.contentId)
.search("doctype=" + docTypeAlias + "&create=true&blueprintId=" + blueprintId);
}

$scope.createBlank = createBlank;
$scope.createFromBlueprint = createFromBlueprint;

//GO!
initView();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,85 @@
<umb-editor-sub-header-content-left>

<umb-editor-sub-header-section ng-if="(listViewAllowedTypes && listViewAllowedTypes.length > 0 && !isAnythingSelected()) && (currentNodePermissions == null || currentNodePermissions.canCreate)">
<div class="btn-group" ng-show="listViewAllowedTypes.length > 1">

<div class="btn-group" ng-show="createAllowedButtonSingle">
<a class="btn" ng-click="createBlank(entityType,listViewAllowedTypes[0].alias)">
<localize key="actions_create">Create</localize> {{listViewAllowedTypes[0].name}}
</a>
</div>

<div class="btn-group" ng-show="createAllowedButtonSingleWithBlueprints">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<localize key="actions_create">Create</localize>
<span ng-click="createBlank(entityType,listViewAllowedTypes[0].alias)">
<localize key="actions_create">Create</localize> {{listViewAllowedTypes[0].name}}
</span>
<span class="caret"></span>
</a>

<ul class="dropdown-menu">
<li ng-repeat="contentType in listViewAllowedTypes | orderBy:'name':false">
<a href="#/{{entityType}}/{{entityType}}/edit/{{contentId}}?doctype={{contentType.alias}}&create=true">
<i class="icon-{{contentType.cssClass}}"></i>
{{contentType.name}}
<li ng-repeat="(key, value) in listViewAllowedTypes[0].blueprints">
<a ng-click="createFromBlueprint(entityType, listViewAllowedTypes[0].blueprints.alias, key)">
<i class="{{listViewAllowedTypes[0].icon}}"></i>
{{value}}
</a>
</li>
</ul>
</div>
<div class="btn-group" ng-show="listViewAllowedTypes.length === 1">
<a class="btn" href="#/{{entityType}}/{{entityType}}/edit/{{contentId}}?doctype={{listViewAllowedTypes[0].alias}}&create=true">
<i class="icon-{{listViewAllowedTypes[0].cssClass}}"></i>
<localize key="actions_create">Create</localize> {{ listViewAllowedTypes[0].name }}

<div class="btn-group" ng-show="createAllowedButtonMultiWithBlueprints">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<localize key="actions_create">Create</localize>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li ng-repeat="contentType in listViewAllowedTypes | orderBy:'name':false">
<a ng-click="createBlank(entityType,contentType.alias)">
<i class="{{contentType.icon}}"></i>
{{contentType.name}} <span ng-show="contentType.blueprints && contentType.blueprints.length != 0" style="text-transform: lowercase;">(<localize key="blueprints_blankBlueprint">blank</localize>)</span>
</a>
<a ng-repeat="(key, value) in contentType.blueprints" ng-click="createFromBlueprint(entityType,contentType.alias , key)">
&nbsp;&nbsp;<i class="{{contentType.icon}}"></i>
{{value}}
</a>
</li>
</ul>
</div>

<ul class="umb-actions umb-actions-child">

<li ng-repeat="(key, value) in docType.blueprints | orderBy:'name':false">
<a ng-click="createFromBlueprint(key)">
<i class="large {{docType.icon}}"></i>
<span class="menu-label">
{{value}} Kim
</span>
</a>
</li>

<li class="sep" ng-show="allowBlank">
<a ng-click="createBlank(docType)">
<i class="large {{docType.icon}}"></i>
<span class="menu-label">
<localize key="blueprints_blankBlueprint">Blank</localize>
</span>
</a>
</li>

</ul>



</umb-editor-sub-header-section>




<umb-editor-sub-header-section ng-if="isAnythingSelected()">
<umb-button
type="button"
label="Clear selection"
label-key="buttons_clearSelection"
action="clearSelection()"
disabled="actionInProgress">
<umb-button type="button"
label="Clear selection"
label-key="buttons_clearSelection"
action="clearSelection()"
disabled="actionInProgress">
</umb-button>
</umb-editor-sub-header-section>

Expand Down

0 comments on commit 3e14da5

Please sign in to comment.