fix für bulk edit moduls
This commit is contained in:
@@ -63,9 +63,14 @@ class ModulsController < ApplicationController
|
|||||||
unless params[:modulgruppen_id].nil?
|
unless params[:modulgruppen_id].nil?
|
||||||
@moduls=Modulgruppe.find(params[:modulgruppen_id]).moduls
|
@moduls=Modulgruppe.find(params[:modulgruppen_id]).moduls
|
||||||
else
|
else
|
||||||
|
unless params[:studium_id].nil?
|
||||||
|
@moduls=Studium.find(params[:studium_id]).modulgruppen.collect(&:moduls).flatten
|
||||||
|
else
|
||||||
|
|
||||||
@moduls=Modul.all
|
@moduls=Modul.all
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@moduls << Modul.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_lvas
|
def edit_lvas
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ class Modul < ActiveRecord::Base
|
|||||||
translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true
|
translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true
|
||||||
def self.update_multiple(hash)
|
def self.update_multiple(hash)
|
||||||
m= []
|
m= []
|
||||||
hash.each_entry do |h|
|
if hash.is_a? Hash
|
||||||
if h["id"].to_i == 0
|
hash.each do |i,h|
|
||||||
|
if i.to_i == 0
|
||||||
unless h["name"].empty?
|
unless h["name"].empty?
|
||||||
md=Modul.new(:name=>h["name"],:desc=>h["desc"],:depend=>h["depend"])
|
md=Modul.new(:name=>h["name"],:desc=>h["desc"],:depend=>h["depend"])
|
||||||
md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
|
md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
|
||||||
@@ -37,7 +38,16 @@ class Modul < ActiveRecord::Base
|
|||||||
md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
|
md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
|
||||||
m << md
|
m << md
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
hash.each do |h|
|
||||||
|
unless h["name"].empty?
|
||||||
|
md=Modul.new(:name=>h["name"],:desc=>h["desc"],:depend=>h["depend"])
|
||||||
|
md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
|
||||||
|
md.save
|
||||||
|
m << md
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
m
|
m
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
class Studium < ActiveRecord::Base
|
class Studium < ActiveRecord::Base
|
||||||
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten
|
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten
|
||||||
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
|
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
|
||||||
|
|
||||||
has_many :semester, :dependent => :destroy
|
has_many :semester, :dependent => :destroy
|
||||||
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
||||||
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<% @moduls.each do |m| %>
|
<% @moduls.each do |m| %>
|
||||||
<%= semantic_fields_for "moduls[#{m.id}]", m do |f| %>
|
<%= semantic_fields_for "moduls[#{m.id}]", m do |f| %>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<%= f.input :id, :label=>false, :hint=>"" ,:as=>:hidden%>
|
<%= f.input :id, :label=>false, :hint=>"" ,:as=>:hidden %>
|
||||||
<%= f.input :name, :label=>false, :hint=>"" %></td>
|
<%= f.input :name, :label=>false, :hint=>"" %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= f.input :modulgruppen, :label=>false, :hint=>"" , :collection=>Modulgruppe.all %>
|
<%= f.input :modulgruppen, :label=>false, :hint=>"" , :collection=>Modulgruppe.all %>
|
||||||
|
|||||||
Reference in New Issue
Block a user