Skip to content

Commit

Permalink
add previewable concern to notes controller
Browse files Browse the repository at this point in the history
  • Loading branch information
caitmich committed Aug 23, 2023
1 parent 0b984f8 commit aec4287
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ class NotesController < NestedNodeResourceController
include MultipleDestroy
include NodesSidebar
include NotificationsReader
include Previewable

before_action :find_or_initialize_note, except: [:index, :new, :multiple_destroy]
before_action :initialize_nodes_sidebar, only: [:edit, :new, :show]
before_action :set_auto_save_key, only: [:new, :create, :edit, :update]
before_action :set_form_preview_path, only: [:new, :edit]

def new
@note = @node.notes.new
Expand Down Expand Up @@ -99,4 +101,8 @@ def set_auto_save_key
"node-#{@node.id}-note"
end
end

def set_form_preview_path
@form_preview_path = { preview_url: preview_project_node_note_path }
end
end
2 changes: 1 addition & 1 deletion app/views/notes/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
data: {
allow_dropdown: @note.new_record?,
behavior: 'auto-save rich-toolbar drop-zone',
paths: editor_paths,
paths: editor_paths.merge!(@form_preview_path),
'rich-toolbar': 'block-code bold field image italic link list-ol list-ul table',
'rich-toolbar-uploader': '[data-behavior~=jquery-upload]',
},
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

resource :merge, only: [:create], controller: 'nodes/merge'

resources :notes, concerns: :multiple_destroy do
resources :notes, concerns: [:multiple_destroy, :previewable] do
resources :revisions, only: [:index, :show]
end

Expand Down

0 comments on commit aec4287

Please sign in to comment.