-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFR] Introducing datetime field #348
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,7 +319,7 @@ A field is the representation of a property of an entity. | |
### General Field Settings | ||
|
||
* `nga.field(name, type)` | ||
Create a new field of the given type. Default type is 'string', so you can omit it. Bundled types include `number`, `string`, `text`, `boolean`, `wysiwyg`, `email`, `date`, `choice`, `choices`, `json`, `file`, and `template` | ||
Create a new field of the given type. Default type is 'string', so you can omit it. Bundled types include `number`, `string`, `text`, `boolean`, `wysiwyg`, `email`, `date`, `datetime`, `choice`, `choices`, `json`, `file`, and `template` | ||
|
||
* `label(string label)` | ||
Define the label of the field. Defaults to the uppercased field name. | ||
|
@@ -330,21 +330,12 @@ Define if the field is editable in the edition form. Usefult to display a field | |
* `order(number|null)` | ||
Define the position of the field in the view. | ||
|
||
* `format(string ['yyyy-MM-dd' by default])` | ||
Define the format for `date` type. | ||
|
||
* `parse(function [no change by default])` | ||
Filter applied to modify date object returned by date picker if needed. | ||
|
||
* `isDetailLink(boolean)` | ||
Tell if the value is a link in the list view. Default to true for the identifier and references field, false otherwise. The link points to the edition view, except for read-only entities, where it points to the show view. | ||
|
||
* `detailLinkRoute(string)` | ||
Define the route for a link in the list view, i.e. `isDetailLink` of the field is true. The default is `edit`, hence the link points to the edition view. The other option is `show` to point to the show view. | ||
|
||
* `choices([{value: '', label: ''}, ...])` | ||
Define array of choices for `choice` type. A choice has both a value and a label. | ||
|
||
* `map(function)` | ||
Define a custom function to transform the value. It receive the value and the corresponding entry. Works in list, edit views and references. | ||
|
||
|
@@ -382,9 +373,32 @@ A list of CSS classes to be added to the corresponding field. If you provide a f | |
* `defaultValue(*)` | ||
Define the default value of the field in the creation form. | ||
|
||
### `choice` and `choices` Field Settings | ||
|
||
* `choices([{value: '', label: ''}, ...])` | ||
Define array of choices for `choice` type. A choice has both a value and a label. | ||
|
||
### `date` Field Settings | ||
|
||
* `format(string ['yyyy-MM-dd' by default])` | ||
|
||
* `parse(function [remove hours, minutes and timezone by default])` | ||
Filter applied to modify date object returned by date picker if needed. | ||
|
||
### `datetime` Field Settings | ||
|
||
* `format(string ['yyyy-MM-dd HH:mm:ss' by default])` | ||
|
||
* `parse(function [no change by default])` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the |
||
Filter applied to modify date object returned by date picker if needed. | ||
|
||
### `template` Field Settings | ||
|
||
* `template(*)` | ||
Define the template to be displayed for fields of type `template` (can be a string or a function). | ||
|
||
### `file` Field Settings | ||
|
||
* `uploadInformation` | ||
Give upload information for `file` field type | ||
- `url`: url for server side upload | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/javascripts/ng-admin/Main/component/service/config/fieldTypes/DateTimeField.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*global define*/ | ||
|
||
define(function (require) { | ||
'use strict'; | ||
|
||
var DateField = require('ng-admin/Main/component/service/config/fieldTypes/DateField'), | ||
utils = require('ng-admin/lib/utils'); | ||
|
||
function DateTimeField() { | ||
DateField.apply(this, arguments); | ||
this._format = 'yyyy-MM-dd HH:mm:ss'; | ||
this._parse = function(date) { | ||
return date; | ||
}; | ||
} | ||
|
||
utils.inherits(DateTimeField, DateField); | ||
|
||
return DateTimeField; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default format for
datetime
field isyyyy-MM-dd HH:mm:ss
, no ?