wco_models 3.1.0.145 → 3.1.0.146

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@
5
5
  //= require ../vendor/bootstrap-4.6.2.min
6
6
  //= require ../vendor/select2-4.0.0
7
7
  //= require ../vendor/jquery.dataTables-1.10.16
8
+ //= require ../vendor/jquery-ui@1.13.2.js
8
9
  //
9
10
  // Skip for now b/c I need to move fonts, too:
10
11
  // require ../vendor/summernote-0.8.18
@@ -28,6 +29,11 @@
28
29
 
29
30
  $(function() {
30
31
 
32
+ /* sortable */
33
+ $( function() {
34
+ $( ".orderable-items" ).sortable();
35
+ } );
36
+
31
37
  /* DataTable */
32
38
  if ('function' === typeof $('body').DataTable) {
33
39
  const _props = {
@@ -114,7 +114,7 @@ textarea.monospace {
114
114
 
115
115
  .gray,
116
116
  .grey {
117
- color: grey;
117
+ color: #999;
118
118
  display: inline-block;
119
119
  }
120
120
 
@@ -93,12 +93,12 @@ class Wco::GalleriesController < Wco::ApplicationController
93
93
 
94
94
  def update_ordering
95
95
  authorize! :update, @gallery
96
- out = []
97
- params[:gallery][:sorted_photo_ids].each_with_index do |id, idx|
98
- out.push Photo.find( id ).update_attribute( :ordering, idx )
96
+ flags = []
97
+ params[:ids].each_with_index do |id, idx|
98
+ flags.push Wco::Photo.find( id ).update( weight: idx )
99
99
  end
100
- flash[:notice] = "Outcomes: #{out}."
101
- redirect_to action: 'show', id: @gallery.id
100
+ flash_notice "Ordering photos: #{flags}"
101
+ redirect_to request.referrer
102
102
  end
103
103
 
104
104
  def update
@@ -66,12 +66,14 @@ class Wco::PhotosController < Wco::ApplicationController
66
66
  authorize! :move, Wco::Photo
67
67
  photos = Wco::Photo.where({ :id.in => params[:ids] })
68
68
 
69
- flag = photos.update_all({ gallery_id: params[:gallery_id] })
70
- if flag
71
- flash_notice 'ok'
69
+ if params['delete'] == '1'
70
+ flash_notice 'deleting'
71
+ flag = photos.map &:delete
72
72
  else
73
- flash_alert 'not ok'
73
+ flag = photos.update_all({ gallery_id: params[:gallery_id] })
74
+ flash_notice 'moving'
74
75
  end
76
+ flash_notice flag
75
77
  redirect_to request.referrer
76
78
  end
77
79
 
@@ -21,34 +21,31 @@
21
21
  = link_to image_tag(photo.photo.url( :mini ), :alt => ''), "#large_#{photo.id}"
22
22
 
23
23
  .row-thumbs
24
- %i.fa.fa-expand.collapse-expand#rowMovableThumbs Movable Thumbs
25
- .orderable-items{ data: { id: @gallery.id.to_s, slug: @gallery.slug, token: form_authenticity_token } }
26
- = form_tag wco.move_photos_path, { method: :post } do
27
- .d-flex
28
- = select_tag :gallery_id, options_for_select(@galleries_list), class: 'select2'
29
- = submit_tag 'Move', data: { confirm: 'Are you sure?' }
30
- .d-flex.items
31
- - @photos.each do |photo|
32
- .itemW
33
- = check_box_tag 'ids[]', photo.id
34
- .item{ data: { id: photo.id.to_s } }
35
- = image_tag photo.photo.url( :thumb )
24
+ %i.fa.fa-expand.collapse-expand#rowMovableThumbs Deletable, Movable Thumbs
25
+ = form_tag wco.move_photos_path, { method: :post } do
26
+ .d-flex
27
+ = select_tag :gallery_id, options_for_select(@galleries_list), class: 'select2'
28
+ = check_box_tag :delete
29
+ %label Delete?
30
+ = submit_tag 'Delete or Move', data: { confirm: 'Are you sure?' }
31
+ .d-flex.items
32
+ - @photos.each do |photo|
33
+ .itemW
34
+ = check_box_tag 'ids[]', photo.id
35
+ .item{ data: { id: photo.id.to_s } }
36
+ = image_tag photo.photo.url( :thumb )
36
37
 
37
38
  .row-thumbs
38
- %i.fa.fa-expand.collapse-expand#rowOrderableThumbs Orderable, Deletable Thumbs
39
- .orderable-items{ data: { id: @gallery.id.to_s, slug: @gallery.slug, token: form_authenticity_token } }
40
- = form_tag wco.delete_photos_path, { method: :delete } do
41
- = submit_tag 'Delete', data: { confirm: 'Are you sure?' }
42
- = button_tag 'Save ordering', class: 'save-ordering'
43
- .d-flex.items
44
- - @photos.each do |photo|
45
- .itemW
46
- %a.mvLeft &lt;
47
- %a.mvRight &gt;
48
- .item{ data: { id: photo.id.to_s } }
49
- = check_box_tag 'ids[]', photo.id
50
- = render 'wco/photos/meta_manager', photo: photo
51
- = image_tag photo.photo.url( :thumb )
39
+ %i.fa.fa-expand.collapse-expand#rowOrderableThumbs Orderable Thumbs
40
+ = form_tag wco.update_ordering_photos_path do
41
+ = hidden_field_tag :id, @gallery.id
42
+ = submit_tag 'Save ordering', class: 'save-ordering', data: { confirm: 'Are you sure?' }
43
+ .d-flex.items.orderable-items{ data: { id: @gallery.id.to_s, slug: @gallery.slug, token: form_authenticity_token } }
44
+ - @photos.each do |photo|
45
+ .item{ data: { id: photo.id.to_s } }
46
+ = hidden_field_tag 'ids[]', photo.id
47
+ = render 'wco/photos/meta_manager', photo: photo
48
+ = image_tag photo.photo.url( :thumb )
52
49
 
53
50
 
54
51
 
@@ -58,5 +55,6 @@
58
55
  - @photos.each do |photo|
59
56
  .item
60
57
  %a{id: "large_#{photo.id}" }
58
+ = button_to '[x]', photo_path( :id => photo.id ), class: 'x', :method => :delete, :data => { :confirm => 'Are you sure?' }
61
59
  = render 'wco/photos/meta_manager', photo: photo
62
60
  .wrapper{ style: "background-image: url('#{photo.photo.url( :large )}')" }
@@ -1,6 +1,6 @@
1
1
 
2
2
  .photos--meta-manager
3
- = button_to '[x]', photo_path( :id => photo.id ), class: 'x', :method => :delete, :data => { :confirm => 'Are you sure?' }
3
+ -# = button_to '[x]', photo_path( :id => photo.id ), class: 'x', :method => :delete, :data => { :confirm => 'Are you sure?' }
4
4
  .right-hand
5
5
  = link_to "Goto", "#large_#{photo.id}", class: 'goto'
6
6
  = link_to "Lg", photo.photo.url(:large)
data/config/routes.rb CHANGED
@@ -46,6 +46,7 @@ Wco::Engine.routes.draw do
46
46
  post 'publishers/:id/do-run', to: 'publishers#do_run', as: :run_publisher
47
47
  resources :publishers
48
48
 
49
+ post 'photos/update-ordering', to: 'galleries#update_ordering', as: :update_ordering_photos
49
50
  post 'photos/move', to: 'photos#move', as: :move_photos
50
51
  delete 'photos/delete', to: 'photos#destroy', as: :delete_photos
51
52
  resources :photos
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.145
4
+ version: 3.1.0.146
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-17 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -371,6 +371,7 @@ files:
371
371
  - app/assets/javascripts/vendor/jquery-3.3.1.slim.min.js
372
372
  - app/assets/javascripts/vendor/jquery-3.4.1.min.js
373
373
  - app/assets/javascripts/vendor/jquery-ui.min.js
374
+ - app/assets/javascripts/vendor/jquery-ui@1.13.2.js
374
375
  - app/assets/javascripts/vendor/jquery.dataTables-1.10.16.js
375
376
  - app/assets/javascripts/vendor/jquery.dataTables-1.10.16.min.js
376
377
  - app/assets/javascripts/vendor/jquery.fileupload.js