paging and a little styling
This commit is contained in:
@ -96,7 +96,7 @@ form {
|
||||
textarea{
|
||||
height: 5em;
|
||||
max-width: 300px;
|
||||
padding: 15px;
|
||||
padding: 5px;
|
||||
width: calc(100% - 30px);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ class PagesController < ApplicationController
|
||||
|
||||
def page
|
||||
@page = Page.new
|
||||
person = Person.find(params[:id])
|
||||
person = Person.find_by(id: params[:id])
|
||||
@people = Person.pageable
|
||||
|
||||
return if person.nil?
|
||||
@ -15,5 +15,16 @@ class PagesController < ApplicationController
|
||||
end
|
||||
|
||||
def send_page
|
||||
page = Page.create page_params.merge(status: 'sent')
|
||||
sms = ::SmsSender.new(to: page.to, message: page.message)
|
||||
sms.send!
|
||||
|
||||
redirect_to list_pages_path, notice: "Page sent!"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def page_params
|
||||
params.require(:page).permit(:message, :to, :person_id)
|
||||
end
|
||||
end
|
||||
|
0
app/views/docs/_sub_nav.html.haml
Normal file
0
app/views/docs/_sub_nav.html.haml
Normal file
@ -10,7 +10,7 @@
|
||||
%body
|
||||
= render partial: 'layouts/alerts'
|
||||
= render partial: 'layouts/navigation'
|
||||
= render partial: 'sub_nav' if lookup_context.find_all('sub_nav').any?
|
||||
= render partial: 'sub_nav'
|
||||
= yield
|
||||
= render partial: 'layouts/footer'
|
||||
= yield :modals
|
||||
|
4
app/views/pages/_sub_nav.html.haml
Normal file
4
app/views/pages/_sub_nav.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
%ul.sub-nav
|
||||
%li= link_to 'View Past Pages', list_pages_path
|
||||
%li= link_to 'Send Page', page_person_path
|
||||
|
@ -1,5 +1,25 @@
|
||||
%h1 Pages
|
||||
|
||||
- @pages.each do |page|
|
||||
%ul
|
||||
%li= raw(ap page)
|
||||
%ul.page_listing
|
||||
%li
|
||||
sent by:
|
||||
%span= page.user.name unless page.user.nil?
|
||||
%li
|
||||
to:
|
||||
%span= page.person.name
|
||||
%li
|
||||
phone:
|
||||
%span= page.to
|
||||
%li
|
||||
message:
|
||||
%span= page.message
|
||||
%li
|
||||
status:
|
||||
%span= page.status
|
||||
%li
|
||||
sent at:
|
||||
%span= page.created_at.strftime("%m/%d/%Y %I:%M %p")
|
||||
%li
|
||||
last modified at:
|
||||
%span= page.updated_at.strftime("%m/%d/%Y %I:%M %p")
|
||||
|
@ -1,8 +1,6 @@
|
||||
= form_for :page do |f|
|
||||
= f.hidden_field :user_id, value: current_user.id
|
||||
|
||||
= form_for :page, url: send_page_path do |f|
|
||||
= f.label :person_id
|
||||
= f.select :person_id, options_from_collection_for_select(@people, :id, :name, @page.person_id)
|
||||
= f.select :person_id, options_from_collection_for_select(@people, :id, :name, @page.person_id), include_blank: true
|
||||
|
||||
= f.label :to
|
||||
= f.phone_field :to
|
||||
@ -17,6 +15,3 @@
|
||||
$('#page_person_id').on('change', function(){
|
||||
$('#page_to').val( getPersonPhone($(this).val(), people) );
|
||||
});
|
||||
|
||||
console.log(people);
|
||||
|
||||
|
2
app/views/parents/_sub_nav.html.haml
Normal file
2
app/views/parents/_sub_nav.html.haml
Normal file
@ -0,0 +1,2 @@
|
||||
%ul.sub-nav
|
||||
|
2
app/views/staff/_sub_nav.html.haml
Normal file
2
app/views/staff/_sub_nav.html.haml
Normal file
@ -0,0 +1,2 @@
|
||||
%ul.sub-nav
|
||||
|
2
app/views/users/_sub_nav.html.haml
Normal file
2
app/views/users/_sub_nav.html.haml
Normal file
@ -0,0 +1,2 @@
|
||||
%ul.sub-nav
|
||||
|
@ -4,9 +4,9 @@ class SmsSender
|
||||
attr_accessor :message
|
||||
|
||||
def initialize args_as_hash
|
||||
@from = args_as_hash["from"] ||= ENV["twilio_number"]
|
||||
@to = args_as_hash["to"]
|
||||
@message = args_as_hash["message"]
|
||||
@from = args_as_hash[:from] ||= ENV["twilio_number"]
|
||||
@to = args_as_hash[:to]
|
||||
@message = args_as_hash[:message]
|
||||
end
|
||||
|
||||
def send!
|
Reference in New Issue
Block a user