Fixed foodcoop/ordergroups and workgroups views.
This commit is contained in:
parent
ab81ef09d5
commit
c0c41a7752
7 changed files with 63 additions and 75 deletions
|
@ -2,11 +2,16 @@ class Foodcoop::OrdergroupsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@ordergroups = Ordergroup.order('name DESC')
|
@ordergroups = Ordergroup.order('name DESC')
|
||||||
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].blank? # Search by name
|
|
||||||
@ordergroups = @ordergroups.joins(:orders).where(:orders => {:starts.gte => Time.now.months_ago(3)}) if params[:only_active] # Select only active groups
|
|
||||||
|
|
||||||
@total = @ordergroups.size
|
unless params[:name].blank? # Search by name
|
||||||
@ordergroups = @ordergroups.paginate(:page => params[:page], :per_page => @per_page)
|
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%")
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:only_active] # Select only active groups
|
||||||
|
@ordergroups = @ordergroups.joins(:orders).where("orders.starts >= ?", Time.now.months_ago(3)).uniq
|
||||||
|
end
|
||||||
|
|
||||||
|
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
%p
|
- if Ordergroup.count > 20
|
||||||
%table{:style => "width:100%"}
|
= items_per_page
|
||||||
%tr
|
= pagination_links_remote @ordergroups
|
||||||
%td
|
|
||||||
= pagination_links_remote @ordergroups, :update => :ordergroups
|
|
||||||
%td{:style => "text-align:right"}
|
|
||||||
- if @total > 20
|
|
||||||
= items_per_page :update => :ordergroups
|
|
||||||
|
|
||||||
%table.list
|
%table.table.table-striped
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Name
|
%th Name
|
||||||
|
@ -16,10 +11,9 @@
|
||||||
|
|
||||||
%tbody
|
%tbody
|
||||||
- for ordergroup in @ordergroups
|
- for ordergroup in @ordergroups
|
||||||
%tr{:class => cycle('even','odd', :name => 'ordergroup')}
|
%tr
|
||||||
%td= link_to h(ordergroup.name), new_message_path(:message => {:group_id => ordergroup.id}), :title => "Bestellgruppe eine Nachricht schicken"
|
%td= ordergroup.name
|
||||||
%td=h ordergroup.users.collect { |u| u.nick }.join(", ")
|
%td=h ordergroup.users.collect { |u| u.nick }.join(", ")
|
||||||
%td
|
%td= format_date ordergroup.orders.order('orders.starts DESC').first.try(:starts)
|
||||||
- order = ordergroup.orders.first(:order => 'starts DESC')
|
%td= link_to_new_message(message_params: {group_id: ordergroup.id})
|
||||||
= order ? format_date(order.starts) : "-"
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
%h1 Bestellgruppen der Foodcoop
|
- title "Bestellgruppen"
|
||||||
|
|
||||||
.left_column{:style => "width:100%"}
|
.well
|
||||||
.box_title
|
= form_tag foodcoop_ordergroups_path, :method => :get, :remote => true, 'data-submit-onchange' => true,
|
||||||
%h2 Übersicht
|
class: 'form-search' do
|
||||||
.column_content
|
= text_field_tag :name, params[:name], class: 'input-medium search-query', placeholder: 'Name ...'
|
||||||
#filter{:style => "margin-right:2em;"}
|
%label{:for => 'only_active'}
|
||||||
= form_tag foodcoop_ordergroups_path, :method => :get, :style=>"display:inline;", :id => 'ordergroup_search',
|
= check_box_tag 'only_active', 1, params[:only_active]
|
||||||
:remote => true, 'data-submit-onchange' => true do
|
Nur aktive
|
||||||
%label{:for => 'article_name'} Suche nach Name:
|
%small (mindestens einmal in den letzten 3 Monaten bestellt)
|
||||||
= text_field_tag :query, params[:query], :size => 10
|
|
||||||
%label{:for => 'only_active'} Nur aktive:
|
#ordergroups
|
||||||
= check_box_tag 'only_active', 1, params[:only_active]
|
= render :partial => "ordergroups"
|
||||||
%small (mindestens einmal in den letzten 3 Monaten bestellt)
|
|
||||||
|
|
||||||
#ordergroups
|
|
||||||
= render :partial => "ordergroups"
|
|
|
@ -1,7 +1,6 @@
|
||||||
- unless params[:sort_by_ordergroups]
|
- if User.count > 20
|
||||||
- if User.count > 20
|
= items_per_page
|
||||||
= items_per_page
|
= pagination_links_remote @users
|
||||||
= pagination_links_remote @users
|
|
||||||
%table.table.table-striped
|
%table.table.table-striped
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
.single_column{:style => "width:55em"}
|
%section.well
|
||||||
.box_title
|
%h3= workgroup.name
|
||||||
%h2= workgroup.name
|
= render :partial => 'shared/group', :locals => { :group => workgroup }
|
||||||
.column_content
|
= link_to "Alle Aufgaben zeigen", workgroup_tasks_path(workgroup_id: workgroup), class: 'btn'
|
||||||
= render :partial => 'shared/group', :locals => { :group => workgroup }
|
= link_to_new_message message_params: {group_id: workgroup.id}
|
||||||
%p
|
- if workgroup.member?(current_user)
|
||||||
= link_to "Alle Aufgaben zeigen", workgroup_tasks_path(workgroup_id: workgroup)
|
= link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup), class: 'btn'
|
||||||
|
|
|
||||||
= link_to "Mitgliedern eine Nachricht schicken", new_message_path(:message => {:group_id => workgroup.id})
|
|
||||||
- if workgroup.member?(@current_user)
|
|
||||||
|
|
|
||||||
= link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup)
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
%h1 Arbeitsgruppen
|
- title "Arbeitsgruppen"
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%i
|
Das bearbeiten von Gruppen ist nur für Mitglieder der Gruppe möglich.
|
||||||
Das bearbeiten von Gruppen ist nur für Mitglieder der Gruppe möglich.
|
%br/
|
||||||
%br/
|
Wenn du einer Gruppe beitreten willst, dann schreib doch den Mitgliedern eine Nachricht.
|
||||||
Wenn du einer Gruppe beitreten willst, dann schreib doch den Mitgliedern eine Nachricht.
|
|
||||||
|
|
||||||
= render :partial => "workgroup", :collection => @workgroups
|
= render :partial => "workgroup", :collection => @workgroups
|
||||||
|
|
||||||
|
|
|
@ -6,35 +6,35 @@ SimpleNavigation::Configuration.run do |navigation|
|
||||||
primary.dom_class = 'nav'
|
primary.dom_class = 'nav'
|
||||||
|
|
||||||
primary.item :foodcoop, 'Foodcoop', '#' do |subnav|
|
primary.item :foodcoop, 'Foodcoop', '#' do |subnav|
|
||||||
subnav.item :members, 'Mitglieder', foodcoop_users_path
|
subnav.item :members, 'Mitglieder', foodcoop_users_path, id: nil
|
||||||
subnav.item :workgroups, 'Arbeitsgruppen', foodcoop_workgroups_path
|
subnav.item :workgroups, 'Arbeitsgruppen', foodcoop_workgroups_path, id: nil
|
||||||
subnav.item :ordergroups, 'Bestellgruppen', foodcoop_ordergroups_path
|
subnav.item :ordergroups, 'Bestellgruppen', foodcoop_ordergroups_path, id: nil
|
||||||
subnav.item :messages, 'Nachrichten', messages_path
|
subnav.item :messages, 'Nachrichten', messages_path, id: nil
|
||||||
subnav.item :tasks, 'Aufgaben', tasks_path
|
subnav.item :tasks, 'Aufgaben', tasks_path, id: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :wiki, 'Wiki', '#' do |subnav|
|
primary.item :wiki, 'Wiki', '#' do |subnav|
|
||||||
subnav.item :wiki_home, 'Startseite', wiki_path
|
subnav.item :wiki_home, 'Startseite', wiki_path, id: nil
|
||||||
subnav.item :all_pages, 'Alle Seiten', all_pages_path
|
subnav.item :all_pages, 'Alle Seiten', all_pages_path, id: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :orders, 'Bestellungen', '#' do |subnav|
|
primary.item :orders, 'Bestellungen', '#' do |subnav|
|
||||||
subnav.item :ordering, 'Bestellen!', group_orders_path
|
subnav.item :ordering, 'Bestellen!', group_orders_path, id: nil
|
||||||
subnav.item :ordering_archive, 'Meine Bestellungen', archive_group_orders_path
|
subnav.item :ordering_archive, 'Meine Bestellungen', archive_group_orders_path, id: nil
|
||||||
subnav.item :orders, 'Bestellverwaltung', orders_path, if: Proc.new { current_user.role_orders? }
|
subnav.item :orders, 'Bestellverwaltung', orders_path, if: Proc.new { current_user.role_orders? }, id: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :articles, 'Artikel', '#',
|
primary.item :articles, 'Artikel', '#',
|
||||||
if: Proc.new { current_user.role_article_meta? or current_user.role_suppliers? } do |subnav|
|
if: Proc.new { current_user.role_article_meta? or current_user.role_suppliers? } do |subnav|
|
||||||
subnav.item :suppliers, 'Lieferanten/Artikel', suppliers_path
|
subnav.item :suppliers, 'Lieferanten/Artikel', suppliers_path, id: nil
|
||||||
subnav.item :stockit, 'Lager', stock_articles_path
|
subnav.item :stockit, 'Lager', stock_articles_path, id: nil
|
||||||
subnav.item :categories, 'Kategorien'
|
subnav.item :categories, 'Kategorien', id: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :finance, 'Finanzen', '#', if: Proc.new { current_user.role_finance? } do |subnav|
|
primary.item :finance, 'Finanzen', '#', if: Proc.new { current_user.role_finance? } do |subnav|
|
||||||
subnav.item :accounts, 'Konten verwalten', finance_ordergroups_path
|
subnav.item :accounts, 'Konten verwalten', finance_ordergroups_path, id: nil
|
||||||
subnav.item :balancing, 'Bestellungen abrechnen', finance_balancing_path
|
subnav.item :balancing, 'Bestellungen abrechnen', finance_balancing_path, id: nil
|
||||||
subnav.item :invoices, 'Rechnungen', finance_invoices_path
|
subnav.item :invoices, 'Rechnungen', finance_invoices_path, id: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :admin, 'Administration', '#', if: Proc.new { current_user.role_admin? } do |subnav|
|
primary.item :admin, 'Administration', '#', if: Proc.new { current_user.role_admin? } do |subnav|
|
||||||
|
@ -48,11 +48,11 @@ SimpleNavigation::Configuration.run do |navigation|
|
||||||
if FoodsoftConfig[:homepage]
|
if FoodsoftConfig[:homepage]
|
||||||
primary.item :homepage, FoodsoftConfig[:name], FoodsoftConfig[:homepage]
|
primary.item :homepage, FoodsoftConfig[:name], FoodsoftConfig[:homepage]
|
||||||
end
|
end
|
||||||
primary.item :help, 'Hilfe', 'https://github.com/bennibu/foodsoft/wiki/Doku'
|
primary.item :help, 'Hilfe', 'https://github.com/bennibu/foodsoft/wiki/Doku', id: nil
|
||||||
primary.item :feedback, 'Feedback', 'new_feedback_path', title: "Fehler gefunden? Vorschlag? Idee? Kritik?"
|
primary.item :feedback, 'Feedback', 'new_feedback_path', title: "Fehler gefunden? Vorschlag? Idee? Kritik?", id: nil
|
||||||
primary.item :nick, current_user.nick, '#' do |subnav|
|
primary.item :nick, current_user.nick, '#' do |subnav|
|
||||||
subnav.item :edit_profile, 'Profil bearbeiten', my_profile_path, title: 'Profil bearbeiten'
|
subnav.item :edit_profile, 'Profil bearbeiten', my_profile_path, title: 'Profil bearbeiten', id: nil
|
||||||
subnav.item :logout, 'Abmelden', logout_path
|
subnav.item :logout, 'Abmelden', logout_path, id: nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue