Skip to content

Commit

Permalink
Add tag input field to wiki editor (#8260)
Browse files Browse the repository at this point in the history
* add tag input field to wiki editor

* fix code climate issue

* leave space between tag_input field an other buttons
  • Loading branch information
Shulammite-Aso committed Aug 11, 2020
1 parent 5fedc09 commit e97eff7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/wiki_controller.rb
Expand Up @@ -163,6 +163,9 @@ def create
body: params[:body])
if saved
flash[:notice] = I18n.t('wiki_controller.wiki_page_created')
params[:tags]&.tr(' ', ',')&.split(',')&.each do |tagname|
@node.add_tag(tagname.strip, current_user)
end
if params[:main_image] && params[:main_image] != ''
img = Image.find params[:main_image]
img.nid = @node.id
Expand Down
6 changes: 6 additions & 0 deletions app/views/editor/_tag_input.html.erb
@@ -0,0 +1,6 @@
<div class="input-group tags-input">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-tags"></i></span>
</div>
<input autocomplete="off" class="form-control" id="taginput" tabindex="3" name="tags" type="text" <% if params[:tags] || (@node && @node.power_tag('question')) || (@node && @node.tagnames) %>value="<%= params[:tags] || @node.tagnames.join(',') %><%= ','+@node.power_tag('question') if @node && @node.power_tag('question') != '' %>"<% else %>placeholder="balloon-mapping,gulf-coast"<% end %> data-provide="typeahead" />
</div>
2 changes: 2 additions & 0 deletions app/views/wiki/edit.html.erb
Expand Up @@ -71,6 +71,8 @@

<%= render partial: 'editor/editor' %>
<%= render partial: 'editor/tag_input' %>
<br>
<a id="publish" tabindex="5" class="publish btn btn-primary btn-lg"><%= translation('wiki.edit.publish') %></a>
<a tabindex="6" data-previewing-text="<%= translation('wiki.edit.previewing_text') %>" class="btn btn-outline-secondary btn-lg preview-btn" onClick="$E.toggle_preview()"><%= translation('wiki.edit.preview') %></a>
<a class="btn btn-outline-secondary btn-lg" href="/wiki/<%= params["id"] %>">Cancel</a>
Expand Down

0 comments on commit e97eff7

Please sign in to comment.