Added property actions button

This commit is contained in:
Niels Lyngsø
2019-10-23 11:48:13 +02:00
parent 01ddc97e25
commit 6cf697acb2
5 changed files with 123 additions and 0 deletions

View File

@@ -137,6 +137,7 @@
@import "components/umb-grid.less";
@import "components/umb-empty-state.less";
@import "components/umb-property-editor.less";
@import "components/umb-property-actions.less";
@import "components/umb-color-swatches.less";
@import "components/check-circle.less";
@import "components/umb-file-icon.less";

View File

@@ -0,0 +1,45 @@
.umb-property-actions__toggle {
position: relative;
display: flex;
flex: 0 0 auto;
padding: 6px 6px;
text-align: center;
cursor: pointer;
border-radius: 3px;
background-color: @ui-action-hover;
i {
height: 3px !important;
width: 3px !important;
border-radius: 3px;
background: @ui-action-type;
display: inline-block;
margin: 0 2px 0 0;
&:last-child {
margin: 0;
}
}
&:hover {
i {
background: @ui-action-type-hover;
}
}
}
.umb-property .umb-property-actions__toggle {
margin-top: 2px;
opacity: 0;
transition: opacity 120ms;
}
.umb-property:hover .umb-property-actions__toggle,
.umb-property .umb-property-actions__toggle:focus {
opacity: 1;
}
.umb-property-actions .dropdown-menu {
left: auto;
top: auto;
}

View File

@@ -0,0 +1,12 @@
<div class="umb-property-actions" ng-if="vm.actions.length > 0">
<button type="button" class="btn-reset umb-property-actions__toggle" ng-click="vm.toggle()"><i></i><i></i><i></i></button>
<ul class="umb-actions dropdown-menu" role="menu" on-outside-click="vm.close()" ng-if="vm.isOpen" on-close="vm.close()" deep-blur="vm.close()">
<li role="menuitem" lass="umb-action" ng-class="{'sep':action.separatorm, '-opens-dialog': action.opensDialog}" ng-repeat="action in vm.actions">
<button type="button" ng-click="vm.executeAction(action)">
<i class="icon icon-{{action.icon}}" aria-hidden="true"></i>
<span class="menu-label">{{::action.label}}</span>
</button>
</li>
</ul>
</div>

View File

@@ -0,0 +1,62 @@
(function () {
'use strict';
/**
* A component to render the property action toggle
*/
function umbPropertyActionsController(keyboardService) {
var vm = this;
vm.isOpen = false;
function initDropDown() {
keyboardService.bind("esc", function() {
navigationService.hideNavigation();
});
}
function destroyDropDown() {
keyboardService.unbind("esc");
}
vm.toggle = function() {
if (vm.isOpen === true) {
vm.close();
} else {
vm.open();
}
}
vm.open = function() {
vm.isOpen = true;
initDropDown();
}
vm.close = function() {
vm.isOpen = false;
destroyDropDown();
}
vm.executeAction = function(action) {
action.method();
}
vm.$onDestroy = function () {
if (vm.isOpen === true) {
destroyDropDown();
}
}
}
var umbPropertyActionsComponent = {
templateUrl: 'views/components/property/property-actions/umb-property-actions.html',
bindings: {
actions: "<"
},
controllerAs: 'vm',
controller: umbPropertyActionsController
};
angular.module('umbraco.directives').component('umbPropertyActions', umbPropertyActionsComponent);
})();

View File

@@ -18,6 +18,9 @@
<strong class="umb-control-required">*</strong>
</span>
<small ng-bind-html="property.description | preserveNewLineInHtml"></small>
<umb-property-actions actions="property.actions"></umb-property-actions>
</label>
<div class="controls" ng-transclude>