add some change

This commit is contained in:
chiu 2020-08-02 21:33:41 +08:00
parent 5ea12df38d
commit 04bbebe1ed
21 changed files with 356 additions and 255 deletions

View File

@ -29,8 +29,6 @@ class Admin::VenueManagementContractsController < OrbitAdminController
def create
@venue_management_contract = VenueManagementContract.new(venue_management_contract_params)
inviting = VenueManagementInviting.find_by(id: venue_management_contract_params[:venue_management_inviting_id])
assign_inviting_attrs(@venue_management_contract, inviting)
@venue_management_contract.save
redirect_to params['referer_url']
@ -41,10 +39,7 @@ class Admin::VenueManagementContractsController < OrbitAdminController
end
def update
inviting = VenueManagementInviting.find_by(id: venue_management_contract_params[:venue_management_inviting_id])
assign_inviting_attrs(@venue_management_contract, inviting)
@venue_management_contract.update_attributes(venue_management_contract_params)
@venue_management_contract.update_attributes!(venue_management_contract_params)
redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_contract.venue_management_main_id)
end
@ -57,12 +52,6 @@ class Admin::VenueManagementContractsController < OrbitAdminController
private
def assign_inviting_attrs(contract, inviting)
%i(case_no publish_times start_date end_date close_date bid_date evaluation_date early_rent operation_rent royalty contractor_manager house_tax_payer land_tax_payer bid_result details).each do |attr|
contract[attr] = inviting.send(attr)
end
end
def set_venue_management_contract
@venue_management_contract = VenueManagementContract.find(params[:id])
end

View File

@ -1,5 +1,3 @@
# frozen_string_literal: true
class Admin::VenueManagementMemorabiliasController < OrbitAdminController
include Admin::VenueManagementsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
@ -22,7 +20,7 @@ class Admin::VenueManagementMemorabiliasController < OrbitAdminController
def new
@venue_management = VenueManagementMain.find(params[:id])
@venue_management_memorabilia = @venue_management.venue_management_memorabilias.build
@venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_main_id: params[:id])
end
def create

View File

@ -81,12 +81,12 @@ class Admin::VenueManagementsController < OrbitAdminController
def create
if !venue_management_params['venue_management_links_attributes'].nil?
venue_management_params['venue_management_links_attributes'].each do |idx,link|
venue_management_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
venue_management_main_params = venue_management_params
if !venue_management_main_params['venue_management_links_attributes'].nil?
venue_management_main_params['venue_management_links_attributes'].each do |idx,link|
venue_management_main_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
end
end
venue_management_main_params = venue_management_params
venue_management_signup_set_params = venue_management_main_params['venue_management_signup_field_sets']
venue_management_submission_set_params = venue_management_main_params['venue_management_submission_field_sets']
venue_management_email_sets_params = venue_management_main_params['venue_management_email_sets']
@ -173,20 +173,21 @@ class Admin::VenueManagementsController < OrbitAdminController
@venue_management.venue_management_submission_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to admin_venue_managements_path
else
if !venue_management_params['venue_management_links_attributes'].nil?
venue_management_params['venue_management_links_attributes'].each do |idx,link|
venue_management_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
venue_management_main_params = venue_management_params
if !venue_management_main_params['venue_management_links_attributes'].nil?
venue_management_main_params['venue_management_links_attributes'].each do |idx,link|
venue_management_main_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
end
end
@venue_management.update_user_id = current_user.id
if @venue_management.update_attributes(venue_management_params)
if @venue_management.update_attributes(venue_management_main_params)
@venue_management.venue_management_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to params['referer_url']
else
flash.now[:error] = t('update.error.category')
render action: :edit
flash.keep
redirect_to action: :edit, :id =>@venue_management.id.to_s
end
end

View File

@ -0,0 +1,12 @@
module VenueLinkFile
extend ActiveSupport::Concern
included do
tmp = self.to_s.underscore.to_sym
VenueManagementFile.send(:belongs_to,tmp, :class_name => self.to_s, :foreign_key => "#{tmp}_id")
VenueManagementLink.send(:belongs_to,tmp, :class_name => self.to_s, :foreign_key => "#{tmp}_id")
self.has_many :venue_management_files, :autosave => true, :dependent => :destroy
self.accepts_nested_attributes_for :venue_management_files, :allow_destroy => true
self.has_many :venue_management_links, :autosave => true, :dependent => :destroy
self.accepts_nested_attributes_for :venue_management_links, :allow_destroy => true
end
end

View File

@ -7,10 +7,12 @@ class VenueManagementContract
include Mongoid::Timestamps
include Mongoid::Enum
PAYERS = [ :school, :vendor ].freeze
BID_RESULTS = [ :failure, :abandoned, :qualified ].freeze
PAYERS = [ :school, :vendor].freeze
BID_RESULTS = [ :failure, :abandoned, :qualified].freeze
# Copy from Inviting
field :renewal_permission, type: Boolean,default: false
field :renewal_deadline, type: Date
field :case_no, type: String
field :publish_times, type: Integer
field :start_date, type: Date, default: Time.now
@ -49,10 +51,31 @@ class VenueManagementContract
field :other_commitment, localize: true
field :note, localize: true
belongs_to :venue_management_main
belongs_to :venue_management_inviting
has_many :venue_management_links, :as => :venue_object, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :venue_management_links, :allow_destroy => true
include VenueLinkFile
before_save do
org_contract = VenueManagementContract.find(self.id)
inviting = VenueManagementInviting.find(self.venue_management_inviting_id) rescue nil
if !inviting.nil?
%i(case_no publish_times start_date end_date close_date bid_date evaluation_date contractor_manager bid_result details).each do |attr_|
self[attr_] = inviting.send(attr_) rescue nil
end
else
self[:case_no] = nil
end
update_flag = true
if org_contract.venue_management_inviting_id == self.venue_management_inviting_id
%i(early_rent operation_rent royalty house_tax_payer land_tax_payer).each do |attr_|
if self[attr_] != (inviting.send(attr_) rescue nil)
update_flag = false
end
end
end
if update_flag && !inviting.nil?
%i(early_rent operation_rent royalty house_tax_payer land_tax_payer).each do |attr_|
self[attr_] = (inviting.send(attr_) rescue nil)
end
end
end
end

View File

@ -8,7 +8,6 @@ class VenueManagementFile
field :description, localize: true
field :title, localize: true
belongs_to :venue_management_main
#belongs_to :venue_management_main
#belongs_to :venue_management_contract
end

View File

@ -6,9 +6,9 @@ class VenueManagementInviting
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Enum
PAYERS = [ :school, :vendor ].freeze
BID_RESULTS = [ :failure, :abandoned, :qualified ].freeze
include OrbitTag::Taggable
PAYERS = [ :school, :vendor].freeze
BID_RESULTS = [ :failure, :abandoned, :qualified].freeze
field :case_no, type: String
field :publish_times, type: Integer
@ -26,8 +26,14 @@ class VenueManagementInviting
enum :bid_result, BID_RESULTS
field :details, localize: true
has_many :venue_management_contracts
has_many :venue_management_memorabilias, :class_name => 'VenueManagementMemorabilia', :foreign_key => "venue_management_memorabilia_ids"
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
include VenueLinkFile
before_save do
contracts = self.venue_management_contracts
contracts.each do |contract|
contract.save
end
end
end

View File

@ -8,11 +8,10 @@ class VenueManagementLink
field :url
field :title, localize: true
belongs_to :venue_management_main
before_validation :add_http
validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
#belongs_to :venue_management_main
#belongs_to :venue_management_contract
#validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
protected

View File

@ -1,7 +1,6 @@
class VenueManagementMain
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Impression
# encoding: utf-8
include OrbitCategory::Categorizable
@ -35,11 +34,9 @@ class VenueManagementMain
belongs_to :venue_management_item
has_many :venue_management_links, :autosave => true, :dependent => :destroy
has_many :venue_management_invitings, :autosave => true, :dependent => :destroy
has_many :venue_management_memorabilias, :autosave => true, :dependent => :destroy
has_many :venue_management_contracts, :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_signups, :autosave => true, :dependent => :destroy
has_many :venue_management_submission_fields, :autosave => true, :dependent => :destroy
@ -49,8 +46,7 @@ class VenueManagementMain
has_many :venue_management_submission_field_sets, autosave: true, dependent: :destroy
has_many :venue_management_email_sets, autosave: true, dependent: :destroy
has_many :venue_management_signup_field_customs, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :venue_management_links, :allow_destroy => true
accepts_nested_attributes_for :venue_management_files, :allow_destroy => true
accepts_nested_attributes_for :venue_management_memorabilias, :allow_destroy => true
accepts_nested_attributes_for :venue_management_item_contents, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signups, :allow_destroy => true
accepts_nested_attributes_for :venue_management_submission_fields, :allow_destroy => true
@ -60,6 +56,7 @@ class VenueManagementMain
accepts_nested_attributes_for :venue_management_submission_field_sets, :allow_destroy => true
accepts_nested_attributes_for :venue_management_email_sets, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signup_field_customs, :allow_destroy => true
include VenueLinkFile
def self.time_range(date1 = null, date2 = null)
if !date1.blank?

View File

@ -1,18 +1,19 @@
# frozen_string_literal: true
require 'orbit_form_helper'
class VenueManagementMemorabilia
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Enum
field :event_date, type: Date, default: Time.now
field :case_no, type: String
field :details, localize: true
def case_no
inviting = self.venue_management_inviting
if !inviting.nil?
inviting.case_no
else
nil
end
end
belongs_to :venue_management_inviting
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
include VenueLinkFile
end

View File

@ -24,6 +24,48 @@
<%= f.select :venue_management_inviting_id, @venue_management.venue_management_invitings.map { |i| [ i.case_no, i.id ] }, :include_blank => true %>
</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] } %>
</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] } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_contract.renewal_permission') %></label>
<div class="controls">
<%= f.check_box :renewal_permission,:id => 'renewal_permission' %>
</div>
</div>
<div class="control-group" id="renewal_deadline" style="<%= 'display:none' if !@venue_management_contract.renewal_permission %>">
<label class="control-label muted"><%= t('vm_contract.renewal_deadline') %></label>
<div class="controls">
<%= f.datetime_picker :renewal_deadline, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_contract.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('vm_contract.contract_start_date') %></label>
<div class="controls">
@ -146,7 +188,7 @@
<div class="controls">
<div class="textarea">
<%= f.fields_for :other_commitment_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_contract.details_translations[locale] rescue nil) %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_contract.other_commitment_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
@ -157,7 +199,7 @@
<div class="controls">
<div class="textarea">
<%= f.fields_for :note_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_contract.details_translations[locale] rescue nil) %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_contract.note_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
@ -165,34 +207,9 @@
</div>
<% end %>
<%= render partial: 'admin/venue_shared/venue_file_link',locals: {venue: @venue_management_contract,f: f} %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @venue_management_contract && !@venue_management_contract.venue_management_links.blank? %>
<div class="exist">
<% @venue_management_contract.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_contract.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 -->
@ -202,3 +219,14 @@
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= link_to t('cancel'), venue_management_contracts_admin_venue_management_path(id: @venue_management.id), :class=>"btn" %>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#renewal_permission').change(function(){
if ($(this).prop('checked')){
$('#renewal_deadline').show()
}else{
$('#renewal_deadline').hide()
}
})
})
</script>

View File

@ -17,6 +17,11 @@
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Tag Module -->
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.type') %></label>
<%= select_tags(f, @module_app) %>
</div>
<%= f.hidden_field :venue_management_main_id %>
<div class="control-group">
<label class="control-label muted"><%= t('vm_inviting.case_no') %></label>
@ -81,19 +86,19 @@
<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 %>
<%= f.select :house_tax_payer, VenueManagementInviting::PAYERS.map { |p| [t("vm_inviting.enums.#{p}"), p] } %>
</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 %>
<%= f.select :land_tax_payer, VenueManagementInviting::PAYERS.map { |p| [t("vm_inviting.enums.#{p}"), p] } %>
</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 %>
<%= f.select :bid_result, VenueManagementInviting::BID_RESULTS.map { |p| [t("vm_inviting.enums.bid_result.#{p}"), p] } %>
</div>
</div>
</div>
@ -131,32 +136,7 @@
<% 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>
<%= render partial: 'admin/venue_shared/venue_file_link',locals: {venue: @venue_management_inviting,f: f} %>
</div>
</div>

View File

@ -21,7 +21,7 @@
<div class="control-group">
<label class="control-label muted"><%= t('vm_memorabilia.case_no') %></label>
<div class="controls">
<%= f.text_field :case_no %>
<%= f.select :venue_management_inviting_id, @venue_management.venue_management_invitings.map { |i| [ i.case_no, i.id ] }, :include_blank => true %>
</div>
</div>
<div class="control-group">
@ -55,42 +55,15 @@
<label class="control-label muted"><%= t('vm_memorabilia.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_memorabilia.details_translations[locale] rescue nil) %>
<%= f.fields_for :details_translations do |f1| %>
<%= f1.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_memorabilia.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_memorabilia && !@venue_management_memorabilia.venue_management_links.blank? %>
<div class="exist">
<% @venue_management_memorabilia.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_memorabilia.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>
<%= render partial: 'admin/venue_shared/venue_file_link',locals: {venue: @venue_management_memorabilia,f: f} %>
</div>
</div>

View File

@ -25,7 +25,13 @@
<div class="input-area">
<!-- Module Tabs -->
<% flash.each do |type, msg| %>
<div class="alert alert-danger">
<%= msg %>
</div>
<% end %>
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#signup" data-toggle="tab"><%= t('venue_management.signup') %></a></li>
@ -85,7 +91,6 @@
</div>
<!-- Sign up Module -->
<div class="tab-pane fade in " id="signup">
@ -442,62 +447,7 @@
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @venue_management && !@venue_management.venue_management_links.blank? %>
<div class="exist">
<% @venue_management.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.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>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @venue_management && !@venue_management.venue_management_files.blank? %>
<div class="exist">
<% @venue_management.venue_management_files.each_with_index do |venue_management_file, i| %>
<%= f.fields_for :venue_management_files, venue_management_file do |f| %>
<%= render :partial => 'form_file', :object => venue_management_file, :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_file_field_count', @venue_management.venue_management_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<%= render partial: 'admin/venue_shared/venue_file_link',locals: {venue: @venue_management,f: f} %>
</div>
@ -510,47 +460,3 @@
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= link_to t('cancel'), admin_venue_managements_path, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$("#main-wrap").after("");
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_venue_management_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :venue_management_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_venue_management_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :venue_management_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,55 @@
<% if form_file.nil? || form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exists start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.nil? || form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_file.nil? || form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,26 @@
<div class="input-prepend input-append start-line">
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<% if form_link.nil? || form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -0,0 +1,94 @@
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if !venue.nil? && !venue.venue_management_links.blank? %>
<div class="exist">
<% venue.venue_management_links.each_with_index do |venue_management_link, i| %>
<%= f.fields_for :venue_management_links, venue_management_link do |f| %>
<%= render :partial => 'admin/venue_shared/form_link', :locals => {:f => f, :i => i,form_link: venue_management_link} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'venue_management_link_field_count', venue.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>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if !venue.nil? && !venue.venue_management_files.blank? %>
<div class="exist">
<% venue.venue_management_files.each_with_index do |venue_management_file, i| %>
<%= f.fields_for :venue_management_files, venue_management_file do |f| %>
<%= render :partial => 'admin/venue_shared/form_file', :locals => {:f => f, :i => i,form_file: venue_management_file} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'venue_management_file_field_count', venue.venue_management_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_venue_management_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'admin/venue_shared/form_link', f, :venue_management_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_venue_management_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'admin/venue_shared/form_file', f, :venue_management_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>

View File

@ -142,6 +142,7 @@ en:
logouting: Logging Out #登出中
success_message: 'Registration successful, thank you.'
vm_inviting:
type: Type
case_no: 'Case No.'
publish_times: Publish Times
start_date: Start Date
@ -170,6 +171,8 @@ en:
event_date: Event Date
details: Details
vm_contract:
renewal_permission: Renewal permission
renewal_deadline: Renewal deadline
case_no: 'Case No.'
vendor: Vendor
start_end: Contract Duration

View File

@ -142,6 +142,7 @@ zh_tw:
logouting: 登出中
success_message: '您的報名已成功,感謝您的參與。'
vm_inviting:
type: 招商形式
case_no: 案號
publish_times: 公告次數
start_date: 公告開始
@ -170,6 +171,8 @@ zh_tw:
event_date: 事件日期
details: 事件內容
vm_contract:
renewal_permission: 是否得續約
renewal_deadline: 續約申請期限
case_no: 案號
vendor: 廠商
start_end: 契約期間

View File

@ -6,6 +6,7 @@ module VenueManagement
base_url File.expand_path File.dirname(__FILE__)
authorizable
categorizable
taggable "VenueManagementInviting"
frontend_enabled
data_count 1..20
@ -32,29 +33,36 @@ module VenueManagement
:active_for_action=>{'admin/venue_managements'=>'categories'},
:active_for_category => 'VenueManagement',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'venue_management').id}",
:priority=>4,
:active_for_action=>{'admin/venue_managements'=>'tags'},
:active_for_tag => 'VenueManagement',
:available_for => 'managers'
context_link 'venue_management.set_venue_management_items',
:link_path=>"admin_venue_management_items_path" ,
:priority=>3,
:priority=>5,
:active_for_action=>{'admin/venue_managements'=>'venue_management_items'},
:available_for => 'managers'
context_link 'venue_management.set_venue_management_agreements',
:link_path=>"admin_venue_management_agreements_path" ,
:priority=>3,
:priority=>6,
:active_for_action=>{'admin/venue_managements'=>'venue_management_agreements'},
:available_for => 'managers'
context_link 'venue_management.set_venue_management_invitings',
:link_path => 'admin_venue_management_invitings_path',
:priority => 3,
:priority => 7,
:active_for_action => { 'admin/venue_managements' => 'venue_management_invitings' },
:available_for => 'managers'
context_link 'venue_management.set_venue_management_memorabilias',
:link_path => 'admin_venue_management_memorabilias_path',
:priority => 3,
:priority => 8,
:active_for_action => { 'admin/venue_managements' => 'venue_management_memorabilias' },
:available_for => 'managers'
context_link 'venue_management.set_venue_management_contracts',
:link_path => 'admin_venue_management_contracts_path',
:priority => 3,
:priority => 9,
:active_for_action => { 'admin/venue_managements' => 'venue_management_contracts' },
:available_for => 'managers'
end