feat(data): add data detail templates

Additionally clean up the code
This commit is contained in:
Jovan Krunić
2019-04-10 15:01:00 +02:00
parent 75ca8c8a73
commit 5855accc16
58 changed files with 1015 additions and 91 deletions

View File

@@ -16,9 +16,9 @@ import {Component, Input} from '@angular/core';
import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '@openstapps/core';
@Component({
selector: 'stapps-offers-in-list',
templateUrl: 'offers-in-list.html',
selector: 'stapps-academic-offers-detail',
templateUrl: 'academic-offers-detail.html',
})
export class OffersInListComponent {
export class AcademicOffersDetailComponent {
@Input() offers: Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
}

View File

@@ -0,0 +1,36 @@
<ion-card>
<ion-card-header>Offers</ion-card-header>
<ion-card-content>
<div *ngFor="let offer of offers">
<p *ngIf="offer.inPlace">
<ion-icon name="pin"></ion-icon>
<a [routerLink]="['/data-detail', offer.inPlace.uid]">{{offer.inPlace.name}}</a>,&nbsp;
<span *ngIf="offer.availabilityStarts">
<ion-icon name="calendar"></ion-icon> {{offer.availabilityStarts | date}}
</span>
</p>
<ion-grid>
<ion-row *ngIf="offer.prices.student">
<ion-col>Students:</ion-col>
<ion-col width-20 text-right>
<p *ngIf="offer.prices.student"> {{offer.prices.student | currency:'EUR':'symbol':undefined:'de'}}</p>
</ion-col>
</ion-row>
<ion-row *ngIf="offer.prices.employee">
<ion-col>Employees:</ion-col>
<ion-col width-20 text-right>
<p *ngIf="offer.prices.employee"> {{offer.prices.employee | currency:'EUR':'symbol':undefined:'de'}}
</p>
</ion-col>
</ion-row>
<ion-row *ngIf="offer.prices.guest">
<ion-col>Guests:</ion-col>
<ion-col width-20 text-right>
<p *ngIf="offer.prices.guest">
{{offer.prices.guest | currency:'EUR':'symbol':undefined:'de'}}</p>
</ion-col>
</ion-row>
</ion-grid>
</div>
</ion-card-content>
</ion-card>

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 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, Input} from '@angular/core';
import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '@openstapps/core';
@Component({
selector: 'stapps-academic-offers-in-list',
templateUrl: 'academic-offers-in-list.html',
})
export class AcademicOffersInListComponent {
@Input() offers: Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 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, Input} from '@angular/core';
import {SCPostalAddress} from '@openstapps/core';
@Component({
selector: 'stapps-address-detail',
templateUrl: 'address-detail.html',
})
export class AddressDetailComponent {
@Input() address: SCPostalAddress;
}

View File

@@ -0,0 +1,43 @@
<ion-card>
<ion-card-header>Address</ion-card-header>
<ion-card-content>
<ion-grid>
<ion-row>
<ion-col>Street:</ion-col>
<ion-col width-60 text-right>
{{address.streetAddress}}
</ion-col>
</ion-row>
<ion-row>
<ion-col>Postal code:</ion-col>
<ion-col width-60 text-right>
{{address.postalCode}}
</ion-col>
</ion-row>
<ion-row>
<ion-col>City:</ion-col>
<ion-col width-60 text-right>
{{address.addressLocality}}
</ion-col>
</ion-row>
<ion-row *ngIf="address.addressRegion">
<ion-col>Region:</ion-col>
<ion-col width-60 text-right>
{{address.addressRegion}}
</ion-col>
</ion-row>
<ion-row>
<ion-col>Country:</ion-col>
<ion-col width-60 text-right>
{{address.addressCountry}}
</ion-col>
</ion-row>
<ion-row *ngIf="address.postOfficeBoxNumber">
<ion-col>Post office box:</ion-col>
<ion-col width-60 text-right>
{{address.postOfficeBoxNumber}}
</ion-col>
</ion-row>
</ion-grid>
</ion-card-content>
</ion-card>

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 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, Input} from '@angular/core';
import {SCThingOrigin} from '@openstapps/core';
@Component({
selector: 'stapps-origin-detail',
templateUrl: 'origin-detail.html',
})
export class OriginDetailComponent {
@Input() origin: SCThingOrigin;
}

View File

@@ -0,0 +1,25 @@
<ion-card *ngIf="origin.type === 'user'">
<ion-card-header>Origin(user)</ion-card-header>
<ion-card-content>
<p>Created: {{origin.created | amDateFormat:'DD. MMM YYYY'}}</p>
<p *ngIf="origin.updated">Updated: {{origin.updated | amDateFormat:'DD. MMM YYYY'}}</p>
<p *ngIf="origin.modified">Modified: {{origin.modified | amDateFormat:'DD. MMM YYYY'}}</p>
<p *ngIf="origin.maintainer">
Maintainer: <a [routerLink]="['/data-detail', origin.maintainer.uid]">{{origin.maintainer.name}}</a>
</p>
</ion-card-content>
</ion-card>
<ion-card *ngIf="origin.type === 'remote'">
<ion-card-header>Origin(remote)</ion-card-header>
<ion-card-content>
<p>Indexed: {{origin.indexed | amDateFormat:'DD. MMM YYYY'}}</p>
<p *ngIf="origin.modified">Modified: {{origin.modified | amDateFormat:'DD. MMM YYYY'}}</p>
<p *ngIf="origin.maintainer">
Maintainer: <a [routerLink]="['/data-detail', origin.maintainer.uid]">{{origin.maintainer.name}}</a>
</p>
<p *ngIf="origin.responsibleEntity">
Responsible: <a [routerLink]="['/data-detail', origin.responsibleEntity.uid]">{{origin.responsibleEntity.name}}</a>
</p>
</ion-card-content>
</ion-card>

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 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, Input} from '@angular/core';
import {SCThingOrigin} from '@openstapps/core';
@Component({
selector: 'stapps-origin-in-list',
templateUrl: 'origin-in-list.html',
})
export class OriginInListComponent {
@Input() origin: SCThingOrigin;
}

View File

@@ -0,0 +1,7 @@
<div *ngIf="origin.type === 'user'">
<p>{{origin.created | amDateFormat:'DD. MMM YY'}}</p>
</div>
<div *ngIf="origin.type === 'remote'">
<p>{{origin.indexed | amDateFormat:'DD. MMM YY'}}</p>
</div>

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2019 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, Input} from '@angular/core';
import {isThing, SCThing} from '@openstapps/core';
@Component({
selector: 'stapps-simple-card',
templateUrl: 'simple-card.html',
})
export class CardOfArrayComponent {
areThings: boolean = false;
@Input() content: string | string[] | SCThing[];
@Input() isMarkdown: boolean = false;
@Input() title: string;
isString(data: any): data is string {
return typeof data === 'string';
}
isThing(something: any): something is SCThing {
return isThing(something);
}
}

View File

@@ -0,0 +1,27 @@
<ion-card>
<ion-card-header>{{title}}</ion-card-header>
<ion-card-content>
<ng-container *ngIf="isString(content) then text; else list">
</ng-container>
<ng-template #text>
<ng-container *ngIf="isMarkdown; else plainText">
<markdown [data]="content"></markdown>
</ng-container>
<ng-template #plainText>
<p>{{content}}</p>
</ng-template>
</ng-template>
<ng-template #list>
<ng-container *ngIf="isThing(content[0]) then thingList; else textList">
</ng-container>
<ng-template #thingList>
<a [routerLink]="['/data-detail', thing.uid]" *ngFor="let thing of content">
<p>{{thing.name}}</p>
</a>
</ng-template>
<ng-template #textList>
<p *ngFor="let text of content">{{text}}</p>
</ng-template>
</ng-template>
</ion-card-content>
</ion-card>