Skip to content

Commit

Permalink
Wording fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Apr 8, 2015
1 parent 5efd203 commit 66898f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,13 @@ These settings are available on all views.

* `fields([field1, field2, ...])`
Add fields to a view (columns to a list, or a form controls to a form). Each field maps a property in the API endpoint result.
Accept both field and array of fields.

listView.fields([
nga.field('first_name'),
nga.field('last_name'),
nga.field('age', 'number')
]);

listView.fields(nga.field('first_name'), [
nga.field('last_name'),
nga.field('age', 'number')
]);

* `fields()` Retrieve the list of fields added to a view. The result can be added to another view, to avoid repetition.

* `title(String)`
Expand Down
19 changes: 11 additions & 8 deletions UPGRADE-0.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ng-admin 0.7 breaks compatibility with 0.5 and makes the "factories" configurati

## Field type

Method `Field.type()` is no longer supported as a setter. Instead, you should specify the second argument from the field factory.
The `Field.type(type)` method is no longer supported as a setter. Instead, you should specify the type as the second argument in the `nga.field()` factory.

``` diff
- nga.field('created_at').type('date')
Expand Down Expand Up @@ -74,13 +74,16 @@ Adding menu children by hand is also the only way to determine the menu order.

The `menuView()` syntax will still be supported in this version, but removed in the next one.

## Passing Literal to `View.fields()` and Using `field.order` Is Deprecated
Prior to 0.7, you could pass both literal and array to the fields methods which returned a literal. Now the fields method return an array. And passing literal to it is deprecated.
Additionaly, the order method which served to order fields passed in literal form is also deprecated.
## Passing Object Literal to `View.fields()` and Using `field.order` Are Deprecated

The proper way to use fields is now by passing field and or arrays of fields.
```
fields(field1, field2)
Calling `view.fields()` as a getter (with no argument) used to return an object literal ; starting with 0.7, it now returns an array.
Symmetrically, passing an object litteral as argument to the setter methor `view.fields(fields)` is deprecated ; only arrays are now officially supported.

Additionaly, the `order()` method, which served to order fields passed in object literal form, is also deprecated.

The proper way to use `fields()` is to pass an array of fields.

```js
fields([field1, field2])
fields(field1, [field2, field3])
fields([field1, [field2, field3]])
```
9 changes: 9 additions & 0 deletions src/javascripts/ng-admin/es6/tests/lib/View/ViewTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ describe('View', function() {
assert.deepEqual(view.fields(), [field1, field2]);
});

it('should add fields when called with a nested array argument', function() {
var view = new View(new Entity('post'));
var field1 = new Field('foo');
var field2 = new Field('bar');
view.fields([field1, [field2]]);

assert.deepEqual(view.fields(), [field1, field2]);
});

it('should add a single field when called with a non array argument', function() {
var view = new View(new Entity('post'));
var field1 = new Field('foo');
Expand Down

0 comments on commit 66898f7

Please sign in to comment.