diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb
index cf7b32a..c544e46 100644
--- a/app/controllers/glossary_terms_controller.rb
+++ b/app/controllers/glossary_terms_controller.rb
@@ -1,8 +1,9 @@
class GlossaryTermsController < ApplicationController
before_action :find_term_from_id, only: [:show, :edit, :update, :destroy]
- before_action :find_project_by_project_id, :authorize
-
+ before_action :find_project_by_project_id, :authorize, except: [:preview]
+ before_action :find_attachments, only: [:preview]
+
def index
@glossary_terms = GlossaryTerm.where(project_id: @project.id)
if not params[:index].nil?
@@ -45,6 +46,16 @@ class GlossaryTermsController < ApplicationController
@term.destroy
redirect_to project_glossary_terms_path
end
+
+ def preview
+ term = GlossaryTerm.find_by_id(params[:id])
+ if term
+ @attachments += term.attachments
+ @previewed = term
+ end
+ @text = params[:glossary_term][:description]
+ render partial: 'common/preview'
+ end
# Find the term whose id is the :id parameter
def find_term_from_id
diff --git a/app/views/glossary_terms/_form.html.erb b/app/views/glossary_terms/_form.html.erb
index 2aa816b..280e6a4 100644
--- a/app/views/glossary_terms/_form.html.erb
+++ b/app/views/glossary_terms/_form.html.erb
@@ -6,7 +6,7 @@
<%= form.text_field :datatype, size: 80 %>
<%= form.text_field :codename, size: 80 %>
<%= form.select :category_id, GlossaryCategory.pluck(:name, :id), include_blank: true %>
- <%= form.text_area :description, size: "80x10", required: false %>
+ <%= form.text_area :description, rows: 10, class: 'wiki-edit', required: false %>
@@ -16,3 +16,4 @@
+<%= wikitoolbar_for 'glossary_term_description' %>
diff --git a/app/views/glossary_terms/edit.html.erb b/app/views/glossary_terms/edit.html.erb
index fdbfbd1..b8b7a2b 100644
--- a/app/views/glossary_terms/edit.html.erb
+++ b/app/views/glossary_terms/edit.html.erb
@@ -1,7 +1,9 @@
<%=l :label_glossary_term %> #<%= @term.id %>
-<%= labelled_form_for @term, url: project_glossary_term_path, html: {multipart: true} do |f| %>
+<%= labelled_form_for :glossary_term, @term, url: project_glossary_term_path, html: {multipart: true, id: 'term-form'} do |f| %>
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
<%= f.submit l(:button_edit) %>
+ <%= preview_link preview_project_glossary_term_path(@project, @term), 'term-form' %>
<% end %>
+
diff --git a/app/views/glossary_terms/new.html.erb b/app/views/glossary_terms/new.html.erb
index 918b4a8..2e9fb5f 100644
--- a/app/views/glossary_terms/new.html.erb
+++ b/app/views/glossary_terms/new.html.erb
@@ -1,7 +1,12 @@
<%=l :label_glossary_term_new %>
-
+
<%= labelled_form_for :glossary_term, @term,
- url: project_glossary_terms_path, html: {multipart: true} do |f| %>
+url: project_glossary_terms_path, html: {multipart: true, id: 'term-form'} do |f| %>
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
<%= f.submit l(:button_create) %>
+ <%= preview_link preview_project_glossary_terms_path(@project), 'term-form' %>
<% end %>
+
+
+
+
diff --git a/app/views/glossary_terms/show.html.erb b/app/views/glossary_terms/show.html.erb
index 07364ad..60b7229 100644
--- a/app/views/glossary_terms/show.html.erb
+++ b/app/views/glossary_terms/show.html.erb
@@ -41,7 +41,7 @@
<%=l :field_description %> |
- <%= @term.description %> |
+ <%= textilizable @term, :description %> |
<%=l :field_created_on %> |
diff --git a/config/routes.rb b/config/routes.rb
index eb14bcf..8c14ca6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,7 +3,14 @@
Rails.application.routes.draw do
resources :projects do
- resources :glossary_terms
+ resources :glossary_terms do
+ member do
+ patch 'preview'
+ end
+ collection do
+ post 'preview'
+ end
+ end
resources :glossary_categories
end
end