Access campaigns in campaign navigation from Observable

pull/46/head
HardiReady 2018-10-18 20:36:57 +02:00
parent 14c4cf68ff
commit 9fb39b0af2
5 changed files with 22 additions and 12 deletions

View File

@ -24,7 +24,6 @@ const vehicleRegex = /(vehicle:\s(.*?)\))/;
const categoryRegex = /(category:\s(.*?)\))/; const categoryRegex = /(category:\s(.*?)\))/;
const parseWarLog = (lineArray, war) => { const parseWarLog = (lineArray, war) => {
let flagBlufor = true; let flagBlufor = true;
let flagOpfor = true; let flagOpfor = true;

View File

@ -33,7 +33,7 @@ export class CampaignService {
submitCampaign(campaign: Campaign) { submitCampaign(campaign: Campaign) {
let requestUrl: string; let requestUrl: string;
let requestMethod: RequestMethod let requestMethod: RequestMethod;
let accessType; let accessType;
if (campaign._id) { if (campaign._id) {

View File

@ -12,7 +12,7 @@
{{'stats.campaign.title.all.time.overview' | translate}} {{'stats.campaign.title.all.time.overview' | translate}}
</div> </div>
<div class="campaign-entry" <div class="campaign-entry"
*ngFor="let campaign of campaigns" *ngFor="let campaign of campaigns$ | async"
[ngClass]="{active : campaign._id === selectedCampaignId}" [ngClass]="{active : campaign._id === selectedCampaignId}"
(click)="select(campaign)"> (click)="select(campaign)">
{{campaign.title}} {{campaign.title}}

View File

@ -1,15 +1,25 @@
import {Component, ElementRef, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild} from '@angular/core'; import {
Component,
ElementRef,
EventEmitter,
Input,
OnInit,
Output,
ViewChild
} from '@angular/core';
import {Campaign} from '../../../models/model-interfaces'; import {Campaign} from '../../../models/model-interfaces';
import {LoginService} from '../../../services/app-user-service/login-service'; import {LoginService} from '../../../services/app-user-service/login-service';
import {Observable} from 'rxjs';
import {CampaignService} from '../../../services/logs/campaign.service';
@Component({ @Component({
selector: 'campaign-navigation', selector: 'campaign-navigation',
templateUrl: './campaign-navigation.component.html', templateUrl: './campaign-navigation.component.html',
styleUrls: ['./campaign-navigation.component.css'] styleUrls: ['./campaign-navigation.component.css']
}) })
export class CampaignNavigationComponent implements OnChanges { export class CampaignNavigationComponent implements OnInit {
@Input() campaigns: Campaign[]; campaigns$: Observable<Campaign[]>;
@Input() selectedCampaignId; @Input() selectedCampaignId;
@ -27,13 +37,15 @@ export class CampaignNavigationComponent implements OnChanges {
repeater; repeater;
constructor(public loginService: LoginService) { constructor(public loginService: LoginService,
private campaignService: CampaignService) {
this.campaigns$ = campaignService.campaigns$;
} }
ngOnChanges(changes: SimpleChanges) { ngOnInit() {
if (!changes.selectedCampaignId) { this.campaigns$.subscribe(campaigns => {
this.isRightScrollVisible = this.campaigns.length > 4; this.isRightScrollVisible = campaigns.length > 4;
} });
} }
select(campaign) { select(campaign) {

View File

@ -1,5 +1,4 @@
<campaign-navigation <campaign-navigation
[campaigns]="campaigns"
[selectedCampaignId]="selectedCampaign._id" [selectedCampaignId]="selectedCampaign._id"
(campaignSelect)="switchCampaign($event)" (campaignSelect)="switchCampaign($event)"
(campaignEdit)="editCampaign($event)" (campaignEdit)="editCampaign($event)"