From 57d668d1221139aced16d89eeb752bb5f0d6f95b Mon Sep 17 00:00:00 2001 From: yamin Date: Fri, 25 Aug 2017 18:48:34 +0630 Subject: [PATCH 1/2] InJutyIndexform --- .../origami/in_juties_controller.rb | 27 ++++- .../in_juties/_assign_in_juty.html.erb | 38 ++---- .../origami/in_juties/_edit_in_juty.html.erb | 61 ++-------- .../origami/in_juties/assign_in_juty.html.erb | 62 +++++++++- .../origami/in_juties/index_in_juty.html.erb | 113 +++++++++++------- 5 files changed, 171 insertions(+), 130 deletions(-) diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb index 4106b77a..821aa409 100644 --- a/app/controllers/origami/in_juties_controller.rb +++ b/app/controllers/origami/in_juties_controller.rb @@ -9,7 +9,8 @@ class Origami::InJutiesController < BaseOrigamiController def index_in_juty @juties_in= InJuty.where("dinning_id=?",params[:table_id]) - @table = params[:table_id] + @table = DiningFacility.find(params[:table_id]) + @in_juty = InJuty.new end # GET /in_juties/1 @@ -24,9 +25,11 @@ class Origami::InJutiesController < BaseOrigamiController # GET /in_juties/1/edit def edit + end def edit_in_juty + @in_juty = InJuty.find(params[:id]) @table = DiningFacility.find(params[:table_id]) end @@ -52,11 +55,23 @@ class Origami::InJutiesController < BaseOrigamiController def create_for_in_juty @in_juty = InJuty.new - @in_juty.dinning_id = params[:dining_id] - @in_juty.commissioner_ids = params[:commissioner_ids] - @in_juty.in_time = params[:in_time] - @in_juty.out_time = params[:out_time] - @in_juty.save + + @in_juty.dinning_id = in_juty_params[:dinning_id] + @in_juty.commissioner_ids = in_juty_params[:commissioner_ids] + @in_juty.in_time = in_juty_params[:in_time] + @in_juty.out_time = in_juty_params[:out_time] + + + respond_to do |format| + if @in_juty.save + format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' } + format.json { render :show, status: :created, location: @in_juty } + else + format.html { render :new } + format.json { render json: @in_juty.errors, status: :unprocessable_entity } + end + end + end # PATCH/PUT /in_juties/1 diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_juties/_assign_in_juty.html.erb index 8463c191..f2f0ed16 100644 --- a/app/views/origami/in_juties/_assign_in_juty.html.erb +++ b/app/views/origami/in_juties/_assign_in_juty.html.erb @@ -1,8 +1,9 @@ -
-<%= simple_form_for([:origami,@in_juty]) do |f| %> +<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %> + <%= f.error_notification %>
+ <%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %> <%= @table.name %>
@@ -15,18 +16,15 @@ <%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>

-
-
-
- <%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %> -
-
- -
-
+ +
+ <%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %> + <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %> + <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
+ <% end %> -
+ \ No newline at end of file diff --git a/app/views/origami/in_juties/_edit_in_juty.html.erb b/app/views/origami/in_juties/_edit_in_juty.html.erb index 86622c66..a2405f58 100644 --- a/app/views/origami/in_juties/_edit_in_juty.html.erb +++ b/app/views/origami/in_juties/_edit_in_juty.html.erb @@ -1,59 +1,14 @@ -
<%= simple_form_for([:origami,@in_juty]) do |f| %> <%= f.error_notification %>
- - <%= @table.name %> -
-
- - - <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {class: 'form-control'} ,:value => @in_juty.commissioner.name %>

- - <%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.in_time %>
- - <%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.out_time %> -

+ <%= f.input :dinning_id %> + <%= f.input :commissioner_ids %> + <%= f.input :in_time %> + <%= f.input :out_time %> +
+
-
-
- <%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %> -
-
- -
+ <%= f.button :submit %>
-
-<% end %> -
- - \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/app/views/origami/in_juties/assign_in_juty.html.erb b/app/views/origami/in_juties/assign_in_juty.html.erb index 93dd4745..7176dea6 100644 --- a/app/views/origami/in_juties/assign_in_juty.html.erb +++ b/app/views/origami/in_juties/assign_in_juty.html.erb @@ -2,5 +2,63 @@ - <%= render 'assign_in_juty', in_juty: @in_juty %> - \ No newline at end of file +
+ <%= simple_form_for([:origami,@in_juty]) do |f| %> + <%= f.error_notification %> + +
+ + <%= @table.name %> +
+
+ + + <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>

+ + <%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
+ + <%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%> +

+
+
+
+ <%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %> +
+
+ +
+
+
+ <% end %> +
+ + + + \ No newline at end of file diff --git a/app/views/origami/in_juties/index_in_juty.html.erb b/app/views/origami/in_juties/index_in_juty.html.erb index fc5128bb..0141af05 100644 --- a/app/views/origami/in_juties/index_in_juty.html.erb +++ b/app/views/origami/in_juties/index_in_juty.html.erb @@ -1,48 +1,79 @@ -