$timeout(function() {
initialize(_.cloneDeep(newForm));
editor.addEntity('Contact');
+ $scope.layout['#children'].push({
+ "#tag": "button",
+ "ng-click": "modelListCtrl.submit()",
+ "#children": [
+ {
+ "#text": "Submit"
+ }
+ ]
+ });
});
}
$scope.layout = getTags($scope.afform.layout, 'af-form')[0];
evaluate($scope.layout['#children']);
$scope.entities = getTags($scope.layout['#children'], 'af-entity', 'name');
- expandFields($scope.layout['#children']);
_.each(_.keys($scope.entities), buildFieldList);
// Set changesSaved to true on initial load, false thereafter whenever changes are made to the model
$scope.fieldList[entityName].push({
"#tag": "af-field",
name: field.name,
- defn: _.cloneDeep(_.pick(field, ['title', 'input_type', 'input_attrs']))
+ defn: {}
});
});
}
controller: function($scope) {
$scope.getEntity = function() {
- return $scope.editor.getEntity($scope.entityName);
+ return $scope.editor ? $scope.editor.getEntity($scope.entityName) : {};
};
$scope.getDefn = function() {
- return $scope.editor.getField($scope.getEntity().type, $scope.node.name);
+ return $scope.editor ? $scope.editor.getField($scope.getEntity().type, $scope.node.name) : {};
};
}
};
return {
restrict: "A",
require: "ngModel",
+ scope: {
+ defaultValue: '='
+ },
link: function(scope, element, attrs, ngModel) {
var ts = CRM.ts();
function read() {
var htmlVal = element.html();
if (!htmlVal) {
- htmlVal = ts('Unnamed');
+ htmlVal = scope.defaultValue;
element.html(htmlVal);
}
ngModel.$setViewValue(htmlVal);
}
ngModel.$render = function() {
- element.html(ngModel.$viewValue || ' ');
+ element.html(ngModel.$viewValue || scope.defaultValue);
};
// Special handling for enter and escape keys
}
// Escape: undo
if (e.which === 27) {
- element.html(ngModel.$viewValue || ' ');
+ element.html(ngModel.$viewValue || scope.defaultValue);
element.blur();
}
});