Code refactoring. Changed design for index page.

Minor changes...
This commit is contained in:
Prominence 2016-07-10 15:00:30 +03:00
parent c05cf24ba4
commit 34048f9525
22 changed files with 132 additions and 100 deletions

View File

@ -22,19 +22,19 @@ class TranslationsGrailsPlugin {
// Extra (optional) plugin metadata
// License: one of 'APACHE', 'GPL2', 'GPL3'
// def license = "APACHE"
def license = "APACHE"
// Details of company behind the plugin (if there is one)
// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]
// Any additional developers beyond the author specified above.
// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
def developers = [ [ name: "Alexey Zinchenko", email: "prominence96@gmail.com" ]]
// Location of the plugin's issue tracker.
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
// Online location of the plugin's browseable source code.
// def scm = [ url: "http://svn.codehaus.org/grails-plugins/" ]
def scm = [ url: "https://github.com/Prominence/grails-translations-plugin" ]
def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before

View File

@ -1,6 +1,6 @@
package by.prominence.translations
class TranslationsOverviewController {
class TranslationsManagementController {
def bundleService
@ -9,23 +9,6 @@ class TranslationsOverviewController {
render view: 'index', model: [bundles: bundleService.getBundles()]
}
def show() {
if (!params.bundleName) {
redirect action: 'index'
return
}
Bundle bundle = bundleService.findBundleByName(params.bundleName as String)
if (!bundle) {
render view: 'index', model: [message: g.message(code: 'plugin.translations.error.bundleNotFound', args: [params.bundleName as String])]
return
}
render view: 'show', model: [bundle: bundle]
}
def edit() {
if (!params.bundleName) {

View File

@ -1,10 +0,0 @@
plugin.translations.overview.index.page.title = Translations overview
plugin.translations.overview.show.page.title = Bundle {0}
plugin.translations.overview.edit.page.title = Edit {0} bundle
plugin.translations.totalRecords = Total: {0} records
plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.
plugin.translations.action.save = Save

View File

@ -7,4 +7,11 @@ plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.
plugin.translations.action.save = Save
plugin.translations.message.noBundles = There is no bundles in your application!
plugin.translations.action.save = Save
plugin.translations.action.edit = Edit
plugin.translations.action.export = Export
plugin.translations.header.bundleName = Bundle
plugin.translations.header.actions = Actions

View File

@ -7,4 +7,11 @@ plugin.translations.totalBundles = Total: {0} bundles
plugin.translations.error.bundleNotFound = Cannot find bundle <b>{0}</b>.
plugin.translations.action.save = Save
plugin.translations.message.noBundles = There is no bundles in your application!
plugin.translations.action.save = Save
plugin.translations.action.edit = Edit
plugin.translations.action.export = Export
plugin.translations.header.bundleName = Bundle
plugin.translations.header.actions = Actions

View File

@ -7,4 +7,11 @@ plugin.translations.totalBundles = Всего: {0} бандлов
plugin.translations.error.bundleNotFound = Бандл с именем <b>{0}</b> не найден.
plugin.translations.action.save = Сохранить
plugin.translations.message.noBundles = В вашем приложении нет бандлов!
plugin.translations.action.save = Сохранить
plugin.translations.action.edit = Редактировать
plugin.translations.action.export = Экспорт
plugin.translations.header.bundleName = Бандл
plugin.translations.header.actions = Действия

View File

@ -5,9 +5,13 @@
<title><g:layoutTitle default="Translations overview" /></title>
<r:layoutResources/>
</head>
<g:layoutBody />
<r:layoutResources/>
<link rel="stylesheet" href="${resource(dir: 'css', file: 'translations.css')}" type="text/css">
<body>
<div class="container main-container">
<g:layoutBody />
</div>
</body>
</html>

View File

@ -0,0 +1,63 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main"/>
<title><g:message code="plugin.translations.overview.index.page.title" /></title>
<r:require modules="bootstrap"/>
</head>
<body>
<div class="raw">
<h2 align="center"><g:message code="plugin.translations.overview.index.page.title"/></h2>
<g:if test="${message}">
<div class="alert alert-danger">
${message}
</div>
</g:if>
<g:if test="${bundles}">
<table class="table table-hover">
<thead>
<tr>
<td>#</td>
<td width="95%" colspan="2">
<g:message code="plugin.translations.header.bundleName"/>
</td>
</tr>
</thead>
<tbody>
<g:each in="${bundles}" var="bundle" status="index">
<tr>
<td width="5%">
${index + 1}
</td>
<td width="75%">
<b>${bundle.name}</b>
</td>
<td>
<div class="action-buttons">
<g:link action="edit" params="${[bundleName: bundle.name]}"
class="btn btn-default">
<g:message code="plugin.translations.action.edit"/>
</g:link>
<g:link action="export" params="${[bundleName: bundle.name]}"
class="btn btn-primary">
<g:message code="plugin.translations.action.export"/>
</g:link>
</div>
</td>
</tr>
</g:each>
</tbody>
</table>
<div class="total">
<g:message code="plugin.translations.totalBundles" args="${[bundles.size()]}"/>
</div>
</g:if>
<g:else>
<div class="alert alert-warning">
<g:message code="plugin.translations.message.noBundles"/>
</div>
</g:else>
</div>
</body>
</html>

View File

@ -1,27 +0,0 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main"/>
<title><g:message code="plugin.translations.overview.index.page.title" /></title>
<r:require modules="bootstrap"/>
</head>
<body>
<g:if test="${message}">
<div class="alert alert-danger">
${message}
</div>
</g:if>
<g:if test="${bundles}">
<ol>
<g:each in="${bundles}" var="bundle">
<li><g:link action="show" params="${[bundleName: bundle.name]}" >${bundle.name}</g:link></li>
</g:each>
</ol>
<g:message code="plugin.translations.totalBundles" args="${[bundles.size()]}"/>
</g:if>
<g:else>
There is no bundles!
</g:else>
</body>
</html>

View File

@ -1,38 +0,0 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main"/>
<title><g:message code="plugin.translations.overview.show.page.title" args="${[bundle.name]}" /></title>
<r:require modules="bootstrap"/>
</head>
<body>
<h1><g:message code="plugin.translations.overview.show.page.title" args="${[bundle.name]}" /></h1>
<br/>
<table>
<thead>
<tr>
<g:each in="${bundle.languages}" var="language">
<th>${language.languageTag.toUpperCase()}</th>
</g:each>
</tr>
</thead>
<tbody>
<tr>
<g:each in="${bundle.languages}" var="language">
<td>
<g:each in="${language.translations}" var="translation">
${translation.key} = ${translation.value} </br>
</g:each>
</td>
</g:each>
</tr>
<tr>
<g:each in="${bundle.languages}" var="language">
<td><g:message code="plugin.translations.totalRecords" args="${language.translations.size() ?: '0'}"/></td>
</g:each>
</tr>
</tbody>
</table>
</body>
</html>

View File

View File

@ -0,0 +1,36 @@
html {
margin: 0px;
padding: 0px;
}
body {
background-color: #222222;
color: #e3e3e3;
}
table {
width: 100%;
}
.main-container {
margin-top: 10%;
border: #000 solid 1px;
background-color: #707070;
padding: 10px;
color: #fff;
font-size: 1.2em;
}
.total {
margin: 10px;
font-size: 1.5em;
}
.action-buttons {
padding-top: 1px;
padding-bottom: 1px;
}
.table-hover tbody tr:hover {
color: #111;
}