Modal animation and board admin tweaks

This commit is contained in:
kiswa 2016-08-26 21:43:33 +00:00
parent 84bf2b46c2
commit 6f0c27df44
8 changed files with 81 additions and 20 deletions

View File

@ -50,7 +50,7 @@
<ul> <ul>
<li *ngFor="let col of board.columns"> <li *ngFor="let col of board.columns">
{{ col.name }} {{ col.name }}
<span class="badge" title="Item Count">{{ col.tasks.length }}</span> <span class="badge" title="Task Count">{{ col.tasks.length }}</span>
</li> </li>
</ul> </ul>
</td> </td>
@ -101,6 +101,15 @@
</div> </div>
</section> </section>
<tb-modal modal-title="Confirm Board Removal" blocking="true"
modal-id="{{ MODAL_CONFIRM_ID }}">
<div class="center">Removing a board cannot be undone.<br>Continue?</div>
<div class="buttons">
<button class="flat" (click)="removeBoard()">Yes</button>
<button (click)="modal.close(MODAL_CONFIRM_ID)">No</button>
</div>
</tb-modal>
<tb-modal modal-title="{{ modalProps.title }} Board" <tb-modal modal-title="{{ modalProps.title }} Board"
modal-id="{{ MODAL_ID }}" wide="true"> modal-id="{{ MODAL_ID }}" wide="true">
<label> <label>
@ -223,9 +232,11 @@
</div> </div>
<div class="buttons"> <div class="buttons">
<button (click)="addBoard()"> <button (click)="addEditBoard()">
<i class="icon icon-plus"></i> <i class="icon"
Add Board [ngClass]="{ 'icon-plus': modalProps.title === 'Add', 'icon-floppy': modalProps.title !== 'Add' }"></i>
{{ modalProps.title === 'Add' ? 'Add' : 'Save' }}
Board
</button> </button>
<button class="flat" (click)="modal.close(MODAL_ID)"> <button class="flat" (click)="modal.close(MODAL_ID)">
Cancel Cancel

View File

@ -34,11 +34,13 @@ export class BoardAdmin {
private activeUser: User; private activeUser: User;
private modalProps: BoardData; private modalProps: BoardData;
private noBoardsMessage: string; private noBoardsMessage: string;
private boardToRemove: Board;
private hasBAUsers = false; private hasBAUsers = false;
private loading = true; private loading = true;
private MODAL_ID: string; private MODAL_ID: string;
private MODAL_CONFIRM_ID: string;
constructor(private auth: AuthService, constructor(private auth: AuthService,
private modal: ModalService, private modal: ModalService,
@ -47,6 +49,8 @@ export class BoardAdmin {
private notes: NotificationsService, private notes: NotificationsService,
private dragula: DragulaService) { private dragula: DragulaService) {
this.MODAL_ID = 'board-addedit-form'; this.MODAL_ID = 'board-addedit-form';
this.MODAL_CONFIRM_ID = 'board-remove-confirm';
this.users = []; this.users = [];
this.boards = []; this.boards = [];
this.modalProps = new BoardData(); this.modalProps = new BoardData();
@ -97,7 +101,7 @@ export class BoardAdmin {
}); });
} }
addBoard(): void { addEditBoard(): void {
this.setBoardUsers(); this.setBoardUsers();
if (this.validateBoard()) { if (this.validateBoard()) {
@ -105,11 +109,9 @@ export class BoardAdmin {
.subscribe((response: ApiResponse) => { .subscribe((response: ApiResponse) => {
response.alerts.forEach(note => this.notes.add(note)); response.alerts.forEach(note => this.notes.add(note));
console.log(response);
// TODO: Update boards list
if (response.status === 'success') { if (response.status === 'success') {
this.modal.close(this.MODAL_ID); this.modal.close(this.MODAL_ID);
this.settings.updateBoards(response.data[1]);
} }
}); });
} }
@ -164,11 +166,11 @@ export class BoardAdmin {
} }
private getTrackerRegExp(i: number): string { private getTrackerRegExp(i: number): string {
return this.modalProps.issueTrackers[i].bugId; return this.modalProps.issueTrackers[i].regex;
} }
private onTrackerRegExpEdit(e: string, i: number): void { private onTrackerRegExpEdit(e: string, i: number): void {
this.modalProps.issueTrackers[i].bugId = e; this.modalProps.issueTrackers[i].regex = e;
} }
private getColor(category: any): string { private getColor(category: any): string {
@ -179,7 +181,7 @@ export class BoardAdmin {
return category.defaultColor; return category.defaultColor;
} }
private showModal(title: string): void { private showModal(title: string, board?: Board): void {
let isAdd = (title === 'Add'); let isAdd = (title === 'Add');
this.modalProps = new BoardData(title); this.modalProps = new BoardData(title);
@ -189,10 +191,19 @@ export class BoardAdmin {
user.selected = false; user.selected = false;
}); });
} else { } else {
// TODO: Load board data in constructor this.modalProps.boardName = board.name;
this.modalProps.columns = board.columns;
this.modalProps.categories = board.categories;
this.modalProps.issueTrackers = board.issue_trackers;
this.modalProps.users = board.users;
} }
this.modal.open(this.MODAL_ID); this.modal.open(this.MODAL_ID);
} }
private showConfirmModal(board: Board): void {
this.boardToRemove = board;
this.modal.open(this.MODAL_CONFIRM_ID);
}
} }

View File

@ -59,7 +59,7 @@ export class BoardData {
this.issueTrackers.push({ this.issueTrackers.push({
url: this.issueTrackerUrl, url: this.issueTrackerUrl,
bugId: this.issueTrackerBugId regex: this.issueTrackerBugId
}); });
this.issueTrackerUrl = ''; this.issueTrackerUrl = '';
this.issueTrackerBugId = ''; this.issueTrackerBugId = '';

View File

@ -1,7 +1,10 @@
<div [hidden]="!isOpen"> <div class="modal-container" [ngClass]="{ 'modal-open': isOpen }">
<div class="modal-overlay" (click)="close(true)"></div> <div class="modal-overlay"
[ngClass]="{ animated: animate, 'modal-closed': !isOpen }"
(click)="close(true)"></div>
<div class="modal" [ngClass]="{ wide: wide }"> <div class="modal"
[ngClass]="{ wide: wide, animated: animate, 'modal-closed': !isOpen }">
<div class="title" *ngIf="modalTitle"> <div class="title" *ngIf="modalTitle">
<h2> <h2>
{{ modalTitle }} {{ modalTitle }}

View File

@ -16,7 +16,9 @@ export class Modal implements OnInit {
@Input('modal-title') modalTitle = ''; @Input('modal-title') modalTitle = '';
@Input() blocking = false; @Input() blocking = false;
@Input() wide = false; @Input() wide = false;
isOpen = false; isOpen = false;
animate = true;
constructor(private modalService: ModalService) { constructor(private modalService: ModalService) {
} }

View File

@ -1,13 +1,16 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AuthService, UserOptions } from '../index';
import { Modal } from './modal.component'; import { Modal } from './modal.component';
@Injectable() @Injectable()
export class ModalService { export class ModalService {
private modals: Array<Modal>; private modals: Array<Modal>;
private userOptions: UserOptions;
constructor() { constructor(private auth: AuthService) {
this.modals = []; this.modals = [];
this.userOptions = auth.userOptions;
} }
registerModal(newModal: Modal): void { registerModal(newModal: Modal): void {
@ -25,6 +28,7 @@ export class ModalService {
var modal = this.findModal(modalId); var modal = this.findModal(modalId);
if (modal) { if (modal) {
modal.animate = this.userOptions.show_animations;
modal.isOpen = true; modal.isOpen = true;
} }
} }

View File

@ -1,3 +1,11 @@
.modal-container {
visibility: hidden;
&.modal-open {
visibility: visible;
}
}
.modal-overlay { .modal-overlay {
background-color: rgba(0, 0, 0, .4); background-color: rgba(0, 0, 0, .4);
bottom: 0; bottom: 0;
@ -6,27 +14,45 @@
right: 0; right: 0;
top: 0; top: 0;
z-index: 1000; z-index: 1000;
&.animated {
transition: all .3s;
}
&.modal-closed {
opacity: 0;
}
} }
.modal { .modal {
@include shadow-float(); @include shadow-float();
background-color: $white; background-color: $white;
left: calc(50% - 200px); left: 50%;
max-height: calc(100% - 10em); max-height: calc(100% - 10em);
max-width: 100%; max-width: 100%;
min-height: 10em; min-height: 10em;
overflow-y: auto; overflow-y: auto;
position: fixed; position: fixed;
top: 5em; top: 50%;
transform: translateX(-50%) translateY(-50%) translateZ(0);
width: 400px; width: 400px;
z-index: 1100; z-index: 1100;
-webkit-font-smoothing: subpixel-antialiased;
&.animated {
transition: all .3s;
}
&.wide { &.wide {
left: calc(50% - 300px);
width: 600px; width: 600px;
} }
&.modal-closed {
opacity: 0;
transform: translateX(-50%) translateY(-100%);
}
.title { .title {
background-color: $color-heading-bg; background-color: $color-heading-bg;

View File

@ -231,6 +231,10 @@
} }
} }
tbody label {
display: inline;
}
.filters { .filters {
margin-top: -2.5em; margin-top: -2.5em;
max-width: 75%; max-width: 75%;