@hmcts/ccd-case-ui-toolkit 6.16.0-query-management-update-mock-data → 6.16.0-query-management-complete-task

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.
@@ -21232,6 +21232,54 @@
21232
21232
  return QueryListData;
21233
21233
  }());
21234
21234
 
21235
+ var QueryManagmentService = /** @class */ (function () {
21236
+ function QueryManagmentService(http, appConfig, errorService, alertService) {
21237
+ this.http = http;
21238
+ this.appConfig = appConfig;
21239
+ this.errorService = errorService;
21240
+ this.alertService = alertService;
21241
+ }
21242
+ /**
21243
+ * Call the API to complete a task.
21244
+ * @param taskId specifies which task should be completed.
21245
+ */
21246
+ QueryManagmentService.prototype.completeTask = function (taskId) {
21247
+ var _this = this;
21248
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
21249
+ return this.http
21250
+ .post(url, {})
21251
+ .pipe(operators.catchError(function (error) {
21252
+ _this.errorService.setError(error);
21253
+ return rxjs.throwError(error);
21254
+ }));
21255
+ };
21256
+ /**
21257
+ * Call the API to get tasks matching the search criteria.
21258
+ * @param searchRequest The search parameters that specify which tasks to match.
21259
+ */
21260
+ QueryManagmentService.prototype.searchTasks = function (searchRequest) {
21261
+ var _this = this;
21262
+ var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
21263
+ return this.http
21264
+ .post(url, { searchRequest: searchRequest }, null, false)
21265
+ .pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
21266
+ _this.errorService.setError(error);
21267
+ return rxjs.throwError(error);
21268
+ }));
21269
+ };
21270
+ return QueryManagmentService;
21271
+ }());
21272
+ QueryManagmentService.ɵfac = function QueryManagmentService_Factory(t) { return new (t || QueryManagmentService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(AlertService)); };
21273
+ QueryManagmentService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: QueryManagmentService, factory: QueryManagmentService.ɵfac, providedIn: 'root' });
21274
+ (function () {
21275
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(QueryManagmentService, [{
21276
+ type: i0.Injectable,
21277
+ args: [{
21278
+ providedIn: 'root'
21279
+ }]
21280
+ }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }]; }, null);
21281
+ })();
21282
+
21235
21283
  function QueryCheckYourAnswersComponent_ng_container_2_Template(rf, ctx) {
21236
21284
  if (rf & 1) {
21237
21285
  i0__namespace.ɵɵelementContainerStart(0);
@@ -21411,17 +21459,56 @@
21411
21459
  }
21412
21460
  }
21413
21461
  var QueryCheckYourAnswersComponent = /** @class */ (function () {
21414
- function QueryCheckYourAnswersComponent() {
21462
+ function QueryCheckYourAnswersComponent(activatedRoute, caseNotifier, queryManagementService, sessionStorageService) {
21463
+ this.activatedRoute = activatedRoute;
21464
+ this.caseNotifier = caseNotifier;
21465
+ this.queryManagementService = queryManagementService;
21466
+ this.sessionStorageService = sessionStorageService;
21415
21467
  this.backClicked = new i0.EventEmitter();
21416
21468
  this.queryCreateContextEnum = exports.QueryCreateContext;
21417
21469
  }
21470
+ QueryCheckYourAnswersComponent.prototype.ngOnInit = function () {
21471
+ var _this = this;
21472
+ this.queryId = this.activatedRoute.snapshot.params.qid;
21473
+ this.caseNotifier.caseView.pipe(operators.take(1)).subscribe(function (caseDetails) {
21474
+ _this.caseId = caseDetails.case_id;
21475
+ });
21476
+ };
21418
21477
  QueryCheckYourAnswersComponent.prototype.goBack = function () {
21419
21478
  this.backClicked.emit(true);
21420
21479
  };
21480
+ QueryCheckYourAnswersComponent.prototype.submit = function () {
21481
+ this.searchAndCompleteTask();
21482
+ };
21483
+ QueryCheckYourAnswersComponent.prototype.searchAndCompleteTask = function () {
21484
+ var _this = this;
21485
+ var userInfoStr = this.sessionStorageService.getItem('userDetails');
21486
+ var userInfo = JSON.parse(userInfoStr);
21487
+ // Search task
21488
+ var searchParameter = { ccdId: this.caseId };
21489
+ this.queryManagementService.searchTasks(searchParameter)
21490
+ .subscribe(function (response) {
21491
+ // Filter task by queryId
21492
+ var filteredtask = response.tasks.find(function (task) {
21493
+ return Object.values(task.additional_properties).some(function (value) {
21494
+ if (value === _this.queryId && task.assignee === userInfo.id) {
21495
+ return task;
21496
+ }
21497
+ });
21498
+ });
21499
+ if (!!filteredtask) {
21500
+ _this.queryManagementService.completeTask(filteredtask.id).subscribe();
21501
+ }
21502
+ return;
21503
+ }),
21504
+ operators.catchError(function (error) {
21505
+ return rxjs.throwError(error);
21506
+ });
21507
+ };
21421
21508
  return QueryCheckYourAnswersComponent;
21422
21509
  }());
21423
- QueryCheckYourAnswersComponent.ɵfac = function QueryCheckYourAnswersComponent_Factory(t) { return new (t || QueryCheckYourAnswersComponent)(); };
21424
- QueryCheckYourAnswersComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: QueryCheckYourAnswersComponent, selectors: [["ccd-query-check-your-answers"]], inputs: { formGroup: "formGroup", queryItem: "queryItem", queryCreateContext: "queryCreateContext" }, outputs: { backClicked: "backClicked" }, decls: 41, vars: 25, consts: [[1, "govuk-grid-row"], [1, "govuk-grid-column-two-thirds-from-desktop"], [4, "ngIf"], [1, "govuk-heading-l"], [4, "ngIf", "ngIfElse"], ["defaultCheckYourAnswersTitle", ""], [1, "govuk-!-margin-bottom-4"], ["class", "govuk-summary-list govuk-!-margin-bottom-0", 4, "ngIf"], [1, "govuk-summary-list", "govuk-!-margin-bottom-0"], [1, "govuk-summary-list__row"], [1, "govuk-summary-list__key"], [1, "govuk-summary-list__value"], [1, "govuk-summary-list__actions"], ["href", "javascript:void(0)", 1, "govuk-link", 3, "click"], [1, "govuk-summary-list__value", "govuk-summary-list__value--documentAttached"], [3, "attachments", 4, "ngIf"], ["data-module", "govuk-button", 1, "govuk-button", "govuk-button--secondary", "govuk-!-margin-right-3", 3, "click"], ["data-module", "govuk-button", 1, "govuk-button"], [1, "govuk-caption-l"], ["href", "javascript:void(0)", "class", "govuk-link", 3, "click", 4, "ngIf"], ["isHearingRelatedFalse", ""], ["class", "govuk-summary-list__row", 4, "ngIf"], [3, "attachments"]], template: function QueryCheckYourAnswersComponent_Template(rf, ctx) {
21510
+ QueryCheckYourAnswersComponent.ɵfac = function QueryCheckYourAnswersComponent_Factory(t) { return new (t || QueryCheckYourAnswersComponent)(i0__namespace.ɵɵdirectiveInject(i1__namespace$1.ActivatedRoute), i0__namespace.ɵɵdirectiveInject(CaseNotifier), i0__namespace.ɵɵdirectiveInject(QueryManagmentService), i0__namespace.ɵɵdirectiveInject(SessionStorageService)); };
21511
+ QueryCheckYourAnswersComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: QueryCheckYourAnswersComponent, selectors: [["ccd-query-check-your-answers"]], inputs: { formGroup: "formGroup", queryItem: "queryItem", queryCreateContext: "queryCreateContext" }, outputs: { backClicked: "backClicked" }, decls: 41, vars: 25, consts: [[1, "govuk-grid-row"], [1, "govuk-grid-column-two-thirds-from-desktop"], [4, "ngIf"], [1, "govuk-heading-l"], [4, "ngIf", "ngIfElse"], ["defaultCheckYourAnswersTitle", ""], [1, "govuk-!-margin-bottom-4"], ["class", "govuk-summary-list govuk-!-margin-bottom-0", 4, "ngIf"], [1, "govuk-summary-list", "govuk-!-margin-bottom-0"], [1, "govuk-summary-list__row"], [1, "govuk-summary-list__key"], [1, "govuk-summary-list__value"], [1, "govuk-summary-list__actions"], ["href", "javascript:void(0)", 1, "govuk-link", 3, "click"], [1, "govuk-summary-list__value", "govuk-summary-list__value--documentAttached"], [3, "attachments", 4, "ngIf"], ["data-module", "govuk-button", 1, "govuk-button", "govuk-button--secondary", "govuk-!-margin-right-3", 3, "click"], ["data-module", "govuk-button", 1, "govuk-button", 3, "click"], [1, "govuk-caption-l"], ["href", "javascript:void(0)", "class", "govuk-link", 3, "click", 4, "ngIf"], ["isHearingRelatedFalse", ""], ["class", "govuk-summary-list__row", 4, "ngIf"], [3, "attachments"]], template: function QueryCheckYourAnswersComponent_Template(rf, ctx) {
21425
21512
  if (rf & 1) {
21426
21513
  i0__namespace.ɵɵelementStart(0, "div", 0);
21427
21514
  i0__namespace.ɵɵelementStart(1, "div", 1);
@@ -21479,6 +21566,7 @@
21479
21566
  i0__namespace.ɵɵpipe(37, "rpxTranslate");
21480
21567
  i0__namespace.ɵɵelementEnd();
21481
21568
  i0__namespace.ɵɵelementStart(38, "button", 17);
21569
+ i0__namespace.ɵɵlistener("click", function QueryCheckYourAnswersComponent_Template_button_click_38_listener() { return ctx.submit(); });
21482
21570
  i0__namespace.ɵɵtext(39);
21483
21571
  i0__namespace.ɵɵpipe(40, "rpxTranslate");
21484
21572
  i0__namespace.ɵɵelementEnd();
@@ -21523,7 +21611,7 @@
21523
21611
  templateUrl: './query-check-your-answers.component.html',
21524
21612
  styleUrls: ['./query-check-your-answers.component.scss']
21525
21613
  }]
21526
- }], null, { formGroup: [{
21614
+ }], function () { return [{ type: i1__namespace$1.ActivatedRoute }, { type: CaseNotifier }, { type: QueryManagmentService }, { type: SessionStorageService }]; }, { formGroup: [{
21527
21615
  type: i0.Input
21528
21616
  }], queryItem: [{
21529
21617
  type: i0.Input