render

in www/secretary/workbench/views/parts.js.rb [36:423]


  def render
    
    options = {
      attrs: {draggable: 'true'},
      on: {
        dragstart: self.dragStart,
        dragenter: self.dragEnter,
        dragover: self.dragOver,
        dragleave: self.dragLeave,
        dragend: self.dragEnd,
        drop: self.drop,
        contextmenu: self.showMenu,
        click: self.select
      }
    }

    _ul do
      _li 'undelete this email', onMousedown: self.undelete_message
    end

    _p '(Use [ctrl|meta] + [delete|backspace] to delete this email)'

    
    signature = CheckSignature.find(decodeURIComponent(@selected), @attachments)

    
    _ul.attachments! @attachments, ref: 'attachments' do |attachment|
      if attachment == @drag
        options[:class] = 'dragging'
      elsif attachment == @selected
        options[:class] = 'selected'
      elsif attachment == signature
        options[:class] = 'signature'
      else
        options[:class] = nil
      end

      if attachment =~ /\.(pdf|txt|jpeg|jpg|gif|png)$/i
        link = "./#{encodeURIComponent(attachment)}"
      else
        link = "_danger_/#{encodeURIComponent(attachment)}"
      end

      _li options do
        _a attachment, href: link, target: 'content', draggable: 'false',
          onClick: self.navigate
      end
    end

    if @headers&.secmail&.status
      _div.alert.alert_info @headers.secmail.status
    end

    if @headers&.secmail&.notes
      _div.alert.alert_warning do
        _h5 'Notes:'
        _span @headers.secmail.notes
      end
    end

    
    _ul.contextMenu do
      _li "\u2704 burst", onMousedown: self.burst
      _li.divider
      _li "\u21B7 right", onMousedown: self.rotate_attachment
      _li "\u21c5 flip", onMousedown: self.rotate_attachment
      _li "\u21B6 left", onMousedown: self.rotate_attachment
      _li.divider
      _li "\u2704 revert", onMousedown: self.revert
      _li.divider
      _li "\u2716 delete", onMousedown: self.delete_attachment
      _li "\u2709 pdf-ize", onMousedown: self.pdfize
      _li.divider
      _li 'parse pdf', onMousedown: self.pdfparse
    end

    if @selected and not @menu and @selected !~ /\.(asc|sig)$/

      _CheckSignature selected: @selected, attachments: @attachments,
        headers: @headers

      _ul.nav.nav_tabs do
        _li class: ('active' unless %i[edit mail].include?(@form)) do
          _a 'Categorize', onMousedown: self.tabSelect
        end
        _li class: ('active' if @form == :edit) do
          _a 'Edit', onMousedown: self.tabSelect
        end
        _li class: ('active' if @form == :mail) do
          _a 'Mail', onMousedown: self.tabSelect
        end
      end

      if @form == :categorize

        
        _div.doctype do
          _label do
            _input type: 'radio', name: 'doctype', value: 'icla',
              onClick: -> {@form = ICLA}
            _span 'icla'
          end

          _label do
            _input type: 'radio', name: 'doctype', value: 'icla2',
              onClick: -> {@form = ICLA2}
            _span 'additional icla'
          end

          _label do
            _input type: 'radio', name: 'doctype', value: 'ccla',
              onClick: -> {@form = CCLA}
            _span 'ccla'
          end

          _label do
            _input type: 'radio', name: 'doctype', value: 'grant',
              onClick: -> {@form = Grant}
            _span 'software grant'
          end

          if @@meeting
            _label do
              _input type: 'radio', name: 'doctype', value: 'mem',
                onClick: -> {@form = MemApp}
              _span 'membership application'
            end
          else
            _label do
              _input type: 'radio', name: 'doctype', disabled: true
              _span '(membership application arrived after the closing date)'
            end
          end

          _label do
            _input type: :radio, name: 'doctype', value: 'emeritus-request',
                   onClick: -> {@form = EmeritusRequest}
            _span 'emeritus request'
          end

          _label do
            _input type: :radio, name: 'doctype', value: 'withdrawal-request',
                   onClick: -> {@form = WithdrawalRequest}
            _span 'withdrawal request'
          end

          _hr

          _label do
            _input type: 'radio', name: 'doctype', value: 'forward',
              onClick: -> {@form = Forward}
            _span 'forward email'
          end

          _hr

          _label do
            _input type: 'radio', name: 'doctype', value: 'forward',
              onClick: -> {@form = Note}
            if @headers&.secmail&.notes
              _span 'edit note'
            else
              _span 'add note'
            end
          end

          _hr

          _form method: 'POST', target: 'content' do
            _input type: 'hidden', name: 'message',
              value: window.parent.location.pathname
            _input type: 'hidden', name: 'selected', value: @@selected
            _input type: 'hidden', name: 'signature', value: @@signature
            _input type: 'hidden', name: 'missing_address', value: @missing_address
            _input type: 'hidden', name: 'missing_email', value: @missing_email
            _input type: 'hidden', name: 'wrong_email', value: @wrong_email
            _input type: 'hidden', name: 'corporate_postal', value: @corporate_postal
            _input type: 'hidden', name: 'invalid_public', value: @invalid_public
            _input type: 'hidden', name: 'separate_signature', value: @separate_signature
            _input type: 'hidden', name: 'unauthorized_signature', value: @unauthorized_signature
            _input type: 'hidden', name: 'empty_form', value: @empty_form
            _input type: 'hidden', name: 'unreadable_scan', value: @unreadable_scan
            _input type: 'hidden', name: 'wrong_identity', value: @wrong_identity
            _input type: 'hidden', name: 'validation_failed', value: @validation_failed
            _input type: 'hidden', name: 'signature_not_armored', value: @signature_not_armored
            _input type: 'hidden', name: 'unsigned', value: @unsigned
            _input type: 'hidden', name: 'script_font', value: @script_font
            _input type: 'hidden', name: 'upload_sig', value: @upload_sig
            _input type: 'hidden', name: 'invalid_availid', value: @invalid_availid
            
            

            

            _label do
              _input type: 'radio', name: 'doctype', value: 'pubkey',
                onClick: self.reject
              _span 'upload public key'
            end

            

            _h4 'Reject email with message:'

            _label do
              _span 'Cc project: '
              _select name: 'project', value: @project, disabled: @filed do
                _option ''
                @@projects.each do |project|
                  _option project
                end
              end
            end

            _label do
              _input type: 'radio', name: 'doctype', value: 'incomplete',
                onClick: self.reject
              _span 'reject document (select reasons below)'
            end

            
            _ul.icla_reject do 
              _li do
                _label do
                  _input type: 'checkbox', checked: @missing_address,
                  onClick: -> {@missing_address = !@missing_address}
                  _span ' missing or partial postal address'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @missing_email,
                  onClick: -> {@missing_email = !@missing_email}
                  _span ' missing email address'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @wrong_email,
                  onClick: -> {@wrong_email = !@wrong_email}
                  _span ' incorrect email address'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @corporate_postal,
                  onClick: -> {@corporate_postal = !@corporate_postal}
                  _span ' corporate postal address'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @invalid_public,
                  onClick: -> {@invalid_public = !@invalid_public}
                  _span ' invalid public name'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @separate_signature,
                  onClick: -> {@separate_signature = !@separate_signature}
                  _span ' separate document and signature'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @unauthorized_signature,
                  onClick: -> {@unauthorized_signature = !@unauthorized_signature}
                  _span ' unauthorized signature'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @empty_form,
                  onClick: -> {@empty_form = !@empty_form}
                  _span ' empty form'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @unreadable_scan,
                  onClick: -> {@unreadable_scan = !@unreadable_scan}
                  _span ' unreadable or partial scan'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @wrong_identity,
                  onClick: -> {@wrong_identity = !@wrong_identity}
                  _span ' key data does not match email'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @validation_failed,
                  onClick: -> {@validation_failed = !@validation_failed}
                  _span ' gpg signature validation failed'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @signature_not_armored,
                  onClick: -> {@signature_not_armored = !@signature_not_armored}
                  _span ' gpg signature not armored'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @unsigned,
                  onClick: -> {@unsigned = !@unsigned}
                  _span ' unsigned'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @script_font,
                  onClick: -> {@script_font = !@script_font}
                  _span ' script font'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @upload_sig,
                  onClick: -> {@upload_sig = !@upload_sig}
                  _span ' upload signature'
                end
              end
              _li do
                _label do
                  _input type: 'checkbox', checked: @invalid_availid,
                  onClick: -> {@invalid_availid = !@invalid_availid}
                  _span ' invalid availid'
                end
              end
            end

            

            _label do
              _input type: 'radio', name: 'doctype', value: 'resubmit',
                onClick: self.reject
              _span 'resubmitted form'
            end

          end
        end

      elsif @form == :edit

        _ul.editPart! do
          _li "\u2704 burst", onMousedown: self.burst
          _li.divider
          _li "\u21B7 right", onMousedown: self.rotate_attachment
          _li "\u21c5 flip", onMousedown: self.rotate_attachment
          _li "\u21B6 left", onMousedown: self.rotate_attachment
          _li.divider
          _li "\u2704 revert", onMousedown: self.revert
          _li.divider
          _li "\u2716 delete", onMousedown: self.delete_attachment
          _li "\u2709 pdf-ize", onMousedown: self.pdfize
          _li.divider
          _li 'parse pdf', onMousedown: self.pdfparse
        end

      elsif @form == :mail

        _div.partmail! do
          _h3 'cc'
          _textarea value: @cc, name: 'cc'

          _h3 'bcc'
          _textarea value: @bcc, name: 'bcc'

          _button.btn.btn_primary 'Save', onClick: self.update_mail
        end

      else

        Vue.createElement @form, props: {
          headers: @headers,
          selected: @selected,
          projects: @@projects,
          signature: signature
        }
      end
    end
  end