Rows exanding xix

This commit is contained in:
karel.picman@lbcfree.net 2020-06-15 14:44:38 +02:00
parent 590b4ccb92
commit 9ead0389f8
7 changed files with 151 additions and 153 deletions

View File

@ -549,10 +549,10 @@ class DmsfFolder < ActiveRecord::Base
else
classes << 'dmsf-tree'
if type == 'folder'
classes << 'dmsf_collapsed'
classes << 'dmsf-collapsed'
classes << 'dmsf-not-loaded'
else
classes << 'dmsf_child'
classes << 'dmsf-child'
end
if title =~ /^\./
classes << 'dmsf-system'

View File

@ -79,8 +79,8 @@
var m = handle.attr("id").match(/^(\d+)span$/);
if(m){
$('.' + m[1]).remove();
handle.removeClass("dmsf_expanded");
handle.addClass("dmsf_collapsed dmsf-not-loaded");
handle.removeClass("dmsf-expanded");
handle.addClass("dmsf-collapsed dmsf-not-loaded");
}
ui.draggable.remove();
}

View File

@ -20,134 +20,98 @@
*/
/* Function to allow the projects to show up as a tree */
function dmsfToggle(EL, PM, url)
function dmsfToggle(el, id, url)
{
let els = document.querySelectorAll('tr.dmsf-tree');
let elsLen = els.length;
let pattern = new RegExp("(^|\\s)" + EL + "(\\s|$)");
let cpattern = new RegExp('span');
let expand = new RegExp('dmsf_expanded');
let collapse = new RegExp('dmsf_collapsed');
let hide = new RegExp('dmsf-hidden');
let spanid = PM;
let classid = new RegExp('junk');
// Expand not yet loaded selected row
let selectedRow = $(el).parents('tr').first();
let expand = $(selectedRow).hasClass('dmsf-collapsed');
if(selectedRow.hasClass('dmsf-child')){
return;
}
if(selectedRow.hasClass('dmsf-not-loaded')){
dmsfExpandRows(id, selectedRow, url);
}
if(expand) {
$(selectedRow).switchClass('dmsf-collapsed', 'dmsf-expanded');
}
else {
$(selectedRow).switchClass('dmsf-expanded', 'dmsf-collapsed');
}
// Hide collapsed rows and reset odd/even rows background colour
let oddeventoggle = 0;
// Expand not yet loaded selected row
let selectedRow = document.getElementById(PM);
$("tr.dmsf-tree").each(function(i, tr){
if(selectedRow.className.indexOf('dmsf-not-loaded') >= 0){
// Visiblity
if($(tr).hasClass(id)) {
dmsfExpandRows(EL, selectedRow, url);
}
if (expand) {
for(let i = 0; i < elsLen; i++)
{
if(cpattern.test(els[i].id))
{
let tmpspanid = spanid;
let tmpclassid = classid;
// Display only children with expanded parent
m = $(tr).attr('class').match(/(\d+) idnt/);
spanid = els[i].id;
classid = spanid;
let m = classid.match(/(\w+)span/);
if(m) {
classid = m[1];
}
classid = new RegExp(classid);
if(m){
if(tmpclassid.test(els[i].className) && (tmpspanid.toString() !== PM.toString()))
{
if(collapse.test(document.getElementById(tmpspanid).className))
{
spanid = tmpspanid;
classid = tmpclassid;
}
}
}
if($("#" + m[1] + "span").hasClass('dmsf-expanded')){
if(pattern.test(els[i].className))
{
let cnames = els[i].className;
cnames = cnames.replace(/dmsf-hidden/g,'');
if(expand.test(selectedRow.className))
{
cnames += ' dmsf-hidden';
}
else
{
if((spanid.toString() !== PM.toString()) && (classid.test(els[i].className)))
{
if(collapse.test(document.getElementById(spanid).className))
{
cnames += ' dmsf-hidden';
$(tr).removeClass('dmsf-hidden');
}
}
}
els[i].className = cnames;
} else {
if(!$(tr).hasClass('dmsf-hidden')) {
$(tr).addClass('dmsf-hidden');
}
}
}
if(!(hide.test(els[i].className)))
{
let cnames = els[i].className;
// Background
$(tr).removeClass('even');
$(tr).removeClass('odd');
cnames = cnames.replace(/odd/g,'');
cnames = cnames.replace(/even/g,'');
if (oddeventoggle === 0) {
if(oddeventoggle === 0)
{
cnames += ' odd';
}
else
{
cnames += ' even';
}
oddeventoggle ^= 1;
els[i].className = cnames;
$(tr).addClass('odd');
}
}
else {
if (collapse.test(selectedRow.className))
{
let cnames = selectedRow.className;
$(tr).addClass('even');
}
cnames = cnames.replace(/dmsf_collapsed/,'dmsf_expanded');
selectedRow.className = cnames;
}
else
{
let cnames = selectedRow.className;
cnames = cnames.replace(/dmsf_expanded/,'dmsf_collapsed');
selectedRow.className = cnames;
}
oddeventoggle ^= 1;
});
}
/* Add child rows */
function dmsfExpandRows(EL, parentRow, url) {
function dmsfExpandRows(id, parentRow, url) {
parentRow.className = parentRow.className.replace(/dmsf-not-loaded/, '');
$(parentRow).removeClass('dmsf-not-loaded');
let idnt = 0;
let pos = $(parentRow).find('.dmsf_position').text();
let classes = '';
let m = parentRow.className.match(/idnt-(\d+)/);
let m = $(parentRow).attr('class').match(/idnt-(\d+)/);
if(m){
idnt = m[1];
}
m = parentRow.className.match(/((\d|\s)+) idnt/);
m = $(parentRow).attr('class').match(/((\d|\s)+) idnt/);
if(m){
classes = m[1]
}
m = parentRow.id.match(/^(\d+)/);
m = $(parentRow).attr('id').match(/^(\d+)/);
if(m){
classes = classes + ' ' + m[1]
@ -158,17 +122,16 @@ function dmsfExpandRows(EL, parentRow, url) {
type: 'post',
dataType: 'html',
data: {
folder_id: EL,
row_id: parentRow.id,
folder_id: id,
row_id: $(parentRow).attr('id'),
idnt: idnt,
pos: pos,
classes: classes
}
}).done(function(data) {
// Hide the expanding icon if there are no childern
// Hide the expanding icon if there are no children
if(data.indexOf(' ' + m[1] + ' ') < 0){
$(parentRow).removeClass('dmsf_expanded');
$(parentRow).addClass('dmsf_child');
$(parentRow).removeClass('dmsf-expanded');
$(parentRow).addClass('dmsf-child');
}
else {
// Add child rows

View File

@ -0,0 +1,67 @@
/*
* Redmine plugin for Document Management System "Features"
*
* Copyright © 2011 Vit Jonas <vit.jonas@gmail.com>
* Copyright © 2011-20 Karel Pičman <karel.picman@kontron.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Intendation in the main view's tree */
.dmsf-tree.idnt-1 td.dmsf-title { padding-left: 2.5em; }
.dmsf-tree.idnt-2 td.dmsf-title { padding-left: 3em; }
.dmsf-tree.idnt-3 td.dmsf-title { padding-left: 3.5em; }
.dmsf-tree.idnt-4 td.dmsf-title { padding-left: 4em; }
.dmsf-tree.idnt-5 td.dmsf-title { padding-left: 4.5em; }
.dmsf-tree.idnt-6 td.dmsf-title { padding-left: 5em; }
.dmsf-tree.idnt-7 td.dmsf-title { padding-left: 5.5em; }
.dmsf-tree.idnt-8 td.dmsf-title { padding-left: 6em; }
.dmsf-tree.idnt-9 td.dmsf-title { padding-left: 6.5em; }
/* Font icons */
table.dmsf > tbody > tr > td a.icon-actions::before {
content: "\F1D8";
}
#sidebar ul > li > a.icon-only.icon-clear-query {
background-image: url(../../../images/close_hl.png);
background-repeat: no-repeat;
padding-left: 16px;
margin-left: 8px;
}
table.dmsf a.sort {
padding-right: 16px;
background-position: 100% 50%;
background-repeat: no-repeat;
}
table.dmsf a.sort.desc.icon.icon-sorted-asc {
background-image: url("../../../images/arrow_up.png") !important;
}
table.dmsf a.sort.asc.icon.icon-sorted-desc {
background-image: url("../../../images/arrow_down.png") !important;
}
/* Approval workflows */
#tab-content-dmsf_workflow table.list ~ p .button {
margin-top: 10px;
}
/* Query filters */
#query_form.dmsf-query-form .collapsed#filters {
opacity: 1;
}

View File

@ -214,25 +214,25 @@ div[id*="revision_access_"] {
/* DMSF tree view */
.dmsf-hidden { display:none; }
.dmsf-tree span.dmsf_expander { cursor: pointer; }
.dmsf-tree.dmsf_expanded td.dmsf-title span {
.dmsf-tree:not(.dmsf-child) span.dmsf_expander { cursor: pointer; }
.dmsf-tree.dmsf-expanded td.dmsf-title span {
background: url(../../../images/arrow_down.png) no-repeat 0 50%;
padding-left: 16px;
}
.dmsf-tree.dmsf_child .dmsf-title span { padding-left: 16px; }
.dmsf-tree.dmsf_collapsed .dmsf-title span {
.dmsf-tree.dmsf-child .dmsf-title span { padding-left: 16px; }
.dmsf-tree.dmsf-collapsed .dmsf-title span {
background: url(../../../images/arrow_right.png) no-repeat 0 50%;
padding-left: 16px;
}
.dmsf-tree.idnt-1 td.dmsf-title { padding-left: 2.5em; }
.dmsf-tree.idnt-2 td.dmsf-title { padding-left: 3em; }
.dmsf-tree.idnt-3 td.dmsf-title { padding-left: 3.5em; }
.dmsf-tree.idnt-4 td.dmsf-title { padding-left: 4em; }
.dmsf-tree.idnt-5 td.dmsf-title { padding-left: 4.5em; }
.dmsf-tree.idnt-6 td.dmsf-title { padding-left: 5em; }
.dmsf-tree.idnt-7 td.dmsf-title { padding-left: 5.5em; }
.dmsf-tree.idnt-8 td.dmsf-title { padding-left: 6em; }
.dmsf-tree.idnt-9 td.dmsf-title { padding-left: 6.5em; }
.dmsf-tree.idnt-1 td.dmsf-title { padding-left: 1.5em; }
.dmsf-tree.idnt-2 td.dmsf-title { padding-left: 2em; }
.dmsf-tree.idnt-3 td.dmsf-title { padding-left: 2.5em; }
.dmsf-tree.idnt-4 td.dmsf-title { padding-left: 3em; }
.dmsf-tree.idnt-5 td.dmsf-title { padding-left: 3.5em; }
.dmsf-tree.idnt-6 td.dmsf-title { padding-left: 4em; }
.dmsf-tree.idnt-7 td.dmsf-title { padding-left: 4.5em; }
.dmsf-tree.idnt-8 td.dmsf-title { padding-left: 5em; }
.dmsf-tree.idnt-9 td.dmsf-title { padding-left: 5.5em; }
.dmsf-select-version {
max-width: 50px;
@ -341,39 +341,3 @@ div[id*="revision_access_"] {
width: 90%;
max-width: 90%;
}
/* EasyExtensions - font icons */
table.dmsf > tbody > tr > td a.icon-actions::before {
content: "\F1D8";
}
#sidebar ul > li > a.icon-only.icon-clear-query {
background-image: url(../../../images/close_hl.png);
background-repeat: no-repeat;
padding-left: 16px;
margin-left: 8px;
}
table.dmsf a.sort {
padding-right: 16px;
background-position: 100% 50%;
background-repeat: no-repeat;
}
table.dmsf a.sort.desc.icon.icon-sorted-asc {
background-image: url("../../../images/arrow_up.png") !important;
}
table.dmsf a.sort.asc.icon.icon-sorted-desc {
background-image: url("../../../images/arrow_down.png") !important;
}
/* EasyExtensions - Approval workflows */
#tab-content-dmsf_workflow table.list ~ p .button {
margin-top: 10px;
}
/* EasyExtension - Query filters */
#query_form.dmsf-query-form .collapsed#filters {
opacity: 1;
}

View File

@ -26,11 +26,15 @@ module RedmineDmsf
def view_layouts_base_html_head(context={})
return unless /^(Dmsf|Projects|Issues)/.match?(context[:controller].class.name)
"\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', plugin: :redmine_dmsf) +
meta = "\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', plugin: :redmine_dmsf) +
"\n".html_safe + stylesheet_link_tag('select2.min.css', plugin: :redmine_dmsf) +
"\n".html_safe + javascript_include_tag('select2.min.js', plugin: :redmine_dmsf, defer: true) +
"\n".html_safe + javascript_include_tag('redmine_dmsf.js', plugin: :redmine_dmsf, defer: true) +
"\n".html_safe + javascript_include_tag('attachments_dmsf.js', plugin: :redmine_dmsf, defer: true)
if defined?(EasyExtensions)
meta = meta + "\n".html_safe + stylesheet_link_tag('easy_extensions.css', plugin: :redmine_dmsf)
end
meta
end
end

View File

@ -74,7 +74,7 @@ module RedmineDmsf
if item.deleted && (item.deleted > 0)
tag = content_tag('span', value, class: 'icon icon-folder')
else
tag = "<span class=\"dmsf_expander\" onclick=\"dmsfToggle('#{item.id}','#{item.id}span','#{escape_javascript(expand_folder_dmsf_path)}')\"></span>".html_safe +
tag = "<span class=\"dmsf_expander\" onclick=\"dmsfToggle(this, '#{item.id}','#{escape_javascript(expand_folder_dmsf_path)}')\"></span>".html_safe +
link_to(h(value),
dmsf_folder_path(id: item.project, folder_id: item.id),
class: 'icon icon-folder',