Added badge count for children in the Parents field and prevent loading Pages in Parents field if they don't have children

This commit is contained in:
Djamil Legato
2020-03-22 14:55:10 -07:00
parent 4010a42db4
commit 4921ac638e
7 changed files with 45 additions and 33 deletions

View File

@@ -4,8 +4,10 @@
1. [](#new) 1. [](#new)
* Added `has-children` flag in parent field data response * Added `has-children` flag in parent field data response
* Added `RESET` en lang string * Added `RESET` en lang string
* Added badge count for children in the Parents field
1. [](#bugfix) 1. [](#bugfix)
* Fixed parent field not working with regular pages * Fixed parent field not working with regular pages
* Prevent loading Pages in Parents field if they don't have children
# v1.10.0-rc.7 # v1.10.0-rc.7
## 03/05/2020 ## 03/05/2020

View File

@@ -51,8 +51,10 @@ export class Parents {
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
const label = $(`<span title="${item[config.labelKey]}" />`); const label = $(`<span title="${item[config.labelKey]}" />`);
const infoContainer = $('<span class="info-container" />');
const iconPrepend = $('<i />'); const iconPrepend = $('<i />');
const iconAppend = $('<i />'); const iconAppend = $('<i />');
const badge = $('<span class="badge" />');
const prependClasses = ['fa']; const prependClasses = ['fa'];
const appendClasses = ['fa']; const appendClasses = ['fa'];
@@ -72,12 +74,15 @@ export class Parents {
label.appendTo(frag); label.appendTo(frag);
// append icon // append icon
if (item.children || item.type === 'dir') { if (item.children || item['has-children']) {
appendClasses.push('fa-caret-right'); appendClasses.push('fa-caret-right');
badge.text(item.size || item.count || 0);
badge.appendTo(infoContainer);
} }
iconAppend.addClass(appendClasses.join(' ')); iconAppend.addClass(appendClasses.join(' '));
iconAppend.appendTo(frag); iconAppend.appendTo(infoContainer);
infoContainer.appendTo(frag);
return frag; return frag;
} }
@@ -110,7 +115,7 @@ export class Parents {
return callback(this.data); return callback(this.data);
} }
if (parent.type !== 'dir') { if (parent.type !== 'dir' || !parent['has-children']) {
return false; return false;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -52,6 +52,11 @@
color: white; color: white;
} }
.info-container {
display: flex;
align-items: center;
}
.fjs-list { .fjs-list {
list-style: none; list-style: none;
margin: 0; margin: 0;