From 79e7f410a7ab1b0050d5ff8d4ad91c691ec7d3f3 Mon Sep 17 00:00:00 2001 From: brutu33 Date: Fri, 31 Aug 2018 19:30:31 +0300 Subject: [PATCH 1/5] change training logic --- app/assets/javascripts/trainings.js | 7 +- app/assets/stylesheets/application.css.scss | 21 ++++ app/controllers/clients_controller.rb | 1 + app/controllers/trainings_controller.rb | 6 +- app/views/layouts/_navigation.html.slim | 120 -------------------- app/views/layouts/application.html.erb | 2 +- app/views/layouts/application.html.slim | 20 ---- app/views/payments/index.html.slim | 2 +- app/views/trainings/join_clients.html.erb | 32 +++++- app/views/trainings/new.html.erb | 79 +++---------- db/seeds.rb | 43 +++++++ 11 files changed, 113 insertions(+), 220 deletions(-) delete mode 100644 app/views/layouts/_navigation.html.slim delete mode 100644 app/views/layouts/application.html.slim diff --git a/app/assets/javascripts/trainings.js b/app/assets/javascripts/trainings.js index 2c1fd94..f5f6dbd 100644 --- a/app/assets/javascripts/trainings.js +++ b/app/assets/javascripts/trainings.js @@ -1,8 +1,13 @@ $(document).ready(function(){ - $('#clients_select').dropdown({onChange(value, text, selItem) { + // $('#clients_select').dropdown({onChange(value, text, selItem) { + //todo: + $('.ui.dropdown').dropdown({onChange(value, text, selItem) { join_clients(JSON.stringify(value)); }}); + $('.exercises-types-select').dropdown({onChange(value, text, selItem) { + }}); + $('#training_date').calendar({ type: 'date' }); diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 1dd748e..74fa0bb 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -41,17 +41,38 @@ .ui.raised.container.segment { //#container-segment { margin-top: 23px; + margin-right: auto !important; + margin-left: auto !important; +} + +#bottom-segment { + width: calc(100% - 210px); + margin-left: 210px; } @media only screen and (max-width: 1144px) { #fixed-sidebar { display: none; } + #kek { + margin-top: 4rem; + } #toggle-sidebar, #menu-sidebar { display: flex; } + #bottom-segment { + margin-left: auto; + width: 100%; + } + + table.ui.unstackable.selectable.table { + overflow: scroll; + display: block; + width: 100%; + overflow-y: hidden; + } } @media only screen and (min-width: 1145px) { diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index fe9bc86..1f67965 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -62,6 +62,7 @@ def find_client end def client_params + # todo: check params params[:status] = params[:status].to_i params[:gender] = params[:gender].to_i params[:metric_ids].map!(&:to_i) diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 41b86a5..b5f0721 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -26,11 +26,6 @@ def show def new @clients = current_user.clients @training = current_user.trainings.build - # todo: parse and set to calendar input - date = params[:date][0...10] - @day = date[8].to_i == 0 ? date[9] : date[8..9] - @month = date[5].to_i == 0 ? date[6] : date[5..6] - @year = date[0..3] end def join_clients @@ -39,6 +34,7 @@ def join_clients JSON.parse(params[:clients]).include?(client.id.to_s) end end + @exercises = ExerciseType.all render layout: false end diff --git a/app/views/layouts/_navigation.html.slim b/app/views/layouts/_navigation.html.slim deleted file mode 100644 index 78631a4..0000000 --- a/app/views/layouts/_navigation.html.slim +++ /dev/null @@ -1,120 +0,0 @@ -/ <<<<<<< HEAD -/ / - if user_signed_in? -/ / - if current_user.admin? -/ / .container -/ / - else -/ / / .ui.left.demo.vertical.visible.inverted.sidebar.labeled.icon.menu -/ / / a.item -/ / / i.calendar.icon -/ / / | Calendar -/ / / a.item -/ / / i.users.layout.icon -/ / / | Clients -/ / / a.item -/ / / i.cog.icon -/ / / | Settings -/ / -/ / -/ / .ui.sidebar.inverted.visible.vertical.menu -/ / .item -/ / a href="/" -/ / h1 FitFree -/ / a.item href="#{calendar_index_path}" -/ / i.calendar.icon -/ / | Calendar -/ / a.item href="#{clients_path}" -/ / i.users.layout.icon -/ / | Clients -/ / a.item -/ / i.cog.icon -/ / | Settings -/ / .pusher -/ / -/ / -/ / -/ / / .ui.top.attached.demo.menu -/ / / a.item -/ / / i.sidebar.icon -/ / / | Menu -/ / / .ui.sidebar.inverted.vertical.menu -/ / / .item -/ / / a href="/" -/ / / b UI Docs -/ / / a.item -/ / / | Calendar -/ / / a.item -/ / / | Clients -/ / / a.item -/ / / | Settings -/ / -/ / -/ / -/ / -/ / / .nav-side-menu -/ / / .brand Fit Free -/ / / i.fa.fa-bars.fa-2x.toggle-btn data-target="#menu-content" data-toggle="collapse" -/ / / .menu-list -/ / / li -/ / / a href="#{calendar_index_path}" -/ / / i.fa.fa-calendar.fa-lg -/ / / | Calendar -/ / / li -/ / / a href="#{clients_path}" -/ / / i.fa.fa-users.fa-lg -/ / / | Clients -/ / / li.collapsed data-target="#settings" data-toggle="collapse" -/ / / a href="#" -/ / / i.fa.fa-globe.fa-lg -/ / / | Settings -/ / / span.arrow -/ / / ul#settings.sub-menu.collapse -/ / / li -/ / / a href="#{metrics_path}" -/ / / -/ / / | Metrics -/ / / li -/ / / a href="#{exercise_types_path}" -/ / / -/ / / | Exercise types -/ / -/ / - else -/ / = link_to 'Log In', new_user_session_path, class: 'btn btn-primary float-right float-top' -/ / = link_to 'I am admin, and i want to log in', new_administrator_session_path, class: 'btn btn-primary float-right float-top' -/ ======= -/ - if user_signed_in? -/ .nav-side-menu -/ .brand Fit Free -/ i.fa.fa-bars.fa-2x.toggle-btn data-target="#menu-content" data-toggle="collapse" -/ .menu-list -/ li -/ a href="#{calendar_index_path}" -/ div -/ i.fa.fa-calendar.fa-lg -/ | #{t('navigation.calendar')} -/ li -/ a href="#{clients_path}" -/ div -/ i.fa.fa-users.fa-lg -/ | #{t('navigation.clients')} -/ li.collapsed data-target="#settings" data-toggle="collapse" -/ a href="#" -/ div -/ i.fa.fa-globe.fa-lg -/ | #{t('navigation.settings')} -/ span.arrow -/ ul#settings.sub-menu.collapse -/ li -/ a href="#{metrics_path}" -/ div -/ -/ | #{t('navigation.metrics')} -/ li -/ a href="#{exercise_types_path}" -/ div -/ -/ | #{t('navigation.exercise_types')} -/ -/ - else -/ = link_to t('log_in'), new_user_session_path, class: 'btn btn-primary float-right float-top' -/ = link_to t('admin_log_in'), new_administrator_session_path, class: 'btn btn-primary float-right float-top' -/ >>>>>>> Alex diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index baf77cd..435634e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -73,7 +73,7 @@ Menu -
+
<%= render 'layouts/messages' %> <%= yield %>
diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim deleted file mode 100644 index 8ae2d2c..0000000 --- a/app/views/layouts/application.html.slim +++ /dev/null @@ -1,20 +0,0 @@ -doctype html -html - head - meta[name="viewport" content="width=device-width, initial-scale=1.0"] - title - = content_for?(:title) ? yield(:title) : 'Fit Free' - meta name="description" content="#{content_for?(:description) ? yield(:description) : 'Fit Free'}" - == stylesheet_link_tag "application", :media => 'all' - == javascript_include_tag 'application' - script src="https://use.fontawesome.com/d1341f9b7a.js" - == csrf_meta_tags - body - header - link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" / - == render 'layouts/navigation' - main[role="main"] - - if user_signed_in? - = link_to t('sing_out'), destroy_user_session_path, method: :delete, class: 'btn btn-primary float-right float-top' - == render 'layouts/messages' - == yield diff --git a/app/views/payments/index.html.slim b/app/views/payments/index.html.slim index 10625fc..cc15b7d 100644 --- a/app/views/payments/index.html.slim +++ b/app/views/payments/index.html.slim @@ -29,7 +29,7 @@ /todo: change depends screen size => .html.ui.top.attached.segment .ui.raised.container.segment .ui.top.attached.label - h4 Adding payments for client + h3 Adding payments for client #content br h2 #{t('payments.index.current_balance')} #{@result_balance} diff --git a/app/views/trainings/join_clients.html.erb b/app/views/trainings/join_clients.html.erb index bfffa49..e6e9ae6 100644 --- a/app/views/trainings/join_clients.html.erb +++ b/app/views/trainings/join_clients.html.erb @@ -1,11 +1,31 @@ <% if @clients.any? %> <% @clients.each do |client| %> - -
-
-
$
- + +
+

<%= client.full_name %>

+
+
+
$
+ +
+
+ <% if @exercises.present? %> + + <% else %> + + + <% end %> +
+ + + +
<% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/trainings/new.html.erb b/app/views/trainings/new.html.erb index 2004888..bb515cb 100644 --- a/app/views/trainings/new.html.erb +++ b/app/views/trainings/new.html.erb @@ -36,76 +36,23 @@

Clients

-
- <% if @clients.present? %> - - <% else %> - Create client - <% end %> -
-
-
- - -
-

Exercise

-
- +
+ <% if @clients.present? %> + + <% else %> + Create client + <% end %> +
+
- - - <%# if @clients.any? %> - - - - - - - - - - - - - - - - - - - <%# for @client in @clients %> - - <%#end %> - - - - - - - - - - <%# for @client in @clients %> - - <%#end %> - - - - - - - - <%#end %> - - diff --git a/db/seeds.rb b/db/seeds.rb index bdc95d8..c924ea5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -15,6 +15,49 @@ %w[Sit-ups Pull-ups Push-ups].each do |name| Metric.find_or_create_by(name: name, units: 'repeats', kind_id: 1) end + +ExerciseType.create(name: 'Bench press with chest standing', description: '') +ExerciseType.create(name: 'Press of dumbbells', description: '') +ExerciseType.create(name: 'Mahi dumbbells in the sides', description: '') +ExerciseType.create(name: 'Pulling the head with a wide grip', description: '') +ExerciseType.create(name: 'Push-ups from the floor with a wide grip', description: '') +ExerciseType.create(name: 'Pressing dumbbells at an angle of 30-40 °', description: '') +ExerciseType.create(name: 'Press the rod at an angle of 30-40 °', description: '') +ExerciseType.create(name: 'Hyperextension', description: '') +ExerciseType.create(name: 'Deadlift on straight legs', description: '') +ExerciseType.create(name: 'Static draft with dumbbells', description: '') +ExerciseType.create(name: 'Pulling up to the chest with a wide grip', description: '') +ExerciseType.create(name: 'Thrust of horizontal block', description: '') +ExerciseType.create(name: 'Thrust T-neck in slope', description: '') +ExerciseType.create(name: 'Pulling in a Smith machine', description: '') +ExerciseType.create(name: 'Thrust from the upper block with a narrow handle', description: '') +ExerciseType.create(name: 'Pull-ups', description: '') +ExerciseType.create(name: 'Bending of arms with a standing post', description: '') +ExerciseType.create(name: 'Bending of hands with dumbbells', description: '') +ExerciseType.create(name: 'Push-ups from the beams on the triceps', description: '') +ExerciseType.create(name: 'Push-ups with a narrow grip from the floor', description: '') +ExerciseType.create(name: 'Press bar with a narrow grip', description: '') +ExerciseType.create(name: 'Flexion of the wrists with the bar sitting', description: '') +ExerciseType.create(name: 'Extension of hands with a bar sitting', description: '') +ExerciseType.create(name: 'Lifting the legs in the vise', description: '') +ExerciseType.create(name: 'Lifting the legs on an incline bench', description: '') +ExerciseType.create(name: 'Twisting on an incline bench', description: '') +ExerciseType.create(name: 'Twisting in a Roman chair', description: '') +ExerciseType.create(name: 'Squats', description: '') +ExerciseType.create(name: 'Impacts with a barbell', description: '') +ExerciseType.create(name: 'Dumbbells with dumbbells', description: '') +ExerciseType.create(name: 'Standing rod standing on a stand', description: '') +ExerciseType.create(name: 'Squats', description: '') +ExerciseType.create(name: 'Squats with a barbell on the chest', description: '') +ExerciseType.create(name: 'Pressing your feet in the machine', description: '') +ExerciseType.create(name: 'Deadlift on straight legs', description: '') +ExerciseType.create(name: 'Leg bending in the machine', description: '') +ExerciseType.create(name: 'Side Effects', description: '') +ExerciseType.create(name: 'Bringing the hip in a crossover', description: '') +ExerciseType.create(name: 'Ascent to the socks in a standing machine', description: '') +ExerciseType.create(name: 'Ascent to the socks in a sitting simulator', description: '') + + puts 'Created strength metrics' superadmin = Administrator.create(email: 'superadmin@gmail.com', password: admin_password, From 395a5f5f36a323871b4beed9229307a74b367f64 Mon Sep 17 00:00:00 2001 From: brutu33 Date: Sat, 1 Sep 2018 04:45:28 +0300 Subject: [PATCH 2/5] training in process --- app/assets/javascripts/trainings.js | 22 +++++-- app/controllers/trainings_controller.rb | 43 ++++++++++--- app/controllers/webhooks_controller.rb | 3 - app/models/training.rb | 2 +- app/views/trainings/exercises.html.erb | 53 ++++++++++++++++ app/views/trainings/join_clients.html.erb | 11 ++-- app/views/trainings/new.html.erb | 61 +++++++++++-------- config/routes.rb | 1 + db/migrate/20180805114652_create_trainings.rb | 2 +- 9 files changed, 145 insertions(+), 53 deletions(-) create mode 100644 app/views/trainings/exercises.html.erb diff --git a/app/assets/javascripts/trainings.js b/app/assets/javascripts/trainings.js index f5f6dbd..e0fa4c6 100644 --- a/app/assets/javascripts/trainings.js +++ b/app/assets/javascripts/trainings.js @@ -1,13 +1,9 @@ $(document).ready(function(){ // $('#clients_select').dropdown({onChange(value, text, selItem) { - //todo: - $('.ui.dropdown').dropdown({onChange(value, text, selItem) { + $('.client-select').dropdown({onChange(value, text, selItem) { join_clients(JSON.stringify(value)); }}); - $('.exercises-types-select').dropdown({onChange(value, text, selItem) { - }}); - $('#training_date').calendar({ type: 'date' }); @@ -28,13 +24,27 @@ function join_clients(clients_ids) { xhttp.onreadystatechange = function() { if (this.readyState === 4 && this.status === 200) { document.getElementById("clients_continer").innerHTML = this.responseText; + $('.exercises-types-select').dropdown({onChange(value, text, selItem) { + add_exercise_params(this.id, JSON.stringify(value)); + }}); } }; xhttp.open("POST", "/trainings/clients", true); xhttp.send(form_data); } - +function add_exercise_params (elem_id, clients_ids) { + var form_data = new FormData(); + form_data.append('erercises', clients_ids); + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 200) { + document.getElementById(`exercise_continer_${elem_id}`).innerHTML = this.responseText; + } + }; + xhttp.open("POST", "/trainings/exercises", true); + xhttp.send(form_data); +} function add_exercise() { $('.tiny.modal').modal('show'); diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index b5f0721..aa06060 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -6,7 +6,7 @@ class TrainingsController < ApplicationController before_action :find_training, only: %i[show edit update cancel destroy] before_action :authenticate_user! # protect_from_forgery with: :null_session - skip_before_action :verify_authenticity_token, only: %i[join_clients] + skip_before_action :verify_authenticity_token, only: %i[join_clients exercises] def index @@ -25,19 +25,46 @@ def show def new @clients = current_user.clients - @training = current_user.trainings.build + (current_user.trainings.find_by(status: 0))&.delete + training = current_user.trainings.build + redirect_url calendar_path, alert: "Couldn't create training" unless training.save end def join_clients - if params[:clients] && params[:clients].present? + training.clients.each do |client| + training.clients.destroy(client) unless JSON.parse(params[:clients]).include?(client.id.to_s) + end + if params[:clients]&.present? @clients = current_user.clients.select do|client| - JSON.parse(params[:clients]).include?(client.id.to_s) + if client && JSON.parse(params[:clients]).include?(client.id.to_s) + client.trainings << training unless client.trainings.include?(training) + client + end end end @exercises = ExerciseType.all render layout: false end + def training + @training ||= current_user.trainings.find_by(status: 0) + end + + def client_with_current_training + current_user.clients.select do |client| + client if client && client.trainings.include?(training) + end + end + + def exercises + if params[:erercises]&.present? + @exercises = ExerciseType.select do|exe| + JSON.parse(params[:erercises]).include?(exe.id.to_s) + end + end + render layout: false + end + def client_list current_user.clients.map do |client| # Client.where(user_id: user).map do |client| @@ -58,13 +85,13 @@ def create start_time = @training.time end_time = start_time + 2.hours summary = Client.find_by(id: @training.client_id).full_name - event = Google::Apis::CalendarV3::Event.new({ + event = Google::Apis::CalendarV3::Event.new( id: 'training' + @training.id.to_s + 'fitfree1asslcom', start: Google::Apis::CalendarV3::EventDateTime.new(date_time: (start_time - 3.hours).to_datetime.rfc3339), end: Google::Apis::CalendarV3::EventDateTime.new(date_time: (end_time - 3.hours).to_datetime.rfc3339), summary: summary, description: @training.description - }) + ) service.insert_event(calendar_id, event) end rescue Google::Apis::AuthorizationError @@ -99,12 +126,12 @@ def update start_time = @training.time end_time = start_time + 2.hours summary = Client.find_by(id: @training.client_id).full_name - event = Google::Apis::CalendarV3::Event.new({ + event = Google::Apis::CalendarV3::Event.new( start: Google::Apis::CalendarV3::EventDateTime.new(date_time: (start_time - 3.hours).to_datetime.rfc3339), end: Google::Apis::CalendarV3::EventDateTime.new(date_time: (end_time - 3.hours).to_datetime.rfc3339), summary: summary, description: @training.description - }) + ) if service.get_event(calendar_id, 'training' + @training.id.to_s + 'fitfree1asslcom') service.patch_event(calendar_id, 'training' + @training.id.to_s + 'fitfree1asslcom', event) end diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index e81a88b..c7b40a7 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -2,9 +2,6 @@ class WebhooksController < ApplicationController def callback - puts - puts message[:text] - puts if client && message_exist.nil? && message[:text] client.messages.create(text: message[:text], update_id: webhook[:update_id]) send_broadcast diff --git a/app/models/training.rb b/app/models/training.rb index ff925a5..6410d20 100644 --- a/app/models/training.rb +++ b/app/models/training.rb @@ -18,5 +18,5 @@ class Training < ApplicationRecord has_and_belongs_to_many :clients has_many :exercises - enum status: %i[is_created planned complete canceled] + enum status: %i[creation planned complete canceled] end diff --git a/app/views/trainings/exercises.html.erb b/app/views/trainings/exercises.html.erb new file mode 100644 index 0000000..a225350 --- /dev/null +++ b/app/views/trainings/exercises.html.erb @@ -0,0 +1,53 @@ +<% @exercises.each do |exe| %> +
+ +
+
+
+
+ Approach +
+ +
+
+
+
+
+ Repeats +
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/trainings/join_clients.html.erb b/app/views/trainings/join_clients.html.erb index e6e9ae6..5c96603 100644 --- a/app/views/trainings/join_clients.html.erb +++ b/app/views/trainings/join_clients.html.erb @@ -1,17 +1,16 @@ <% if @clients.any? %> <% @clients.each do |client| %> -

<%= client.full_name %>

-
-
$
+
+
<% if @exercises.present? %> - <% @exercises.each do |exe| %> @@ -22,9 +21,7 @@ <% end %>
- - - +
<% end %> diff --git a/app/views/trainings/new.html.erb b/app/views/trainings/new.html.erb index bb515cb..24ed687 100644 --- a/app/views/trainings/new.html.erb +++ b/app/views/trainings/new.html.erb @@ -1,44 +1,51 @@ -
-

New Training

- -
-
- -
-
- - + + +
+
+ +
+

t('.title')

+
+ +
+
+ +
+
+ + +
+
-
-
-
-
- -
-
- - +
+
+ +
+
+ + +
+
-
-
-
-
- - +
+
+ + +
+
-

Clients

<% if @clients.present? %> - <% @clients.each do |client| %> diff --git a/config/routes.rb b/config/routes.rb index 547149b..fe9e979 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,7 @@ resources :metrics post 'trainings/clients', to: 'trainings#join_clients' + post 'trainings/exercises', to: 'trainings#exercises' mount ActionCable.server, at: '/cable' diff --git a/db/migrate/20180805114652_create_trainings.rb b/db/migrate/20180805114652_create_trainings.rb index ce3f092..d49e9d1 100644 --- a/db/migrate/20180805114652_create_trainings.rb +++ b/db/migrate/20180805114652_create_trainings.rb @@ -5,7 +5,7 @@ def change t.datetime :time t.integer :price t.text :description - t.integer :status, default: 0, null: false + t.integer :status, default: 0 t.timestamps end end From 837d6de92f8a83ec030a8a8af5e99cf44a74a3c2 Mon Sep 17 00:00:00 2001 From: brutu33 Date: Sat, 1 Sep 2018 12:06:42 +0300 Subject: [PATCH 3/5] trainings --- app/assets/stylesheets/application.css.scss | 2 + app/views/trainings/join_clients.html.erb | 1 - app/views/trainings/new.html.erb | 65 --------------------- app/views/trainings/new.html.slim | 37 ++++++++++++ 4 files changed, 39 insertions(+), 66 deletions(-) delete mode 100644 app/views/trainings/new.html.erb create mode 100644 app/views/trainings/new.html.slim diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 74fa0bb..2cbbf4e 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -43,6 +43,8 @@ margin-top: 23px; margin-right: auto !important; margin-left: auto !important; + padding-top: 40px; + padding-bottom: 40px; } #bottom-segment { diff --git a/app/views/trainings/join_clients.html.erb b/app/views/trainings/join_clients.html.erb index 5c96603..e55b275 100644 --- a/app/views/trainings/join_clients.html.erb +++ b/app/views/trainings/join_clients.html.erb @@ -17,7 +17,6 @@ <%end %> <% else %> - <% end %>
diff --git a/app/views/trainings/new.html.erb b/app/views/trainings/new.html.erb deleted file mode 100644 index 24ed687..0000000 --- a/app/views/trainings/new.html.erb +++ /dev/null @@ -1,65 +0,0 @@ - - -
-
- -
-

t('.title')

-
- -
-
- -
-
- - -
-
-
-
- -
-
- -
-
- - -
-
-
-
- -
-
- - -
-
-
-
-
- -
-

Clients

-
- <% if @clients.present? %> - - <% else %> - Create client - <% end %> -
-
- - -
- - - - diff --git a/app/views/trainings/new.html.slim b/app/views/trainings/new.html.slim new file mode 100644 index 0000000..b74fa5f --- /dev/null +++ b/app/views/trainings/new.html.slim @@ -0,0 +1,37 @@ +.main.ui.container + .ui.raised.container.segment + .ui.top.attached.label + h3 Clients + .ui.form + .field + label Start Date + #training_date.ui.calendar + .ui.input.left.icon + i.calendar.icon + input placeholder="Date" type="text" / + .ui.form + .field + label Start time + #start_time.ui.calendar + .ui.input.left.icon + i.time.icon + input placeholder="Time" type="text" / + .ui.form + .field + label Notes + textarea rows="2" + +.main.ui.container + .ui.raised.container.segment + .ui.top.attached.label + h3 Clients + .ui.form + .field style=("margin-bottom: 20px; margin-top: 20px") + - if @clients.present? + select#clients_select.ui.fluid.search.dropdown.client-select.multiple multiple="" + option value="" Clinets... + - @clients.each do |client| + option value=("#{client.id}") "#{client.full_name}" + - else + a.ui.green.button href="#{new_client_path}" Create client +#clients_continer \ No newline at end of file From 6e239c266abbd878a18cefc785b5082d2ebe7783 Mon Sep 17 00:00:00 2001 From: brutu33 Date: Sat, 1 Sep 2018 13:42:15 +0300 Subject: [PATCH 4/5] add navbar to all tabs --- app/controllers/payments_controller.rb | 3 ++- app/views/clients/_navbar.html.slim | 2 +- app/views/messages/index.html.erb | 2 +- app/views/payments/index.html.slim | 27 +------------------------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 73e1245..8ee99d5 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -5,7 +5,8 @@ class PaymentsController < ApplicationController def index @payments_list = Transaction.where(client_id: client_id).order(created_at: :desc) @payments_list = @payments_list.page(params[:page]) - @result_balance = Client.find(client_id).cash + @client = client + @result_balance = client.cash end def create; end diff --git a/app/views/clients/_navbar.html.slim b/app/views/clients/_navbar.html.slim index e858f06..db2e1e8 100644 --- a/app/views/clients/_navbar.html.slim +++ b/app/views/clients/_navbar.html.slim @@ -3,7 +3,7 @@ a.item [class="#{'active' if active_section == :show}" href="#{client_path(@client)}" ] #{t('client_navigation.info')} a.item [class="#{'active' if active_section == :stats}" href="#{client_stats_path(@client)}" ] #{t('client_navigation.stats')} a.item [class="#{'active' if active_section == :messages}" href="#{client_messages_path(@client)}" ] #{t('client_navigation.messages')} - a.item [class="#{'active' if active_section == :diet}" href="#" ] #{t('client_navigation.diet')} + / a.item [class="#{'active' if active_section == :diet}" href="#" ] #{t('client_navigation.diet')} a.item [class="#{'active' if active_section == :payments}" href="#{client_payments_path(@client)}" ] #{t('client_navigation.payments')} a.item [class="#{'active' if active_section == :diary}" href="#" ] #{t('client_navigation.diary')} diff --git a/app/views/messages/index.html.erb b/app/views/messages/index.html.erb index 1fe3c84..3ffa64a 100644 --- a/app/views/messages/index.html.erb +++ b/app/views/messages/index.html.erb @@ -1,4 +1,4 @@ -<%= action_cable_meta_tag %> +<%= render 'clients/navbar', active_section: :payments %>
<% @messages.each do |msg| %> diff --git a/app/views/payments/index.html.slim b/app/views/payments/index.html.slim index cc15b7d..e29c660 100644 --- a/app/views/payments/index.html.slim +++ b/app/views/payments/index.html.slim @@ -1,29 +1,4 @@ -/= render 'clients/navbar', active_section: :payments -/ ul.nav.nav-tabs.justify-content-center role="tablist" -/ li.nav-item -/ a.nav-link href="./" role="tab" -/ i.now-ui-icons.users_single-02 -/ | Client info -/ li.nav-item -/ a.nav-link href="./stats" role="tab" -/ i.now-ui-icons.sport_user-run -/ |Stats -/ li.nav-item -/ a.nav-link role="tab" -/ i.now-ui-icons.ui-1_email-85 -/ | Messages -/ li.nav-item -/ a.nav-link role="tab" -/ i.now-ui-icons.shopping_box -/ | Client diet -/ li.nav-item -/ a.nav-link.active href="#{client_payments_path}" role="tab" -/ i.now-ui-icons.business_bank -/ | Payments -/ li.nav-item -/ a.nav-link role="tab" -/ i.now-ui-icons.sport_trophy -/ | Training diary += render 'clients/navbar', active_section: :payments .main.ui.container /todo: change depends screen size => .html.ui.top.attached.segment From 386b90bc4152d0f3efbc90bfa8971495984de11c Mon Sep 17 00:00:00 2001 From: brutu33 Date: Sat, 1 Sep 2018 14:13:45 +0300 Subject: [PATCH 5/5] start messages design --- app/views/messages/index.html.erb | 37 ------------------------------ app/views/messages/index.html.slim | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 app/views/messages/index.html.erb create mode 100644 app/views/messages/index.html.slim diff --git a/app/views/messages/index.html.erb b/app/views/messages/index.html.erb deleted file mode 100644 index 3ffa64a..0000000 --- a/app/views/messages/index.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<%= render 'clients/navbar', active_section: :payments %> - -
- <% @messages.each do |msg| %> -

- <%= msg.messagable_type %>: <%= msg.text %> -

- <% end %> -
- - - - - - - - - - - - - - - - - - -<%#= javascript_include_tag('messages.js') %> diff --git a/app/views/messages/index.html.slim b/app/views/messages/index.html.slim new file mode 100644 index 0000000..51fc75a --- /dev/null +++ b/app/views/messages/index.html.slim @@ -0,0 +1,24 @@ += render 'clients/navbar', active_section: :messages +.main.ui.container + .ui.raised.container.segment + .ui.top.attached.label + h3 #{@client.full_name} conversation + .col-sm-offset-4.frame + ul + div + .msj-rta.macro + .text.text-r style=("background:whitesmoke !important") + input.mytext placeholder=("Type a message") / + div style="padding:10px;" + button#button-addon2.btn.btn-outline-secondary onclick=("send_message(<%= @client.id %>)") type="button" Send + +/ #container_msg style=("margin-bottom: 20%") +/ - @messages.each do |msg| +/ p style=("<%= 'float: right;'if msg.messagable_type.eql?('User') %>") +/ = msg.messagable_type %>: <%= msg.text % +/ nav.navbar.fixed-bottom.navbar-dark.bg-dark style=("margin-bottom: 0px") +/ .input-group.mb-3 +/ form action="post" method="" +/ input#message.form-control aria-describedby="button-addon2" aria-label=("Recipient's username") placeholder=("Write your message") type="text" / +/ .input-group-append +/ button#button-addon2.btn.btn-outline-secondary onclick=("send_message(<%= @client.id %>)") type="button" Send \ No newline at end of file