diff --git a/UmbracoPackages/App_Plugins/brothers.uNesting/_nc.js b/UmbracoPackages/App_Plugins/brothers.uNesting/_nc.js index cb2db49..99c60c5 100644 --- a/UmbracoPackages/App_Plugins/brothers.uNesting/_nc.js +++ b/UmbracoPackages/App_Plugins/brothers.uNesting/_nc.js @@ -1,4 +1,121 @@ -angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.PropertyEditorController", [ +angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.DocTypePickerController", [ + + "$scope", + "Umbraco.PropertyEditors.NestedContent.Resources", + + function ($scope, ncResources) + { + + $scope.add = function () + { + $scope.model.value.push({ + // As per PR #4, all stored content type aliases must be prefixed "nc" for easier recognition. + // For good measure we'll also prefix the tab alias "nc" + ncAlias: "", + ncTabAlias: "", + nameTemplate: "" + }); + } + + $scope.canAdd = function () + { + return !$scope.model.docTypes || !$scope.model.value || $scope.model.value.length < $scope.model.docTypes.length; + } + + $scope.remove = function (index) + { + $scope.model.value.splice(index, 1); + } + + $scope.sortableOptions = { + axis: "y", + cursor: "move", + handle: ".handle", + placeholder: 'sortable-placeholder', + forcePlaceholderSize: true, + helper: function (e, ui) + { + // When sorting table rows, the cells collapse. This helper fixes that: https://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ + ui.children().each(function () + { + $(this).width($(this).width()); + }); + return ui; + }, + start: function (e, ui) + { + + var cellHeight = ui.item.height(); + + // Build a placeholder cell that spans all the cells in the row: https://stackoverflow.com/questions/25845310/jquery-ui-sortable-and-table-cell-size + var cellCount = 0; + $('td, th', ui.helper).each(function () + { + // For each td or th try and get it's colspan attribute, and add that or 1 to the total + var colspan = 1; + var colspanAttr = $(this).attr('colspan'); + if (colspanAttr > 1) + { + colspan = colspanAttr; + } + cellCount += colspan; + }); + + // Add the placeholder UI - note that this is the item's content, so td rather than tr - and set height of tr + ui.placeholder.html('
| + |
+ |
+
+ |
+
+ |
+ + |
|---|---|---|---|---|
| + + | ++ + | ++ + | ++ + | ++ + | +
+
+ Select the group whose properties should be displayed. If left blank, the first group on the element type will be used.
+
+
+ Enter an angular expression to evaluate against each item for its name. Use {{$index}} to display the item index
+