wco_models 3.1.0.136 → 3.1.0.137

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4aca388a9b787126a677bc0a0dada925305f24381f879dc7df154179e968381
4
- data.tar.gz: b2d6f9d703ab36d7bbdb1ce87940f516b96ff9e9c288a9f201bf8d712e3f4bb2
3
+ metadata.gz: 632761ee3733fa6dfa80381c4e542ced567f4ef571d3bd2cc14bd649f46c91b7
4
+ data.tar.gz: c597ae263f07ce7b48a86d0f95890a159a63d0275f2f56fe1ea46108bb3380c4
5
5
  SHA512:
6
- metadata.gz: 102c9769aa8cff0861ca10a8a63774da3d17686dc36ffc1f2a3bcb290504c4263fcc3d2a4149ca5796fd6c5406b24ce314f5bcdb1e479ec824fc743ca7432970
7
- data.tar.gz: c79fa5615fe7d33f5ca72b56934c71934177f9f70d3cfad6d1af54a43dc801c6eab1895a4dbe4243b960ee98fc49cdaea6b8c436dd2c344375961d3a9dda75e8
6
+ metadata.gz: '08fdf497885da8ba2afe8ea69995a21152f565811e2d1ab584abdad2087f4ac836169d67ad489ba517c8357286d47eb17a6a0b8023afb45fb75ef05be13dccd0'
7
+ data.tar.gz: '0778143ba46e945b64d8f2da6eb52afb9486ce60e427c843e613b8535d705c98801e3b1d852bd4bbc963bc992f8aa61d17d3f3cc29adafe0954429acf8de2caf'
@@ -12,12 +12,12 @@
12
12
  color: var(--wco-color-2contrast);
13
13
  }
14
14
 
15
- display: inline;
15
+ display: inline-block;
16
16
 
17
17
  height: 32px;
18
18
 
19
19
  margin-right: 32px;
20
- margin-bottom: 0.1em;
20
+ margin-bottom: 0.3em;
21
21
 
22
22
  padding: 0.1em .3em;
23
23
  padding: 0.2em 0.2em 0.2em 0.6em;
@@ -44,14 +44,15 @@ class Wco::GalleriesController < Wco::ApplicationController
44
44
  @page_title = 'Galleries'
45
45
  @galleries = Wco::Gallery.all.order_by( :created_at => :desc )
46
46
 
47
+ @tags = Wco::Tag.all
48
+
47
49
  if params[:q]
48
50
  q = URI.decode(params[:q])
49
51
  @galleries = @galleries.where({ :name => /#{q}/i })
50
52
  end
51
53
 
52
54
  @galleries = @galleries.page( params[:galleries_page] ).per( current_profile.per_page )
53
-
54
- render "_index"
55
+ render '_index'
55
56
  end
56
57
 
57
58
  def j_show
@@ -127,6 +128,31 @@ class Wco::GalleriesController < Wco::ApplicationController
127
128
  end
128
129
  end
129
130
 
131
+ def update_many
132
+ authorize! :update, Wco::Gallery
133
+ galleries = Wco::Gallery.where( :id.in => params[:gallery_ids] )
134
+
135
+ tags = Wco::Tag.where( :id.in => params[:tag_ids] )
136
+
137
+ if params[:remove]
138
+ galleries.each do |gallery|
139
+ tags.each do |tag|
140
+ gallery.tags.delete tag
141
+ end
142
+ gallery.save
143
+ end
144
+ else
145
+ galleries.each do |gallery|
146
+ gallery.tags.push tags
147
+ gallery.save
148
+ end
149
+ end
150
+
151
+ flash_notice 'Unknown outcome, no exception raised.'
152
+ redirect_to request.referrer
153
+ end
154
+
155
+
130
156
  ##
131
157
  ## private
132
158
  ##
@@ -1,6 +1,8 @@
1
1
 
2
2
  class Wco::TagsController < Wco::ApplicationController
3
3
 
4
+ before_action :set_lists, only: %i| show |
5
+
4
6
  def create
5
7
  @tag = Wco::Tag.new params[:tag].permit!
6
8
  authorize! :create, @tag
@@ -42,7 +44,12 @@ class Wco::TagsController < Wco::ApplicationController
42
44
  @tag = Wco::Tag.find params[:id]
43
45
  authorize! :show, @tag
44
46
 
45
- @reports = @tag.reports.page( params[:reports_page] ).per( current_profile.per_page )
47
+ @galleries = @tag.galleries(
48
+ ).page( params[:galleries_page] ).per( current_profile.per_page )
49
+
50
+ @reports = @tag.reports(
51
+ ).page( params[:reports_page] ).per( current_profile.per_page )
52
+
46
53
  end
47
54
 
48
55
  def update
@@ -56,4 +63,14 @@ class Wco::TagsController < Wco::ApplicationController
56
63
  redirect_to action: 'index'
57
64
  end
58
65
 
66
+ ##
67
+ ## private
68
+ ##
69
+ private
70
+
71
+ def set_lists
72
+ @tags = Wco::Tag.all
73
+ end
74
+
75
+
59
76
  end
@@ -51,6 +51,9 @@ class Wco::Gallery
51
51
  %w| name subhead descr |
52
52
  end
53
53
 
54
+ has_and_belongs_to_many :tags
55
+
56
+
54
57
  has_many :oats, class_name: 'Wco::OfficeActionTemplate'
55
58
 
56
59
  end
@@ -18,7 +18,9 @@ class Wco::Tag
18
18
  has_and_belongs_to_many :headlines # , class_name: 'Headline'
19
19
  has_and_belongs_to_many :leads, index: true # , class_name: 'Lead'
20
20
  has_and_belongs_to_many :leadsets # , class_name: 'Leadset'
21
+ has_and_belongs_to_many :galleries
21
22
  has_and_belongs_to_many :reports
23
+ has_and_belongs_to_many :videos
22
24
  has_and_belongs_to_many :logs
23
25
 
24
26
  INBOX = 'inbox'
@@ -32,6 +32,9 @@ class Wco::Video
32
32
  # belongs_to :user_profile, :class_name => 'Ish::UserProfile', :inverse_of => :videos
33
33
  # has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_videos
34
34
 
35
+ has_and_belongs_to_many :tags
36
+
37
+
35
38
  has_mongoid_attached_file :video,
36
39
  # styles: { :thumb => { geometry: '192x108', format: 'jpeg' }, },
37
40
  # processors: [ :transcoder ],
@@ -8,37 +8,48 @@
8
8
 
9
9
 
10
10
  .galleries--index.maxwidth
11
- = render 'header', galleries: galleries
11
+ = render '/wco/galleries/header', galleries: galleries
12
12
 
13
13
  .padded
14
14
  - if galleries.length > 0
15
- - if galleries.respond_to? :total_pages
16
- = paginate galleries, :param_name => :galleries_page, :views_prefix => 'wco'
17
-
18
15
  = form_tag update_galleries_path do
19
- = select_tag 'tag_ids[]', options_for_select([ nil, 1 ]), { multiple: true }
20
- = submit_tag 'Add Tags'
21
-
22
- .row
23
- - galleries.each do |g|
24
- .col-sm-12.col-md-6
25
- .Card
26
- %h5
27
- = check_box_tag 'ids[]', g.id
28
- = link_to '[~]', edit_gallery_path( g )
29
- = link_to g.name, gallery_path(g.slug)
30
- (#{g.photos.length})
31
- = render 'meta', item: g
32
- - if g.photos.length == 0
33
- No Photos
34
- - else
35
- .d-flex.flex-wrap.photos-thumbs
36
- - g.photos.limit( @current_profile.show_n_thumbs ).each do |photo|
37
- = link_to image_tag(photo.photo.url(:thumb), :alt => ''), gallery_path(g.slug)
16
+ - @tags.each do |tag|
17
+
18
+ .Chip
19
+ = check_box_tag 'tag_ids[]', tag.id
20
+ = tag
21
+
22
+ = submit_tag 'Add Tags', data: { confirm: 'Are you sure?' }
23
+ &nbsp;&nbsp;
24
+ %label remove?
25
+ = check_box_tag :remove
26
+ = submit_tag 'Tags', data: { confirm: 'Are you sure?' }
38
27
 
39
28
  - if galleries.respond_to? :total_pages
40
29
  = paginate galleries, :param_name => :galleries_page, :views_prefix => 'wco'
41
30
 
31
+ .row
32
+ - galleries.each do |g|
33
+ .col-sm-12.col-md-6
34
+ .Card
35
+ %h5
36
+ = check_box_tag 'gallery_ids[]', g.id
37
+ = link_to '[~]', edit_gallery_path( g )
38
+ = link_to g.name, gallery_path(g.slug)
39
+ (#{g.photos.length})
40
+ = render 'meta', item: g
41
+ - if g.photos.length == 0
42
+ No Photos
43
+ - else
44
+ .d-flex.flex-wrap.photos-thumbs
45
+ - g.photos.limit( @current_profile.show_n_thumbs ).each do |photo|
46
+ = link_to image_tag(photo.photo.url(:thumb), :alt => ''), gallery_path(g.slug)
47
+
48
+ - if galleries.respond_to? :total_pages
49
+ = paginate galleries, :param_name => :galleries_page, :views_prefix => 'wco'
50
+
42
51
  - else
43
- %h5 No Galleries
52
+ .p No Galleries
53
+
54
+
44
55
 
@@ -10,6 +10,9 @@
10
10
  %i.material-icons visibility
11
11
  - else
12
12
  %i.material-icons visibility_off
13
+
14
+ = render '/wco/tags/list_mini', tags: gallery.tags
15
+
13
16
  %ul
14
17
  %li slug :: #{gallery.slug}
15
18
  %li subhead :: #{gallery.subhead}
@@ -1,10 +1,7 @@
1
1
 
2
2
 
3
- .Tags.mb-2
3
+ .Tags.chips.mb-2
4
4
  <b>Tags (#{tags.length}):</b>
5
5
  - tags.each_with_index do |tag, idx|
6
- = link_to tag.slug, wco.tag_path(tag)
7
- - if idx+1 == tags.length
8
- \.
9
- - else
10
- \,&nbsp;
6
+ .Chip
7
+ = link_to tag.slug, wco.tag_path(tag)
@@ -12,6 +12,9 @@
12
12
  %li.d-flex
13
13
  <b>Headlines (#{@tag.headlines.length}):&nbsp;</b>
14
14
  = render '/wco/headlines/index', headlines: @tag.headlines
15
+ %li.d-flex
16
+ <b>Galleries (#{@galleries.length}):&nbsp;</b>
17
+ = render 'wco/galleries/index', galleries: @galleries, config: { skip_tags: true }
15
18
  %li.d-flex
16
19
  <b>Reports (#{@reports.length}):&nbsp;</b>
17
20
  = render 'wco/reports/list', reports: @reports, config: { skip_tags: true }
data/config/routes.rb CHANGED
@@ -11,7 +11,7 @@ Wco::Engine.routes.draw do
11
11
  resources :assets
12
12
  # get 'assets/:id', to: 'assets#show', as: :asset
13
13
 
14
- post 'galleries/update', to: 'galleries#update', as: :update_galleries
14
+ post 'galleries/update', to: 'galleries#update_many', as: :update_galleries
15
15
  resources :galleries do
16
16
  post 'multiadd', :to => 'photos#j_create', :as => :multiadd
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.136
4
+ version: 3.1.0.137
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev