@hmcts/ccd-case-ui-toolkit 6.16.0-query-management-query-list-v4 → 6.16.0-query-management-sorting

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.
@@ -19619,6 +19619,13 @@
19619
19619
  }], function () { return []; }, null);
19620
19620
  })();
19621
19621
 
19622
+ var SortOrder;
19623
+ (function (SortOrder) {
19624
+ SortOrder[SortOrder["ASCENDING"] = 0] = "ASCENDING";
19625
+ SortOrder[SortOrder["DESCENDING"] = 1] = "DESCENDING";
19626
+ SortOrder[SortOrder["UNSORTED"] = 2] = "UNSORTED";
19627
+ })(SortOrder || (SortOrder = {}));
19628
+
19622
19629
  var QueryListItem = /** @class */ (function () {
19623
19630
  function QueryListItem() {
19624
19631
  this.children = [];
@@ -19712,42 +19719,62 @@
19712
19719
  QueryListResponseStatus["RESPONDED"] = "Responded";
19713
19720
  })(exports.QueryListResponseStatus || (exports.QueryListResponseStatus = {}));
19714
19721
 
19715
- function QueryListComponent_ng_container_0_tr_23_Template(rf, ctx) {
19722
+ function QueryListComponent_ng_container_0_th_7_Template(rf, ctx) {
19723
+ if (rf & 1) {
19724
+ var _r5_1 = i0__namespace.ɵɵgetCurrentView();
19725
+ i0__namespace.ɵɵelementStart(0, "th", 8);
19726
+ i0__namespace.ɵɵtext(1);
19727
+ i0__namespace.ɵɵpipe(2, "rpxTranslate");
19728
+ i0__namespace.ɵɵelementStart(3, "a", 9);
19729
+ i0__namespace.ɵɵlistener("click", function QueryListComponent_ng_container_0_th_7_Template_a_click_3_listener() { i0__namespace.ɵɵrestoreView(_r5_1); var col_r3 = ctx.$implicit; var ctx_r4 = i0__namespace.ɵɵnextContext(2); return ctx_r4.sortTable(col_r3); });
19730
+ i0__namespace.ɵɵelementEnd();
19731
+ i0__namespace.ɵɵelementEnd();
19732
+ }
19733
+ if (rf & 2) {
19734
+ var col_r3 = ctx.$implicit;
19735
+ var ctx_r1 = i0__namespace.ɵɵnextContext(2);
19736
+ i0__namespace.ɵɵadvance(1);
19737
+ i0__namespace.ɵɵtextInterpolate1(" ", i0__namespace.ɵɵpipeBind1(2, 2, col_r3.displayName), " ");
19738
+ i0__namespace.ɵɵadvance(2);
19739
+ i0__namespace.ɵɵproperty("innerHTML", ctx_r1.sortWidget(col_r3), i0__namespace.ɵɵsanitizeHtml);
19740
+ }
19741
+ }
19742
+ function QueryListComponent_ng_container_0_tr_9_Template(rf, ctx) {
19716
19743
  if (rf & 1) {
19717
19744
  i0__namespace.ɵɵelementStart(0, "tr", 4);
19718
- i0__namespace.ɵɵelementStart(1, "td", 8);
19719
- i0__namespace.ɵɵelementStart(2, "a", 9);
19745
+ i0__namespace.ɵɵelementStart(1, "td", 10);
19746
+ i0__namespace.ɵɵelementStart(2, "a", 11);
19720
19747
  i0__namespace.ɵɵtext(3);
19721
19748
  i0__namespace.ɵɵelementEnd();
19722
19749
  i0__namespace.ɵɵelementEnd();
19723
- i0__namespace.ɵɵelementStart(4, "td", 10);
19750
+ i0__namespace.ɵɵelementStart(4, "td", 12);
19724
19751
  i0__namespace.ɵɵtext(5);
19725
19752
  i0__namespace.ɵɵelementEnd();
19726
- i0__namespace.ɵɵelementStart(6, "td", 10);
19753
+ i0__namespace.ɵɵelementStart(6, "td", 12);
19727
19754
  i0__namespace.ɵɵtext(7);
19728
19755
  i0__namespace.ɵɵpipe(8, "date");
19729
19756
  i0__namespace.ɵɵelementEnd();
19730
- i0__namespace.ɵɵelementStart(9, "td", 10);
19757
+ i0__namespace.ɵɵelementStart(9, "td", 12);
19731
19758
  i0__namespace.ɵɵtext(10);
19732
19759
  i0__namespace.ɵɵpipe(11, "date");
19733
19760
  i0__namespace.ɵɵelementEnd();
19734
- i0__namespace.ɵɵelementStart(12, "td", 10);
19761
+ i0__namespace.ɵɵelementStart(12, "td", 12);
19735
19762
  i0__namespace.ɵɵtext(13);
19736
19763
  i0__namespace.ɵɵelementEnd();
19737
19764
  i0__namespace.ɵɵelementEnd();
19738
19765
  }
19739
19766
  if (rf & 2) {
19740
- var message_r2 = ctx.$implicit;
19767
+ var message_r6 = ctx.$implicit;
19741
19768
  i0__namespace.ɵɵadvance(3);
19742
- i0__namespace.ɵɵtextInterpolate(message_r2.subject);
19769
+ i0__namespace.ɵɵtextInterpolate(message_r6.subject);
19743
19770
  i0__namespace.ɵɵadvance(2);
19744
- i0__namespace.ɵɵtextInterpolate(message_r2.lastSubmittedBy);
19771
+ i0__namespace.ɵɵtextInterpolate(message_r6.lastSubmittedBy);
19745
19772
  i0__namespace.ɵɵadvance(2);
19746
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind2(8, 5, message_r2.lastSubmittedDate, "dd MMM YYYY"));
19773
+ i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind2(8, 5, message_r6.lastSubmittedDate, "dd MMM YYYY"));
19747
19774
  i0__namespace.ɵɵadvance(3);
19748
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind2(11, 8, message_r2.lastResponseDate, "dd MMM YYYY"));
19775
+ i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind2(11, 8, message_r6.lastResponseDate, "dd MMM YYYY"));
19749
19776
  i0__namespace.ɵɵadvance(3);
19750
- i0__namespace.ɵɵtextInterpolate(message_r2.lastResponseBy);
19777
+ i0__namespace.ɵɵtextInterpolate(message_r6.lastResponseBy);
19751
19778
  }
19752
19779
  }
19753
19780
  function QueryListComponent_ng_container_0_Template(rf, ctx) {
@@ -19761,30 +19788,11 @@
19761
19788
  i0__namespace.ɵɵelementEnd();
19762
19789
  i0__namespace.ɵɵelementStart(5, "thead", 3);
19763
19790
  i0__namespace.ɵɵelementStart(6, "tr", 4);
19764
- i0__namespace.ɵɵelementStart(7, "th", 5);
19765
- i0__namespace.ɵɵtext(8);
19766
- i0__namespace.ɵɵpipe(9, "rpxTranslate");
19791
+ i0__namespace.ɵɵtemplate(7, QueryListComponent_ng_container_0_th_7_Template, 4, 4, "th", 5);
19767
19792
  i0__namespace.ɵɵelementEnd();
19768
- i0__namespace.ɵɵelementStart(10, "th", 5);
19769
- i0__namespace.ɵɵtext(11);
19770
- i0__namespace.ɵɵpipe(12, "rpxTranslate");
19771
- i0__namespace.ɵɵelementEnd();
19772
- i0__namespace.ɵɵelementStart(13, "th", 5);
19773
- i0__namespace.ɵɵtext(14);
19774
- i0__namespace.ɵɵpipe(15, "rpxTranslate");
19775
- i0__namespace.ɵɵelementEnd();
19776
- i0__namespace.ɵɵelementStart(16, "th", 5);
19777
- i0__namespace.ɵɵtext(17);
19778
- i0__namespace.ɵɵpipe(18, "rpxTranslate");
19779
19793
  i0__namespace.ɵɵelementEnd();
19780
- i0__namespace.ɵɵelementStart(19, "th", 5);
19781
- i0__namespace.ɵɵtext(20);
19782
- i0__namespace.ɵɵpipe(21, "rpxTranslate");
19783
- i0__namespace.ɵɵelementEnd();
19784
- i0__namespace.ɵɵelementEnd();
19785
- i0__namespace.ɵɵelementEnd();
19786
- i0__namespace.ɵɵelementStart(22, "tbody", 6);
19787
- i0__namespace.ɵɵtemplate(23, QueryListComponent_ng_container_0_tr_23_Template, 14, 11, "tr", 7);
19794
+ i0__namespace.ɵɵelementStart(8, "tbody", 6);
19795
+ i0__namespace.ɵɵtemplate(9, QueryListComponent_ng_container_0_tr_9_Template, 14, 11, "tr", 7);
19788
19796
  i0__namespace.ɵɵelementEnd();
19789
19797
  i0__namespace.ɵɵelementEnd();
19790
19798
  i0__namespace.ɵɵelementContainerEnd();
@@ -19793,22 +19801,21 @@
19793
19801
  var ctx_r0 = i0__namespace.ɵɵnextContext();
19794
19802
  i0__namespace.ɵɵadvance(4);
19795
19803
  i0__namespace.ɵɵtextInterpolate(ctx_r0.queryListData.partyName);
19796
- i0__namespace.ɵɵadvance(4);
19797
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(9, 7, "Queries"));
19798
- i0__namespace.ɵɵadvance(3);
19799
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(12, 9, "Last submitted by"));
19800
- i0__namespace.ɵɵadvance(3);
19801
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(15, 11, "Last submission date"));
19802
- i0__namespace.ɵɵadvance(3);
19803
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(18, 13, "Last response date"));
19804
- i0__namespace.ɵɵadvance(3);
19805
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(21, 15, "Response by"));
19806
19804
  i0__namespace.ɵɵadvance(3);
19805
+ i0__namespace.ɵɵproperty("ngForOf", ctx_r0.displayedColumns);
19806
+ i0__namespace.ɵɵadvance(2);
19807
19807
  i0__namespace.ɵɵproperty("ngForOf", ctx_r0.queryListData.partyMessages);
19808
19808
  }
19809
19809
  }
19810
19810
  var QueryListComponent = /** @class */ (function () {
19811
19811
  function QueryListComponent() {
19812
+ this.displayedColumns = [
19813
+ { name: 'subject', displayName: 'Queries', sortOrder: SortOrder.UNSORTED },
19814
+ { name: 'lastSubmittedBy', displayName: 'Last submitted by', sortOrder: SortOrder.UNSORTED },
19815
+ { name: 'lastSubmittedDate', displayName: 'Last submission date', sortOrder: SortOrder.UNSORTED },
19816
+ { name: 'lastResponseDate', displayName: 'Last response date', sortOrder: SortOrder.UNSORTED },
19817
+ { name: 'lastResponseBy', displayName: 'Response by', sortOrder: SortOrder.UNSORTED }
19818
+ ];
19812
19819
  }
19813
19820
  QueryListComponent.prototype.ngOnChanges = function (simpleChanges) {
19814
19821
  var _a;
@@ -19817,17 +19824,78 @@
19817
19824
  this.queryListData = new QueryListData(currentPartyMessageGroup);
19818
19825
  }
19819
19826
  };
19827
+ QueryListComponent.prototype.sortTable = function (col) {
19828
+ switch (col.displayName) {
19829
+ case 'Queries': {
19830
+ this.sort(col);
19831
+ break;
19832
+ }
19833
+ case 'Last submitted by': {
19834
+ this.sort(col);
19835
+ break;
19836
+ }
19837
+ case 'Last submission date': {
19838
+ this.sortDate(col);
19839
+ break;
19840
+ }
19841
+ case 'Last response date': {
19842
+ this.sortDate(col);
19843
+ break;
19844
+ }
19845
+ case 'Response by': {
19846
+ this.sort(col);
19847
+ break;
19848
+ }
19849
+ }
19850
+ };
19851
+ QueryListComponent.prototype.sortWidget = function (col) {
19852
+ switch (col.sortOrder) {
19853
+ case SortOrder.DESCENDING: {
19854
+ return '▲';
19855
+ }
19856
+ case SortOrder.ASCENDING: {
19857
+ return '▼';
19858
+ }
19859
+ default: {
19860
+ return '⬧';
19861
+ }
19862
+ }
19863
+ };
19864
+ QueryListComponent.prototype.sort = function (col) {
19865
+ if (col.sortOrder && col.sortOrder === SortOrder.DESCENDING) {
19866
+ this.queryListData.partyMessages.sort(function (a, b) { return (a[col.name] < b[col.name]) ? 1 : -1; });
19867
+ this.displayedColumns.forEach(function (c) { return c.sortOrder = SortOrder.UNSORTED; });
19868
+ col.sortOrder = SortOrder.ASCENDING;
19869
+ }
19870
+ else {
19871
+ this.queryListData.partyMessages.sort(function (a, b) { return (a[col.name] > b[col.name]) ? 1 : -1; });
19872
+ this.displayedColumns.forEach(function (c) { return c.sortOrder = SortOrder.UNSORTED; });
19873
+ col.sortOrder = SortOrder.DESCENDING;
19874
+ }
19875
+ };
19876
+ QueryListComponent.prototype.sortDate = function (col) {
19877
+ if (col.sortOrder && col.sortOrder === SortOrder.DESCENDING) {
19878
+ this.queryListData.partyMessages.sort(function (a, b) { return b[col.name] - a[col.name]; });
19879
+ this.displayedColumns.forEach(function (c) { return c.sortOrder = SortOrder.UNSORTED; });
19880
+ col.sortOrder = SortOrder.ASCENDING;
19881
+ }
19882
+ else {
19883
+ this.queryListData.partyMessages.sort(function (a, b) { return a[col.name] - b[col.name]; });
19884
+ this.displayedColumns.forEach(function (c) { return c.sortOrder = SortOrder.UNSORTED; });
19885
+ col.sortOrder = SortOrder.DESCENDING;
19886
+ }
19887
+ };
19820
19888
  return QueryListComponent;
19821
19889
  }());
19822
19890
  QueryListComponent.ɵfac = function QueryListComponent_Factory(t) { return new (t || QueryListComponent)(); };
19823
- QueryListComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: QueryListComponent, selectors: [["ccd-query-list"]], inputs: { partyMessageGroup: "partyMessageGroup" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "govuk-table", "query-list__table"], [1, "govuk-table__cell", "query-list__caption", "query-list__row"], [1, "govuk-table__head"], [1, "govuk-table__row", "query-list__row"], ["scope", "col", 1, "govuk-table__header"], [1, "govuk-table__body"], ["class", "govuk-table__row query-list__row", 4, "ngFor", "ngForOf"], [1, "govuk-table__cell", "query-list__cell", "query-list__cell--first"], ["href", "javascript:void(0)"], [1, "govuk-table__cell", "query-list__cell"]], template: function QueryListComponent_Template(rf, ctx) {
19891
+ QueryListComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: QueryListComponent, selectors: [["ccd-query-list"]], inputs: { partyMessageGroup: "partyMessageGroup" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "govuk-table", "query-list__table"], [1, "govuk-table__cell", "query-list__caption", "query-list__row"], [1, "govuk-table__head"], [1, "govuk-table__row", "query-list__row"], ["class", "govuk-table__header", 4, "ngFor", "ngForOf"], [1, "govuk-table__body"], ["class", "govuk-table__row query-list__row", 4, "ngFor", "ngForOf"], [1, "govuk-table__header"], ["href", "javascript:void(0)", 1, "sort-widget", 3, "innerHTML", "click"], [1, "govuk-table__cell", "query-list__cell", "query-list__cell--first"], ["href", "javascript:void(0)"], [1, "govuk-table__cell", "query-list__cell"]], template: function QueryListComponent_Template(rf, ctx) {
19824
19892
  if (rf & 1) {
19825
- i0__namespace.ɵɵtemplate(0, QueryListComponent_ng_container_0_Template, 24, 17, "ng-container", 0);
19893
+ i0__namespace.ɵɵtemplate(0, QueryListComponent_ng_container_0_Template, 10, 3, "ng-container", 0);
19826
19894
  }
19827
19895
  if (rf & 2) {
19828
19896
  i0__namespace.ɵɵproperty("ngIf", ctx.queryListData);
19829
19897
  }
19830
- }, directives: [i1__namespace.NgIf, i1__namespace.NgForOf], pipes: [i2__namespace$1.RpxTranslatePipe, i1__namespace.DatePipe], styles: [".query-list__caption[_ngcontent-%COMP%], .query-list__table[_ngcontent-%COMP%]{border:1px solid #b1b4b6}.query-list__caption[_ngcontent-%COMP%]{background:#f3f2f1;border-bottom:0;font-weight:700}.query-list__row[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:first-child{padding-left:10px}.query-list__row[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:last-child{padding-right:10px}.query-list__cell--first[_ngcontent-%COMP%]{width:33%}"] });
19898
+ }, directives: [i1__namespace.NgIf, i1__namespace.NgForOf], pipes: [i2__namespace$1.RpxTranslatePipe, i1__namespace.DatePipe], styles: [".query-list__caption[_ngcontent-%COMP%], .query-list__table[_ngcontent-%COMP%]{border:1px solid #b1b4b6}.query-list__caption[_ngcontent-%COMP%]{background:#f3f2f1;border-bottom:0;font-weight:700}.query-list__row[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:first-child{padding-left:10px}.query-list__row[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:last-child{padding-right:10px}.query-list__cell--first[_ngcontent-%COMP%]{width:33%}.sort-widget[_ngcontent-%COMP%]{cursor:pointer;text-decoration:none;color:#000}"] });
19831
19899
  (function () {
19832
19900
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(QueryListComponent, [{
19833
19901
  type: i0.Component,
@@ -23567,13 +23635,6 @@
23567
23635
  }] });
23568
23636
  })();
23569
23637
 
23570
- var SortOrder;
23571
- (function (SortOrder) {
23572
- SortOrder[SortOrder["ASCENDING"] = 0] = "ASCENDING";
23573
- SortOrder[SortOrder["DESCENDING"] = 1] = "DESCENDING";
23574
- SortOrder[SortOrder["UNSORTED"] = 2] = "UNSORTED";
23575
- })(SortOrder || (SortOrder = {}));
23576
-
23577
23638
  function ReadComplexFieldCollectionTableComponent_th_9_Template(rf, ctx) {
23578
23639
  if (rf & 1) {
23579
23640
  var _r4_1 = i0__namespace.ɵɵgetCurrentView();