diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index ee840f23..93639da1 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -1150,6 +1150,15 @@ "LAST_MODIFICATION": "last modification" } }, + "HINTS": { + "SECTION_NAME": "Hint", + "LINK": "If you want to know how to use it visit our support page", + "LINK_TITLE": "Visit our support page", + "HINT1_TITLE": "Did you know you import and export projects?", + "HINT1_TEXT": "This allow you to extract all your data from one taiga and move it to another one", + "HINT2_TITLE": "Did you know you can create custom fields?", + "HINT2_TEXT": "This will provide teams with a flexible input to fit in their workflow" + }, "TIMELINE": { "UPLOAD_ATTACHMENT": "{{username}} has uploaded a new attachment in {{obj_name}}", "US_CREATED": "{{username}} has created a new US in {{project_name}} {{obj_name}}", diff --git a/app/modules/profile/includes/profile-sidebar.jade b/app/modules/profile/includes/profile-sidebar.jade index 48e8d078..d5b46539 100644 --- a/app/modules/profile/includes/profile-sidebar.jade +++ b/app/modules/profile/includes/profile-sidebar.jade @@ -5,10 +5,4 @@ aside.profile-sidebar a.trans-button span(translate="USER.PROFILE_SIDEBAR.ADD_INFO") - h4 - span.icon.icon-help - span Hint - - p Did you know you can archive user Stories? - p Archived User Stories help you organize better your columns and remove old cards. - a(href="", title="visit our archived user stories support page") If you want to know how to use it visit our archived user stories support page + div(tg-profile-hints) \ No newline at end of file diff --git a/app/modules/profile/profile-hints/profile-hints.controller.coffee b/app/modules/profile/profile-hints/profile-hints.controller.coffee new file mode 100644 index 00000000..657656b1 --- /dev/null +++ b/app/modules/profile/profile-hints/profile-hints.controller.coffee @@ -0,0 +1,22 @@ +class ProfileHints + maxHints: 2 + supportUrls: [ + "https://taiga.io/support/import-export-projects/", + "https://taiga.io/support/custom-fields/" + ] + constructor: (@translate) -> + hintKey = Math.floor(Math.random() * @.maxHints) + 1 + + @.url = @.supportUrls[hintKey - 1] + + @translate("HINTS.HINT#{hintKey}_TITLE").then (text) => + @.title = text + + @translate("HINTS.HINT#{hintKey}_TEXT").then (text) => + @.text = text + +ProfileHints.$inject = [ + "$translate" +] + +angular.module("taigaProfile").controller("ProfileHints", ProfileHints) diff --git a/app/modules/profile/profile-hints/profile-hints.controller.spec.coffee b/app/modules/profile/profile-hints/profile-hints.controller.spec.coffee new file mode 100644 index 00000000..e9428308 --- /dev/null +++ b/app/modules/profile/profile-hints/profile-hints.controller.spec.coffee @@ -0,0 +1,49 @@ +describe "ProfileHints", -> + $controller = null + $provide = null + + mocks = {} + + _mockTranslate = () -> + mocks.translateService = sinon.stub() + + $provide.value "$translate", mocks.translateService + + _mocks = () -> + module (_$provide_) -> + $provide = _$provide_ + _mockTranslate() + + return null + + beforeEach -> + module "taigaProfile" + _mocks() + + inject (_$controller_) -> + $controller = _$controller_ + + it "random hint generator", (done) -> + + returned = { + then: () -> + } + + mocks.translateService.withArgs("HINTS.HINT1_TITLE").promise().resolve("title_1") + mocks.translateService.withArgs("HINTS.HINT1_TEXT").promise().resolve("text_1") + + mocks.translateService.withArgs("HINTS.HINT2_TITLE").promise().resolve("title_2") + mocks.translateService.withArgs("HINTS.HINT2_TEXT").promise().resolve("text_2") + + ctrl = $controller("ProfileHints") + + setTimeout ( -> + if ctrl.url == "https://taiga.io/support/custom-fields/" + expect(ctrl.title).to.be.equal("title_2") + expect(ctrl.text).to.be.equal("text_2") + done() + else if ctrl.url == "https://taiga.io/support/import-export-projects/" + expect(ctrl.title).to.be.equal("title_1") + expect(ctrl.text).to.be.equal("text_1") + done() + ) diff --git a/app/modules/profile/profile-hints/profile-hints.directive.coffee b/app/modules/profile/profile-hints/profile-hints.directive.coffee new file mode 100644 index 00000000..63d61fcf --- /dev/null +++ b/app/modules/profile/profile-hints/profile-hints.directive.coffee @@ -0,0 +1,13 @@ +ProfileHints = ($translate) -> + return { + scope: {}, + controller: "ProfileHints", + controllerAs: "vm", + templateUrl: "profile/profile-hints/profile-hints.html" + } + +ProfileHints.$inject = [ + "$translate" +] + +angular.module("taigaProfile").directive("tgProfileHints", ProfileHints) diff --git a/app/modules/profile/profile-hints/profile-hints.jade b/app/modules/profile/profile-hints/profile-hints.jade new file mode 100644 index 00000000..f5057393 --- /dev/null +++ b/app/modules/profile/profile-hints/profile-hints.jade @@ -0,0 +1,8 @@ +h4 + span.icon.icon-help + span(translate="HINTS.SECTION_NAME") + +p {{::vm.title}} +p {{::vm.text}} + |   + a(target="_blank", ng-href="{{::vm.url}}", title="{{'HINTS.LINK_TITLE' | translate}}", translate="HINTS.LINK")