forked from bofh/fetsite
calentry js interface
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<% image_tag("/iconnavy/time.png") %>
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
|
||||
<% if calentry.start.to_date == calentry.ende.to_date
|
||||
<% if (calentry.start.to_date - calentry.ende.to_date) < 1.day
|
||||
format=:timeonly
|
||||
else
|
||||
format =:default
|
||||
end %>
|
||||
<%= calentry.text %>
|
||||
|
||||
<%= link_to "edit", edit_calentry_path(calentry),:remote=>true if can? :edit, calentry %>
|
||||
<%= link_to 'Delete', calentry, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, calentry %>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= 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 :object_id , :as => :hidden %>
|
||||
<%= f.input :object_type , :as => :hidden %>
|
||||
<%= f.input :typ , :as => :hidden %>
|
||||
|
||||
|
||||
<%= f.action :submit, :as => :input_ %>
|
||||
|
||||
2
app/views/calentries/create.js.erb
Normal file
2
app/views/calentries/create.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
alert("sdf");
|
||||
$("#calentry_new").replaceWith("<div id=\"calentry_<%= @calentry.id %>\"> <%=escape_javascript( render :partial=>"calentry", :object=>@calentry)%> </div><div id=\"calentry_new\"><%= escape_javascript( link_to "new Calentry", new_calentry_path, :remote=>true) %></div>");
|
||||
1
app/views/calentries/delete.js.erb
Normal file
1
app/views/calentries/delete.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#calentry_<%= @calentry_id %>").remove();
|
||||
1
app/views/calentries/destroy.js.erb
Normal file
1
app/views/calentries/destroy.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#calentry_<%= @calentry_id %>").remove();
|
||||
@@ -1,2 +1,7 @@
|
||||
|
||||
$("#calentry_<%= @calentry.id %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@calentry)%>");
|
||||
|
||||
|
||||
|
||||
|
||||
$('.datetimepicker').datetimepicker({format: 'd.m.Y H:i', startDate: (!($(this).attr("value")==undefined))? $(this).attr("value"): ""})
|
||||
|
||||
3
app/views/calentries/new.js.erb
Normal file
3
app/views/calentries/new.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
$("#calentry_new").replaceWith("<div id=\"calentry_new\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@calentry) %></div>");
|
||||
$('.datetimepicker').datetimepicker({format: 'd.m.Y H:i', startDate: (!($(this).attr("value")==undefined))? $(this).attr("value"): ""})
|
||||
|
||||
@@ -48,9 +48,12 @@ end
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="calentries">
|
||||
<% @calentries1.each do |ce|%>
|
||||
<%= render ce unless ce.nil? %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="calentry_new" ><%= link_to "new Calentry", new_calentry_path(:object_id=>@neuigkeit.id, :object_type=>"Neuigkeit"), :remote=>true %></div>
|
||||
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
|
||||
</div>
|
||||
<%= render partial: 'nlink_list_whole', :object=>@neuigkeit.nlinks %>
|
||||
|
||||
Reference in New Issue
Block a user