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