Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10341: Use different picker for content types #10896

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @description
* The controller for the content type editor property dialog
*/
(function() {
(function () {
'use strict';

function PermissionsController($scope, $timeout, contentTypeResource, iconHelper, contentTypeHelper, localizationService, overlayService) {
function PermissionsController($scope, $timeout, contentTypeResource, iconHelper, contentTypeHelper, localizationService, overlayService, editorService) {
patrickdemooij9 marked this conversation as resolved.
Show resolved Hide resolved

/* ----------- SCOPE VARIABLES ----------- */

Expand All @@ -34,21 +34,21 @@

function init() {

contentTypeResource.getAll().then(function(contentTypes){
vm.contentTypes = _.where(contentTypes, {isElement: false});
contentTypeResource.getAll().then(function (contentTypes) {
vm.contentTypes = _.where(contentTypes, { isElement: false });

// convert legacy icons
iconHelper.formatContentTypeIcons(vm.contentTypes);

vm.selectedChildren = contentTypeHelper.makeObjectArrayFromId($scope.model.allowedContentTypes, contentTypes);

if($scope.model.id === 0) {
contentTypeHelper.insertChildNodePlaceholder(vm.contentTypes, $scope.model.name, $scope.model.icon, $scope.model.id);
if ($scope.model.id === 0) {
contentTypeHelper.insertChildNodePlaceholder(vm.contentTypes, $scope.model.name, $scope.model.icon, $scope.model.id);
}
});

// Can only switch to an element type if there are no content nodes already created from the type.
if ($scope.model.id > 0 && !$scope.model.isElement ) {
if ($scope.model.id > 0 && !$scope.model.isElement) {
contentTypeResource.hasContentNodes($scope.model.id).then(function (result) {
vm.canToggleIsElement = !result;
});
Expand All @@ -58,38 +58,39 @@
}

function addChild($event) {
const dialog = {
view: "itempicker",
availableItems: vm.contentTypes,
selectedItems: vm.selectedChildren,
position: "target",
event: $event,

var editor = {
multiPicker: true,
filterCssClass: "not-allowed not-published",
filter: function (item) {
return !_.findWhere(vm.contentTypes, { udi: item.udi }) || !!_.findWhere(vm.selectedChildren, { udi: item.udi });
},
submit: function (model) {
if (model.selectedItem) {
vm.selectedChildren.push(model.selectedItem);
$scope.model.allowedContentTypes.push(model.selectedItem.id);
}
overlayService.close();
Utilities.forEach(model.selection,
function (item) {
contentTypeResource.getById(item.id).then(function (contentType) {
vm.selectedChildren.push(contentType);
$scope.model.allowedContentTypes.push(item.id);
});
});

editorService.close();
},
close: function() {
overlayService.close();
close: function () {
editorService.close();
}
};

localizationService.localize("contentTypeEditor_chooseChildNode").then(value => {
dialog.title = value;
overlayService.open(dialog);
});
editorService.contentTypePicker(editor);
}

function removeChild(selectedChild, index) {
// remove from vm
vm.selectedChildren.splice(index, 1);
// remove from vm
vm.selectedChildren.splice(index, 1);

// remove from content type model
var selectedChildIndex = $scope.model.allowedContentTypes.indexOf(selectedChild.id);
$scope.model.allowedContentTypes.splice(selectedChildIndex, 1);
// remove from content type model
var selectedChildIndex = $scope.model.allowedContentTypes.indexOf(selectedChild.id);
$scope.model.allowedContentTypes.splice(selectedChildIndex, 1);
}

function sortChildren() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
'use strict';

function PermissionsController($scope, $timeout, mediaTypeResource, iconHelper, contentTypeHelper, localizationService, overlayService) {
function PermissionsController($scope, $timeout, mediaTypeResource, iconHelper, contentTypeHelper, editorService) {

/* ----------- SCOPE VARIABLES ----------- */

Expand Down Expand Up @@ -39,29 +39,30 @@
}

function addChild($event) {
var dialog = {
view: "itempicker",
availableItems: vm.mediaTypes,
selectedItems: vm.selectedChildren,
position: "target",
event: $event,

var editor = {
multiPicker: true,
filterCssClass: "not-allowed not-published",
filter: function (item) {
return !_.findWhere(vm.mediaTypes, { udi: item.udi }) || !!_.findWhere(vm.selectedChildren, { udi: item.udi });
},
submit: function (model) {
if (model.selectedItem) {
vm.selectedChildren.push(model.selectedItem);
$scope.model.allowedContentTypes.push(model.selectedItem.id);
}
overlayService.close();
Utilities.forEach(model.selection,
function (item) {
mediaTypeResource.getById(item.id).then(function (contentType) {
vm.selectedChildren.push(contentType);
$scope.model.allowedContentTypes.push(item.id);
});
});

editorService.close();
},
close: function() {
overlayService.close();
close: function () {
editorService.close();
}
};

localizationService.localize("contentTypeEditor_chooseChildNode").then(value => {
dialog.title = value;
overlayService.open(dialog);
});
editorService.mediaTypePicker(editor);
}

function removeChild(selectedChild, index) {
Expand Down