[phase-14]add wiki-style description and preview
This commit is contained in:
parent
3d77142a46
commit
0e0aa07131
@ -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
|
||||
|
@ -6,7 +6,7 @@
|
||||
<p><%= form.text_field :datatype, size: 80 %></p>
|
||||
<p><%= form.text_field :codename, size: 80 %></p>
|
||||
<p><%= form.select :category_id, GlossaryCategory.pluck(:name, :id), include_blank: true %></p>
|
||||
<p><%= form.text_area :description, size: "80x10", required: false %></p>
|
||||
<p><%= form.text_area :description, rows: 10, class: 'wiki-edit', required: false %></p>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
@ -16,3 +16,4 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= wikitoolbar_for 'glossary_term_description' %>
|
||||
|
@ -1,7 +1,9 @@
|
||||
<h2><%=l :label_glossary_term %> #<%= @term.id %></h2>
|
||||
|
||||
<%= 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 %>
|
||||
|
||||
<div id="preview" class="wiki" ></div>
|
||||
|
@ -1,7 +1,12 @@
|
||||
<h2><%=l :label_glossary_term_new %></h2>
|
||||
|
||||
|
||||
<%= 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 %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_description %></th>
|
||||
<td><%= @term.description %></td>
|
||||
<td><div class="wiki"><%= textilizable @term, :description %></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_created_on %></th>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user