Skip to content

Commit 4ca96eb

Browse files
committed
css grids replaced tables, json views remade, datetime filter fixed
1 parent 0ee4a10 commit 4ca96eb

29 files changed

+447
-444
lines changed

assets/functions.js

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
let currentItem;
55
if (addr.includes("/docs")) {
66
currentItem = document.querySelector("#textmenu a[href^='/docs']");
7-
if (currentItem) currentItem.classList.add("chosenmenu");
87
} else if (addr.includes("/team")) {
98
currentItem = document.querySelector("#textmenu a[href^='/team']");
10-
if (currentItem) currentItem.classList.add("chosenmenu");
119
} else if (addr.includes("/task")) {
1210
currentItem = document.querySelector("#textmenu a[href^='/task']");
13-
if (currentItem) currentItem.classList.add("chosenmenu");
1411
}
12+
if (currentItem) currentItem.classList.add("chosenmenu");
1513
})();
1614

1715
/* Translates the page - aka i18n */
@@ -59,7 +57,8 @@ function translateAll(rootElem, lang) {
5957
if (c0 == '+' && s.charAt(0) != '+') s = '+ ' + s;
6058
if (c0 == '×' && s.charAt(0) != '×') s = '× ' + s;
6159
if (c1 == ':' && c2 != '*' && s.charAt(s.length - 1) != ':') {s += ':';
62-
} else if (c1 == ':' && c2 == '*' && s.charAt(s.length - 2) != '*') {s += '*:';}
60+
} else if (c1 == ':' && c2 == '*' && s.charAt(s.length - 2) != '*') {s += '*:';
61+
} else if (c1 == ' ' && c2 == ':') {s += ': ';}
6362
return s;
6463
}
6564

@@ -301,31 +300,48 @@ function processTableSelection(removeAllowed) {
301300
const checkhead = document.getElementById('chead');
302301
const checkboxes = document.querySelectorAll('input[class="chbox"]');
303302
const styleRoot = getComputedStyle(document.body);
303+
const tableEvenRowBkgColor = styleRoot.getPropertyValue('--defaultBackgroundColor');
304304
const tableOddRowBkgColor = styleRoot.getPropertyValue('--tableOddRowBkgColor');
305305
const tableSelectionColor = styleRoot.getPropertyValue('--tableSelectionColor');
306306
const cbListLength = checkboxes.length;
307307
const deleteButton = document.getElementById('deleteButton');
308308
const statusButtons = document.querySelectorAll('input[class="sbut statusMultiControl"]');
309+
310+
document.getElementById("mainTable").addEventListener("click", function (event) {
311+
if (event.target.classList.contains('grideven') || event.target.classList.contains('gridodd')) {
312+
let id = (+event.target.classList[0].split('-')[1]);
313+
let cb = document.getElementById(id);
314+
cb.checked = !cb.checked;
315+
checkOne(cb.checked, '.' + cb.parentNode.classList[0]);
316+
}
317+
});
309318

310319
for (let i = 0; i < cbListLength; i++) {
311320
let cb = checkboxes[i];
312321
cb.onclick = function() {
313-
let state = cb.checked;
314-
let currentRow = this.parentNode.parentNode;
315-
if (state) {
316-
currentRow.style.backgroundColor = tableSelectionColor;
317-
if (removeAllowed) deleteButton.disabled = false;
318-
if (statusButtons) statusButtons.forEach(btn => btn.disabled = false);
322+
checkOne(this.checked, '.' + this.parentNode.classList[0]);
323+
};
324+
}
325+
326+
function checkOne(state, currentRowClass) {
327+
if (state) {
328+
changeRowBkgColor(currentRowClass, true);
329+
if (removeAllowed) deleteButton.disabled = false;
330+
if (statusButtons) statusButtons.forEach(btn => btn.disabled = false);
331+
} else {
332+
processAllCBDisabledCheckup();
333+
changeRowBkgColor(currentRowClass, false);
334+
}
335+
}
336+
337+
function changeRowBkgColor(classSelector, select){
338+
document.querySelectorAll(classSelector).forEach((elem) => {
339+
if (select) {
340+
elem.style.backgroundColor = tableSelectionColor;
319341
} else {
320-
processAllCBDisabledCheckup();
321-
currentRow.style.backgroundColor = "inherit";
322-
if (currentRow.rowIndex % 2 == 0) {
323-
currentRow.style.backgroundColor = "inherit";
324-
} else {
325-
currentRow.style.backgroundColor = tableOddRowBkgColor;
326-
}
342+
elem.style.backgroundColor = (elem.classList.contains('gridodd')) ? tableOddRowBkgColor : tableEvenRowBkgColor;
327343
}
328-
}
344+
});
329345
}
330346

331347
function processAllCBDisabledCheckup() {
@@ -340,42 +356,27 @@ function processTableSelection(removeAllowed) {
340356
}
341357

342358
checkhead.onclick = function() {
343-
let chstate = checkhead.checked;
344-
if (chstate) {
345-
checkAll();
346-
if (removeAllowed) deleteButton.disabled = false;
347-
if (statusButtons) statusButtons.forEach(btn => btn.disabled = false);
359+
if (checkhead.checked) {
360+
checkAll(true);
348361
} else {
349-
uncheckAll();
350-
if (removeAllowed) deleteButton.disabled = true;
351-
if (statusButtons) statusButtons.forEach(btn => btn.disabled = true);
362+
checkAll(false);
352363
}
353364
}
354365

355-
function checkAll() {
356-
checkboxes.forEach(function(cb) {
357-
cb.checked = true;
358-
let currentRow = cb.parentNode.parentNode;
359-
currentRow.style.backgroundColor = tableSelectionColor;
360-
});
361-
}
362-
363-
function uncheckAll() {
366+
function checkAll(select) {
367+
if (removeAllowed) deleteButton.disabled = !select;
368+
if (statusButtons) statusButtons.forEach(btn => btn.disabled = !select);
364369
checkboxes.forEach(function(cb) {
365-
cb.checked = false;
366-
let currentRow = cb.parentNode.parentNode;
367-
if (currentRow.rowIndex % 2 == 0) {
368-
currentRow.style.backgroundColor = "inherit";
369-
} else {
370-
currentRow.style.backgroundColor = tableOddRowBkgColor;
371-
}
370+
cb.checked = select;
371+
let currentRowClass = '.' + cb.parentNode.classList[0];
372+
changeRowBkgColor(currentRowClass, select);
372373
});
373374
}
374375

375376
}
376377

377378
/* Hides control buttons and disables checkboxes */
378-
function disableControlButtons() {
379+
function disableControlButtons(mainTablePresent) {
379380
document.getElementById('controlButtons').style.display = 'none';
380381
if (mainTablePresent) {
381382
const checkhead = document.getElementById('chead');
@@ -581,33 +582,38 @@ function applyTextFilter(searchPhrase) {
581582
}
582583

583584
/* Iterate over table data cells to insert a highlight tag */
584-
function highlightSearchResults(textFilter, columns) {
585+
function highlightSearchResults(textFilter) {
585586
textFilter = textFilter.toLowerCase().replace('<', '&lt;').replace('>', '&gt;');
586-
let tds;
587-
const tb = document.getElementById('mainTable');
588-
if (tb) {
589-
tds = tb.getElementsByTagName('td');
587+
let elems;
588+
const content = document.getElementById('mainTable');
589+
if (content) {
590+
elems = content.getElementsByClassName('textsearch');
590591
}
591-
if (textFilter && tds) {
592-
for (let td of tds) {
593-
if (columns.indexOf(td.cellIndex) !== -1) {
594-
td.innerHTML = insertCaseInsensitive(td.innerHTML.replace('&amp;', '&'), textFilter, '<span class="highlight">', '</span>');
595-
let subElems = td.children;
596-
for (let i = 0; i < subElems.length; i++) {
597-
subElems[i].classList.add('clampbig');
598-
}
599-
}
592+
if (textFilter && elems) {
593+
for (let elem of elems) {
594+
recursiveChildrenSearch(elem, textFilter);
600595
}
601596
}
602597
}
603598

599+
function recursiveChildrenSearch(elem, textFilter) {
600+
if (elem.children && elem.children.length > 0) {
601+
for (subelem of elem.children) {
602+
recursiveChildrenSearch(subelem, textFilter);
603+
}
604+
} else {
605+
if (elem.classList && elem.classList.contains('mobile')) return;
606+
elem.innerHTML = insertCaseInsensitive(elem.innerHTML.replace('&amp;', '&'), textFilter, '<span class="highlight">', '</span>');
607+
}
608+
}
609+
604610
/* Insert a highlight tag */
605611
function insertCaseInsensitive(srcStr, lowerCaseFilter, before, after) {
606612
let lowStr = srcStr.toLowerCase();
607613
let flen = lowerCaseFilter.length;
608614
let i = -1;
609615
while ((i = lowStr.indexOf(lowerCaseFilter, i + 1)) != -1) {
610-
if (insideTag(i, srcStr)) continue;
616+
//if (insideTag(i, srcStr)) continue;
611617
srcStr = srcStr.slice(0, i) + before + srcStr.slice(i, i+flen) + after + srcStr.slice(i+flen);
612618
lowStr = srcStr.toLowerCase();
613619
i += before.length + after.length;
@@ -694,8 +700,9 @@ function addSeekPagination(formID, filteredNum){
694700
addHiddenElem(frm, 'filteredNum', filteredNum);
695701
addHiddenElem(frm, 'previousPage', pageNumber);
696702
const mainTable = document.getElementById('mainTable');
697-
addHiddenElem(frm, 'firstElemOnPage', mainTable.rows[1].cells[1].innerText);
698-
addHiddenElem(frm, 'lastElemOnPage', mainTable.rows[mainTable.rows.length-1].cells[1].innerText);
703+
//console.log(mainTable.getElementsByClassName('firstcell')[0].lastElementChild.innerText, mainTable.getElementsByClassName('firstcell')[mainTable.getElementsByClassName('firstcell').length-1].lastElementChild.innerText);
704+
addHiddenElem(frm, 'firstElemOnPage', mainTable.getElementsByClassName('firstcell')[0].lastElementChild.innerText);
705+
addHiddenElem(frm, 'lastElemOnPage', mainTable.getElementsByClassName('firstcell')[mainTable.getElementsByClassName('firstcell').length-1].lastElementChild.innerText);
699706
}
700707
function processAddingFilters(frm, filters) {
701708

@@ -833,7 +840,7 @@ function printAppliedFilters(classFilterArr, dateFilterArr, sumFilterArr, textFi
833840
if (langCode != 'en') {
834841
timeout = 20;
835842
getLang(langCode).then(lang => {
836-
if (lang.appliedFilters) appliedFilters = lang.appliedFilters;
843+
if (lang.appliedFilters) appliedFilters = lang.appliedFilters + ": ";
837844
if (lang.noFiltersApplied) noFiltersApplied = lang.noFiltersApplied;
838845
if (lang.diapason) diapason = lang.diapason;
839846
runAllowed = true;
@@ -975,7 +982,7 @@ function processPagesCalculations(elemsOnPage, filteredNum) {
975982
}
976983

977984
function getElemsOnCurrentPage() {
978-
return document.getElementById('mainTable').getElementsByTagName('tr').length - 1;
985+
return document.getElementById('mainTable').getElementsByClassName('firstcell').length;
979986
}
980987

981988
/* Text formatting in multiline elements */

assets/i18n/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"totalElemsFound": "Total objects by search criteria",
8080
"onThisPage": "On this page",
8181
"totalPages": "Total pages",
82-
"appliedFilters": "Applied filters: ",
82+
"appliedFilters": "Applied filters",
8383
"noFiltersApplied": "No filters applied.",
8484
"seeAlso": "See also:",
8585

@@ -229,8 +229,8 @@
229229
"category": "Category",
230230
"docAbout": "About",
231231
"docSum": "Sum",
232-
"currencyLabel": "currency: ",
233-
"sumLabel": "sum: ",
232+
"currencyLabel": "currency",
233+
"sumLabel": "sum",
234234
"authors": "Authors",
235235
"addressees": "Addressees",
236236
"note": "Note",
@@ -255,7 +255,7 @@
255255
"myApprovals": "My approvals",
256256
"approvalBreak": "This will break any approval if present!",
257257
"approvalSign": [
258-
"For approval",
258+
"Pending",
259259
"Approved",
260260
"Rejected",
261261
"Broken"

assets/i18n/es.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"totalElemsFound": "Total de objetos por criterio de búsqueda",
8080
"onThisPage": "En esta página",
8181
"totalPages": "Total de páginas",
82-
"appliedFilters": "Filtros aplicados: ",
82+
"appliedFilters": "Filtros aplicados",
8383
"noFiltersApplied": "No se aplicaron filtros.",
8484
"seeAlso": "Ver también:",
8585

@@ -229,8 +229,8 @@
229229
"category": "Categoría",
230230
"docAbout": "Acerca de",
231231
"docSum": "Suma",
232-
"currencyLabel": "moneda: ",
233-
"sumLabel": "suma: ",
232+
"currencyLabel": "moneda",
233+
"sumLabel": "suma",
234234
"authors": "Autores",
235235
"addressees": "Destinatarios",
236236
"note": "Nota",
@@ -255,7 +255,7 @@
255255
"myApprovals": "Mis aprobaciones",
256256
"approvalBreak": "¡Esto romperá cualquier aprobación si está presente!",
257257
"approvalSign": [
258-
"Para aprobación",
258+
"Bajo aprobación",
259259
"Aprobado",
260260
"Rechazado",
261261
"Roto"

assets/i18n/fr.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"totalElemsFound": "Total des objets par critère de recherche",
8080
"onThisPage": "Sur cette page",
8181
"totalPages": "Pages totales",
82-
"appliedFilters": "Filtres appliqués: ",
82+
"appliedFilters": "Filtres appliqués",
8383
"noFiltersApplied": "Aucun filtre appliqué.",
8484
"seeAlso": "Voir également:",
8585

@@ -229,8 +229,8 @@
229229
"category": "Catégorie",
230230
"docAbout": "À propos",
231231
"docSum": "Somme",
232-
"currencyLabel": "devise: ",
233-
"sumLabel": "somme: ",
232+
"currencyLabel": "devise",
233+
"sumLabel": "somme",
234234
"authors": "Auteurs",
235235
"addressees": "Destinataires",
236236
"note": "Remarque",
@@ -255,7 +255,7 @@
255255
"myApprovals": "Mes approbations",
256256
"approvalBreak": "Cela cassera toute approbation si elle est présente!",
257257
"approvalSign": [
258-
"Pour approbation",
258+
"En cours",
259259
"Approuvé",
260260
"Rejeté",
261261
"Cassé"

assets/i18n/ru.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"totalElemsFound": "Всего объектов по критериям поиска",
8080
"onThisPage": "На этой странице",
8181
"totalPages": "Всего страниц",
82-
"appliedFilters": "Примененные фильтры: ",
82+
"appliedFilters": "Примененные фильтры",
8383
"noFiltersApplied": "Фильтры не применены.",
8484
"seeAlso": "См. также:",
8585

@@ -229,8 +229,8 @@
229229
"category": "Категория",
230230
"docAbout": "О чем",
231231
"docSum": "Сумма",
232-
"currencyLabel": "валюта: ",
233-
"sumLabel": "сумма: ",
232+
"currencyLabel": "валюта",
233+
"sumLabel": "сумма",
234234
"authors": "Авторы",
235235
"addressees": "Адресаты",
236236
"note": "Примечание",
@@ -255,7 +255,7 @@
255255
"myApprovals": "Мои согласования",
256256
"approvalBreak": "Это действие сбросит все согласования если они имеются!",
257257
"approvalSign": [
258-
"На согласование",
258+
"Ожидается",
259259
"Согласовано",
260260
"Отклонено",
261261
"Сброшено"

assets/manual-admin.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta http-equiv="X-UA-Compatible" content="ie=edge">
55
<title>EDM: User documentation</title>
66
<link rel="shortcut icon" href="favicon.png">
7+
<link rel="icon" href="favicon.png">
78
<link rel="stylesheet" href="fonts.css">
89
<link rel="stylesheet" href="system-rust.css">
910
</head>
@@ -21,9 +22,9 @@ <h1>Administrator documentation</h1>
2122
<p>Please, read <a href="manual.html">user documentation</a> before this administrator documentation in order to understand some basic concepts.</p>
2223

2324
<h2 class="margintop">Technical Description</h2>
25+
<p>The software should be installed on a server machine and configured to use a database management system selected by you.</p>
2426
<p>This software utilizes <a href="https://go.dev/">Go</a> programming language, <a href="https://github.com/alecxcode/sqla">sqla</a> module and drivers for each database type to directly connect to a database server.</p>
2527
<p>Probably all platforms where Go programming language is available are supported (Linux, Mac, Windows, etc.).</p>
26-
<p>The software should be installed on a server machine and configured to use a database management system selected by you.</p>
2728
<p>The following RDBMS are supported:</p>
2829
<ul>
2930
<li>SQLite</li>
@@ -94,6 +95,10 @@ <h2 class="margintop">Command line arguments</h2>
9495
<p><code>--filldb</code> - fill database with showcase data. Useful only for presentation and testing.</p>
9596
<p><code>--nobrowser</code> - the server should not run a browser on launch.</p>
9697
<p><code>--consolelog</code> - print messages to console instead of a log file.</p>
98+
99+
<h2 class="margintop">View pages as JSON</h2>
100+
<p>The program can display a responce in JSON format. It is applicable for almost any page. This might be useful for connecting this server to other services.</p>
101+
<p>To load a page as JSON use the following key and value in GET or POST request: <code>api=json</code>.</p>
97102

98103
<h2 class="margintop">Building from source</h2>
99104
<p>The simplest way to build the software is to run <code>go build</code> command, and then you can run <code>./edm</code> (<code>edm.exe</code> for windows) app in the current directory.</p>
@@ -115,7 +120,10 @@ <h3 class="margintop">Localization</h3>
115120
Frontend localization files are located in <b>assets/i18n</b> directory, and they contain a lot more strings, almost everything user interface language. Users can easily switch their interface language on settings page.
116121
</p>
117122
<p>To add a new language you need to create those two JSON files with the same structure as existing files. Language codes list is defined in <code>main()</code> function of the program. You need to add language code to the list, and rebuild the application. You also need to edit <b>config.tmpl</b> file to add a language name there.</p>
118-
119123
</div>
120-
<div id="bottom">© 2022 <a href="https://github.com/alecxcode/edm" target="_blank">EDM Project</a></div>
124+
<div id="bottom">
125+
<span>© 2022 <a href="https://github.com/alecxcode/edm" target="_blank">EDM Project</a></span>
126+
<span>v1.2.0.</span>
127+
<span><a href="/assets/manual.html">Manual</a></span>
128+
</div>
121129
</div></body></html>

0 commit comments

Comments
 (0)