Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
99d0d73136
|
@ -1,5 +1,5 @@
|
||||||
<ul ng-if="$ctrl.items">
|
<ul ng-if="$ctrl.items">
|
||||||
<li ng-repeat="item in $ctrl.items" ng-class="{'selected' : item.selected, 'included': item.included}">
|
<li ng-repeat="item in $ctrl.items" ng-class="{'selected' : item.selected && !item.excluded, 'included': item.included}">
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-auto class="actions">
|
<vn-auto class="actions">
|
||||||
<vn-icon icon="keyboard_arrow_up" ng-if="item.childs.length"
|
<vn-icon icon="keyboard_arrow_up" ng-if="item.childs.length"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-one class="description">
|
<vn-one class="description">
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-check vn-auto field="item.selected"
|
<vn-check vn-auto field="item.selected && !item.excluded"
|
||||||
on-change="$ctrl.select(item)">
|
on-change="$ctrl.select(item)">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<vn-one ng-dblclick="$ctrl.toggle(item)" class="text unselectable">
|
<vn-one ng-dblclick="$ctrl.toggle(item)" class="text unselectable">
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default class Treeview extends Component {
|
||||||
for (let i = 0; i < childs.length; i++) {
|
for (let i = 0; i < childs.length; i++) {
|
||||||
childs[i].included = false;
|
childs[i].included = false;
|
||||||
|
|
||||||
if ((node.selected || node.included && this.hasCheckedParents(childs[i])) && !childs[i].selected)
|
if (((node.selected || node.included && this.hasCheckedParents(childs[i])) && !childs[i].selected) && !node.excluded)
|
||||||
childs[i].included = true;
|
childs[i].included = true;
|
||||||
|
|
||||||
this.repaintDesc(childs[i]);
|
this.repaintDesc(childs[i]);
|
||||||
|
@ -107,6 +107,13 @@ export default class Treeview extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelection(item) {
|
onSelection(item) {
|
||||||
|
let canBeExcluded = this.hasCheckedChilds(item) || this.hasCheckedParents(item);
|
||||||
|
|
||||||
|
if (!item.selected && item.included && canBeExcluded)
|
||||||
|
item.excluded = true;
|
||||||
|
else
|
||||||
|
item.excluded = false;
|
||||||
|
|
||||||
item.selected = !item.selected;
|
item.selected = !item.selected;
|
||||||
|
|
||||||
if (item.selected && item.included)
|
if (item.selected && item.included)
|
||||||
|
|
|
@ -23,13 +23,30 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.toggleIsIncluded = async(zoneFk, geoFk) => {
|
Self.toggleIsIncluded = async(zoneFk, geoFk) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const geo = await models.ZoneTreeview.findById(geoFk);
|
||||||
const isIncluded = await Self.findOne({
|
const isIncluded = await Self.findOne({
|
||||||
where: {zoneFk, geoFk}
|
where: {zoneFk, geoFk}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasCheckedParents = await Self.rawSql(
|
||||||
|
`SELECT id
|
||||||
|
FROM vn.zoneTreeview zt
|
||||||
|
JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id
|
||||||
|
WHERE zt.lft < ? AND zt.rgt > ?`, [geo.lft, geo.rgt]
|
||||||
|
);
|
||||||
|
const hasCheckedChilds = await Self.rawSql(
|
||||||
|
`SELECT id
|
||||||
|
FROM vn.zoneTreeview zt
|
||||||
|
JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id
|
||||||
|
WHERE zt.lft > ? AND zt.rgt < ?`, [geo.lft, geo.rgt]
|
||||||
|
);
|
||||||
|
|
||||||
|
const isExcluded = hasCheckedParents.length || hasCheckedChilds.length;
|
||||||
|
|
||||||
if (isIncluded)
|
if (isIncluded)
|
||||||
return Self.destroyAll({zoneFk, geoFk});
|
return Self.destroyAll({zoneFk, geoFk});
|
||||||
else
|
else
|
||||||
return Self.upsert({zoneFk, geoFk});
|
return Self.upsert({zoneFk, geoFk, isIncluded: isExcluded});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,7 +78,8 @@ module.exports = Self => {
|
||||||
pt.depth,
|
pt.depth,
|
||||||
pt.sons,
|
pt.sons,
|
||||||
ti.id IS NOT NULL hasCheckedChilds,
|
ti.id IS NOT NULL hasCheckedChilds,
|
||||||
zi.geoFk IS NOT NULL AS selected
|
zi.geoFk IS NOT NULL AS selected,
|
||||||
|
zi.isIncluded AS excluded
|
||||||
FROM zoneTreeview pt
|
FROM zoneTreeview pt
|
||||||
LEFT JOIN vn.zoneIncluded zi
|
LEFT JOIN vn.zoneIncluded zi
|
||||||
ON zi.geoFk = pt.id AND zi.zoneFk = ?
|
ON zi.geoFk = pt.id AND zi.zoneFk = ?
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<vn-card class="summary">
|
<vn-card class="summary">
|
||||||
|
<h5>{{$ctrl.summary.name}}</h5>
|
||||||
<vn-vertical pad-medium>
|
<vn-vertical pad-medium>
|
||||||
<vn-auto>
|
|
||||||
<h5 text-center pad-small-v class="title">{{$ctrl.summary.name}}</h5>
|
|
||||||
</vn-auto>
|
|
||||||
<vn-horizontal pad-medium>
|
<vn-horizontal pad-medium>
|
||||||
<vn-one>
|
<vn-one>
|
||||||
<vn-label-value label="Id"
|
<vn-label-value label="Id"
|
||||||
|
|
Loading…
Reference in New Issue