Commit f442b1cf by Tuukka Kivilahti

viplist changes

1 parent 091de5de
...@@ -32,9 +32,31 @@ Oma moduulinsa, joka tullaan jossain vaiheessa eriyttämään ja käyttämään ...@@ -32,9 +32,31 @@ Oma moduulinsa, joka tullaan jossain vaiheessa eriyttämään ja käyttämään
### Muuta ### Muuta
Jos tulee muita järkeviä kokonaisuuksia, joita voi käyttää muualla, jaa omaan moduuliinsa. Jos tulee muita järkeviä kokonaisuuksia, joita voi käyttää muualla, jaa omaan moduuliinsa.
## Hakemistohierarkia ## WIP: Hakemistohierarkia
* app
* modules
* viplist
* viplist.component
* viplist.module
* pizza
* user-pizza
* user-pizza.component
* admin-pizza
* admin-pizza.component
* services
* pizza.service
* common
* pizza-list.component (shared for user / admin pizza)
* pizza.module
* shared
* components
* services
* models
* auth
Älykäs komponentti:
* app * app
* pages `tämän alla on käytännössä "älykkäät" komponentit (stateful), eli componentit jotka tietää mitä dataa haetaan ja mistä. Käytännössä route -targetit` * pages `tämän alla on käytännössä "älykkäät" komponentit (stateful), eli componentit jotka tietää mitä dataa haetaan ja mistä. Käytännössä route -targetit`
......
...@@ -12,12 +12,11 @@ import { BrowserModule } from '@angular/platform-browser'; ...@@ -12,12 +12,11 @@ import { BrowserModule } from '@angular/platform-browser';
import { MoyaLocaleComponent } from './components/moya-locale/moya-locale.component'; import { MoyaLocaleComponent } from './components/moya-locale/moya-locale.component';
import { TopMenuComponent } from './menu/top-menu/top-menu.component'; import { TopMenuComponent } from './menu/top-menu/top-menu.component';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { LoginComponent } from './pages/login/login.component';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import {MatTableModule} from "@angular/material";
@NgModule({ @NgModule({
declarations: [ declarations: [
LoginComponent,
AppComponent, AppComponent,
TopMenuComponent, TopMenuComponent,
MoyaLocaleComponent MoyaLocaleComponent
...@@ -27,6 +26,8 @@ import { NgModule } from '@angular/core'; ...@@ -27,6 +26,8 @@ import { NgModule } from '@angular/core';
AppRoutingModule, AppRoutingModule,
FormsModule, FormsModule,
HttpClientModule, HttpClientModule,
MatTableModule,
AlertModule.forRoot(), AlertModule.forRoot(),
TranslateModule.forRoot({ TranslateModule.forRoot({
loader: { loader: {
......
<mat-table [dataSource]="vips | async">
<ng-container matColumnDef="host">
<mat-header-cell *matHeaderCellDef translate> vip.host </mat-header-cell>
<mat-cell *matCellDef="let v"> {{v.host.firstname v.host.lastname}} </mat-cell>
</ng-container>
<ng-container matColumnDef="host">
<mat-header-cell *matHeaderCellDef translate> vip.shortdescr </mat-header-cell>
<mat-cell *matCellDef="let v"> {{v.shortdescr}} </mat-cell>
</ng-container>
<ng-container matColumnDef="host">
<mat-header-cell *matHeaderCellDef translate> vip.description </mat-header-cell>
<mat-cell *matCellDef="let v"> {{v.description}} </mat-cell>
</ng-container>
<ng-container matColumnDef="host">
<mat-header-cell *matHeaderCellDef translate> vip.products </mat-header-cell>
<mat-cell *matCellDef="let v">
<div *ngFor="let p of v.products" class="row">
<div style="display: inline-block;">{{p.name}}</div>
<div style="display: inline-block;">{{p.quantity}}</div>
<div style="display: inline-block; flex: 1;"> </div>
</div>
</mat-cell>
</ng-container>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
import {Component, NgZone, OnInit} from '@angular/core'; import {Component, NgZone, OnInit} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Vip} from '../../../shared/models/vip.model'; import {Vip} from '../../../shared/models/vip.model';
import {ViplistService} from './viplist.service'; import {ViplistService} from '../viplist.service';
@Component({ @Component({
selector: 'moya-viplist', selector: 'moya-viplist',
...@@ -13,6 +13,8 @@ export class ViplistComponent implements OnInit { ...@@ -13,6 +13,8 @@ export class ViplistComponent implements OnInit {
vips: Observable<Array<Vip>>; vips: Observable<Array<Vip>>;
displayedColumns = ['host', 'shortdescr', 'description', 'products'];
constructor(private viplistService: ViplistService) { constructor(private viplistService: ViplistService) {
} }
......
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Vip} from '../../../shared/models/vip.model'; import {Vip} from '../../shared/models/vip.model';
import {User} from '../../../shared/models/user.model'; import {User} from '../../shared/models/user.model';
import {UserService} from '../../../shared/services/user.service'; import {UserService} from '../../shared/services/user.service';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap'; import 'rxjs/add/operator/switchMap';
import 'rxjs/add/observable/forkJoin'; import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/first'; import 'rxjs/add/operator/first';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {MOYA_BASE_URL} from '../../../shared/tools/moya-rest.tool'; import {MOYA_BASE_URL} from '../../shared/tools/moya-rest.tool';
@Injectable() @Injectable()
export class ViplistService { export class ViplistService {
......
import { ViplistComponent } from './viplist/viplist.component'; import { ViplistComponent } from '../../modules/viplist/info/viplist.component';
import { OldMoyaComponent } from './../old-moya/old-moya.component'; import { OldMoyaComponent } from './../old-moya/old-moya.component';
import { InfoMenuComponent } from './../../menu/info-menu/info-menu.component'; import { InfoMenuComponent } from './../../menu/info-menu/info-menu.component';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
......
import { ViplistComponent } from './viplist/viplist.component'; import { ViplistComponent } from '../../modules/viplist/info/viplist.component';
import { OldMoyaModule } from './../old-moya/old-moya.module'; import { OldMoyaModule } from './../old-moya/old-moya.module';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
......
<div class="container-fluid">
<div class="row bg-primary text-white titlerow">
<div class="col">Isäntä</div>
<div class="col-3">Nimi</div>
<div class="col">Kuvaus</div>
<div class="col-4">Tuotteet</div>
<div class="col">Muokkaa</div>
</div>
<div *ngFor="let vip of vips | async" class="row contentrow">
<div class="col">{{vip.host.firstname}}</div>
<div class="col-3"><b>{{vip.shortdescr}}</b></div>
<div class="col">{{vip.description}}</div>
<div class="col-4">
<div *ngFor="let p of vip.products" class="row">
<div style="display: inline-block;">{{p.name}}</div>
<div style="display: inline-block;">{{p.quantity}}</div>
<div style="display: inline-block; flex: 1;"> </div>
<div style="display: inline-block;"><button type="button" class="btn btn-default">Toimita</button></div>
</div>
</div>
<div class="col">todo</div>
</div>
<div *ngFor="let vip of vips | async" class="row contentrow">
<div class="col">{{vip.host.firstname}}</div>
<div class="col-3"><b>{{vip.shortdescr}}</b></div>
<div class="col">{{vip.description}}</div>
<div class="col-4">
<div *ngFor="let p of vip.products" class="row">
<div style="display: inline-block;">{{p.name}}</div>
<div style="display: inline-block;">{{p.quantity}}</div>
<div style="display: inline-block; flex: 1;"> </div>
<div style="display: inline-block;"><button type="button" class="btn btn-default">Toimita</button></div>
</div>
</div>
<div class="col">todo</div>
</div>
</div>
<br /><br />
<br /><br />
<br /><br />
<!--
<table class="table table-striped">
<thead>
<tr class="bg-primary text-white">
<th>Isäntä</th>
<th>Nimi</th>
<th>Kuvaus</th>
<th>Tuotteet</th>
<th>Muokkaa</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let vip of vips | async" >
<td class="">Kekkonen kekkonen</td>
<td class=""><b>{{vip.shortdescr}}</b></td>
<td class="">{{vip.description}}</td>
<td class="">
<div *ngFor="let p of vip.products" class="productsRow">
<div>{{p.name}}</div>
<div>{{p.quantity}}</div>
<div style="flex: 1;"> </div>
<div><button type="button" class="btn btn-default">Toimita</button></div>
</div>
</td>
<td class="">todo</td>
</tr>
</tbody>
</table>
-->
<span i18n>This is testfile</span>
<br />
<br />
<br />
<h1 i18n>Counter value</h1>
{{counter}}
<p i18n>{counter, plural, =0 {not pressed} =1 {pressed once} other {pressed many times}} </p>
<button (click)="addOne()" i18n>ADD ONE</button>
<span i18n>This is testfile</span>
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { TestComponent } from './test.component';
describe('TestComponent', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TestComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import {Component, OnInit, Input} from '@angular/core';
@Component({
selector: 'moya-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss']
})
export class TestComponent implements OnInit {
@Input() counter: number;
constructor() {
this.counter = 0;
}
ngOnInit() {
}
addOne() {
this.counter++;
}
}
{ {
"test": { "test": {
"user": "Userna" "user": "Användare",
},
"general": {
"yes": "Ja",
"no": "Nej",
"save": "Spara",
"edit": "Edigera",
"control": "Kontrollera",
},
"vip": {
"host": "Värd",
"shortdescr": "Namn",
"description": "Beskrivning",
"products": "Produkter",
"deliver": "Leverera",
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!