This commit is contained in:
Nicolas Bally 2019-05-20 22:35:16 +02:00
parent 0bb1993bdd
commit 3075c2ab63
27 changed files with 425 additions and 22 deletions

View File

@ -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()

View File

@ -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

View File

@ -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

9
app/models/i_task.rb Normal file
View File

@ -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

View File

@ -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

View File

@ -7,4 +7,15 @@
Date et heure sur le serveur au chargement de cette page :
=l Time.now
.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"

View File

@ -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"

View File

@ -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;
}
}

View File

@ -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

View File

@ -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"))%>");

View File

@ -0,0 +1 @@
$('#i_task_<%= @i_task.id %>').remove();

View File

@ -0,0 +1,4 @@
%h1 Modifier un distributeur
= render 'form'

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
%h1 Ajouter un distributeur
= render 'form'

View File

@ -0,0 +1 @@
$("#i_task_form").html("<%= escape_javascript(render(:partial => "form"))%>");

View File

@ -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")

View File

@ -0,0 +1,2 @@
$('#i_tasks_results').html("<%= escape_javascript(render(:partial => "admin/i_tasks/results"))%>");
close_pane_hover();

View File

@ -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)

View File

@ -15,6 +15,7 @@
%th Url provisoire
%th Url
%th Status
%th Nbr de tâches
%th

View File

@ -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
.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"

View File

@ -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

View File

@ -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

View File

@ -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"

19
test/fixtures/i_tasks.yml vendored Normal file
View File

@ -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:

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ITaskTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end