Add action Settings::PassportsController#new
This commit is contained in:
parent
e3f410c223
commit
44131ce7d3
6 changed files with 70 additions and 1 deletions
|
@ -7,6 +7,7 @@ class Settings::PassportsController < ApplicationController
|
|||
|
||||
before_action :set_account
|
||||
before_action :set_passport, only: :show
|
||||
before_action :new_passport, only: :new
|
||||
|
||||
# GET /settings/passports
|
||||
def index
|
||||
|
@ -20,6 +21,11 @@ class Settings::PassportsController < ApplicationController
|
|||
authorize [:settings, @passport]
|
||||
end
|
||||
|
||||
# GET /settings/passports/new
|
||||
def new
|
||||
authorize [:settings, Passport]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
|
@ -29,4 +35,8 @@ private
|
|||
def set_passport
|
||||
@passport = Passport.find params[:id]
|
||||
end
|
||||
|
||||
def new_passport
|
||||
@passport = Passport.new person: @account&.person
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,4 +8,8 @@ class Settings::PassportPolicy < ApplicationPolicy
|
|||
def show?
|
||||
account&.person && record.person == account.person
|
||||
end
|
||||
|
||||
def create?
|
||||
account&.person
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,17 @@
|
|||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
<% if policy([:settings, Passport]).new? %>
|
||||
<div class="btn-group mb-3" role="group">
|
||||
<% if policy([:settings, Passport]).new? %>
|
||||
<%= link_to translate(:create),
|
||||
new_settings_passport_path,
|
||||
class: 'btn btn-primary',
|
||||
role: :button %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'table', locals: { passports: @passports } %>
|
||||
<%= pagination @passports %>
|
||||
</div>
|
||||
|
|
37
app/views/settings/passports/new.html.erb
Normal file
37
app/views/settings/passports/new.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4">
|
||||
<%= render partial: 'settings/nav_sidebar', locals: { tab: :passports } %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
<%= simple_form_for [:settings, @passport] do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<%= f.input :series %>
|
||||
<%= f.input :number %>
|
||||
<%= f.input :issued_by %>
|
||||
<%= f.input :unit_code %>
|
||||
<%= f.input :date_of_issue %>
|
||||
|
||||
<%= f.input :zip_code %>
|
||||
<%= f.input :town_type %>
|
||||
<%= f.input :town_name %>
|
||||
<%= f.input :settlement_type %>
|
||||
<%= f.input :settlement_name %>
|
||||
<%= f.input :district_type %>
|
||||
<%= f.input :district_name %>
|
||||
<%= f.input :street_type %>
|
||||
<%= f.input :street_name %>
|
||||
<%= f.input :residence_type %>
|
||||
<%= f.input :residence_name %>
|
||||
<%= f.input :building_type %>
|
||||
<%= f.input :building_name %>
|
||||
<%= f.input :apartment_type %>
|
||||
<%= f.input :apartment_name %>
|
||||
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -35,7 +35,7 @@ Rails.application.routes.draw do
|
|||
resource :appearance, only: %i[edit update]
|
||||
resource :person, only: %i[show new]
|
||||
resources :sessions, only: :index
|
||||
resources :passports, only: %i[index show]
|
||||
resources :passports, only: %i[index show new]
|
||||
|
||||
resources :contacts, only: %i[index create destroy] do
|
||||
resource :security_notification_switch,
|
||||
|
|
7
spec/requests/settings/passports/new_spec.rb
Normal file
7
spec/requests/settings/passports/new_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /settings/passports/new' do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Reference in a new issue