From 5f535e6c13029379818d1668064fa87f1d148101 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 6 Nov 2019 08:29:09 -0500 Subject: [PATCH] GUI: Add block button --- ext/afform/gui/ang/afGuiEditor.css | 16 +++++++++++++++- ext/afform/gui/ang/afGuiEditor.js | 10 ++++++++++ ext/afform/gui/ang/afGuiEditor/block.html | 23 ++++++++++++++++------- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ext/afform/gui/ang/afGuiEditor.css b/ext/afform/gui/ang/afGuiEditor.css index 8047a19184..fd02507575 100644 --- a/ext/afform/gui/ang/afGuiEditor.css +++ b/ext/afform/gui/ang/afGuiEditor.css @@ -88,7 +88,10 @@ } #afGuiEditor #afGuiEditor-canvas .af-entity-selected > .af-gui-bar { background-color: #0071bd; - visibility: visible; + opacity: 1; + transition: opacity 0s; +} +#afGuiEditor #afGuiEditor-canvas .af-entity-selected > .af-gui-bar > span { color: white; } @@ -134,6 +137,17 @@ top: 5px; } +#afGuiEditor .af-gui-add-block-button span { + display: inline-block; + width: 16px; + height: 16px; + border: 2px dashed grey; +} +#afGuiEditor .af-gui-add-block-button span i { + position: relative; + top: -3px; +} + #afGuiEditor .af-gui-layout-icon { width: 12px; height: 11px; diff --git a/ext/afform/gui/ang/afGuiEditor.js b/ext/afform/gui/ang/afGuiEditor.js index 05a60c422d..ecbdeddf6e 100644 --- a/ext/afform/gui/ang/afGuiEditor.js +++ b/ext/afform/gui/ang/afGuiEditor.js @@ -276,6 +276,7 @@ require: '^^afGuiEditor', link: function($scope, element, attrs, editor) { $scope.editor = editor; + $scope.ts = CRM.ts(); }, controller: function($scope) { $scope.block = this; @@ -312,6 +313,15 @@ return null; }; + $scope.addBlock = function(type) { + var newBlock = { + '#tag': type === 'text' ? 'p' : 'div', + 'class': 'af-' + type, + '#children': type == 'block' ? [] : [{'#text': ts('Enter text')}] + }; + $scope.node['#children'].push(newBlock); + }; + $scope.isSelectedFieldset = function(entityName) { return entityName === $scope.editor.getSelectedEntity(); }; diff --git a/ext/afform/gui/ang/afGuiEditor/block.html b/ext/afform/gui/ang/afGuiEditor/block.html index 64570cc63a..45d6c3d750 100644 --- a/ext/afform/gui/ang/afGuiEditor/block.html +++ b/ext/afform/gui/ang/afGuiEditor/block.html @@ -1,13 +1,22 @@
{{ editor.getEntity(entityName).label }} - {{ node['#tag'] }} - -
- +
+ + +
-- 2.25.1