-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
99 additions
and
8 deletions.
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
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
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,30 @@ | ||
module Slots | ||
class Builder | ||
def initialize(user, params) | ||
@user = user | ||
@params = params | ||
end | ||
|
||
def call | ||
Slot.new(slot_params) | ||
end | ||
|
||
private | ||
|
||
attr_reader :user, :params | ||
|
||
def slot_params | ||
{ user: user, | ||
scheduled_at: scheduled_at, | ||
notes: safe_params[:notes] } | ||
end | ||
|
||
def safe_params | ||
params.require(:slot).permit(:scheduled_at_date, :scheduled_at_time, :notes) | ||
end | ||
|
||
def scheduled_at | ||
DateTime.parse("#{safe_params[:scheduled_at_date]} #{safe_params[:scheduled_at_time]}") | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div id="slot-creation-modal" class="modal"> | ||
<%= form_with model: Slot.new, html: { class: 'new-slot' } do |f| %> | ||
<div class="modal-content"> | ||
<h4>Create a new slot</h4> | ||
<div class="row"> | ||
<div class="input-field col s12"> | ||
<i class="material-icons prefix">date_range</i> | ||
<%= f.text_field :scheduled_at_date, class: 'datepicker', placeholder: 'Scheduled date' %> | ||
</div> | ||
|
||
<div class="input-field col s12"> | ||
<i class="material-icons prefix">access_time</i> | ||
<%= f.text_field :scheduled_at_time, class: 'timepicker', placeholder: 'Scheduled time' %> | ||
</div> | ||
<div class="input-field col s12"> | ||
<i class="material-icons prefix">event_note</i> | ||
<%= f.text_area :notes, placeholder: 'Notes', rows: 10 %> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<%= f.submit 'Create slot', class: 'modal-close waves-effect waves-green btn-flat' %> | ||
</div> | ||
<% end %> | ||
</div> |
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