From 3b5ee9700814d3902097d2ce19f473c16fad6147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 11 Jul 2018 21:41:35 +0200 Subject: [PATCH] prepare for multi actions --- .../theme/diazo_resources/static/main.css | 55 ++++++++++++++---- .../theme/diazo_resources/static/main.js | 57 ++++++++++++++++++- 2 files changed, 97 insertions(+), 15 deletions(-) diff --git a/src/pfwbged/theme/diazo_resources/static/main.css b/src/pfwbged/theme/diazo_resources/static/main.css index ebd8a95..5bfc9a2 100644 --- a/src/pfwbged/theme/diazo_resources/static/main.css +++ b/src/pfwbged/theme/diazo_resources/static/main.css @@ -139,6 +139,7 @@ div.table { } #content div.table div.table-top, +div.multi-actions, #content div.table p { margin: 0 0; padding: 5px 1ex; @@ -611,24 +612,39 @@ dl.portletFolderLinks dd { margin-top: 0; } -#portal-body td.colour-column { width: 1px; padding: 0; } +#content .portletItem table { + margin-bottom: 0; +} -#portal-body tr.row-state-published td.colour-column { background: #b54040; } -#portal-body tr.row-state-abandoned td.colour-column { background: #aaaaaa; } +#portal-body table.listing th, +#portal-body table.listing td { + vertical-align: middle; +} + +#portal-body th span.colour-column-head { display: block; width: 2rem; height: 2rem; padding: 0; } +#portal-body td.colour-column { width: 1ex; height: 1ex; padding: 0; } +#portal-body td.colour-column label { padding: 0.8rem; display: block; } +#portal-body td.colour-column input { } + +#portal-body tr.row-state-published td.colour-column { background: #b54040 !important; } +#portal-body tr.row-state-abandoned td.colour-column { background: #aaaaaa !important; } #portal-body tr.row-state-attributed td.colour-column { } -#portal-body tr.row-state-done td.colour-column { background: #62ae17; } -#portal-body tr.row-state-in-progress td.colour-column { background: #e38623; } +#portal-body tr.row-state-done td.colour-column { background: #62ae17 !important; } +#portal-body tr.row-state-in-progress td.colour-column { background: #e38623 !important; } #portal-body tr.row-state-refusal-requested td.colour-column { } -#portal-body tr.row-state-todo td.colour-column { background: #de0707; } -#portal-body tr.row-state-refused td.colour-column { background: #fe2707; } -#portal-body tr.row-state-answered td.colour-column { background: #62ae17; } +#portal-body tr.row-state-todo td.colour-column { background: #de0707 !important; } +#portal-body tr.row-state-refused td.colour-column { background: #fe2707 !important; } +#portal-body tr.row-state-answered td.colour-column { background: #62ae17 !important; } #portal-body tr.row-state-assigning td.colour-column.colour-column { background: #de0707;} -#portal-body tr.row-state-noaction td.colour-column { background: #aaaaaa; } -#portal-body tr.row-state-processing td.colour-column { background: #ff6600; } +#portal-body tr.row-state-noaction td.colour-column { background: #aaaaaa !important; } +#portal-body tr.row-state-processing td.colour-column { background: #ff6600 !important; } #portal-body tr.row-state-registering td.colour-column { } #portal-body tr.row-state-ready_to_sent td.colour-column { } -#portal-body tr.row-state-sent td.colour-column { background: #62ae17; } -#portal-body tr.row-state-writing td.colour-column { background: #e38623; } +#portal-body tr.row-state-sent td.colour-column { background: #62ae17 !important; } +#portal-body tr.row-state-writing td.colour-column { background: #e38623 !important; } + +#portal-body tr.selected td { background: #bbb; } +#portal-body tr.selected:hover td { background: #bbb; } #portal-advanced-search { @@ -928,3 +944,18 @@ table.listing td.icon-column { padding: 5px; border: 1px solid #666; } + +div.multi-actions button { + display: none; +} + +#portal-body div.ResultsOpinionsTable table th span.colour-column-head, +#portal-body div.ResultsOpinionsTable table td.colour-column label, +div#document-viewlets table th span.colour-column-head, +div#document-viewlets table td.colour-column label { + display: none; +} + +#portal-body div table tr.row-state-done td.colour-column label { + display: none; +} diff --git a/src/pfwbged/theme/diazo_resources/static/main.js b/src/pfwbged/theme/diazo_resources/static/main.js index f6c1067..cf0a922 100644 --- a/src/pfwbged/theme/diazo_resources/static/main.js +++ b/src/pfwbged/theme/diazo_resources/static/main.js @@ -12,13 +12,13 @@ $.pfwbged.prepareLinearNavigation = function () { /* prepare for linear navigation from document page to document page */ - var doc_links = $('table.listing:first').parent('.ResultsTasksTable, .ResultsTable').find('tr a').map( + var doc_links = $('table.listing:first').parent('.ResultsTasksTable, .ResultsTable, .ResultsDocumentsTable').find('tr a').map( function(a, b) { return $(b).attr('href'); }); var doc_tables = $('table.listing'); var i=0; for (i; i 0) { doc_links.push.apply(doc_links, links); @@ -63,6 +63,56 @@ } }; + $.pfwbged.prepareMultiActions = function () { + $('th span.colour-column-head').click(function(e) { + var $table = $(this).parents('table'); + $table.find('td.colour-column input').click(); + }); + $('td.colour-column input').change(function(e) { + if ($(this).prop('checked')) { + $(this).parents('tr').addClass('selected'); + } else { + $(this).parents('tr').removeClass('selected'); + } + $(this).parents('.portletItem').find('.multi-actions button').each(function(idx, elem) { + var action_status = $(elem).data('status'); + var action_type = $(elem).data('type'); + var selector = 'tr.selected.row-state-' + action_status; + if (action_type) { + selector = selector + '.row-type-' + action_type; + } + if ($(this).parents('.portletItem').find(selector).length) { + $(elem).show(); + } else { + $(elem).hide(); + } + }); + e.stopPropagation(); + return true; + }); + $('.multi-actions button').on('click', function() { + var $div = $(this).parent(); + var url = $(this).parent().data('actions-url'); + var action = $(this).data('action'); + var action_status = $(this).data('status'); + var documents = Array(); + $(this).parents('.ResultsTasksTable, .ResultsDocumentsTable, .ResultsTable').find('tr.selected.row-state-' + action_status + ' input').each(function(idx, elem) { + documents.push($(elem).data('value')); + }); + $div.find('button').prop('disabled', true); + $.post(url, {'action': action, 'documents': documents } + ).done(function() { + console.log('success'); + window.location.reload(true); + }).fail(function() { + console.log('fail'); + }).always(function() { + $div.find('button').prop('disabled', false); + }); + }); + } + + $(document).on('form-submit-validate', function(e, data, form) { /* before the form gets submitted to the server, we disable form buttons */ $(form).find('.button-field').prop('disabled', 'disabled'); @@ -112,7 +162,7 @@ $(function() { return false; }); var xhr_preview = null; - $('.ResultsTasksTable tr a, .ResultsTable tr a').hover(function() { + $('.ResultsTasksTable tr a, .ResultsDocumentsTable tr a, .ResultsTable tr a').hover(function() { $('#preview-doc').remove(); xhr_preview = $.getJSON($(this).attr('href') + '/@@preview', function (data) { @@ -131,5 +181,6 @@ $(function() { $.pfwbged.prepareLinearNavigation(); $.pfwbged.doLinearNavigation(); + $.pfwbged.prepareMultiActions(); });