|
| 1 | +Migration Notes |
| 2 | +=============== |
| 3 | + |
| 4 | +This document attempts to provide a guide for changes you may require between versions of Angular Schema Form. |
| 5 | + |
| 6 | +0.8.13 -> 1.0.0 |
| 7 | +--------------- |
| 8 | +The path to version 1.0.0 is aiming to stabilise as much as possible the API that Angular Schema Form uses to interact |
| 9 | +with the JSON Schema Form Core. As items are moved out of the library there are many cases where more or less |
| 10 | +information is required by the function calls within the framework. |
| 11 | + |
| 12 | +### Merge |
| 13 | +The signature of the merge function has added `typeDefaults` as the defaults generated are required independantly by the |
| 14 | +function now. There are now defaults for all parameters so a schema is all that is required. |
| 15 | +```js |
| 16 | +schemaForm.merge( |
| 17 | + schema, |
| 18 | + form = [ '*' ], |
| 19 | + typeDefaults = service.typeDefault, |
| 20 | + ignore, |
| 21 | + options = {}, |
| 22 | + readonly = false, |
| 23 | + asyncTemplates |
| 24 | +) |
| 25 | +``` |
| 26 | + |
| 27 | +### sfValidator |
| 28 | +If you were using the validation API directly or in an add-on this is now no longer wrapped in an object to keep it in |
| 29 | +alignment with other functions imported from the core. |
| 30 | + |
| 31 | +The factories are now loaded with: |
| 32 | +```js |
| 33 | +.factory('sfSelect', () => JSONSchemaFormCore.select) |
| 34 | +.factory('sfValidator', () => JSONSchemaFormCore.validate) |
| 35 | +``` |
| 36 | +So when using the factories you now use: |
| 37 | +`sfValidator(form, viewValue)` instead of `sfValidator.validate(form, viewValue)` |
| 38 | + |
| 39 | +**Warning: this will change substantially again as we move away from relying on the no longer maintained tv4 library** |
| 40 | + |
| 41 | +### Input Field Names |
| 42 | +To make arrays work and fields with the same names on different paths no longer clash `id` and `name` attributes are now |
| 43 | +handled with a one-time function call generating a path. |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "comments": [ |
| 48 | + { "comment": "other comment" }, |
| 49 | + { "comment": "my comment" } |
| 50 | + ] |
| 51 | +} |
| 52 | +``` |
| 53 | +In the above example "my comment" would generate from a field with the `id` and `name` attribute |
| 54 | +`ngform-comments-1-comment`. The previous name and id would have been `comment`, by adding the form name and array |
| 55 | +indexes there is no longer issues with conflicts caused by this. |
| 56 | + |
| 57 | +#### CSS Classes |
| 58 | +In addition to the `id` and `name` attibutes, there are additional classes available in the field container to take |
| 59 | +advantage of. For the above example the following classes are added: |
| 60 | +`comments-1-comment` for referencing a specific array position. |
| 61 | +`comments-comment` for all attibutes the same regardless of position. |
| 62 | +`required` for all attibutes the same regardless of position. |
| 63 | + |
| 64 | +### Object.assign polyfill for Internet Explorer |
| 65 | +If you must support legacy browsers then an `Object.assign` polyfill must be used to provide that function to |
| 66 | +non-compliant browsers. There is a polyfil provided by Mozilla [here](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill) or you can use |
| 67 | +Babel with the appropriate plugin module `babel-plugin-transform-object-assign`. |
| 68 | + |
0 commit comments