Generate qis PArticle
This commit is contained in:
parent
b36b1d46a1
commit
c687353802
76
app/controllers/admin/p_articles_controller.rb
Normal file
76
app/controllers/admin/p_articles_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::PArticlesController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@p_articles = PArticle.all
|
||||
|
||||
@p_articles = sort_by_sorting(@p_articles, "id DESC")
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
|
||||
params[:search][:per_page] = params[:search][:per_page] || 100
|
||||
per_page = params[:search][:per_page]
|
||||
page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
@p_articles = @p_articles.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@p_article = PArticle.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@p_article = PArticle.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@p_article = PArticle.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@p_article = PArticle.new(params.require(:p_article).permit!)
|
||||
|
||||
if @p_article.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@p_article = PArticle.find(params[:id])
|
||||
|
||||
|
||||
if @p_article.update_attributes(params.require(:p_article).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@p_article = PArticle.find(params[:id])
|
||||
@p_article.destroy
|
||||
|
||||
end
|
||||
end
|
3
app/models/p_article.rb
Normal file
3
app/models/p_article.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class PArticle < ApplicationRecord
|
||||
belongs_to :p_product_ref
|
||||
end
|
12
app/views/admin/p_articles/_form.html.haml
Normal file
12
app/views/admin/p_articles/_form.html.haml
Normal file
@ -0,0 +1,12 @@
|
||||
=semantic_form_for [:admin, @p_article], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :p_product_ref, :label => f.object.label_for(:p_product_ref)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
16
app/views/admin/p_articles/_p_article.html.haml
Normal file
16
app/views/admin/p_articles/_p_article.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
%tr#p_article_row{:id => p_article.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_p_article_path(p_article), :remote => true
|
||||
= link_to i(:eye), admin_p_article_path(p_article), :remote => true
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_article}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/p_articles/create.js.erb
Normal file
2
app/views/admin/p_articles/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_articles_rows').prepend("<%= escape_javascript(render(@p_article))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/p_articles/destroy.js.erb
Normal file
1
app/views/admin/p_articles/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#p_article_row_<%= @p_article.id %>').remove();
|
1
app/views/admin/p_articles/edit.js.erb
Normal file
1
app/views/admin/p_articles/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/p_articles/index.html.haml
Normal file
16
app/views/admin/p_articles/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
=PArticle.human rescue ""
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_articles}
|
||||
|
||||
|
||||
|
1
app/views/admin/p_articles/new.js.erb
Normal file
1
app/views/admin/p_articles/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/p_articles/show.html.haml
Normal file
10
app/views/admin/p_articles/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @p_article
|
2
app/views/admin/p_articles/update.js.erb
Normal file
2
app/views/admin/p_articles/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_article_row_<%= @p_article.id %>').replaceWith("<%= escape_javascript(render(@p_article))%>");
|
||||
close_pane_hover();
|
@ -1,5 +1,16 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
resources :p_articles do
|
||||
member do
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :buy_lists do
|
||||
member do
|
||||
|
9
db/migrate/20210826135742_create_p_articles.rb
Normal file
9
db/migrate/20210826135742_create_p_articles.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class CreatePArticles < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :p_articles do |t|
|
||||
t.references :p_product_ref, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
7
test/fixtures/p_articles.yml
vendored
Normal file
7
test/fixtures/p_articles.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
p_product_ref: one
|
||||
|
||||
two:
|
||||
p_product_ref: two
|
7
test/models/p_article_test.rb
Normal file
7
test/models/p_article_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PArticleTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Reference in New Issue
Block a user