effective_classifieds 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/admin/classified_wizards_controller.rb +19 -0
  4. data/app/controllers/effective/{classified_submissions_controller.rb → classified_wizards_controller.rb} +4 -4
  5. data/app/datatables/admin/{effective_classified_submissions_datatable.rb → effective_classified_wizards_datatable.rb} +2 -2
  6. data/app/datatables/admin/effective_classifieds_datatable.rb +1 -1
  7. data/app/datatables/effective_classified_wizards_datatable.rb +36 -0
  8. data/app/helpers/effective_classifieds_helper.rb +0 -5
  9. data/app/models/concerns/{effective_classifieds_classified_submission.rb → effective_classifieds_classified_wizard.rb} +7 -15
  10. data/app/models/effective/classified.rb +2 -2
  11. data/app/models/effective/classified_wizard.rb +7 -0
  12. data/app/views/effective/classified_wizards/_classified.html.haml +10 -0
  13. data/app/views/effective/classified_wizards/_classified_wizard.html.haml +3 -0
  14. data/app/views/effective/{classified_submissions → classified_wizards}/_content.html.haml +0 -0
  15. data/app/views/effective/{classified_submissions → classified_wizards}/_dashboard.html.haml +6 -6
  16. data/app/views/effective/{classified_submissions → classified_wizards}/_layout.html.haml +0 -0
  17. data/app/views/effective/{classified_submissions → classified_wizards}/_summary.html.haml +4 -4
  18. data/app/views/effective/classified_wizards/classified.html.haml +17 -0
  19. data/app/views/effective/{classified_submissions → classified_wizards}/start.html.haml +1 -1
  20. data/app/views/effective/classified_wizards/submitted.html.haml +14 -0
  21. data/app/views/effective/{classified_submissions → classified_wizards}/summary.html.haml +2 -2
  22. data/app/views/effective/classifieds/index.html.haml +2 -2
  23. data/config/effective_classifieds.rb +2 -2
  24. data/config/routes.rb +2 -2
  25. data/db/migrate/01_create_effective_classifieds.rb.erb +5 -5
  26. data/lib/effective_classifieds/engine.rb +1 -1
  27. data/lib/effective_classifieds/version.rb +1 -1
  28. data/lib/effective_classifieds.rb +4 -4
  29. data/lib/generators/effective_classifieds/install_generator.rb +1 -1
  30. metadata +18 -18
  31. data/app/controllers/admin/classified_submissions_controller.rb +0 -19
  32. data/app/datatables/effective_classified_submissions_datatable.rb +0 -36
  33. data/app/models/effective/classified_submission.rb +0 -7
  34. data/app/views/effective/classified_submissions/_classified.haml +0 -13
  35. data/app/views/effective/classified_submissions/_classified_submission.html.haml +0 -8
  36. data/app/views/effective/classified_submissions/classified.html.haml +0 -16
  37. data/app/views/effective/classified_submissions/submitted.html.haml +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c63e81e0e5192044916433851a3611a6dd378fab65da8a5371375b310737bc9f
4
- data.tar.gz: cf7fea6948d57d2ed13a82e3f5e90bc6eb922aa1e61e4071deec4e770c0b3ff1
3
+ metadata.gz: b922833fe51ff1291c85c0708b708120ab0d87c25ff96185c62b105b53fb1fe7
4
+ data.tar.gz: 7bbb631c54607a94616f8493234dbab069c1446b6d6256ed8758cba5b9c2dd2e
5
5
  SHA512:
6
- metadata.gz: b432d9428538383229d8c71f0b15489081ba9028a807e13066fa3cc1850b03eca22962bc713d0a995afd2f4616df0e05e8773ae2c19a48986ec0c22662765d8c
7
- data.tar.gz: 9721963c16dbab88c25303f923ffb440532663085a9d48722e6616e8465bb36d46afe59ea305aa2f1994ae11f44842756ec428bef1d523919506c09d3b70ab35
6
+ metadata.gz: c0945747f72335c70181f4f63f89467b936974ad166a938a70e6b97ce23201b42c034997c4279d7f7372662b6afe15e1101759e3551e6d9a495612a9aa3fa148
7
+ data.tar.gz: c7dea63e19d5d077ba9c83f0cfaf7bace041f2aa82fdfa173fb5b8d75a5d8358a7380cc759769f75ce308d8b2c698ff88255791ea060e5fb705664d1ee3e209a
data/README.md CHANGED
@@ -46,7 +46,7 @@ Please add the following to your user dashboard page:
46
46
  .card-body= render 'effective/classifieds/dashboard'
47
47
 
48
48
  .card.card-dashboard.mb-4
49
- .card-body= render 'effective/classified_submissions/dashboard'
49
+ .card-body= render 'effective/classified_wizards/dashboard'
50
50
  ```
51
51
 
52
52
  and
@@ -82,9 +82,9 @@ The permissions you actually want to define are as follows (using CanCan):
82
82
  can([:index, :show], Effective::Classified) { |classified| classified.published? }
83
83
  can([:show, :edit, :update], Effective::Classified) { |classified| classified.owner == user }
84
84
 
85
- can(:new, EffectiveClassifieds.ClassifiedSubmission)
86
- can([:show, :index, :destroy], EffectiveClassifieds.ClassifiedSubmission) { |submission| submission.owner == user }
87
- can([:update], EffectiveClassifieds.ClassifiedSubmission) { |submission| submission.owner == user && !submission.was_submitted? }
85
+ can(:new, EffectiveClassifieds.ClassifiedWizard)
86
+ can([:show, :index, :destroy], EffectiveClassifieds.ClassifiedWizard) { |submission| submission.owner == user }
87
+ can([:update], EffectiveClassifieds.ClassifiedWizard) { |submission| submission.owner == user && !submission.was_submitted? }
88
88
 
89
89
  if user.admin?
90
90
  can :admin, :effective_classifieds
@@ -93,7 +93,7 @@ if user.admin?
93
93
  can(:approve, Classified) { |classified| classified.was_submitted? && !classified.approved? }
94
94
  can(:destroy, Classified) { |classified| !classified.draft? }
95
95
 
96
- can([:index, :show], EffectiveClassifieds.ClassifiedSubmission)
96
+ can([:index, :show], EffectiveClassifieds.ClassifiedWizard)
97
97
  end
98
98
  ```
99
99
 
@@ -0,0 +1,19 @@
1
+ module Admin
2
+ class ClassifiedWizardsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_classifieds) }
5
+
6
+ include Effective::CrudController
7
+
8
+ resource_scope -> { EffectiveEvents.ClassifiedWizard.deep.all }
9
+ datatable -> { Admin::EffectiveClassifiedWizardsDatatable.new }
10
+
11
+ private
12
+
13
+ def permitted_params
14
+ model = (params.key?(:effective_classified_wizard) ? :effective_classified_wizard : :classified_wizard)
15
+ params.require(model).permit!
16
+ end
17
+
18
+ end
19
+ end
@@ -1,10 +1,10 @@
1
1
  module Effective
2
- class ClassifiedSubmissionsController < ApplicationController
2
+ class ClassifiedWizardsController < ApplicationController
3
3
  before_action(:authenticate_user!) if defined?(Devise)
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveClassifieds.ClassifiedSubmission.deep.where(owner: current_user) }
7
+ resource_scope -> { EffectiveClassifieds.ClassifiedWizard.deep.where(owner: current_user) }
8
8
 
9
9
  # Allow only 1 in-progress application at a time
10
10
  before_action(only: [:new, :show], unless: -> { resource&.done? }) do
@@ -12,7 +12,7 @@ module Effective
12
12
 
13
13
  if existing.present?
14
14
  flash[:success] = "You have been redirected to your in-progress classified ad submission"
15
- redirect_to effective_classifieds.classified_submission_build_path(existing, existing.next_step)
15
+ redirect_to effective_classifieds.classified_wizard_build_path(existing, existing.next_step)
16
16
  end
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module Effective
23
23
  private
24
24
 
25
25
  def permitted_params
26
- model = (params.key?(:effective_classified_submission) ? :effective_classified_submission : :classified_submission)
26
+ model = (params.key?(:effective_classified_wizard) ? :effective_classified_wizard : :classified_wizard)
27
27
  params.require(model).permit!.except(:status, :status_steps, :wizard_steps, :submitted_at)
28
28
  end
29
29
 
@@ -1,4 +1,4 @@
1
- class Admin::EffectiveClassifiedSubmissionsDatatable < Effective::Datatable
1
+ class Admin::EffectiveClassifiedWizardsDatatable < Effective::Datatable
2
2
  datatable do
3
3
  order :created_at
4
4
 
@@ -16,7 +16,7 @@ class Admin::EffectiveClassifiedSubmissionsDatatable < Effective::Datatable
16
16
  end
17
17
 
18
18
  collection do
19
- EffectiveSubmissions.ClassifiedSubmission.all.deep.done.joins(:classified)
19
+ EffectiveSubmissions.ClassifiedWizard.all.deep.done.joins(:classified)
20
20
  end
21
21
 
22
22
  end
@@ -18,7 +18,7 @@ module Admin
18
18
 
19
19
  col :id, visible: false
20
20
 
21
- col :classified_submission, visible: false, search: :string
21
+ col :classified_wizard, visible: false, search: :string
22
22
  col :owner, visible: false, label: 'Submitted by'
23
23
 
24
24
  col :start_on, as: :date
@@ -0,0 +1,36 @@
1
+ # Dashboard Classified Submissions
2
+ class EffectiveClassifiedWizardsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :created_at
5
+
6
+ col :token, visible: false
7
+ col :created_at, visible: false
8
+
9
+ col :submitted_at, label: 'Submitted' do |wizard|
10
+ wizard.submitted_at&.strftime('%F') || 'Incomplete'
11
+ end
12
+
13
+ col :classified, search: :string, label: 'Title'
14
+
15
+ col :owner, visible: false, search: :string
16
+
17
+ col :status, visible: false do |wizard|
18
+ wizard.classified&.status || wizard.status
19
+ end
20
+
21
+ actions_col(actions: []) do |wizard|
22
+ if wizard.draft?
23
+ dropdown_link_to('Continue', effective_classifieds.classified_wizard_build_path(wizard, wizard.next_step), 'data-turbolinks' => false)
24
+ else
25
+ dropdown_link_to('Edit', effective_classifieds.edit_classified_path(wizard.classified))
26
+ end
27
+
28
+ dropdown_link_to('Delete', effective_classifieds.classified_wizard_path(wizard), 'data-confirm': "Really delete #{wizard}?", 'data-method': :delete)
29
+ end
30
+ end
31
+
32
+ collection do
33
+ EffectiveClassifieds.ClassifiedWizard.deep.where(owner: current_user).left_joins(:classified)
34
+ end
35
+
36
+ end
@@ -1,7 +1,2 @@
1
1
  module EffectiveClassifiedsHelper
2
-
3
- def edit_effective_classified_submissions_wizard?
4
- params[:controller] == 'effective/classified_submissions' && defined?(resource) && resource.draft?
5
- end
6
-
7
2
  end
@@ -1,28 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # EffectiveClassifiedsClassifiedSubmission
3
+ # EffectiveClassifiedsClassifiedWizard
4
4
  #
5
- # Mark your owner model with effective_classifieds_classified_submission to get all the includes
5
+ # Mark your owner model with effective_classifieds_classified_wizard to get all the includes
6
6
 
7
- module EffectiveClassifiedsClassifiedSubmission
7
+ module EffectiveClassifiedsClassifiedWizard
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  module Base
11
- def effective_classifieds_classified_submission
12
- include ::EffectiveClassifiedsClassifiedSubmission
11
+ def effective_classifieds_classified_wizard
12
+ include ::EffectiveClassifiedsClassifiedWizard
13
13
  end
14
14
  end
15
15
 
16
16
  module ClassMethods
17
- def effective_classifieds_classified_submission?; true; end
18
-
19
- def all_wizard_steps
20
- const_get(:WIZARD_STEPS).keys
21
- end
22
-
23
- def required_wizard_steps
24
- [:start, :summary, :submitted]
25
- end
17
+ def effective_classifieds_classified_wizard?; true; end
26
18
  end
27
19
 
28
20
  included do
@@ -47,7 +39,7 @@ module EffectiveClassifiedsClassifiedSubmission
47
39
  accepts_nested_attributes_for :owner
48
40
 
49
41
  # Effective Namespace
50
- has_one :classified, class_name: 'Effective::Classified', inverse_of: :classified_submission, dependent: :destroy
42
+ has_one :classified, class_name: 'Effective::Classified', inverse_of: :classified_wizard, dependent: :destroy
51
43
  accepts_nested_attributes_for :classified, reject_if: :all_blank, allow_destroy: true
52
44
 
53
45
  effective_resource do
@@ -15,7 +15,7 @@ module Effective
15
15
  belongs_to :owner, polymorphic: true
16
16
 
17
17
  # When submitted through the wizard
18
- belongs_to :classified_submission, polymorphic: true, optional: true
18
+ belongs_to :classified_wizard, polymorphic: true, optional: true
19
19
 
20
20
  has_rich_text :body
21
21
 
@@ -102,7 +102,7 @@ module Effective
102
102
  end
103
103
 
104
104
  # Automatically approve submissions created by admins outside the submissions wizard
105
- before_validation(if: -> { new_record? && classified_submission.blank? }) do
105
+ before_validation(if: -> { new_record? && classified_wizard.blank? }) do
106
106
  assign_attributes(status: :approved)
107
107
  end
108
108
 
@@ -0,0 +1,7 @@
1
+ module Effective
2
+ class ClassifiedWizard < ActiveRecord::Base
3
+ self.table_name = EffectiveClassifieds.classified_wizards_table_name.to_s
4
+
5
+ effective_classifieds_classified_wizard
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ .card
2
+ .card-body
3
+ .row
4
+ .col-sm
5
+ %h5.card-title= classified_wizard.wizard_step_title(:classified)
6
+ .col-sm-auto.text-right
7
+ = link_to('Edit', wizard_path(:classified)) if edit_effective_wizard?
8
+
9
+ - classified = classified_wizard.classified
10
+ = render 'effective/classifieds/classified', classified: classified
@@ -0,0 +1,3 @@
1
+ .effective-classified-wizard
2
+ - classified_wizard.render_steps.each do |partial|
3
+ = render "effective/classified_wizards/#{partial}", classified_wizard: classified_wizard, step: partial
@@ -1,8 +1,8 @@
1
- - if can?(:new, EffectiveClassifieds.ClassifiedSubmission)
1
+ - if can?(:new, EffectiveClassifieds.ClassifiedWizard)
2
2
 
3
3
  -# In-progress submission
4
- - submission = EffectiveClassifieds.ClassifiedSubmission.in_progress.for(current_user).first
5
- - datatable = EffectiveResources.best('EffectiveClassifiedSubmissionsDatatable').new(self, namespace: :effective)
4
+ - submission = EffectiveClassifieds.ClassifiedWizard.in_progress.for(current_user).first
5
+ - datatable = EffectiveResources.best('EffectiveClassifiedWizardsDatatable').new(self, namespace: :effective)
6
6
 
7
7
  - if submission.present?
8
8
  %h2 In-progress Classified Ads
@@ -12,9 +12,9 @@
12
12
 
13
13
  %p
14
14
  Please
15
- = link_to("Continue submission for #{submission.classified.presence || 'a classified'}", effective_classifieds.classified_submission_build_path(submission, submission.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
15
+ = link_to("Continue submission for #{submission.classified.presence || 'a classified'}", effective_classifieds.classified_wizard_build_path(submission, submission.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
16
16
  or you can
17
- = link_to('Abandon submission', effective_classifieds.classified_submission_path(submission), 'data-confirm': "Really delete #{submission}?", 'data-method': :delete, class: 'btn btn-danger')
17
+ = link_to('Abandon submission', effective_classifieds.classified_wizard_path(submission), 'data-confirm': "Really delete #{submission}?", 'data-method': :delete, class: 'btn btn-danger')
18
18
  to submit another.
19
19
 
20
20
  %hr
@@ -27,4 +27,4 @@
27
27
  %p You don't have any classified ads. When you do, we'll show them here.
28
28
 
29
29
  - if submission.blank?
30
- %p= link_to 'Submit New Classified Ad', effective_classifieds.new_classified_submission_path, class: 'btn btn-primary'
30
+ %p= link_to 'Submit New Classified Ad', effective_classifieds.new_classified_wizard_path, class: 'btn btn-primary'
@@ -1,5 +1,5 @@
1
1
  = card('Classified Ad') do
2
- - classified = classified_submission.classified
2
+ - classified = classified_wizard.classified
3
3
 
4
4
  %table.table.table-sm
5
5
  %tbody
@@ -16,12 +16,12 @@
16
16
  %tr
17
17
  %th Owner
18
18
  %td
19
- - url = (polymorphic_admin_path(classified_submission.owner) rescue "/admin/users/#{classified_submission.owner.to_param}/edit")
20
- = link_to(classified_submission.owner, url)
19
+ - url = (polymorphic_admin_path(classified_wizard.owner) rescue "/admin/users/#{classified_wizard.owner.to_param}/edit")
20
+ = link_to(classified_wizard.owner, url)
21
21
  - else
22
22
  %tr
23
23
  %th Owner
24
- %td= classified_submission.owner
24
+ %td= classified_wizard.owner
25
25
 
26
26
  - if classified&.was_submitted?
27
27
  %tr
@@ -0,0 +1,17 @@
1
+ = render 'layout' do
2
+ = render 'effective/classified_wizards/content', resource: resource
3
+
4
+ .card
5
+ .card-body
6
+ = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
7
+ = f.hidden_field :id
8
+
9
+ = f.fields_for :classified, (f.object.classified || f.object.build_classified) do |fc|
10
+ = fc.hidden_field :id
11
+
12
+ = fc.hidden_field :owner_id, value: f.object.owner_id
13
+ = fc.hidden_field :owner_type, value: f.object.owner_type
14
+
15
+ = render('effective/classifieds/fields', f: fc, classified: fc.object)
16
+
17
+ = f.save 'Save and Continue'
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/classified_submissions/content', resource: resource
2
+ = render 'effective/classified_wizards/content', resource: resource
3
3
 
4
4
  .card
5
5
  .card-body
@@ -0,0 +1,14 @@
1
+ = render 'layout' do
2
+ = render 'effective/classified_wizards/content', resource: resource
3
+
4
+ - raise('expected a submitted classified_wizard') unless resource.was_submitted?
5
+
6
+ .alert.alert-warning.mb-4
7
+ Successfully submitted on #{resource.submitted_at.strftime('%F')}.
8
+
9
+ = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary mb-4'
10
+
11
+ = render 'effective/classified_wizards/summary', classified_wizard: resource
12
+ = render 'effective/classified_wizards/classified_wizard', classified_wizard: resource
13
+
14
+ = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary'
@@ -1,7 +1,7 @@
1
1
  = render 'layout' do
2
- = render 'effective/classified_submissions/content', resource: resource
2
+ = render 'effective/classified_wizards/content', resource: resource
3
3
 
4
- = render('effective/classified_submissions/classified_submission', classified_submission: resource)
4
+ = render('effective/classified_wizards/classified_wizard', classified_wizard: resource)
5
5
 
6
6
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
7
7
  = f.hidden_field :id
@@ -1,8 +1,8 @@
1
1
  .resource-buttons
2
- = link_to 'Submit New Classified Ad', effective_classifieds.new_classified_submission_path, class: 'btn btn-primary'
2
+ = link_to 'Submit New Classified Ad', effective_classifieds.new_classified_wizard_path, class: 'btn btn-primary'
3
3
 
4
4
  = card do
5
- - if @datatable
5
+ - if @datatable.present?(self)
6
6
  = render_datatable(@datatable, simple: true)
7
7
  - else
8
8
  %p There are no active classified ads. When there are, we'll show them here.
@@ -1,6 +1,6 @@
1
1
  EffectiveClassifieds.setup do |config|
2
2
  config.classifieds_table_name = :classifieds
3
- config.classified_submissions_table_name = :classified_submissions
3
+ config.classified_wizards_table_name = :classified_wizards
4
4
 
5
5
  # Every classified must have a category.
6
6
  config.categories = ['Job', 'Equipment Sales', 'Other']
@@ -10,7 +10,7 @@ EffectiveClassifieds.setup do |config|
10
10
  # config.layout = { application: 'application', admin: 'admin' }
11
11
 
12
12
  # Classified Settings
13
- # config.classified_submission_class_name = 'Effective::ClassifiedSubmission'
13
+ # config.classified_wizard_class_name = 'Effective::ClassifiedWizard'
14
14
 
15
15
  # Pagination length on the Classified#index page
16
16
  config.per_page = :all
data/config/routes.rb CHANGED
@@ -9,8 +9,8 @@ EffectiveClassifieds::Engine.routes.draw do
9
9
  scope module: 'effective' do
10
10
  resources :classifieds, only: [:index, :show, :edit, :update]
11
11
 
12
- resources :classified_submissions, only: [:new, :show, :destroy] do
13
- resources :build, controller: :classified_submissions, only: [:show, :update]
12
+ resources :classified_wizards, only: [:new, :show, :destroy] do
13
+ resources :build, controller: :classified_wizards, only: [:show, :update]
14
14
  end
15
15
 
16
16
  end
@@ -1,8 +1,8 @@
1
1
  class CreateEffectiveClassifieds < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table <%= @classifieds_table_name %> do |t|
4
- t.integer :classified_submission_id
5
- t.string :classified_submission_type
4
+ t.integer :classified_wizard_id
5
+ t.string :classified_wizard_type
6
6
 
7
7
  t.integer :owner_id
8
8
  t.string :owner_type
@@ -36,7 +36,7 @@ class CreateEffectiveClassifieds < ActiveRecord::Migration[6.1]
36
36
  add_index :classifieds, [:owner_id, :owner_type]
37
37
  add_index :classifieds, :slug
38
38
 
39
- create_table <%= @classified_submissions_table_name %> do |t|
39
+ create_table <%= @classified_wizards_table_name %> do |t|
40
40
  t.string :token
41
41
 
42
42
  t.integer :owner_id
@@ -56,7 +56,7 @@ class CreateEffectiveClassifieds < ActiveRecord::Migration[6.1]
56
56
  t.datetime :created_at
57
57
  end
58
58
 
59
- add_index :classified_submissions, [:owner_id, :owner_type]
60
- add_index :classified_submissions, :token
59
+ add_index :classified_wizards, [:owner_id, :owner_type]
60
+ add_index :classified_wizards, :token
61
61
  end
62
62
  end
@@ -10,7 +10,7 @@ module EffectiveClassifieds
10
10
  # Include acts_as_addressable concern and allow any ActiveRecord object to call it
11
11
  initializer 'effective_classifieds.active_record' do |app|
12
12
  ActiveSupport.on_load :active_record do
13
- ActiveRecord::Base.extend(EffectiveClassifiedsClassifiedSubmission::Base)
13
+ ActiveRecord::Base.extend(EffectiveClassifiedsClassifiedWizard::Base)
14
14
  end
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveClassifieds
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -7,17 +7,17 @@ module EffectiveClassifieds
7
7
 
8
8
  def self.config_keys
9
9
  [
10
- :classifieds_table_name, :classified_submissions_table_name,
10
+ :classifieds_table_name, :classified_wizards_table_name,
11
11
  :layout, :categories, :per_page, :use_effective_roles, :max_duration, :auto_approve,
12
- :classified_submission_class_name,
12
+ :classified_wizard_class_name,
13
13
  :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin
14
14
  ]
15
15
  end
16
16
 
17
17
  include EffectiveGem
18
18
 
19
- def self.ClassifiedSubmission
20
- classified_submission_class_name&.constantize || Effective::ClassifiedSubmission
19
+ def self.ClassifiedWizard
20
+ classified_wizard_class_name&.constantize || Effective::ClassifiedWizard
21
21
  end
22
22
 
23
23
  def self.mailer_class
@@ -21,7 +21,7 @@ module EffectiveMemberships
21
21
 
22
22
  def create_migration_file
23
23
  @classifieds_table_name = ':' + EffectiveClassifieds.classifieds_table_name.to_s
24
- @classified_submissions_table_name = ':' + EffectiveClassifieds.classified_submissions_table_name.to_s
24
+ @classified_wizards_table_name = ':' + EffectiveClassifieds.classified_wizards_table_name.to_s
25
25
 
26
26
  migration_template ('../' * 3) + 'db/migrate/01_create_effective_classifieds.rb.erb', 'db/migrate/create_effective_classifieds.rb'
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_classifieds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-24 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -179,32 +179,32 @@ files:
179
179
  - app/assets/javascripts/effective_classifieds/base.js
180
180
  - app/assets/stylesheets/effective_classifieds.scss
181
181
  - app/assets/stylesheets/effective_classifieds/base.scss
182
- - app/controllers/admin/classified_submissions_controller.rb
182
+ - app/controllers/admin/classified_wizards_controller.rb
183
183
  - app/controllers/admin/classifieds_controller.rb
184
- - app/controllers/effective/classified_submissions_controller.rb
184
+ - app/controllers/effective/classified_wizards_controller.rb
185
185
  - app/controllers/effective/classifieds_controller.rb
186
- - app/datatables/admin/effective_classified_submissions_datatable.rb
186
+ - app/datatables/admin/effective_classified_wizards_datatable.rb
187
187
  - app/datatables/admin/effective_classifieds_datatable.rb
188
- - app/datatables/effective_classified_submissions_datatable.rb
188
+ - app/datatables/effective_classified_wizards_datatable.rb
189
189
  - app/datatables/effective_classifieds_datatable.rb
190
190
  - app/helpers/effective_classifieds_helper.rb
191
191
  - app/mailers/effective/classifieds_mailer.rb
192
- - app/models/concerns/effective_classifieds_classified_submission.rb
192
+ - app/models/concerns/effective_classifieds_classified_wizard.rb
193
193
  - app/models/effective/classified.rb
194
- - app/models/effective/classified_submission.rb
194
+ - app/models/effective/classified_wizard.rb
195
195
  - app/views/admin/classifieds/_form.html.haml
196
196
  - app/views/admin/classifieds/_form_access.html.haml
197
197
  - app/views/admin/classifieds/_form_classified.html.haml
198
- - app/views/effective/classified_submissions/_classified.haml
199
- - app/views/effective/classified_submissions/_classified_submission.html.haml
200
- - app/views/effective/classified_submissions/_content.html.haml
201
- - app/views/effective/classified_submissions/_dashboard.html.haml
202
- - app/views/effective/classified_submissions/_layout.html.haml
203
- - app/views/effective/classified_submissions/_summary.html.haml
204
- - app/views/effective/classified_submissions/classified.html.haml
205
- - app/views/effective/classified_submissions/start.html.haml
206
- - app/views/effective/classified_submissions/submitted.html.haml
207
- - app/views/effective/classified_submissions/summary.html.haml
198
+ - app/views/effective/classified_wizards/_classified.html.haml
199
+ - app/views/effective/classified_wizards/_classified_wizard.html.haml
200
+ - app/views/effective/classified_wizards/_content.html.haml
201
+ - app/views/effective/classified_wizards/_dashboard.html.haml
202
+ - app/views/effective/classified_wizards/_layout.html.haml
203
+ - app/views/effective/classified_wizards/_summary.html.haml
204
+ - app/views/effective/classified_wizards/classified.html.haml
205
+ - app/views/effective/classified_wizards/start.html.haml
206
+ - app/views/effective/classified_wizards/submitted.html.haml
207
+ - app/views/effective/classified_wizards/summary.html.haml
208
208
  - app/views/effective/classifieds/_classified.html.haml
209
209
  - app/views/effective/classifieds/_dashboard.html.haml
210
210
  - app/views/effective/classifieds/_fields.html.haml
@@ -1,19 +0,0 @@
1
- module Admin
2
- class ClassifiedSubmissionsController < ApplicationController
3
- before_action(:authenticate_user!) if defined?(Devise)
4
- before_action { EffectiveResources.authorize!(self, :admin, :effective_classifieds) }
5
-
6
- include Effective::CrudController
7
-
8
- resource_scope -> { EffectiveEvents.ClassifiedSubmission.deep.all }
9
- datatable -> { Admin::EffectiveClassifiedSubmissionsDatatable.new }
10
-
11
- private
12
-
13
- def permitted_params
14
- model = (params.key?(:effective_classified_submission) ? :effective_classified_submission : :classified_submission)
15
- params.require(model).permit!
16
- end
17
-
18
- end
19
- end
@@ -1,36 +0,0 @@
1
- # Dashboard Classified Submissions
2
- class EffectiveClassifiedSubmissionsDatatable < Effective::Datatable
3
- datatable do
4
- order :created_at
5
-
6
- col :token, visible: false
7
- col :created_at, visible: false
8
-
9
- col :submitted_at, label: 'Submitted' do |submission|
10
- submission.submitted_at&.strftime('%F') || 'Incomplete'
11
- end
12
-
13
- col :classified, search: :string, label: 'Title'
14
-
15
- col :owner, visible: false, search: :string
16
-
17
- col :status, visible: false do |submission|
18
- submission.classified&.status || submission.status
19
- end
20
-
21
- actions_col(actions: []) do |submission|
22
- if submission.draft?
23
- dropdown_link_to('Continue', effective_classifieds.classified_submission_build_path(submission, submission.next_step), 'data-turbolinks' => false)
24
- else
25
- dropdown_link_to('Edit', effective_classifieds.edit_classified_path(submission.classified))
26
- end
27
-
28
- dropdown_link_to('Delete', effective_classifieds.classified_submission_path(submission), 'data-confirm': "Really delete #{submission}?", 'data-method': :delete)
29
- end
30
- end
31
-
32
- collection do
33
- EffectiveClassifieds.ClassifiedSubmission.deep.where(owner: current_user).left_joins(:classified)
34
- end
35
-
36
- end
@@ -1,7 +0,0 @@
1
- module Effective
2
- class ClassifiedSubmission < ActiveRecord::Base
3
- self.table_name = EffectiveClassifieds.classified_submissions_table_name.to_s
4
-
5
- effective_classifieds_classified_submission
6
- end
7
- end
@@ -1,13 +0,0 @@
1
- .card
2
- .card-body
3
- .row
4
- .col-sm
5
- %h5.card-title= classified_submission.wizard_step_title(:classified)
6
- .col-sm-auto.text-right
7
- = link_to('Edit', wizard_path(:classified)) if edit_effective_classified_submissions_wizard?
8
-
9
- - classified = classified_submission.classified
10
-
11
- - if classified.present?
12
- = render('effective/classifieds/classified', classified: classified) do
13
- = classified.body
@@ -1,8 +0,0 @@
1
- .effective-classified-submission
2
- - blacklist = EffectiveClassifieds.ClassifiedSubmission.required_wizard_steps
3
- - steps = classified_submission.required_steps - blacklist
4
-
5
- = render "effective/classified_submissions/summary", classified_submission: classified_submission
6
-
7
- - steps.select { |step| classified_submission.has_completed_step?(step) }.each do |partial|
8
- = render "effective/classified_submissions/#{partial}", classified_submission: classified_submission, step: partial
@@ -1,16 +0,0 @@
1
- = render 'effective/classified_submissions/content', resource: resource
2
-
3
- .card
4
- .card-body
5
- = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
6
- = f.hidden_field :id
7
-
8
- = f.fields_for :classified, (f.object.classified || f.object.build_classified) do |fc|
9
- = fc.hidden_field :id
10
-
11
- = fc.hidden_field :owner_id, value: f.object.owner_id
12
- = fc.hidden_field :owner_type, value: f.object.owner_type
13
-
14
- = render('effective/classifieds/fields', f: fc, classified: fc.object)
15
-
16
- = f.save 'Save and Continue'
@@ -1,13 +0,0 @@
1
- = render 'layout' do
2
- = render 'effective/classified_submissions/content', resource: resource
3
-
4
- - raise('expected a submitted classified_submission') unless resource.was_submitted?
5
-
6
- .alert.alert-warning.mb-4
7
- Successfully submitted on #{resource.submitted_at.strftime('%F')}.
8
-
9
- = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary mb-4'
10
-
11
- = render 'effective/classified_submissions/classified_submission', classified_submission: resource
12
-
13
- = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary'