* Add toggle button filter replacement blueprint/util

* Improve startup scripts to match ng6 requirements
pull/40/head
HardiReady 2018-07-02 20:23:47 +02:00
parent cf43fab89f
commit 68ca503a76
5 changed files with 30 additions and 12 deletions

View File

@ -1,13 +1,14 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.7.8", "version": "1.8.0",
"author": "Florian Hartwich <hardi@noarch.de>", "author": "Florian Hartwich <hardi@noarch.de>",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "npm run deploy-static-prod && npm start --prefix ./api", "start": "npm run deploy-static-prod && npm start --prefix ./api",
"dev": "npm run deploy-static && npm run dev --prefix ./api", "dev": "npm run deploy-static && npm run dev --prefix ./api",
"deploy-static": "npm run build --prefix=static && npm run deploy-static:link-resource && npm run deploy-static:api-docs", "pre-deploy-clean": "unlink ./public/resource",
"deploy-static:prod": "npm run build:prod --prefix=static && npm run deploy-static:link-resource && npm run deploy-static:api-docs", "deploy-static": "npm run pre-deploy-clean && npm run build --prefix=static && npm run deploy-static:link-resource && npm run deploy-static:api-docs",
"deploy-static:prod": "pre-deploy-clean && npm run build:prod --prefix=static && npm run deploy-static:link-resource && npm run deploy-static:api-docs",
"deploy-static:link-resource": "ln -s ../api/resource/ public/resource", "deploy-static:link-resource": "ln -s ../api/resource/ public/resource",
"deploy-static:api-docs": "npm run api:docs --prefix=api", "deploy-static:api-docs": "npm run api:docs --prefix=api",
"postinstall": "npm install --prefix ./static && npm install --prefix ./api", "postinstall": "npm install --prefix ./static && npm install --prefix ./api",

View File

@ -1,9 +1,13 @@
<div class="select-list"> <div class="select-list">
<div class="input-group list-header"> <div class="list-header">
<div class="btn-group" (click)="filterRanks()"> <mat-button-toggle-group #group="matButtonToggleGroup">
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="BLUFOR" uncheckable>{{fraction.BLUFOR}}</label> <mat-button-toggle value="BLUFOR" (change)="filterRanks(group)">
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="OPFOR" uncheckable>{{fraction.OPFOR}}</label> {{fraction.BLUFOR}}
</div> </mat-button-toggle>
<mat-button-toggle value="OPFOR" (change)="filterRanks(group)">
{{fraction.OPFOR}}
</mat-button-toggle>
</mat-button-toggle-group>
<a class="pull-right btn btn-success" (click)="openNewRankForm()">+</a> <a class="pull-right btn btn-success" (click)="openNewRankForm()">+</a>
</div> </div>

View File

@ -7,6 +7,7 @@ import {Observable} from 'rxjs/Observable';
import {Rank} from '../../models/model-interfaces'; import {Rank} from '../../models/model-interfaces';
import {RankService} from '../../services/army-management/rank.service'; import {RankService} from '../../services/army-management/rank.service';
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {UIHelpers} from '../../utils/global.helpers';
@Component({ @Component({
selector: 'rank-list', selector: 'rank-list',
@ -21,7 +22,7 @@ export class RankListComponent implements OnInit {
searchTerm = new FormControl(); searchTerm = new FormControl();
public radioModel: string; radioModel = '';
readonly fraction = Fraction; readonly fraction = Fraction;
@ -60,7 +61,8 @@ export class RankListComponent implements OnInit {
this.router.navigate([{outlets: {'right': ['edit', rankId]}}], {relativeTo: this.route}); this.router.navigate([{outlets: {'right': ['edit', rankId]}}], {relativeTo: this.route});
} }
filterRanks() { filterRanks(group) {
this.radioModel = UIHelpers.toggleReleaseButton(this.radioModel, group);
this.ranks$ = this.rankService.findRanks(this.searchTerm.value, this.radioModel); this.ranks$ = this.rankService.findRanks(this.searchTerm.value, this.radioModel);
} }

View File

@ -4,11 +4,11 @@ import {SharedModule} from '../shared.module';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {RankService} from '../services/army-management/rank.service'; import {RankService} from '../services/army-management/rank.service';
import {RankStore} from '../services/stores/rank.store'; import {RankStore} from '../services/stores/rank.store';
import {ButtonsModule} from 'ngx-bootstrap'; import {MatButtonToggleModule} from '@angular/material';
@NgModule({ @NgModule({
declarations: ranksRoutingComponents, declarations: ranksRoutingComponents,
imports: [CommonModule, SharedModule, ButtonsModule.forRoot(), rankRouterModule], imports: [CommonModule, SharedModule, MatButtonToggleModule, rankRouterModule],
providers: [RankStore, RankService] providers: [RankStore, RankService]
}) })
export class RanksModule { export class RanksModule {

View File

@ -7,3 +7,14 @@ export const CSSHelpers = {
'background-repeat: no-repeat;'; 'background-repeat: no-repeat;';
} }
}; };
export const UIHelpers = {
toggleReleaseButton: (currentVal, group) => {
if (currentVal == group.value) {
group.value = '';
return '';
} else {
return group.value;
}
}
};