Commit f39497ed authored by colemanw's avatar colemanw
Browse files

Rename blocks & require form name

parent fb66adad
{
"title": "Email Block (default)",
"title": "Email (default)",
"block": "Contact",
"join": "Email",
"repeat": true
......
{
"title": "IM Block (default)",
"title": "IM (default)",
"block": "Contact",
"join": "IM",
"repeat": true
......
{
"title": "Phone Block (default)",
"title": "Phone (default)",
"block": "Contact",
"join": "Phone",
"repeat": true
......
{
"title": "Website Block (default)",
"title": "Website (default)",
"block": "Contact",
"join": "Website",
"repeat": true
......
......@@ -29,13 +29,10 @@
$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',
......@@ -62,10 +59,9 @@
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');
......@@ -75,6 +71,7 @@
}
// 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);
......@@ -114,7 +111,7 @@
};
// 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');
......
......@@ -2,7 +2,7 @@
<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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment