aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/clients_controller.rb2
-rw-r--r--app/views/clients/_form.html.haml34
-rw-r--r--app/views/clients/new.html.haml35
-rw-r--r--app/views/home/index.html.haml2
4 files changed, 37 insertions, 36 deletions
diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb
index f0b58a5..6110029 100644
--- a/app/controllers/clients_controller.rb
+++ b/app/controllers/clients_controller.rb
@@ -25,7 +25,7 @@ class ClientsController < ApplicationController
def find
query = params[:q].downcase
json = Client.where('lower(first_name) LIKE ? OR lower(last_name) LIKE ? OR mobile_number = ?', query, query, query)
- .select(:uuid, :first_name, :last_name)
+ .select(:uuid, :first_name, :last_name, :mobile_number)
.as_json
render json: json
diff --git a/app/views/clients/_form.html.haml b/app/views/clients/_form.html.haml
new file mode 100644
index 0000000..42db615
--- /dev/null
+++ b/app/views/clients/_form.html.haml
@@ -0,0 +1,34 @@
+%h3 Client Information
+
+.grid
+ = f.input :first_name
+ = f.input :last_name
+= f.input :mobile_number
+= f.input :address
+
+%h3 Household Members
+%table
+ %thead
+ %th First Name
+ %th Last Name
+ %th Member Type
+
+ %tbody{ 'data-nested-fields-target': 'fields' }
+
+ %template{ 'data-nested-fields-target': 'template' }
+ %tr
+ = simple_fields_for 'client[household_members_attributes][]', HouseholdMember.new, index: '__INDEX__' do |hm_f|
+ %td
+ = hm_f.input :first_name, label: false
+ %td
+ = hm_f.input :last_name, label: false
+ %td
+ = hm_f.collection_radio_buttons :member_type, HouseholdMember::MEMBER_TYPES, :first, :last, label: false
+
+= button_tag "Add Member", type: :button, data: { action: "nested-fields#append" }
+
+= f.input :notes, as: :text
+
+%br
+%br
+= f.submit
diff --git a/app/views/clients/new.html.haml b/app/views/clients/new.html.haml
index ea5748e..1026175 100644
--- a/app/views/clients/new.html.haml
+++ b/app/views/clients/new.html.haml
@@ -3,37 +3,4 @@
%b Register a New Client
= simple_form_for @client, data: { controller: 'nested-fields' } do |f|
- %h3 Client Information
-
- .grid
- = f.input :first_name
- = f.input :last_name
- = f.input :mobile_number
- = f.input :address
-
- %h3 Household Members
- %table
- %thead
- %th First Name
- %th Last Name
- %th Member Type
-
- %tbody{ 'data-nested-fields-target': 'fields' }
-
- %template{ 'data-nested-fields-target': 'template' }
- %tr
- = simple_fields_for 'client[household_members_attributes][]', HouseholdMember.new, index: '__INDEX__' do |hm_f|
- %td
- = hm_f.input :first_name, label: false
- %td
- = hm_f.input :last_name, label: false
- %td
- = hm_f.collection_radio_buttons :member_type, HouseholdMember::MEMBER_TYPES, :first, :last, label: false
-
- = button_tag "Add Member", type: :button, data: { action: "nested-fields#append" }
-
- = f.input :notes, as: :text
-
- %br
- %br
- = f.submit
+ = render 'form', f: f
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml
index 52fcd4c..615a478 100644
--- a/app/views/home/index.html.haml
+++ b/app/views/home/index.html.haml
@@ -25,7 +25,7 @@
new TomSelect('#search',{
valueField: 'uuid',
labelField: 'first_name',
- searchField: [ 'first_name', 'last_name' ],
+ searchField: [ 'first_name', 'last_name', 'mobile_number' ],
load: function(query, callback) {