SUSE/hackweek

View on GitHub
app/views/projects/_file_buttons.html.haml

Summary

Maintainability
Test Coverage
.btn-group
  - if current_user
    - hidden = current_user.project_followings.include?(@project) ? '' : 'hidden'
    = link_to(project_followers_path(@project), method: :delete, class: "btn btn-default #{hidden}", title: 'Unfollow this project?', id: "unfollow-#{@project.id}", remote: true) do
      %i.fas.fa-eye-slash
    - hidden = current_user.project_followings.include?(@project) ? 'hidden' : ''
    = link_to(project_followers_path(@project), method: :post, class: "btn btn-default #{hidden}", title: 'Follow this project?', id: "follow-#{@project.id}", remote: true) do
      %i.far.fa-eye
  - if can? :edit, @project
    = link_to(edit_project_path(@episode, @project), title: 'Edit this project?', class: "btn btn-default", id: "project#{@project.to_param}-edit-link") do
      %i.fas.fa-pencil-alt
    - if @project.may_advance?
      - case @project.aasm_state
        - when "project"
          =link_to(advance_project_path(@episode, @project), method: :post, title: 'Finish this project', class: "btn btn-default", id: "project#{@project.to_param}-advance-link") do
            %i.fas.fa-check
        - when "record"
          =link_to(advance_project_path(@episode, @project), method: :post, title: 'Revive this project', class: "btn btn-default", id: "project#{@project.to_param}-advance-link") do
            %i.fas.fa-bolt
    - if @project.may_recess?
      - case @project.aasm_state
        - when "idea"
          =link_to(recess_project_path(@episode, @project), :method => :post,:title=>'Archive this project', :class=> "btn btn-default", id: "project#{@project.to_param}-recess-link") do
            %i.fas.fa-archive
        - when "invention"
          =link_to(recess_project_path(@episode, @project), :method => :post,:title=>"Restart this project", :class=> "btn btn-default", id: "project#{@project.to_param}-recess-link") do
            %i.fas.fa-lightbulb
  -if can? :destroy, @project
    = link_to(project_path(@episode, @project), :title=>'Delete this project?', :class=> "btn btn-default", id: "project#{@project.to_param}-delete-link", :method => :delete, data: { confirm: "Are you sure you want to delete this project? This can't be undone!" }) do
      %i.fas.fa-trash