Additional board admin work
This commit is contained in:
parent
e6186aabf0
commit
45ecb6fdde
@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<h3>Current Boards</h3>
|
||||
|
||||
<div class="small right filters">
|
||||
<div class="small right filters" *ngIf="boards.length">
|
||||
<label class="inline right">
|
||||
Show By User:
|
||||
<select class="autosize">
|
||||
@ -103,12 +103,13 @@
|
||||
<label>Columns</label>
|
||||
<ul class="modal-list" [hidden]="!modalProps.columns.length"
|
||||
[dragula]="'columns-bag'" [dragulaModel]="modalProps.columns">
|
||||
<li *ngFor="let column of modalProps.columns">
|
||||
<li *ngFor="let column of modalProps.columns; let i = index">
|
||||
<i class="icon icon-resize-vertical"></i>
|
||||
{{ column.name }}
|
||||
<inline-edit [text]="getColumnName(i)"
|
||||
(edit)="onColumnNameEdit($event, i)"></inline-edit>
|
||||
<span class="actions">
|
||||
<i class="icon icon-edit color-primary"></i>
|
||||
<i class="icon icon-trash-empty color-secondary"
|
||||
title="Remove"
|
||||
(click)="modalProps.removeColumn(column)"></i>
|
||||
</span>
|
||||
</li>
|
||||
@ -129,13 +130,14 @@
|
||||
<div class="half-modal">
|
||||
<label>Categories</label>
|
||||
<ul *ngIf="modalProps.categories.length" class="modal-list">
|
||||
<li *ngFor="let category of modalProps.categories">
|
||||
{{ category.name }}
|
||||
<li *ngFor="let category of modalProps.categories; let i = index">
|
||||
<span class="badge" title="Default Task Color"
|
||||
[style.background-color]="getColor(category)"></span>
|
||||
<inline-edit [text]="getCategoryName(i)"
|
||||
(edit)="onCategoryNameEdit($event, i)"></inline-edit>
|
||||
<span class="actions">
|
||||
<span class="badge" title="Default Task Color"
|
||||
[style.background-color]="getColor(category)"></span>
|
||||
<i class="icon icon-edit color-primary"></i>
|
||||
<i class="icon icon-trash-empty color-secondary"
|
||||
title="Remove"
|
||||
(click)="modalProps.removeCategory(category)"></i>
|
||||
</span>
|
||||
</li>
|
||||
@ -163,13 +165,16 @@
|
||||
Issue Trackers
|
||||
<i class="icon icon-help-circled"
|
||||
alt="Example URL: https://github.com/kiswa/TaskBoard/issues/%BUGID\1%
|
||||
Example RegExp: (?:Issue)?#(\d+)"></i>
|
||||
Example RegExp: (?:Issue)?#(\d+)"></i>
|
||||
</label>
|
||||
<ul *ngIf="modalProps.issueTrackers.length" class="modal-list">
|
||||
<li *ngFor="let tracker of modalProps.issueTrackers">
|
||||
{{ tracker.url }} | {{ tracker.bugId }}
|
||||
<li class="double-edit"
|
||||
*ngFor="let tracker of modalProps.issueTrackers; let i = index">
|
||||
<inline-edit class="first" [text]="getTrackerUrl(i)"
|
||||
(edit)="onTrackerUrlEdit($event, i)"></inline-edit>
|
||||
<inline-edit class="last" [text]="getTrackerRegExp(i)"
|
||||
(edit)="onTrackerRegExpEdit($event, i)"></inline-edit>
|
||||
<span class="actions">
|
||||
<i class="icon icon-edit color-primary"></i>
|
||||
<i class="icon icon-trash-empty color-secondary"
|
||||
(click)="modalProps.removeIssueTracker(tracker)"></i>
|
||||
</span>
|
||||
@ -194,19 +199,17 @@
|
||||
<div class="users">
|
||||
<label>Select Users</label>
|
||||
<div class="clearfix"></div>
|
||||
<div class="user-select" *ngFor="let user of users">
|
||||
<label>
|
||||
<input type="checkbox">
|
||||
<label class="user-select" *ngFor="let user of users; let i = index">
|
||||
<input type="checkbox" [(ngModel)]="users[i].selected">
|
||||
{{ user.username }}
|
||||
<span *ngIf="user.security_level === 2">*</span>
|
||||
</label>
|
||||
</div>
|
||||
<p>
|
||||
<span *ngIf="hasBAUsers"><strong>*</strong> Including a Board Admin, makes
|
||||
them an admin of this board.<br></span>
|
||||
</label>
|
||||
<div>
|
||||
<em *ngIf="hasBAUsers"><strong>*</strong> Including a Board Admin,
|
||||
makes them an admin of this board.<br></em>
|
||||
<em>Administrators have access to all boards and are
|
||||
not listed here.</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
|
@ -4,23 +4,28 @@ import { Dragula, DragulaService } from 'ng2-dragula/ng2-dragula';
|
||||
|
||||
import {
|
||||
ApiResponse,
|
||||
User,
|
||||
Board,
|
||||
InlineEdit,
|
||||
Modal,
|
||||
Notification,
|
||||
User,
|
||||
AuthService,
|
||||
ModalService,
|
||||
NotificationsService,
|
||||
AuthService
|
||||
NotificationsService
|
||||
} from '../../shared/index';
|
||||
import { SettingsService } from '../settings.service';
|
||||
//import { BoardAdminService } from './board-admin.service';
|
||||
import { BoardAdminService } from './board-admin.service';
|
||||
import { BoardData } from './board-data.model';
|
||||
|
||||
class SelectableUser extends User {
|
||||
public selected: boolean;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'tb-board-admin',
|
||||
templateUrl: 'app/settings/board-admin/board-admin.component.html',
|
||||
directives: [ Modal, Dragula ],
|
||||
// providers: [ BoardAdminService ],
|
||||
directives: [ InlineEdit, Modal, Dragula ],
|
||||
providers: [ BoardAdminService ],
|
||||
viewProviders: [ DragulaService ]
|
||||
})
|
||||
export class BoardAdmin {
|
||||
@ -38,6 +43,8 @@ export class BoardAdmin {
|
||||
constructor(private auth: AuthService,
|
||||
private modal: ModalService,
|
||||
private settings: SettingsService,
|
||||
private boardService: BoardAdminService,
|
||||
private notes: NotificationsService,
|
||||
private dragula: DragulaService) {
|
||||
this.MODAL_ID = 'board-addedit-form';
|
||||
this.users = [];
|
||||
@ -61,10 +68,11 @@ export class BoardAdmin {
|
||||
this.users = [];
|
||||
this.hasBAUsers = false;
|
||||
|
||||
users.forEach((user) => {
|
||||
users.forEach(user => {
|
||||
// Don't include admin users
|
||||
if (user.security_level > 1) {
|
||||
this.users.push(user);
|
||||
|
||||
if (user.security_level === 2) {
|
||||
this.hasBAUsers = true;
|
||||
}
|
||||
@ -89,6 +97,70 @@ export class BoardAdmin {
|
||||
});
|
||||
}
|
||||
|
||||
addBoard(): void {
|
||||
this.setBoardUsers();
|
||||
|
||||
if (this.validateBoard()) {
|
||||
this.boardService.addBoard(this.modalProps);
|
||||
}
|
||||
}
|
||||
|
||||
private validateBoard(): boolean {
|
||||
if (this.modalProps.boardName === '') {
|
||||
this.notes.add(new Notification('error',
|
||||
'Board name is required.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.modalProps.columns.length === 0) {
|
||||
this.notes.add(new Notification('error',
|
||||
'At least one column is required.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private setBoardUsers(): void {
|
||||
this.users.forEach((user: SelectableUser) => {
|
||||
if (user.selected) {
|
||||
this.modalProps.users.push(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getColumnName(i: number): string {
|
||||
return this.modalProps.columns[i].name;
|
||||
}
|
||||
|
||||
private onColumnNameEdit(e: string, i: number): void {
|
||||
this.modalProps.columns[i].name = e;
|
||||
}
|
||||
|
||||
private getCategoryName(i: number): string {
|
||||
return this.modalProps.categories[i].name;
|
||||
}
|
||||
|
||||
private onCategoryNameEdit(e: string, i: number): void {
|
||||
this.modalProps.categories[i].name = e;
|
||||
}
|
||||
|
||||
private getTrackerUrl(i): string {
|
||||
return this.modalProps.issueTrackers[i].url;
|
||||
}
|
||||
|
||||
private onTrackerUrlEdit(e: string, i: number): void {
|
||||
this.modalProps.issueTrackers[i].url = e;
|
||||
}
|
||||
|
||||
private getTrackerRegExp(i: number): string {
|
||||
return this.modalProps.issueTrackers[i].bugId;
|
||||
}
|
||||
|
||||
private onTrackerRegExpEdit(e: string, i: number): void {
|
||||
this.modalProps.issueTrackers[i].bugId = e;
|
||||
}
|
||||
|
||||
private getColor(category: any): string {
|
||||
return category.defaultColor;
|
||||
}
|
||||
@ -98,6 +170,9 @@ export class BoardAdmin {
|
||||
|
||||
if (isAdd) {
|
||||
this.modalProps = new BoardData(title);
|
||||
this.users.forEach((user: SelectableUser) => {
|
||||
user.selected = false;
|
||||
});
|
||||
} else {
|
||||
// TODO: Load board data in constructor
|
||||
this.modalProps = new BoardData(title);
|
||||
|
@ -1,2 +1,55 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/catch';
|
||||
|
||||
import { ApiResponse, Board, User } from '../../shared/index';
|
||||
import { BoardData } from './board-data.model';
|
||||
|
||||
@Injectable()
|
||||
export class BoardAdminService {
|
||||
constructor(private http: Http) {
|
||||
}
|
||||
|
||||
addBoard(board: BoardData): Observable<ApiResponse> {
|
||||
let newBoard = this.convertForApi(board);
|
||||
console.log(newBoard);
|
||||
|
||||
return this.http.post('api/boards', newBoard)
|
||||
.map(res => {
|
||||
let response: ApiResponse = res.json();
|
||||
return response;
|
||||
})
|
||||
.catch((res, caught) => {
|
||||
let response: ApiResponse = res.json();
|
||||
return Observable.of(response);
|
||||
});
|
||||
}
|
||||
|
||||
private convertForApi(board: BoardData): Board {
|
||||
let newBoard = new Board();
|
||||
|
||||
newBoard.name = board.boardName;
|
||||
|
||||
board.columns.forEach(column => {
|
||||
newBoard.addColumn(column.name);
|
||||
});
|
||||
|
||||
board.categories.forEach(category => {
|
||||
newBoard.addCategory(category.name, category.defaultColor);
|
||||
});
|
||||
|
||||
board.issueTrackers.forEach(tracker => {
|
||||
newBoard.addIssueTracker(tracker.url, tracker.bugId);
|
||||
});
|
||||
|
||||
board.users.forEach(user => {
|
||||
newBoard.users.push(user);
|
||||
});
|
||||
|
||||
return newBoard;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
<tb-modal modal-title="Confirm User Removal" blocking="true"
|
||||
modal-id="{{ MODAL_CONFIRM_ID }}">
|
||||
<div class="center">Removing a user cannot be undone.<br>Are you sure?</div>
|
||||
<div class="center">Removing a user cannot be undone.<br>Continue?</div>
|
||||
<div class="buttons">
|
||||
<button class="flat" (click)="removeUser()">Yes</button>
|
||||
<button (click)="modal.close(MODAL_CONFIRM_ID)">No</button>
|
||||
@ -76,22 +76,23 @@
|
||||
[(ngModel)]="modalProps.user.email">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Default Board
|
||||
<i *ngIf="modalProps.title === 'Add'"
|
||||
alt="Selecting a default board adds the user to that board."
|
||||
class="icon icon-help-circled"></i>
|
||||
<select>
|
||||
<option>TODO</option>
|
||||
</select>
|
||||
</label>
|
||||
<div *ngIf="boards.length">
|
||||
<label>
|
||||
Default Board
|
||||
<i alt="Selecting a default board adds the user to that board."
|
||||
class="icon icon-help-circled"></i>
|
||||
<select>
|
||||
<option>TODO</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Board Access
|
||||
<select multiple>
|
||||
<option>TODO</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Board Access
|
||||
<select multiple>
|
||||
<option>TODO</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
Security Level
|
||||
|
Reference in New Issue
Block a user