Commit 6e7c76e6d3542b681fac66bcbeed96be684e734e
1 parent
62f85230
Exists in
master
and in
11 other branches
Get available languages from translator service in block edition
Showing
2 changed files
with
41 additions
and
3 deletions
Show diff stats
src/app/layout/blocks/block-edition/block-edition.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,34 @@ |
1 | +import {Component} from 'ng-forward'; | |
2 | +import {BlockEditionComponent} from './block-edition.component'; | |
3 | +import * as helpers from "../../../../spec/helpers"; | |
4 | +import {ComponentTestHelper, createClass} from '../../../../spec/component-test-helper'; | |
5 | + | |
6 | +const htmlTemplate: string = '<noosfero-block-edition></noosfero-block-edition>'; | |
7 | + | |
8 | +describe("Boxes Component", () => { | |
9 | + | |
10 | + let helper: ComponentTestHelper<BlockEditionComponent>; | |
11 | + let translatorService = { | |
12 | + availableLanguages: { 'en': 'English', 'pt': 'Portuguese' } | |
13 | + }; | |
14 | + | |
15 | + beforeEach(() => { | |
16 | + angular.mock.module("templates"); | |
17 | + }); | |
18 | + | |
19 | + beforeEach((done) => { | |
20 | + let cls = createClass({ | |
21 | + template: htmlTemplate, | |
22 | + directives: [BlockEditionComponent], | |
23 | + providers: [ | |
24 | + helpers.createProviderToValue('TranslatorService', translatorService) | |
25 | + ] | |
26 | + }); | |
27 | + helper = new ComponentTestHelper<BlockEditionComponent>(cls, done); | |
28 | + }); | |
29 | + | |
30 | + it("get available languages from translator service", () => { | |
31 | + expect(helper.component.languageOptions).toEqual(['all', 'en', 'pt']); | |
32 | + }); | |
33 | + | |
34 | +}); | ... | ... |
src/app/layout/blocks/block-edition/block-edition.component.ts
1 | -import { Input, Component } from 'ng-forward'; | |
1 | +import { Input, Inject, Component } from 'ng-forward'; | |
2 | +import { TranslatorService } from "../../../shared/services/translator.service"; | |
2 | 3 | |
3 | 4 | @Component({ |
4 | 5 | selector: 'noosfero-block-edition', |
5 | 6 | templateUrl: 'app/layout/blocks/block-edition/block-edition.html' |
6 | 7 | }) |
8 | +@Inject(TranslatorService) | |
7 | 9 | export class BlockEditionComponent { |
8 | 10 | |
11 | + static $inject = ["TranslatorService"]; // @Inject doesn't works with uibModal.open | |
12 | + | |
9 | 13 | displayOptions: any; |
10 | 14 | displayUserOptions: any; |
11 | 15 | languageOptions: any; |
12 | 16 | |
13 | - constructor() { | |
17 | + constructor(private translatorService: TranslatorService) { | |
14 | 18 | this.displayOptions = ["always", "home_page_only", "except_home_page", "never"]; |
15 | 19 | this.displayUserOptions = ["all", "logged", "not_logged"]; |
16 | - this.languageOptions = ["all", "en", "pt"]; // FIXME get language list | |
20 | + this.languageOptions = ["all"].concat(Object.keys(translatorService.availableLanguages)); | |
17 | 21 | } |
18 | 22 | } | ... | ... |