-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from hieuhv07/205/create_address
205: create address
- Loading branch information
Showing
15 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ config/environments/*.local.yml | |
|
||
# Ignore application configuration | ||
/config/application.yml | ||
/public/uploads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Manager | ||
class AddressesController < BaseController | ||
def create | ||
@address = Address.new address_params | ||
if @address.save | ||
flash[:success] = t ".success" | ||
else | ||
flash.now[:danger] = t ".danger" | ||
end | ||
respond_to do |format| | ||
format.js | ||
end | ||
end | ||
|
||
private | ||
|
||
def address_params | ||
params.require(:address).permit :name, :area_id | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Address < ApplicationRecord | ||
belongs_to :area | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- if @address.errors.present? | ||
| $("#message_errors").html("#{j(render 'shared/manager/error_messages', object: @address)}"); | ||
toastr.error("#{flash[:danger]}"); | ||
- else | ||
| $('#address_name').val(''); | ||
$('.load-address').load(location.href + ' .load-address'); | ||
toastr.success("#{flash[:success]}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tr | ||
td | ||
= address_counter.next | ||
td | ||
= address.name | ||
td | ||
= link_to t(".delete"), "#", class: "btn btn-danger" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#myModal.modal.fade | ||
.modal-dialog | ||
.modal-content | ||
.modal-header | ||
h4.modal-title = t ".new" | ||
= button_tag t(".btn"), class: "close", data: {dismiss: "modal"}, type: "button" | ||
.modal-body | ||
= form_for :address, url: manager_area_addresses_path(@area), remote: true do |f| | ||
#message_errors | ||
= f.hidden_field :area_id, value: @area.id | ||
.form-group | ||
= f.text_field :name, class: "form-control", placeholder: t(".enter_name") | ||
= f.submit t(".save"), class: "btn btn-primary" | ||
.modal-footer | ||
= button_tag t(".close"), class: "btn btn-danger", data: {dismiss: "modal"}, type: "button" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ location_per: 10 | |
max_size: 5_242_880 | ||
file_path: image/ | ||
time_out: 30 | ||
address_per: 10 |