Added client side validations. Fixed shared sync.
This commit is contained in:
parent
013637a4fc
commit
3f133bb8c3
8 changed files with 413 additions and 7 deletions
|
|
@ -220,16 +220,14 @@ class ArticlesController < ApplicationController
|
|||
def sync
|
||||
# check if there is an shared_supplier
|
||||
unless @supplier.shared_supplier
|
||||
flash[:error]= "#{@supplier.name} ist nicht mit einer externen Datenbank verknüpft."
|
||||
redirect_to supplier_articles_path(@supplier)
|
||||
redirect_to supplier_articles_url(@supplier), :alert => "#{@supplier.name} ist nicht mit einer externen Datenbank verknüpft."
|
||||
end
|
||||
# sync articles against external database
|
||||
@updated_articles, @outlisted_articles = @supplier.sync_all
|
||||
# convert to db-compatible-string
|
||||
@updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)}
|
||||
if @updated_articles.empty? && @outlisted_articles.empty?
|
||||
flash[:notice] = "Der Katalog ist aktuell."
|
||||
redirect_to supplier_articles_path(@supplier)
|
||||
redirect_to supplier_articles_path(@supplier), :notice => "Der Katalog ist aktuell."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -27,7 +27,7 @@ class Supplier < ActiveRecord::Base
|
|||
def sync_all
|
||||
updated_articles = Array.new
|
||||
outlisted_articles = Array.new
|
||||
for article in articles.without_deleted
|
||||
for article in articles
|
||||
# try to find the associated shared_article
|
||||
shared_article = article.shared_article
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
= simple_form_for [@supplier, @article], :remote => true do |f|
|
||||
= simple_form_for [@supplier, @article], :validate => true, :remote => true do |f|
|
||||
= f.input :availability
|
||||
= f.input :name
|
||||
= f.input :origin
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
= stylesheet_link_tag 'ie_hacks'
|
||||
<![endif]-->
|
||||
= javascript_include_tag 'jquery.min', 'jquery-ui.min', 'jquery_ujs', 'jquery.tokeninput', 'jquery.observe_field',
|
||||
'application', 'ordering', 'jquery.fancybox-1.3.4.pack', :cache => 'all_cached'
|
||||
'rails.validations', 'application', 'ordering', 'jquery.fancybox-1.3.4.pack', :cache => 'all_cached'
|
||||
= csrf_meta_tag
|
||||
= yield(:head)
|
||||
%body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue