mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: add the app
This commit is contained in:
68
src/app/modules/data/detail/data-detail.component.spec.ts
Normal file
68
src/app/modules/data/detail/data-detail.component.spec.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {ActivatedRoute, RouterModule} from '@angular/router';
|
||||
import {DataRoutingModule} from '../data-routing.module';
|
||||
import {DataListComponent} from '../list/data-list.component';
|
||||
import {DataDetailComponent} from './data-detail.component';
|
||||
|
||||
describe('DataDetailComponent', () => {
|
||||
let comp: DataDetailComponent;
|
||||
let fixture: ComponentFixture<DataDetailComponent>;
|
||||
let detailPage: HTMLElement;
|
||||
|
||||
// @Component({ selector: 'stapps-data-list-item', template: '' })
|
||||
// class DataListItemComponent {
|
||||
// @Input() item;
|
||||
// }
|
||||
|
||||
const fakeActivatedRoute = {
|
||||
snapshot: {
|
||||
paramMap: {
|
||||
get: (url) => {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
} as ActivatedRoute;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DataListComponent, DataDetailComponent],
|
||||
imports: [RouterModule, DataRoutingModule],
|
||||
providers: [{provide: ActivatedRoute, useValue: fakeActivatedRoute}],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async() => {
|
||||
fixture = await TestBed.createComponent(DataDetailComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create component', () =>
|
||||
expect(comp).toBeDefined(),
|
||||
);
|
||||
|
||||
it('should have apropriate title', () => {
|
||||
detailPage = fixture.nativeElement;
|
||||
const title: HTMLIonTitleElement | null = detailPage.querySelector('ion-title');
|
||||
expect(title).not.toBe(null);
|
||||
expect(title!.innerText).toContain('Detailansicht');
|
||||
});
|
||||
});
|
||||
41
src/app/modules/data/detail/data-detail.component.ts
Normal file
41
src/app/modules/data/detail/data-detail.component.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {SCThings} from '@openstapps/core';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-data-detail',
|
||||
templateUrl: 'data-detail.html'
|
||||
})
|
||||
export class DataDetailComponent {
|
||||
item: SCThings;
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.item = {
|
||||
categories: ['main dish'],
|
||||
name: 'Demo-Name',
|
||||
origin: {
|
||||
indexed: '2018-09-11T12:30:00Z',
|
||||
name: 'Dummy',
|
||||
},
|
||||
type: 'dish',
|
||||
uid: '',
|
||||
};
|
||||
}
|
||||
ngOnInit() {
|
||||
this.item.uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||
this.item.description = 'Demo Beschreibung für das Item mit der UID ' + this.item.uid;
|
||||
}
|
||||
}
|
||||
21
src/app/modules/data/detail/data-detail.html
Normal file
21
src/app/modules/data/detail/data-detail.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Detailansicht</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
<stapps-data-list-item [item]="item"></stapps-data-list-item>
|
||||
|
||||
<div [ngSwitch]="item.type">
|
||||
<stapps-dish-detail-content [item]="item" *ngSwitchCase="'dish'"></stapps-dish-detail-content>
|
||||
|
||||
<span *ngSwitchDefault>
|
||||
<p *ngIf="item.description">{{item.description}}</p>
|
||||
</span>
|
||||
</div>
|
||||
</ion-content>
|
||||
3
src/app/modules/data/detail/data-detail.scss
Normal file
3
src/app/modules/data/detail/data-detail.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
stapps-data-detail {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user