Skip to content

Commit

Permalink
Merge branch 'unify-asset-selection-views' of github.com:seek4science…
Browse files Browse the repository at this point in the history
…/seek into fairdom_test
  • Loading branch information
Kevin De Pelseneer committed Aug 23, 2023
2 parents afd3a11 + 9b8185e commit f279e48
Show file tree
Hide file tree
Showing 29 changed files with 655 additions and 960 deletions.
127 changes: 126 additions & 1 deletion app/assets/javascripts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ $j(document).ready(function () {
event.preventDefault();
deselectChildren(this,$j(this).data("cb_parent_selector"))
})
$j("a.managed_by_toggle").click(function () {
toggleManagers(this,$j(this).data("managed_by_selector"))
})
$j("a.permissions_toggle").click(function () {
togglePermissions(this,$j(this).data("permissions_selector"),'')
})
$j("a.showPermissions").click(function () {
togglePermissions(this,$j(this).data("permissions_selector"),'show')
})
$j("a.hidePermissions").click(function () {
togglePermissions(this,$j(this).data("permissions_selector"),'hide')
})
$j("div.isa-tree-toggle-open").click(function () {
isaTreeShow(this,$j(this).data("cb_parent_selector"))
})
$j("div.isa-tree-toggle-close").click(function () {
isaTreeHide(this,$j(this).data("cb_parent_selector"))
})
$j("a.collapseChildren").click(function (event) {
event.preventDefault();
collapseRecursively($j(this).data("cb_parent_selector"))
})
$j("a.expandChildren").click(function (event) {
event.preventDefault();
expandRecursively($j(this).data("cb_parent_selector"))
})
$j(".hideBlocked").click(function (event) {
event.preventDefault();
hideBlocked($j(this).data("cb_parent_selector"),$j(this).data("blocked_selector"))
})
$j(".showBlocked").click(function (event) {
event.preventDefault();
showBlocked($j(this).data("cb_parent_selector"),$j(this).data("blocked_selector"))
})
})

function selectChildren(select_all_element,cb_parent_selector){
Expand All @@ -39,4 +73,95 @@ function checkRepeatedItems(checkbox_element) {
for(let element of repeated_elements){
element.checked = check
}
}
}

function toggleManagers(item,managed_by_selector) {
$j(managed_by_selector).toggle()
}

function togglePermissions(item,permissions_selector,state) {
switch(state){
case 'show':
$j(permissions_selector).show()
break
case 'hide':
$j(permissions_selector).hide()
break
default:
$j(permissions_selector).toggle()
}
}

function isaTreeShow(item,cb_parent_selector) {
let children_assets = $j('.isa-tree', $j(item).parents(cb_parent_selector))
if(cb_parent_selector.includes('split_button_parent')){
children_assets.splice(0, 1);
}
let keep_closed = []
for (let asset of children_assets) {
$j(asset).show()
for (let caret of $j('.isa-tree-toggle-close', $j(asset))){
if (caret.style.display == "none"){
keep_closed.push(caret)
}
}
}
$j($j('.isa-tree-toggle-open', $j(item).parents(cb_parent_selector))[0]).hide()
$j($j('.isa-tree-toggle-close', $j(item).parents(cb_parent_selector))[0]).show()

for (let caret of keep_closed){
isaTreeHide(caret,$j(caret).data("cb_parent_selector"))
}
}
function isaTreeHide(item,cb_parent_selector){
let children_assets = $j('.isa-tree', $j(item).parents(cb_parent_selector))
if(cb_parent_selector.includes('split_button_parent')){
children_assets.splice(0, 1);
}
for (let asset of children_assets) {
$j(asset).hide()
}
$j($j('.isa-tree-toggle-open', $j(item).parents(cb_parent_selector))[0]).show()
$j($j('.isa-tree-toggle-close', $j(item).parents(cb_parent_selector))[0]).hide()
}

function collapseRecursively(cb_parent_selector){
let children_assets = $j('[class^=isa-tree-toggle]', $j(cb_parent_selector))
for (let asset of children_assets) {
isaTreeHide(asset,$j(asset).data("cb_parent_selector"))
}
}

function expandRecursively(cb_parent_selector){
let children_assets = $j('[class^=isa-tree-toggle]', $j(cb_parent_selector))
for (let asset of children_assets) {
isaTreeShow(asset,$j(asset).data("cb_parent_selector"))
}
}

function hideBlocked(cb_parent_selector,blocked_selector){
let children_assets = $j(blocked_selector, $j(cb_parent_selector))
for (let asset of children_assets) {
//Items in isa tree
if($j($j(asset).parents('div.split_button_parent')).length>0) {
// Don't hide "parents" of non-blocked items
if (!$j('input[type=checkbox]', $j(asset).parent()).length > 0) {
$j($j(asset).parents('div.split_button_parent')[0]).hide()
}
//Items not in isa tree
} else {
$j(asset).hide()
}
}
}

function showBlocked(cb_parent_selector,blocked_selector){
let children_assets = $j(blocked_selector, $j(cb_parent_selector))
for (let asset of children_assets) {
if($j($j(asset).parents('div.split_button_parent')).length>0) {
$j($j(asset).parents('div.split_button_parent')[0]).show()
} else{
$j(asset).show()
}
}
}
6 changes: 5 additions & 1 deletion app/assets/stylesheets/publishing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ ul.item_for_decision {
border-left-color: $btn-success-bg;
}

&.not-publishable {
&.not-manageable {
border-left-color: $btn-warning-bg;
}

&.not-visible {
border-left-color: $btn-danger-bg;
}

&.already-published {
border-left-color: $gray-light;
}
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/sharing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
border-radius: 5px;
display: inline-block;
height: 25px;
cursor: default;
}
.parent-btn-dropdown {
padding: 2px 6px 10px 0px;
Expand Down
1 change: 1 addition & 0 deletions app/controllers/single_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class SinglePagesController < ApplicationController
include Seek::AssetsCommon
include Seek::Sharing::SharingCommon
include Seek::Publishing::PublishingCommon
include Seek::Data::SpreadsheetExplorerRepresentation

before_action :set_up_instance_variable
Expand Down
12 changes: 0 additions & 12 deletions app/helpers/assets_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,6 @@ def publishing_item_param(item)
"publish[#{item.class.name}][#{item.id}]"
end

def sharing_item_param(item)
if item.try(:is_isa?)
"share_isa[#{item.class.name}][#{item.id}]"
elsif (item.respond_to? (:investigations)) && (!item.investigations.any?)
"share_not_isa[#{item.class.name}][#{item.id}]"
elsif !item.respond_to? (:investigations)
"share_not_isa[#{item.class.name}][#{item.id}]"
else
"share_isa[#{item.class.name}][#{item.id}]"
end
end

def include_downloadable_item?(items)
has_downloadable_item = false
items.each do |item|
Expand Down
Loading

0 comments on commit f279e48

Please sign in to comment.