send page start
This commit is contained in:
10
app/assets/javascripts/main.js
Normal file
10
app/assets/javascripts/main.js
Normal file
@ -0,0 +1,10 @@
|
||||
function getPersonPhone(id, collection){
|
||||
for(var i = 0; i < collection.length; i++){
|
||||
if(collection[i].id == id){
|
||||
return collection[i].phone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
});
|
@ -64,3 +64,40 @@ body {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
form {
|
||||
width: 100%;
|
||||
* {
|
||||
font-size: 14px;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
margin: 0.6em 0 0;
|
||||
width: 100%;
|
||||
|
||||
&:after {
|
||||
content: ": ";
|
||||
}
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
margin: 0 0 0.6em;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
[type=submit]{
|
||||
margin: 0.6em 0;
|
||||
}
|
||||
|
||||
textarea{
|
||||
height: 5em;
|
||||
max-width: 300px;
|
||||
padding: 15px;
|
||||
width: calc(100% - 30px);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,4 +4,10 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
respond_to :html, :json
|
||||
|
||||
def current_user
|
||||
# temp
|
||||
Person.new(id: 9999)
|
||||
end
|
||||
helper_method :current_user
|
||||
end
|
||||
|
@ -4,7 +4,15 @@ class PagesController < ApplicationController
|
||||
respond_with @pages
|
||||
end
|
||||
|
||||
def page; end
|
||||
def page
|
||||
@page = Page.new
|
||||
person = Person.find(params[:id])
|
||||
@people = Person.pageable
|
||||
|
||||
return if person.nil?
|
||||
@page.person_id = person.id
|
||||
@page.to = person.phone
|
||||
end
|
||||
|
||||
def send_page
|
||||
end
|
||||
|
@ -15,6 +15,8 @@ class Person < ActiveRecord::Base
|
||||
.uniq
|
||||
}
|
||||
|
||||
scope :pageable, -> { where('phone is not NULL').order(:first_name) }
|
||||
|
||||
scope :staff, -> { where(staff: true) }
|
||||
|
||||
scope :admins, -> { where(admin: true) }
|
||||
|
@ -1,2 +1,22 @@
|
||||
%p send page form
|
||||
%p active class on main navs
|
||||
= form_for :page do |f|
|
||||
= f.hidden_field :user_id, value: current_user.id
|
||||
|
||||
= f.label :person_id
|
||||
= f.select :person_id, options_from_collection_for_select(@people, :id, :name, @page.person_id)
|
||||
|
||||
= f.label :to
|
||||
= f.phone_field :to
|
||||
|
||||
= f.label :message
|
||||
= f.text_area :message
|
||||
|
||||
= f.submit 'Send Page'
|
||||
|
||||
:javascript
|
||||
var people = #{@people.to_json};
|
||||
$('#page_person_id').on('change', function(){
|
||||
$('#page_to').val( getPersonPhone($(this).val(), people) );
|
||||
});
|
||||
|
||||
console.log(people);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
- @parents.each do |parent|
|
||||
%ul
|
||||
%li= parent.name
|
||||
%li #{parent.name} #{page_link(parent)}
|
||||
%li= number_to_phone parent.phone
|
||||
%li= mail_to parent.email
|
||||
%li Children:
|
||||
|
Reference in New Issue
Block a user