Skip to content

Commit

Permalink
fix(share-map): remove sharemap button when not auth
Browse files Browse the repository at this point in the history
  • Loading branch information
gignacnic authored and mbarbeau committed Feb 13, 2018
1 parent 1a25e8f commit d817693
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/share-map/share-map/share-map.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</mat-form-field>
</div>

<div class="igo-form-button-group">
<div *ngIf="hasApi" class="igo-form-button-group">
<button
mat-raised-button
type="submit"
Expand All @@ -38,7 +38,7 @@

</form>

<div *ngIf="url" class="igo-input-container linkToShare">
<div class="igo-input-container linkToShare">
<mat-form-field>
<textarea #textArea matInput readonly rows="1"
[placeholder]="'igo.shareMap.placeholderLink' | translate"
Expand Down
13 changes: 11 additions & 2 deletions src/lib/share-map/share-map/share-map.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { AfterViewInit, Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { uuid } from '../../utils/uuid';

Expand All @@ -13,7 +13,7 @@ import { ShareMapService } from '../shared';
templateUrl: './share-map.component.html',
styleUrls: ['./share-map.component.styl']
})
export class ShareMapComponent implements OnInit {
export class ShareMapComponent implements AfterViewInit, OnInit {

public form: FormGroup;

Expand Down Expand Up @@ -47,6 +47,15 @@ export class ShareMapComponent implements OnInit {
});
}

ngAfterViewInit(): void {
this.auth.authenticate$.subscribe((auth) => {
const decodeToken = this.auth.decodeToken();
this.userId = decodeToken.user ? decodeToken.user.id : undefined;
this.url = this.shareMapService.getUrl(this.map, this.userId);
this.buildForm();
});
}

resetUrl(values) {
const inputs = Object.assign({}, values);
inputs.uri = this.userId ? `${this.userId}-${values.uri}` : values.uri;
Expand Down

0 comments on commit d817693

Please sign in to comment.