],
'css' => ['ang/afGuiEditor.css'],
'partials' => ['ang/afGuiEditor'],
- 'requires' => ['crmUi', 'crmUtil', 'dialogService', 'api4'],
+ 'requires' => ['crmUi', 'crmUtil', 'dialogService', 'api4', 'crmMonaco'],
'settings' => [],
'basePages' => [],
'exports' => [
}
}
$scope.canvasTab = 'layout';
+ $scope.layoutHtml = '';
$scope.layout = findRecursive($scope.afform.layout, {'#tag': 'af-form'})[0];
$scope.entities = findRecursive($scope.layout['#children'], {'#tag': 'af-entity'}, 'name');
}, true);
}
+ $scope.updateLayoutHtml = function() {
+ $scope.layoutHtml = '...Loading...';
+ crmApi4('Afform', 'convert', {layout: [$scope.layout], from: 'deep', to: 'html', formatWhitespace: true})
+ .then(function(r){
+ $scope.layoutHtml = r[0].layout || '(Error)';
+ })
+ .catch(function(r){
+ $scope.layoutHtml = '(Error)';
+ });
+ };
+
this.addEntity = function(type) {
var meta = editor.meta.entities[type],
num = 1;
<span>{{ ts('Form Layout') }}</span>
</a>
</li>
+ <li role="presentation" ng-class="{active: canvasTab === 'markup'}">
+ <a ng-click="canvasTab = 'markup'; updateLayoutHtml()">
+ <span>{{ ts('Markup') }}</span>
+ </a>
+ </li>
</ul>
</div>
<div id="afGuiEditor-canvas-body" class="panel-body" ng-if="canvasTab === 'layout'">
<div ng-if="layout" af-gui-container="layout" entity-name="" />
</div>
+ <div class="panel-body" ng-if="canvasTab === 'markup'">
+ <p class="help-block">{{ts('This is a read-only preview of the auto-generated markup.')}}</p>
+ <!-- Wiring up edit mode wouldn't be super-hard in itself, but it's not worthwhile until we have validation to ensure that GUI+raw content are exchangeable -->
+ <div crm-monaco="{readOnly: true}" ng-model="layoutHtml"></div>
+ </div>
+
</div>