fixed treeview order
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
687e000e60
commit
90092a4f48
|
@ -26,7 +26,7 @@ class Icon {
|
|||
Icon.$inject = ['$attrs'];
|
||||
|
||||
ngModule.component('vnIcon', {
|
||||
template: '<i class="{{::$ctrl.iconClass}}">{{::$ctrl.iconContent}}</i>',
|
||||
template: '<i class="{{::$ctrl.iconClass}} unselectable">{{::$ctrl.iconContent}}</i>',
|
||||
controller: Icon,
|
||||
bindings: {
|
||||
icon: '@'
|
||||
|
|
|
@ -2,6 +2,7 @@ vn-icon {
|
|||
display: inline-block;
|
||||
font-size: 18pt;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
|
||||
& > i,
|
||||
& > i.material-icons {
|
||||
|
|
|
@ -23,28 +23,6 @@ export default class Treeview extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
/* hasCheckedChilds(node) {
|
||||
if (!node.childs) return false;
|
||||
|
||||
const childs = node.childs;
|
||||
for (let i = 0; i < childs.length; i++) {
|
||||
if (childs[i].selected || this.hasCheckedChilds(childs[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hasCheckedParents(node) {
|
||||
if (!node.parent) return false;
|
||||
|
||||
const parent = node.parent;
|
||||
if (parent.selected || this.hasCheckedParents(parent))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
} */
|
||||
|
||||
onSelection(item, value) {
|
||||
this.emit('selection', {item, value});
|
||||
}
|
||||
|
@ -67,12 +45,15 @@ export default class Treeview extends Component {
|
|||
}
|
||||
|
||||
item.childs = newData.sort((a, b) => {
|
||||
let priority = (b.isIncluded - a.isIncluded) - 1;
|
||||
if (b.isIncluded !== a.isIncluded) {
|
||||
if (a.isIncluded == null)
|
||||
return 1;
|
||||
if (b.isIncluded == null)
|
||||
return -1;
|
||||
return b.isIncluded - a.isIncluded;
|
||||
}
|
||||
|
||||
if (b.name > a.name)
|
||||
priority++;
|
||||
|
||||
return priority;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -116,16 +116,7 @@ module.exports = Self => {
|
|||
const parentNodes = nodes.filter(element => {
|
||||
return element.depth === minorDepth;
|
||||
});
|
||||
|
||||
const sortedLeaves = parentNodes.sort((a, b) => {
|
||||
let priority = (b.isIncluded - a.isIncluded) - 1;
|
||||
|
||||
if (b.name > a.name)
|
||||
priority++;
|
||||
|
||||
return priority;
|
||||
});
|
||||
const leaves = Object.assign([], sortedLeaves);
|
||||
const leaves = Object.assign([], sortNodes(parentNodes));
|
||||
|
||||
nestLeaves(leaves);
|
||||
|
||||
|
@ -143,9 +134,23 @@ module.exports = Self => {
|
|||
&& element.depth === parent.depth + 1;
|
||||
});
|
||||
|
||||
return elements;
|
||||
return sortNodes(elements);
|
||||
}
|
||||
|
||||
return leaves;
|
||||
};
|
||||
|
||||
function sortNodes(nodes) {
|
||||
return nodes.sort((a, b) => {
|
||||
if (b.isIncluded !== a.isIncluded) {
|
||||
if (a.isIncluded == null)
|
||||
return 1;
|
||||
if (b.isIncluded == null)
|
||||
return -1;
|
||||
return b.isIncluded - a.isIncluded;
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue