calentry js interface
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
class CalentriesController < ApplicationController
|
class CalentriesController < ApplicationController
|
||||||
# GET /calentries
|
# GET /calentries
|
||||||
# GET /calentries.json
|
# GET /calentries.json
|
||||||
load_and_authorize_resource
|
#load_and_authorize_resource
|
||||||
# def index
|
def index
|
||||||
# @calentries = Calentry.all
|
|
||||||
|
|
||||||
# respond_to do |format|
|
respond_to do |format|
|
||||||
# format.html # index.html.erb
|
format.html {redirect_to rubriken_path}
|
||||||
# format.json { render json: @calentries }
|
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
# GET /calentries/1
|
# GET /calentries/1
|
||||||
# GET /calentries/1.json
|
# GET /calentries/1.json
|
||||||
@@ -25,14 +25,16 @@ class CalentriesController < ApplicationController
|
|||||||
|
|
||||||
# GET /calentries/new
|
# GET /calentries/new
|
||||||
# GET /calentries/new.json
|
# GET /calentries/new.json
|
||||||
# def new
|
def new
|
||||||
# @calentry = Calentry.new
|
@calentry = Calentry.new
|
||||||
|
@calentry.object="Neuigkeit".constantize.find(params[:object_id])
|
||||||
# respond_to do |format|
|
@calentry.typ=1
|
||||||
# format.html # new.html.erb
|
respond_to do |format|
|
||||||
# format.json { render json: @calentry }
|
format.html # new.html.erb
|
||||||
# end
|
format.json { render json: @calentry }
|
||||||
# end
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# GET /calentries/1/edit
|
# GET /calentries/1/edit
|
||||||
def edit
|
def edit
|
||||||
@@ -45,19 +47,21 @@ class CalentriesController < ApplicationController
|
|||||||
|
|
||||||
# POST /calentries
|
# POST /calentries
|
||||||
# POST /calentries.json
|
# POST /calentries.json
|
||||||
# def create
|
def create
|
||||||
# @calentry = Calentry.new(params[:calentry])
|
@calentry = Calentry.new(params[:calentry])
|
||||||
|
|
||||||
# respond_to do |format|
|
respond_to do |format|
|
||||||
# if @calentry.save
|
if @calentry.save
|
||||||
# format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' }
|
format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' }
|
||||||
# format.json { render json: @calentry, status: :created, location: @calentry }
|
format.json { render json: @calentry, status: :created, location: @calentry }
|
||||||
# else
|
format.js
|
||||||
# format.html { render action: "new" }
|
else
|
||||||
# format.json { render json: @calentry.errors, status: :unprocessable_entity }
|
format.html { render action: "new" }
|
||||||
# end
|
format.json { render json: @calentry.errors, status: :unprocessable_entity }
|
||||||
# end
|
format.js { render action: "new" }
|
||||||
# end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# PUT /calentries/1
|
# PUT /calentries/1
|
||||||
# PUT /calentries/1.json
|
# PUT /calentries/1.json
|
||||||
@@ -80,12 +84,16 @@ class CalentriesController < ApplicationController
|
|||||||
# DELETE /calentries/1
|
# DELETE /calentries/1
|
||||||
# DELETE /calentries/1.json
|
# DELETE /calentries/1.json
|
||||||
def destroy
|
def destroy
|
||||||
|
logger.info("-------------delete------------------")
|
||||||
@calentry = Calentry.find(params[:id])
|
@calentry = Calentry.find(params[:id])
|
||||||
|
@calentry_id = params[:id]
|
||||||
|
@object=@calentry.object
|
||||||
@calentry.destroy
|
@calentry.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to calentries_url }
|
format.html { redirect_to @object}
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class Ability
|
|||||||
|
|
||||||
can [:show,:index], Calendar
|
can [:show,:index], Calendar
|
||||||
can [:edit, :update,:new,:create,:verwalten], Calendar
|
can [:edit, :update,:new,:create,:verwalten], Calendar
|
||||||
can [:edit, :update,:new,:create,:verwalten], Calentry
|
can [:edit, :update,:new,:create,:verwalten,:delete], Calentry
|
||||||
end
|
end
|
||||||
if( user.has_role?("fetadmin"))
|
if( user.has_role?("fetadmin"))
|
||||||
can [:delete],Calendar
|
can [:delete],Calendar
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
class Calentry < ActiveRecord::Base
|
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 :calendar
|
||||||
#belongs_to :neuigkeit
|
#belongs_to :neuigkeit
|
||||||
validates :start, :presence => true
|
validates :start, :presence => true
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<div class="contentbox" id="calentry_<%= calentry.id%>">
|
<div class="contentbox" id="calentry_<%= calentry.id%>">
|
||||||
<% image_tag("/iconnavy/time.png") %>
|
<% image_tag("/iconnavy/time.png") %>
|
||||||
<%= fa_icon("calendar 2x") %>
|
<%= 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
|
format=:timeonly
|
||||||
else
|
else
|
||||||
format =:default
|
format =:default
|
||||||
end%>
|
end %>
|
||||||
<%= calentry.text %>
|
<%= calentry.text %>
|
||||||
|
<%= link_to "edit", edit_calentry_path(calentry),:remote=>true if can? :edit, calentry %>
|
||||||
<%= 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>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
<%= fa_icon("calendar 2x") %>
|
<%= fa_icon("calendar 2x") %>
|
||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
<%= semantic_form_for @calentry, :remote=>true, :html=>{:class=>"inline"} do |f| %>
|
<%= semantic_form_for @calentry, :remote=>true, :html=>{:class=>"inline"} do |f| %>
|
||||||
|
|
||||||
<%= f.input :start, :as => :datetimepicker %>
|
<%= 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_ %>
|
<%= 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)%>");
|
$("#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>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="calentries">
|
||||||
<% @calentries1.each do |ce|%>
|
<% @calentries1.each do |ce|%>
|
||||||
<%= render ce unless ce.nil? %>
|
<%= render ce unless ce.nil? %>
|
||||||
<% end %>
|
<% 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 %>
|
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
|
||||||
</div>
|
</div>
|
||||||
<%= render partial: 'nlink_list_whole', :object=>@neuigkeit.nlinks %>
|
<%= render partial: 'nlink_list_whole', :object=>@neuigkeit.nlinks %>
|
||||||
|
|||||||
Reference in New Issue
Block a user