Skip to content

Commit

Permalink
Merge pull request #2 from skttl/U4-8955
Browse files Browse the repository at this point in the history
Only paste allowed editors
  • Loading branch information
lars-erik authored Jul 1, 2017
2 parents cee073c + 5beda8f commit 424ac8e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/src/less/buttons.less
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

}

.btn-group>.btn+.dropdown-toggle {
.btn-group>.btn~.dropdown-toggle {
box-shadow: none;
-webkit-box-shadow:none;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Web.UI.Client/src/less/canvas-designer.less
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ a, a:hover{
color: #ffffff;
}

.btn-group > .btn + .dropdown-toggle {
.btn-group > .btn ~ .dropdown-toggle {
-webkit-box-shadow: none;
box-shadow: none;
}
Expand All @@ -141,7 +141,7 @@ a, a:hover{
margin-left: -6px;
}

.btn-group > .btn + .dropdown-toggle {
.btn-group > .btn ~ .dropdown-toggle {
padding-right: 8px;
padding-left: 8px;
-webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,18 +645,36 @@ angular.module("umbraco")
setClipboard();
}

$scope.paste = function (event, cell, index, copied) {
var newControl = $.extend({}, copied);
if (copied && copied.editor) {
$scope.allowedEditorsInClipboard = function (cell) {
var allowedEditors = cell.$allowedEditors.map(function (editor) { return editor.alias; });
return $scope.clipboard.filter(function (control) {
return allowedEditors.indexOf(control.editor.alias) > -1;
});
}

$scope.paste = function (event, cell, index, copied) {
if (typeof (copied) == "undefined") {
// should be first allowed editor
var allowedEditors = $scope.allowedEditorsInClipboard(cell);
if (allowedEditors.length == 0) {
return false;
}
else {
copied = allowedEditors[allowedEditors.length - 1];
}
}

var newControl = $.extend({}, copied);
if (copied && copied.editor) {

if (index === undefined) {
index = cell.controls.length;
}

if (index === undefined) {
index = cell.controls.length;
newControl.active = true;
$scope.initControl(newControl, index + 1);
cell.controls.push(newControl);
}

newControl.active = true;
$scope.initControl(newControl, index + 1);
cell.controls.push(newControl);
}
}

// *********************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,16 @@
<div class="umb-grid-add-more-content" ng-if="area.controls.length > 0 && !sortMode">
<div class="cell-tools-add -bar newbtn" ng-click="openEditorOverlay($event, area, 0, area.$uniqueId);"><localize key="grid_addElement"/>
</div>
<div class="cell-tools-button btn-group dropup" ng-if="clipboard.length > 0">
<button type="button" class="btn umb-button__button" ng-click="paste($event, area, 0, clipboard[clipboard.length-1])">
<div class="cell-tools-button btn-group dropup" ng-if="allowedEditorsInClipboard(area).length > 0">
<button type="button" class="btn umb-button__button" ng-click="paste($event, area, 0)">
<i class="icon icon-paste-in"></i>
<localize key="grid_pasteElement" />
</button>
<button ng-if="clipboard.length > 1" type="button" class="btn umb-button__button dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button ng-if="allowedEditorsInClipboard(area).length > 1" type="button" class="btn umb-button__button dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
<ul ng-if="clipboard.length > 1" class="dropdown-menu">
<li ng-repeat="control in clipboard">
<ul ng-if="allowedEditorsInClipboard(area).length > 1" class="dropdown-menu dropdown-menu-right">
<li ng-repeat="control in allowedEditorsInClipboard(area)">
<a ng-click="paste($event, area, 0, control)">
<i class="icon {{ control.editor.icon }}"></i>
<span ng-bind="control.editor.name"></span>
Expand Down

0 comments on commit 424ac8e

Please sign in to comment.