Skip to content

Commit

Permalink
Merge pull request #724 from HiP-App/HIPCMS-795-history
Browse files Browse the repository at this point in the history
Hipcms 795 history
  • Loading branch information
pschick authored Dec 11, 2017
2 parents e9b1c09 + 2b86ac2 commit 480d22f
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 35 deletions.
11 changes: 7 additions & 4 deletions app/mobile-content/exhibits/exhibits.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<md-card class="default-card">
<h1>{{ 'exhibits' | translate }}</h1>
<h1>{{ !inDeletedPage ? ( 'exhibits' | translate ) : 'Deleted exhibits'}}</h1>
<button *ngIf="( !inDeletedPage && isSupervisor)" [routerLink]="[ '/mobile-content/exhibits/deleted']" class="DeletedItems" md-raised-button color="primary" >
{{ 'Recently deleted' | translate }}
</button>
</md-card>

<md-card class="default-card">
Expand Down Expand Up @@ -57,10 +60,10 @@ <h2 md-line>{{ exhibit.name }} ({{ exhibit.status | translate }})
</p>

<button md-icon-button color="primary" [routerLink]="['/mobile-content/exhibits/edit', exhibit.id]" title="{{ 'edit' | translate }}">
<md-icon>edit</md-icon>
<md-icon>{{ !inDeletedPage ? 'edit' : 'remove_red_eye'}}</md-icon>
</button>
<button md-icon-button color="warn" (click)="deleteExhibit(exhibit)" *ngIf="!exhibit.used" title="{{ 'delete' | translate }}">
<md-icon>delete_forever</md-icon>
<button md-icon-button color="warn" (click)="deleteExhibit(exhibit)" *ngIf="!exhibit.used && !inDeletedPage" title="{{ 'delete' | translate }}">
<md-icon >delete_forever</md-icon>
</button>
</md-list-item>
</md-nav-list>
Expand Down
19 changes: 17 additions & 2 deletions app/mobile-content/exhibits/exhibits.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { MediaService } from '../media/shared/media.service';
import { Route } from '../routes/shared/route.model';
import { RouteService } from '../routes/shared/routes.service';
import { Status } from '../shared/status.model';
import { SupervisorGuard } from '../../shared/guards/supervisor-guard';
import { Tag } from '../tags/shared/tag.model';
import { TagService } from '../tags/shared/tag.service';

Expand All @@ -34,6 +35,8 @@ export class ExhibitsComponent implements OnInit {
previewsLoaded = false;
routes: Route[];
statuses = Status.getValuesForSearch();
isSupervisor: boolean;
inDeletedPage: boolean;
private exhibitCache = new Map<number, Exhibit[]>();
@Output() rating: number;

Expand Down Expand Up @@ -65,9 +68,13 @@ export class ExhibitsComponent implements OnInit {
private sanitizer: DomSanitizer,
private tagService: TagService,
private toasterService: ToasterService,
private translateService: TranslateService) { }
private translateService: TranslateService,
private supervisorGuard: SupervisorGuard) {
if (router.url === '/mobile-content/exhibits/deleted') {this.inDeletedPage = true; } else {this.inDeletedPage = false; }
}

ngOnInit() {
this.getIsSupervisor();
let allRoutesOption = Route.emptyRoute();
allRoutesOption.title = 'ALL';
this.routes = [allRoutesOption];
Expand All @@ -84,6 +91,13 @@ export class ExhibitsComponent implements OnInit {
this.getPage(1);
}

getIsSupervisor() {
this.supervisorGuard.isSupervisor().then(
(response: boolean) => {
this.isSupervisor = response;
});
}

createExhibit() {
let context = this;
this.createDialogRef = this.dialog.open(CreateExhibitDialogComponent, { width: '45em' });
Expand Down Expand Up @@ -139,7 +153,8 @@ export class ExhibitsComponent implements OnInit {
this.exhibits = this.exhibitCache.get(page);
this.currentPage = page;
} else {
this.exhibitService.getAllExhibits(page, this.exhibitsPerPage, this.selectedStatus,
let status = this.inDeletedPage ? 'Deleted' : this.selectedStatus;
this.exhibitService.getAllExhibits(page, this.exhibitsPerPage, status,
this.searchQuery, 'id', undefined,
this.selectedRoute !== -1 ? [this.selectedRoute] : undefined)
.then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ <h3 md-line>{{ medium.title }}</h3>
<p md-line>{{ medium.description }}</p>

<button *ngIf="!selectMode" md-icon-button color="primary" (click)="editMedium(medium)" title="{{ 'edit' | translate }}">
<md-icon>edit</md-icon>
<md-icon>{{ !inDeletedPage ? 'edit' : 'remove_red_eye'}}</md-icon>
</button>
<button *ngIf="!selectMode && !medium.used" md-icon-button color="warn" (click)="deleteMedium(medium)" title="{{ 'delete' | translate }}">
<button *ngIf="!selectMode && !medium.used && !inDeletedPage" md-icon-button color="warn" (click)="deleteMedium(medium)" title="{{ 'delete' | translate }}">
<md-icon>delete_forever</md-icon>
</button>
</md-list-item>
Expand Down
22 changes: 20 additions & 2 deletions app/mobile-content/media/media-gallery/media-gallery.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { TranslateService } from 'ng2-translate';

Expand All @@ -9,6 +10,7 @@ import { EditMediumDialogComponent } from '../edit-medium-dialog/edit-medium-dia
import { MediaService } from '../shared/media.service';
import { Medium, MediaTypeForSearch } from '../shared/medium.model';
import { Status, statusTypeForSearch } from '../../shared/status.model';
import { SupervisorGuard } from '../../../shared/guards/supervisor-guard';
import { UploadMediumDialogComponent } from '../upload-medium-dialog/upload-medium-dialog.component';

@Component({
Expand All @@ -23,6 +25,9 @@ export class MediaGalleryComponent implements OnInit {
media: Medium[];
statuses = Status.getValuesForSearch();
types = ['ALL'].concat(Medium.types);
isSupervisor: boolean;
inDeletedPage: boolean;


// search parameters
searchQuery = '';
Expand All @@ -47,13 +52,25 @@ export class MediaGalleryComponent implements OnInit {
constructor(private dialog: MdDialog,
private mediaService: MediaService,
private sanitizer: DomSanitizer,
public router: Router,
private toasterService: ToasterService,
private translateService: TranslateService) {}
private translateService: TranslateService,
private supervisorGuard: SupervisorGuard) {
if (router.url === '/mobile-content/media/deleted') {this.inDeletedPage = true; } else {this.inDeletedPage = false; }
}

ngOnInit() {
this.getIsSupervisor();
this.getPage(1);
}

getIsSupervisor() {
this.supervisorGuard.isSupervisor().then(
(response: boolean) => {
this.isSupervisor = response;
});
}

addMedium() {
this.uploadDialogRef = this.dialog.open(UploadMediumDialogComponent, {width: '35em'});
this.uploadDialogRef.afterClosed().subscribe(
Expand Down Expand Up @@ -177,7 +194,8 @@ export class MediaGalleryComponent implements OnInit {
private fetchMedia() {
this.media = [];
this.totalItems = undefined;
this.mediaService.getAllMedia(this.currentPage, this.pageSize, 'id', this.searchQuery, this.selectedStatus, this.selectedType)
let status = this.inDeletedPage ? 'Deleted' : this.selectedStatus;
this.mediaService.getAllMedia(this.currentPage, this.pageSize, 'id', this.searchQuery, status, this.selectedType)
.then(
response => {
this.media = response.items.map(obj => Medium.parseObject(obj));
Expand Down
5 changes: 4 additions & 1 deletion app/mobile-content/media/media.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<md-card class="default-card">
<h1>{{ 'media' | translate }}</h1>
<h1>{{ !inDeletedPage ? ( 'media' | translate ) : 'Deleted media'}}</h1>
<button *ngIf="( !inDeletedPage && isSupervisor)" [routerLink]="[ '/mobile-content/media/deleted']" class="DeletedItems" md-raised-button color="primary" >
{{ 'Recently deleted' | translate }}
</button>
</md-card>

<md-card class="default-card">
Expand Down
19 changes: 19 additions & 0 deletions app/mobile-content/media/media.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { SupervisorGuard } from '../../shared/guards/supervisor-guard';


@Component({
moduleId: module.id,
selector: 'hip-media',
templateUrl: 'media.component.html'
})
export class MediaComponent {
isSupervisor: boolean;
inDeletedPage: boolean;
constructor(
public router: Router,
private supervisorGuard: SupervisorGuard) {
if (router.url === '/mobile-content/media/deleted') {this.inDeletedPage = true; } else {this.inDeletedPage = false;
this.getIsSupervisor();
}
}

getIsSupervisor() {
this.supervisorGuard.isSupervisor().then(
(response: boolean) => {
this.isSupervisor = response;
});
}
}
31 changes: 31 additions & 0 deletions app/mobile-content/mobile-content.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const mobileContentRoutes: Routes = [
component: ExhibitsComponent,
canActivate: [AuthGuard]
},
{
path: 'exhibits/deleted',
component: ExhibitsComponent,
canActivate: [AuthGuard, SupervisorGuard]
},
{
path: 'exhibits/edit/:id',
component: EditExhibitComponent,
Expand All @@ -43,11 +48,26 @@ const mobileContentRoutes: Routes = [
component: MediaComponent,
canActivate: [AuthGuard]
},
{
path: 'media/deleted',
component: MediaComponent,
canActivate: [AuthGuard, SupervisorGuard]
},
{
path: 'pages',
component: PagesComponent,
canActivate: [AuthGuard]
},
{
path: 'pages',
component: PagesComponent,
canActivate: [AuthGuard]
},
{
path: 'pages/deleted',
component: PagesComponent,
canActivate: [AuthGuard, SupervisorGuard]
},
{
path: 'pages/edit/:id',
component: EditPageComponent,
Expand All @@ -68,6 +88,12 @@ const mobileContentRoutes: Routes = [
component: EditRouteComponent,
canActivate: [AuthGuard, SupervisorGuard]
},
{
path: 'routes/deleted',
component: RoutesComponent,
canActivate: [SupervisorGuard]

},
{
path: 'routes/view/:id',
component: ViewRouteComponent,
Expand All @@ -78,6 +104,11 @@ const mobileContentRoutes: Routes = [
component: TagsComponent,
canActivate: [AuthGuard]
},
{
path: 'tags/deleted',
component: TagsComponent,
canActivate: [AuthGuard, SupervisorGuard]
},
{
path: 'tags/edit/:id',
component: EditTagComponent,
Expand Down
5 changes: 4 additions & 1 deletion app/mobile-content/pages/pages.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<md-card class="default-card">
<h1>{{ 'mobile pages' | translate }}</h1>
<h1>{{ !inDeletedPage ? ( 'mobile pages' | translate ) : 'Deleted mobile pages'}}</h1>
<button *ngIf="( !inDeletedPage && isSupervisor)" [routerLink]="[ '/mobile-content/pages/deleted']" class="DeletedItems" md-raised-button color="primary" >
{{ 'Recently deleted' | translate }}
</button>
</md-card>

<md-card class="default-card">
Expand Down
18 changes: 18 additions & 0 deletions app/mobile-content/pages/pages.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { SupervisorGuard } from '../../shared/guards/supervisor-guard';

@Component({
moduleId: module.id,
selector: 'hip-pages',
templateUrl: 'pages.component.html'
})
export class PagesComponent {
isSupervisor: boolean;
inDeletedPage: boolean;
constructor(
public router: Router,
private supervisorGuard: SupervisorGuard) {
if (router.url === '/mobile-content/pages/deleted') {this.inDeletedPage = true; } else {this.inDeletedPage = false;
this.getIsSupervisor();
}
}

getIsSupervisor() {
this.supervisorGuard.isSupervisor().then(
(response: boolean) => {
this.isSupervisor = response;
});
}
}
9 changes: 4 additions & 5 deletions app/mobile-content/pages/shared/mobile-page.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Response } from '@angular/http';

import { MobilePage, pageTypeForSearch } from './mobile-page.model';
import { MobileContentApiService } from '../../shared/mobile-content-api.service';
import { statusTypeForSearch } from '../../shared/status.model';

@Injectable()
export class MobilePageService {
Expand All @@ -29,7 +28,7 @@ export class MobilePageService {
* Retrieves id's of all mobile pages currently stored on the server.
* @param status Restricts results to only pages with a specific status. Defaults to 'ALL'.
*/
getAllIds(status: statusTypeForSearch = 'ALL'): Promise<number[]> {
getAllIds(status = 'ALL'): Promise<number[]> {
return this.mobileApiService.getUrl(`/api/Exhibits/Pages/ids?status=${status}`)
.toPromise()
.then(
Expand All @@ -44,7 +43,7 @@ export class MobilePageService {
* @param id id of the exhibit for which to retrieve page id's
* @param status Restricts results to only pages with a specific status. Defaults to 'ALL'.
*/
getAllIdsFor(id: number, status: statusTypeForSearch = 'ALL'): Promise<number[]> {
getAllIdsFor(id: number, status = 'ALL'): Promise<number[]> {
return this.mobileApiService.getUrl(`/api/Exhibits/${id}/Pages/ids?status=${status}`)
.toPromise()
.then(
Expand All @@ -58,7 +57,7 @@ export class MobilePageService {
* Retrieves all mobile pages currently stored on the server.
* @param status Restricts results to only pages with a specific status. Defaults to 'ALL'.
*/
getAllPages(query = '', status: statusTypeForSearch = 'ALL', type: pageTypeForSearch = 'ALL'): Promise<MobilePage[]> {
getAllPages(query = '', status = 'ALL', type: pageTypeForSearch = 'ALL'): Promise<MobilePage[]> {
let params = '?status=' + status;
params += type === 'ALL' ? '' : '&type=' + type;
if (query) {
Expand All @@ -78,7 +77,7 @@ export class MobilePageService {
* @param id id of the exhibit for which to fetch pages
* @param status Restricts results to only pages with a specific status. Defaults to 'ALL'.
*/
getAllPagesFor(id: number, status: statusTypeForSearch = 'ALL', type: pageTypeForSearch = 'ALL'): Promise<MobilePage[]> {
getAllPagesFor(id: number, status = 'ALL', type: pageTypeForSearch = 'ALL'): Promise<MobilePage[]> {
let params = '?status=' + status;
params += type === 'ALL' ? '' : '&type=' + type;
return this.mobileApiService.getUrl(`/api/Exhibits/${id}/Pages` + params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ <h3 md-line>{{ page.title || '(' + ('no title' | translate) + ')' }}</h3>

<md-icon *ngIf="selectMode && selectedPages.includes(page)" color="accent">done</md-icon>
<button md-icon-button color="primary" [routerLink]="['/mobile-content/pages/edit', page.id]" title="{{ 'edit page' | translate }}" *ngIf="!selectMode">
<md-icon>edit</md-icon>
<md-icon>{{ !inDeletedPage ? 'edit' : 'remove_red_eye'}}</md-icon>
</button>
<button md-icon-button color="warn" (click)="deletePage(page)" title="{{ 'delete page' | translate }}" *ngIf="!selectMode">
<button md-icon-button color="warn" (click)="deletePage(page)" title="{{ 'delete page' | translate }}" *ngIf="!selectMode && !inDeletedPage">
<md-icon>delete_forever</md-icon>
</button>
</md-list-item>
Expand Down
Loading

0 comments on commit 480d22f

Please sign in to comment.