Saturday progress

This commit is contained in:
2013-01-19 17:14:33 +01:00
parent db1a6ac96b
commit 702bd41ee4
36 changed files with 128 additions and 57 deletions
@@ -12,6 +12,7 @@ var $translations = {
<%= I18n.t('supplier', locale: :nl).to_json[1..-2] %>
}
}
$transformation_mappings = {
downcase: 'toLowerCase',
upcase: 'toUpperCase'
@@ -18,6 +18,13 @@ body
padding-bottom: 0
.main-content
padding-top: 16px
label
&.number
display: inline
padding: 4px 10px
input
&.number
width: 40px
.supplier-is-closed
.alert
form
@@ -3,7 +3,7 @@ module Suppliers
# GET /tables
# GET /tables.json
def index
@tables = current_supplier.tables
@tables = Table.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25, from_number: params[:from_number], to_number: params[:to_number])
respond_to do |format|
format.html # index.html.erb
+19 -5
View File
@@ -31,7 +31,6 @@ class Supplier
has_many :sections, dependent: :destroy
after_create :add_section_on_create
after_create :send_creation_notifications
view :by_email, key: :email
@@ -39,7 +38,7 @@ class Supplier
validates :iens_profile, numericality: {allow_blank: true}
def location=(val)
lat, lng = val.strip.split(/[ ,]+/).map(&:to_f)
lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f)
self.lat = lat
self.lng = lng
end
@@ -88,14 +87,29 @@ class Supplier
self.open = false
save
end
# Find a user by its confirmation token and try to confirm it.
# If no user is found, returns a new user with an error.
# If the user is already confirmed, create an error for the user
# Options must have the confirmation_token
#
# Overwrite devise method for mail sending
def self.confirm_by_token(confirmation_token)
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
confirmable.confirm! if confirmable.persisted?
confirmable.send_creation_notifications if confirmable.errors.empty?
confirmable
end
def send_creation_notifications
SupplierMailer.creation(self).deliver
end
private
def add_section_on_create
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
end
def send_creation_notifications
SupplierMailer.creation(self).deliver
end
end
+11 -2
View File
@@ -1,5 +1,6 @@
class Table
include SimplyStored::Couch
per_page_method :limit_value #kaminari
property :number, type: Fixnum, default: 1
property :position_x, type: Float
@@ -21,8 +22,16 @@ class Table
view :by_number, key: :number
def self.for_supplier(supplier, options = {})
startkey = options[:from_number].present? ? [supplier.id, options.delete(:from_number).to_i] : [supplier.id]
endkey = options[:to_number].present? ? [supplier.id, options.delete(:to_number).to_i]: [supplier.id, {}]
startkey = if from_number = options.delete(:from_number).presence
[supplier.id, from_number.to_i]
else
[supplier.id]
end
endkey = if to_number = options.delete(:to_number).presence
[supplier.id, to_number.to_i]
else
[supplier.id, {}]
end
total_entries = database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: false, reduce: true}))
options[:total_entries] = total_entries
+1 -1
View File
@@ -11,7 +11,7 @@ div.page-header= title :index, model_class
th= Table.model_name.human
th= Supplier.model_name.human
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @lists.each do |list|
tr
+1 -1
View File
@@ -7,7 +7,7 @@ div.page-header= title :index, model_class
th= model_class.human_attribute_name(:state)
th= Supplier.model_name.human
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @orders.each do |order|
tr
@@ -8,7 +8,7 @@
th= model_class.human_attribute_name(:position)
th= Supplier.model_name.human
th.timestamp= model_class.human_attribute_name(:created_at)
th.actions=t 'helpers.actions'
th.actions=t 'helpers.actions.title'
tbody
- @product_categories.each do |product_category|
tr
+1 -1
View File
@@ -9,7 +9,7 @@
th= model_class.human_attribute_name(:price)
th= Supplier.model_name.human
th.timestamp= model_class.human_attribute_name(:created_at)
th.actions=t 'helpers.actions'
th.actions=t 'helpers.actions.title'
tbody
- @products.each do |product|
tr
+1 -1
View File
@@ -7,7 +7,7 @@
th= model_class.human_attribute_name(:title)
th= Supplier.model_name.human
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @sections.each do |section|
tr
+1 -1
View File
@@ -7,7 +7,7 @@
th= model_class.human_attribute_name(:email)
th= model_class.human_attribute_name(:name)
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @suppliers.each do |supplier|
tr
+1 -1
View File
@@ -7,7 +7,7 @@ div.page-header= title :index, model_class
th= model_class.human_attribute_name(:number)
th= Supplier.model_name.human
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @tables.each do |table|
tr
+1 -1
View File
@@ -6,7 +6,7 @@
tr
th= model_class.human_attribute_name(:email)
th= model_class.human_attribute_name(:created_at)
th=t 'helpers.actions'
th=t 'helpers.actions.title'
tbody
- @users.each do |user|
tr
+1 -1
View File
@@ -14,7 +14,7 @@ form action='' method="get"
th= Table.model_name.human
th.currency= model_class.human_attribute_name(:price)
th.timestamp= model_class.human_attribute_name(:created_at)
th.actions=t 'helpers.actions'
th.actions=t 'helpers.actions.title'
tbody
- @lists.each do |list|
tr
+7 -7
View File
@@ -5,12 +5,12 @@
table.table
thead
tr
th= model_class.human_attribute_name(:name)
th= model_class.human_attribute_name(:code)
th.currency= model_class.human_attribute_name(:price)
th= ProductCategory.model_name.human_plural
th.timestamp= model_class.human_attribute_name(:created_at)
th.actions=t 'helpers.actions'
th data-t="attributes.product.name" = model_class.human_attribute_name(:name)
th data-t="attributes.product.code" = model_class.human_attribute_name(:code)
th.currency data-t="attributes.product.price" = model_class.human_attribute_name(:price)
th data-t="models.product_category" = ProductCategory.model_name.human_plural
th.timestamp data-t="attributes.product.created_at" = model_class.human_attribute_name(:created_at)
th.actions data-t="helpers.actions.title" =t 'helpers.actions.title'
tbody
- @products.each do |product|
tr
@@ -26,4 +26,4 @@
- else
= no_content_given model_class
= link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary'
/a.btn.btn-primary data-t="helpers.links.new" href=new_suppliers_product_path
@@ -1,4 +1,8 @@
h2= t('devise.registrations.title')
p
|
Leuk dat je je wilt aanmelden voor Qwaiter. Na de aanmelding zal er een bevestigings e-mail worden gestuurd
om het e-mailadres te bevestigen. Hierna kan je aan de slag met mobiel bestellen!
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
+1 -1
View File
@@ -10,7 +10,7 @@
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.timestamp data-t='attributes.section.created_at' = model_class.human_attribute_name(:created_at)
th.actions data-t='helpers.actions' = t 'helpers.actions'
th.actions data-t='helpers.actions.title' = t 'helpers.actions.title'
tbody
- @sections.each do |section|
tr
+9 -1
View File
@@ -1,14 +1,22 @@
- model_class = Table
div.page-header= title :index, model_class
= form_tag({}, method: :get) do
label.number for="filter-from_number" data-t="attributes.table.from_number"
input#filter-from_number.number type="number" size=4 value=params[:from_number] name="from_number"
label.number for="filter-to_number" data-t="attributes.table.to_number"
input#filter-to_number.number type="number" size=4 value=params[:to_number] name="to_number"
'
= submit_tag 'Filter'
.well
- if @tables.any?
= paginate @tables
table.table
thead
tr
th.link data-t="attributes.table.number"= model_class.human_attribute_name(:number)
th.link data-t="models.section"= Section.model_name.human
th.timestamp data-t="attributes.table.created_at"= model_class.human_attribute_name(:created_at)
th.actions data-t="helpers.actions"=t 'helpers.actions'
th.actions data-t="helpers.actions.title"=t 'helpers.actions.title'
tbody
- @tables.each do |table|
tr
-19
View File
@@ -1,19 +0,0 @@
ul.nav.nav-pills
- if controller_name != 'sessions'
li= link_to t('devise.sessions.button'), new_session_path(resource_name), class: [:devise, :btn]
- if devise_mapping.registerable? && controller_name != 'registrations'
li= link_to t('devise.registrations.button'), new_registration_path(resource_name), class: [:devise, :btn]
- if devise_mapping.recoverable? && controller_name != 'passwords'
li= link_to t('devise.sessions.forgot_your_password'), new_password_path(resource_name), class: [:devise, :btn]
- if devise_mapping.confirmable? && controller_name != 'confirmations'
li= link_to t('devise.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: [:devise, :btn]
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
li= link_to t('devise.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: [:devise, :btn]
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
li= link_to t('devise.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: [:devise, :btn]