mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-26 16:07:18 +02:00
Accomodate new contacts in flow chart
This commit is contained in:
parent
216d9a46ee
commit
d5ee875aef
3 changed files with 11 additions and 10 deletions
|
@ -306,7 +306,7 @@ class GetFlows extends \Civi\Api4\Generic\AbstractAction {
|
||||||
// Don't use exchange array so as not to gazump non-array data(?)
|
// Don't use exchange array so as not to gazump non-array data(?)
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'from_category_id' => (int) (($row['from_category_id']) ?: $defaultCategoryId),
|
'from_category_id' => (int) (($row['from_category_id'])), // ?: $defaultCategoryId,
|
||||||
'to_category_id' => (int) $row['to_category_id'],
|
'to_category_id' => (int) $row['to_category_id'],
|
||||||
'contact_count' => (int) $row['contact_count'],
|
'contact_count' => (int) $row['contact_count'],
|
||||||
];
|
];
|
||||||
|
|
|
@ -61,14 +61,14 @@
|
||||||
</g>
|
</g>
|
||||||
<!-- to-side labels -->
|
<!-- to-side labels -->
|
||||||
<g transform="translate({{$ctrl.sankey.iconWidth + $ctrl.sankey.snakeWidth}})">
|
<g transform="translate({{$ctrl.sankey.iconWidth + $ctrl.sankey.snakeWidth}})">
|
||||||
<rect ng-repeat="toAna in $ctrl.sankey.analysisArray"
|
<rect ng-repeat="toAna in $ctrl.sankey.analysisArray.slice(0, -1)"
|
||||||
x=0
|
x=0
|
||||||
y="{{toAna.y}}"
|
y="{{toAna.y}}"
|
||||||
width=16
|
width=16
|
||||||
height="{{toAna.toCatHeight}}"
|
height="{{toAna.toCatHeight}}"
|
||||||
fill="{{toAna.cat.color}}"
|
fill="{{toAna.cat.color}}"
|
||||||
></rect>
|
></rect>
|
||||||
<foreignobject ng-repeat="toAna in $ctrl.sankey.analysisArray"
|
<foreignobject ng-repeat="toAna in $ctrl.sankey.analysisArray.slice(0, -1)"
|
||||||
x="20" y="{{toAna.y}}" width="{{$ctrl.sankey.labelWidth}}" height="{{toAna.thisCatHeight}}">
|
x="20" y="{{toAna.y}}" width="{{$ctrl.sankey.labelWidth}}" height="{{toAna.thisCatHeight}}">
|
||||||
<span class=sankey-label style="display:block;color:{{toAna.cat.color}}">
|
<span class=sankey-label style="display:block;color:{{toAna.cat.color}}">
|
||||||
<i class="crm-i {{toAna.cat.icon}}" title="{{toAna.cat.label}}"></i>
|
<i class="crm-i {{toAna.cat.icon}}" title="{{toAna.cat.label}}"></i>
|
||||||
|
@ -91,9 +91,8 @@
|
||||||
x=0 y="{{toAna.y}}" width="{{$ctrl.sankey.iconWidth}}"
|
x=0 y="{{toAna.y}}" width="{{$ctrl.sankey.iconWidth}}"
|
||||||
height="{{toAna.thisCatHeight}}">
|
height="{{toAna.thisCatHeight}}">
|
||||||
<span class=sankey-label
|
<span class=sankey-label
|
||||||
title="{{toAna.previous}}"
|
|
||||||
style="display:block;text-align:center;color:{{toAna.cat.color}}"
|
style="display:block;text-align:center;color:{{toAna.cat.color}}"
|
||||||
><i class="crm-i {{toAna.cat.icon}}" title="{{toAna.cat.label}}"></i>
|
><i class="crm-i {{toAna.cat.icon}}" title="{{toAna.cat.label}} {{toAna.previous.toLocaleString()}}"></i>
|
||||||
</span>
|
</span>
|
||||||
</foreignobject>
|
</foreignobject>
|
||||||
</g>
|
</g>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
let flowsData = ctrl.changesOnly
|
let flowsData = ctrl.changesOnly
|
||||||
? allFlowsData.filter(({from_category_id, to_category_id}) => from_category_id != to_category_id)
|
? allFlowsData.filter(({from_category_id, to_category_id}) => from_category_id != to_category_id)
|
||||||
: allFlowsData;
|
: allFlowsData;
|
||||||
|
console.log("flowsData", flowsData, ctrl.catDefs);
|
||||||
|
|
||||||
ctrl.loading = false;
|
ctrl.loading = false;
|
||||||
const width = Math.max(600, document.querySelector('.contact-cats-sankey').clientWidth),
|
const width = Math.max(600, document.querySelector('.contact-cats-sankey').clientWidth),
|
||||||
|
@ -61,11 +62,11 @@
|
||||||
let totalContacts = 0;
|
let totalContacts = 0;
|
||||||
flowsData.forEach(row => {
|
flowsData.forEach(row => {
|
||||||
const {from_category_id, to_category_id, contact_count} = row;
|
const {from_category_id, to_category_id, contact_count} = row;
|
||||||
if (!from_category_id) {
|
// if (!from_category_id) {
|
||||||
// from nowhere: ignore for now.
|
// // from nowhere: ignore for now.
|
||||||
console.log("Skipping", row);
|
// console.log("Skipping", row);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
analysis[to_category_id].now += contact_count;
|
analysis[to_category_id].now += contact_count;
|
||||||
if (!catDefsIndexed[from_category_id]) {
|
if (!catDefsIndexed[from_category_id]) {
|
||||||
console.log("from_category_id", from_category_id, "not found in defs", catDefsIndexed);
|
console.log("from_category_id", from_category_id, "not found in defs", catDefsIndexed);
|
||||||
|
@ -192,6 +193,7 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
ctrl.catDefs.push({ id: 0, label: ts('New'), color: '#6cf66c', icon: 'fa-add', presentation_order: ctrl.catDefs.length, search_type:'new'});
|
||||||
ctrl.loading = false;
|
ctrl.loading = false;
|
||||||
ctrl.catDefs.forEach(cat => {catDefsIndexed[cat.id] = cat;});
|
ctrl.catDefs.forEach(cat => {catDefsIndexed[cat.id] = cat;});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue