Allow to copy articles (PR #673, #541)

This commit is contained in:
JuliusR 2019-10-14 09:25:34 +02:00 committed by wvengen
parent 3ade87167a
commit 71bdf3bfcc
5 changed files with 19 additions and 7 deletions

View File

@ -36,6 +36,11 @@ class ArticlesController < ApplicationController
render :layout => false
end
def copy
@article = @supplier.articles.find(params[:article_id]).dup
render :layout => false
end
def create
@article = Article.new(params[:article])
if @article.valid? && @article.save

View File

@ -11,7 +11,11 @@
= number_to_currency(article.price)
%td= number_to_percentage(article.tax) if article.tax != 0
%td= number_to_currency(article.deposit) if article.deposit != 0
%td= link_to t('ui.edit'), edit_supplier_article_path(@supplier, article),
:remote => true, class: 'btn btn-mini'
%td= link_to t('ui.delete'), [@supplier, article],
:method => :delete, :data => {:confirm => t('ui.confirm_delete', name: article.name)}, :remote => true, class: 'btn btn-mini btn-danger'
%td
= link_to t('ui.edit'), edit_supplier_article_path(@supplier, article),
remote: true, class: 'btn btn-mini'
= link_to t('ui.copy'), supplier_article_copy_path(@supplier, article),
remote: true, class: 'btn btn-mini'
= link_to t('ui.delete'), [@supplier, article],
method: :delete, data: {confirm: t('ui.confirm_delete', name: article.name)},
remote: true, class: 'btn btn-mini btn-danger'

View File

@ -15,10 +15,10 @@
%th{:style => "width: 5em;"}= heading_helper Article, :price
%th{:style => "width: 3.5em;"}= heading_helper Article, :tax
%th{:style => "width: 4em;"}= heading_helper Article, :deposit
%th{:style => "width: 3em;"}
%th
%tbody#listbody
- unless @articles.empty?
- for article in @articles
= render(article)

View File

@ -0,0 +1,2 @@
$('#modalContainer').html('#{j(render("form"))}');
$('#modalContainer').modal();

View File

@ -125,6 +125,7 @@ Foodsoft::Application.routes.draw do
end
resources :articles do
get :copy
collection do
post :update_selected
get :edit_all