mirror of
				https://github.com/scinote-eln/scinote-web.git
				synced 2025-10-28 07:00:24 +08:00 
			
		
		
		
	Add archived label to results dropdown and add link to results in shared tasks [SCI-12067]
This commit is contained in:
		
							parent
							
								
									6e78a3d1a6
								
							
						
					
					
						commit
						677d438f85
					
				
					 8 changed files with 32 additions and 7 deletions
				
			
		|  | @ -43,8 +43,6 @@ class MyModuleShareableLinksController < ApplicationController | ||||||
|     @results_order = params[:order] || 'new' |     @results_order = params[:order] || 'new' | ||||||
| 
 | 
 | ||||||
|     @results = @my_module.results.active |     @results = @my_module.results.active | ||||||
|     @results = @results.page(params[:page]).per(Constants::RESULTS_PER_PAGE_LIMIT) |  | ||||||
| 
 |  | ||||||
|     @results = case @results_order |     @results = case @results_order | ||||||
|                when 'old' then @results.order(created_at: :asc) |                when 'old' then @results.order(created_at: :asc) | ||||||
|                when 'old_updated' then @results.order(updated_at: :asc) |                when 'old_updated' then @results.order(updated_at: :asc) | ||||||
|  | @ -54,6 +52,15 @@ class MyModuleShareableLinksController < ApplicationController | ||||||
|                else @results.order(created_at: :desc) |                else @results.order(created_at: :desc) | ||||||
|                end |                end | ||||||
| 
 | 
 | ||||||
|  |     if params[:result_id].present? | ||||||
|  |       page = @results.find_page_number(params[:result_id].to_i, Constants::RESULTS_PER_PAGE_LIMIT) | ||||||
|  |       params[:result_id] = nil | ||||||
|  |     else | ||||||
|  |       page = params[:page] | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     @results = @results.page(page).per(Constants::RESULTS_PER_PAGE_LIMIT) | ||||||
|  | 
 | ||||||
|     @gallery = @results.left_joins(:assets).pluck('assets.id').compact |     @gallery = @results.left_joins(:assets).pluck('assets.id').compact | ||||||
| 
 | 
 | ||||||
|     @disable_smart_annotation_links = true |     @disable_smart_annotation_links = true | ||||||
|  |  | ||||||
|  | @ -105,9 +105,12 @@ | ||||||
|                   :key="result.id" |                   :key="result.id" | ||||||
|                   :title="result.name" |                   :title="result.name" | ||||||
|                   :href="resultUrl(result.id, result.archived)" |                   :href="resultUrl(result.id, result.archived)" | ||||||
|                   class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer block hover:no-underline text-sn-blue truncate" |                   class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer hover:no-underline text-sn-blue truncate flex items-center gap-2" | ||||||
|                 > |                 > | ||||||
|                   {{ result.name }} |                   {{ result.name }} | ||||||
|  |                   <div v-if="result.archived" class="py-1 px-2 text-xs ml-auto text-white bg-sn-grey rounded-full"> | ||||||
|  |                     {{ i18n.t('protocols.steps.archived_result') }} | ||||||
|  |                   </div> | ||||||
|                 </a> |                 </a> | ||||||
|               </div> |               </div> | ||||||
|               <template v-if="urls.update_url"> |               <template v-if="urls.update_url"> | ||||||
|  |  | ||||||
|  | @ -66,11 +66,11 @@ | ||||||
|             :data-object-type="result.attributes.type" |             :data-object-type="result.attributes.type" | ||||||
|             tabindex="0" |             tabindex="0" | ||||||
|           ></span> <!-- Hidden element to support legacy code --> |           ></span> <!-- Hidden element to support legacy code --> | ||||||
|           <tempplate v-if="result.attributes.steps.length == 0"> |           <template v-if="result.attributes.steps.length == 0"> | ||||||
|             <button v-if="urls.update_url" ref="linkButton" :title="i18n.t('my_modules.results.link_steps')" class="btn btn-light icon-btn" @click="this.openLinkStepsModal = true"> |             <button v-if="urls.update_url" ref="linkButton" :title="i18n.t('my_modules.results.link_steps')" class="btn btn-light icon-btn" @click="this.openLinkStepsModal = true"> | ||||||
|               {{ i18n.t('my_modules.results.link_to_step') }} |               {{ i18n.t('my_modules.results.link_to_step') }} | ||||||
|             </button> |             </button> | ||||||
|           </tempplate> |           </template> | ||||||
|           <GeneralDropdown v-else ref="linkedStepsDropdown"  position="right"> |           <GeneralDropdown v-else ref="linkedStepsDropdown"  position="right"> | ||||||
|             <template v-slot:field> |             <template v-slot:field> | ||||||
|               <button ref="linkButton" class="btn btn-light icon-btn" :title="i18n.t('my_modules.results.linked_steps')"> |               <button ref="linkButton" class="btn btn-light icon-btn" :title="i18n.t('my_modules.results.linked_steps')"> | ||||||
|  |  | ||||||
|  | @ -179,6 +179,8 @@ export default { | ||||||
|           this.nextPageUrl = response.data.links.next; |           this.nextPageUrl = response.data.links.next; | ||||||
|           this.loadingPage = false; |           this.loadingPage = false; | ||||||
| 
 | 
 | ||||||
|  |           this.infiniteScrollLoad(); | ||||||
|  | 
 | ||||||
|           if (this.anchorId) { |           if (this.anchorId) { | ||||||
|             const result = this.results.find((e) => e.id === this.anchorId); |             const result = this.results.find((e) => e.id === this.anchorId); | ||||||
|             if (!result) { |             if (!result) { | ||||||
|  |  | ||||||
|  | @ -79,6 +79,11 @@ class Result < ApplicationRecord | ||||||
|              .where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query) |              .where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |   def self.find_page_number(result_id, per_page = Kaminari.config.default_per_page) | ||||||
|  |     position = pluck(:id).index(result_id) | ||||||
|  |     (position.to_f / per_page).ceil | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   def duplicate(my_module, user, result_name: nil) |   def duplicate(my_module, user, result_name: nil) | ||||||
|     ActiveRecord::Base.transaction do |     ActiveRecord::Base.transaction do | ||||||
|       new_result = my_module.results.new( |       new_result = my_module.results.new( | ||||||
|  |  | ||||||
|  | @ -38,7 +38,14 @@ | ||||||
|           <ul id="ResultsMenuDropdown<%= step.id %>" class="dropdown-menu dropdown-menu-right px-4 py-2"> |           <ul id="ResultsMenuDropdown<%= step.id %>" class="dropdown-menu dropdown-menu-right px-4 py-2"> | ||||||
|             <% step.results.each do |result| %> |             <% step.results.each do |result| %> | ||||||
|               <li class="dropdown-item"> |               <li class="dropdown-item"> | ||||||
|                 <%= link_to result.name, shared_protocol_results_path(@shareable_link.uuid), class: "!py-2.5 !px-3 hover:!bg-sn-super-light-grey !cursor-pointer !block hover:!no-underline !text-sn-blue !truncate" %> |                 <%= link_to shared_protocol_results_path(@shareable_link.uuid, result_id: result.id, anchor: "resultContainer#{result.id}"), class: "!py-2.5 !px-3 hover:!bg-sn-super-light-grey !cursor-pointer hover:!no-underline !text-sn-blue !truncate !flex items-center gap-4 #{'disabled' if result.archived?}" do %> | ||||||
|  |                   <span class="leading-4"><%= result.name %></span> | ||||||
|  |                   <% if result.archived? %> | ||||||
|  |                     <div class="py-1 px-2 text-xs ml-auto text-white bg-sn-grey rounded-full "> | ||||||
|  |                       <%= I18n.t('protocols.steps.archived_result') %> | ||||||
|  |                     </div> | ||||||
|  |                   <% end %> | ||||||
|  |                 <% end %> | ||||||
|               </li> |               </li> | ||||||
|             <% end %> |             <% end %> | ||||||
|           </ul> |           </ul> | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| <div class="result-container bg-white p-4 mb-4 rounded"> | <div class="result-container bg-white p-4 mb-4 rounded" id="resultContainer<%= result.id %>"> | ||||||
|   <div class="result-header flex justify-between"> |   <div class="result-header flex justify-between"> | ||||||
|     <div class="result-head-left flex items-start flex-grow gap-4"> |     <div class="result-head-left flex items-start flex-grow gap-4"> | ||||||
|       <a class="result-collapse-link hover:no-underline focus:no-underline text-sn-black" href="#result-panel-<%= result.id %>" data-toggle="collapse"> |       <a class="result-collapse-link hover:no-underline focus:no-underline text-sn-black" href="#result-panel-<%= result.id %>" data-toggle="collapse"> | ||||||
|  |  | ||||||
|  | @ -4064,6 +4064,7 @@ en: | ||||||
|       timestamp: "Created on %{date} by %{user}" |       timestamp: "Created on %{date} by %{user}" | ||||||
|       timestamp_iso_html: "Created on <span class='iso-formatted-date'>%{date}</span> by %{user}" |       timestamp_iso_html: "Created on <span class='iso-formatted-date'>%{date}</span> by %{user}" | ||||||
|       manage_links: "Manage links" |       manage_links: "Manage links" | ||||||
|  |       archived_result: "Archived" | ||||||
|       link_results: "Link results to this step" |       link_results: "Link results to this step" | ||||||
|       linked_results: "Linked results" |       linked_results: "Linked results" | ||||||
|       status: |       status: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue