Commit | Line | Data |
---|---|---|
7f9236da CW |
1 | (function(angular, $, _) { |
2 | // Whitelist of all allowed properties of an af-fieldset | |
3 | // (at least the ones we care about client-side - other's can be added for server-side processing and we'll just ignore them) | |
4 | var modelProps = { | |
5 | type: '@', | |
6 | data: '=', | |
7 | modelName: '@name', | |
8 | label: '@', | |
9 | autofill: '@' | |
10 | }; | |
11 | // Example usage: <af-form><af-entity name="Person" type="Contact" /> ... <fieldset af-fieldset="Person"> ... </fieldset></af-form> | |
12 | angular.module('af').component('afEntity', { | |
13 | require: {afForm: '^afForm'}, | |
14 | bindings: modelProps, | |
15 | controller: function() { | |
16 | ||
17 | this.$onInit = function() { | |
18 | var entity = _.pick(this, _.keys(modelProps)); | |
19 | entity.id = null; | |
20 | this.afForm.registerEntity(entity); | |
21 | }; | |
22 | } | |
23 | ||
24 | }); | |
25 | })(angular, CRM.$, CRM._); |