Fix tests, more translation, update counts

This commit is contained in:
kiswa 2017-03-03 22:04:36 +00:00
parent dd8a350825
commit 32ab494e1e
17 changed files with 156 additions and 77 deletions

View File

@ -132,13 +132,13 @@ Because I like seeing the numbers.
### `src`
Language | Files | Blank | Comment | Code
-------------|-------:|---------:|--------:|---------:
TypeScript | 51 | 543 | 23 | 2521
PHP | 18 | 538 | 19 | 1672
HTML | 17 | 117 | 0 | 1061
SASS | 13 | 207 | 11 | 940
__SUM:__ | __99__ | __1405__ | __53__ | __6194__
Language | Files | Blank | Comment | Code
-------------|--------:|---------:|--------:|---------:
TypeScript | 53 | 565 | 24 | 2656
PHP | 18 | 554 | 19 | 1725
HTML | 17 | 120 | 10 | 1102
SASS | 13 | 207 | 11 | 942
__SUM:__ | __101__ | __1446__ | __64__ | __6425__
Command: `cloc --exclude-dir=vendor --exclude-ext=json src/`
@ -146,11 +146,11 @@ Command: `cloc --exclude-dir=vendor --exclude-ext=json src/`
Language | Files | Blank | Comment | Code
-------------|-------:|---------:|--------:|---------:
PHP | 10 | 669 | 14 | 1955
JavaScript | 29 | 383 | 49 | 1584
__SUM:__ | __39__ | __1052__ | __63__ | __3539__
PHP | 10 | 683 | 16 | 1994
JavaScript | 30 | 390 | 50 | 1610
__SUM:__ | __40__ | __1073__ | __66__ | __3604__
Command: `cloc --exclude-ext=xml test/`
Counts last updated Feb 17, 2017
Counts last updated Mar 3, 2017

View File

@ -8,7 +8,8 @@ import { Notifications, StringsService } from './shared/index';
})
export class AppComponent {
constructor(strings: StringsService) {
// Nothing needed
// StringsService loaded here so the same instance
// is availabe across the app.
}
}

View File

@ -61,7 +61,7 @@ export class BoardDisplay implements OnInit {
});
active.params.subscribe(params => {
let id = +params['id']; // tslint:disable-line
let id = +params.id;
this.boardNavId = id ? id : null;
this.updateActiveBoard();

View File

@ -1,4 +1,4 @@
<tb-top-nav page-name="Settings"></tb-top-nav>
<tb-top-nav page-name="{{ strings['settings'] }}"></tb-top-nav>
<div class="settings">
<div class="half-page">

View File

@ -1,13 +1,8 @@
import { Component } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TopNav } from '../shared/index';
import { StringsService } from '../shared/index';
import { SettingsService } from './settings.service';
import {
UserSettings,
UserAdmin,
BoardAdmin
} from './index';
@Component({
selector: 'tb-settings',
@ -15,10 +10,18 @@ import {
providers: [ SettingsService ]
})
export class Settings {
constructor(private settings: SettingsService, private title: Title) {
private strings: any;
constructor(private settings: SettingsService,
private stringsService: StringsService,
private title: Title) {
// SettingsService is loaded here so the same instance is available
// to all child components.
title.setTitle('TaskBoard - Settings');
stringsService.stringsChanged.subscribe(newStrings => {
this.strings = newStrings;
title.setTitle('TaskBoard - ' + this.strings['settings']); // tslint:disable-line
});
}
}

View File

@ -1,15 +1,15 @@
<section>
<h2>User Administration</h2>
<h2>{{ strings['settings_userAdmin'] }}</h2>
<div class="row">
<table class="alternating">
<thead>
<tr>
<th>User</th>
<th>Email</th>
<th>Security Level</th>
<th>Default Board</th>
<th>Actions</th>
<th>{{ strings['settings_user'] }}</th>
<th>{{ strings['settings_email'] }}</th>
<th>{{ strings['settings_securityLevel'] }}</th>
<th>{{ strings['settings_defaultBoard'] }}</th>
<th>{{ strings['settings_actions'] }}</th>
</tr>
</thead>
<tbody *ngIf="!loading">
@ -20,11 +20,13 @@
<td>{{ user.default_board_name }}</td>
<td>
<span *ngIf="user.can_admin">
<a class="padded" href="javascript:" title="Edit User"
(click)="showModal('Edit', user)">
<a class="padded" href="javascript:"
title="{{ strings['settings_edit'] }} {{ strings['settings_user'] }}"
(click)="showModal(strings['settings_edit'], user)">
<i class="icon icon-edit color-primary"></i>
</a>
<a class="padded" href="javascript:" title="Remove User"
<a class="padded" href="javascript:"
title="{{ strings['settings_removeUser'] }}"
(click)="showConfirmModal(user)">
<i class="icon icon-trash-empty color-secondary"></i>
</a>
@ -39,53 +41,60 @@
</div>
<button *ngIf="activeUser.security_level < 3"
(click)="showModal('Add')">
<i class="icon icon-plus"></i> Add User
(click)="showModal(strings['settings_add'])">
<i class="icon icon-plus"></i>
{{ strings['settings_add'] }} {{ strings['settings_user'] }}
</button>
</div>
</section>
<tb-modal modal-title="Confirm User Removal" blocking="true"
modal-id="{{ MODAL_CONFIRM_ID }}">
<div class="center">Removing a user cannot be undone.<br>Continue?</div>
<div class="center">
{{ strings['settings_removeUserWarning'] }}<br>
{{ strings['settings_continue'] }}
</div>
<div class="buttons">
<button class="flat"
(click)="removeUser()">Yes</button>
(click)="removeUser()">{{ strings['yes'] }}</button>
<button #defaultAction
(click)="modal.close(MODAL_CONFIRM_ID)">No</button>
(click)="modal.close(MODAL_CONFIRM_ID)">{{ strings['no'] }}</button>
</div>
</tb-modal>
<tb-modal modal-title="{{ modalProps.title }} User" modal-id="{{ MODAL_ID }}">
<tb-modal modal-title="{{ modalProps.title }} {{ strings['settings_user'] }}"
modal-id="{{ MODAL_ID }}">
<label>
{{ modalProps.prefix }} Username
<input #focusMe type="text" name="new-username" placeholder="Username"
{{ modalProps.prefix }} {{ strings['settings_username'] }}
<input #focusMe type="text" name="new-username"
placeholder="{{ strings['settings_username'] }}"
[(ngModel)]="modalProps.user.username">
</label>
<label>
{{ modalProps.prefix }} Password
<input type="password" name="new-password" placeholder="Password"
{{ modalProps.prefix }} {{ strings['settings_password'] }}
<input type="password" name="new-password"
placeholder="{{ strings['settings_password'] }}"
[(ngModel)]="modalProps.user.password">
</label>
<input type="password" name="new-password-verify"
placeholder="Verify Password"
placeholder="{{ strings['settings_verifyPassword'] }}"
[(ngModel)]="modalProps.user.password_verify">
<label>
{{ modalProps.prefix }} Email
{{ modalProps.prefix }} {{ strings['settings_email'] }}
<input type="text" name="new-email"
placeholder="New Email - Blank to disable"
placeholder="{{ strings['settings_emailPlaceholder'] }}"
[(ngModel)]="modalProps.user.email">
</label>
<div *ngIf="boards.length">
<label>
Default Board
<i alt="Selecting a default board adds the user to that board."
{{ strings['settings_defaultBoard'] }}
<i [attr.data-help]="strings['settings_defaultBoardHelp']"
class="icon icon-help-circled"></i>
<select [(ngModel)]="modalProps.user.default_board_id">
<option value="0">None</option>
<option value="0">{{ strings['none'] }}</option>
<option *ngFor="let board of boards" value="{{ board.id }}">
{{ board.name }}
</option>
@ -93,7 +102,7 @@
</label>
<label>
Board Access
{{ strings['settings_boardAccess'] }}
<select multiple [(ngModel)]="modalProps.user.boardAccess">
<option *ngFor="let board of boards" value="{{ board.id }}">
{{ board.name }}
@ -103,12 +112,12 @@
</div>
<label>
Security Level
{{ strings['settings_securityLevel'] }}
<select name="new-security"
[(ngModel)]="modalProps.user.security_level">
<option value="3">User</option>
<option value="2">Board Admin</option>
<option value="1">Admin</option>
<option value="3">{{ strings['settings_user'] }}</option>
<option value="2">{{ strings['settings_boardAdmin'] }}</option>
<option value="1">{{ strings['settings_admin'] }}</option>
</select>
</label>
@ -118,11 +127,12 @@
<i class="icon"
[ngClass]="{ 'icon-plus': modalProps.prefix === '',
'icon-floppy': modalProps.prefix !== '' }"></i>
{{ modalProps.prefix === '' ? 'Add' : 'Save' }}
User
{{ modalProps.prefix === ''
? strings['settings_add'] : strings['save'] }}
{{ strings['settings_user'] }}
</button>
<button class="flat" (click)="modal.close(MODAL_ID)">
Cancel
{{ strings['cancel'] }}
</button>
</div>
</tb-modal>

View File

@ -10,7 +10,8 @@ import {
User,
AuthService,
ModalService,
NotificationsService
NotificationsService,
StringsService
} from '../../shared/index';
import {
UserDisplay,
@ -29,6 +30,7 @@ export class UserAdmin {
private activeUser: User;
private modalProps: ModalProperties;
private userToRemove: UserDisplay;
private strings: any;
private loading = true;
private saving = false;
@ -40,7 +42,8 @@ export class UserAdmin {
private notes: NotificationsService,
private auth: AuthService,
private settings: SettingsService,
private modal: ModalService) {
private modal: ModalService,
private stringsService: StringsService) {
this.MODAL_ID = 'user-addEdit-form';
this.MODAL_CONFIRM_ID = 'user-remove-confirm';
@ -61,6 +64,10 @@ export class UserAdmin {
this.replaceUser(activeUser);
});
stringsService.stringsChanged.subscribe(newStrings => {
this.strings = newStrings;
});
settings.boardsChanged
.subscribe(boards => {
this.boards = boards;
@ -225,11 +232,11 @@ export class UserAdmin {
}
private showModal(title: string, user?: UserDisplay): void {
let isAdd = (title === 'Add');
let isAdd = (title === this.strings.settings_add);
this.modalProps = {
title,
prefix: isAdd ? '' : 'Change',
prefix: isAdd ? '' : this.strings.settings_change,
user: isAdd ? new ModalUser(new User()) : new ModalUser(user)
};

View File

@ -40,7 +40,7 @@
</select>
</label>
<label>
{{ strings['settings_defaultBoard'] }}:
{{ strings['settings_selectDefaultBoard'] }}:
<select class="autosize"
[ngModel]="user.default_board_id"
(ngModelChange)="updateDefaultBoard($event)">

View File

@ -185,10 +185,6 @@ export class UserSettings implements OnInit {
this.changeEmail = new EmailForm(this.user.email);
}
private getString(key: string): string {
return this.strings.getString(key);
}
private addAlerts(alerts: Array<Notification>) {
alerts.forEach(msg => {
this.notes.add(msg);

View File

@ -1,6 +1,12 @@
{
"reset": "Reset",
"none": "None",
"yes": "Yes",
"no": "No",
"save": "Save",
"cancel": "Cancel",
"settings": "Settings",
"settings_userSettings": "My Settings",
"settings_changePassword": "Change Password",
"settings_currentPassword": "Current Password",
@ -13,12 +19,33 @@
"settings_blank": "Blank to disable",
"settings_globalOptions": "Global Options",
"settings_displayLanguage": "Display Language",
"settings_defaultBoard": "Select default board",
"settings_selectDefaultBoard": "Select default board",
"settings_newTasks": "New tasks appear at column",
"settings_bottom": "bottom",
"settings_top": "top",
"settings_optionsDisplay": "Display tasks side-by-side in columns?",
"settings_optionsAnimate": "Show animations?",
"settings_optionsAssignee": "Show Assignee on task cards?"
"settings_optionsAssignee": "Show Assignee on task cards?",
"settings_userAdmin": "User Administration",
"settings_user": "User",
"settings_email": "Email",
"settings_securityLevel": "Security Level",
"settings_defaultBoard": "Default Board",
"settings_actions": "Actions",
"settings_edit": "Edit",
"settings_removeUser": "Remove User",
"settings_add": "Add",
"settings_change": "Change",
"settings_confirmUserRemoval": "Confirm User Removal",
"settings_removeUserWarning": "Removing a user cannot be undone.",
"setings_continue": "Continue?",
"settings_username": "Username",
"settings_password": "Password",
"settings_emailPlaceholder": "New Email - Blank to disable",
"settings_defaultBoardHelp": "Selecting a default board adds the user to that board.",
"settings_boardAccess": "Board Access",
"settings_boardAdmin": "Board Admin",
"settings_admin": "Admin"
}

View File

@ -1,24 +1,51 @@
{
"reset": "Reiniciar",
"none": "Nada",
"yes": "Sí",
"no": "No",
"save": "Guardar",
"cancel": "Cancelar",
"settings": "Ajustes",
"settings_userSettings": "Mi Configuración",
"settings_changePassword": "Cambia la Contraseña",
"settings_changePassword": "Cambia Contraseña",
"settings_currentPassword": "Contraseña Actual",
"settings_newPassword": "Contraseña Nueva",
"settings_verifyPassword": "Verficar Contraseña",
"settings_changeUsername": "Cambia el Nombre de Usuario",
"settings_changeUsername": "Cambia Nombre de Usuario",
"settings_newUsername": "Nuevo Nombre de Usuario",
"settings_changeEmail": "Cambia Email",
"settings_newEmail": "Nuevo Email",
"settings_blank": "En blanco para desactivar",
"settings_globalOptions": "Opciones Globales",
"settings_displayLanguage": "Idioma de la Pantalla",
"settings_defaultBoard": "Seleccionar Tablero Predeterminada",
"settings_selectDefaultBoard": "Seleccionar Tablero Predeterminada",
"settings_newTasks": "Nuevas tareas aparecen en la columna",
"settings_bottom": "parte inferior",
"settings_top": "parte superior",
"settings_optionsDisplay": "¿Mostrar tareas lado a lado en columnas?",
"settings_optionsAnimate": "¿Mostrar animaciones?",
"settings_optionsAssignee": "¿Mostrar al cesionario en las tarjetas de tarea?"
"settings_optionsAssignee": "¿Mostrar al cesionario en las tarjetas de tarea?",
"settings_userAdmin": "Administración de Usuario",
"settings_user": "Usuario",
"settings_email": "Email",
"settings_securityLevel": "Nivel de Seguridad",
"settings_defaultBoard": "Tablero Predeterminada",
"settings_actions": "Acciones",
"settings_edit": "Editar",
"settings_removeUser": "Eliminar Usuario",
"settings_add": "Agregar",
"settings_change": "Cambia",
"settings_confirmUserRemoval": "Confirmar Eliminación del Usuario",
"settings_removeUserWarning": "No se puede deshacer la eliminación de un usuario.",
"setings_continue": "¿Continuar?",
"settings_username": "Nombre de Usuario",
"settings_password": "Contraseña",
"settings_emailPlaceholder": "Nuevo Email - En blanco para deshabilitar",
"settings_defaultBoardHelp": "La selección de una tarjeta predeterminada añade el usuario a esa tarjeta.",
"settings_boardAccess": "Acceso a los Tableros",
"settings_boardAdmin": "Administrador de los Tableros",
"settings_admin": "Administrador"
}

View File

@ -109,7 +109,7 @@ button {
background-color: $white;
border: 1px solid $color-border;
content: attr(alt);
content: attr(data-help);
left: 20px;
min-width: 250px;
padding: 7px;

View File

@ -521,6 +521,7 @@ class UsersTest extends PHPUnit_Framework_TestCase {
$data->show_animations = true;
$data->show_assignee = true;
$data->multiple_tasks_per_row = false;
$data->language = "en";
return $data;
}

View File

@ -201,6 +201,13 @@ var actions = [
}
];
global.StringsServiceMock = {
stringsChanged: {
subscribe: function() {}
},
loadStrings: function() {}
};
global.SettingsServiceMock = function() {
var userList = new RxJs.BehaviorSubject(users),
boardList = new RxJs.BehaviorSubject(boards),

View File

@ -1,4 +1,4 @@
/* global expect UserAdminServiceMock NotificationsServiceMock AuthServiceMock SettingsServiceMock ModalServiceMock */
/* global expect UserAdminServiceMock NotificationsServiceMock AuthServiceMock SettingsServiceMock ModalServiceMock StringsServiceMock */
var path = '../../../../build/settings/user-admin/',
UserAdmin = require(path + 'user-admin.component.js').UserAdmin;
@ -22,7 +22,7 @@ describe('UserAdmin', () => {
userAdmin = new UserAdmin(new UserAdminServiceMock(),
new NotificationsServiceMock(), AuthServiceMock,
new SettingsServiceMock(), modalService);
new SettingsServiceMock(), modalService, StringsServiceMock);
});
it('has a function to add or edit a user - Add', done => {

View File

@ -1,4 +1,4 @@
/* global expect AuthServiceMock NotificationsServiceMock SettingsServiceMock UserSettingsServiceMock */
/* global expect AuthServiceMock NotificationsServiceMock SettingsServiceMock StringsServiceMock UserSettingsServiceMock */
var path = '../../../../build/settings/user-settings/',
UserSettings = require(path + 'user-settings.component.js').UserSettings;
@ -23,7 +23,7 @@ describe('UserSettings', () => {
notifications = new NotificationsServiceMock();
userSettings = new UserSettings(AuthServiceMock,
notifications, new SettingsServiceMock(),
UserSettingsServiceMock);
UserSettingsServiceMock, StringsServiceMock);
});
it('resets forms on init', () => {

View File

@ -1,4 +1,4 @@
/* global expect ConstantsMock, HttpMock, RouterMock */
/* global expect ConstantsMock, HttpMock, RouterMock, StringsServiceMock */
var path = '../../../../build/shared/auth/',
AuthService = require(path + 'auth.service.js').AuthService;
@ -7,7 +7,7 @@ describe('AuthService', () => {
beforeEach(() => {
authService = new AuthService(ConstantsMock,
HttpMock, new RouterMock());
HttpMock, new RouterMock(), StringsServiceMock);
});
it('has userOptions', () => {