Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14,15,16,18,20 #21

Merged
merged 7 commits into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ test
*.swo
.DS_Store
*~
.idea
.idea
db-dump.sql
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gem "haml-rails"

gem 'jquery-rails'
gem 'jquery-validation-rails'
gem 'wice_grid'
gem 'wice_grid', '~> 3.5'

gem 'simple_form'
group :development, :test do
Expand Down
11 changes: 7 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ GEM
raindrops (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
wice_grid (3.4.11)
coffee-rails
kaminari (>= 0.13.0)
wice_grid (3.5.0)
coffee-rails (~> 4.0)
kaminari (~> 0.16)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand Down Expand Up @@ -366,4 +366,7 @@ DEPENDENCIES
twitter-bootstrap-rails
uglifier (>= 1.0.3)
unicorn
wice_grid
wice_grid (~> 3.5)

BUNDLED WITH
1.10.6
3 changes: 3 additions & 0 deletions app/admin/activity-types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ActiveAdmin.register ActivityStatus do
permit_params :name
end
33 changes: 33 additions & 0 deletions app/assets/stylesheets/activities.css.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Place all the styles related to the activities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
label.error
color: red



table.table.wice-grid
tr
td,th
padding: 0
font-size: 13px

&.date-col
width: 80px

.btn.btn-xs
font-size: 12px
line-height: 14px
padding: 1px 2px
th
&.filter_icons
width: 140px
min-width: 84px

&.wg-filter-row
th
.clickable
display: inline-block
&.date-filter
span
display: inline-block
6 changes: 0 additions & 6 deletions app/assets/stylesheets/activities.css.scss

This file was deleted.

6 changes: 5 additions & 1 deletion app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def grouped?

def index
@activities_grid = initialize_grid(Activity.where(parent_id: nil),
include: [:from_organization, :to_organization, :owner, :activity_type])
include: [:from_organization, :to_organization, :owner, :activity_type, :activity_status],
order: 'activities.date',
order_direction: 'desc')
end

def show
Expand Down Expand Up @@ -199,6 +201,7 @@ def activity_update_params
:tag,
:sum_koef,
:group_name,
:activity_status_id,
:sort_name)
end

Expand All @@ -216,6 +219,7 @@ def activity_create_params
:group_name,
:sum_koef,
:sort_name,
:activity_status_id,
activity_items_attributes: [:product_id, :quantity])
end

Expand Down
1 change: 1 addition & 0 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Activity < ActiveRecord::Base
has_many :activity_items
has_many :items, through: :activity_items, source: :product

belongs_to :activity_status
belongs_to :activity_type
belongs_to :from_organization, class_name: "Organization"
belongs_to :to_organization, class_name: "Organization"
Expand Down
11 changes: 11 additions & 0 deletions app/models/activity_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ActivityStatus < ActiveRecord::Base

class << self

def to_option
all.map{|s| [s.name, s.id] }
end

end

end
5 changes: 4 additions & 1 deletion app/views/activities/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
.col-xs-4
= f.input :sort_name

.row.form-group
.col-xs-4
= f.association :activity_status #, collection: ActivityStatus.all

-unless @activity.parent_id.nil?
%h3 Activity Items
%p
Expand All @@ -60,4 +64,3 @@
dateFormat: 'yy-mm-dd'
});
});

16 changes: 11 additions & 5 deletions app/views/activities/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
= link_to 'Add', new_activity_path, class: 'btn btn-success'
= link_to 'Delete', { controller: 'activities', action: 'delete' }, id: 'delete'

= grid(@activities_grid, show_filters: :when_filtered, class: :table) do |g|
= grid(@activities_grid, show_filters: :always, class: :table) do |g|
- g.action_column
- g.column name: 'ID', attribute: 'id'

- g.column name: 'Number', attribute: 'number'

- g.column name: 'Type', attribute: 'name', model: 'ActivityType' do |activity|
- activity.type.name if activity.type

- g.column name: 'Date', attribute: 'date'
- g.column name: 'Date', attribute: 'date', class: 'date-col'

- # alias_table должна называться именно так чтобы работали фильтры
- g.column name: 'From Organization',
Expand All @@ -26,8 +26,14 @@
table_alias: 'to_organizations_activities' do |activity|
- activity.to_organization.name if activity.to_organization

- g.column name: 'Owner', attribute: 'email', model: 'User' do |activity|
- activity.owner.email if activity.owner
- g.column name: 'Note', attribute: 'note'

- g.column name: 'Tag', attribute: 'tag'

- g.column name: 'Status', attribute: 'name', model: 'ActivityStatus',
allow_multiple_selection: true,
custom_filter: ActivityStatus.pluck(:name) do |activity|
- activity.activity_status.name if activity.activity_status

- g.column name: 'Total', attribute: 'total' do |activity|
- activity.total_price
Expand Down
4 changes: 4 additions & 0 deletions app/views/activities/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
.col-xs-4
= f.input :sort_name

.row.form-group
.col-xs-4
= f.association :activity_status

- if @activity.child?
%h3 Activity Items
.row
Expand Down
75 changes: 66 additions & 9 deletions app/views/activities/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,58 @@
Activity Details
.row
.col-md-8
= render :partial => 'form', :locals => { :activity => @activity, :disable_activity_editing => true }
#activity_details.container
.row
.col-xs-4
%b Number:
= @activity.number
.col-xs-4
%b Type:
- if @activity.parent_id.nil?
- activityTypes = ActivityType.all
- else
- activityTypes = ActivityType.where.not(:name => 'Order')
= @activity.activity_type.try(:name)

.row
.col-xs-4
%b From Organization:
= @activity.from_organization.try(:name)
.col-xs-4
%b To Organization:
= @activity.to_organization.try(:name)

.row
.col-xs-4
%b Date:
= @activity.date
.col-xs-4
%b Owner:
= @activity.owner.email

.row
.col-xs-4
%b Note:
= @activity.note
.col-xs-4
%b Tag:
= @activity.tag

.row
.col-xs-4
%b Group Name:
= @activity.group_name
.col-xs-4
%b Sort Type:
= @activity.sort_name

.row
.col-xs-4
%b Sum Koef:
= @activity.sum_koef
.col-xs-4
%b Status:
= @activity.activity_status.try(:name)

.row
.col-md-6
Expand Down Expand Up @@ -32,10 +83,6 @@
%p
= link_to 'Edit activity', edit_activity_path(@activity), class: 'btn btn-primary'
= link_to 'Go to parent', activity_path(@activity.parent), class: 'btn btn-primary'
%p
= link_to 'Скачать счет', activity_bill_path(@activity), class: 'btn btn-default'
= link_to 'Скачать Торг 12', activity_torg12_path(@activity), class: 'btn btn-default'
= link_to 'Скачать СФ', activity_sf_path(@activity), class: 'btn btn-default'

- if @activity.parent?
%h3
Expand Down Expand Up @@ -73,8 +120,12 @@
- g.column name: 'To Organization', attribute: 'name', model: 'Organization', :table_alias => 'to_organization' do |activity|
- activity.to_organization.name if activity.to_organization

- g.column name: 'Owner', attribute: 'email', model: 'User' do |activity|
- activity.owner.email if activity.owner
- g.column name: 'Note', attribute: 'note'

- g.column name: 'Tag', attribute: 'tag'

- g.column name: 'Status', attribute: 'name', model: 'ActivityStatus' do |activity|
- activity.activity_status.name if activity.activity_status

- g.column name: 'Total', attribute: 'total'

Expand Down Expand Up @@ -108,8 +159,12 @@
table_alias: 'to_organizations_activities' do |activity|
- activity.to_organization.name if activity.to_organization

- g.column name: 'Owner', attribute: 'email', model: 'User' do |activity|
- activity.owner.email if activity.owner
- g.column name: 'Note', attribute: 'note'

- g.column name: 'Tag', attribute: 'tag'

- g.column name: 'Status', attribute: 'name', model: 'ActivityStatus' do |activity|
- activity.activity_status.name if activity.activity_status

- g.column name: 'Total', attribute: 'total'

Expand All @@ -125,6 +180,8 @@
- else
= link_to 'View Grouped', activity_path(@activity, grouped: true), class: 'btn btn-primary'

-# временно, потом сделаем buld- download
- unless @activity.parent?
%p
= link_to 'Скачать счет', activity_bill_path(@activity), class: 'btn btn-default'
= link_to 'Скачать Торг 12', activity_torg12_path(@activity), class: 'btn btn-default'
Expand Down
46 changes: 0 additions & 46 deletions app/views/products/index.html.erb

This file was deleted.

27 changes: 27 additions & 0 deletions app/views/products/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- model_class = Product

%h2 Products

%p
= link_to 'Add', new_product_path, class: 'btn btn-success'

= grid(@products_grid, show_filters: true, class: :table) do |g|
- g.action_column

- g.column :name => t(:product_name), :attribute => 'name' do |product|
- product.name

- g.column :name => t(:product_sku), :attribute => 'articul' do |product|
- product.articul

- g.column :name => t(:measure), :attribute => 'measure' do |product|
- product.measure

- g.column :name => t(:product_active), :attribute => 'active' do |product|
- product.active? ? t(:yes) : t(:no)

- g.column :name => t(:product_forsale), :attribute => 'forsale' do |product|
- product.forsale? ? t(:yes) : t(:no)

- g.column do |product|
- link_to('Edit', { :controller => 'products', :action => 'edit', :id => product.id })
Loading