Add meeting JS to show/hide edit form

pull/6827/head
Oliver Günther 7 years ago
parent 79260eb001
commit a47f5f6934
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 23
      app/assets/javascripts/meeting/meeting.js
  2. 9
      app/helpers/meeting_contents_helper.rb
  3. 8
      app/views/meeting_contents/_form.html.erb
  4. 15
      app/views/meeting_contents/_show.html.erb
  5. 2
      lib/open_project/meeting/engine.rb

@ -0,0 +1,23 @@
jQuery(function($) {
function toggleContentTypeForm(content_type, edit) {
jQuery('.edit-' + content_type).toggle(edit);
jQuery('.show-' + content_type).toggle(!edit);
jQuery('.button--edit-agenda').toggleClass('-active', edit);
jQuery('.button--edit-agenda').attr('disabled', edit);
}
$('.button--edit-agenda').click(function() {
var content_type = $(this).data('contentType');
toggleContentTypeForm(content_type, true);
return false;
});
$('.button--cancel-agenda').click(function() {
var content_type = $(this).data('contentType');
toggleContentTypeForm(content_type, false);
return false;
});
});

@ -92,14 +92,11 @@ module MeetingContentsHelper
def meeting_content_edit_link(content_type) def meeting_content_edit_link(content_type)
content_tag :li, '', class: 'toolbar-item' do content_tag :li, '', class: 'toolbar-item' do
content_tag :button, content_tag :button,
'', '',
class: 'button button--edit-agenda', data: { 'content-type': content_type },
onclick: "jQuery('.edit-#{content_type}').show(); class: 'button button--edit-agenda' do
jQuery('.show-#{content_type}').hide();
jQuery('.button--edit-agenda').addClass('-active');
jQuery('.button--edit-agenda').attr('disabled', true);
return false;" do
link_to l(:button_edit), link_to l(:button_edit),
'', '',
class: 'icon-context icon-edit', class: 'icon-context icon-edit',

@ -29,13 +29,7 @@ See doc/COPYRIGHT.md for more details.
<p><%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %> <p><%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %>
<% path = send("preview_#{content_type}_path", content.meeting) %> <% path = send("preview_#{content_type}_path", content.meeting) %>
<%= preview_link path, "#{content_type}_form", { class: 'button preview' } %> <%= preview_link path, "#{content_type}_form", { class: 'button preview' } %>
<%= link_to l(:button_cancel), "#", <%= link_to l(:button_cancel), "#", data: { 'content-type': content_type }, class: 'button button--cancel-agenda' %>
:onclick => "jQuery('.show-#{content_type}').show();
jQuery('.edit-#{content_type}').hide();
jQuery('.button--edit-agenda').removeClass('-active');
jQuery('.button--edit-agenda').removeAttr('disabled');;
return false;",
class: 'button' %></p>
<%= wikitoolbar_for "#{content_type}_text" %> <%= wikitoolbar_for "#{content_type}_text" %>
<% end %> <% end %>

@ -23,6 +23,11 @@ See doc/COPYRIGHT.md for more details.
tab ||= locals[:tab_contents] if defined? locals tab ||= locals[:tab_contents] if defined? locals
content, content_type = tab[:content], tab[:content_type] if tab && tab.present? content, content_type = tab[:content], tab[:content_type] if tab && tab.present?
-%> -%>
<% content_for :header_tags do %>
<%= javascript_include_tag('meeting/meeting.js') %>
<% end %>
<div class="meeting_content <%= content_type %>"> <div class="meeting_content <%= content_type %>">
<div> <div>
<%= toolbar title: l(:"label_#{content_type}") do %> <%= toolbar title: l(:"label_#{content_type}") do %>
@ -31,20 +36,22 @@ See doc/COPYRIGHT.md for more details.
</div> </div>
<% if can_edit_meeting_content?(content, content_type) -%> <% if can_edit_meeting_content?(content, content_type) -%>
<div id="edit-<%= content_type %>" class="edit-<%= content_type %>"<%= " style=\"display: none;\"" unless show_meeting_content_editor?(content, content_type)%>> <div id="edit-<%= content_type %>"
class="edit-<%= content_type %>"
style="<%= 'display: none' unless show_meeting_content_editor?(content, content_type) %>">
<%= render(:partial => "meeting_contents/form", :locals => {:content => content, :content_type => content_type}) %> <%= render(:partial => "meeting_contents/form", :locals => {:content => content, :content_type => content_type}) %>
</div> </div>
<% end -%> <% end -%>
<% if saved_meeting_content_text_present?(content) -%> <% if saved_meeting_content_text_present?(content) -%>
<div id="<%= content_type %>-text" class="wiki show-<%= content_type %>"> <div id="<%= content_type %>-text"
style="<%= 'display: none' if show_meeting_content_editor?(content, content_type) %>"
class="wiki show-<%= content_type %>">
<%= format_text(content.text, :object => @meeting) %> <%= format_text(content.text, :object => @meeting) %>
</div> </div>
<% else -%> <% else -%>
<%= no_results_box %> <%= no_results_box %>
<% end -%> <% end -%>
<%= nonced_javascript_tag(show_meeting_content_editor?(content, content_type) ? "jQuery('.show-#{content_type}').hide();" : "jQuery('.edit-#{content_type}').hide();") %>
</div> </div>
<%= render :partial => 'shared/meeting_header' %> <%= render :partial => 'shared/meeting_header' %>

@ -68,7 +68,7 @@ module OpenProject::Meeting
patch_with_namespace :BasicData, :SettingSeeder patch_with_namespace :BasicData, :SettingSeeder
initializer 'meeting.precompile_assets' do initializer 'meeting.precompile_assets' do
Rails.application.config.assets.precompile += %w(meeting/meeting.css) Rails.application.config.assets.precompile += %w(meeting/meeting.css meeting/meeting.js)
end end
initializer 'meeting.register_hooks' do initializer 'meeting.register_hooks' do

Loading…
Cancel
Save