Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

カーリルのバーコード連番印刷へのリンクを追加する #1835

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/controllers/calil/barcodes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Calil::BarcodesController < ApplicationController
def new
@library = Library.friendly.find(params[:library_id])
authorize @library

@calil_barcode = Calil::Barcode.new(name: @library.name)
end

def create
end
end
15 changes: 15 additions & 0 deletions app/models/calil/barcode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Calil
class Barcode
include ActiveModel::Model
include ActiveModel::Attributes
attributes :name, :string
attributes :initial_number, :string
attribuets :number_of_sheets, :integer, default: 1

with_options presence: true do
validates :name # 図書館名
validates :initial_number # 開始番号
end
validates :number_of_sheets, numericality: { greater_than_or_equal_to: 0 } # 枚数
end
end
27 changes: 27 additions & 0 deletions app/views/calil/barcodes/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div id="content_detail" class="ui-corner-all ui-widget-content">
<h1 class="title"><%= @library.display_name.localize -%></h1>
<div id="content_list">
<%= render 'page/required_field' %>
<%= form_with(model: @calil_barcode, url: library_barcodes_path, method: :post) do |f| %>
<%= error_messages(@calil_barcode) %>
<div class="field">
<%= f.label :name %>
<%= f.text_field :name, class: 'short_name' %>
</div>

<div class="field">
<%= f.label :initial_number %>
<%= f.text_field :initial_number, class: 'short_name' %>
</div>

<div class="field">
<%= f.label :number_of_sheets %>
<%= f.number_field :number_of_sheets, class: 'short_name' %>
</div>

<% end %>
</div>
</div>

<div id="submenu" class="ui-corner-all ui-widget-content">
</div>
1 change: 1 addition & 0 deletions app/views/libraries/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<li><%= link_to t('page.new', model: t('activerecord.models.event')), new_event_path(library_id: @library.id) -%></li>
<%- end -%>
<%- end -%>
<li><%= link_to "連番を作成する", new_library_barcode_path(library_id: @library.name) -%></li>
<li><%= link_to t('page.listing', model: t('activerecord.models.library')), libraries_path -%></li>
</ul>
</div>
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
resources :carrier_types
resources :content_types
resources :donates
resources :libraries
resources :libraries do
resources :barcodes, only: [:new, :create], module: 'calil'
end
resources :shelves
resources :accepts
resources :withdraws
Expand Down