'pid' field added in entities and communities for queries by portal - can be changed by forms

bug fix in cancel/save in pageContents form
page in pageContents form cannot be changed when editing contents of specific page
order in pageContents form can be set by hand (text not number)
api for pageContents of specific community changed



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@50388 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-01-24 15:45:12 +00:00
parent 989bb6394b
commit aec61776ae
15 changed files with 48 additions and 15 deletions

View File

@ -80,7 +80,7 @@
</li> </li>
<li class="uk-nav-header uk-parent"> <li class="uk-nav-header uk-parent">
Help Content Manage Help Content
<ul class="uk-nav-sub"> <ul class="uk-nav-sub">
<li> <li>

View File

@ -3,6 +3,7 @@ import {Entity} from './entity';
export interface Community { export interface Community {
_id: string; _id: string;
pid: string;
name: string; name: string;
entities: string[] | Entity[]; entities: string[] | Entity[];
pages: string[] | Page[]; pages: string[] | Page[];

View File

@ -1,5 +1,6 @@
export class Entity { export class Entity {
_id: string; _id: string;
pid: string;
name: string; name: string;
isEnabled :boolean; isEnabled :boolean;
} }

View File

@ -1,7 +1,11 @@
<form [formGroup]="myForm"> <form [formGroup]="myForm">
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.name.valid && myForm.controls.name.dirty}"> <div class="form-group" [ngClass]="{'has-error':!myForm.controls.name.valid && myForm.controls.name.dirty}">
<label for="pageNameTag">Community Name</label> <label for="communityNameTag">Community Name</label>
<input type="text" class="form-control" formControlName="name" id="pageNameTag" placeholder="Community Name"> <input type="text" class="form-control" formControlName="name" id="pageNameTag" placeholder="Community Name">
</div> </div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.pid.valid && myForm.controls.pid.dirty}">
<label for="communityPidTag">Community persistent id for portal</label>
<input type="text" class="uk-input uk-width-medium" formControlName="pid" id="communityPidTag" placeholder="Community Pid">
</div>
<input type="hidden" formControlName="_id"> <input type="hidden" formControlName="_id">
</form> </form>

View File

@ -21,6 +21,7 @@ export class CommunityFormComponent implements OnInit{
public get form() { public get form() {
return this._fb.group({ return this._fb.group({
_id : '', _id : '',
pid: ['', Validators.required],
name : ['', Validators.required] name : ['', Validators.required]
}); });
} }
@ -28,7 +29,8 @@ export class CommunityFormComponent implements OnInit{
public reset() { public reset() {
this.myForm.patchValue({ this.myForm.patchValue({
name : '', name : '',
_id : '' _id : '',
pid: ''
}); });
} }

View File

@ -12,9 +12,9 @@
<div> <div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div> <div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<page-content-form [communityId]="communityId" [group]="formGroup"></page-content-form> <page-content-form [communityId]="communityId" [pageId]="pageId" [group]="formGroup"></page-content-form>
<a [queryParams]="{community: communityId, page: pageId}" routerLink="/pageContents" class="btn"><i></i>Cancel</a> <button (click)="cancelCustom()" class="uk-button uk-button-link">Cancel</button>
<a (click)="saveCustom()" class="btn btn-success"><i></i>Update page content</a> <button (click)="saveCustom()" class="uk-button uk-button-primary">Update page content</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -75,6 +75,13 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
} else { } else {
this.errorMessage = "Please fill all required fields"; this.errorMessage = "Please fill all required fields";
} }
}
private cancelCustom() {
if(this.pageId) {
this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } );
} else {
this.router.navigate(['/pageContents']);
}
} }
} }

View File

@ -3,7 +3,10 @@
<label for="entityNameTag">Entity Name</label> <label for="entityNameTag">Entity Name</label>
<input type="text" class="uk-input uk-width-medium" formControlName="name" id="entityNameTag" placeholder="Entity Name"> <input type="text" class="uk-input uk-width-medium" formControlName="name" id="entityNameTag" placeholder="Entity Name">
</div> </div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.pid.valid && myForm.controls.pid.dirty}">
<label for="entityPidTag">Entity persistent id for portal</label>
<input type="text" class="uk-input uk-width-medium" formControlName="pid" id="entityPidTag" placeholder="Entity Pid">
</div>
<!-- <!--
<div ngModelGroup="phoneNumbers"> <div ngModelGroup="phoneNumbers">

View File

@ -19,14 +19,18 @@ export class EntityFormComponent implements OnInit{
public get form() { public get form() {
return this._fb.group({ return this._fb.group({
pid: ['', Validators.required],
name : ['', Validators.required], name : ['', Validators.required],
isEnabled: '',
_id : '' _id : ''
}); });
} }
public reset() { public reset() {
this.myForm.patchValue({ this.myForm.patchValue({
pid: '',
name : '', name : '',
isEnabled: '',
_id : '' _id : ''
}); });
} }

View File

@ -12,9 +12,9 @@
<div> <div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div> <div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<page-content-form [communityId]="communityId" [group]="formGroup"></page-content-form> <page-content-form [communityId]="communityId" [pageId]="pageId" [group]="formGroup"></page-content-form>
<a [queryParams]="{community: communityId, page: pageId}" routerLink="/pageContents" class="btn"><i></i>Cancel</a> <button (click)="cancelCustom()" class="uk-button uk-button-link">Cancel</button>
<a (click)="saveCustom()" class="btn btn-success"><i></i>Save page content</a> <button (click)="saveCustom()" class="uk-button uk-button-primary">Save page content</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -41,6 +41,7 @@ export class NewPageHelpContentComponent {
if(this.formComponent.myForm.valid) { if(this.formComponent.myForm.valid) {
let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; let pageHelpContent : PageHelpContent = this.formComponent.myForm.value;
this._helpContentService.savePageHelpContent(pageHelpContent).subscribe( this._helpContentService.savePageHelpContent(pageHelpContent).subscribe(
_ => { _ => {
if(this.pageId) { if(this.pageId) {
@ -56,6 +57,14 @@ export class NewPageHelpContentComponent {
} }
} }
private cancelCustom() {
if(this.pageId) {
this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } );
} else {
this.router.navigate(['/pageContents']);
}
}
handleError(message: string, error) { handleError(message: string, error) {
this.errorMessage = message + ' (Server responded: ' + error + ')'; this.errorMessage = message + ' (Server responded: ' + error + ')';

View File

@ -1,6 +1,6 @@
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div> <div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<form [formGroup]="myForm"> <form [formGroup]="myForm">
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.page.valid && myForm.controls.page.dirty}"> <div *ngIf="!pageId" class="form-group" [ngClass]="{'has-error':!myForm.controls.page.valid && myForm.controls.page.dirty}">
<label for="pageTag">Select Page</label> <label for="pageTag">Select Page</label>
<select formControlName="page" id="pageTag" class="form-control"> <select formControlName="page" id="pageTag" class="form-control">
<option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option> <option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option>
@ -36,7 +36,7 @@
</div> </div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.order.valid && myForm.controls.order.dirty}"> <div class="form-group" [ngClass]="{'has-error':!myForm.controls.order.valid && myForm.controls.order.dirty}">
<label for="orderTag">Order</label> <label for="orderTag">Order</label>
<input type="number" step="1" class="form-control" formControlName="order" id="orderTag" placeholder="Order (e.g. 2)"> <input type="text" step="1" class="form-control" formControlName="order" id="orderTag" placeholder="Order (e.g. 2)">
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Select Status</label> <label>Select Status</label>

View File

@ -18,6 +18,8 @@ export class PageContentFormComponent implements OnInit{
myForm: FormGroup; myForm: FormGroup;
@Input('communityId') @Input('communityId')
communityId: string; communityId: string;
@Input('pageId')
pageId: string;
private availablePages : Page[] = []; private availablePages : Page[] = [];
private errorMessage: string; private errorMessage: string;
@ -35,7 +37,7 @@ export class PageContentFormComponent implements OnInit{
public get form() { public get form() {
return this._fb.group({ return this._fb.group({
page : ['',Validators.required], page : [this.pageId,Validators.required],
community : this.communityId, community : this.communityId,
placement : ['', Validators.required], placement : ['', Validators.required],
content : ['', Validators.required], content : ['', Validators.required],

View File

@ -233,7 +233,7 @@
</div> </div>
</td> </td>
<td> <td>
<a class="helpContents" [queryParams]="{community: selectedCommunityId, page: check.page._id}" routerLink="/pageContents">edit</a> <a class="helpContents" [queryParams]="{community: selectedCommunityId, page: check.page._id}" routerLink="/pageContents">add contents</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -218,7 +218,7 @@ export class HelpContentService {
} }
getCommunityPageHelpContents(community_id: string) { getCommunityPageHelpContents(community_id: string) {
return this.http.get(this._helpContentUrl + 'pagehelpcontent/community/'+community_id) return this.http.get(this._helpContentUrl + 'pagehelpcontent?communityId='+community_id)
.map(res => <Array<PageHelpContent>> res.json()) .map(res => <Array<PageHelpContent>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }