diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index 13246d8..477202e 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -647,14 +647,4 @@ $(document).on "click", "#menu_item_informations h4", -> return false -$( document ).ready -> - $('input[type="number"]').on "keydown", (e) -> - alert(String.fromCharCode(e.keyCode)); - if(e.keyCode == 190) - - $(this).value += "," - e.preventDefault() - - - diff --git a/app/controllers/admin/i_tasks_controller.rb b/app/controllers/admin/i_tasks_controller.rb new file mode 100644 index 0000000..ea7f80f --- /dev/null +++ b/app/controllers/admin/i_tasks_controller.rb @@ -0,0 +1,92 @@ +# -*- encoding : utf-8 -*- + +class Admin::ITasksController < ApplicationController + layout "admin" + before_filter :auth_admin + + before_filter :admin_space + + def admin_space + @admin_space = "sites" + end + + + + + def index + @i_tasks = ITask.order("p_customer_id ASC").all + + + end + + def show + @i_task = ITask.find(params[:id]) + + end + + def new + + + @i_task = ITask.new + + + end + + + + def edit + + + @i_task = ITask.find(params[:id]) + end + + def create + @i_task = ITask.new(params.require(:i_task).permit!) + + + if @i_task.save + if @i_task.i_website + @new_i_task = @i_task.i_website.i_tasks.new + @i_tasks = @i_task.i_website.i_tasks.order("end_at ASC").all + else + @i_tasks = ITask.order("end_at ASC").all + end + + + + else + render action: "new" + + end + + end + + + def update + @i_task = ITask.find(params[:id]) + + + if @i_task.update_attributes(params.require(:i_task).permit!) + + if @i_task.i_website + #@new_i_task = @i_task.i_website.i_tasks.new + @i_tasks = @i_task.i_website.i_tasks.order("end_at ASC").all + else + @i_tasks = ITask.order("end_at ASC").all + end + + else + render action: "edit" + + end + + end + + + def destroy + @i_task = ITask.find(params[:id]) + @i_task.destroy + + + end +end diff --git a/app/controllers/admin/i_websites_controller.rb b/app/controllers/admin/i_websites_controller.rb index 38aa5f4..8b4affb 100644 --- a/app/controllers/admin/i_websites_controller.rb +++ b/app/controllers/admin/i_websites_controller.rb @@ -22,6 +22,8 @@ class Admin::IWebsitesController < ApplicationController def show @i_website = IWebsite.find(params[:id]) + @i_tasks = @i_website.i_tasks + end def new diff --git a/app/models/i_task.rb b/app/models/i_task.rb new file mode 100644 index 0000000..aa90e81 --- /dev/null +++ b/app/models/i_task.rb @@ -0,0 +1,9 @@ +class ITask < ActiveRecord::Base + belongs_to :i_website + belongs_to :admin + + has_one :p_customer, :through => :i_website + + validates :name, :presence => true + +end diff --git a/app/models/i_website.rb b/app/models/i_website.rb index 5d4604c..2109c89 100644 --- a/app/models/i_website.rb +++ b/app/models/i_website.rb @@ -1,6 +1,8 @@ class IWebsite < ActiveRecord::Base belongs_to :p_customer + has_many :i_tasks + def show_name self.name.to_s+(" - "+self.url.to_s if self.url?).to_s+(" - "+self.prov_url.to_s if self.prov_url?).to_s end diff --git a/app/views/admin/admin_auths/index.haml b/app/views/admin/admin_auths/index.haml index 3197fa7..91ac567 100644 --- a/app/views/admin/admin_auths/index.haml +++ b/app/views/admin/admin_auths/index.haml @@ -7,4 +7,15 @@ Date et heure sur le serveur au chargement de cette page : =l Time.now - \ No newline at end of file + + + + +.qi_row + + #i_task_form + -@i_tasks = ITask.all + =render :partial => "admin/i_tasks/form", :locals => {:new_var => true} + + +#i_tasks_results= render :partial => "admin/i_tasks/results" diff --git a/app/views/admin/i_tasks/_form.html.haml b/app/views/admin/i_tasks/_form.html.haml new file mode 100755 index 0000000..bd86fe5 --- /dev/null +++ b/app/views/admin/i_tasks/_form.html.haml @@ -0,0 +1,24 @@ +-@new_i_task = @new_i_task || ITask.new(:i_website_id => (@i_website.id if @i_website)) + +-new_var = new_var || false + + + +=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 :" + + + + + + + .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 new file mode 100644 index 0000000..aae3545 --- /dev/null +++ b/app/views/admin/i_tasks/_i_task.html.haml @@ -0,0 +1,72 @@ +.qi_row.i_task_row#i_task{:id => i_task.id} + .qi_pannel.qi_plain.padding + %table.table + + %tr + %td{:style => "width:20px;"} + -if i_task.done + =link_to admin_i_task_path(:id => i_task.id, :i_task => {:done => false}), :remote => true, :method => :put do + .done + =ic :check + -else + =link_to admin_i_task_path(:id => i_task.id, :i_task => {:done => true}), :remote => true, :method => :put do + .undone + =ic :check + + + + %td= i_task.name + %td{:style => "width:200px;"} + = i_task.i_website.name if i_task.i_website + %br + = i_task.p_customer.show_name if i_task.p_customer + %td{:style => "width:100px;"} + -if i_task.minutes + = i_task.minutes + min + + + + + %td.actions{:style => "width:120px;"} + = link_to i(:"trash-o"), [:admin, i_task], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cette tache ? ' } , :remote => true + = link_to i(:pencil), edit_admin_i_task_path(i_task), :remote => true + = link_to i(:eye), admin_i_task_path(i_task) + + +:scss + .done,.undone{ + font-size:2em; + + } + .done{ + color:green; + } + + .undone{ + color:rgba(0,0,0,0.2); + } + + .i_task_row{ + margin:5px 0; + padding:5px 0; + + .qi_pannel.padding{ + padding:10px; + + + } + td{ + border:0 !important; + border:0 !important; + vertical-align: middle !important; + } + + table{ + margin:0; + } + + } + + + \ No newline at end of file diff --git a/app/views/admin/i_tasks/_results.html.haml b/app/views/admin/i_tasks/_results.html.haml new file mode 100644 index 0000000..a072db3 --- /dev/null +++ b/app/views/admin/i_tasks/_results.html.haml @@ -0,0 +1,31 @@ +.qi_row + + -@i_tasks.order("end_at ASC").group(:end_at).each do |ech| + + + + + + -if ech.end_at + + %p{:style => "margin-top:30px;"} + %strong=l ech.end_at if ech.end_at + + =render @i_tasks.where(:end_at => ech.end_at).order("end_at ASC, done DESC") + + + + %p{:style => "margin-top:30px;"} + %strong Sans échéances + + =render @i_tasks.where(:end_at => nil).order("end_at ASC, done DESC") + +%br +%br +%br +%br +%br +%br +%br +%br +%br diff --git a/app/views/admin/i_tasks/create.js.erb b/app/views/admin/i_tasks/create.js.erb new file mode 100644 index 0000000..038759e --- /dev/null +++ b/app/views/admin/i_tasks/create.js.erb @@ -0,0 +1,4 @@ +$('#i_task_form').html(""); +$('#i_task_form').html("<%= escape_javascript(render(:partial => "admin/i_tasks/form", :locals => {:new_var => true}))%>"); + +$('#i_tasks_results').html("<%= escape_javascript(render(:partial => "admin/i_tasks/results"))%>"); \ No newline at end of file diff --git a/app/views/admin/i_tasks/destroy.js.erb b/app/views/admin/i_tasks/destroy.js.erb new file mode 100644 index 0000000..a3d8763 --- /dev/null +++ b/app/views/admin/i_tasks/destroy.js.erb @@ -0,0 +1 @@ +$('#i_task_<%= @i_task.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/i_tasks/edit.html.haml b/app/views/admin/i_tasks/edit.html.haml new file mode 100644 index 0000000..684eb81 --- /dev/null +++ b/app/views/admin/i_tasks/edit.html.haml @@ -0,0 +1,4 @@ +%h1 Modifier un distributeur + += render 'form' + diff --git a/app/views/admin/i_tasks/edit.js.erb b/app/views/admin/i_tasks/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/i_tasks/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/i_tasks/import.html.haml b/app/views/admin/i_tasks/import.html.haml new file mode 100644 index 0000000..276b6d1 --- /dev/null +++ b/app/views/admin/i_tasks/import.html.haml @@ -0,0 +1,32 @@ +-@import= true + +-i = 0 +-@csv.each do |csv| + -i += 1 + + =csv["code"] + -if csv["code"].to_s != "" + sfsd + -PFournisseur.create(:code => csv["code"],:name => csv["nom"],:address1 => csv["adresse 1"],:address2 => csv["adresse 2"],:cp => csv["code postal"],:city => csv["city"],:country => csv["country"],:email => csv["email"],:tel => csv["tel"]) + + + +.qi_header + %h2 Importation + +-if false + =semantic_form_for [:admin, @j_contrat], :url => import_save_admin_j_lines_path(), :html => {:method => :post}, :remote => false do |f| + + =hidden_field_tag :id, @j_contrat.id + + .j_lines_form + =f.semantic_fields_for :j_lines do |form| + =render :partial => "admin/j_lines/inline_form", :locals => {:f => form} + + %center + =f.submit "Importer", :class => "btn btn-primary" + %br + %br + %br + + diff --git a/app/views/admin/i_tasks/index.html.haml b/app/views/admin/i_tasks/index.html.haml new file mode 100644 index 0000000..917953d --- /dev/null +++ b/app/views/admin/i_tasks/index.html.haml @@ -0,0 +1,24 @@ +.qi_header + .right= link_to 'Ajouter un projet', new_admin_i_task_path(), :class => "btn btn-primary", :remote => true + %h1 + Sites & projets + + +.qi_row + .qi_pannel.qi_plain.padding + %table.table + %tr + %th Client + + + %th Nom + %th Url provisoire + %th Url + %th Status + %th + + + %tbody#i_tasks_rows + =render @i_tasks + + \ No newline at end of file diff --git a/app/views/admin/i_tasks/new.html.haml b/app/views/admin/i_tasks/new.html.haml new file mode 100644 index 0000000..3b1635e --- /dev/null +++ b/app/views/admin/i_tasks/new.html.haml @@ -0,0 +1,4 @@ +%h1 Ajouter un distributeur + += render 'form' + diff --git a/app/views/admin/i_tasks/new.js.erb b/app/views/admin/i_tasks/new.js.erb new file mode 100644 index 0000000..d6f96bf --- /dev/null +++ b/app/views/admin/i_tasks/new.js.erb @@ -0,0 +1 @@ +$("#i_task_form").html("<%= escape_javascript(render(:partial => "form"))%>"); \ No newline at end of file diff --git a/app/views/admin/i_tasks/show.html.haml b/app/views/admin/i_tasks/show.html.haml new file mode 100644 index 0000000..0994c58 --- /dev/null +++ b/app/views/admin/i_tasks/show.html.haml @@ -0,0 +1,26 @@ +.qi_header + .right=# link_to 'Ajouter un projet', new_admin_i_task_path(), :class => "btn btn-primary", :remote => true + %h1 + Sites & projets + %span + =@i_task.name + + +.qi_row + + + + .qi_pannel.qi_plain.padding + %table.table + %tr + %th + %th Client + %th Projet + %th Nom + %th + + + %tbody#i_tasks_rows + =render @i_task.i_tasks.order("end_at DESC") + + \ 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 new file mode 100644 index 0000000..f6b80f4 --- /dev/null +++ b/app/views/admin/i_tasks/update.js.erb @@ -0,0 +1,2 @@ +$('#i_tasks_results').html("<%= escape_javascript(render(:partial => "admin/i_tasks/results"))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/i_websites/_i_website.html.haml b/app/views/admin/i_websites/_i_website.html.haml index 3c13cb4..dff9733 100644 --- a/app/views/admin/i_websites/_i_website.html.haml +++ b/app/views/admin/i_websites/_i_website.html.haml @@ -5,7 +5,8 @@ %td=link_to i_website.url.to_s, i_website.url.to_s, :target => "_blank" %td=link_to i_website.prov_url.to_s, i_website.prov_url.to_s, :target => "_blank" %td= i_website.status - + %td + = i_website.i_tasks.count @@ -14,4 +15,5 @@ %td.actions = link_to i(:"trash-o"), [:admin, i_website], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce projet ? ' } , :remote => true = link_to i(:pencil), edit_admin_i_website_path(i_website), :remote => true - + = link_to i(:eye), admin_i_website_path(i_website) + diff --git a/app/views/admin/i_websites/index.html.haml b/app/views/admin/i_websites/index.html.haml index b3e7af1..f80f5c2 100644 --- a/app/views/admin/i_websites/index.html.haml +++ b/app/views/admin/i_websites/index.html.haml @@ -15,6 +15,7 @@ %th Url provisoire %th Url %th Status + %th Nbr de tâches %th diff --git a/app/views/admin/i_websites/show.html.haml b/app/views/admin/i_websites/show.html.haml index 311b0c8..9e8a735 100644 --- a/app/views/admin/i_websites/show.html.haml +++ b/app/views/admin/i_websites/show.html.haml @@ -1,10 +1,17 @@ -%h1=@i_website.name +.qi_header + .right=# link_to 'Ajouter un projet', new_admin_i_website_path(), :class => "btn btn-primary", :remote => true + %h1 + Sites & projets + %span + =@i_website.name + -%h2 Marques -=link_to "ajouter une marque", new_admin_label_marque_path(:i_website_id => @i_website.id), :class => "btn btn-primary" -%table.table - =render @i_website.label_marques.order(:name) %br -%br -%br -%br \ No newline at end of file + +.qi_row + .qi_pannel.qi_plain.padding#i_task_form + =render :partial => "admin/i_tasks/form", :locals => {:new_var => true} + + +#i_tasks_results= render :partial => "admin/i_tasks/results" + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5ee00f7..fea5ecd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,6 +111,7 @@ Rails.application.routes.draw do end namespace :admin do + resources :i_tasks resources :i_hebergements resources :i_websites resources :p_ship_bills diff --git a/db/migrate/20190520102905_create_i_tasks.rb b/db/migrate/20190520102905_create_i_tasks.rb new file mode 100644 index 0000000..ae7d3de --- /dev/null +++ b/db/migrate/20190520102905_create_i_tasks.rb @@ -0,0 +1,16 @@ +class CreateITasks < ActiveRecord::Migration + def change + create_table :i_tasks do |t| + t.references :i_website, index: true, foreign_key: true + t.string :name + t.text :descritpion + t.date :end_at + t.integer :image_file_id + t.boolean :done, :default => false + t.integer :minutes + t.references :admin, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 32b9eae..2c10f24 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: 20181110152121) do +ActiveRecord::Schema.define(version: 20190520102905) do create_table "admin_admin_roles", force: :cascade do |t| t.integer "admin_id", limit: 4 @@ -431,6 +431,22 @@ ActiveRecord::Schema.define(version: 20181110152121) do t.datetime "updated_at", null: false end + create_table "i_tasks", force: :cascade do |t| + t.integer "i_website_id", limit: 4 + t.string "name", limit: 255 + t.text "descritpion", limit: 65535 + t.date "end_at" + t.integer "image_file_id", limit: 4 + t.boolean "done", default: false + t.integer "minutes", limit: 4 + t.integer "admin_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "i_tasks", ["admin_id"], name: "index_i_tasks_on_admin_id", using: :btree + add_index "i_tasks", ["i_website_id"], name: "index_i_tasks_on_i_website_id", using: :btree + create_table "i_websites", force: :cascade do |t| t.string "name", limit: 255 t.string "url", limit: 255 @@ -1347,6 +1363,8 @@ ActiveRecord::Schema.define(version: 20181110152121) do add_foreign_key "home_slide_langs", "home_slider_slides" add_foreign_key "home_slide_langs", "lang_sites" add_foreign_key "home_slider_slides", "home_sliders" + add_foreign_key "i_tasks", "admins" + add_foreign_key "i_tasks", "i_websites" add_foreign_key "lang_pages", "lang_sites" add_foreign_key "lang_pages", "pages" add_foreign_key "menu_item_langs", "image_files" diff --git a/test/fixtures/i_tasks.yml b/test/fixtures/i_tasks.yml new file mode 100644 index 0000000..72b1914 --- /dev/null +++ b/test/fixtures/i_tasks.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + i_website_id: + name: MyString + descritpion: MyText + image_file_id: 1 + done: false + minutes: 1 + admin_id: + +two: + i_website_id: + name: MyString + descritpion: MyText + image_file_id: 1 + done: false + minutes: 1 + admin_id: diff --git a/test/models/i_task_test.rb b/test/models/i_task_test.rb new file mode 100644 index 0000000..1e8c054 --- /dev/null +++ b/test/models/i_task_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ITaskTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end