Ariel Weinberger pushed to branch feature/CC-CHANNELMGR-1484 at cms-community / hippo-addon-channel-manager
Commits: 6956b7b7 by Ariel Weinberger at 2017-11-01T12:04:29+01:00 CHANNELMGR-1484 Generate document URL using back-end call - Add dll folder to gitignore - Remove unnecessary tests in CreateContentService - Add generateDocumentUrlByName method to CreateContentService - - - - - 4 changed files: - .gitignore - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.spec.ts - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.ts - frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/name-url-fields/name-url-fields.component.ts Changes: ===================================== .gitignore ===================================== --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ target/ node_modules/ coverage/ cache/ +dll/ ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.spec.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.spec.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.spec.ts @@ -38,28 +38,4 @@ describe('CreateContentService', () => { ] }); }); - - it('can get document types by template query', - inject([CreateContentService], (createContentService: CreateContentService) => { - - const documentTypes: DocumentTypeInfo[] = [ - { id: 'doctype1', displayName: 'Doctype 1'} - ]; - const spy = spyOn(contentService, '_send').and.returnValue(Promise.resolve({ documentTypes })); - createContentService.getTemplateQuery('test-template-query') - .subscribe((templateQuery: TemplateQuery) => { - expect(spy).toHaveBeenCalledWith('GET', ['templatequery', 'test-template-query'], null, true); - expect(templateQuery.documentTypes).toBe(documentTypes); - }); - })); - - it('can fail to get document types by template query', - inject([CreateContentService], (createContentService: CreateContentService) => { - - spyOn(contentService, '_send').and.returnValue(Promise.reject('serverError')); - createContentService.getTemplateQuery('test-template-query') - .subscribe(() => { }, (error) => { - expect(error).toBe('serverError'); - }); - })); }); ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/create-content.service.ts @@ -14,4 +14,9 @@ export class CreateContentService { const promise = this.contentService._send('GET', ['templatequery', id], null, true); return Observable.fromPromise(promise); } + + generateDocumentUrlByName(name: string): Observable<string> { + const promise = this.contentService._send('POST', ['slugs'], name, true); + return Observable.fromPromise(promise); + } } ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/name-url-fields/name-url-fields.component.ts ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/name-url-fields/name-url-fields.component.ts +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/create-content/name-url-fields/name-url-fields.component.ts @@ -16,6 +16,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { Observable } from 'rxjs/rx'; +import { CreateContentService } from '../create-content.service'; @Component({ selector: 'hippo-name-url-fields', @@ -29,6 +30,8 @@ export class NameUrlFieldsComponent implements OnInit { public urlEditMode: { state: boolean, oldValue: string } = { state: false, oldValue: '' }; public dummy: string; + constructor(private createContentService: CreateContentService) {} + ngOnInit() { Observable.fromEvent(this.nameInputElement.nativeElement, 'keyup') .debounceTime(1000) @@ -36,10 +39,8 @@ export class NameUrlFieldsComponent implements OnInit { } setDocumentUrlByName(name: string) { - // TODO: back-end call - name = name.toLowerCase(); - name = name.replace(/\s+/g, '-').toLowerCase(); - this.urlField = name; + this.createContentService.generateDocumentUrlByName(name) + .subscribe((slug) => this.urlField = slug); } setDocumentUrlEditable(state: boolean) { View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/6956b7b7b855e090ba224839b348a6fffc4a3356 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/6956b7b7b855e090ba224839b348a6fffc4a3356 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn