diff --git a/app/controllers/calentries_controller.rb b/app/controllers/calentries_controller.rb index 3a4be9a..e4f4095 100644 --- a/app/controllers/calentries_controller.rb +++ b/app/controllers/calentries_controller.rb @@ -1,15 +1,15 @@ class CalentriesController < ApplicationController # GET /calentries # GET /calentries.json - load_and_authorize_resource - # def index - # @calentries = Calentry.all + #load_and_authorize_resource + def index + - # respond_to do |format| - # format.html # index.html.erb - # format.json { render json: @calentries } - # end - # end + respond_to do |format| + format.html {redirect_to rubriken_path} + + end + end # GET /calentries/1 # GET /calentries/1.json @@ -25,14 +25,16 @@ class CalentriesController < ApplicationController # GET /calentries/new # GET /calentries/new.json - # def new - # @calentry = Calentry.new - - # respond_to do |format| - # format.html # new.html.erb - # format.json { render json: @calentry } - # end - # end + def new + @calentry = Calentry.new + @calentry.object="Neuigkeit".constantize.find(params[:object_id]) + @calentry.typ=1 + respond_to do |format| + format.html # new.html.erb + format.json { render json: @calentry } + format.js + end + end # GET /calentries/1/edit def edit @@ -45,19 +47,21 @@ class CalentriesController < ApplicationController # POST /calentries # POST /calentries.json - # def create - # @calentry = Calentry.new(params[:calentry]) + def create + @calentry = Calentry.new(params[:calentry]) -# respond_to do |format| -# if @calentry.save -# format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' } -# format.json { render json: @calentry, status: :created, location: @calentry } -# else - # format.html { render action: "new" } -# format.json { render json: @calentry.errors, status: :unprocessable_entity } -# end -# end -# end + respond_to do |format| + if @calentry.save + format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' } + format.json { render json: @calentry, status: :created, location: @calentry } + format.js + else + format.html { render action: "new" } + format.json { render json: @calentry.errors, status: :unprocessable_entity } + format.js { render action: "new" } +end + end + end # PUT /calentries/1 # PUT /calentries/1.json @@ -80,12 +84,16 @@ class CalentriesController < ApplicationController # DELETE /calentries/1 # DELETE /calentries/1.json def destroy + logger.info("-------------delete------------------") @calentry = Calentry.find(params[:id]) + @calentry_id = params[:id] + @object=@calentry.object @calentry.destroy - + respond_to do |format| - format.html { redirect_to calentries_url } + format.html { redirect_to @object} format.json { head :no_content } + format.js end end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6e38a7d..1cc4986 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -129,7 +129,7 @@ class Ability can [:show,:index], Calendar can [:edit, :update,:new,:create,:verwalten], Calendar - can [:edit, :update,:new,:create,:verwalten], Calentry + can [:edit, :update,:new,:create,:verwalten,:delete], Calentry end if( user.has_role?("fetadmin")) can [:delete],Calendar diff --git a/app/models/calentry.rb b/app/models/calentry.rb index 66c401f..4c25840 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -13,7 +13,7 @@ # class Calentry < ActiveRecord::Base - attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer + attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer, :object_id, :object_type belongs_to :calendar #belongs_to :neuigkeit validates :start, :presence => true diff --git a/app/views/calentries/_calentry.html.erb b/app/views/calentries/_calentry.html.erb index 909737a..b591e28 100644 --- a/app/views/calentries/_calentry.html.erb +++ b/app/views/calentries/_calentry.html.erb @@ -1,13 +1,13 @@
<%= notice %>
+ <%= semantic_form_for @calentry, :remote=>true, :html=>{:class=>"inline"} do |f| %> <%= f.input :start, :as => :datetimepicker %> -<%= f.input :dauer , :as => :string, :append=>"h" %> + <%= f.input :dauer , :as => :string, :append=>"h" %> + <%= f.input :object_id , :as => :hidden %> + <%= f.input :object_type , :as => :hidden %> +<%= f.input :typ , :as => :hidden %> <%= f.action :submit, :as => :input_ %> diff --git a/app/views/calentries/create.js.erb b/app/views/calentries/create.js.erb new file mode 100644 index 0000000..302cda5 --- /dev/null +++ b/app/views/calentries/create.js.erb @@ -0,0 +1,2 @@ +alert("sdf"); +$("#calentry_new").replaceWith("