Growstuff/growstuff

View on GitHub
app/views/photos/new.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, "New Photo"

%h1 New Photo
%h2 Choose photo for #{link_to @item, @item} from Flickr, or contribute to unique crops to <a href="https://inaturalist.org/" target="_blank">iNaturalist</a> or <a href="https://identify.plantnet.org/" target="_blank">Pl@ntNet</a> via the app.

- if @please_reconnect_flickr
  %h2.alert Please reconnect your flickr account

  %p the token has expired or been revoked.

  = link_to '/members/auth/flickr', class: "btn btn-lg" do
    = icon 'fab', 'flickr'
    Reconnect Flickr


- elsif @flickr_auth
  %p
    Connected to Flickr as
    = succeed "." do
      = link_to @flickr_auth.name, "http://flickr.com/photos/#{@flickr_auth.uid}"
    Please select a photo from your recent uploads.


  - if @sets && !@sets.empty?
    %p
      = bootstrap_form_tag(url: new_photo_path, method: :get, layout: :inline) do |f|
        = f.select :set, options_for_select(@sets, @current_set), label: "Choose a photo album"
        = hidden_field_tag :type, @type
        = hidden_field_tag :id, @id
        = f.submit "Search", class: "btn btn-success"

  - if @sets && @current_set
    %h2= @sets.key(@current_set)

  .row.pagination
    .col-md-12= page_entries_info @photos
    .col-md-12= will_paginate @photos

  .row
    - @photos.each do |photo|
      .col-md-2.col-6
        .card
          = link_to photos_path(photo: { source_id: photo.id, source: 'flickr' }, id: @id, type: @type ), method: :post do
            = image_tag(FlickRaw.url_z(photo), alt: photo.title, class: 'img img-card')
          .card-body= photo.title

  .row.pagination
    .col-md-12= will_paginate @photos
- else
  %h2.alert You must connect your account to Flickr to add photos.

  %p
    = link_to '/members/auth/flickr', class: :btn do
      = icon 'fab', 'flickr'
      connect to Flickr