Add Motion Detail Desktop view

This commit is contained in:
Sean Engelhardt 2018-09-03 14:23:54 +02:00
parent fa9d8de21c
commit 90e8c81ddc
4 changed files with 286 additions and 181 deletions

View File

@ -33,171 +33,227 @@
</mat-menu> </mat-menu>
</mat-toolbar> </mat-toolbar>
<mat-accordion multi='true' class='on-transition-fade'> <ng-container *ngIf="vp.isMobile ; then mobileView; else desktopView"></ng-container>
<!-- MetaInfo --> <ng-template #mobileView>
<!-- <mat-expansion-panel #metaInfoPanel [expanded]='true' class='meta-info-panel'> --> <mat-accordion multi='true' class='on-transition-fade'>
<mat-expansion-panel #metaInfoPanel [expanded]='this.editMotion && this.newMotion' class='meta-info-panel'>
<mat-expansion-panel-header>
<mat-panel-title>
<fa-icon icon='info-circle' [fixedWidth]="true"></fa-icon>
<span translate>Meta information</span>
</mat-panel-title>
</mat-expansion-panel-header>
<!-- Meta info --> <!-- MetaInfo Panel-->
<form [formGroup]='metaInfoForm' class='expansion-panel-custom-body' (ngSubmit)='saveMotion()'> <mat-expansion-panel #metaInfoPanel [expanded]='this.editMotion && this.newMotion' class='meta-info-block meta-info-panel'>
<mat-expansion-panel-header>
<mat-panel-title>
<fa-icon icon='info-circle' [fixedWidth]="true"></fa-icon>
<span translate>Meta information</span>
</mat-panel-title>
</mat-expansion-panel-header>
<!-- Identifier --> <!-- Meta info -->
<div *ngIf="editMotion && !newMotion"> <div class="expansion-panel-custom-body">
<!-- <div *ngIf="editMotion"> --> <ng-container *ngTemplateOutlet="metaInfoTemplate"></ng-container>
<div *ngIf='!editMotion'> </div>
<h3 translate>Identifier</h3> </mat-expansion-panel>
{{motion.identifier}}
</div> <!-- Personal Note -->
<mat-form-field *ngIf="editMotion"> <mat-expansion-panel>
<input matInput placeholder='Identifier' formControlName='identifier' [value]='motionCopy.identifier'> <mat-expansion-panel-header>
</mat-form-field> <mat-panel-title>
<fa-icon icon='file-signature' [fixedWidth]="true"></fa-icon>
<span translate>Personal note</span>
</mat-panel-title>
</mat-expansion-panel-header>
TEST
</mat-expansion-panel>
<!-- Content -->
<mat-expansion-panel #contentPanel [expanded]='true' class='content-panel'>
<mat-expansion-panel-header>
<mat-panel-title>
<fa-icon icon='align-left' [fixedWidth]="true"></fa-icon>
<span translate>Content</span>
</mat-panel-title>
</mat-expansion-panel-header>
<div class="expansion-panel-custom-body">
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
</div>
</mat-expansion-panel>
</mat-accordion>
</ng-template>
<ng-template #desktopView>
<div class="desktop-view">
<div class="desktop-left on-transition-fade">
<!-- Meta Info -->
<div class="meta-info-block meta-info-desktop">
<ng-container *ngTemplateOutlet="metaInfoTemplate"></ng-container>
</div> </div>
<!-- Submitter --> <!-- Personal Note -->
<div *ngIf="motion && motion.submitters || editMotion"> <div class="personal-note">
<h3 translate>Submitters</h3> <mat-card>
{{motion.submitterAsUser}} <mat-card-header>
<mat-card-title>
<span translate>Personal Note</span>
<div class="title-right">
<fa-icon icon="pen" [fixedWidth]=" true"></fa-icon>
<fa-icon icon="ellipsis-v" [fixedWidth]="true"></fa-icon>
</div>
</mat-card-title>
</mat-card-header>
<mat-card-content>
Hier könnte ihre Werbung stehen. 1 2 3 4 5 6 Hier könnte ihre Werbung stehen. 1 2 3 4 5 6
</mat-card-content>
</mat-card>
</div> </div>
<!-- Supporter --> </div>
<div *ngIf='motion && motion.supporters_id && motion.supporters_id.length > 0 || editMotion'> <div class="desktop-right ">
<h3 translate>Supporters</h3>
<!-- print all motion supporters --> <!-- Content -->
<mat-card class="content-panel">
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
</mat-card>
</div>
</div>
</ng-template>
<ng-template #metaInfoTemplate>
<form [formGroup]='metaInfoForm' (ngSubmit)='saveMotion()'>
<!-- Identifier -->
<div *ngIf="editMotion && !newMotion">
<!-- <div *ngIf="editMotion"> -->
<div *ngIf='!editMotion'>
<h3 translate>Identifier</h3>
{{motion.identifier}}
</div> </div>
<mat-form-field *ngIf="editMotion">
<input matInput placeholder='Identifier' formControlName='identifier' [value]='motionCopy.identifier'>
</mat-form-field>
</div>
<!-- State --> <!-- Submitter -->
<div *ngIf='!newMotion && motion && motion.workflow && motion.state_id || editMotion'> <div *ngIf="motion && motion.submitters || editMotion">
<div *ngIf='!editMotion'> <h3 translate>Submitters</h3>
<h3 translate>State</h3> {{motion.submitterAsUser}}
{{motion.state}} </div>
</div>
<mat-form-field *ngIf="editMotion && !newMotion"> <!-- Supporter -->
<mat-select placeholder='State' formControlName='state_id'> <div *ngIf='motion && motion.supporters_id && motion.supporters_id.length > 0 || editMotion'>
<mat-option [value]="motionCopy.state.id">{{motionCopy.state}}</mat-option> <h3 translate>Supporters</h3>
<mat-divider></mat-divider> <!-- print all motion supporters -->
<mat-option *ngFor="let state of motionCopy.nextStates" [value]="state.id">{{state}}</mat-option> </div>
<mat-divider></mat-divider>
<mat-option> <!-- State -->
<fa-icon icon='exclamation-triangle'></fa-icon> <span translate>Reset State</span> <div *ngIf='!newMotion && motion && motion.workflow && motion.state_id || editMotion'>
</mat-option> <div *ngIf='!editMotion'>
</mat-select> <h3 translate>State</h3>
</mat-form-field> {{motion.state}}
</div> </div>
<mat-form-field *ngIf="editMotion && !newMotion">
<mat-select placeholder='State' formControlName='state_id'>
<mat-option [value]="motionCopy.state.id">{{motionCopy.state}}</mat-option>
<mat-divider></mat-divider>
<mat-option *ngFor="let state of motionCopy.nextStates" [value]="state.id">{{state}}</mat-option>
<mat-divider></mat-divider>
<mat-option>
<fa-icon icon='exclamation-triangle'></fa-icon> <span translate>Reset State</span>
</mat-option>
</mat-select>
</mat-form-field>
</div>
<!-- Recommendation --> <!-- Recommendation -->
<!-- The suggestion of the work group weather or not a motion should be accepted --> <!-- The suggestion of the work group weather or not a motion should be accepted -->
<div *ngIf='motion && motion.recomBy && (motion.recommendation_id || editMotion)'> <div *ngIf='motion && motion.recomBy && (motion.recommendation_id || editMotion)'>
<div *ngIf='!editMotion'> <div *ngIf='!editMotion'>
<h3>{{motion.recomBy}}</h3> <h3>{{motion.recomBy}}</h3>
{{motion.recommendation.name}} {{motion.recommendation.name}}
</div>
<mat-form-field *ngIf="motion && editMotion">
<mat-select placeholder='Recommendation' formControlName='recommendation_id'>
<mat-option *ngFor="let state of motionCopy.nextStates" [value]="state.id">{{state}}</mat-option>
<mat-divider></mat-divider>
<!-- TODO has no effect -->
<mat-option>
<fa-icon icon='exclamation-triangle'></fa-icon>
<span translate>Reset recommendation</span>
</mat-option>
</mat-select>
</mat-form-field>
</div> </div>
<mat-form-field *ngIf="motion && editMotion">
<mat-select placeholder='Recommendation' formControlName='recommendation_id'>
<mat-option *ngFor="let state of motionCopy.nextStates" [value]="state.id">{{state}}</mat-option>
<mat-divider></mat-divider>
<!-- Category --> <!-- TODO has no effect -->
<div *ngIf="motion && motion.category_id || editMotion"> <mat-option>
<div *ngIf='!editMotion'> <fa-icon icon='exclamation-triangle'></fa-icon>
<h3 translate> Category</h3> <span translate>Reset recommendation</span>
{{motion.category}} </mat-option>
</div> </mat-select>
<mat-form-field *ngIf="motion && editMotion"> </mat-form-field>
<mat-select placeholder='Category' formControlName='category_id'> </div>
<mat-option>None</mat-option>
<mat-divider></mat-divider> <!-- Category -->
<mat-option *ngFor="let cat of getMotionCategories()" [value]="cat.id">{{cat}}</mat-option> <div *ngIf="motion && motion.category_id || editMotion">
</mat-select> <div *ngIf='!editMotion'>
</mat-form-field> <h3 translate> Category</h3>
{{motion.category}}
</div> </div>
<mat-form-field *ngIf="motion && editMotion">
<mat-select placeholder='Category' formControlName='category_id'>
<mat-option>None</mat-option>
<mat-divider></mat-divider>
<mat-option *ngFor="let cat of getMotionCategories()" [value]="cat.id">{{cat}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<!-- Origin --> <!-- Origin -->
<div *ngIf="motion && motion.origin || editMotion"> <div *ngIf="motion && motion.origin || editMotion">
<div *ngIf='!editMotion'> <div *ngIf='!editMotion'>
<h3 translate> Origin</h3> <h3 translate> Origin</h3>
{{motion.origin}} {{motion.origin}}
</div>
<mat-form-field *ngIf="editMotion">
<input matInput placeholder='Origin' formControlName='origin' [value]='motionCopy.origin'>
</mat-form-field>
</div> </div>
<mat-form-field *ngIf="editMotion">
<input matInput placeholder='Origin' formControlName='origin' [value]='motionCopy.origin'>
</mat-form-field>
</div>
<!-- Voting --> <!-- Voting -->
<!-- <div *ngIf='motion.polls && motion.polls.length > 0 || editMotion'> <!-- <div *ngIf='motion.polls && motion.polls.length > 0 || editMotion'>
<h3 translate>Voting</h3> <h3 translate>Voting</h3>
</div> --> </div> -->
</form> </form>
</mat-expansion-panel> </ng-template>
<!-- Personal Note --> <ng-template #contentTemplate>
<mat-expansion-panel> <form [formGroup]='contentForm' (ngSubmit)='saveMotion()'>
<mat-expansion-panel-header>
<mat-panel-title>
<fa-icon icon='file-signature' [fixedWidth]="true"></fa-icon>
<span translate>Personal note</span>
</mat-panel-title>
</mat-expansion-panel-header>
TEST
</mat-expansion-panel>
<!-- Content --> <!-- Title -->
<mat-expansion-panel #contentPanel [expanded]='true' class='content-panel'> <div *ngIf="motion && motion.currentTitle || editMotion">
<mat-expansion-panel-header> <div *ngIf='!editMotion'>
<mat-panel-title> <h2>{{motion.currentTitle}}</h2>
<fa-icon icon='align-left' [fixedWidth]="true"></fa-icon>
<span translate>Content</span>
</mat-panel-title>
</mat-expansion-panel-header>
<form [formGroup]='contentForm' class='expansion-panel-custom-body' (ngSubmit)='saveMotion()'>
<!-- Title -->
<div *ngIf="motion && motion.currentTitle || editMotion">
<div *ngIf='!editMotion'>
<h2>{{motion.currentTitle}}</h2>
</div>
<mat-form-field *ngIf="editMotion" class='wide-text'>
<input matInput placeholder='Title' formControlName='currentTitle' [value]='motionCopy.currentTitle'>
</mat-form-field>
</div> </div>
<mat-form-field *ngIf="editMotion" class="wide-form">
<!-- Text --> <input matInput placeholder='Title' formControlName='currentTitle' [value]='motionCopy.currentTitle'>
<!-- TODO: this is a config variable. Read it out -->
<h3 translate>The assembly may decide:</h3>
<div *ngIf='motion && !editMotion'>
<div [innerHtml]='motion.currentText'></div>
</div>
<mat-form-field *ngIf="motion && editMotion" class='wide-text'>
<textarea matInput placeholder='Motion Text' formControlName='currentText' [value]='motionCopy.currentText'></textarea>
</mat-form-field> </mat-form-field>
<!-- Reason --> </div>
<div *ngIf="motion && motion.currentReason || editMotion">
<div *ngIf='!editMotion'>
<h4 translate>Reason</h4>
<div [innerHtml]='motion.currentReason'></div>
</div>
<mat-form-field *ngIf="editMotion" class='wide-text'>
<textarea matInput placeholder="Reason" formControlName='currentReason' [value]='motionCopy.currentReason'></textarea>
</mat-form-field>
</div>
</form> <!-- Text -->
</mat-expansion-panel> <!-- TODO: this is a config variable. Read it out -->
</mat-accordion> <h3 translate>The assembly may decide:</h3>
<div *ngIf='motion && !editMotion'>
<div [innerHtml]='motion.currentText'></div>
</div>
<mat-form-field *ngIf="motion && editMotion" class="wide-form">
<textarea matInput placeholder='Motion Text' formControlName='currentText' [value]='motionCopy.currentText'></textarea>
</mat-form-field>
<!-- Reason -->
<div *ngIf="motion && motion.currentReason || editMotion">
<div *ngIf='!editMotion'>
<h4 translate>Reason</h4>
<div [innerHtml]='motion.currentReason'></div>
</div>
<mat-form-field *ngIf="editMotion" class="wide-form">
<textarea matInput placeholder="Reason" formControlName='currentReason' [value]='motionCopy.currentReason'></textarea>
</mat-form-field>
</div>
</form>
</ng-template>

View File

@ -27,13 +27,7 @@ mat-panel-title {
} }
} }
.meta-info-panel { .meta-info-block {
padding-top: 25px;
a:hover {
cursor: pointer;
}
h3 { h3 {
display: block; display: block;
margin-top: 12px; //distance between heading and text margin-top: 12px; //distance between heading and text
@ -62,11 +56,21 @@ mat-panel-title {
} }
} }
.wide-text { .wide-form {
width: 95%;
textarea { textarea {
height: 200px; height: 25vh;
}
::ng-deep {
width: 100%;
}
}
.meta-info-panel {
padding-top: 25px;
a:hover {
cursor: pointer;
} }
} }
@ -95,3 +99,61 @@ mat-expansion-panel {
font-size: 100%; font-size: 100%;
} }
} }
.desktop-view {
.desktop-left {
width: 30%;
float: left;
.meta-info-desktop {
padding: 40px 20px 10px 20px;
}
.personal-note {
mat-card {
padding: 0px;
margin: 20px;
min-width: 10hv;
min-width: 200px;
.mat-card-header-text {
width: 100%;
}
mat-card-header {
display: inherit;
padding: 15px;
margin: 0;
background-color: #eee;
.title-right {
float: right;
fa-icon {
padding-left: 10px;
}
}
mat-card-title {
font-weight: bold;
display: inline;
}
}
mat-card-content {
padding: 30px 15px 15px 15px;
}
}
}
}
.desktop-right {
display: grid;
min-width: 70%;
mat-card {
display: inline;
margin: 20px;
}
}
}

View File

@ -1,11 +1,13 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { MatExpansionPanel } from '@angular/material';
import { BaseComponent } from '../../../base.component'; import { BaseComponent } from '../../../base.component';
import { Motion } from '../../../shared/models/motions/motion'; import { Motion } from '../../../shared/models/motions/motion';
import { Category } from '../../../shared/models/motions/category'; import { Category } from '../../../shared/models/motions/category';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { MatExpansionPanel } from '@angular/material';
import { DataSendService } from '../../../core/services/data-send.service'; import { DataSendService } from '../../../core/services/data-send.service';
import { ViewportService } from '../../../core/services/viewport.service';
/** /**
* Component for the motion detail view * Component for the motion detail view
@ -59,11 +61,14 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
/** /**
* Constuct the detail view. * Constuct the detail view.
* *
* * @param vp the viewport service
* @param router to navigate back to the motion list and to an existing motion
* @param route determine if this is a new or an existing motion * @param route determine if this is a new or an existing motion
* @param formBuilder For reactive forms. Form Group and Form Control * @param formBuilder For reactive forms. Form Group and Form Control
* @param dataSend To send changes of the motion
*/ */
public constructor( public constructor(
public vp: ViewportService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
@ -180,8 +185,11 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
this.motionCopy = new Motion(); this.motionCopy = new Motion();
this.motionCopy.patchValues(this.motion); this.motionCopy.patchValues(this.motion);
this.patchForm(this.motionCopy); this.patchForm(this.motionCopy);
this.metaInfoPanel.open();
this.contentPanel.open(); if (this.vp.isMobile) {
this.metaInfoPanel.open();
this.contentPanel.open();
}
} else { } else {
this.saveMotion(); this.saveMotion();
} }

View File

@ -1,24 +1,3 @@
<!-- <mat-toolbar color='primary'>
<button class='generic-plus-button on-transition-fade' routerLink='new' mat-fab>
<fa-icon icon='plus'></fa-icon>
</button>
<span class='app-name on-transition-fade' translate>Motions</span>
<span class='spacer'></span>
<button class='on-transition-fade' mat-icon-button [matMenuTriggerFor]="motionExtraMenu">
<fa-icon icon='ellipsis-v'></fa-icon>
</button>
<mat-menu #motionExtraMenu="matMenu">
<button mat-menu-item translate><fa-icon icon='download'></fa-icon> Export As...</button>
<button mat-menu-item routerLink='category' translate>Categories</button>
</mat-menu>
</mat-toolbar> -->
<os-head-bar appName="Motions" plusButton=true (plusButtonClicked)=onPlusButton() [menuList]=motionMenuList (ellipsisMenuItem)=onEllipsisItem($event)> <os-head-bar appName="Motions" plusButton=true (plusButtonClicked)=onPlusButton() [menuList]=motionMenuList (ellipsisMenuItem)=onEllipsisItem($event)>
</os-head-bar> </os-head-bar>
@ -71,4 +50,4 @@
<mat-row (click)='selectMotion(row)' *matRowDef="let row; columns: columnsToDisplayMinWidth"></mat-row> <mat-row (click)='selectMotion(row)' *matRowDef="let row; columns: columnsToDisplayMinWidth"></mat-row>
</mat-table> </mat-table>
<mat-paginator class="on-transition-fade" [pageSizeOptions]="[25, 50, 75, 100, 125]"></mat-paginator> <mat-paginator class="on-transition-fade" [pageSizeOptions]="[25, 50, 75, 100, 125]"></mat-paginator>