Added error message if bundle wasn't found.

This commit is contained in:
Prominence 2016-06-27 13:31:16 +03:00
parent 675eb1d055
commit 0a90793b02
6 changed files with 22 additions and 7 deletions

View File

@ -12,13 +12,15 @@ class TranslationsOverviewController {
def show() { def show() {
if (!params.bundleName) { if (!params.bundleName) {
// render error redirect action: 'index'
return
} }
Bundle bundle = bundleService.findBundleByName(params.bundleName as String) Bundle bundle = bundleService.findBundleByName(params.bundleName as String)
if (!bundle) { if (!bundle) {
// render error render view: 'index', model: [message: g.message(code: 'plugin.translations.error.bundleNotFound', args: [params.bundleName as String])]
return
} }
render view: 'show', model: [bundle: bundle] render view: 'show', model: [bundle: bundle]

View File

@ -2,4 +2,6 @@ plugin.translations.overview.index.page.title = Translations overview
plugin.translations.overview.show.page.title = Bundle {0} plugin.translations.overview.show.page.title = Bundle {0}
plugin.translations.totalRecords = Total: {0} records plugin.translations.totalRecords = Total: {0} records
plugin.translations.totalBundles = Total: {0} bundles plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.

View File

@ -2,4 +2,6 @@ plugin.translations.overview.index.page.title = Translations overview
plugin.translations.overview.show.page.title = Bundle {0} plugin.translations.overview.show.page.title = Bundle {0}
plugin.translations.totalRecords = Total: {0} records plugin.translations.totalRecords = Total: {0} records
plugin.translations.totalBundles = Total: {0} bundles plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.

View File

@ -2,4 +2,6 @@ plugin.translations.overview.index.page.title = Translations overview
plugin.translations.overview.show.page.title = Bundle {0} plugin.translations.overview.show.page.title = Bundle {0}
plugin.translations.totalRecords = Total: {0} records plugin.translations.totalRecords = Total: {0} records
plugin.translations.totalBundles = Total: {0} bundles plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.

View File

@ -2,4 +2,6 @@ plugin.translations.overview.index.page.title = Обзор переводов
plugin.translations.overview.show.page.title = Бандл {0} plugin.translations.overview.show.page.title = Бандл {0}
plugin.translations.totalRecords = Всего: {0} записей plugin.translations.totalRecords = Всего: {0} записей
plugin.translations.totalBundles = Всего: {0} бандлов plugin.translations.totalBundles = Всего: {0} бандлов
plugin.translations.error.bundleNotFound = Бандл с именем <b>{0}</b> не найден.

View File

@ -7,16 +7,21 @@
</head> </head>
<body> <body>
<g:if test="${message}">
<div class="alert alert-danger">
${message}
</div>
</g:if>
<g:if test="${bundles}"> <g:if test="${bundles}">
<ol> <ol>
<g:each in="${bundles}" var="bundle"> <g:each in="${bundles}" var="bundle">
<li><g:link action="show" params="${[bundleName: bundle.name]}" >${bundle.name}</g:link></li> <li><g:link action="show" params="${[bundleName: bundle.name]}" >${bundle.name}</g:link></li>
</g:each> </g:each>
</ol> </ol>
<g:message code="plugin.translations.totalBundles" args="${[bundles.size()]}"/>
</g:if> </g:if>
<g:else> <g:else>
There is no bundles! There is no bundles!
</g:else> </g:else>
<g:message code="plugin.translations.totalBundles" args="${[bundles.size()]}"/>
</body> </body>
</html> </html>