@nyaruka/temba-components 0.93.2 → 0.94.0

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.
@@ -9,6 +9,7 @@ import { FormElement } from '../FormElement';
9
9
  import { Checkbox } from '../checkbox/Checkbox';
10
10
  import { msg } from '@lit/localize';
11
11
  import { OmniOption } from '../omnibox/Omnibox';
12
+ import { Select } from '../select/Select';
12
13
 
13
14
  const QUEIT_MILLIS = 2000;
14
15
 
@@ -193,6 +194,37 @@ export class ContactSearch extends FormElement {
193
194
  temba-alert {
194
195
  margin: 1em 0;
195
196
  }
197
+
198
+ temba-select[name='not_seen_since_days'] {
199
+ margin-bottom: 1em;
200
+ display: block;
201
+ }
202
+
203
+ .activity-select {
204
+ display: flex;
205
+ align-items: center;
206
+ padding: var(--checkbox-padding, 10px);
207
+ border-radius: var(--curvature);
208
+ cursor: pointer;
209
+ }
210
+
211
+ .activity-select:hover {
212
+ background: #f9f9f9;
213
+ }
214
+
215
+ .small-select {
216
+ --temba-select-selected-padding: 0px 0.5em;
217
+ --temba-select-selected-line-height: 1em;
218
+ --temba-select-selected-font-size: 1em;
219
+ --search-input-height: 0px !important;
220
+ min-width: 100px;
221
+ }
222
+
223
+ .filters {
224
+ padding: 1em;
225
+ border: 1px solid var(--color-borders);
226
+ border-radius: var(--curvature);
227
+ }
196
228
  `;
197
229
  }
198
230
 
@@ -368,19 +400,48 @@ export class ContactSearch extends FormElement {
368
400
  }
369
401
  }
370
402
 
403
+ private handleActivityLevelChanged(evt: any) {
404
+ const select = evt.target as Select;
405
+ const option = select.values[0];
406
+ if (option) {
407
+ if (this.exclusions['not_seen_since_days']) {
408
+ this.exclusions['not_seen_since_days'] = parseInt(option.value);
409
+ this.refresh();
410
+ }
411
+ }
412
+ }
413
+
414
+ private handleActivityLabelClicked(evt: any) {
415
+ if (
416
+ evt.target &&
417
+ evt.target.tagName !== 'TEMBA-CHECKBOX' &&
418
+ evt.target.tagName !== 'TEMBA-SELECT' &&
419
+ !evt.target.disabled
420
+ ) {
421
+ const checkbox = evt.currentTarget.querySelector('temba-checkbox');
422
+ checkbox.checked = !checkbox.checked;
423
+ }
424
+ }
425
+
371
426
  private handleExclusionChanged(evt: any) {
372
427
  if (evt.target.tagName === 'TEMBA-CHECKBOX') {
373
428
  const ex = JSON.stringify(this.exclusions);
374
429
  const checkbox = evt.target as Checkbox;
375
430
  let value = checkbox.checked as any;
376
431
 
432
+ // if we check the activity box, look inside the select for the value
433
+ if (checkbox.name === 'not_seen_since_days' && value) {
434
+ const select = checkbox.parentElement.querySelector(
435
+ 'temba-select'
436
+ ) as Select;
437
+ if (select.values[0]) {
438
+ value = parseInt(select.values[0].value);
439
+ }
440
+ }
441
+
377
442
  if (!value) {
378
443
  delete this.exclusions[checkbox.name];
379
444
  } else {
380
- if (checkbox.name === 'not_seen_since_days') {
381
- value = 90;
382
- }
383
-
384
445
  this.exclusions[checkbox.name] = value;
385
446
  }
386
447
 
@@ -447,72 +508,106 @@ export class ContactSearch extends FormElement {
447
508
  }
448
509
 
449
510
  return html`
450
- ${this.advanced
451
- ? html`<div class="query">
452
- <temba-textinput
453
- .label=${this.label}
454
- .helpText=${this.helpText}
455
- .widgetOnly=${this.widgetOnly}
456
- .errors=${this.errors}
457
- name=${this.name}
458
- .inputRoot=${this}
459
- @input=${this.handleQueryChange}
460
- placeholder=${this.placeholder}
461
- .value=${this.query}
462
- textarea
463
- autogrow
464
- >
465
- </temba-textinput>
466
- </div>`
467
- : html`<temba-omnibox
468
- placeholder="Search for contacts or groups"
469
- widget_only=""
470
- groups=""
471
- contacts=""
472
- label="Recipients"
473
- help_text="The contacts to send the message to."
474
- .errors=${this.errors}
475
- id="recipients"
476
- name="recipients"
477
- .value=${this.recipients}
478
- endpoint="/contact/omnibox/?"
479
- @change=${this.handleRecipientsChanged}
480
- >
481
- </temba-omnibox>
482
-
483
- ${this.not_seen_since_days
484
- ? html`<temba-checkbox
485
- name="not_seen_since_days"
486
- label="${msg('Skip inactive contacts')}"
487
- help_text="${msg(
488
- 'Only include contacts who have sent a message in the last 90 days.'
489
- )}"
490
- ?checked=${this.exclusions['not_seen_since_days'] === 90}
491
- @change=${this.handleExclusionChanged}
492
- ></temba-checkbox>`
493
- : null}
494
- ${this.in_a_flow
495
- ? html`<temba-checkbox
496
- name="in_a_flow"
497
- label="${msg('Skip contacts currently in a flow')}"
498
- help_text="${msg(
499
- 'Avoid interrupting a contact who is already in a flow.'
500
- )}"
501
- ?checked=${this.exclusions['in_a_flow']}
502
- @change=${this.handleExclusionChanged}
503
- ></temba-checkbox>`
504
- : null}
505
- ${this.started_previously
506
- ? html`<temba-checkbox
507
- name="started_previously"
508
- label="${msg('Skip repeat contacts')}"
509
- help_text="${msg(
510
- 'Avoid restarting a contact who has been in this flow in the last 90 days.'
511
- )}"
512
- ?checked=${this.exclusions['started_previously']}
513
- @change=${this.handleExclusionChanged}
514
- ></temba-checkbox>`
515
- : null}`}
511
+ ${
512
+ this.advanced
513
+ ? html`<div class="query">
514
+ <temba-textinput
515
+ .label=${this.label}
516
+ .helpText=${this.helpText}
517
+ .widgetOnly=${this.widgetOnly}
518
+ .errors=${this.errors}
519
+ name=${this.name}
520
+ .inputRoot=${this}
521
+ @input=${this.handleQueryChange}
522
+ placeholder=${this.placeholder}
523
+ .value=${this.query}
524
+ textarea
525
+ autogrow
526
+ >
527
+ </temba-textinput>
528
+ </div>`
529
+ : html`<temba-omnibox
530
+ placeholder="Search for contacts or groups"
531
+ widget_only=""
532
+ groups=""
533
+ contacts=""
534
+ label="Recipients"
535
+ help_text="The contacts to send the message to."
536
+ .errors=${this.errors}
537
+ id="recipients"
538
+ name="recipients"
539
+ .value=${this.recipients}
540
+ endpoint="/contact/omnibox/?"
541
+ @change=${this.handleRecipientsChanged}
542
+ >
543
+ </temba-omnibox>
544
+
545
+ <div class="filters">
546
+ <div style="display:flex;font-size:1em;margin-bottom:0.5em">
547
+ <temba-icon size="1" name="filter"></temba-icon>
548
+ <div style="margin-left:0.5em">
549
+ Only include contacts who...
550
+ </div>
551
+ </div>
552
+
553
+ ${this.not_seen_since_days
554
+ ? html`
555
+ <div
556
+ class="activity-select"
557
+ @click=${this.handleActivityLabelClicked}
558
+ >
559
+ <temba-checkbox
560
+ style="display:inline;"
561
+ name="not_seen_since_days"
562
+ @change=${this.handleExclusionChanged}
563
+ >
564
+ </temba-checkbox>
565
+
566
+ <div style="margin-left:0.5em">
567
+ ${msg('Have sent a message in the last')}
568
+ </div>
569
+
570
+ <temba-select
571
+ style="margin-left:0.5em"
572
+ class="small-select"
573
+ @change=${this.handleActivityLevelChanged}
574
+ ?disabled=${!this.exclusions['not_seen_since_days']}
575
+ >
576
+ <temba-option
577
+ name="90 days"
578
+ value="90"
579
+ ></temba-option>
580
+ <temba-option
581
+ name="180 days"
582
+ value="180"
583
+ ></temba-option>
584
+ <temba-option name="Year" value="365"></temba-option>
585
+ </temba-select>
586
+ <div></div>
587
+ </div>
588
+ `
589
+ : null}
590
+ ${this.in_a_flow
591
+ ? html`<temba-checkbox
592
+ name="in_a_flow"
593
+ label="${msg('Are not currently in a flow')}"
594
+ ?checked=${this.exclusions['in_a_flow']}
595
+ @change=${this.handleExclusionChanged}
596
+ ></temba-checkbox>`
597
+ : null}
598
+ ${this.started_previously
599
+ ? html`<temba-checkbox
600
+ name="started_previously"
601
+ label="${msg(
602
+ 'Have not started this flow in the last 90 days'
603
+ )}"
604
+ ?checked=${this.exclusions['started_previously']}
605
+ @change=${this.handleExclusionChanged}
606
+ ></temba-checkbox>`
607
+ : null}
608
+ </div>`
609
+ }
610
+ </div>
516
611
 
517
612
  <div
518
613
  class="results ${getClasses({
@@ -527,14 +622,16 @@ export class ContactSearch extends FormElement {
527
622
  <div class="summary ${this.expanded ? 'expanded' : ''}">${summary}</div>
528
623
  </div>
529
624
 
530
- ${this.summary && this.summary.warnings
531
- ? this.summary.warnings.map(
532
- (warning) =>
533
- html`<temba-alert level="warning"
534
- >${unsafeHTML(warning)}</temba-alert
535
- >`
536
- )
537
- : ``}
625
+ ${
626
+ this.summary && this.summary.warnings
627
+ ? this.summary.warnings.map(
628
+ (warning) =>
629
+ html`<temba-alert level="warning"
630
+ >${unsafeHTML(warning)}</temba-alert
631
+ >`
632
+ )
633
+ : ``
634
+ }
538
635
  `;
539
636
  }
540
637
  }
package/src/locales/es.ts CHANGED
@@ -6,10 +6,7 @@
6
6
 
7
7
  export const templates = {
8
8
  scf1453991c986b25: `Tab para completar, enter para seleccionar`,
9
- sf8653793d61d060c: `Skip inactive contacts`,
10
- sd4af861b95e8ba4a: `Only include contacts who have sent a message in the last 90 days.`,
11
- sd149dff460c8dc41: `Skip contacts currently in a flow`,
12
- sc85010c81b71421e: `Avoid interrupting a contact who is already in a flow.`,
13
- s3e3fa53e834f4fda: `Skip repeat contacts`,
14
- s95e715d82602bced: `Avoid restarting a contact who has been in this flow in the last 90 days.`
9
+ s638236250662c6b3: `Have sent a message in the last`,
10
+ s8f02e3a18ffc083a: `Are not currently in a flow`,
11
+ s4788ee206c4570c7: `Have not started this flow in the last 90 days`
15
12
  };
package/src/locales/fr.ts CHANGED
@@ -6,10 +6,7 @@
6
6
 
7
7
  export const templates = {
8
8
  scf1453991c986b25: `Tab to complete, enter to select`,
9
- sf8653793d61d060c: `Skip inactive contacts`,
10
- sd4af861b95e8ba4a: `Only include contacts who have sent a message in the last 90 days.`,
11
- sd149dff460c8dc41: `Skip contacts currently in a flow`,
12
- sc85010c81b71421e: `Avoid interrupting a contact who is already in a flow.`,
13
- s3e3fa53e834f4fda: `Skip repeat contacts`,
14
- s95e715d82602bced: `Avoid restarting a contact who has been in this flow in the last 90 days.`
9
+ s638236250662c6b3: `Have sent a message in the last`,
10
+ s8f02e3a18ffc083a: `Are not currently in a flow`,
11
+ s4788ee206c4570c7: `Have not started this flow in the last 90 days`
15
12
  };
package/src/locales/pt.ts CHANGED
@@ -6,10 +6,7 @@
6
6
 
7
7
  export const templates = {
8
8
  scf1453991c986b25: `Tab to complete, enter to select`,
9
- sf8653793d61d060c: `Skip inactive contacts`,
10
- sd4af861b95e8ba4a: `Only include contacts who have sent a message in the last 90 days.`,
11
- sd149dff460c8dc41: `Skip contacts currently in a flow`,
12
- sc85010c81b71421e: `Avoid interrupting a contact who is already in a flow.`,
13
- s3e3fa53e834f4fda: `Skip repeat contacts`,
14
- s95e715d82602bced: `Avoid restarting a contact who has been in this flow in the last 90 days.`
9
+ s638236250662c6b3: `Have sent a message in the last`,
10
+ s8f02e3a18ffc083a: `Are not currently in a flow`,
11
+ s4788ee206c4570c7: `Have not started this flow in the last 90 days`
15
12
  };
@@ -116,6 +116,14 @@ export class TabPane extends RapidElement {
116
116
  .bottom .tab.selected {
117
117
  }
118
118
 
119
+ .unselect .tab.selected {
120
+ cursor: pointer;
121
+ }
122
+
123
+ .unselect .tab.selected:hover {
124
+ background: var(--unselect-tab-color, #eee);
125
+ }
126
+
119
127
  .tab:hover {
120
128
  --icon-color: #666;
121
129
  color: #666;
@@ -216,6 +224,10 @@ export class TabPane extends RapidElement {
216
224
  @property({ type: Boolean })
217
225
  bottom = false;
218
226
 
227
+ // do we allow unselecting the current tab
228
+ @property({ type: Boolean })
229
+ unselect = false;
230
+
219
231
  // Only shows the name if the tab is focused
220
232
  @property({ type: Boolean })
221
233
  focusedName = false;
@@ -230,9 +242,16 @@ export class TabPane extends RapidElement {
230
242
  tabs: Tab[] = [];
231
243
 
232
244
  private handleTabClick(event: MouseEvent): void {
233
- this.index = parseInt(
245
+ const newIndex = parseInt(
234
246
  (event.currentTarget as HTMLDivElement).dataset.index
235
247
  );
248
+
249
+ if (this.unselect && this.index === newIndex) {
250
+ this.index = -1;
251
+ } else {
252
+ this.index = newIndex;
253
+ }
254
+
236
255
  event.preventDefault();
237
256
  event.stopPropagation();
238
257
  this.requestUpdate('index');
@@ -332,7 +351,8 @@ export class TabPane extends RapidElement {
332
351
  bottom: this.bottom,
333
352
  collapses: this.collapses,
334
353
  embedded: this.embedded,
335
- focusedname: this.focusedName
354
+ focusedname: this.focusedName,
355
+ unselect: this.unselect
336
356
  })}"
337
357
  >
338
358
  ${this.tabs.map(
package/xliff/es.xlf CHANGED
@@ -6,23 +6,14 @@
6
6
  <source>Tab to complete, enter to select</source>
7
7
  <target>Tab para completar, enter para seleccionar</target>
8
8
  </trans-unit>
9
- <trans-unit id="sf8653793d61d060c">
10
- <source>Skip inactive contacts</source>
9
+ <trans-unit id="s638236250662c6b3">
10
+ <source>Have sent a message in the last</source>
11
11
  </trans-unit>
12
- <trans-unit id="sd4af861b95e8ba4a">
13
- <source>Only include contacts who have sent a message in the last 90 days.</source>
12
+ <trans-unit id="s8f02e3a18ffc083a">
13
+ <source>Are not currently in a flow</source>
14
14
  </trans-unit>
15
- <trans-unit id="sd149dff460c8dc41">
16
- <source>Skip contacts currently in a flow</source>
17
- </trans-unit>
18
- <trans-unit id="sc85010c81b71421e">
19
- <source>Avoid interrupting a contact who is already in a flow.</source>
20
- </trans-unit>
21
- <trans-unit id="s3e3fa53e834f4fda">
22
- <source>Skip repeat contacts</source>
23
- </trans-unit>
24
- <trans-unit id="s95e715d82602bced">
25
- <source>Avoid restarting a contact who has been in this flow in the last 90 days.</source>
15
+ <trans-unit id="s4788ee206c4570c7">
16
+ <source>Have not started this flow in the last 90 days</source>
26
17
  </trans-unit>
27
18
  </body>
28
19
  </file>
package/xliff/fr.xlf CHANGED
@@ -5,23 +5,14 @@
5
5
  <trans-unit id="scf1453991c986b25">
6
6
  <source>Tab to complete, enter to select</source>
7
7
  </trans-unit>
8
- <trans-unit id="sf8653793d61d060c">
9
- <source>Skip inactive contacts</source>
8
+ <trans-unit id="s638236250662c6b3">
9
+ <source>Have sent a message in the last</source>
10
10
  </trans-unit>
11
- <trans-unit id="sd4af861b95e8ba4a">
12
- <source>Only include contacts who have sent a message in the last 90 days.</source>
11
+ <trans-unit id="s8f02e3a18ffc083a">
12
+ <source>Are not currently in a flow</source>
13
13
  </trans-unit>
14
- <trans-unit id="sd149dff460c8dc41">
15
- <source>Skip contacts currently in a flow</source>
16
- </trans-unit>
17
- <trans-unit id="sc85010c81b71421e">
18
- <source>Avoid interrupting a contact who is already in a flow.</source>
19
- </trans-unit>
20
- <trans-unit id="s3e3fa53e834f4fda">
21
- <source>Skip repeat contacts</source>
22
- </trans-unit>
23
- <trans-unit id="s95e715d82602bced">
24
- <source>Avoid restarting a contact who has been in this flow in the last 90 days.</source>
14
+ <trans-unit id="s4788ee206c4570c7">
15
+ <source>Have not started this flow in the last 90 days</source>
25
16
  </trans-unit>
26
17
  </body>
27
18
  </file>
package/xliff/pt.xlf CHANGED
@@ -5,23 +5,14 @@
5
5
  <trans-unit id="scf1453991c986b25">
6
6
  <source>Tab to complete, enter to select</source>
7
7
  </trans-unit>
8
- <trans-unit id="sf8653793d61d060c">
9
- <source>Skip inactive contacts</source>
8
+ <trans-unit id="s638236250662c6b3">
9
+ <source>Have sent a message in the last</source>
10
10
  </trans-unit>
11
- <trans-unit id="sd4af861b95e8ba4a">
12
- <source>Only include contacts who have sent a message in the last 90 days.</source>
11
+ <trans-unit id="s8f02e3a18ffc083a">
12
+ <source>Are not currently in a flow</source>
13
13
  </trans-unit>
14
- <trans-unit id="sd149dff460c8dc41">
15
- <source>Skip contacts currently in a flow</source>
16
- </trans-unit>
17
- <trans-unit id="sc85010c81b71421e">
18
- <source>Avoid interrupting a contact who is already in a flow.</source>
19
- </trans-unit>
20
- <trans-unit id="s3e3fa53e834f4fda">
21
- <source>Skip repeat contacts</source>
22
- </trans-unit>
23
- <trans-unit id="s95e715d82602bced">
24
- <source>Avoid restarting a contact who has been in this flow in the last 90 days.</source>
14
+ <trans-unit id="s4788ee206c4570c7">
15
+ <source>Have not started this flow in the last 90 days</source>
25
16
  </trans-unit>
26
17
  </body>
27
18
  </file>