File

feature-libs/storefinder/components/store-finder-store/store-finder-store.component.ts

Implements

OnInit

Metadata

selector cx-store-finder-store
templateUrl ./store-finder-store.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(storeFinderService: StoreFinderService, route: ActivatedRoute, routingService: RoutingService)
Parameters :
Name Type Optional
storeFinderService StoreFinderService No
route ActivatedRoute No
routingService RoutingService No

Inputs

disableMap
Type : boolean
location
Type : PointOfService

Methods

goBack
goBack()
Returns : void
ngOnInit
ngOnInit()
Returns : void
requestStoresData
requestStoresData()
Returns : void

Properties

disableMap
Type : boolean
Decorators :
@Input()
iconTypes
Default value : ICON_TYPE
isLoading$
Type : Observable<any>
location
Type : PointOfService
Decorators :
@Input()
location$
Type : Observable<any>
import { Component, Input, OnInit } from '@angular/core';
import { PointOfService, RoutingService } from '@spartacus/core';
import { Observable } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
import { ICON_TYPE } from '@spartacus/storefront';
import { StoreFinderService } from '@spartacus/storefinder/core';

@Component({
  selector: 'cx-store-finder-store',
  templateUrl: './store-finder-store.component.html',
})
export class StoreFinderStoreComponent implements OnInit {
  location$: Observable<any>;
  isLoading$: Observable<any>;
  iconTypes = ICON_TYPE;

  @Input() location: PointOfService;
  @Input() disableMap: boolean;

  constructor(
    private storeFinderService: StoreFinderService,
    private route: ActivatedRoute,
    private routingService: RoutingService
  ) {}

  ngOnInit() {
    if (!this.location) {
      this.requestStoresData();
      this.location$ = this.storeFinderService.getFindStoreEntityById();
      this.isLoading$ = this.storeFinderService.getStoresLoading();
    }
  }

  requestStoresData() {
    this.storeFinderService.viewStoreById(this.route.snapshot.params.store);
  }

  goBack(): void {
    this.routingService.go([
      `store-finder/country/${this.route.snapshot.params.country}`,
    ]);
  }
}
<div
  class="container"
  *ngIf="
    location || (!(isLoading$ | async) && (location$ | async)) as location;
    else loading
  "
>
  <div class="row cx-store-actions">
    <div class="col-md-4 col-sm-6 col-lg-2">
      <button class="btn btn-block btn-action" (click)="goBack()">
        <cx-icon [type]="iconTypes.CARET_LEFT"></cx-icon>
        {{ 'storeFinder.backToList' | cxTranslate }}
      </button>
    </div>
  </div>
  <div class="row">
    <div class="col-12 p-0">
      <cx-store-finder-store-description
        [disableMap]="disableMap"
        [location]="location"
      ></cx-store-finder-store-description>
    </div>
  </div>
</div>
<ng-template #loading>
  <div class="cx-spinner"><cx-spinner></cx-spinner></div>
</ng-template>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""