Commit c494da7e5764cd2653730f1df4bde904cc43d35e
1 parent
c623e86c
Exists in
master
and in
24 other branches
Initial version
Showing
4 changed files
with
77 additions
and
10 deletions
Show diff stats
src/app/article/content-viewer/navbar-actions.html
| 1 | 1 | <ul class="nav navbar-nav"> |
| 2 | - <li ng-show="vm.profile"> | |
| 3 | - <a ng-show="vm.parentId" href="#" role="button" ui-sref="main.cms({profile: vm.profile.identifier, parent_id: vm.parentId})"> | |
| 4 | - <i class="fa fa-file fa-fw fa-lg"></i> {{"navbar.content_viewer_actions.new_post" | translate}} | |
| 5 | - </a> | |
| 6 | - </li> | |
| 7 | - <li ng-show="vm.profile"> | |
| 8 | - <a href="#" role="button" ui-sref="main.cms({profile: vm.profile.identifier, parent_id: vm.parentId, type: 'CommentParagraphPlugin::Discussion'})"> | |
| 9 | - <i class="fa fa-file fa-fw fa-lg"></i> {{"navbar.content_viewer_actions.new_post" | translate}} | |
| 10 | - </a> | |
| 11 | - </li> | |
| 2 | + <li class="dropdown profile-menu" uib-dropdown> | |
| 3 | + <a class="btn dropdown-toggle" data-toggle="dropdown" uib-dropdown-toggle> | |
| 4 | + {{"navbar.content_viewer_actions.new_item" | translate}} | |
| 5 | + <i class="fa fa-caret-down"></i> | |
| 6 | + </a> | |
| 7 | + <ul class="dropdown-menu" uib-dropdown-menu ng-show="vm.profile"> | |
| 8 | + <li ng-show="vm.parentId"> | |
| 9 | + <a href="#" ui-sref="main.cms({profile: vm.profile.identifier, parent_id: vm.parentId})"> | |
| 10 | + <i class="fa fa-file fa-fw fa-lg"></i> {{"navbar.content_viewer_actions.new_post" | translate}} | |
| 11 | + </a> | |
| 12 | + </li> | |
| 13 | + <li ng-show="vm.parentId"> | |
| 14 | + <a href="#" ui-sref="main.cms({profile: vm.profile.identifier, parent_id: vm.parentId, type: 'CommentParagraphPlugin::Discussion'})"> | |
| 15 | + <i class="fa fa-file fa-fw fa-lg"></i> {{"navbar.content_viewer_actions.new_discussion" | translate}} | |
| 16 | + </a> | |
| 17 | + </li> | |
| 18 | + </ul> | |
| 19 | + </li> | |
| 20 | + | |
| 12 | 21 | </ul> |
| 22 | + | ... | ... |
| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | |
| 2 | +import {Provider} from 'ng-forward'; | |
| 3 | +import {ComponentTestHelper, createClass} from "./../../../spec/component-test-helper"; | |
| 4 | +import {providers} from 'ng-forward/cjs/testing/providers'; | |
| 5 | +import {ContentViewerActionsComponent} from '././content-viewer-actions.component'; | |
| 6 | +import * as helpers from "../../../spec/helpers"; | |
| 7 | + | |
| 8 | +const htmlTemplate: string = '<content-viewer-actions [article]="ctrl.article" [profile]="ctrl.profile"></content-viewer-actions>'; | |
| 9 | + | |
| 10 | +describe("Components", () => { | |
| 11 | + | |
| 12 | + describe("Content Viewer Actions Component", () => { | |
| 13 | + let serviceMock = { | |
| 14 | + getEnvironmentPeople: (filters: any): any => { | |
| 15 | + return Promise.resolve([{ identifier: "person1" }]); | |
| 16 | + } | |
| 17 | + }; | |
| 18 | + let providers = [ | |
| 19 | + new Provider('ArticleService', { useValue: helpers.mocks.articleService }), | |
| 20 | + new Provider('ProfileService', { useValue: helpers.mocks.profileService }) | |
| 21 | + ]; | |
| 22 | + | |
| 23 | + let helper: ComponentTestHelper<ContentViewerActionsComponent>; | |
| 24 | + | |
| 25 | + beforeEach(angular.mock.module("templates")); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * The beforeEach procedure will initialize the helper and parse | |
| 29 | + * the component according to the given providers. Unfortunetly, in | |
| 30 | + * this mode, the providers and properties given to the construtor | |
| 31 | + * can't be overriden. | |
| 32 | + */ | |
| 33 | + beforeEach((done) => { | |
| 34 | + // Create the component bed for the test. Optionally, this could be done | |
| 35 | + // in each test if one needs customization of these parameters per test | |
| 36 | + let cls = createClass({ | |
| 37 | + template: htmlTemplate, | |
| 38 | + directives: [ContentViewerActionsComponent], | |
| 39 | + providers: providers, | |
| 40 | + properties: {} | |
| 41 | + }); | |
| 42 | + helper = new ComponentTestHelper<ContentViewerActionsComponent>(cls, done); | |
| 43 | + }); | |
| 44 | + | |
| 45 | + it("render the actions new item menu", () => { | |
| 46 | + expect(helper.all("a[class|='btn dropdown-toggle']")[0]).not.toBeNull(); | |
| 47 | + }); | |
| 48 | + | |
| 49 | + it("render two menu item actions", () => { | |
| 50 | + expect(helper.all("ul")[1].find("li").length).toBe(2); | |
| 51 | + }); | |
| 52 | + }); | |
| 53 | +}); | ... | ... |
src/languages/en.json
| ... | ... | @@ -24,7 +24,9 @@ |
| 24 | 24 | "auth.form.login": "Login / Email address", |
| 25 | 25 | "auth.form.password": "Password", |
| 26 | 26 | "auth.form.login_button": "Login", |
| 27 | + "navbar.content_viewer_actions.new_item": "New Item", | |
| 27 | 28 | "navbar.content_viewer_actions.new_post": "New Post", |
| 29 | + "navbar.content_viewer_actions.new_discussion": "New Discussion", | |
| 28 | 30 | "notification.error.default.message": "Something went wrong!", |
| 29 | 31 | "notification.error.default.title": "Oops...", |
| 30 | 32 | "notification.profile.not_found": "Page not found", | ... | ... |
src/languages/pt.json
| ... | ... | @@ -24,7 +24,9 @@ |
| 24 | 24 | "auth.form.login": "Login / Email", |
| 25 | 25 | "auth.form.password": "Senha", |
| 26 | 26 | "auth.form.login_button": "Login", |
| 27 | + "navbar.content_viewer_actions.new_item": "Novo Item", | |
| 27 | 28 | "navbar.content_viewer_actions.new_post": "Novo Artigo", |
| 29 | + "navbar.content_viewer_actions.new_discussion": "Nova Discussão", | |
| 28 | 30 | "notification.error.default.message": "Algo deu errado!", |
| 29 | 31 | "notification.error.default.title": "Oops...", |
| 30 | 32 | "notification.profile.not_found": "Página não encontrada", | ... | ... |