Add some view structure
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
@import ./foundation_and_overrides
|
||||
|
||||
.display-row
|
||||
@extend .row
|
||||
.display-label
|
||||
font-weight: bold
|
||||
@media #{$small-only}
|
||||
+grid-column($columns:10, $center:true)
|
||||
@media #{$medium-only}
|
||||
+grid-column($columns:4, $offset:1)
|
||||
@media #{$large-up}
|
||||
+grid-column(3)
|
||||
.display-field
|
||||
@media #{$small-only}
|
||||
+grid-column($columns:10, $center:true, $last-column:true)
|
||||
@media #{$medium-only}
|
||||
+grid-column($columns:4, $last-column:true)
|
||||
@media #{$large-up}
|
||||
+grid-column($columns: 3, $last-column:true)
|
||||
@@ -1,6 +1,9 @@
|
||||
@import font-awesome
|
||||
@import ./foundation_and_overrides
|
||||
.form-actions
|
||||
.form-action-submit
|
||||
+button($bg: $button-submit-color, $padding: $button-sml)
|
||||
margin-right: $button-margin
|
||||
a
|
||||
&.form-action-index
|
||||
+button($bg: $button-index-color, $padding: $button-sml)
|
||||
@@ -13,6 +16,8 @@
|
||||
margin-right: $button-margin
|
||||
&.form-action-destroy
|
||||
+button($bg: $button-destroy-color, $padding: $button-sml)
|
||||
&.form-action-cancel
|
||||
+button($bg: $button-cancel-color, $padding: $button-sml)
|
||||
&.form-action-qr-codes
|
||||
+button($bg: $button-qr-code-color, $padding: $button-sml)
|
||||
span
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
@import ./foundation_and_overrides
|
||||
|
||||
.form-row
|
||||
@extend .row
|
||||
.form-label
|
||||
@media #{$small-only}
|
||||
+grid-column($columns:10, $center:true)
|
||||
@media #{$medium-only}
|
||||
+grid-column($columns:4, $offset:1)
|
||||
@media #{$large-up}
|
||||
+grid-column(3)
|
||||
.form-field
|
||||
@media #{$small-only}
|
||||
+grid-column($columns:10, $center:true, $last-column:true)
|
||||
@media #{$medium-only}
|
||||
+grid-column($columns:4, $last-column:true)
|
||||
@media #{$large-up}
|
||||
+grid-column($columns: 3, $last-column:true)
|
||||
&.full
|
||||
@media #{$large-up}
|
||||
+grid-column($columns: 9, $last-column:true)
|
||||
@@ -1255,4 +1255,6 @@ $button-index-color: $secondary-color
|
||||
$button-new-color: #afa
|
||||
$button-edit-color: #ffa
|
||||
$button-destroy-color: #faa
|
||||
$button-submit-color: $primary-color
|
||||
$button-cancel-color: $secondary-color
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ table
|
||||
+table-fit
|
||||
th.status-icons, td.status-icons
|
||||
+table-fit
|
||||
.table-edit
|
||||
+button($bg: $secondary-color)
|
||||
+button-icon-only
|
||||
span
|
||||
@extend .fa
|
||||
@extend .fa-pencil
|
||||
.table-destroy
|
||||
+button($bg: $secondary-color)
|
||||
+button-icon-only
|
||||
color: $warning-color
|
||||
.table-edit
|
||||
+button($bg: $secondary-color)
|
||||
+button-icon-only
|
||||
span
|
||||
@extend .fa
|
||||
@extend .fa-pencil
|
||||
.table-destroy
|
||||
+button($bg: $secondary-color)
|
||||
+button-icon-only
|
||||
color: $warning-color
|
||||
|
||||
margin-left: 8px
|
||||
span
|
||||
@extend .fa
|
||||
@extend .fa-times
|
||||
margin-left: 8px
|
||||
span
|
||||
@extend .fa
|
||||
@extend .fa-times
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :set_locale
|
||||
if Rails.env.development?
|
||||
before_action :force_reloads
|
||||
end
|
||||
layout :layout_by_resource
|
||||
#protect_from_forgery
|
||||
|
||||
@@ -66,4 +69,8 @@ private
|
||||
format.json { render json: {ok: false}, status: 404 }
|
||||
end
|
||||
end
|
||||
|
||||
def force_reloads
|
||||
load Rails.root.join('config/initializers/custom_form_builder.rb')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
module SuppliersHelper
|
||||
def supplier_form_actions(*actions, &block)
|
||||
options = actions.extract_options!
|
||||
object = options[:object]
|
||||
target = options[:for]
|
||||
elements = []
|
||||
actions.each do |action|
|
||||
if action == :index
|
||||
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.index'}), [:suppliers, target], class: 'form-action-index')
|
||||
elsif action == :new
|
||||
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.new'}), [:new, :suppliers, target.to_s.singularize], class: 'form-action-new')
|
||||
elsif action == :edit
|
||||
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.edit'}), [:edit, :suppliers, object], class: 'form-action-edit')
|
||||
elsif action == :destroy
|
||||
elements << link_to(
|
||||
content_tag(:span, nil, data: {t: 'helpers.links.destroy'}),
|
||||
[:suppliers, object],
|
||||
class: 'form-action-destroy', method: :delete, data: {confirm: are_you_sure? }
|
||||
)
|
||||
end
|
||||
end
|
||||
elements << capture(&block) if block.present?
|
||||
content_tag(:div, elements.inject(&:+), class: 'form-actions').html_safe
|
||||
end
|
||||
end
|
||||
@@ -1,35 +1,37 @@
|
||||
= simple_form_for [:suppliers, @product_category], html: {class: 'form-horizontal'} do |f|
|
||||
= form_for [:suppliers, @product_category] do |f|
|
||||
= render 'error_messages', target: @product_category
|
||||
= f.input :name
|
||||
.control-group
|
||||
.form-row
|
||||
.form-label
|
||||
= f.label :name
|
||||
.form-field
|
||||
= f.text_field :name
|
||||
.form-row
|
||||
= hidden_field_tag 'product_category[product_ids][]', ''
|
||||
= label_tag nil, Product.model_name.human_plural, class: 'control-label'
|
||||
.controls
|
||||
.form-label
|
||||
= label_tag nil, Product.model_name.human_plural, class: 'control-label'
|
||||
.form-field
|
||||
- for product in current_supplier.products
|
||||
= check_box_tag "product_category[product_ids][]", product.id, @product_category.product_ids.to_a.include?(product.id), id: "product-checker-#{product.id}"
|
||||
= label_tag "product-checker-#{product.id}", product.display
|
||||
br
|
||||
.control-group
|
||||
= label_tag nil, ProductCategory.human_attribute_name(:week_days), class: 'control-label'
|
||||
.controls
|
||||
.form-row
|
||||
.form-label
|
||||
= label_tag nil, ProductCategory.human_attribute_name(:week_days), class: 'control-label'
|
||||
.form-field.full
|
||||
#week_days-group.btn-group data-toggle="buttons-checkbox"
|
||||
- day_names = week_days.dup; day_names << day_names.shift if current_supplier.week_starts_on_monday?
|
||||
- day_names.each do |day_name|
|
||||
button.week-day-toggle.btn type="button" data-day=day_name data-t="product_category.week_days.abbreviation.#{day_name}"
|
||||
button.week-day-toggle.tiny type="button" data-day=day_name data-t="product_category.week_days.abbreviation.#{day_name}"
|
||||
|
||||
|
||||
span#full_day-controller
|
||||
#sub-day-container.hide
|
||||
= f.input_field :start_from, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
|
||||
= f.input_field :end_on, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
|
||||
/= f.input_field :start_from, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
|
||||
/= f.input_field :end_on, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
|
||||
.hidden
|
||||
- @product_category.week_days.each.with_index do |day, i|
|
||||
= select_tag 'product_category[week_days][]', options_for_select([0,1], day), class: 'week-day-select', id: "week-day-select-#{week_days[i]}", data: {day: week_days[i] }
|
||||
/= f.input :full_day, as: :select, collection: [true, false], label: false, include_blank: false
|
||||
= f.input_field :full_day, as: :boolean, label: false, wrapper: false
|
||||
/= f.input_field :full_day, as: :boolean, label: false, wrapper: false
|
||||
/= f.check_box :full_day
|
||||
|
||||
.form-actions
|
||||
= f.button :submit, class: 'btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_product_categories_path, class: 'btn'
|
||||
= f.supplier_form_actions
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
span.name= link_to product_category.name, [:suppliers, product_category]
|
||||
span= product_category.visible_on
|
||||
.pull-right.actions
|
||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, product_category], class: 'btn btn-mini edit-resource-button'
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||
= link_to [:edit, :suppliers, product_category], class: 'table-edit' do
|
||||
span data-title="helpers.links.edit"
|
||||
= link_to [:suppliers, product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'table-destroy' do
|
||||
span data-title="helpers.links.destroy"
|
||||
- else
|
||||
= no_content_given model_class
|
||||
.form-actions
|
||||
= link_to t("helpers.links.new"), new_suppliers_product_category_path, class: 'btn btn-primary'
|
||||
= supplier_form_actions :new, for: :product_categories
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
- model_class = ProductCategory
|
||||
.page-header= title :show, @product_category
|
||||
|
||||
dl.dl-horizontal.show-list
|
||||
dt data-t='attributes.product_category.name'= model_class.human_attribute_name(:name)
|
||||
dd= @product_category.name
|
||||
/dt data-t='attributes.product_category.position'= model_class.human_attribute_name(:position)
|
||||
/dd= @product_category.position
|
||||
dt data-t='attributes.product_category.visible_on'= model_class.human_attribute_name(:visible_on)
|
||||
dd= @product_category.visible_on
|
||||
dt data-t='models.plural.product'= Product.model_name.human_plural
|
||||
dd= @product_category.products.map{|product| link_to product.display, suppliers_product_path(product) }.join(', ').html_safe
|
||||
|
||||
|
||||
.form-actions
|
||||
= link_to t("helpers.links.back"), suppliers_product_categories_path, class: 'btn', data: {t: 'helpers.links.back'}
|
||||
'
|
||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, @product_category], class: 'btn', data: {t: 'helpers.links.edit'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, @product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger', data: {t: 'helpers.links.destroy'}
|
||||
.display-row
|
||||
.display-label
|
||||
span data-t='attributes.product_category.name'
|
||||
.display-field
|
||||
span= @product_category.name
|
||||
.display-row
|
||||
.display-label
|
||||
span data-t='attributes.product_category.visible_on'
|
||||
.display-field
|
||||
span= @product_category.visible_on
|
||||
.display-row
|
||||
.display-label
|
||||
span data-t='models.plural.product'
|
||||
.display-field
|
||||
span= @product_category.products.map{|product| link_to product.display, suppliers_product_path(product) }.join(', ').html_safe
|
||||
= supplier_form_actions :index, :edit, :destroy, object: @product_category, for: :product_categories
|
||||
|
||||
@@ -1,18 +1,31 @@
|
||||
= simple_form_for [:suppliers, @product], html: {class: 'form-horizontal'} do |f|
|
||||
= form_for [:suppliers, @product] do |f|
|
||||
= render 'error_messages', target: @product
|
||||
= f.input :name
|
||||
= f.input :code
|
||||
= f.input :price
|
||||
.control-group
|
||||
.form-row
|
||||
.form-label
|
||||
= f.label :name, data: {t: 'attributes.product.name'}
|
||||
.form-field
|
||||
= f.text_field :name
|
||||
.form-row
|
||||
.form-label
|
||||
= f.label :code, data: {t: 'attributes.product.code'}
|
||||
.form-field
|
||||
= f.text_field :code
|
||||
.form-row
|
||||
.form-label
|
||||
= f.label :price, data: {t: 'attributes.product.price'}
|
||||
.form-field
|
||||
= f.text_field :price
|
||||
/= f.input :name
|
||||
/= f.input :code
|
||||
/= f.input :price
|
||||
.form-row
|
||||
= hidden_field_tag 'product[product_category_ids][]', []
|
||||
= label_tag nil, ProductCategory.model_name.human_plural, class: 'control-label'
|
||||
.controls
|
||||
.form-label
|
||||
= label_tag nil, ProductCategory.model_name.human_plural, class: 'control-label'
|
||||
.form-field
|
||||
- for product_category in current_supplier.product_categories
|
||||
= check_box_tag "product[product_category_ids][]", product_category.id, @product.product_categories.to_a.include?(product_category), id: "product-category-checker-#{product_category.id}"
|
||||
= label_tag "product-category-checker-#{product_category.id}", product_category.name
|
||||
br
|
||||
|
||||
.form-actions
|
||||
= f.button :submit, class: 'btn-primary save-product-button'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_products_path, class: 'btn'
|
||||
= f.supplier_form_actions
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
= form_for [:suppliers, @section], html: {class: 'form-horizontal' } do |f|
|
||||
= render 'error_messages', target: @section
|
||||
.control-group class=(@section.errors[:title].any? ? 'error' : nil)
|
||||
@@ -12,10 +13,4 @@
|
||||
= f.label :height, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :height, class: ['text_field', :numeric]
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
- unless f.object.new_record?
|
||||
'
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_sections_path, class: 'btn'
|
||||
= f.supplier_form_actions
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
- model_class = Section
|
||||
.page-header
|
||||
= title :edit, model_class
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
- model_class = Section
|
||||
.page-header= title :index, model_class
|
||||
.well
|
||||
- if @sections.any?
|
||||
table.table
|
||||
thead
|
||||
- if @sections.any?
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th.link data-t='attributes.section.title' = model_class.human_attribute_name(:title)
|
||||
th.table-info data-t='models.plural.table' = Table.model_name.human_plural
|
||||
th.numeric data-t='attributes.section.width' = model_class.human_attribute_name(:width)
|
||||
th.numeric data-t='attributes.section.height' = model_class.human_attribute_name(:height)
|
||||
th.actions data-t='helpers.actions.title' = t 'helpers.actions.title'
|
||||
tbody
|
||||
- @sections.each do |section|
|
||||
tr
|
||||
th.link data-t='attributes.section.title' = model_class.human_attribute_name(:title)
|
||||
th.table-info data-t='models.plural.table' = Table.model_name.human_plural
|
||||
th.numeric data-t='attributes.section.width' = model_class.human_attribute_name(:width)
|
||||
th.numeric data-t='attributes.section.height' = model_class.human_attribute_name(:height)
|
||||
th.actions data-t='helpers.actions.title' = t 'helpers.actions.title'
|
||||
tbody
|
||||
- @sections.each do |section|
|
||||
tr
|
||||
td.link= link_to section.title, [:suppliers, section]
|
||||
td.table-info
|
||||
span.table-count= section.tables.size
|
||||
span.active-table-count= (@active_table_ids & section.tables.map(&:id)).size
|
||||
td.numeric= section.width
|
||||
td.numeric= section.height
|
||||
td.actions
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: section.id), class: 'btn btn-mini btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy'}, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
.form-actions
|
||||
= link_to new_suppliers_section_path, class: 'form-action-new'
|
||||
span data-t="helpers.links.new"
|
||||
td.link= link_to section.title, [:suppliers, section]
|
||||
td.table-info
|
||||
span.table-count= section.tables.size
|
||||
span.active-table-count= (@active_table_ids & section.tables.map(&:id)).size
|
||||
td.numeric= section.width
|
||||
td.numeric= section.height
|
||||
td.actions
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: section.id), class: 'btn btn-mini btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy'}, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
= supplier_form_actions :new, for: :sections
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
- model_class = Section
|
||||
.page-header
|
||||
h1 data-t='section.manage_tables.title' data-t-attributes=%|{"title":"#{@section.title}"}|
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
- model_class = Section
|
||||
.page-header
|
||||
= title :new, model_class
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
- model_class = Section
|
||||
- content_for :head do
|
||||
= javascript_include_tag 'supplier/app/application'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-# DEPRICATED
|
||||
ul#table-actions-list
|
||||
- if @list
|
||||
- if @list.needs_help?
|
||||
|
||||
@@ -8,7 +8,4 @@
|
||||
= f.label :section_id, Section.model_name.human, class: 'control-label', data: {t: 'models.section'}
|
||||
.controls
|
||||
= f.collection_select :section_id, current_supplier.sections, :id, :title, include_blank: "[#{t('supplier.tables.has_no_section')}]"
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary save-table-button'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_tables_path, class: 'btn'
|
||||
= f.supplier_form_actions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- model_class = Table
|
||||
.page-header
|
||||
= title :edit, model_class
|
||||
= render 'form'
|
||||
= render 'form'
|
||||
|
||||
@@ -30,8 +30,6 @@ div.page-header= title :index, model_class
|
||||
- else
|
||||
= no_content_given model_class
|
||||
|
||||
.form-actions
|
||||
= link_to new_suppliers_table_path, class: 'form-action-new'
|
||||
span data-t="helpers.links.new"
|
||||
= supplier_form_actions :new, for: :tables do
|
||||
= link_to qr_codes_suppliers_tables_path(params.slice(:from_number, :to_number)), class: 'form-action-qr-codes', target: :_blank
|
||||
span data-t="tables.qr_codes.link"
|
||||
|
||||
@@ -7,11 +7,4 @@ dl.dl-horizontal.show-list
|
||||
- if @table.section.present?
|
||||
dt= Section.model_name.human
|
||||
dd= link_to @table.section.title, [:suppliers, @table.section]
|
||||
//= supplier_form_actions :index, :edit, :destroy, object: @table, for: :tables
|
||||
.form-actions
|
||||
= link_to [:suppliers, :tables], class: 'form-action-index'
|
||||
span data-t="helpers.links.index"
|
||||
= link_to [:edit, :suppliers, @table], class: 'form-action-edit'
|
||||
span data-t="helpers.links.edit"
|
||||
= link_to [:suppliers, @table], method: :delete, data: {confirm: are_you_sure? }, class: 'form-action-destroy'
|
||||
span data-t="helpers.links.destroy"
|
||||
= supplier_form_actions :index, :edit, :destroy, object: @table, for: :tables
|
||||
|
||||
Reference in New Issue
Block a user