Skip to content

Instantly share code, notes, and snippets.

@amalagaura
Created April 16, 2012 16:45
Show Gist options
  • Save amalagaura/2399888 to your computer and use it in GitHub Desktop.
Save amalagaura/2399888 to your computer and use it in GitHub Desktop.
complicated slim template
- content_for :sidebar do
= render_widget :contract_summary, :display, @contract, true
- content_for :extra_header_row do
- unless @hide_edit_link
.price-offset.breadcrumb
span = "Go to "
= link_to *@link_to
- content_for :content do
- Contract.filtered_categories.each do |category|
- config_set = @category_details[category.name][:config_set]
- selected_ids = @category_details[category.name][:ids]
- title_texts = @category_details[category.name][:title_texts]
- selected_quote_ids = @category_details[category.name][:selected_quote_ids]
- item_names = @category_details[category.name][:names]
- relevant_quote_ids = @category_details[category.name][:relevant_quotes].collect(&:id)
- quote_quantities = @category_details[category.name][:quote_quantities]
script type="text/javascript"
| #{category.name} =
== @category_details[category.name][:dependencies].to_json
| ; #{category.name}.quote_prices =
== @contract.quote_prices(category).to_json
.modal.hide.fade style="display: block;" id="#{category.name}-modal"
.modal-header
a.close href="#" x
h3 Custom Quote
= form_for [@buyer,@contract,CustomQuote.new], :html => {:id => "#{category.name}_quote_form"} do |f|
.modal-body
= f.hidden_field :category_id, :value => category.id
fieldset
legend Enter your request details
- unless category.has_quantity?
.clearfix
= f.label "#{category.name}_item", "Item To Customize"
= f.select :item_id, config_set.configuration_set_entries.collect{|c_s_e| [c_s_e.item.name,c_s_e.item.id]}, { :include_blank => 'Not related to other item' }, { :id => "#{category.name}_item", :class => "input", :required => (config_set.min > 0) }
.clearfix
= f.label "Custom Quote Request Name"
= f.text_field :name, :class => "input", :required => true, :placeholder => "Enter name"
.clearfix
= f.label "#{category.name}_description", "Description"
= f.text_area :description, :id => "#{category.name}_description", :class => "input", :required => true, :placeholder => "Enter Description", :rows => 5
.modal-footer
button.btn.primary Create Custom Quote
button.btn.close Close
.row id="#{category.name}-section" class="invisible"
.well.span8.short-padding
= form_for @contract, :remote=>true, :url => url_for_event(:submit,:source => :contract_summary), :html => { :id => "#{category.name}_form", :class => "form-stacked" } do |f|
= hidden_field_tag :buyer_id, @buyer.id
= hidden_field_tag :id, @contract.id
= hidden_field_tag :category_id, category.id
= hidden_field_tag :path, []
= hidden_field_tag :category_name, category.name
= hidden_field_tag :source_id, @contract.source_id_of_category(category)
fieldset
.clearfix
- if category.interior?
label Please use Addendum #1 for additional details and locations
label#optionsCheckboxes List of #{category.name.pluralize.titleize}
.input
ul.inputs-list
- for configuration_entry in config_set.configuration_set_entries.select{ |c_s_e| c_s_e.state == ConfigurationSetEntry::STANDARD }.sort_by(&@sort_block) do
- item = configuration_entry.item
li
label
= check_box_tag "#{category.name}_items[]", item.id, true, :disabled => true, :id => "item_#{item.id}"
span #{item.name.titleize}
== render :partial => "quote_line", :locals => {:contract => @contract, :category => category, :item => item, :selected_quote_ids => selected_quote_ids, :item_names => item_names }
- ConfigurationSet.grouped_entries(config_set.configuration_set_entries.select{ |c_s_e| c_s_e.state == ConfigurationSetEntry::OPTIONAL }.sort_by(&@sort_block)).each do |group_label,configuration_set_entries|
li.group-label
- if group_label.blank?
br
br
- else
= group_label
- configuration_set_entries.each do |configuration_entry|
- item = configuration_entry.item
- title_text = @category_details[category.name][:text][item.id]
- item_name = "item_#{item.id}"
li
label.item_label.preview.row href=item.picture_url desc="#{item.description.presence || '.'}" category=category.name
- price_offset = 'price-offset'
- if category.has_quantity?
- price_offset = 'offset1'
= number_field_tag "#{category.name}_quantities[#{item.id}]", 0, :min => 0, :class => "quantity-field", 'data-bind' => "value: #{item_name}_quantity, valueUpdate: 'aftermouseup'"
- else
= check_box_tag "#{category.name}_items[]", item.id, selected_ids.include?(item.id), :id => item_name, 'data-bind' => "checked: #{item_name}, enable: #{item_name}_enabled"
span.item_label title="#{title_text}" data-bind="css: {dependent : #{item_name}_dependent_hover,exclusive : #{item_name}_exclusive_hover,comember : #{item_name}_comember_hover}, event: { mouseover: hoverOn.bind($data,'#{item_name}'), mouseout:hoverOff.bind($data,'#{item_name}') }" data-placement='right'
span = item.name.titleize
br
.row
span class=price_offset = number_to_currency configuration_entry.price
- if category.has_quantity?
span.pull-right data-bind="text: #{item_name}_total"
== render :partial => "quote_line", :locals => {:contract => @contract, :category => category, :item => item, :selected_quote_ids => selected_quote_ids, :item_names => item_names }
== render :partial => "quote_line", :locals => {:contract => @contract, :category => category, :item => nil, :category_quotes => @category_details[category.name][:relevant_quotes].select { |cq| cq.item_id.blank? },:selected_quote_ids => selected_quote_ids, :quote_quantities => quote_quantities }
.well.span6 id="custom_quotes_#{category.name}"
p Custom Quotes
table.condensed-table.bordered-table
tr
th Name
th State
th Price
- for custom_quote in @contract.custom_quotes.select{ |c_q| c_q.category_id == category.id } do
tr
td = custom_quote.name
td = custom_quote.state
td = number_to_currency(custom_quote.price) if custom_quote.approved?
button.btn data-controls-modal="#{category.name}-modal" data-backdrop=true data-keyboard=true Request quote
script type="text/javascript"
== render :partial => 'create_knockout_mappings', :formats => [:js] , :locals => {:config_set => config_set, :selected_ids => selected_ids, :custom_quote_quantities => quote_quantities,:quantities => @category_details[category.name][:quantities], :selected_quote_ids => selected_quote_ids,:relevant_quote_ids => relevant_quote_ids}
javascript:
var categoryName = '#{category.name}';
$('[name^="' + categoryName + '_"]:input').change({categoryName : categoryName },checkboxClick);
$('#'+categoryName+'_form').on('submit',function() { $("#saving_notification").show() });
categoryList.push(categoryName);
javascript:
window.contractId = #{@contract.id};
$(function() {
try { controller(localStorage["contract_"+window.contractId+"_category"]); } catch(err) { }
});
.row id="default-section"
.well.span8
.row
h4.offset3 Lot Address
p
= simple_form_for [@buyer,@contract], :html => { :id => "lot_detail_form" } do |f|
= hidden_field_tag :origin, :edit
= f.input :address1
= f.input :address2
= f.input :city
= f.input :state
= f.input :zip
.row
.offset3
= f.button :submit, :class => "btn primary span3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment