Add Inviting CRUD

This commit is contained in:
Leo Chen 2020-07-28 00:34:33 +08:00
parent de83819ac3
commit 4380966ab8
16 changed files with 468 additions and 49 deletions

View File

@ -0,0 +1,66 @@
# frozen_string_literal: true
class Admin::VenueManagementInvitingsController < OrbitAdminController
include Admin::VenueManagementsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_venue_management_inviting, only: [:edit, :update, :destroy]
def initialize
super
@app_title = 'venue_management'
end
def index
@table_fields = [
'venue_management.title',
'vm_inviting.case_no',
'vm_inviting.publish_times',
'vm_inviting.rents',
'vm_inviting.royalty',
'vm_inviting.house_tax_payer',
'vm_inviting.land_tax_payer',
'vm_inviting.contractor_manager',
'vm_inviting.bid_result',
]
@invitings = VenueManagementInviting.order(updated_at: :desc).page(params[:page]).per(10)
end
def new
@venue_management = VenueManagementMain.find(params[:id])
@venue_management_inviting = @venue_management.venue_management_invitings.build
end
def create
@venue_management_inviting = VenueManagementInviting.new(venue_management_inviting_params)
@venue_management_inviting.save
redirect_to params['referer_url']
end
def edit
@venue_management = VenueManagementMain.find(@venue_management_inviting.venue_management_main_id)
end
def update
@venue_management_inviting.update_attributes(venue_management_inviting_params)
redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_inviting.venue_management_main_id)
end
def destroy
@venue_management_main_id = @venue_management_inviting.venue_management_main_id
@venue_management_inviting.destroy
redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_main_id)
end
private
def set_venue_management_inviting
@venue_management_inviting = VenueManagementInviting.find(params[:id])
end
def venue_management_inviting_params
params.require(:venue_management_inviting).permit!
end
end

View File

@ -4,7 +4,7 @@ class Admin::VenueManagementsController < OrbitAdminController
require 'axlsx' require 'axlsx'
helper Admin::VenueManagementsFieldHelper helper Admin::VenueManagementsFieldHelper
before_action ->(module_app = @app_title) { set_variables module_app } before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy] before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings]
def initialize def initialize
super super
@ -240,6 +240,20 @@ class Admin::VenueManagementsController < OrbitAdminController
redirect_to "/admin/venue_managements/@venue_management_id.to_s/venue_management_signup" redirect_to "/admin/venue_managements/@venue_management_id.to_s/venue_management_signup"
end end
def venue_management_invitings
@table_fields = [
'vm_inviting.case_no',
'vm_inviting.publish_times',
'vm_inviting.rents',
'vm_inviting.royalty',
'vm_inviting.house_tax_payer',
'vm_inviting.land_tax_payer',
'vm_inviting.contractor_manager',
'vm_inviting.bid_result',
]
@invitings = @venue_management.venue_management_invitings.page(params[:page]).per(10)
end
private private
def set_venue_management def set_venue_management

View File

@ -0,0 +1,33 @@
# frozen_string_literal: true
require 'orbit_form_helper'
class VenueManagementInviting
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Enum
PAYERS = [ :school, :vendor ].freeze
BID_RESULTS = [ :failure, :abandoned, :qualified ].freeze
field :case_no, type: String
field :publish_times, type: Integer
field :start_date, type: Date, default: Time.now
field :end_date, type: Date, default: Time.now
field :close_date, type: Date, default: Time.now
field :bid_date, type: Date, default: Time.now
field :evaluation_date, type: Date, default: Time.now
field :early_rent, type: Integer
field :operation_rent, type: Integer
field :royalty, type: Integer
field :contractor_manager # save user_id
enum :house_tax_payer, PAYERS
enum :land_tax_payer, PAYERS
enum :bid_result, BID_RESULTS
field :details, localize: true
belongs_to :venue_management_main
has_many :venue_management_links, :as => :venue_object, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :venue_management_links, :allow_destroy => true
end

View File

@ -36,6 +36,7 @@ class VenueManagementMain
belongs_to :venue_management_item belongs_to :venue_management_item
has_many :venue_management_links, :autosave => true, :dependent => :destroy has_many :venue_management_links, :autosave => true, :dependent => :destroy
has_many :venue_management_invitings, :autosave => true, :dependent => :destroy
has_many :venue_management_files, :autosave => true, :dependent => :destroy has_many :venue_management_files, :autosave => true, :dependent => :destroy
has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy
has_many :venue_management_signups, :autosave => true, :dependent => :destroy has_many :venue_management_signups, :autosave => true, :dependent => :destroy

View File

@ -0,0 +1,169 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<%= f.hidden_field :venue_management_main_id %>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.case_no') %></label>
<div class="controls">
<%= f.text_field :case_no %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.publish_times') %></label>
<div class="controls">
<%= f.number_field :publish_times %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.start_date') %></label>
<div class="controls">
<%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_inviting.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.end_date') %></label>
<div class="controls">
<%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_inviting.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.close_date') %></label>
<div class="controls">
<%= f.datetime_picker :close_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_inviting.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.bid_date') %></label>
<div class="controls">
<%= f.datetime_picker :bid_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_inviting.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.evaluation_date') %></label>
<div class="controls">
<%= f.datetime_picker :evaluation_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_inviting.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.early_rent') %></label>
<div class="controls">
<%= f.number_field :early_rent %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.operation_rent') %></label>
<div class="controls">
<%= f.number_field :operation_rent %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.royalty') %></label>
<div class="controls">
<%= f.number_field :royalty %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.house_tax_payer') %></label>
<div class="controls">
<%= f.select :house_tax_payer, VenueManagementInviting::PAYERS.map { |p| [t("vm_inviting.enums.#{p}"), p] }, :include_blank => true %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.land_tax_payer') %></label>
<div class="controls">
<%= f.select :land_tax_payer, VenueManagementInviting::PAYERS.map { |p| [t("vm_inviting.enums.#{p}"), p] }, :include_blank => true %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.bid_result') %></label>
<div class="controls">
<%= f.select :bid_result, VenueManagementInviting::BID_RESULTS.map { |p| [t("vm_inviting.enums.bid_result.#{p}"), p] }, :include_blank => true %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t('vm_inviting.details') %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :details_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_inviting.details_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @venue_management_inviting && !@venue_management_inviting.venue_management_links.blank? %>
<div class="exist">
<% @venue_management_inviting.venue_management_links.each_with_index do |venue_management_link, i| %>
<%= f.fields_for :venue_management_links, venue_management_link do |f| %>
<%= render :partial => 'form_link', :object => venue_management_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'venue_management_link_field_count', @venue_management_inviting.venue_management_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= get_referer_url[:venue_managemention] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= link_to t('cancel'), venue_management_invitings_admin_venue_management_path(id: @venue_management.id), :class=>"btn" %>
</div>

View File

@ -0,0 +1,58 @@
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<% if 'venue_management_invitings' == params[:action] %>
<h4><%= @venue_management.title %></h4>
<% end %>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @invitings.each do |inviting| %>
<tr>
<% if 'venue_management_invitings' != params[:action] %>
<td><%= inviting.venue_management_main.title %></td>
<% end %>
<td>
<%= link_to inviting.case_no, admin_venue_management_inviting_path(inviting.id), :target => '_blank' %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(inviting) %>
<li><%= link_to t(:edit), edit_admin_venue_management_inviting_path(inviting.id) %></li>
<li><a href="#" class="delete text-error" rel="/admin/venue_management_invitings/<%=inviting.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><%= inviting.publish_times %></td>
<td><%= "#{inviting.early_rent} / #{inviting.operation_rent}" %></td>
<td><%= inviting.royalty %></td>
<td><%= t("vm_inviting.enums.#{inviting.house_tax_payer}") %></td>
<td><%= t("vm_inviting.enums.#{inviting.land_tax_payer}") %></td>
<td><%= inviting.contractor_manager %></td>
<td><%= t("vm_inviting.enums.bid_result.#{inviting.bid_result}") %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@invitings), class: "pagination pagination-centered"
end
%>
<% if @venue_management.present? %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_venue_management_inviting_path(id: @venue_management.id), class: "btn btn-primary" %>
</div>
</div>
<!-- footer:end -->
<% end %>

View File

@ -0,0 +1,5 @@
<%= form_for @venue_management_inviting, url: admin_venue_management_inviting_path(@venue_management_inviting), html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,4 @@
<span id="index_table">
<%= render 'index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -0,0 +1,5 @@
<%= form_for @venue_management_inviting, url: admin_venue_management_invitings_path, html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -35,7 +35,9 @@
<td><%= VenueManagementMain.time_range(venue_management.venue_management_start_date, venue_management.venue_management_end_date) %></td> <td><%= VenueManagementMain.time_range(venue_management.venue_management_start_date, venue_management.venue_management_end_date) %></td>
<td><%= VenueManagementMain.time_range(venue_management.signup_start_date, venue_management.signup_end_date) %></td> <td><%= VenueManagementMain.time_range(venue_management.signup_start_date, venue_management.signup_end_date) %></td>
<td><a href="/admin/venue_managements/<%=venue_management.id.to_s%>/venue_management_signup"><%= venue_management.venue_management_signups.count %></a></td> <td><a href="/admin/venue_managements/<%=venue_management.id.to_s%>/venue_management_signup"><%= venue_management.venue_management_signups.count %></a></td>
<td><a href="#">0</a></td> <td>
<%= link_to venue_management.venue_management_invitings.count, venue_management_invitings_admin_venue_management_path(venue_management.id) %>
</td>
<td><a href="#">0</a></td> <td><a href="#">0</a></td>
<td><a href="/admin/venue_managements/<%=venue_management.id.to_s%>/export?format=xlsx" target="_blank"><%= t('venue_management.export') %></a></td> <td><a href="/admin/venue_managements/<%=venue_management.id.to_s%>/export?format=xlsx" target="_blank"><%= t('venue_management.export') %></a></td>
</tr> </tr>

View File

@ -0,0 +1,5 @@
<span id="index_table">
<%= render 'admin/venue_management_invitings/index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -3,7 +3,7 @@ en:
simple_captcha: simple_captcha:
placeholder: "" placeholder: ""
label: "" label: ""
empty: none
restful_actions: restful_actions:
act_signup: Sign Up Info #報名資料 act_signup: Sign Up Info #報名資料
venue_management_submission_field: VenueManagement Submission Field venue_management_submission_field: VenueManagement Submission Field
@ -137,3 +137,27 @@ en:
logout: Log Out #登出 logout: Log Out #登出
logouting: Logging Out #登出中 logouting: Logging Out #登出中
success_message: 'Registration successful, thank you.' success_message: 'Registration successful, thank you.'
vm_inviting:
case_no: 'Case No.'
publish_times: Publish Times
start_date: Start Date
end_date: End Date
close_date: Close Date
bid_date: Bid Date
evaluation_date: Evaluation Date
rents: 'Early / Operation Rent'
early_rent: Early
operation_rent: Operation Rent
royalty: Royalty
house_tax_payer: House Tax Payer
land_tax_payer: Land Tax Payer
contractor_manager: Contractor Manager
bid_result: Bid Result
details: Details
enums:
school: School
vendor: Vendor
bid_result:
failure: Failure
abandoned: Abandoned
qualified: Qualified

View File

@ -3,7 +3,7 @@ zh_tw:
simple_captcha: simple_captcha:
placeholder: "" placeholder: ""
label: "" label: ""
empty:
restful_actions: restful_actions:
act_signup: 報名資料 act_signup: 報名資料
venue_management_submission_field: 上傳介面欄位 venue_management_submission_field: 上傳介面欄位
@ -88,6 +88,9 @@ zh_tw:
set_venue_management_signup_field: 圈選設定 set_venue_management_signup_field: 圈選設定
set_venue_management_item_content: 項目設定 set_venue_management_item_content: 項目設定
set_venue_management_agreements: 個資宣告設定 set_venue_management_agreements: 個資宣告設定
set_venue_management_contracts: 履約記錄
set_venue_management_invitings: 招商公告
set_venue_management_memorabilias: 大事記
venue_management_agreements_content: 個資宣告內容 venue_management_agreements_content: 個資宣告內容
to_require: 是否必填 to_require: 是否必填
sign_up_not_yet: 報名時間未開始 sign_up_not_yet: 報名時間未開始
@ -137,3 +140,27 @@ zh_tw:
logout: 登出 logout: 登出
logouting: 登出中 logouting: 登出中
success_message: '您的報名已成功,感謝您的參與。' success_message: '您的報名已成功,感謝您的參與。'
vm_inviting:
case_no: 案號
publish_times: 公告次數
start_date: 公告開始
end_date: 公告結束
close_date: 截止收件
bid_date: 開標日期
evaluation_date: 評選時間
rents: '興建期/營運期租金'
early_rent: 興建期租金
operation_rent: 營運期租金
royalty: 權利金
house_tax_payer: 房屋稅負擔方
land_tax_payer: 地價稅負擔方
contractor_manager: 招商承辦人
bid_result: 開標結果
details: 其他說明
enums:
school: 學校
vendor: 廠商
bid_result:
failure: 流標
abandoned: 廢標
qualified: 合格續行評審

View File

@ -12,6 +12,7 @@ Rails.application.routes.draw do
get 'venue_management_item_content' get 'venue_management_item_content'
get 'venue_management_signup_field' get 'venue_management_signup_field'
get 'venue_management_submission_field' get 'venue_management_submission_field'
get 'venue_management_invitings'
end end
end end
resources :venue_management_items do resources :venue_management_items do
@ -22,6 +23,7 @@ Rails.application.routes.draw do
resources :venue_management_agreements resources :venue_management_agreements
resources :venue_management_signups resources :venue_management_signups
resources :venue_management_item_contents resources :venue_management_item_contents
resources :venue_management_invitings
end end
resources :venue_managements do resources :venue_managements do

View File

@ -42,8 +42,12 @@ module VenueManagement
:priority=>3, :priority=>3,
:active_for_action=>{'admin/venue_managements'=>'venue_management_agreements'}, :active_for_action=>{'admin/venue_managements'=>'venue_management_agreements'},
:available_for => 'managers' :available_for => 'managers'
context_link 'venue_management.set_venue_management_invitings',
:link_path => 'admin_venue_management_invitings_path',
:priority => 3,
:active_for_action => { 'admin/venue_managements' => 'venue_management_invitings' },
:available_for => 'managers'
end end
end end
end end
end end