Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
143c239b
Verified
Commit
143c239b
authored
Jul 09, 2018
by
Kaspar Vollenweider
👻
Browse files
modify button helpers slightly and add glyph_action_button_link helper
parent
b04aaaec
Pipeline
#22211
passed with stage
in 48 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/helpers/navigation_and_button_helper.rb
View file @
143c239b
module
NavigationAndButtonHelper
GLYPH_TRANSLATE
=
{
show:
{
text:
'Anzeigen'
,
glyph:
'eye-open'
},
edit:
{
text:
'Bearbeiten'
,
glyph:
'pencil'
},
delete:
{
text:
'Löschen'
,
glyph:
'trash'
},
terminate:
{
text:
'Beenden'
,
glyph:
'off'
},
activate:
{
text:
'Aktivieren'
,
glyph:
'ok'
},
deactivate:
{
text:
'Deaktivieren'
,
glyph:
'remove'
},
back:
{
text:
'Zurück'
,
glyph:
'arrow-left'
},
print:
{
text:
'Ausdrucken'
,
glyph:
'print'
},
download:
{
text:
'Herunterladen'
,
glyph:
'download-alt'
},
yes:
{
text:
'Ja'
,
glyph:
'ok'
},
no:
{
text:
'Nein'
,
glyph:
'remove'
},
journal:
{
text:
'Journal'
,
glyph:
'book'
},
hours:
{
text:
'Stunden erfassen'
,
glyph:
'time'
},
billing_expenses:
{
text:
'Spesen'
,
glyph:
'usd'
},
assignment:
{
text:
'Begleitung'
,
glyph:
'user'
},
certificate:
{
text:
'Nachweis'
,
glyph:
'education'
}
}.
freeze
def
form_navigation_btn
(
action
,
cols:
12
,
with_row:
true
,
md_cols:
nil
,
with_col:
false
,
add_class:
nil
)
button
=
make_nav_button
(
action
)
...
...
@@ -12,6 +31,29 @@ module NavigationAndButtonHelper
link_to
text
,
target
,
class:
"btn btn-
#{
type
}#{
btn_size
}
"
,
**
options
end
def
yield_button_link
(
target
,
**
options
)
btn_size
=
options
[
:dimension
]
&&
" btn-
#{
options
[
:dimension
]
}
"
type
=
options
.
delete
(
:type
)
link_to
(
target
,
class:
"btn btn-
#{
type
||
'default'
}#{
btn_size
}
"
,
**
options
)
do
yield
end
end
# bootstrap button link with action glyphicon
# Params:
# action_type - one of GLYPH_TRANSLATE's keys
# target - the path target for the link
# title: 'string' - optional title attribute, else it will be taken from
# GLYPH_TRANSLATE[action_type][:text]
# dimension: [xs|md|lg] - optional dimension (Bootstrap's: xs, lg, md)
# ..options - any optional parameter link_to accepts
def
glyph_action_button_link
(
action_type
,
target
,
**
options
)
options
[
:title
]
||=
GLYPH_TRANSLATE
[
action_type
.
to_sym
][
:text
]
yield_button_link
(
target
,
**
options
)
do
navigation_glyph
(
action_type
)
end
end
def
make_nav_button
(
action
)
if
action
==
:back
text
=
navigation_glyph
(
:back
)
...
...
@@ -32,25 +74,7 @@ module NavigationAndButtonHelper
end
def
navigation_glyph
(
icon_type
=
:back
)
translate_glyph
=
{
show:
{
text:
'Anzeigen'
,
glyph:
'eye-open'
},
edit:
{
text:
'Bearbeiten'
,
glyph:
'pencil'
},
delete:
{
text:
'Löschen'
,
glyph:
'trash'
},
terminate:
{
text:
'Beenden'
,
glyph:
'off'
},
activate:
{
text:
'Aktivieren'
,
glyph:
'ok'
},
deactivate:
{
text:
'Deaktivieren'
,
glyph:
'remove'
},
back:
{
text:
'Zurück'
,
glyph:
'arrow-left'
},
print:
{
text:
'Ausdrucken'
,
glyph:
'print'
},
download:
{
text:
'Herunterladen'
,
glyph:
'download-alt'
},
yes:
{
text:
'Ja'
,
glyph:
'ok'
},
no:
{
text:
'Nein'
,
glyph:
'remove'
},
journal:
{
text:
'Journal'
,
glyph:
'book'
},
hours:
{
text:
'Stunden erfassen'
,
glyph:
'time'
},
billing_expenses:
{
text:
'Spesen'
,
glyph:
'usd'
},
assignment:
{
text:
'Begleitung'
,
glyph:
'user'
},
certificate:
{
text:
'Nachweis'
,
glyph:
'education'
}
}
glyph_span
(
translate_glyph
[
icon_type
.
to_sym
])
glyph_span
(
GLYPH_TRANSLATE
[
icon_type
.
to_sym
])
end
def
glyph_span
(
text:
'Zurück'
,
glyph:
'arrow-left'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment