Skip to content

Commit

Permalink
Introduce workflow overviews
Browse files Browse the repository at this point in the history
Towards #114
  • Loading branch information
lmrodriguezr committed Apr 10, 2023
1 parent 2f7c599 commit 0c1a091
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 12 deletions.
6 changes: 5 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

$theme-colors: (
"primary": indigo,
"secondary": slategrey
"secondary": slategrey,
"info": rgb(23, 162, 184)
// TODO: color update
// "primary": rgb(38, 104, 153),
// "info": rgb(23, 172, 184)
);

@import "bootstrap";
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

.bg-dark-ce {
background-color: #322348 !important;
// TODO: color update
// background-color: theme-color-level(primary, 7) !important;
}
.bg-vdark-ce {
background-color: #221831 !important;
// TODO: color update
// background-color: theme-color-level(primary, 9) !important;
}

.main-section {
Expand Down
28 changes: 26 additions & 2 deletions app/models/name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ def public?
status_hash[:public]
end

def after_claim?
status >= 5
end

def after_register?
register.present? || after_submission?
end

def after_submission?
status >= 10
end
Expand All @@ -383,6 +391,18 @@ def after_approval?
status >= 12
end

def after_notification?
validated? || register.try(:notified?)
end

def after_validation?
valid?
end

def after_register_publication?
register.try(:published?)
end

Name.status_hash.each do |k, v|
define_method("#{v[:symbol]}?") do
status == k
Expand Down Expand Up @@ -458,6 +478,10 @@ def can_see?(user)
(!user.nil?) && (user.curator? || user?(user))
end

def can_see_status?(user)
can_edit?(user) || can_claim?(user)
end

def can_edit?(user)
return false if only_display
return false if user.nil?
Expand Down Expand Up @@ -716,13 +740,13 @@ def add_to_register(register, user)
end

def notified?
register&.notified?
register.try(:notified?)
end

def priority_date
@priority_date ||= attribute(:priority_date)
if !@priority_date && seqcode?
@priority_date = register&.priority_date
@priority_date = register.try(:priority_date)
update_column(:priority_date, @priority_date)
end
@priority_date
Expand Down
2 changes: 1 addition & 1 deletion app/models/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def propose_title
end

def propose_doi
'10.57973/seqcode.%s' % accession
doi || ('10.57973/seqcode.%s' % accession)
end

def doi_url
Expand Down
28 changes: 20 additions & 8 deletions app/views/names/_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,26 @@

<dt><%= fa_icon 'calendar' %> Local history</dt>
<dd>
<% if @name.created_at == @name.updated_at %>
This name has not been modified since creation
<% else %>
This name was last modified
<u class="hover-help"
title="<%= @name.updated_at %>"
><%= time_ago_in_words(@name.updated_at) %> ago</u>
<% end %>
<ul>
<% if @name.created_at == @name.updated_at %>
<li>This name has not been modified since creation</li>
<% else %>
<li>
This name was last modified
<u class="hover-help"
title="<%= @name.updated_at %>"
><%= time_ago_in_words(@name.updated_at) %> ago</u>
</li>
<% end %>
<% if @workflow_modal_id ||= nil %>
<li>
<%= modal_button(@workflow_modal_id,
type: '', class: '', tag: 'a', href: '#') do %>
Current workflow status
<% end %>
</li>
<% end %>
</ul>
</dd>

<dt><%= fa_icon('user') %> Registered by</dt>
Expand Down
2 changes: 2 additions & 0 deletions app/views/names/_name.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
<% end %>
<% entry.footer do %>
<ul class='list-inline' style='margin: 0;'>
<!-- TODO: Link genome page instead
<li class='list-inline-item'>
<%= link_to name.ncbi_search_url, title: 'Search genomes', target: '_blank' do %>
<%= fa_icon 'dna' %>
<% end %>
</li>
-->
<li class='list-inline-item'>
<%= link_to name, title: 'See more' do %>
<%= fa_icon 'arrow-circle-right' %>
Expand Down
246 changes: 246 additions & 0 deletions app/views/names/_workflow.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
<% @workflow_modal_id = modal('Workflow status', size: 'xl') do %>
<%
@downstream = false
def workflow_step(title, test_fun)
test = @name.send(test_fun)
content_tag(:div, class: 'card my-2') do
title_class = 'text-' + (
@downstream ? 'muted' : test ? 'success' : 'info'
)
icon = @downstream ? 'circle' : test ? 'check-circle' : 'hand-point-right'
content_tag(:div, class: "card-header #{title_class}") do
fa_icon(icon, class: 'mr-3') + content_tag(:span, title)
end +
unless @downstream
@downstream ||= !test.present?
content_tag(:div, class: 'card-body') do
yield(test)
end
end
end
end
%>

<!-- 01: Name exists -->
<%= workflow_step('Initial registration', :present?) do |pass| %>
<% if pass %>
This name was first registered in the system on
<%= time_tag(@name.created_at, format: '%F') %>.
<% else %>
This should never happen!
<% end %>
<% end %>

<!-- 02: Name claimed -->
<%= workflow_step('User claim', :after_claim?) do |pass| %>
<% if pass %>
<% if @name.created_by %>
This name was successfully claimed by
<%= link_to(@name.created_by.username, @name.created_by) %>.
<% else %>
This name was automatically processed by the SeqCode Registry.
<% end %>
<% else %>
<h5 class="mt-2 text-info">Next step:</h5>
<ul>
<li>
This name has not been claimed yet. You can
<%= link_to(
'claim it now', claim_name_url(@name),
method: :post,
data: { confirm: 'Are you sure? This action cannot be undone' }
) %>.
</li>
</ul>
<% end %>
<% end %>

<!-- 03: Name in registry list -->
<%= workflow_step('Name in registry list', :after_register?) do |pass| %>
<% if pass %>
<% if @name.register %>
This name was added to the registry list
<%= link_to(@name.register.acc_url, @name.register) %>.
<% else %>
This name was registered by a mechanism parallel to registry lists.
<% end %>
<% else %>
This name has not been added to a registry list yet.
<h5 class="mt-2 text-info">Next step:</h5>
<ul>
<li>
<% if @name.can_edit?(current_user) %>
You can
<%= link_to(
'propose name by adding it to a registry list',
new_register_url(name: @name),
) %>.
<% else %>
You cannot currently propose name, since you don't have editing
privileges. If you want to gain editing privileges for this name,
please <%= link_to('contact us', page_connect_url) %>.
<% end %>
</li>
</ul>
<% end %>
<% end %>

<!-- 04: Name submitted -->
<%= workflow_step('Name submission', :after_submission?) do |pass| %>
<% if pass %>
This name was submitted for evaluation
<% if @name.submitted_by %>
by <%= link_to(@name.submitted_by.username, @name.submitted_by) %>
<% end %>
<% if @name.submitted_at %>
on <%= time_tag(@name.submitted_at, format: '%F') %>
<% end %>
<% if @name.register %>
as part of the registry list
<%= link_to(@name.register.acc_url, @name.register) %>.
<% else %>
by a mechanism parallel to registry lists.
<% end %>
<% else %>
This name has not been submitted yet.
<h5 class="mt-2 text-info">Next step:</h5>
<% if @name.register %>
<ol>
<li>
If the publication reporting this name is still in preparation
or undergoing peer-review, go to
<%= link_to(@name.register.acc_url, @name.register) %> and
click <b>Submit register list for evaluation</b> at the bottom of
the page. This is known in SeqCode as "Path 1".
</li>
<li>
If this name has already been published in a peer-reviewed outlet,
go to <%= link_to(@name.register.acc_url, @name.register) %> and
click <b>Notify about effective publication</b> at the bottom of
the page. This is known in SeqCode as "Path 2".
</li>
</ol>
<% else %>
<ul>
<li>
<!-- This is definitively a mistake! -->
<span class="text-danger">No actions are currently available.</span>
If you think this is a mistake, please
<%= link_to('contact us', page_connect_url) %>.
</li>
</ul>
<% end %>
<% end %>
<% end %>

<!-- 05: Name approved -->
<%= workflow_step('Name approval', :after_approval?) do |pass| %>
<% if pass %>
<% if @name.approved_by %>
This name was approved
<% if @name.approved_by %>
by <%= link_to(@name.approved_by.username, @name.approved_by) %>
<% end %>
<% if @name.approved_at %>
on <%= time_tag(@name.approved_at, format: '%F') %>
<% end %>
after manual review.
<% else %>
This name was marked as approved.
<% end %>
<% else %>
This name is yet to be approved.
<h5 class="mt-2 text-info">Next step:</h5>
<ul>
<li>
This name is currently undergoing manual curation by the SeqCode team,
and the submitter will be notified soon about the next steps. If you
want to inquire about the status of this submission, please
<%= link_to('contact us', page_connect_url) %>.
</li>
</ul>
<% end %>
<% end %>

<!-- 06: SeqCode notified -->
<%= workflow_step('SeqCode notification', :after_notification?) do |pass| %>
<% if pass %>
The SeqCode was notified
<% if @name.register&.notified_at %>
on <%= time_tag(@name.register.notified_at, format: '%F') %>
<% end %>
of effective publication of this name,
<% if @name.register %>
as part of the register list
<%= link_to(@name.register.acc_url, @name.register) %>.
<% else %>
through validation under another code of nomenclature.
<% end %>
<% else %>
The SeqCode has not been notified of effective publication yet.
<h5 class="mt-2 text-info">Next step:</h5>
<ul>
<li>
<% if @name.register %>
If this name has already been published in a peer-reviewed outlet,
go to <%= link_to(@name.register.acc_url, @name.register) %> and
click <b>Notify about effective publication</b> at the bottom of
the page. Otherwise, this name is reserved for up to a year or until
an effective publication becomes available and the SeqCode is
notified.
<% else %>
<!-- This is definitively a mistake! -->
<span class="text-danger">No actions are currently available.</span>
If you think this is a mistake, please
<%= link_to('contact us', page_connect_url) %>.
<% end %>
</li>
</ul>
<% end %>
<% end %>

<!-- 07: Name validated -->
<%= workflow_step('Name validation', :validated?) do |pass| %>
<% if pass %>
This name is validly published
<% if @name.priority_date %>
with priority date: <%= time_tag(@name.priority_date, format: '%F') %>.
<% else %>
but the SeqCode Registry does not have a priority date on file.
<% end %>
<% else %>
This name is not validly published yet.
<h5 class="mt-2 text-info">Next step:</h5>
<ul>
<li>
This name is currently undergoing manual curation by the SeqCode team,
and the submitter will be notified soon about the next steps. If you
want to inquire about the status of this submission, please
<%= link_to('contact us', page_connect_url) %>.
</li>
</ul>
<% end %>
<% end %>

<% unless @name.icnp? %>
<!-- 08: Registry list published -->
<%= workflow_step(
'Register list publication',
:after_register_publication?) do |pass| %>
<% if pass %>
The register list including this name was successfully published with
DOI: <%= link_to(@name.register.doi_url, @name.register.doi_url) %>.
<% else %>
<% end %>
<% end %>
<% end %>
<% end %>

<% if @name.can_see_status?(current_user) %>
<div class="text-center border-bottom mb-3 py-3">
<%= modal_button(@workflow_modal_id) do %>
<%= fa_icon('paper-plane') %>
See the current workflow status of this name
<% end %>
</div>
<% end %>
Loading

0 comments on commit 0c1a091

Please sign in to comment.