diff --git a/app/pages/community/communities.component.html b/app/pages/community/communities.component.html index 19ef05f..4922ca3 100644 --- a/app/pages/community/communities.component.html +++ b/app/pages/community/communities.component.html @@ -74,14 +74,12 @@ + [isModalShown]="isModalShown" (emmitObject)="communitySavedSuccessfully($event)" (emmitError)="handleError($event)"> + [isModalShown]="isModalShown" (emmitObject)="communityUpdatedSuccessfully($event)" (emmitError)="handleError($event)"> diff --git a/app/pages/community/communities.component.ts b/app/pages/community/communities.component.ts index d6269a7..c57337b 100644 --- a/app/pages/community/communities.component.ts +++ b/app/pages/community/communities.component.ts @@ -53,9 +53,9 @@ export class CommunitiesComponent implements OnInit { constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {} - getCommunity(community_id: string) { + getCommunity(community_pid: string) { let self = this; - this._helpContentService.getCommunityFull(community_id).subscribe( + this._helpContentService.getCommunityFull(community_pid).subscribe( community => { self.communities = [community]; this.checkboxes.push({community : community, checked : false}); diff --git a/app/pages/helpcontent/edit-page-help-content.component.html b/app/pages/helpcontent/edit-page-help-content.component.html index a4eb6c8..96e953d 100644 --- a/app/pages/helpcontent/edit-page-help-content.component.html +++ b/app/pages/helpcontent/edit-page-help-content.component.html @@ -12,7 +12,7 @@
{{errorMessage}}
- +
diff --git a/app/pages/helpcontent/edit-page-help-content.component.ts b/app/pages/helpcontent/edit-page-help-content.component.ts index b8fba38..a486cb0 100644 --- a/app/pages/helpcontent/edit-page-help-content.component.ts +++ b/app/pages/helpcontent/edit-page-help-content.component.ts @@ -18,7 +18,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ @ViewChild(PageContentFormComponent) public formComponent : PageContentFormComponent; - private communityId: string; + private communityPid: string; private pageId: string; @@ -38,7 +38,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.sub = this.route.queryParams.subscribe(params => { //let id = params['id']; let pageContentId = params['pageContentId']; - this.communityId = params['communityId']; + this.communityPid = params['community']; this.pageId = params['pageId']; this._helpContentService.getPageHelpContent(pageContentId as string).subscribe( pageHelpContent => this.updateForm(pageHelpContent), @@ -62,10 +62,11 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ private saveCustom() { if(this.formComponent.myForm.valid) { let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; - this._helpContentService.savePageHelpContent(pageHelpContent).subscribe( + console.info(pageHelpContent.community); + this._helpContentService.updatePageHelpContent(pageHelpContent).subscribe( _ => { if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } ); + this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); } else { this.router.navigate(['/pageContents']); } @@ -79,7 +80,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ private cancelCustom() { if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } ); + this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); } else { this.router.navigate(['/pageContents']); } diff --git a/app/pages/helpcontent/entities.component.html b/app/pages/helpcontent/entities.component.html index 4c1854f..d17014c 100644 --- a/app/pages/helpcontent/entities.component.html +++ b/app/pages/helpcontent/entities.component.html @@ -51,7 +51,7 @@ Filter by community: @@ -102,14 +102,12 @@ + [isModalShown]="isModalShown" (emmitObject)="entitySavedSuccessfully($event)" (emmitError)="handleError($event)"> + [isModalShown]="isModalShown" (emmitObject)="entityUpdatedSuccessfully($event)" (emmitError)="handleError($event)"> diff --git a/app/pages/helpcontent/entities.component.ts b/app/pages/helpcontent/entities.component.ts index a8b547e..8e6dd9e 100644 --- a/app/pages/helpcontent/entities.component.ts +++ b/app/pages/helpcontent/entities.component.ts @@ -39,7 +39,7 @@ export class EntitiesComponent implements OnInit { public communities: Community[] = []; - public selectedCommunityId: string; + public selectedCommunityPid: string; ngOnInit() { this.getCommunities(); @@ -54,15 +54,15 @@ export class EntitiesComponent implements OnInit { this._helpContentService.getCommunities().subscribe( communities => { self.communities = communities; - self.getEntities(self.communities[0]._id); - self.selectedCommunityId = self.communities[0]._id; + self.selectedCommunityPid = self.communities[0].pid; + self.getEntities(self.selectedCommunityPid); }, error => this.handleError('System error retrieving communities', error)); } - getEntities(community_id: string) { + getEntities(community_pid: string) { let self = this; - this._helpContentService.getCommunityEntities(community_id).subscribe( + this._helpContentService.getCommunityEntities(community_pid).subscribe( entities => { self.entities = entities; self.checkboxes = []; @@ -158,16 +158,16 @@ export class EntitiesComponent implements OnInit { public filterByCommunity(event: any) { - this.selectedCommunityId = event.target.value; - this.applyCommunityFilter(this.selectedCommunityId); + this.selectedCommunityPid = event.target.value; + this.applyCommunityFilter(this.selectedCommunityPid); } - public applyCommunityFilter(community_id: string) { - this.getEntities(community_id); + public applyCommunityFilter(community_pid: string) { + this.getEntities(community_pid); } public toggleEntities(status : boolean, ids : string[]) { - this._helpContentService.toggleEntities(this.selectedCommunityId,ids,status).subscribe( + this._helpContentService.toggleEntities(this.selectedCommunityPid,ids,status).subscribe( () => { for(let id of ids) { let i = this.checkboxes.findIndex(_ => _.entity._id == id); diff --git a/app/pages/helpcontent/new-page-help-content.component.html b/app/pages/helpcontent/new-page-help-content.component.html index 2433a3a..010c3b4 100644 --- a/app/pages/helpcontent/new-page-help-content.component.html +++ b/app/pages/helpcontent/new-page-help-content.component.html @@ -12,7 +12,7 @@
{{errorMessage}}
- +
diff --git a/app/pages/helpcontent/new-page-help-content.component.ts b/app/pages/helpcontent/new-page-help-content.component.ts index db43f51..08e0b27 100644 --- a/app/pages/helpcontent/new-page-help-content.component.ts +++ b/app/pages/helpcontent/new-page-help-content.component.ts @@ -19,7 +19,7 @@ export class NewPageHelpContentComponent { private errorMessage : string = null; - private communityId: string; + private communityPid: string; private pageId: string; @@ -30,7 +30,7 @@ export class NewPageHelpContentComponent { ngOnInit() { this.route.queryParams.subscribe(params => { - this.communityId = params['communityId']; + this.communityPid = params['community']; this.pageId = params['pageId']; }); } @@ -45,7 +45,7 @@ export class NewPageHelpContentComponent { this._helpContentService.savePageHelpContent(pageHelpContent).subscribe( _ => { if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } ); + this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); } else { this.router.navigate(['/pageContents']); } @@ -59,7 +59,7 @@ export class NewPageHelpContentComponent { private cancelCustom() { if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityId, "page": this.pageId } } ); + this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); } else { this.router.navigate(['/pageContents']); } diff --git a/app/pages/helpcontent/page-form.component.ts b/app/pages/helpcontent/page-form.component.ts index b43b75c..932cc88 100644 --- a/app/pages/helpcontent/page-form.component.ts +++ b/app/pages/helpcontent/page-form.component.ts @@ -15,8 +15,6 @@ export class PageFormComponent implements OnInit{ @Input('group') myForm: FormGroup; - @Input('selectedCommunityId') - public selectedCommunityId: string; @Input('type') public type: string; diff --git a/app/pages/helpcontent/page-help-content-form.component.ts b/app/pages/helpcontent/page-help-content-form.component.ts index 8097d5e..62f9ee6 100644 --- a/app/pages/helpcontent/page-help-content-form.component.ts +++ b/app/pages/helpcontent/page-help-content-form.component.ts @@ -16,8 +16,8 @@ export class PageContentFormComponent implements OnInit{ @Input('group') myForm: FormGroup; - @Input('communityId') - communityId: string; + @Input('communityPid') + communityPid: string; @Input('pageId') pageId: string; @@ -30,7 +30,7 @@ export class PageContentFormComponent implements OnInit{ ngOnInit() { this.myForm = this.form; - this._helpContentService.getCommunityPages(this.communityId).subscribe( + this._helpContentService.getCommunityPages(this.communityPid).subscribe( pages => this.availablePages = pages, error => this.handleError('System error retrieving pages', error)); } @@ -38,7 +38,7 @@ export class PageContentFormComponent implements OnInit{ public get form() { return this._fb.group({ page : [this.pageId,Validators.required], - community : this.communityId, + community : this.communityPid, placement : ['', Validators.required], content : ['', Validators.required], order : ['1', Validators.required], @@ -50,7 +50,7 @@ export class PageContentFormComponent implements OnInit{ public reset() { this.myForm.patchValue({ page : '', - community : this.communityId, + community : this.communityPid, placement : '', content : [''], order : '1', diff --git a/app/pages/helpcontent/page-help-contents.component.html b/app/pages/helpcontent/page-help-contents.component.html index fbabe45..3ec7e76 100644 --- a/app/pages/helpcontent/page-help-contents.component.html +++ b/app/pages/helpcontent/page-help-contents.component.html @@ -150,8 +150,8 @@ - New Page Content - New Page Content + New Page Content + New Page Content
@@ -187,7 +187,7 @@
diff --git a/app/pages/helpcontent/page-help-contents.component.ts b/app/pages/helpcontent/page-help-contents.component.ts index 3d3b8a0..e7e4e70 100644 --- a/app/pages/helpcontent/page-help-contents.component.ts +++ b/app/pages/helpcontent/page-help-contents.component.ts @@ -49,7 +49,7 @@ export class PageHelpContentsComponent implements OnInit { public communities: Community[] = []; - public selectedCommunityId: string; + public selectedCommunityPid: string; public selectedPageId: string; @@ -60,13 +60,13 @@ export class PageHelpContentsComponent implements OnInit { ngOnInit() { this.route.queryParams.subscribe(params => { - this.selectedCommunityId = params['community']; + this.selectedCommunityPid = params['community']; this.selectedPageId = params['page']; - if(this.selectedCommunityId && this.selectedPageId) { - this.getPageHelpContents(this.selectedCommunityId); + if(this.selectedCommunityPid && this.selectedPageId) { + this.getPageHelpContents(this.selectedCommunityPid); this.getPage(this.selectedPageId); - this.getCommunity(this.selectedCommunityId); + this.getCommunity(this.selectedCommunityPid); } else { this.selectedPageId = ""; this.getCommunities(); @@ -86,9 +86,9 @@ export class PageHelpContentsComponent implements OnInit { ); } - getCommunity(communityId: string) { + getCommunity(communityPid: string) { let self = this; - this._helpService.getCommunity(communityId).subscribe( + this._helpService.getCommunity(communityPid).subscribe( community => { self.community = community; } @@ -100,15 +100,15 @@ export class PageHelpContentsComponent implements OnInit { this._helpService.getCommunities().subscribe( communities => { self.communities = communities; - self.selectedCommunityId = self.communities[0]._id; - this.getPages(self.selectedCommunityId); - this.getPageHelpContents(self.selectedCommunityId); + self.selectedCommunityPid = self.communities[0].pid; + this.getPages(self.selectedCommunityPid); + this.getPageHelpContents(self.selectedCommunityPid); }, error => this.handleError('System error retrieving communities', error)); } - getPages(community_id: string) { - this._helpService.getCommunityPages(community_id).subscribe( + getPages(community_pid: string) { + this._helpService.getCommunityPages(community_pid).subscribe( pages => this.pages = pages, error => this.handleError('System error retrieving pages', error)); } @@ -126,9 +126,9 @@ export class PageHelpContentsComponent implements OnInit { this.counter.all = this.counter.active + this.counter.inactive; } - getPageHelpContents(community_id: string) { + getPageHelpContents(community_pid: string) { let self = this; - this._helpService.getCommunityPageHelpContents(community_id).subscribe( + this._helpService.getCommunityPageHelpContents(community_pid).subscribe( pageHelpContents => { self.pageHelpContents = pageHelpContents as Array; self.counter.all = self.pageHelpContents.length; @@ -198,12 +198,12 @@ export class PageHelpContentsComponent implements OnInit { } } - public editPageHelpContent(_id : string) { + public editPageHelpContent(id : string) { //this.router.navigate(['/pageContents/edit/', _id]); if(this.selectedPageId) { - this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": _id, "communityId": this.selectedCommunityId, "pageId": this.selectedPageId } } ); + this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "community": this.selectedCommunityPid, "pageId": this.selectedPageId } } ); } else { - this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": _id, "communityId": this.selectedCommunityId } } ); + this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "community": this.selectedCommunityPid } } ); } } @@ -294,12 +294,12 @@ export class PageHelpContentsComponent implements OnInit { } public filterByCommunity(event: any) { - this.selectedCommunityId = event.target.value; - this.applyCommunityFilter(this.selectedCommunityId); + this.selectedCommunityPid = event.target.value; + this.applyCommunityFilter(this.selectedCommunityPid); } - public applyCommunityFilter(community_id: string) { - this.getPages(community_id); - this.getPageHelpContents(community_id); + public applyCommunityFilter(community_pid: string) { + this.getPages(community_pid); + this.getPageHelpContents(community_pid); } } diff --git a/app/pages/helpcontent/pages.component.html b/app/pages/helpcontent/pages.component.html index 8a134e9..4137cb5 100644 --- a/app/pages/helpcontent/pages.component.html +++ b/app/pages/helpcontent/pages.component.html @@ -181,7 +181,7 @@ Filter by community: @@ -233,7 +233,7 @@ - add contents + add contents @@ -251,14 +251,12 @@ + [isModalShown]="isModalShown" (emmitObject)="pageSavedSuccessfully($event)" (emmitError)="handleError($event)"> + [isModalShown]="isModalShown" (emmitObject)="pageUpdatedSuccessfully($event)" (emmitError)="handleError($event)"> diff --git a/app/pages/helpcontent/pages.component.ts b/app/pages/helpcontent/pages.component.ts index ff88f46..653c21d 100644 --- a/app/pages/helpcontent/pages.component.ts +++ b/app/pages/helpcontent/pages.component.ts @@ -44,7 +44,7 @@ export class PagesComponent implements OnInit { public communities: Community[] = []; - public selectedCommunityId: string; + public selectedCommunityPid: string; public pagesType: string; @@ -63,17 +63,17 @@ export class PagesComponent implements OnInit { constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {} - getPages(community_id: string) { + getPages(community_pid: string) { let self = this; if(this.pagesType) { - this._helpContentService.getCommunityPagesByType(community_id, "?page_type="+this.pagesType).subscribe( + this._helpContentService.getCommunityPagesByType(community_pid, "?page_type="+this.pagesType).subscribe( pages => { self.pagesReturned(pages); }, error => this.handleError('System error retrieving pages', error)); } else { - this._helpContentService.getCommunityPages(community_id).subscribe( + this._helpContentService.getCommunityPages(community_pid).subscribe( pages => { self.pagesReturned(pages); }, @@ -95,8 +95,8 @@ export class PagesComponent implements OnInit { this._helpContentService.getCommunities().subscribe( communities => { self.communities = communities; - self.getPages(self.communities[0]._id); - self.selectedCommunityId = self.communities[0]._id; + self.selectedCommunityPid = self.communities[0].pid; + self.getPages(self.selectedCommunityPid); }, error => this.handleError('System error retrieving communities', error)); } @@ -193,16 +193,16 @@ export class PagesComponent implements OnInit { public filterByCommunity(event: any) { - this.selectedCommunityId = event.target.value; - this.applyCommunityFilter(this.selectedCommunityId); + this.selectedCommunityPid = event.target.value; + this.applyCommunityFilter(this.selectedCommunityPid); } - public applyCommunityFilter(community_id: string) { - this.getPages(community_id); + public applyCommunityFilter(community_pid: string) { + this.getPages(community_pid); } public togglePages(status : boolean, ids : string[]) { - this._helpContentService.togglePages(this.selectedCommunityId,ids,status).subscribe( + this._helpContentService.togglePages(this.selectedCommunityPid,ids,status).subscribe( () => { for(let id of ids) { // let i = this.checkboxes.findIndex(_ => _.page._id == id); diff --git a/app/pages/modal-form.component.ts b/app/pages/modal-form.component.ts index 3f63397..6539701 100644 --- a/app/pages/modal-form.component.ts +++ b/app/pages/modal-form.component.ts @@ -39,9 +39,6 @@ export class ModalFormComponent { @Input() public type : string = 'topic'; - @Input() - public selectedCommunityId: string; - public errorMessage : string = null; @Output() emmitObject: EventEmitter = new EventEmitter(); diff --git a/app/services/help-content.service.ts b/app/services/help-content.service.ts index b8843b8..db8d176 100644 --- a/app/services/help-content.service.ts +++ b/app/services/help-content.service.ts @@ -44,8 +44,8 @@ export class HelpContentService { .catch(this.handleError); } - getCommunity(community_id: string) { - return this.http.get(this._helpContentUrl + 'community/'+community_id) + getCommunity(community_pid: string) { + return this.http.get(this._helpContentUrl + 'community/'+community_pid) .map(res => res.json()) .catch(this.handleError); } @@ -56,8 +56,8 @@ export class HelpContentService { .catch(this.handleError); } - getCommunityFull(community_id: string) { - return this.http.get(this._helpContentUrl + 'communityFull/'+community_id) + getCommunityFull(community_pid: string) { + return this.http.get(this._helpContentUrl + 'communityFull/'+community_pid) .map(res => res.json()) .catch(this.handleError); } @@ -92,14 +92,14 @@ export class HelpContentService { .catch(this.handleError); } - getCommunityPages(community_id: string) { - return this.http.get(this._helpContentUrl + 'community/'+community_id+'/pages') + getCommunityPages(community_pid: string) { + return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages') .map(res => > res.json()) .catch(this.handleError); } - getCommunityPagesByType(community_id: string, params: string) { - return this.http.get(this._helpContentUrl + 'community/'+community_id+'/pages'+params) + getCommunityPagesByType(community_pid: string, params: string) { + return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages'+params) .map(res => > res.json()) .catch(this.handleError); } @@ -110,8 +110,8 @@ export class HelpContentService { .catch(this.handleError); } - getCommunityEntities(community_id: string) { - return this.http.get(this._helpContentUrl + 'community/'+community_id+'/entities') + getCommunityEntities(community_pid: string) { + return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/entities') .map(res => > res.json()) .catch(this.handleError); } @@ -147,11 +147,11 @@ export class HelpContentService { // .catch(this.handleError); // } - toggleEntities(selectedCommunityId: string, ids : string[],status : boolean) { + toggleEntities(selectedCommunityPid: string, ids : string[],status : boolean) { let headers = new Headers({'Content-Type': 'application/json'}); let options = new RequestOptions({headers: headers}); - return this.http.post(this._helpContentUrl +'community/'+selectedCommunityId+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), options) + return this.http.post(this._helpContentUrl +'community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), options) //.map( res => res.json()) .catch(this.handleError); } @@ -195,11 +195,11 @@ export class HelpContentService { .catch(this.handleError); } - togglePages(selectedCommunityId: string, ids : string[],status : boolean) { + togglePages(selectedCommunityPid: string, ids : string[],status : boolean) { let headers = new Headers({'Content-Type': 'application/json'}); let options = new RequestOptions({headers: headers}); - return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityId+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), options) + return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), options) .catch(this.handleError); } @@ -217,8 +217,8 @@ export class HelpContentService { .catch(this.handleError); } - getCommunityPageHelpContents(community_id: string) { - return this.http.get(this._helpContentUrl + 'pagehelpcontent?communityId='+community_id) + getCommunityPageHelpContents(community_pid: string) { + return this.http.get(this._helpContentUrl + 'pagehelpcontent?community='+community_pid) .map(res => > res.json()) .catch(this.handleError); } @@ -236,7 +236,7 @@ export class HelpContentService { HelpContentService.removeNulls(pageHelpContent); - return this.http.post(this._helpContentUrl + 'pagehelpcontent', JSON.stringify(pageHelpContent), options) + return this.http.post(this._helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), options) .map(res => res.json()) .catch(this.handleError); } @@ -247,7 +247,7 @@ export class HelpContentService { HelpContentService.removeNulls(pageHelpContent); - return this.http.put(this._helpContentUrl + 'pagehelpcontent', JSON.stringify(pageHelpContent), options) + return this.http.post(this._helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), options) .map(res => res.json()) .catch(this.handleError); }