@nyaruka/temba-components 0.94.0 → 0.94.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/temba-components.js +64 -55
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/contactsearch/ContactSearch.js +83 -58
- package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
- package/package.json +1 -1
- package/src/contactsearch/ContactSearch.ts +86 -61
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.94.2](https://github.com/nyaruka/temba-components/compare/v0.94.1...v0.94.2)
|
|
8
|
+
|
|
9
|
+
- Fix init exclusions for contact search [`#438`](https://github.com/nyaruka/temba-components/pull/438)
|
|
10
|
+
|
|
11
|
+
#### [v0.94.1](https://github.com/nyaruka/temba-components/compare/v0.94.0...v0.94.1)
|
|
12
|
+
|
|
13
|
+
> 26 June 2024
|
|
14
|
+
|
|
15
|
+
- Don't show contact filter menu with no options [`1ced446`](https://github.com/nyaruka/temba-components/commit/1ced446f385c0cf4f5ccf864bfd4019c77ddd3cb)
|
|
16
|
+
|
|
7
17
|
#### [v0.94.0](https://github.com/nyaruka/temba-components/compare/v0.93.3...v0.94.0)
|
|
8
18
|
|
|
19
|
+
> 25 June 2024
|
|
20
|
+
|
|
9
21
|
- Improvements to contact search [`#437`](https://github.com/nyaruka/temba-components/pull/437)
|
|
10
22
|
- Show contact search exclusions as filters [`98cf90e`](https://github.com/nyaruka/temba-components/commit/98cf90e74a5ca4017998c52284251ddf07268b4a)
|
|
11
23
|
- Allow filter by various activity levels [`8928b7b`](https://github.com/nyaruka/temba-components/commit/8928b7bf3bd018fa53ec1a9c3e4f8b551d4289d6)
|
package/dist/temba-components.js
CHANGED
|
@@ -2762,7 +2762,7 @@ let ir=Is,or=!1;const nr=["es","fr","pt"],{setLocale:sr}=(t=>(function(t){if(or)
|
|
|
2762
2762
|
border: 1px solid var(--color-borders);
|
|
2763
2763
|
border-radius: var(--curvature);
|
|
2764
2764
|
}
|
|
2765
|
-
`}refresh(){this.refreshKey="requested_"+(new Date).getTime()}updated(t){super.updated(t),t.has("advanced")&&this.advanced||(t.has("in_a_flow")&&!this.in_a_flow&&(delete this.exclusions.in_a_flow,this.requestUpdate("exclusions")),(t.has("query")&&this.advanced||t.has("refreshKey")&&"0"!==this.refreshKey)&&(this.summary=null,this.fireCustomEvent(Oe.ContentChanged,{reset:!0}),this.lastQuery&&(window.clearTimeout(this.lastQuery),this.fetching=!1),(this.query.trim().length>0||this.recipients.length>0)&&(this.fetching=!0,this.lastQuery=window.setTimeout((()=>{this.fetchSummary()}),2e3))))}fetchSummary(){if(this.endpoint){const t=this.recipients.filter((t=>"group"===t.type)).map((t=>t.id)),e=this.recipients.filter((t=>"contact"===t.type)).map((t=>t.id));Kt(this.endpoint,{include:this.advanced?{query:this.query}:{contact_uuids:e,group_uuids:t},exclude:this.exclusions}).then((t=>{this.fetching=!1,200===t.status?(this.summary=t.json,this.advanced||(this.query=this.summary.query),this.setValue({advanced:this.advanced,query:this.query,exclusions:this.exclusions,recipients:this.recipients}),this.summary.error?this.errors=[this.summary.error]:this.errors=[],this.requestUpdate("errors"),this.fireCustomEvent(Oe.ContentChanged,this.summary)):(this.summary=t.json,this.summary.error&&(this.errors=[this.summary.error]),this.requestUpdate("errors"),this.fireCustomEvent(Oe.ContentChanged,this.summary))}))}}handleAdvancedToggle(t){re(t),this.recipients=[],this.exclusions={},this.advanced&&(this.query="",this.value=null),this.advanced=!this.advanced,this.setValue({advanced:this.advanced,query:this.query,exclusions:this.exclusions,recipients:this.recipients})}handleQueryChange(t){const e=t.target;this.query=e.inputElement.value}handleRecipientsChanged(){"0"!==this.refreshKey||this.initialized?this.refresh():this.initialized=!0}handleActivityLevelChanged(t){const e=t.target.values[0];e&&this.exclusions.not_seen_since_days&&(this.exclusions.not_seen_since_days=parseInt(e.value),this.refresh())}handleActivityLabelClicked(t){if(t.target&&"TEMBA-CHECKBOX"!==t.target.tagName&&"TEMBA-SELECT"!==t.target.tagName&&!t.target.disabled){const e=t.currentTarget.querySelector("temba-checkbox");e.checked=!e.checked}}handleExclusionChanged(t){if("TEMBA-CHECKBOX"===t.target.tagName){const e=JSON.stringify(this.exclusions),i=t.target;let o=i.checked;if("not_seen_since_days"===i.name&&o){const t=i.parentElement.querySelector("temba-select");t.values[0]
|
|
2765
|
+
`}refresh(){this.refreshKey="requested_"+(new Date).getTime()}updated(t){super.updated(t),t.has("advanced")&&this.advanced||(t.has("in_a_flow")&&!this.in_a_flow&&(delete this.exclusions.in_a_flow,this.requestUpdate("exclusions")),(t.has("query")&&this.advanced||t.has("refreshKey")&&"0"!==this.refreshKey)&&(this.summary=null,this.fireCustomEvent(Oe.ContentChanged,{reset:!0}),this.lastQuery&&(window.clearTimeout(this.lastQuery),this.fetching=!1),(this.query.trim().length>0||this.recipients.length>0)&&(this.fetching=!0,this.lastQuery=window.setTimeout((()=>{this.fetchSummary()}),2e3))))}fetchSummary(){if(this.endpoint){const t=this.recipients.filter((t=>"group"===t.type)).map((t=>t.id)),e=this.recipients.filter((t=>"contact"===t.type)).map((t=>t.id));if(0===t.length&&0===e.length)return this.summary&&(this.summary.total=0),void(this.fetching=!1);Kt(this.endpoint,{include:this.advanced?{query:this.query}:{contact_uuids:e,group_uuids:t},exclude:this.exclusions}).then((t=>{this.fetching=!1,this.initialized=!0,200===t.status?(this.summary=t.json,this.advanced||(this.query=this.summary.query),this.setValue({advanced:this.advanced,query:this.query,exclusions:this.exclusions,recipients:this.recipients}),this.summary.error?this.errors=[this.summary.error]:this.errors=[],this.requestUpdate("errors"),this.fireCustomEvent(Oe.ContentChanged,this.summary)):(this.summary=t.json,this.summary.error&&(this.errors=[this.summary.error]),this.requestUpdate("errors"),this.fireCustomEvent(Oe.ContentChanged,this.summary))}))}}handleAdvancedToggle(t){re(t),this.recipients=[],this.exclusions={},this.advanced&&(this.query="",this.value=null),this.advanced=!this.advanced,this.setValue({advanced:this.advanced,query:this.query,exclusions:this.exclusions,recipients:this.recipients})}handleQueryChange(t){const e=t.target;this.query=e.inputElement.value}handleRecipientsChanged(){"0"!==this.refreshKey||this.initialized?this.refresh():this.initialized=!0}handleActivityLevelChanged(t){const e=t.target.values[0];e&&this.exclusions.not_seen_since_days&&(this.exclusions.not_seen_since_days=parseInt(e.value),this.refresh())}handleActivityLabelClicked(t){if(t.target&&"TEMBA-CHECKBOX"!==t.target.tagName&&"TEMBA-SELECT"!==t.target.tagName&&!t.target.disabled){const e=t.currentTarget.querySelector("temba-checkbox");e.checked=!e.checked}}handleExclusionChanged(t){if("TEMBA-CHECKBOX"===t.target.tagName){const e=JSON.stringify(this.exclusions),i=t.target;let o=i.checked;if("not_seen_since_days"===i.name&&o){const t=i.parentElement.querySelector("temba-select");o=t.values[0]?parseInt(t.values[0].value):this.exclusions[i.name]}o?this.exclusions[i.name]=o:delete this.exclusions[i.name],e!==JSON.stringify(this.exclusions)&&this.refresh()}}render(){let t;if(this.summary&&!this.summary.error){const e=this.summary.total||0;t=j`
|
|
2766
2766
|
<div class="result-count">
|
|
2767
2767
|
Found
|
|
2768
2768
|
<a
|
|
@@ -2795,7 +2795,7 @@ let ir=Is,or=!1;const nr=["es","fr","pt"],{setLocale:sr}=(t=>(function(t){if(or)
|
|
|
2795
2795
|
</div>
|
|
2796
2796
|
</div>
|
|
2797
2797
|
</temba-button>
|
|
2798
|
-
`}return this.summary&&this.summary.blockers&&this.summary.blockers.length>0?j`${this.summary.blockers.map((t=>j`<temba-alert level="error">${pr(t)}</temba-alert>`))}`:j`
|
|
2798
|
+
`}const e=this.exclusions.not_seen_since_days;return this.summary&&this.summary.blockers&&this.summary.blockers.length>0?j`${this.summary.blockers.map((t=>j`<temba-alert level="error">${pr(t)}</temba-alert>`))}`:j`
|
|
2799
2799
|
${this.advanced?j`<div class="query">
|
|
2800
2800
|
<temba-textinput
|
|
2801
2801
|
.label=${this.label}
|
|
@@ -2827,71 +2827,80 @@ let ir=Is,or=!1;const nr=["es","fr","pt"],{setLocale:sr}=(t=>(function(t){if(or)
|
|
|
2827
2827
|
>
|
|
2828
2828
|
</temba-omnibox>
|
|
2829
2829
|
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
<temba-icon size="1" name="filter"></temba-icon>
|
|
2833
|
-
<div style="margin-left:0.5em">
|
|
2834
|
-
Only include contacts who...
|
|
2835
|
-
</div>
|
|
2836
|
-
</div>
|
|
2837
|
-
|
|
2838
|
-
${this.not_seen_since_days?j`
|
|
2830
|
+
${this.not_seen_since_days||this.in_a_flow||this.started_previously?j`
|
|
2831
|
+
<div class="filters">
|
|
2839
2832
|
<div
|
|
2840
|
-
|
|
2841
|
-
@click=${this.handleActivityLabelClicked}
|
|
2833
|
+
style="display:flex;font-size:1em;margin-bottom:0.5em"
|
|
2842
2834
|
>
|
|
2843
|
-
<temba-
|
|
2844
|
-
style="display:inline;"
|
|
2845
|
-
name="not_seen_since_days"
|
|
2846
|
-
@change=${this.handleExclusionChanged}
|
|
2847
|
-
>
|
|
2848
|
-
</temba-checkbox>
|
|
2849
|
-
|
|
2835
|
+
<temba-icon size="1" name="filter"></temba-icon>
|
|
2850
2836
|
<div style="margin-left:0.5em">
|
|
2851
|
-
|
|
2837
|
+
Only include contacts who...
|
|
2852
2838
|
</div>
|
|
2853
|
-
|
|
2854
|
-
<temba-select
|
|
2855
|
-
style="margin-left:0.5em"
|
|
2856
|
-
class="small-select"
|
|
2857
|
-
@change=${this.handleActivityLevelChanged}
|
|
2858
|
-
?disabled=${!this.exclusions.not_seen_since_days}
|
|
2859
|
-
>
|
|
2860
|
-
<temba-option
|
|
2861
|
-
name="90 days"
|
|
2862
|
-
value="90"
|
|
2863
|
-
></temba-option>
|
|
2864
|
-
<temba-option
|
|
2865
|
-
name="180 days"
|
|
2866
|
-
value="180"
|
|
2867
|
-
></temba-option>
|
|
2868
|
-
<temba-option name="Year" value="365"></temba-option>
|
|
2869
|
-
</temba-select>
|
|
2870
|
-
<div></div>
|
|
2871
2839
|
</div>
|
|
2872
|
-
`:null}
|
|
2873
|
-
${this.in_a_flow?j`<temba-checkbox
|
|
2874
|
-
name="in_a_flow"
|
|
2875
|
-
label="${ir("Are not currently in a flow")}"
|
|
2876
|
-
?checked=${this.exclusions.in_a_flow}
|
|
2877
|
-
@change=${this.handleExclusionChanged}
|
|
2878
|
-
></temba-checkbox>`:null}
|
|
2879
|
-
${this.started_previously?j`<temba-checkbox
|
|
2880
|
-
name="started_previously"
|
|
2881
|
-
label="${ir("Have not started this flow in the last 90 days")}"
|
|
2882
|
-
?checked=${this.exclusions.started_previously}
|
|
2883
|
-
@change=${this.handleExclusionChanged}
|
|
2884
|
-
></temba-checkbox>`:null}
|
|
2885
|
-
</div>`}
|
|
2886
|
-
</div>
|
|
2887
2840
|
|
|
2841
|
+
${this.not_seen_since_days?j`
|
|
2842
|
+
<div
|
|
2843
|
+
class="activity-select"
|
|
2844
|
+
@click=${this.handleActivityLabelClicked}
|
|
2845
|
+
>
|
|
2846
|
+
<temba-checkbox
|
|
2847
|
+
style="display:inline;"
|
|
2848
|
+
name="not_seen_since_days"
|
|
2849
|
+
?checked=${e}
|
|
2850
|
+
@change=${this.handleExclusionChanged}
|
|
2851
|
+
>
|
|
2852
|
+
</temba-checkbox>
|
|
2853
|
+
|
|
2854
|
+
<div style="margin-left:0.5em">
|
|
2855
|
+
${ir("Have sent a message in the last")}
|
|
2856
|
+
</div>
|
|
2857
|
+
|
|
2858
|
+
<temba-select
|
|
2859
|
+
style="margin-left:0.5em"
|
|
2860
|
+
class="small-select"
|
|
2861
|
+
@change=${this.handleActivityLevelChanged}
|
|
2862
|
+
?disabled=${!e}
|
|
2863
|
+
>
|
|
2864
|
+
<temba-option
|
|
2865
|
+
name="90 days"
|
|
2866
|
+
value="90"
|
|
2867
|
+
?selected=${90===e}
|
|
2868
|
+
></temba-option>
|
|
2869
|
+
<temba-option
|
|
2870
|
+
name="180 days"
|
|
2871
|
+
value="180"
|
|
2872
|
+
?selected=${180===e}
|
|
2873
|
+
></temba-option>
|
|
2874
|
+
<temba-option
|
|
2875
|
+
name="Year"
|
|
2876
|
+
value="365"
|
|
2877
|
+
?selected=${365===e}
|
|
2878
|
+
></temba-option>
|
|
2879
|
+
</temba-select>
|
|
2880
|
+
<div></div>
|
|
2881
|
+
</div>
|
|
2882
|
+
`:null}
|
|
2883
|
+
${this.in_a_flow?j`<temba-checkbox
|
|
2884
|
+
name="in_a_flow"
|
|
2885
|
+
label="${ir("Are not currently in a flow")}"
|
|
2886
|
+
?checked=${this.exclusions.in_a_flow}
|
|
2887
|
+
@change=${this.handleExclusionChanged}
|
|
2888
|
+
></temba-checkbox>`:null}
|
|
2889
|
+
${this.started_previously?j`<temba-checkbox
|
|
2890
|
+
name="started_previously"
|
|
2891
|
+
label="${ir("Have not started this flow in the last 90 days")}"
|
|
2892
|
+
?checked=${this.exclusions.started_previously}
|
|
2893
|
+
@change=${this.handleExclusionChanged}
|
|
2894
|
+
></temba-checkbox>`:null}
|
|
2895
|
+
</div>
|
|
2896
|
+
`:null} `}
|
|
2897
|
+
</div>
|
|
2888
2898
|
<div
|
|
2889
2899
|
class="results ${Vt({fetching:this.fetching,initialized:this.initialized||this.fetching,empty:(this.summary&&this.summary.error||!this.summary)&&!this.fetching})}"
|
|
2890
2900
|
>
|
|
2891
2901
|
<temba-loading units="6" size="8"></temba-loading>
|
|
2892
2902
|
<div class="summary ${this.expanded?"expanded":""}">${t}</div>
|
|
2893
2903
|
</div>
|
|
2894
|
-
|
|
2895
2904
|
${this.summary&&this.summary.warnings?this.summary.warnings.map((t=>j`<temba-alert level="warning"
|
|
2896
2905
|
>${pr(t)}</temba-alert
|
|
2897
2906
|
>`)):""}
|