configurable link hint text & url

stable
Juanfran 2015-06-12 10:28:12 +02:00
parent 21f705a0e8
commit a072d96eac
3 changed files with 24 additions and 30 deletions

View File

@ -1,21 +1,28 @@
class ProfileHints
maxHints: 4
supportUrls: [
"https://taiga.io/support/import-export-projects/", #HINT1
"https://taiga.io/support/custom-fields/" #HINT2
"#" #HINT3
"#" #HINT4
HINTS: [
{ #hint1
url: "https://taiga.io/support/import-export-projects/"
},
{ #hint2
url: "https://taiga.io/support/custom-fields/"
},
{ #hint3
},
{ #hint4
}
]
constructor: (@translate) ->
hintKey = Math.floor(Math.random() * @.maxHints) + 1
hintKey = Math.floor(Math.random() * @.HINTS.length) + 1
@.url = @.supportUrls[hintKey - 1]
@.hint = @.HINTS[hintKey - 1]
@.hint.linkText = @.hint.linkText || 'HINTS.LINK'
@translate("HINTS.HINT#{hintKey}_TITLE").then (text) =>
@.title = text
@.hint.title = text
@translate("HINTS.HINT#{hintKey}_TEXT").then (text) =>
@.text = text
@.hint.text = text
ProfileHints.$inject = [
"$translate"

View File

@ -24,26 +24,13 @@ describe "ProfileHints", ->
$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")
mocks.translateService.promise().resolve("fill")
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")
expect(ctrl.hint.title).to.be.equal("fill")
expect(ctrl.hint.text).to.be.equal("fill")
expect(ctrl.hint.linkText).to.have.length.above(1)
done()
)

View File

@ -2,7 +2,7 @@ h4
span.icon.icon-help
span(translate="HINTS.SECTION_NAME")
p {{::vm.title}}
p {{::vm.text}}
p {{::vm.hint.title}}
p {{::vm.hint.text}}
|  
a(target="_blank", ng-href="{{::vm.url}}", title="{{'HINTS.LINK_TITLE' | translate}}", translate="HINTS.LINK")
a(ng-if="::vm.hint.url", target="_blank", ng-href="{{::vm.hint.url}}", title="{{'HINTS.LINK_TITLE' | translate}}", translate="{{::vm.hint.linkText}}")