$scope.saving = false;
$scope.selectedEntityName = null;
$scope.meta = this.meta = CRM.afformAdminData;
- _.each($scope.meta.blocks, function(block) {
- evaluate(block.layout);
- });
this.scope = $scope;
var editor = $scope.editor = this;
var newForm = {
- title: ts('Untitled Form'),
+ title: '',
permission: 'access CiviCRM',
layout: [{
'#tag': 'af-form',
if (!$scope.afform) {
$scope.afform = _.cloneDeep(newForm);
if ($scope.afGuiEditor.name != '0') {
- alert('Error: could not find form ' + $scope.afGuiEditor.name);
+ alert('Error: unknown form "' + $scope.afGuiEditor.name + '"');
}
}
- $scope.changesSaved = 1;
$scope.layout = findRecursive($scope.afform.layout, {'#tag': 'af-form'})[0];
$scope.entities = findRecursive($scope.layout['#children'], {'#tag': 'af-entity'}, 'name');
}
// Set changesSaved to true on initial load, false thereafter whenever changes are made to the model
+ $scope.changesSaved = $scope.afGuiEditor.name == '0' ? false : 1;
$scope.$watch('afform', function () {
$scope.changesSaved = $scope.changesSaved === 1;
}, true);
};
// Add default contact name block
if (meta.entity === 'Contact') {
- fieldset['#children'].push({'#tag': 'block-name-' + type.toLowerCase()});
+ fieldset['#children'].push({'#tag': 'afblock-name-' + type.toLowerCase()});
}
// Attempt to place the new af-fieldset after the last one on the form
pos = 1 + _.findLastIndex($scope.layout['#children'], 'af-fieldset');
<div class="panel-heading">
<form class="form-inline">
<div class="btn-group btn-group-md pull-right">
- <button class="btn" ng-class="{'btn-primary': !changesSaved && !saving, 'btn-warning': saving, 'btn-success': changesSaved}" ng-disabled="changesSaved || saving" ng-click="save()">
+ <button type="submit" class="btn" ng-class="{'btn-primary': !changesSaved && !saving, 'btn-warning': saving, 'btn-success': changesSaved}" ng-disabled="changesSaved || saving || !afform.title" ng-click="save()">
<i class="crm-i" ng-class="{'fa-check': !saving, 'fa-spin fa-spinner': saving}"></i>
<span ng-if="changesSaved && !saving">{{ ts('Saved') }}</span>
<span ng-if="!changesSaved && !saving">{{ ts('Save') }}</span>
<label for="af_config_form_title">
- {{ ts('Title:') }}
+ {{ ts('Title:') }} <span class="crm-marker">*</span>
</label>
-<input ng-model="afform.title" class="form-control" id="af_config_form_title" />
+<input ng-model="afform.title" class="form-control" id="af_config_form_title" required />
<label for="af_config_form_description">
{{ ts('Description:') }}
</label>