From d52b2278802999cc6d2e556df2ed83fa6791a70d Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 22 Jul 2019 17:26:39 +0200 Subject: [PATCH] suite --- app/assets/stylesheets/admin.css.scss | 7 +- app/models/admin.rb | 6 ++ app/models/i_task.rb | 10 +++ app/views/admin/i_tasks/_form.html.haml | 70 ++++++++++++---- app/views/admin/i_tasks/_i_task.html.haml | 6 +- app/views/admin/i_tasks/index.html.haml | 82 +++++++++++++++---- app/views/admin/i_tasks/update.js.erb | 7 +- ...90722151424_add_minutes_done_to_i_tasks.rb | 5 ++ db/schema.rb | 3 +- 9 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 db/migrate/20190722151424_add_minutes_done_to_i_tasks.rb diff --git a/app/assets/stylesheets/admin.css.scss b/app/assets/stylesheets/admin.css.scss index c37caf5..b4acee6 100644 --- a/app/assets/stylesheets/admin.css.scss +++ b/app/assets/stylesheets/admin.css.scss @@ -973,6 +973,7 @@ h1{ bottom:0; width:100px; padding:10px 0; + z-index:10; box-shadow:0 0 5px rgba(0,0,0,0.2); .bottom{ position:absolute; @@ -1065,9 +1066,9 @@ h1{ .big_icon{ - font-size:2em; + font-size:1.5em; display:inline-block; - margin-right:10px; + margin-right:3px; text-decoration:none; color:rgba(0,0,0,0.2); @@ -1094,7 +1095,7 @@ h1{ background:transparent !important; } .qi_pannel.padding{ - padding:10px; + padding:2px; } diff --git a/app/models/admin.rb b/app/models/admin.rb index 1d59c1a..cbad029 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -26,6 +26,12 @@ class Admin < ActiveRecord::Base before_create { generate_token(:remember_token) } + + def show_name + self.firstname.to_s + " " + self.name.to_s + end + + def send_password_reset generate_token(:reset_password_token) self.reset_password_sent_at = Time.now diff --git a/app/models/i_task.rb b/app/models/i_task.rb index aa90e81..daeeaed 100644 --- a/app/models/i_task.rb +++ b/app/models/i_task.rb @@ -6,4 +6,14 @@ class ITask < ActiveRecord::Base validates :name, :presence => true + + before_validation do + if !self.done + self.done_at = nil + elsif self.done and !self.done_at? + self.done_at = Time.now + end + + end + end diff --git a/app/views/admin/i_tasks/_form.html.haml b/app/views/admin/i_tasks/_form.html.haml index bd86fe5..0b955f5 100755 --- a/app/views/admin/i_tasks/_form.html.haml +++ b/app/views/admin/i_tasks/_form.html.haml @@ -1,24 +1,66 @@ --@new_i_task = @new_i_task || ITask.new(:i_website_id => (@i_website.id if @i_website)) +-@new_i_task = @new_i_task || ITask.new(:admin_id => current_admin.id, :i_website_id => (@i_website.id if @i_website), :end_at => (Date.today + 2.day)) -new_var = new_var || false +.task_form_wrapper -=semantic_form_for [:admin, (new_var ? @new_i_task : @i_task)], :remote => true do |f| + =semantic_form_for [:admin, (new_var ? @new_i_task : @i_task)], :remote => true do |f| - .content - =f.inputs do - = f.input :i_website_id, :label => "Site :", :collection => IWebsite.all, :as => :select, :include_blank => true - = f.input :name, :label => "Libélé :" - = f.input :minutes, :label => "Temps estimé :" - = f.input :end_at, :label => "Echeance", :as => :date - = f.input :done, :label => "Accomplis ?" - =# f.input :status, :label => "Nom :" + .content.task_form + %table{:style => "width:100%;"} + =f.inputs do + %tr + %td{:style => "width:120px;"}= f.input :admin_id, :label => false, :collection => Admin.all, :as => :select, :include_blank => true, :member_label => :show_name + %td{:style => "width:200px;"}= f.input :i_website_id, :label => false, :placeholder => "Projet :", :collection => IWebsite.all, :as => :select, :include_blank => true + %td= f.input :name, :label => false, :placeholder => "Libélé" + %td{:style => "width:100px;"}= f.input :minutes, :label => false, :placeholder => "Temps estimé (min)" , :as => :string + -if f.object.id + %td{:style => "width:100px;"}= f.input :minutes_done, :label => false, :placeholder => "Temps passé (min)" , :as => :string + %td{:style => "width:120px;"}= f.input :end_at, :label => false, :placeholder => "Echéance", :as => :date + %td{:style => "width:20px;"}=f.submit "OK !", :class => "btn btn-primary" + + :scss + #qi_pane_hover{ + table, tr, td, tbody{ + display:block !important; + width:auto !important; + } + td{ + padding-bottom:10px !important; + } + + } + + + #new_i_task_form{ + .task_form_wrapper{ + position:fixed; + bottom:0; + left:100px; + right:0; + background:white; + padding:10px 20px; + box-shadow:0 0 5px rgba(0,0,0,0.5); + z-index:1; + + + } + + } + .task_form{ + input{ + margin:0; + } + td{ + padding:0; + } + .form-group{ + padding:0; + margin:0; + } + } - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/i_tasks/_i_task.html.haml b/app/views/admin/i_tasks/_i_task.html.haml index 4f99aa6..9806997 100644 --- a/app/views/admin/i_tasks/_i_task.html.haml +++ b/app/views/admin/i_tasks/_i_task.html.haml @@ -3,7 +3,7 @@ %table.table %tr - %td{:style => (params[:no_detail] ? "width:50px;" : "width:230px;")} + %td{:style => (params[:no_detail] ? "width:30px;" : "width:150px;")} -if i_task.done =link_to admin_i_task_path(:id => i_task.id, :i_task => {:done => false}), :remote => true, :method => :put do .big_icon.done @@ -39,10 +39,10 @@ - + %td{:style => "width:150px;"}= i_task.admin.show_name if i_task.admin %td= i_task.name -if !@i_website - %td.project{:style => "width:200px;"} + %td.project{:style => "width:150px;"} = i_task.i_website.name if i_task.i_website %br = i_task.p_customer.show_name if i_task.p_customer diff --git a/app/views/admin/i_tasks/index.html.haml b/app/views/admin/i_tasks/index.html.haml index 917953d..b339ef3 100644 --- a/app/views/admin/i_tasks/index.html.haml +++ b/app/views/admin/i_tasks/index.html.haml @@ -1,24 +1,72 @@ .qi_header - .right= link_to 'Ajouter un projet', new_admin_i_task_path(), :class => "btn btn-primary", :remote => true - %h1 - Sites & projets + %h1 To do .qi_row - .qi_pannel.qi_plain.padding - %table.table - %tr - %th Client + + -if params[:i_previ_id] + -@i_tasks = ITask.where(:i_previ_id => params[:i_previ_id], :done => false).all + + -elsif params[:archive] + -@i_tasks = ITask.where(:done => true).all + + -elsif params[:urgent] + -@i_tasks = ITask.where(:urgent => true, :done => false).all + -elsif params[:no] + -@i_tasks = ITask.where(:done => false, :i_previ_id => nil).all + + -else + -params[:all] = true + -@i_tasks = ITask.where(:done => false).all + + + + + .tasks_menu + =link_to admin_i_tasks_path(:no => 1), :class => ("active" if params[:no]) do + Non planifiées + + =link_to admin_i_tasks_path(:all => 1), :class => ("active" if params[:all]) do + Toutes les tâches + + + =link_to admin_i_tasks_path(:urgent => 1), :class => ("active" if params[:urgent]) do + =ic :"free-code-camp" + Urgent + + =link_to admin_i_tasks_path(:i_previ_id => 1), :class => ("active" if params[:i_previ_id].to_s == "1") do + =ic :star + Aujourd'hui + + =link_to admin_i_tasks_path(:i_previ_id => 2), :class => ("active" if params[:i_previ_id].to_s == "2") do + =ic :"arrow-right" + Rapidement + + =link_to admin_i_tasks_path(:i_previ_id => 3), :class => ("active" if params[:i_previ_id].to_s == "3") do + =ic :history + Un jour + + =link_to admin_i_tasks_path(:archive => 1), :class => ("active" if params[:archive]) do + Journal + + :scss + .tasks_menu{ + a{ + display:inline-block; + padding:4px 8px; + &:hover,&.active{ + font-weight:bold; + } + } + + } + + #i_task_form + + + #new_i_task_form=render :partial => "admin/i_tasks/form", :locals => {:new_var => true} - %th Nom - %th Url provisoire - %th Url - %th Status - %th - - - %tbody#i_tasks_rows - =render @i_tasks - + .row + #i_tasks_results= render :partial => "admin/i_tasks/results" \ No newline at end of file diff --git a/app/views/admin/i_tasks/update.js.erb b/app/views/admin/i_tasks/update.js.erb index f6b80f4..8e39f7b 100644 --- a/app/views/admin/i_tasks/update.js.erb +++ b/app/views/admin/i_tasks/update.js.erb @@ -1,2 +1,7 @@ -$('#i_tasks_results').html("<%= escape_javascript(render(:partial => "admin/i_tasks/results"))%>"); +$('#i_task_<%= @i_task.id %>').replaceWith("<%= escape_javascript(render(@i_task))%>"); + +<% if false %> +//$('#i_tasks_results').html("<%= escape_javascript(render(:partial => "admin/i_tasks/results"))%>"); +<% end %> + close_pane_hover(); \ No newline at end of file diff --git a/db/migrate/20190722151424_add_minutes_done_to_i_tasks.rb b/db/migrate/20190722151424_add_minutes_done_to_i_tasks.rb new file mode 100644 index 0000000..eb82da8 --- /dev/null +++ b/db/migrate/20190722151424_add_minutes_done_to_i_tasks.rb @@ -0,0 +1,5 @@ +class AddMinutesDoneToITasks < ActiveRecord::Migration + def change + add_column :i_tasks, :minutes_done, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 3420114..03638ad 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190602113239) do +ActiveRecord::Schema.define(version: 20190722151424) do create_table "admin_admin_roles", force: :cascade do |t| t.integer "admin_id", limit: 4 @@ -448,6 +448,7 @@ ActiveRecord::Schema.define(version: 20190602113239) do t.integer "i_task_type_id", limit: 4 t.boolean "from_customer", default: false t.integer "i_task_bill_state_id", limit: 4 + t.integer "minutes_done", limit: 4 end add_index "i_tasks", ["admin_id"], name: "index_i_tasks_on_admin_id", using: :btree