Skip to content

Commit

Permalink
bug fixes for address lists
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSipayung committed Jan 24, 2024
1 parent b3a6458 commit 2595129
Show file tree
Hide file tree
Showing 59 changed files with 883 additions and 40 deletions.
7 changes: 7 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions app/controllers/address_kabupaten_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AddressKabupatenListsController < ApplicationController
before_action :set_address_kabupaten_list, only: %i[ show edit update destroy ]

# GET /address_kabupaten_lists or /address_kabupaten_lists.json
def index
@address_kabupaten_lists = AddressKabupatenList.all
end

# GET /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json
def show
end

# GET /address_kabupaten_lists/new
def new
@address_kabupaten_list = AddressKabupatenList.new
end

# GET /address_kabupaten_lists/1/edit
def edit
end

# POST /address_kabupaten_lists or /address_kabupaten_lists.json
def create
@address_kabupaten_list = AddressKabupatenList.new(address_kabupaten_list_params)

respond_to do |format|
if @address_kabupaten_list.save
format.html { redirect_to address_kabupaten_list_url(@address_kabupaten_list), notice: "Address kabupaten list was successfully created." }
format.json { render :show, status: :created, location: @address_kabupaten_list }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @address_kabupaten_list.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json
def update
respond_to do |format|
if @address_kabupaten_list.update(address_kabupaten_list_params)
format.html { redirect_to address_kabupaten_list_url(@address_kabupaten_list), notice: "Address kabupaten list was successfully updated." }
format.json { render :show, status: :ok, location: @address_kabupaten_list }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @address_kabupaten_list.errors, status: :unprocessable_entity }
end
end
end

# DELETE /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json
def destroy
@address_kabupaten_list.destroy!

respond_to do |format|
format.html { redirect_to address_kabupaten_lists_url, notice: "Address kabupaten list was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_address_kabupaten_list
@address_kabupaten_list = AddressKabupatenList.find(params[:id])
end

# Only allow a list of trusted parameters through.
def address_kabupaten_list_params
params.require(:address_kabupaten_list).permit(:kabupaten, :address_kecamatan_list_id)
end
end
70 changes: 70 additions & 0 deletions app/controllers/address_kecamatan_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AddressKecamatanListsController < ApplicationController
before_action :set_address_kecamatan_list, only: %i[ show edit update destroy ]

# GET /address_kecamatan_lists or /address_kecamatan_lists.json
def index
@address_kecamatan_lists = AddressKecamatanList.all
end

# GET /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json
def show
end

# GET /address_kecamatan_lists/new
def new
@address_kecamatan_list = AddressKecamatanList.new
end

# GET /address_kecamatan_lists/1/edit
def edit
end

# POST /address_kecamatan_lists or /address_kecamatan_lists.json
def create
@address_kecamatan_list = AddressKecamatanList.new(address_kecamatan_list_params)

respond_to do |format|
if @address_kecamatan_list.save
format.html { redirect_to address_kecamatan_list_url(@address_kecamatan_list), notice: "Address kecamatan list was successfully created." }
format.json { render :show, status: :created, location: @address_kecamatan_list }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @address_kecamatan_list.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json
def update
respond_to do |format|
if @address_kecamatan_list.update(address_kecamatan_list_params)
format.html { redirect_to address_kecamatan_list_url(@address_kecamatan_list), notice: "Address kecamatan list was successfully updated." }
format.json { render :show, status: :ok, location: @address_kecamatan_list }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @address_kecamatan_list.errors, status: :unprocessable_entity }
end
end
end

# DELETE /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json
def destroy
@address_kecamatan_list.destroy!

respond_to do |format|
format.html { redirect_to address_kecamatan_lists_url, notice: "Address kecamatan list was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_address_kecamatan_list
@address_kecamatan_list = AddressKecamatanList.find(params[:id])
end

# Only allow a list of trusted parameters through.
def address_kecamatan_list_params
params.require(:address_kecamatan_list).permit(:kecamatan, :address_province_list_id)
end
end
70 changes: 70 additions & 0 deletions app/controllers/address_province_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AddressProvinceListsController < ApplicationController
before_action :set_address_province_list, only: %i[ show edit update destroy ]

# GET /address_province_lists or /address_province_lists.json
def index
@address_province_lists = AddressProvinceList.all
end

# GET /address_province_lists/1 or /address_province_lists/1.json
def show
end

# GET /address_province_lists/new
def new
@address_province_list = AddressProvinceList.new
end

# GET /address_province_lists/1/edit
def edit
end

# POST /address_province_lists or /address_province_lists.json
def create
@address_province_list = AddressProvinceList.new(address_province_list_params)

respond_to do |format|
if @address_province_list.save
format.html { redirect_to address_province_list_url(@address_province_list), notice: "Address province list was successfully created." }
format.json { render :show, status: :created, location: @address_province_list }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @address_province_list.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /address_province_lists/1 or /address_province_lists/1.json
def update
respond_to do |format|
if @address_province_list.update(address_province_list_params)
format.html { redirect_to address_province_list_url(@address_province_list), notice: "Address province list was successfully updated." }
format.json { render :show, status: :ok, location: @address_province_list }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @address_province_list.errors, status: :unprocessable_entity }
end
end
end

# DELETE /address_province_lists/1 or /address_province_lists/1.json
def destroy
@address_province_list.destroy!

respond_to do |format|
format.html { redirect_to address_province_lists_url, notice: "Address province list was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_address_province_list
@address_province_list = AddressProvinceList.find(params[:id])
end

# Only allow a list of trusted parameters through.
def address_province_list_params
params.require(:address_province_list).permit(:provinsi)
end
end
2 changes: 2 additions & 0 deletions app/helpers/address_kabupaten_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AddressKabupatenListsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/address_kecamatan_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AddressKecamatanListsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/address_province_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AddressProvinceListsHelper
end
3 changes: 3 additions & 0 deletions app/models/address_kabupaten_list.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AddressKabupatenList < ApplicationRecord
belongs_to :address_kecamatan_list
validates :kabupaten, presence: true, uniqueness: true,
length: { minimum: 3, maximum: 35 }
end
4 changes: 4 additions & 0 deletions app/models/address_kecamatan_list.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class AddressKecamatanList < ApplicationRecord
has_many :address_kabupaten_lists, dependent: :destroy
belongs_to :address_province_list
validates :kecamatan, presence: true, uniqueness: true,
length: { minimum: 3, maximum: 35 }
end
3 changes: 3 additions & 0 deletions app/models/address_province_list.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AddressProvinceList < ApplicationRecord
has_many :address_kecamatan_lists, dependent: :destroy
validates :provinsi, presence: true, uniqueness: true,
length: { minimum: 3, maximum: 35 }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="<%= dom_id address_kabupaten_list %>">
<p>
<strong>Kabupaten:</strong>
<%= address_kabupaten_list.kabupaten %>
</p>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! address_kabupaten_list, :id, :kabupaten, :created_at, :updated_at
json.url address_kabupaten_list_url(address_kabupaten_list, format: :json)
22 changes: 22 additions & 0 deletions app/views/address_kabupaten_lists/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= form_with(model: address_kabupaten_list) do |form| %>
<% if address_kabupaten_list.errors.any? %>
<div style="color: red">
<h2><%= pluralize(address_kabupaten_list.errors.count, "error") %> prohibited this address_kabupaten_list from being saved:</h2>

<ul>
<% address_kabupaten_list.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>

<div>
<%= form.label :kabupaten, style: "display: block" %>
<%= form.text_field :kabupaten %>
</div>

<div>
<%= form.submit %>
</div>
<% end %>
10 changes: 10 additions & 0 deletions app/views/address_kabupaten_lists/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>Editing address kabupaten list</h1>

<%= render "form", address_kabupaten_list: @address_kabupaten_list %>

<br>

<div>
<%= link_to "Show this address kabupaten list", @address_kabupaten_list %> |
<%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %>
</div>
14 changes: 14 additions & 0 deletions app/views/address_kabupaten_lists/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p style="color: green"><%= notice %></p>

<h1>Address kabupaten lists</h1>

<div id="address_kabupaten_lists">
<% @address_kabupaten_lists.each do |address_kabupaten_list| %>
<%= render address_kabupaten_list %>
<p>
<%= link_to "Show this address kabupaten list", address_kabupaten_list %>
</p>
<% end %>
</div>

<%= link_to "New address kabupaten list", new_address_kabupaten_list_path %>
1 change: 1 addition & 0 deletions app/views/address_kabupaten_lists/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @address_kabupaten_lists, partial: "address_kabupaten_lists/address_kabupaten_list", as: :address_kabupaten_list
9 changes: 9 additions & 0 deletions app/views/address_kabupaten_lists/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>New address kabupaten list</h1>

<%= render "form", address_kabupaten_list: @address_kabupaten_list %>

<br>

<div>
<%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %>
</div>
10 changes: 10 additions & 0 deletions app/views/address_kabupaten_lists/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p style="color: green"><%= notice %></p>

<%= render @address_kabupaten_list %>

<div>
<%= link_to "Edit this address kabupaten list", edit_address_kabupaten_list_path(@address_kabupaten_list) %> |
<%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %>

<%= button_to "Destroy this address kabupaten list", @address_kabupaten_list, method: :delete %>
</div>
1 change: 1 addition & 0 deletions app/views/address_kabupaten_lists/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.partial! "address_kabupaten_lists/address_kabupaten_list", address_kabupaten_list: @address_kabupaten_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="<%= dom_id address_kecamatan_list %>">
<p>
<strong>Kecamatan:</strong>
<%= address_kecamatan_list.kecamatan %>
</p>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! address_kecamatan_list, :id, :kecamatan, :created_at, :updated_at
json.url address_kecamatan_list_url(address_kecamatan_list, format: :json)
22 changes: 22 additions & 0 deletions app/views/address_kecamatan_lists/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= form_with(model: address_kecamatan_list) do |form| %>
<% if address_kecamatan_list.errors.any? %>
<div style="color: red">
<h2><%= pluralize(address_kecamatan_list.errors.count, "error") %> prohibited this address_kecamatan_list from being saved:</h2>

<ul>
<% address_kecamatan_list.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>

<div>
<%= form.label :kecamatan, style: "display: block" %>
<%= form.text_field :kecamatan %>
</div>

<div>
<%= form.submit %>
</div>
<% end %>
10 changes: 10 additions & 0 deletions app/views/address_kecamatan_lists/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>Editing address kecamatan list</h1>

<%= render "form", address_kecamatan_list: @address_kecamatan_list %>

<br>

<div>
<%= link_to "Show this address kecamatan list", @address_kecamatan_list %> |
<%= link_to "Back to address kecamatan lists", address_kecamatan_lists_path %>
</div>
14 changes: 14 additions & 0 deletions app/views/address_kecamatan_lists/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p style="color: green"><%= notice %></p>

<h1>Address kecamatan lists</h1>

<div id="address_kecamatan_lists">
<% @address_kecamatan_lists.each do |address_kecamatan_list| %>
<%= render address_kecamatan_list %>
<p>
<%= link_to "Show this address kecamatan list", address_kecamatan_list %>
</p>
<% end %>
</div>

<%= link_to "New address kecamatan list", new_address_kecamatan_list_path %>
Loading

0 comments on commit 2595129

Please sign in to comment.