Skip to content
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

Date and Time fields #931

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gemspec

gem "administrate-field-image"
gem "autoprefixer-rails"
gem "datetime_picker_rails", github: "bronislav/datetime_picker_rails", branch: "update-bootstrap-datetimepicker"
gem "faker"
gem "pg"
gem "redcarpet"
Expand Down
13 changes: 11 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: git://github.com/bronislav/datetime_picker_rails.git
revision: f1cb277bad33a121bc6595dae8c1d09279d07fca
branch: update-bootstrap-datetimepicker
specs:
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)

PATH
remote: .
specs:
Expand All @@ -9,6 +17,7 @@ PATH
datetime_picker_rails (~> 0.0.7)
jquery-rails (>= 4.0)
kaminari (>= 1.0)
moment_timezone-rails (~> 0.5)
momentjs-rails (~> 2.8)
sass-rails (~> 5.0)
selectize-rails (~> 0.6)
Expand Down Expand Up @@ -75,8 +84,6 @@ GEM
crack (0.4.3)
safe_yaml (~> 1.0.0)
database_cleaner (1.6.1)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
diff-lcs (1.3)
dotenv (2.2.1)
dotenv-rails (2.2.1)
Expand Down Expand Up @@ -143,6 +150,7 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.2)
moment_timezone-rails (0.5.0)
momentjs-rails (2.17.1)
railties (>= 3.1)
multipart-post (2.0.0)
Expand Down Expand Up @@ -259,6 +267,7 @@ DEPENDENCIES
bundler-audit
byebug
database_cleaner
datetime_picker_rails!
dotenv-rails
factory_girl_rails
faker
Expand Down
1 change: 1 addition & 0 deletions administrate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |s|
s.add_dependency "jquery-rails", ">= 4.0"
s.add_dependency "kaminari", ">= 1.0"
s.add_dependency "momentjs-rails", "~> 2.8"
s.add_dependency "moment_timezone-rails", "~> 0.5"
s.add_dependency "sass-rails", "~> 5.0"
s.add_dependency "selectize-rails", "~> 0.6"

Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/administrate/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
//= require jquery_ujs
//= require selectize
//= require moment
//= require moment-timezone-with-data
//= require datetime_picker
//= require_tree .
10 changes: 10 additions & 0 deletions app/assets/javascripts/administrate/components/date_time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@ $(function () {
debug: false,
format: "YYYY-MM-DD HH:mm:ss",
});

$(".datepicker").datetimepicker({
debug: false,
format: "YYYY-MM-DD",
});

$(".timepicker").datetimepicker({
debug: true,
format: "HH:mm:ss ZZ",
});
});
24 changes: 24 additions & 0 deletions app/views/fields/date/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%#
# Date Form Partial

This partial renders an input element for a date attribute.
By default, the input is a text field that is augmented with [DatePicker].

## Local variables:

- `f`:
A Rails form generator, used to help create the appropriate input fields.
- `field`:
An instance of [Administrate::Field::Date][1].
A wrapper around the Date value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
[DatePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
%>

<div class="field-unit__label">
<%= f.label field.attribute %>
</div>
<div class="field-unit__field">
<%= f.text_field field.attribute, class: "datepicker" %>
</div>
21 changes: 21 additions & 0 deletions app/views/fields/date/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%#
# Date Index Partial

This partial renders a date attribute,
to be displayed on a resource's index page.

By default, the attribute is rendered
as a localized date string.

## Local variables:

- `field`:
An instance of [Administrate::Field::Date][1].
A wrapper around the Date value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
%>

<% if field.data %>
<%= field.date %>
<% end %>
21 changes: 21 additions & 0 deletions app/views/fields/date/_show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%#
# Date Show Partial

This partial renders a date attribute,
to be displayed on a resource's show page.

By default, the attribute is rendered
as a localized date string.

## Local variables:

- `field`:
An instance of [Administrate::Field::Date][1].
A wrapper around the Date value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
%>

<% if field.data %>
<%= field.date %>
<% end %>
24 changes: 24 additions & 0 deletions app/views/fields/time/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%#
# Time Form Partial

This partial renders an input element for a time attribute.
By default, the input is a text field that is augmented with [DatePicker].

## Local variables:

- `f`:
A Rails form generator, used to help create the appropriate input fields.
- `field`:
An instance of [Administrate::Field::Time][1].
A wrapper around the Time value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Time
[DatePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
%>

<div class="field-unit__label">
<%= f.label field.attribute %>
</div>
<div class="field-unit__field">
<%= f.text_field field.attribute, class: "timepicker" %>
</div>
21 changes: 21 additions & 0 deletions app/views/fields/time/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%#
# Time Index Partial

This partial renders a time attribute,
to be displayed on a resource's index page.

By default, the attribute is rendered
as a localized time string.

## Local variables:

- `field`:
An instance of [Administrate::Field::Time][1].
A wrapper around the Time value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Time
%>

<% if field.data %>
<%= field.time %>
<% end %>
21 changes: 21 additions & 0 deletions app/views/fields/time/_show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%#
# Time Show Partial

This partial renders a time attribute,
to be displayed on a resource's show page.

By default, the attribute is rendered
as a localized time string.

## Local variables:

- `field`:
An instance of [Administrate::Field::Time][1].
A wrapper around the Time value pulled from the database.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Time
%>

<% if field.data %>
<%= field.time %>
<% end %>
3 changes: 3 additions & 0 deletions config/locales/administrate.ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ar:
search:
clear: مسح البحث
label: بحث %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ da:
search:
clear: Ryd søgning
label: Søg %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ de:
search:
clear: Saubere Suche
label: Suche %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ en:
search:
clear: Clear search
label: Search %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ es:
search:
clear: Borrar búsqueda
label: Buscar %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ fr:
search:
clear: Effacer la recherche
label: Chercher %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ it:
search:
clear: Cancella ricerca
label: Ricerca %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ja:
search:
clear: 検索をクリアする
label: サーチ %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ko:
search:
clear: 검색 초기화
label: "%{resource} 검색"
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ nl:
search:
clear: CDuidelijke zoek
label: Zoeken %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ pl:
search:
clear: Wyczyść wyszukiwanie
label: Szukanie %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ pt-BR:
search:
clear: Limpar pesquisa
label: Pesquisa %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ pt:
search:
clear: Limpar pesquisa
label: Pesquisa %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ru:
search:
clear: Очистить поиск
label: Поиск %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ sv:
search:
clear: Rensa sökningen
label: Sök %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ uk:
search:
clear: Очистити пошук
label: пошук %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.vi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ vi:
search:
clear: Tìm kiếm rõ ràng
label: Tìm kiếm %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ zh-CN:
search:
clear: 清除搜索
label: 搜索 %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
3 changes: 3 additions & 0 deletions config/locales/administrate.zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ zh-TW:
search:
clear: 清除搜索
label: 搜索 %{resource}
time:
formats:
time_without_date: "%H:%M:%S"
2 changes: 2 additions & 0 deletions docs/customizing_dashboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ specify, including:

- `Field::BelongsTo`
- `Field::Boolean`
- `Field::Date`
- `Field::DateTime`
- `Field::Time`
- `Field::Email`
- `Field::HasMany`
- `Field::HasOne`
Expand Down
2 changes: 2 additions & 0 deletions lib/administrate/base_dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "administrate/field/belongs_to"
require "administrate/field/boolean"
require "administrate/field/date"
require "administrate/field/date_time"
require "administrate/field/email"
require "administrate/field/has_many"
Expand All @@ -9,6 +10,7 @@
require "administrate/field/select"
require "administrate/field/string"
require "administrate/field/text"
require "administrate/field/time"

module Administrate
class BaseDashboard
Expand Down
1 change: 1 addition & 0 deletions lib/administrate/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "jquery-rails"
require "kaminari"
require "momentjs-rails"
require "moment_timezone/rails"
require "sass-rails"
require "selectize-rails"
require "sprockets/railtie"
Expand Down
Loading