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 parseWarLog = (lineArray, war) => {
let flagBlufor = true;
let flagOpfor = true;

View File

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

View File

@ -12,7 +12,7 @@
{{'stats.campaign.title.all.time.overview' | translate}}
</div>
<div class="campaign-entry"
*ngFor="let campaign of campaigns"
*ngFor="let campaign of campaigns$ | async"
[ngClass]="{active : campaign._id === selectedCampaignId}"
(click)="select(campaign)">
{{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 {LoginService} from '../../../services/app-user-service/login-service';
import {Observable} from 'rxjs';
import {CampaignService} from '../../../services/logs/campaign.service';
@Component({
selector: 'campaign-navigation',
templateUrl: './campaign-navigation.component.html',
styleUrls: ['./campaign-navigation.component.css']
})
export class CampaignNavigationComponent implements OnChanges {
export class CampaignNavigationComponent implements OnInit {
@Input() campaigns: Campaign[];
campaigns$: Observable<Campaign[]>;
@Input() selectedCampaignId;
@ -27,13 +37,15 @@ export class CampaignNavigationComponent implements OnChanges {
repeater;
constructor(public loginService: LoginService) {
constructor(public loginService: LoginService,
private campaignService: CampaignService) {
this.campaigns$ = campaignService.campaigns$;
}
ngOnChanges(changes: SimpleChanges) {
if (!changes.selectedCampaignId) {
this.isRightScrollVisible = this.campaigns.length > 4;
}
ngOnInit() {
this.campaigns$.subscribe(campaigns => {
this.isRightScrollVisible = campaigns.length > 4;
});
}
select(campaign) {

View File

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