SumOfUs/Champaign

View on GitHub
app/views/plugins/call_tools/_sound_clip_form.slim

Summary

Maintainability
Test Coverage
javascript:
  Dropzone.options.mainSoundClipDropzone = false;
  Dropzone.options.menuSoundClipDropzone = false;

  $(function() {
    new Dropzone('#main-sound-clip-dropzone', {
      paramName: 'plugins_call_tool[sound_clip]',
      clickable: '#main-sound-clip-dropzone__clickable',
      init: function() {
        this.on('complete', handleComplete);
      }
    });

    new Dropzone('#menu-sound-clip-dropzone', {
      paramName: 'plugins_call_tool[menu_sound_clip]',
      clickable: '#menu-sound-clip-dropzone__clickable',
      init: function() {
        this.on('complete', handleComplete);
      }
    });

    function handleComplete(file) {
      $('.call-tool .sound-clip-section').html(file.xhr.responseText)
    }
  });

.error-msg
  - if plugin.errors.present?
    span Something went wrong, please make sure the uploaded file has the correct format
    ul
      - plugin.errors.full_messages.each do |error|
        li = error

= form_tag sound_clip_plugins_call_tool_path(plugin), method: :post, id: 'main-sound-clip-dropzone', class: 'dropzone', multipart: true
  .form-group
    = label_tag_with_tooltip(:sound_clip, 'Main Sound Clip', t('tooltips.call_tool.campaign_audio'))
    = button_tag "Choose file", id: 'main-sound-clip-dropzone__clickable', type: 'button', class: 'btn btn-default choose-file-btn'

  .sound-clip-detail.main
    - if plugin.errors.blank? && plugin.sound_clip.present?
      = render partial: 'plugins/call_tools/main_sound_clip_player', locals: { plugin: plugin }

= form_tag sound_clip_plugins_call_tool_path(plugin), method: :post, id: 'menu-sound-clip-dropzone', class: 'dropzone', multipart: true
  .form-group
    = label_tag_with_tooltip(:sound_clip, 'Menu Sound Clip', t('tooltips.call_tool.menu_audio'))
    = button_tag "Choose file", id: 'menu-sound-clip-dropzone__clickable', type: 'button', class: 'btn btn-default choose-file-btn'

  .sound-clip-detail.menu
    - if plugin.errors.blank? && plugin.menu_sound_clip.present?
      = render partial: 'plugins/call_tools/menu_sound_clip_player', locals: { plugin: plugin }